diff --git "a/data/train/java-003.jsonl" "b/data/train/java-003.jsonl" new file mode 100644--- /dev/null +++ "b/data/train/java-003.jsonl" @@ -0,0 +1,605 @@ +{"question_id": 2108, "task_id": "find-first-palindromic-string-in-the-array", "difficulty": "Easy", "problem_description": "Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string \"\".\nA string is palindromic if it reads the same forward and backward.\n \nExample 1:\n\nInput: words = [\"abc\",\"car\",\"ada\",\"racecar\",\"cool\"]\nOutput: \"ada\"\nExplanation: The first string that is palindromic is \"ada\".\nNote that \"racecar\" is also palindromic, but it is not the first.\n\nExample 2:\n\nInput: words = [\"notapalindrome\",\"racecar\"]\nOutput: \"racecar\"\nExplanation: The first and only string that is palindromic is \"racecar\".\n\nExample 3:\n\nInput: words = [\"def\",\"ghi\"]\nOutput: \"\"\nExplanation: There are no palindromic strings, so the empty string is returned.\n\n \nConstraints:\n\n1 <= words.length <= 100\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 = ['hello', 'world', 'python', 'madam']) == \"madam\"\n assert candidate(words = ['hello', 'world', 'python']) == \"\"\n assert candidate(words = ['abba', 'abcba', 'abcdedcba', 'nonpalindrome']) == \"abba\"\n assert candidate(words = ['level', 'deified', 'civic', 'rotor']) == \"level\"\n assert candidate(words = ['abccba', 'def', 'ghi', 'jklmnoponmlkj']) == \"abccba\"\n assert candidate(words = ['abc', 'car', 'ada', 'racecar', 'cool']) == \"ada\"\n assert candidate(words = ['madam', 'refer', 'level', 'world']) == \"madam\"\n assert candidate(words = ['madam', 'racecar', 'refer', 'deed', 'peep', 'noon']) == \"madam\"\n assert candidate(words = ['reviled', 'civic', 'rotor', 'redder', 'repaper', 'deed']) == \"civic\"\n assert candidate(words = ['a', 'b', 'c', 'd', 'e']) == \"a\"\n assert candidate(words = ['a', 'b', 'c']) == \"a\"\n assert candidate(words = ['racecar', 'ada', 'cool', 'abc']) == \"racecar\"\n assert candidate(words = ['noon', 'level', 'deified', 'rotor', 'redder']) == \"noon\"\n assert candidate(words = ['notapalindrome', 'racecar']) == \"racecar\"\n assert candidate(words = ['Was', 'it', 'a', 'car', 'or', 'a', 'cat', 'I', 'saw']) == \"a\"\n assert candidate(words = ['racecar', 'car', 'level']) == \"racecar\"\n assert candidate(words = ['noon', 'moon', 'refer', 'deed']) == \"noon\"\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst']) == \"\"\n assert candidate(words = ['madam', 'refer', 'deed', 'peep', 'level']) == \"madam\"\n assert candidate(words = ['abacaba', 'racecar', 'kayak', 'detartrated', 'repaper']) == \"abacaba\"\n assert candidate(words = ['hello', 'world', 'python', 'programming']) == \"\"\n assert candidate(words = ['level', 'deified', 'civic', 'rotor', 'kayak', 'reviled']) == \"level\"\n assert candidate(words = ['noon', 'level', 'world', 'deified']) == \"noon\"\n assert candidate(words = ['abccba', 'defed', 'ghi', 'jkllkj']) == \"abccba\"\n assert candidate(words = ['def', 'ghi']) == \"\"\n assert candidate(words = ['noon', 'civic', 'rotor', 'deified']) == \"noon\"\n assert candidate(words = ['abcba', 'xyz', 'madam', 'noon']) == \"abcba\"\n assert candidate(words = ['step', 'on', 'no', 'pets']) == \"\"\n assert candidate(words = ['noon', 'racecar', 'kayak', 'reviled', 'civic', 'madam', 'refer', 'deed', 'detartrated', 'repaper']) == \"noon\"\n assert candidate(words = ['notapalindrome', 'almostapalindrome', 'palindromebutnot', 'thisisnotapalindrome', 'palindromic', 'palindrome', 'palindromes', 'palindromicly']) == \"\"\n assert candidate(words = ['abba', 'acca', 'adda', 'aedd', 'aeeea', 'aeeeea', 'aeeeeea', 'aeeeeeea']) == \"abba\"\n assert candidate(words = ['algorithm', 'datastructure', 'python', 'java', 'csharp', 'javascript', 'typescript', 'ruby', 'swift', 'kotlin']) == \"\"\n assert candidate(words = ['notapalindrome', 'stillnotapalindrome', 'palindrome', 'palindromic', 'racecar', 'noon', 'level']) == \"racecar\"\n assert candidate(words = ['a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff', 'ggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjjjj']) == \"a\"\n assert candidate(words = ['abccba', 'defed', 'fedcbafedcba', 'zxyzyx', 'mnoponm', 'qwertyytrewq', 'poiuytghjklkjhgfdsapoiuytrewq']) == \"abccba\"\n assert candidate(words = ['racecar', 'level', 'civic', 'rotor', 'deified', 'repaper', 'reviver', 'rotator']) == \"racecar\"\n assert candidate(words = ['nonpalindrome', 'notapalindrome', 'neverpalindrome', 'nopalin', 'palindromeisnothere', 'stillnotapalindrome']) == \"\"\n assert candidate(words = ['racecar', 'refer', 'reviler', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'ananab', 'banana', 'anana', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'racecar']) == \"racecar\"\n assert candidate(words = ['noon', 'civic', 'rotor', 'deed', 'peep', 'reed']) == \"noon\"\n assert candidate(words = ['x', 'y', 'z', 'aa', 'bb', 'cc', 'aaa', 'bbb', 'ccc', 'aaaa', 'bbbb', 'cccc', 'abcba', 'abccba', 'abba', 'racecar', 'madam', 'refer', 'deed', 'peep']) == \"x\"\n assert candidate(words = ['nonpalindromic', 'string', 'without', 'any', 'palindrome', 'here']) == \"\"\n assert candidate(words = ['deed', 'peep', 'noon', 'radar', 'repaper', 'reviver', 'rotator']) == \"deed\"\n assert candidate(words = ['racecar', 'deified', 'civic', 'rotor', 'level', 'repaper', 'rotor', 'reviled', 'detartrated', 'redivider', 'deed', 'peep', 'radar', 'redder', 'refer', 'rotator', 'reviver', 'rotor', 'racecar', 'madam', 'refer', 'racecar', 'deified', 'civic', 'rotor', 'level', 'repaper', 'rotor', 'reviled', 'detartrated', 'redivider', 'deed', 'peep', 'radar', 'redder', 'refer', 'rotator', 'reviver', 'rotor', 'racecar', 'madam', 'refer', 'racecar', 'deified', 'civic', 'rotor', 'level', 'repaper', 'rotor', 'reviled', 'detartrated', 'redivider', 'deed', 'peep', 'radar', 'redder', 'refer', 'rotator', 'reviver', 'rotor', 'racecar', 'madam', 'refer']) == \"racecar\"\n assert candidate(words = ['aabbccdd', 'ddccbbaa', 'abcdeedcba', 'abcdefghihgfedcba', 'abcdefghijkjihgfedcba', 'abcdefghijllkjihgfedcba', 'abcdefghijllkjihgfedcbaf', 'mnopqrstsrqponm']) == \"abcdeedcba\"\n assert candidate(words = ['a', 'bb', 'ccc', 'dddd', 'eeeee']) == \"a\"\n assert candidate(words = ['xylophone', 'guitar', 'piano', 'violin', 'flute', 'saxophone', 'trombone', 'trumpet', 'harp', 'xylophone', 'guitar', 'piano', 'violin', 'flute', 'saxophone', 'trombone', 'trumpet', 'harp', 'a', 'ab', 'aba', 'abcba', 'abcdedcba', 'abcdecba', 'abba', 'abcba']) == \"a\"\n assert candidate(words = ['racecar', 'refer', 'deed', 'peep', 'wow', 'madam', 'rotor', 'level']) == \"racecar\"\n assert candidate(words = ['zzzzzzzz', 'zzzyzzzz', 'zzzyyzzz', 'zzzyyyzz', 'zzzyyyyzzz', 'zzzyyyyyzzzz', 'zzzyyyyyyzzzzz']) == \"zzzzzzzz\"\n assert candidate(words = ['notapalindrome', 'noon', 'racecar', 'rotor', 'notapalindrome', 'reviled', 'detartrated', 'redivider', 'notapalindrome', 'deed', 'peep', 'radar', 'redder', 'refer', 'rotator', 'reviver', 'rotor', 'racecar', 'madam', 'refer', 'notapalindrome']) == \"noon\"\n assert candidate(words = ['noon', 'level', 'rotor', 'deified', 'civic', 'radar']) == \"noon\"\n assert candidate(words = ['abcdcba', 'dcba', 'efgh', 'hgef', 'ijkl', 'lkji', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvw', 'wvu', 'xyz', 'zyx', 'racecar', 'level', 'deified', 'rotor', 'deed', 'peep', 'wow', 'civic', 'radar', 'refer', 'detartrated', 'repaper']) == \"abcdcba\"\n assert candidate(words = ['this', 'is', 'not', 'a', 'palindrome', 'racecar', 'madam', 'refer', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'ananab', 'banana', 'anana', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'racecar']) == \"a\"\n assert candidate(words = ['repaper', 'deed', 'civic', 'level', 'rotor', 'kayak', 'racecar', 'reviled']) == \"repaper\"\n assert candidate(words = ['bobby', 'radar', 'level', 'rotor', 'deed', 'peep', 'wow', 'madam']) == \"radar\"\n assert candidate(words = ['abccba', 'abcde', 'fghij', 'klmno', 'pqrst', 'xyzzyx', 'mnopqr', 'stuvuts']) == \"abccba\"\n assert candidate(words = ['abccba', 'bcb', 'a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff', 'ggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjjjj']) == \"abccba\"\n assert candidate(words = ['abcdedcba', 'abcdecba', 'abba', 'abcba', 'a', 'ab', 'aba', 'noon', 'civic', 'rotor', 'level', 'deified', 'redivider', 'detartrated', 'deed', 'peep', 'racecar', 'refer', 'reviler', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'ananab', 'banana', 'anana', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'racecar']) == \"abcdedcba\"\n assert candidate(words = ['verylongpalindromesequenceeosuqeeqosuerosequencemosuqeeqoserev', 'nonpalindrome', 'anotherlongword', 'racecar', 'level', 'deified']) == \"racecar\"\n assert candidate(words = ['nonpalindrome', 'another', 'longwordthatshouldnotbeapalindrome', 'almostapalindromemordnilapalmo', 'racecar', 'noon']) == \"racecar\"\n assert candidate(words = ['aabbcc', 'racecar', 'level', 'noon', 'civic', 'rotor', 'kayak']) == \"racecar\"\n assert candidate(words = ['aabb', 'abba', 'abcba', 'abcdedcba', 'abcdeedcba', 'abcdefgfedcba', 'ghijklmnonmlkjihg', 'poiuytrewqmrewtuyiop']) == \"abba\"\n assert candidate(words = ['noon', 'civic', 'rotor', 'level', 'deified', 'redivider', 'detartrated', 'deed', 'peep', 'racecar', 'refer', 'reviler', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'ananab', 'banana', 'anana', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'racecar']) == \"noon\"\n assert candidate(words = ['abacaba', 'bcb', 'abcba', 'a', 'racecar', 'level', 'deified', 'rotor', 'deed', 'peep', 'wow', 'civic', 'radar', 'refer', 'detartrated', 'repaper']) == \"abacaba\"\n assert candidate(words = ['madam', 'refer', 'stats', 'civic', 'rotor', 'kayak']) == \"madam\"\n assert candidate(words = ['zxcvbnm', 'mnbvcxz', 'qwertyuiop', 'poiuytrewq', 'asdfghjkl', 'lkjhgfdsa', 'qwertyuiopasdfghjklzxcvbnm', 'mnbvcxzlkjhgfdsapoiuytrewq', 'noon', 'civic', 'rotor', 'level', 'deified', 'redivider', 'detartrated', 'deed', 'peep', 'racecar', 'refer', 'reviler', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'ananab', 'banana', 'anana', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'racecar']) == \"noon\"\n assert candidate(words = ['madam', 'refer', 'deed', 'peep', 'reed', 'level', 'deified', 'repaper', 'deed', 'wow', 'did', 'civic', 'rotor', 'kayak', 'reviled', 'redder', 'repaper', 'peep', 'deed', 'madam', 'refer', 'civic', 'rotor', 'kayak', 'reviled']) == \"madam\"\n assert candidate(words = ['no', 'on', 'civic', 'rotor', 'deed', 'peep', 'noon', 'radar', 'racecar', 'redder', 'repaper', 'level', 'deified']) == \"civic\"\n assert candidate(words = ['level', 'deified', 'civic', 'rotor', 'refer', 'deed', 'peep', 'wow', 'madam']) == \"level\"\n assert candidate(words = ['xylophone', 'keyboard', 'guitar', 'piano', 'violin', 'flute', 'drums', 'harp', 'saxophone', 'trumpet']) == \"\"\n assert candidate(words = ['xylophone', 'guitar', 'piano', 'drums', 'violin', 'harp', 'flute', 'trumpet']) == \"\"\n assert candidate(words = ['a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff']) == \"a\"\n assert candidate(words = ['aabb', 'bbcc', 'ccdd', 'ddeeff', 'ffeeggee', 'hhiijjkk', 'llmmnnoopp', 'qqrrssttuuvvww', 'xxxyyyyzzzz']) == \"\"\n assert candidate(words = ['racecar', 'refer', 'deified', 'civic', 'level', 'rotor', 'kayak', 'reviled', 'deed', 'noon', 'madam', 'repaper', 'elppa', 'stuvuts', 'xyzzyx']) == \"racecar\"\n assert candidate(words = ['noon', 'level', 'deified', 'rotor', 'repaper', 'reviled', 'detartrated', 'redivider', 'deed', 'peep', 'radar', 'redder', 'refer', 'rotator', 'reviver', 'rotor', 'racecar', 'madam', 'refer']) == \"noon\"\n assert candidate(words = ['12321', '1234321', '123454321', '12345654321', '1234567654321', '123456787654321', '12345678987654321', '1234567890987654321', '123456789010987654321', '12345678901210987654321', '1234567890123210987654321']) == \"12321\"\n assert candidate(words = ['qwerty', 'asdfgh', 'zxcvbn', 'police', 'museum', 'kayak']) == \"kayak\"\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'abcba', 'abccba', 'abcdcba', 'abcdeba', 'abcdefedcba', 'abcdeedcba']) == \"a\"\n assert candidate(words = ['ab', 'aba', 'abcba', 'abcdedcba', 'abcdeedcba', 'abcdefgfedcba']) == \"aba\"\n assert candidate(words = ['banana', 'ananab', 'mango', 'orange', 'grape', 'apple', 'elppa']) == \"\"\n assert candidate(words = ['noon', 'level', 'civic', 'rotor', 'deified', 'repaper', 'reviver', 'rotator', 'a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff', 'ggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjjjj']) == \"noon\"\n assert candidate(words = ['xyzzyx', 'xyzyx', 'xyx', 'xx', 'x', 'aaa', 'abba', 'abcba', 'abcdedcba', 'abcdefghihgfedcba']) == \"xyzzyx\"\n assert candidate(words = ['madam', 'refer', 'level', 'deified', 'rotor', 'kayak', 'reviled', 'rotor', 'redder', 'repaper']) == \"madam\"\n assert candidate(words = ['aaaaaaaa', 'abccba', 'abcddcba', 'abcdedcba', 'abcdefghihgfedcba', 'abcdefghgfedcba', 'abcdeffedcba']) == \"aaaaaaaa\"\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\"\n assert candidate(words = ['abba', 'acca', 'adca', 'aeia', 'afda', 'agga']) == \"abba\"\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz']) == \"a\"\n assert candidate(words = ['abcdeedcba', 'fghihgf', 'jklmlkj', 'nopon', 'qrsrstq', 'tuvut', 'xyzzyx', 'abcdedcba', 'fghigfh', 'jklkjl', 'mnoponm', 'qrstsrq', 'tuvutuv', 'xyzyx', 'abccba', 'madam', 'refer', 'noon', 'peep', 'deed', 'racecar', 'repaper', 'redder']) == \"abcdeedcba\"\n assert candidate(words = ['level', 'deified', 'civic', 'rotor', 'kayak', 'madam', 'racecar', 'refer', 'reviled']) == \"level\"\n assert candidate(words = ['aabbcc', 'baccab', 'racecar', 'madam', 'refer', 'reviler', 'repaper', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'rotor', 'refer', 'reviler', 'repaper', 'rotor', 'level', 'kayak', 'stats']) == \"baccab\"\n assert candidate(words = ['notapalindrome', 'almostapalindrome', 'palindromebutnot', 'thisisnotapalindrome', 'palindromic', 'palindrome', 'palindromes', 'palindromicly', 'a', 'aa', 'aaa', 'aaaa', 'abcba', 'abccba', 'abcdcba', 'abcdeba', 'abcdefedcba', 'abcdeedcba']) == \"a\"\n assert candidate(words = ['anana', 'banana', 'ananab', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats']) == \"anana\"\n assert candidate(words = ['abccba', 'defg', 'hijklm', 'nopqrst', 'uvwxyz']) == \"abccba\"\n assert candidate(words = ['deified', 'repaper', 'detartrated', 'reviled', 'redder', 'repaid', 'deed']) == \"deified\"\n assert candidate(words = ['aabbccddeeff', 'ffeeddccbbaa', 'abcdefedcba', 'abcdefgihgfedcba', 'abcdefghijkjihgfedcba', 'abcdefghijllkjihgfedcba', 'abcdefghijllkjihgfedcbaf']) == \"abcdefedcba\"\n assert candidate(words = ['abac', 'abcba', 'abccba', 'abcdedcba', 'abcdeedcba', 'abcdeedcbaf', 'abcdeedcba', 'abcdefedcbaf', 'abcdefedcba', 'abcdefgihgfedcba', 'abcdefghihgfedcba', 'abcdefghihgfedcba123']) == \"abcba\"\n assert candidate(words = ['thisisnotapalindrome', 'neitheristhis', 'butthisoneis', 'civic', 'rotor', 'madam', 'refer', 'noon', 'deed', 'racecar', 'repaper', 'redder', 'level', 'deified', 'abccba', 'abcba', 'abba', 'baab', 'abcdedcba', 'fghigfh', 'jklkjl', 'mnoponm', 'qrstsrq', 'tuvutuv', 'xyzyx']) == \"civic\"\n assert candidate(words = ['noon', 'level', 'deified', 'rotor', 'reviled']) == \"noon\"\n assert candidate(words = ['level', 'deified', 'rotor', 'redder', 'repaper', 'deed', 'peep', 'wow', 'civic', 'radar']) == \"level\"\n assert candidate(words = ['madam', 'refer', 'level', 'deified', 'rotor', 'reviled']) == \"madam\"\n assert candidate(words = ['deified', 'level', 'civic', 'rotor', 'kayak', 'reviled', 'madam', 'refer', 'noon', 'peep', 'redder', 'repaper', 'racecar', 'deed']) == \"deified\"\n assert candidate(words = ['aabb', 'bbaa', 'abba', 'baab', 'abcba', 'abccba', 'madam', 'refer', 'noon', 'deed', 'racecar', 'repaper', 'redder', 'civic', 'rotor', 'kayak', 'reviled', 'deified', 'level', 'rotor', 'redder', 'repaper', 'level', 'deified']) == \"abba\"\n assert candidate(words = ['xylophone', 'guitar', 'piano', 'drums', 'flute', 'violin', 'harp']) == \"\"\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'hgef', 'ijkl', 'lkji', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvw', 'wvu', 'xyz', 'zyx']) == \"\"\n assert candidate(words = ['noon', 'civic', 'rotor', 'level', 'deified', 'redivider', 'detartrated', 'deed', 'peep', 'racecar']) == \"noon\"\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().firstPalindrome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String firstPalindrome(String[] words) {", "container": "Solution", "callable": "firstPalindrome", "parameters": [{"name": "words", "type": "String[]"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2109, "task_id": "adding-spaces-to-a-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.\n\nFor example, given s = \"EnjoyYourCoffee\" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain \"Enjoy Your Coffee\".\n\nReturn the modified string after the spaces have been added.\n \nExample 1:\n\nInput: s = \"LeetcodeHelpsMeLearn\", spaces = [8,13,15]\nOutput: \"Leetcode Helps Me Learn\"\nExplanation: \nThe indices 8, 13, and 15 correspond to the underlined characters in \"LeetcodeHelpsMeLearn\".\nWe then place spaces before those characters.\n\nExample 2:\n\nInput: s = \"icodeinpython\", spaces = [1,5,7,9]\nOutput: \"i code in py thon\"\nExplanation:\nThe indices 1, 5, 7, and 9 correspond to the underlined characters in \"icodeinpython\".\nWe then place spaces before those characters.\n\nExample 3:\n\nInput: s = \"spacing\", spaces = [0,1,2,3,4,5,6]\nOutput: \" s p a c i n g\"\nExplanation:\nWe are also able to place spaces before the first character of the string.\n\n \nConstraints:\n\n1 <= s.length <= 3 * 105\ns consists only of lowercase and uppercase English letters.\n1 <= spaces.length <= 3 * 105\n0 <= spaces[i] <= s.length - 1\nAll the values of spaces are strictly increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"spacing\",spaces = [0, 1, 2, 3, 4, 5, 6]) == \" s p a c i n g\"\n assert candidate(s = \"NoSpacesHere\",spaces = []) == \"NoSpacesHere\"\n assert candidate(s = \"icodeinpython\",spaces = [1, 5, 7, 9]) == \"i code in py thon\"\n assert candidate(s = \"A\",spaces = [0]) == \" A\"\n assert candidate(s = \"NoSpace\",spaces = []) == \"NoSpace\"\n assert candidate(s = \"icodeinpython\",spaces = [1, 5, 7, 9]) == \"i code in py thon\"\n assert candidate(s = \"InsertSpacesEverywhere\",spaces = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20]) == \"I n s e r t S p a c e s E v e r yw h e re\"\n assert candidate(s = \"LeetcodeHelpsMeLearn\",spaces = [8, 13, 15]) == \"Leetcode Helps Me Learn\"\n assert candidate(s = \"spacing\",spaces = [0, 1, 2, 3, 4, 5, 6]) == \" s p a c i n g\"\n assert candidate(s = \"PythonProgramming\",spaces = [6]) == \"Python Programming\"\n assert candidate(s = \"LeetcodeHelpsMeLearn\",spaces = [8, 13, 15]) == \"Leetcode Helps Me Learn\"\n assert candidate(s = \"AlibabaCloudisAmazing\",spaces = [7, 13, 19]) == \"Alibaba Cloudi sAmazi ng\"\n assert candidate(s = \"AugmentedReality\",spaces = [8, 14]) == \"Augmente dReali ty\"\n assert candidate(s = \"OperatingSystems\",spaces = [7, 19]) == \"Operati ngSystems\"\n assert candidate(s = \"ParallelAndDistributedComputing\",spaces = [8, 26]) == \"Parallel AndDistributedComp uting\"\n assert candidate(s = \"Short\",spaces = [1, 2]) == \"S h ort\"\n assert candidate(s = \"DataScienceAndMachineLearning\",spaces = [4, 13, 18, 29]) == \"Data ScienceAn dMach ineLearning\"\n assert candidate(s = \"NaturalLanguageProcessing\",spaces = [7, 18, 28]) == \"Natural LanguagePro cessing\"\n assert candidate(s = \"EmbeddedSystems\",spaces = [7, 17]) == \"Embedde dSystems\"\n assert candidate(s = \"InsertSpacesHere\",spaces = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == \"I n s e r t S p a c e sHere\"\n assert candidate(s = \"NoSpaceHere\",spaces = []) == \"NoSpaceHere\"\n assert candidate(s = \"SpacesAtEnd\",spaces = [9, 10, 11]) == \"SpacesAtE n d\"\n assert candidate(s = \"AlgorithmDesignAndAnalysis\",spaces = [9, 18, 22]) == \"Algorithm DesignAnd Anal ysis\"\n assert candidate(s = \"ParallelProcessing\",spaces = [8, 19]) == \"Parallel Processing\"\n assert candidate(s = \"CyberSecurity\",spaces = [5, 14]) == \"Cyber Security\"\n assert candidate(s = \"InformationSecurity\",spaces = [16]) == \"InformationSecur ity\"\n assert candidate(s = \"Multiple Spaces\",spaces = [8, 9, 10, 11]) == \"Multiple Spaces\"\n assert candidate(s = \"DeepLearningFrameworks\",spaces = [4, 12, 18, 25]) == \"Deep Learning Framew orks\"\n assert candidate(s = \"ComputerNetworking\",spaces = [13]) == \"ComputerNetwo rking\"\n assert candidate(s = \"HelloWorldFromPython\",spaces = [5, 11, 15]) == \"Hello WorldF romP ython\"\n assert candidate(s = \"OneTwoThreeFourFiveSixSevenEightNineTen\",spaces = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == \"One Two Thr eeF our Fiv eSi xSe ven Eig htNineTen\"\n assert candidate(s = \"EndWithSpaces\",spaces = [10, 11, 12]) == \"EndWithSpa c e s\"\n assert candidate(s = \"ArtificialIntelligence\",spaces = [10, 24]) == \"Artificial Intelligence\"\n assert candidate(s = \"ComplexDataStructures\",spaces = [7, 14, 22, 29]) == \"Complex DataStr uctures\"\n assert candidate(s = \"QuantumComputing\",spaces = [7, 19]) == \"Quantum Computing\"\n assert candidate(s = \"MultipleSpacesInARow\",spaces = [12, 13, 14, 15]) == \"MultipleSpac e s I nARow\"\n assert candidate(s = \"ZebraCrossing\",spaces = [5, 10]) == \"Zebra Cross ing\"\n assert candidate(s = \"abcdefghij\",spaces = [1, 3, 5, 7, 9]) == \"a bc de fg hi j\"\n assert candidate(s = \"ProgrammingLanguages\",spaces = [2, 5, 12, 18, 21]) == \"Pr ogr ammingL anguag es\"\n assert candidate(s = \"HumanComputerInteraction\",spaces = [12, 30]) == \"HumanCompute rInteraction\"\n assert candidate(s = \"QuantumComputing\",spaces = [7, 16]) == \"Quantum Computing\"\n assert candidate(s = \"BlockchainTechnology\",spaces = [9, 18]) == \"Blockchai nTechnolo gy\"\n assert candidate(s = \"BoundaryEdgeCases\",spaces = [0, 14]) == \" BoundaryEdgeCa ses\"\n assert candidate(s = \"SingleWord\",spaces = [10]) == \"SingleWord\"\n assert candidate(s = \"ThisIsATestStringForComplexInputs\",spaces = [4, 7, 10, 13, 17, 21, 26, 31, 34]) == \"This IsA Tes tSt ring ForC omple xInpu ts\"\n assert candidate(s = \"ComplexPattern\",spaces = [1, 3, 5, 7, 9, 11]) == \"C om pl ex Pa tt ern\"\n assert candidate(s = \"aVeryLongStringWithoutSpacesThatNeedsSpacesInserted\",spaces = [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]) == \"a Ve ry Lo ng St ri ng Wi th ou tS pa ce sT ha tN ee ds Sp ac es In se rt ed\"\n assert candidate(s = \"ThisIsAVeryLongStringWithoutSpaces\",spaces = [4, 8, 12, 17, 21, 27, 32]) == \"This IsAV eryL ongSt ring Withou tSpac es\"\n assert candidate(s = \"ComputerVision\",spaces = [12]) == \"ComputerVisi on\"\n assert candidate(s = \"ThisIsAVeryLongStringWithSeveralSpacesNeeded\",spaces = [4, 7, 11, 15, 20, 25, 30, 35, 40, 45, 50]) == \"This IsA Very Long Strin gWith Sever alSpa cesNe eded\"\n assert candidate(s = \"VirtualReality\",spaces = [7, 13]) == \"Virtual Realit y\"\n assert candidate(s = \"AnotherExampleWithLongerWords\",spaces = [8, 19, 29]) == \"AnotherE xampleWithL ongerWords\"\n assert candidate(s = \"MultipleConsecutiveSpaces\",spaces = [7, 8, 9, 10, 11]) == \"Multipl e C o n secutiveSpaces\"\n assert candidate(s = \"OneBigSpaceInTheMiddle\",spaces = [10]) == \"OneBigSpac eInTheMiddle\"\n assert candidate(s = \"CloudComputingServices\",spaces = [5, 14, 21]) == \"Cloud Computing Service s\"\n assert candidate(s = \"MultipleSpaces\",spaces = [2, 5, 8, 11]) == \"Mu lti ple Spa ces\"\n assert candidate(s = \"InformationRetrieval\",spaces = [12, 27]) == \"InformationR etrieval\"\n assert candidate(s = \"VeryLongStringForTestingPurposes\",spaces = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56]) == \"Very Long Stri ngFo rTes ting Purp oses\"\n assert candidate(s = \"TestStringWithSeveralSpaces\",spaces = [4, 8, 12, 16, 20, 24]) == \"Test Stri ngWi thSe vera lSpa ces\"\n assert candidate(s = \"SpecialCharacters!@#\",spaces = [7, 8, 9]) == \"Special C h aracters!@#\"\n assert candidate(s = \"mixedCASEStringWithSPACES\",spaces = [6, 10, 17, 22, 29, 34]) == \"mixedC ASES tringWi thSPA CES\"\n assert candidate(s = \"EdgeCase\",spaces = [0, 8]) == \" EdgeCase\"\n assert candidate(s = \"AdvancedAlgorithmDesign\",spaces = [7, 21]) == \"Advance dAlgorithmDesi gn\"\n assert candidate(s = \"CompilersAndInterpreters\",spaces = [9, 26]) == \"Compilers AndInterpreters\"\n assert candidate(s = \"ComplexExampleString\",spaces = [7, 13, 18, 22]) == \"Complex Exampl eStri ng\"\n assert candidate(s = \"ComplexScenarioWithLongWord\",spaces = [7, 15, 23, 31]) == \"Complex Scenario WithLong Word\"\n assert candidate(s = \"NaturalLanguageProcessing\",spaces = [11, 21]) == \"NaturalLang uageProces sing\"\n assert candidate(s = \"AnotherExample\",spaces = [2, 6, 10, 14]) == \"An othe rExa mple\"\n assert candidate(s = \"SoftwareEngineering\",spaces = [8, 21]) == \"Software Engineering\"\n assert candidate(s = \"MachineLearning\",spaces = [7, 16]) == \"Machine Learning\"\n assert candidate(s = \"NeuralNetworks\",spaces = [6, 13]) == \"Neural Network s\"\n assert candidate(s = \"QuickBrownFox\",spaces = [5, 11]) == \"Quick BrownF ox\"\n assert candidate(s = \"SingleCharacter\",spaces = [0]) == \" SingleCharacter\"\n assert candidate(s = \"InternetOfThings\",spaces = [8, 13, 15]) == \"Internet OfThi ng s\"\n assert candidate(s = \"WithALotOfSpaces\",spaces = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == \"Wi th AL ot Of Sp ac es\"\n assert candidate(s = \"HumanComputerInteraction\",spaces = [5, 16, 26]) == \"Human ComputerInt eraction\"\n assert candidate(s = \"ComplexExampleWithRandomSpaces\",spaces = [7, 14, 19, 26, 31, 37]) == \"Complex Example WithR andomSp aces\"\n assert candidate(s = \"EmbeddedSystems\",spaces = [9, 20]) == \"EmbeddedS ystems\"\n assert candidate(s = \"InternetOfThings\",spaces = [8, 14]) == \"Internet OfThin gs\"\n assert candidate(s = \"DataStructuresAndAlgorithms\",spaces = [4, 16, 23]) == \"Data StructuresAn dAlgori thms\"\n assert candidate(s = \"HighPerformanceComputing\",spaces = [17, 34]) == \"HighPerformanceCo mputing\"\n assert candidate(s = \"PythonIsFun\",spaces = [6, 8]) == \"Python Is Fun\"\n assert candidate(s = \"AddingSpacesEverywhere\",spaces = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == \"A dd in gS pa ce sE ve ry where\"\n assert candidate(s = \"SingleWord\",spaces = [5]) == \"Singl eWord\"\n assert candidate(s = \"BigDataAnalytics\",spaces = [3, 8, 16]) == \"Big DataA nalytics\"\n assert candidate(s = \"ReallyLongStringWithLotsOfSpaces\",spaces = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == \"Reall yLong Strin gWith LotsO fSpac es\"\n assert candidate(s = \"EdgeCasesAtTheEnd\",spaces = [13, 14, 15]) == \"EdgeCasesAtTh e E nd\"\n assert candidate(s = \"RoboticsEngineering\",spaces = [8, 17]) == \"Robotics Engineeri ng\"\n assert candidate(s = \"QwenIsPowerful\",spaces = [4, 8, 12]) == \"Qwen IsPo werf ul\"\n assert candidate(s = \"TheQuickBrownFoxJumpsOverTheLazyDog\",spaces = [3, 9, 15, 21, 25, 30, 34]) == \"The QuickB rownFo xJumps Over TheLa zyDo g\"\n assert candidate(s = \"AddingSpacesInAString\",spaces = [5, 12, 16]) == \"Addin gSpaces InAS tring\"\n assert candidate(s = \"SingleSpaceAtEnd\",spaces = [13]) == \"SingleSpaceAt End\"\n assert candidate(s = \"ProgrammingLanguages\",spaces = [11]) == \"Programming Languages\"\n assert candidate(s = \"OneWord\",spaces = [0]) == \" OneWord\"\n assert candidate(s = \"ConsecutiveSpaces\",spaces = [4, 5, 11, 12]) == \"Cons e cutive S paces\"\n assert candidate(s = \"aLongStringWithoutSpaces\",spaces = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == \"a L o n g S t r i n g W i t h o u t S p a ces\"\n assert candidate(s = \"RandomAccessMemory\",spaces = [6, 12, 19]) == \"Random Access Memory\"\n assert candidate(s = \"DatabaseSystems\",spaces = [10]) == \"DatabaseSy stems\"\n assert candidate(s = \"LongStringWithSpacesInsertedAtVariousPositions\",spaces = [4, 9, 14, 20, 26, 31, 37, 42, 48, 53]) == \"Long Strin gWith Spaces Insert edAtV arious Posit ions\"\n assert candidate(s = \"DistributedSystems\",spaces = [13]) == \"DistributedSy stems\"\n assert candidate(s = \"InsertMultipleSpaces\",spaces = [6, 12, 19, 25]) == \"Insert Multip leSpace s\"\n assert candidate(s = \"BlockChainTechnology\",spaces = [9, 18]) == \"BlockChai nTechnolo gy\"\n assert candidate(s = \"ComplexityTheory\",spaces = [8, 16]) == \"Complexi tyTheory\"\n assert candidate(s = \"Alphabet\",spaces = [1, 2, 3, 4, 5, 6]) == \"A l p h a b et\"\n assert candidate(s = \"a\",spaces = [0]) == \" a\"\n assert candidate(s = \"InsertingMultipleSpaces\",spaces = [9, 17, 25, 30, 36]) == \"Inserting Multiple Spaces\"\n assert candidate(s = \"AlibabaCloudServices\",spaces = [7, 18]) == \"Alibaba CloudServic es\"\n assert candidate(s = \"AlgorithmsAndDataStructures\",spaces = [10, 15, 20]) == \"Algorithms AndDa taStr uctures\"\n assert candidate(s = \"SoftwareEngineering\",spaces = [8, 19]) == \"Software Engineering\"\n assert candidate(s = \"DataScienceAndAnalytics\",spaces = [9, 14, 17, 26]) == \"DataScien ceAnd Ana lytics\"\n assert candidate(s = \"MultipleWords\",spaces = [5, 13]) == \"Multi pleWords\"\n assert candidate(s = \"MachineLearning\",spaces = [7, 18]) == \"Machine Learning\"\n assert candidate(s = \"TestEdgeCases\",spaces = [0, 4, 8, 12]) == \" Test Edge Case s\"\n assert candidate(s = \"OneSpaceAtTheEnd\",spaces = [16]) == \"OneSpaceAtTheEnd\"\n assert candidate(s = \"EdgeCasesHandled\",spaces = [0, 11, 13]) == \" EdgeCasesHa nd led\"\n assert candidate(s = \"CyberSecurity\",spaces = [10]) == \"CyberSecur ity\"\n assert candidate(s = \"StartWithSpaces\",spaces = [0, 1, 2]) == \" S t artWithSpaces\"\n assert candidate(s = \"ComputerVision\",spaces = [8, 13]) == \"Computer Visio n\"\n assert candidate(s = \"AlgorithmsAndDataStructures\",spaces = [9, 25, 36]) == \"Algorithm sAndDataStructur es\"\n assert candidate(s = \"NoSpaces\",spaces = []) == \"NoSpaces\"\n assert candidate(s = \"abcdefg\",spaces = [1, 2, 3, 4, 5, 6]) == \"a b c d e f g\"\n assert candidate(s = \"CloudComputing\",spaces = [5, 15]) == \"Cloud Computing\"\n assert candidate(s = \"OperatingSystems\",spaces = [12]) == \"OperatingSys tems\"\n assert candidate(s = \"ArtificialIntelligence\",spaces = [9, 19]) == \"Artificia lIntellige nce\"\n assert candidate(s = \"YetAnotherExample\",spaces = [3, 7, 12, 17]) == \"Yet Anot herEx ample\"\n assert candidate(s = \"BoundaryTestCases\",spaces = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == \" B o u n d a r y T e s t C a s e s\"\n assert candidate(s = \"AlgorithmsAndDataStructures\",spaces = [10, 15, 20, 25]) == \"Algorithms AndDa taStr uctur es\"\n"}, "metadata": {"canonical_parameter_names": ["s", "spaces"], "leetcode_dataset_entry_point": "Solution().addSpaces", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String addSpaces(String s, int[] spaces) {", "container": "Solution", "callable": "addSpaces", "parameters": [{"name": "s", "type": "String"}, {"name": "spaces", "type": "int[]"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2110, "task_id": "number-of-smooth-descent-periods-of-a-stock", "difficulty": "Medium", "problem_description": "You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day.\nA smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 1. The first day of the period is exempted from this rule.\nReturn the number of smooth descent periods.\n \nExample 1:\n\nInput: prices = [3,2,1,4]\nOutput: 7\nExplanation: There are 7 smooth descent periods:\n[3], [2], [1], [4], [3,2], [2,1], and [3,2,1]\nNote that a period with one day is a smooth descent period by the definition.\n\nExample 2:\n\nInput: prices = [8,6,7,7]\nOutput: 4\nExplanation: There are 4 smooth descent periods: [8], [6], [7], and [7]\nNote that [8,6] is not a smooth descent period as 8 - 6 ≠ 1.\n\nExample 3:\n\nInput: prices = [1]\nOutput: 1\nExplanation: There is 1 smooth descent period: [1]\n\n \nConstraints:\n\n1 <= prices.length <= 105\n1 <= prices[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(prices = [10, 9, 4, 3, 2, 1]) == 13\n assert candidate(prices = [3, 3, 3, 3, 3]) == 5\n assert candidate(prices = [100000, 99999, 99998, 99997, 99996, 99995]) == 21\n assert candidate(prices = [8, 6, 7, 7]) == 4\n assert candidate(prices = [1]) == 1\n assert candidate(prices = [10, 9, 10, 9, 8, 7, 8, 7, 6, 5]) == 23\n assert candidate(prices = [3, 3, 3, 3, 3, 3, 3]) == 7\n assert candidate(prices = [5, 4, 5, 4, 3, 2, 1]) == 18\n assert candidate(prices = [3, 2, 1, 4]) == 7\n assert candidate(prices = [1, 3, 2, 1, 4, 3, 2, 1]) == 17\n assert candidate(prices = [5, 4, 3, 4, 3, 2, 1]) == 16\n assert candidate(prices = [5]) == 1\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 55\n assert candidate(prices = [10, 9, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 51\n assert candidate(prices = [1, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 19\n assert candidate(prices = [5, 4, 3, 2, 1]) == 15\n assert candidate(prices = [1, 2, 3, 4, 5]) == 5\n assert candidate(prices = [10, 9, 8, 9, 8, 7, 6, 5, 6, 7]) == 23\n assert candidate(prices = [2, 1, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 37\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 65\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 36\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 66\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(prices = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 210\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 136\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(prices = [1, 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]) == 166\n assert candidate(prices = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == 135\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5]) == 76\n assert candidate(prices = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == 210\n assert candidate(prices = [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]) == 29\n assert candidate(prices = [3, 2, 1, 2, 1, 3, 2, 1, 2, 1, 3, 2, 1, 2, 1]) == 27\n assert candidate(prices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 28\n assert candidate(prices = [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]) == 465\n assert candidate(prices = [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, 2, 3, 4, 5]) == 60\n assert candidate(prices = [7, 6, 5, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]) == 73\n assert candidate(prices = [5, 4, 3, 4, 3, 2, 1, 0, 1, 0, -1, -2, -3]) == 36\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 6, 5, 4, 3, 2, 1]) == 42\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 64\n assert candidate(prices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 29\n assert candidate(prices = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 49990, 49989, 49988, 49987, 49986, 49985, 49984, 49983, 49982, 49981]) == 210\n assert candidate(prices = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 70\n assert candidate(prices = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == 210\n assert candidate(prices = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 41\n assert candidate(prices = [1, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2]) == 40\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 54\n assert candidate(prices = [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]) == 44\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(prices = [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]) == 325\n assert candidate(prices = [10, 9, 8, 10, 9, 8, 7, 6, 5, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(prices = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(prices = [10, 9, 8, 7, 10, 9, 8, 7, 6, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 86\n assert candidate(prices = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 33\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 75\n assert candidate(prices = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5]) == 37\n assert candidate(prices = [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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 170\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 19\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 64\n assert candidate(prices = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 496\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(prices = [7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 109\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 231\n assert candidate(prices = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 231\n assert candidate(prices = [10, 9, 8, 9, 8, 7, 8, 7, 6, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 60\n assert candidate(prices = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1]) == 38\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 136\n assert candidate(prices = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 49\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 110\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(prices = [10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 201\n assert candidate(prices = [10, 9, 8, 9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 5, 6, 7, 8, 9]) == 62\n assert candidate(prices = [10, 8, 6, 4, 2, 0, -2, -4, -6, -8, -10, 10, 8, 6, 4, 2, 0, -2, -4, -6, -8, -10]) == 22\n assert candidate(prices = [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(prices = [1, 2, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 19\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 19\n assert candidate(prices = [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]) == 80\n assert candidate(prices = [10, 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]) == 147\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 55\n assert candidate(prices = [1, 1, 1, 1, 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(prices = [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]) == 119\n assert candidate(prices = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4]) == 40\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 29\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 110\n assert candidate(prices = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 24\n assert candidate(prices = [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]) == 5050\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3]) == 22\n assert candidate(prices = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]) == 44\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 64\n assert candidate(prices = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20]) == 211\n assert candidate(prices = [5, 6, 5, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 41\n assert candidate(prices = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 210\n assert candidate(prices = [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]) == 69\n assert candidate(prices = [10, 9, 10, 9, 8, 7, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]) == 48\n assert candidate(prices = [3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 1, 0, -1, -2, -3]) == 45\n assert candidate(prices = [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]) == 81\n assert candidate(prices = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 66\n assert candidate(prices = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 14\n assert candidate(prices = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 35\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(prices = [3, 2, 1, 0, -1, -2, -3, -4, -5, -6]) == 55\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(prices = [5, 4, 3, 2, 1, 2, 1, 0, -1, -2, -1, 0, 1, 2, 1, 0, -1, -2, -1, 0]) == 50\n assert candidate(prices = [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]) == 325\n assert candidate(prices = [2, 1, 3, 2, 1, 0, 1, 2, 1, 0, -1]) == 24\n assert candidate(prices = [5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 26\n assert candidate(prices = [10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4]) == 70\n assert candidate(prices = [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, 0]) == 351\n assert candidate(prices = [5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 72\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 240\n assert candidate(prices = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 11\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(prices = [7, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 79\n assert candidate(prices = [3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 66\n assert candidate(prices = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(prices = [10, 9, 8, 7, 8, 7, 6, 5, 6, 5, 4, 3, 2, 1, 0, -1, -2]) == 65\n"}, "metadata": {"canonical_parameter_names": ["prices"], "leetcode_dataset_entry_point": "Solution().getDescentPeriods", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long getDescentPeriods(int[] prices) {", "container": "Solution", "callable": "getDescentPeriods", "parameters": [{"name": "prices", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2111, "task_id": "minimum-operations-to-make-the-array-k-increasing", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k.\nThe array arr is called K-increasing if arr[i-k] <= arr[i] holds for every index i, where k <= i <= n-1.\n\nFor example, arr = [4, 1, 5, 2, 6, 2] is K-increasing for k = 2 because:\n\n\t\narr[0] <= arr[2] (4 <= 5)\narr[1] <= arr[3] (1 <= 2)\narr[2] <= arr[4] (5 <= 6)\narr[3] <= arr[5] (2 <= 2)\n\n\nHowever, the same arr is not K-increasing for k = 1 (because arr[0] > arr[1]) or k = 3 (because arr[0] > arr[3]).\n\nIn one operation, you can choose an index i and change arr[i] into any positive integer.\nReturn the minimum number of operations required to make the array K-increasing for the given k.\n \nExample 1:\n\nInput: arr = [5,4,3,2,1], k = 1\nOutput: 4\nExplanation:\nFor k = 1, the resultant array has to be non-decreasing.\nSome of the K-increasing arrays that can be formed are [5,6,7,8,9], [1,1,1,1,1], [2,2,3,4,4]. All of them require 4 operations.\nIt is suboptimal to change the array to, for example, [6,7,8,9,10] because it would take 5 operations.\nIt can be shown that we cannot make the array K-increasing in less than 4 operations.\n\nExample 2:\n\nInput: arr = [4,1,5,2,6,2], k = 2\nOutput: 0\nExplanation:\nThis is the same example as the one in the problem description.\nHere, for every index i where 2 <= i <= 5, arr[i-2] <= arr[i].\nSince the given array is already K-increasing, we do not need to perform any operations.\nExample 3:\n\nInput: arr = [4,1,5,2,6,2], k = 3\nOutput: 2\nExplanation:\nIndices 3 and 5 are the only ones not satisfying arr[i-3] <= arr[i] for 3 <= i <= 5.\nOne of the ways we can make the array K-increasing is by changing arr[3] to 4 and arr[5] to 5.\nThe array will now be [4,1,5,4,6,5].\nNote that there can be other ways to make the array K-increasing, but none of them require less than 2 operations.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i], k <= arr.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 2, 2, 2, 2],k = 1) == 0\n assert candidate(arr = [1, 5, 9, 13, 17],k = 4) == 0\n assert candidate(arr = [4, 1, 5, 2, 6, 2],k = 3) == 2\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 0\n assert candidate(arr = [5, 3, 7, 1, 9, 2, 10, 4, 11, 6],k = 2) == 1\n assert candidate(arr = [6, 5, 4, 3, 2, 1],k = 2) == 4\n assert candidate(arr = [5, 4, 3, 2, 1],k = 1) == 4\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 0\n assert candidate(arr = [9, 7, 5, 3, 1],k = 2) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 2) == 0\n assert candidate(arr = [10, 9, 2, 5, 3, 7, 101, 18],k = 2) == 2\n assert candidate(arr = [5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(arr = [1, 3, 5, 7, 9],k = 2) == 0\n assert candidate(arr = [1, 2, 3, 4, 5],k = 1) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(arr = [7, 4, 2, 6, 3, 5, 1, 8],k = 3) == 3\n assert candidate(arr = [10, 9, 2, 5, 3, 7, 101, 18],k = 3) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1],k = 2) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n assert candidate(arr = [2, 2, 2, 2, 2],k = 5) == 0\n assert candidate(arr = [9, 4, 2, 3, 1, 5, 7, 8, 6, 10],k = 1) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 1) == 0\n assert candidate(arr = [4, 1, 5, 2, 6, 2],k = 2) == 0\n assert candidate(arr = [1, 3, 5, 7, 9],k = 3) == 0\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 0\n assert candidate(arr = [1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(arr = [5, 9, 4, 6, 7, 2, 8, 10, 3, 11],k = 2) == 4\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 3\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 15\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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) == 0\n assert candidate(arr = [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 = 5) == 20\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == 0\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],k = 2) == 9\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 3, 5, 7, 4, 6, 8],k = 2) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == 0\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 1) == 9\n assert candidate(arr = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60],k = 2) == 0\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 16\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 0\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == 0\n assert candidate(arr = [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(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 0\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == 26\n assert candidate(arr = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 2) == 0\n assert candidate(arr = [9, 7, 5, 3, 1, 10, 8, 6, 4, 2, 11],k = 5) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10],k = 5) == 7\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 8, 7, 9, 11, 10, 12, 14, 13, 15, 17, 16, 18, 20, 19, 21, 23, 22, 24, 26, 25, 27, 29, 28, 30, 32, 31, 33, 35, 34, 36, 38, 37, 39, 41, 40, 42, 44, 43, 45, 47, 46, 48, 50, 49],k = 3) == 0\n assert candidate(arr = [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 = 4) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 0\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],k = 10) == 5\n assert candidate(arr = [10, 15, 10, 20, 25, 20, 30, 35, 30, 40],k = 3) == 0\n assert candidate(arr = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4],k = 4) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(arr = [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) == 0\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],k = 5) == 4\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == 7\n assert candidate(arr = [50, 20, 30, 10, 40, 60, 50, 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],k = 10) == 0\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30],k = 3) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 4) == 4\n assert candidate(arr = [5, 3, 8, 6, 9, 7, 10, 12, 11, 15, 13, 16, 18, 14, 19, 20],k = 3) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 2) == 0\n assert candidate(arr = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],k = 5) == 0\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9],k = 3) == 3\n assert candidate(arr = [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 = 5) == 0\n assert candidate(arr = [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],k = 10) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 7\n assert candidate(arr = [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 = 3) == 27\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 0\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 1) == 0\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 3) == 0\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15],k = 3) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 0\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],k = 2) == 0\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 9\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 1) == 0\n assert candidate(arr = [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],k = 1) == 0\n assert candidate(arr = [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) == 0\n assert candidate(arr = [7, 4, 2, 6, 3, 5, 1, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 2) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],k = 2) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 2) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 0\n assert candidate(arr = [1, 3, 2, 4, 6, 5, 7, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20],k = 3) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 0\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 1) == 9\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 2) == 3\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 1) == 0\n assert candidate(arr = [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],k = 29) == 0\n assert candidate(arr = [5, 5, 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(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9],k = 1) == 12\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 2) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 6) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 0\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15],k = 1) == 9\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 2) == 0\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4],k = 5) == 9\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 14\n assert candidate(arr = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 1) == 9\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(arr = [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],k = 2) == 0\n assert candidate(arr = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11],k = 3) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 0\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 12\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 25\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],k = 2) == 5\n assert candidate(arr = [10, 20, 30, 25, 40, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105],k = 7) == 0\n assert candidate(arr = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5],k = 2) == 0\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10],k = 2) == 0\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 3) == 8\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 2) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 3) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 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(arr = [10, 20, 30, 40, 50, 1, 11, 21, 31, 41, 51, 2, 12, 22, 32, 42, 52],k = 5) == 10\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 9, 1],k = 2) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 0\n assert candidate(arr = [100, 50, 200, 150, 300, 250, 400, 350, 500, 450],k = 4) == 0\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().kIncreasing", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int kIncreasing(int[] arr, int k) {", "container": "Solution", "callable": "kIncreasing", "parameters": [{"name": "arr", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2114, "task_id": "maximum-number-of-words-found-in-sentences", "difficulty": "Easy", "problem_description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces.\nYou are given an array of strings sentences, where each sentences[i] represents a single sentence.\nReturn the maximum number of words that appear in a single sentence.\n \nExample 1:\n\nInput: sentences = [\"alice and bob love leetcode\", \"i think so too\", \"this is great thanks very much\"]\nOutput: 6\nExplanation: \n- The first sentence, \"alice and bob love leetcode\", has 5 words in total.\n- The second sentence, \"i think so too\", has 4 words in total.\n- The third sentence, \"this is great thanks very much\", has 6 words in total.\nThus, the maximum number of words in a single sentence comes from the third sentence, which has 6 words.\n\nExample 2:\n\nInput: sentences = [\"please wait\", \"continue to fight\", \"continue to win\"]\nOutput: 3\nExplanation: It is possible that multiple sentences contain the same number of words. \nIn this example, the second and third sentences (underlined) have the same number of words.\n\n \nConstraints:\n\n1 <= sentences.length <= 100\n1 <= sentences[i].length <= 100\nsentences[i] consists only of lowercase English letters and ' ' only.\nsentences[i] does not have leading or trailing spaces.\nAll the words in sentences[i] are separated by a single space.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentences = ['short', 'tiny', 'minuscule']) == 1\n assert candidate(sentences = ['one']) == 1\n assert candidate(sentences = ['alice and bob love leetcode', 'i think so too', 'this is great thanks very much']) == 6\n assert candidate(sentences = ['singleword', 'two words', 'three words here']) == 3\n assert candidate(sentences = ['one two three four five six seven eight nine ten']) == 10\n assert candidate(sentences = ['please wait', 'continue to fight', 'continue to win']) == 3\n assert candidate(sentences = ['hello world', 'hi there']) == 2\n assert candidate(sentences = ['singleword', 'another word', 'yet another example']) == 3\n assert candidate(sentences = ['a quick brown fox', 'jumps over the lazy dog']) == 5\n assert candidate(sentences = ['one two three', 'four five six seven', 'eight nine ten eleven twelve']) == 5\n assert candidate(sentences = ['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(sentences = ['longer sentences with more words to test the function', 'another sentence to check the word count correctly', 'yet another example sentence for validation', 'this is the last sentence for this test case']) == 9\n assert candidate(sentences = ['equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal']) == 1\n assert candidate(sentences = ['word1', 'word1 word2', 'word1 word2 word3', 'word1 word2 word3 word4', 'word1 word2 word3 word4 word5']) == 5\n assert candidate(sentences = ['all questions asked by five watched experts amaze the judge', 'jackdaws love my big sphinx of quartz', 'the five boxing wizards jump quickly on this new sentence']) == 10\n assert candidate(sentences = ['tiny', 'shorter', 'shortest', 'a bit longer', 'the longest sentence in the list']) == 6\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'this sentence is longer than the previous one', 'a']) == 9\n assert candidate(sentences = ['once upon a time in a world far far away', 'there lived a king and a queen', 'who were very very happy together']) == 10\n assert candidate(sentences = ['singleword', 'two words', 'three words are', 'four words are here', 'five words are here now', 'six words are here now indeed', 'seven words are here now indeed truly']) == 7\n assert candidate(sentences = ['this sentence has twelve words in it indeed', 'this one has seven words']) == 8\n assert candidate(sentences = ['a short sentence', 'a much longer sentence with many more words in it', 'tiny', 'an even longer sentence that seems to go on and on and on']) == 13\n assert candidate(sentences = ['one two three', 'four five six seven', 'eight nine ten eleven twelve', 'thirteen fourteen fifteen sixteen seventeen']) == 5\n assert candidate(sentences = ['equal number of words here', 'equal number of words here', 'equal number of words here']) == 5\n assert candidate(sentences = ['this is a single word', 'this is a two word phrase', 'this sentence has three words in it']) == 7\n assert candidate(sentences = ['one two three', 'four five six seven eight', 'nine ten eleven twelve thirteen fourteen fifteen']) == 7\n assert candidate(sentences = ['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', 'this is a sentence with many many many words indeed']) == 26\n assert candidate(sentences = ['this is a test sentence with exactly ten words in it', 'another test sentence here with ten words too', 'and yet another test sentence that has ten words']) == 11\n assert candidate(sentences = ['singleword', 'anotherword', 'yetanotherword', 'onemoreword']) == 1\n assert candidate(sentences = ['python is fun', 'data structures and algorithms', 'object oriented programming is powerful']) == 5\n assert candidate(sentences = ['this is a test', 'another test sentence', 'yet another example to consider', 'the longest sentence in this batch is this one here']) == 10\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'pack my box with five dozen liquor jugs']) == 9\n assert candidate(sentences = ['abcd efgh ijkl mnop qrst uvwx yz', 'abcd efgh ijkl mnop qrst uvwx yz abcd', 'abcd efgh ijkl mnop qrst uvwx yz abcd efgh', 'abcd efgh ijkl mnop qrst uvwx yz abcd efgh ijkl mnop']) == 11\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'every good boy does fine', 'to be or not to be that is the question']) == 10\n assert candidate(sentences = ['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', 'the rain in spain stays mainly in the plain', 'i am six']) == 26\n assert candidate(sentences = ['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', 'a b c d e f g h i j k l m n o p q r s t u v w x']) == 26\n assert candidate(sentences = ['lorem ipsum dolor sit amet consectetur adipiscing elit', 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua', 'ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat']) == 17\n assert candidate(sentences = ['words words words words words words words words words words', 'just a couple', 'quite a bit more words than before']) == 10\n assert candidate(sentences = ['Python is an interpreted high-level general-purpose programming language', 'Java is a class-based, object-oriented programming language', 'C++ is a general-purpose programming language']) == 8\n assert candidate(sentences = ['the best way to achieve success is through hard work', 'persistence is key to overcoming challenges', 'never give up on your dreams']) == 10\n assert candidate(sentences = ['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', 'quick fox jumps', 'lazy dog']) == 26\n assert candidate(sentences = ['one', 'two words', 'three words here', 'four words here now', 'five words here now indeed', 'six words here now indeed truly']) == 6\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'every good boy does fine', 'pack my box with five dozen liquor jugs']) == 9\n assert candidate(sentences = ['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', 'short sentence']) == 26\n assert candidate(sentences = ['one', 'two three', 'four five six', 'seven eight nine ten', 'eleven twelve thirteen fourteen fifteen']) == 5\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'pack my box with five dozen liquor jugs', 'how vexingly quick daft zebras jump']) == 9\n assert candidate(sentences = ['repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat', 'different repeat different repeat', 'unique sentence']) == 10\n assert candidate(sentences = ['a quick brown fox jumps over the lazy dog', 'this is a longer sentence with more words in it', 'short']) == 10\n assert candidate(sentences = ['equal length words here', 'equal length words here', 'equal length words here']) == 4\n assert candidate(sentences = ['one two three four five', 'six seven eight nine ten eleven', 'twelve thirteen fourteen fifteen sixteen seventeen', 'eighteen nineteen twenty']) == 6\n assert candidate(sentences = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyzabcdefghijkl']) == 1\n assert candidate(sentences = ['equal length', 'equal length', 'equal length', 'equal length', 'equal length', 'equal length']) == 2\n assert candidate(sentences = ['lorem ipsum dolor sit amet', 'consectetur adipiscing elit', 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua']) == 11\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'a quick movement of the enemy will jeopardize six gunboats', 'five boxing wizards jump quickly']) == 10\n assert candidate(sentences = ['an apple a day keeps the doctor away', 'once upon a time in a land far far away', 'hello world hello universe']) == 10\n assert candidate(sentences = ['the longest sentence in this list is the last one which contains many many words indeed']) == 16\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'how now brown cow', 'she sells sea shells by the sea shore']) == 9\n assert candidate(sentences = ['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', 'jumps over the lazy dog']) == 26\n assert candidate(sentences = ['the secret to a happy life is simple', 'be kind to others', 'live each day to the fullest', 'love what you do']) == 8\n assert candidate(sentences = ['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', 'i am a sentence with many words indeed', 'this is another test sentence']) == 26\n assert candidate(sentences = ['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']) == 26\n assert candidate(sentences = ['python is a great programming language', 'java is also a great programming language', 'c plus plus is another popular language']) == 7\n assert candidate(sentences = ['singleword', 'two words', 'three words here', 'four words are in this', 'five words make a phrase', 'six words is a complete sentence']) == 6\n assert candidate(sentences = ['longer sentences are more challenging to process correctly', 'even longer sentences that contain a greater number of words for testing', 'tiny']) == 12\n assert candidate(sentences = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij']) == 1\n assert candidate(sentences = ['to be or not to be that is the question', 'that is the question indeed', 'whether tis nobler in the mind to suffer']) == 10\n assert candidate(sentences = ['python is great', 'i love programming', 'data science is fascinating', 'machine learning and ai are transforming industries']) == 7\n assert candidate(sentences = ['this is a very long sentence indeed that should test the boundaries of the problem constraints']) == 16\n assert candidate(sentences = ['singleword', 'two words', 'three words here', 'four words make a sentence', 'five words in this sentence']) == 5\n assert candidate(sentences = ['complex sentences are interesting', 'they can have many clauses and ideas', 'and sometimes they even have subordinate clauses']) == 7\n assert candidate(sentences = ['very very very long sentence to test the length', 'short sentence', 'another medium length sentence here']) == 9\n assert candidate(sentences = ['very long sentence with many many many words indeed', 'short one', 'medium length sentence']) == 9\n assert candidate(sentences = ['a singleword', 'two words here', 'three words in this', 'four words make up']) == 4\n assert candidate(sentences = ['this is a sentence with seven words', 'another one with five words', 'and yet another with eight words here']) == 7\n assert candidate(sentences = ['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', 'the cat in the hat']) == 26\n assert candidate(sentences = ['this is a longer sentence with more words', 'tiny', 'another sentence with quite a few words indeed']) == 8\n assert candidate(sentences = ['python is an amazing language for data science and machine learning', 'the early morning sun illuminated the dew covered grass', 'she sells sea shells by the sea shore']) == 11\n assert candidate(sentences = ['same same same same same same same', 'another same same same', 'and yet another same same']) == 7\n assert candidate(sentences = ['one', 'two three', 'four five six', 'seven eight nine ten']) == 4\n"}, "metadata": {"canonical_parameter_names": ["sentences"], "leetcode_dataset_entry_point": "Solution().mostWordsFound", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int mostWordsFound(String[] sentences) {", "container": "Solution", "callable": "mostWordsFound", "parameters": [{"name": "sentences", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2115, "task_id": "find-all-possible-recipes-from-given-supplies", "difficulty": "Medium", "problem_description": "You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. A recipe can also be an ingredient for other recipes, i.e., ingredients[i] may contain a string that is in recipes.\nYou are also given a string array supplies containing all the ingredients that you initially have, and you have an infinite supply of all of them.\nReturn a list of all the recipes that you can create. You may return the answer in any order.\nNote that two recipes may contain each other in their ingredients.\n \nExample 1:\n\nInput: recipes = [\"bread\"], ingredients = [[\"yeast\",\"flour\"]], supplies = [\"yeast\",\"flour\",\"corn\"]\nOutput: [\"bread\"]\nExplanation:\nWe can create \"bread\" since we have the ingredients \"yeast\" and \"flour\".\n\nExample 2:\n\nInput: recipes = [\"bread\",\"sandwich\"], ingredients = [[\"yeast\",\"flour\"],[\"bread\",\"meat\"]], supplies = [\"yeast\",\"flour\",\"meat\"]\nOutput: [\"bread\",\"sandwich\"]\nExplanation:\nWe can create \"bread\" since we have the ingredients \"yeast\" and \"flour\".\nWe can create \"sandwich\" since we have the ingredient \"meat\" and can create the ingredient \"bread\".\n\nExample 3:\n\nInput: recipes = [\"bread\",\"sandwich\",\"burger\"], ingredients = [[\"yeast\",\"flour\"],[\"bread\",\"meat\"],[\"sandwich\",\"meat\",\"bread\"]], supplies = [\"yeast\",\"flour\",\"meat\"]\nOutput: [\"bread\",\"sandwich\",\"burger\"]\nExplanation:\nWe can create \"bread\" since we have the ingredients \"yeast\" and \"flour\".\nWe can create \"sandwich\" since we have the ingredient \"meat\" and can create the ingredient \"bread\".\nWe can create \"burger\" since we have the ingredient \"meat\" and can create the ingredients \"bread\" and \"sandwich\".\n\n \nConstraints:\n\nn == recipes.length == ingredients.length\n1 <= n <= 100\n1 <= ingredients[i].length, supplies.length <= 100\n1 <= recipes[i].length, ingredients[i][j].length, supplies[k].length <= 10\nrecipes[i], ingredients[i][j], and supplies[k] consist only of lowercase English letters.\nAll the values of recipes and supplies combined are unique.\nEach ingredients[i] does not contain any duplicate values.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(recipes = ['bread', 'sandwich'],ingredients = [['yeast', 'flour'], ['bread', 'meat']],supplies = ['yeast', 'flour', 'meat']) == ['bread', 'sandwich']\n assert candidate(recipes = ['pasta', 'salad'],ingredients = [['noodles', 'sauce'], ['lettuce', 'tomato']],supplies = ['noodles', 'sauce', 'lettuce']) == ['pasta']\n assert candidate(recipes = ['bread', 'sandwich', 'burger'],ingredients = [['yeast', 'flour'], ['bread', 'meat'], ['sandwich', 'meat', 'bread']],supplies = ['yeast', 'flour', 'meat']) == ['bread', 'sandwich', 'burger']\n assert candidate(recipes = ['cake', 'muffin'],ingredients = [['flour', 'sugar'], ['flour', 'eggs']],supplies = ['flour', 'sugar']) == ['cake']\n assert candidate(recipes = ['bread'],ingredients = [['yeast', 'flour']],supplies = ['yeast', 'flour', 'corn']) == ['bread']\n assert candidate(recipes = ['cake', 'muffin', 'brownie'],ingredients = [['flour', 'sugar', 'eggs'], ['flour', 'sugar', 'butter'], ['flour', 'sugar', 'chocolate']],supplies = ['flour', 'sugar', 'eggs']) == ['cake']\n assert candidate(recipes = ['cake', 'muffin'],ingredients = [['flour', 'sugar', 'eggs'], ['flour', 'sugar', 'eggs', 'butter']],supplies = ['flour', 'sugar', 'eggs', 'butter']) == ['cake', 'muffin']\n assert candidate(recipes = ['pizza', 'pasta'],ingredients = [['dough', 'tomato', 'cheese'], ['noodles', 'sauce']],supplies = ['dough', 'tomato', 'cheese', 'noodles', 'sauce']) == ['pizza', 'pasta']\n assert candidate(recipes = ['steak_dinner', 'chicken_soup', 'pasta'],ingredients = [['steak', 'potato', 'carrot'], ['chicken', 'vegetable_stock', 'carrot'], ['noodles', 'sauce', 'meat']],supplies = ['steak', 'potato', 'carrot', 'chicken', 'vegetable_stock', 'noodles', 'sauce', 'meat']) == ['steak_dinner', 'chicken_soup', 'pasta']\n assert candidate(recipes = ['soup', 'stew'],ingredients = [['water', 'vegetables', 'spices'], ['water', 'meat', 'vegetables', 'spices']],supplies = ['water', 'vegetables', 'spices']) == ['soup']\n assert candidate(recipes = ['cake', 'ice_cream', 'brownie'],ingredients = [['flour', 'sugar', 'eggs'], ['milk', 'sugar', 'vanilla'], ['flour', 'cocoa', 'sugar']],supplies = ['flour', 'sugar', 'eggs', 'milk', 'vanilla']) == ['cake', 'ice_cream']\n assert candidate(recipes = ['sushi', 'ramen'],ingredients = [['rice', 'seaweed', 'salmon'], ['noodles', 'water', 'meat', 'vegetables']],supplies = ['rice', 'noodles', 'water', 'meat']) == []\n assert candidate(recipes = ['cake', 'pudding', 'pie'],ingredients = [['flour', 'sugar', 'eggs'], ['milk', 'sugar', 'flour'], ['crust', 'fruit', 'filling']],supplies = ['flour', 'sugar', 'eggs', 'milk', 'crust', 'fruit', 'filling']) == ['cake', 'pudding', 'pie']\n assert candidate(recipes = ['cake', 'brownie'],ingredients = [['flour', 'sugar', 'eggs'], ['flour', 'cocoa', 'sugar']],supplies = ['flour', 'sugar', 'eggs']) == ['cake']\n assert candidate(recipes = ['omelette', 'pancake', 'waffle'],ingredients = [['eggs', 'milk'], ['flour', 'eggs', 'milk'], ['flour', 'eggs', 'milk', 'butter']],supplies = ['eggs', 'milk', 'flour', 'butter', 'sugar']) == ['omelette', 'pancake', 'waffle']\n assert candidate(recipes = ['bread', 'sandwich', 'burger', 'wrap'],ingredients = [['yeast', 'flour'], ['bread', 'meat'], ['bread', 'meat', 'cheese'], ['bread', 'cheese', 'lettuce']],supplies = ['yeast', 'flour', 'meat', 'cheese', 'lettuce']) == ['bread', 'sandwich', 'burger', 'wrap']\n assert candidate(recipes = ['soup', 'stew'],ingredients = [['carrot', 'onion'], ['carrot', 'potato', 'beef']],supplies = ['carrot', 'onion', 'beef', 'potato', 'pepper']) == ['soup', 'stew']\n assert candidate(recipes = ['chocolate_chip_cookie', 'oatmeal_cookie'],ingredients = [['flour', 'sugar', 'chocolate_chips'], ['flour', 'sugar', 'oatmeal']],supplies = ['flour', 'sugar', 'oatmeal']) == ['oatmeal_cookie']\n assert candidate(recipes = ['pizza', 'pasta', 'omelette'],ingredients = [['dough', 'tomato', 'cheese'], ['noodles', 'sauce'], ['eggs', 'milk']],supplies = ['dough', 'tomato', 'cheese', 'noodles', 'sauce', 'eggs', 'milk', 'flour']) == ['pizza', 'pasta', 'omelette']\n assert candidate(recipes = ['juice', 'smoothie'],ingredients = [['fruit', 'water'], ['fruit', 'yogurt', 'banana']],supplies = ['fruit', 'water', 'yogurt', 'banana', 'milk']) == ['juice', 'smoothie']\n assert candidate(recipes = ['steak', 'chicken', 'beef'],ingredients = [['beef', 'salt'], ['chicken', 'pepper'], ['salt', 'spice']],supplies = ['salt', 'pepper', 'spice', 'chicken']) == ['beef', 'chicken', 'steak']\n assert candidate(recipes = ['cheese_pizza', 'pepperoni_pizza', 'margherita_pizza'],ingredients = [['dough', 'tomato', 'cheese'], ['dough', 'tomato', 'cheese', 'pepperoni'], ['dough', 'tomato', 'basil', 'cheese']],supplies = ['dough', 'tomato', 'cheese', 'pepperoni', 'basil']) == ['cheese_pizza', 'pepperoni_pizza', 'margherita_pizza']\n assert candidate(recipes = ['soup', 'stew'],ingredients = [['water', 'vegetables', 'meat'], ['water', 'vegetables', 'meat', 'tomato']],supplies = ['water', 'vegetables', 'meat', 'tomato', 'salt']) == ['soup', 'stew']\n assert candidate(recipes = ['pizza', 'taco', 'pasta'],ingredients = [['dough', 'tomato', 'cheese'], ['tortilla', 'meat', 'cheese'], ['noodles', 'sauce', 'meat']],supplies = ['dough', 'tomato', 'cheese', 'tortilla', 'meat', 'noodles', 'sauce']) == ['pizza', 'taco', 'pasta']\n assert candidate(recipes = ['salmon', 'trout'],ingredients = [['salmon_filet', 'vegetables', 'lemon'], ['trout_filet', 'vegetables', 'lemon']],supplies = ['vegetables', 'lemon']) == []\n assert candidate(recipes = ['steak_dinner', 'pasta_dinner', 'chicken_dinner'],ingredients = [['steak', 'potato', 'carrot'], ['pasta', 'sauce'], ['chicken', 'vegetable_oil']],supplies = ['steak', 'potato', 'carrot', 'pasta', 'sauce', 'chicken', 'vegetable_oil']) == ['steak_dinner', 'pasta_dinner', 'chicken_dinner']\n assert candidate(recipes = ['smoothie', 'juice'],ingredients = [['banana', 'orange', 'milk'], ['apple', 'orange', 'water']],supplies = ['banana', 'orange', 'water']) == []\n assert candidate(recipes = ['apple_crisp', 'apple_pie', 'blueberry_pie'],ingredients = [['apple', 'oat', 'sugar'], ['apple', 'pie_crust'], ['blueberry', 'pie_crust']],supplies = ['apple', 'oat', 'sugar', 'blueberry', 'pie_crust']) == ['apple_crisp', 'apple_pie', 'blueberry_pie']\n assert candidate(recipes = ['chocolate_cake', 'vanilla_cake', 'red_velvet'],ingredients = [['flour', 'eggs', 'chocolate', 'sugar'], ['flour', 'eggs', 'vanilla', 'sugar'], ['chocolate_cake', 'red_food_color']],supplies = ['flour', 'eggs', 'chocolate', 'vanilla', 'sugar', 'red_food_color']) == ['chocolate_cake', 'vanilla_cake', 'red_velvet']\n assert candidate(recipes = ['omelette', 'frittata'],ingredients = [['eggs', 'cheese'], ['eggs', 'cheese', 'spinach', 'tomato']],supplies = ['eggs', 'cheese', 'spinach']) == ['omelette']\n assert candidate(recipes = ['cake_layer', 'chocolate_ganache', 'frosting'],ingredients = [['flour', 'sugar', 'eggs'], ['chocolate', 'cream'], ['powdered_sugar', 'milk']],supplies = ['flour', 'sugar', 'eggs', 'chocolate', 'cream', 'powdered_sugar', 'milk']) == ['cake_layer', 'chocolate_ganache', 'frosting']\n assert candidate(recipes = ['pizza', 'pasta'],ingredients = [['dough', 'tomato_sauce', 'cheese'], ['dough', 'noodles', 'sauce']],supplies = ['dough', 'tomato_sauce', 'cheese', 'noodles', 'sauce']) == ['pizza', 'pasta']\n assert candidate(recipes = ['taco', 'burrito', 'enchilada'],ingredients = [['beef', 'shell'], ['beef', 'tortilla'], ['beef', 'taco_shell', 'sauce']],supplies = ['beef', 'shell', 'tortilla', 'taco_shell', 'sauce']) == ['taco', 'burrito', 'enchilada']\n assert candidate(recipes = ['chocolate_cake', 'vanilla_cake', 'red_velvet_cake'],ingredients = [['flour', 'sugar', 'cocoa'], ['flour', 'sugar'], ['vanilla_cake', 'cocoa', 'red_food_color']],supplies = ['flour', 'sugar', 'cocoa', 'red_food_color']) == ['vanilla_cake', 'chocolate_cake', 'red_velvet_cake']\n assert candidate(recipes = ['omelette', 'pancakes'],ingredients = [['eggs', 'milk'], ['eggs', 'flour', 'milk']],supplies = ['eggs', 'milk', 'flour', 'butter']) == ['omelette', 'pancakes']\n assert candidate(recipes = ['sandwich', 'burger', 'omelet'],ingredients = [['bread', 'meat', 'cheese'], ['bread', 'patty', 'cheese'], ['eggs', 'cheese', 'spinach']],supplies = ['bread', 'meat', 'cheese', 'patty', 'eggs', 'spinach']) == ['sandwich', 'burger', 'omelet']\n assert candidate(recipes = ['salmon', 'steak', 'chicken'],ingredients = [['salmon_fillet', 'lemon'], ['beef_steak', 'salt'], ['chicken_breast', 'pepper']],supplies = ['salmon_fillet', 'lemon', 'beef_steak', 'salt', 'chicken_breast', 'pepper', 'oil']) == ['salmon', 'steak', 'chicken']\n assert candidate(recipes = ['cake', 'brownie'],ingredients = [['sugar', 'flour', 'eggs'], ['sugar', 'chocolate', 'eggs']],supplies = ['sugar', 'eggs']) == []\n assert candidate(recipes = ['cake', 'pie', 'tiramisu'],ingredients = [['flour', 'eggs', 'sugar'], ['apple', 'flour', 'sugar'], ['cake', 'coffee', 'mascarpone']],supplies = ['flour', 'eggs', 'sugar', 'apple', 'coffee', 'mascarpone']) == ['cake', 'pie', 'tiramisu']\n assert candidate(recipes = ['soup', 'stew', 'salad', 'sandwich'],ingredients = [['carrot', 'onion'], ['carrot', 'potato', 'beef'], ['lettuce', 'cucumber'], ['bread', 'cheese']],supplies = ['carrot', 'onion', 'beef', 'potato', 'pepper', 'lettuce', 'cucumber', 'bread', 'cheese', 'eggs']) == ['soup', 'stew', 'salad', 'sandwich']\n assert candidate(recipes = ['chocolate_cake', 'vanilla_cake', 'red_velvet_cake'],ingredients = [['flour', 'sugar', 'eggs', 'chocolate'], ['flour', 'sugar', 'eggs'], ['vanilla_cake', 'red_food_color']],supplies = ['flour', 'sugar', 'eggs', 'chocolate', 'red_food_color']) == ['vanilla_cake', 'chocolate_cake', 'red_velvet_cake']\n assert candidate(recipes = ['mashed_potatoes', 'grilled_cheese', 'mac_n_cheese'],ingredients = [['potatoes', 'butter', 'milk'], ['bread', 'cheese'], ['macaroni', 'cheese', 'milk']],supplies = ['potatoes', 'butter', 'milk', 'bread', 'cheese', 'macaroni']) == ['mashed_potatoes', 'grilled_cheese', 'mac_n_cheese']\n assert candidate(recipes = ['pancake', 'waffle', 'muffin'],ingredients = [['flour', 'eggs', 'milk'], ['flour', 'eggs', 'milk', 'butter'], ['flour', 'sugar', 'eggs']],supplies = ['flour', 'eggs', 'milk', 'butter', 'sugar']) == ['pancake', 'waffle', 'muffin']\n assert candidate(recipes = ['apple_pie', 'blueberry_pie'],ingredients = [['apple', 'pie_crust'], ['blueberry', 'pie_crust']],supplies = ['apple', 'blueberry', 'pie_crust']) == ['apple_pie', 'blueberry_pie']\n assert candidate(recipes = ['chocolate_cake', 'vanilla_cake', 'red_velvet_cake'],ingredients = [['flour', 'sugar', 'eggs', 'chocolate'], ['flour', 'sugar', 'eggs'], ['vanilla_cake', 'red_food_coloring']],supplies = ['flour', 'sugar', 'eggs', 'chocolate', 'vanilla', 'red_food_coloring']) == ['vanilla_cake', 'chocolate_cake', 'red_velvet_cake']\n assert candidate(recipes = ['pizza', 'pasta', 'soup'],ingredients = [['dough', 'tomato', 'cheese'], ['noodles', 'sauce'], ['carrots', 'onions', 'water']],supplies = ['dough', 'tomato', 'noodles', 'carrots']) == []\n assert candidate(recipes = ['a', 'b', 'c', 'd'],ingredients = [['e', 'f'], ['a', 'g'], ['b', 'h'], ['c', 'i']],supplies = ['e', 'f', 'g', 'h', 'i']) == ['a', 'b', 'c', 'd']\n assert candidate(recipes = ['beer', 'wine'],ingredients = [['grains', 'water', 'hops'], ['grapes', 'yeast', 'sugar']],supplies = ['grains', 'water', 'hops', 'grapes', 'yeast', 'sugar']) == ['beer', 'wine']\n assert candidate(recipes = ['pizza', 'pasta', 'salad'],ingredients = [['dough', 'sauce', 'cheese'], ['noodles', 'sauce'], ['lettuce', 'tomato']],supplies = ['dough', 'cheese', 'noodles', 'sauce', 'lettuce', 'tomato', 'spinach']) == ['pizza', 'pasta', 'salad']\n assert candidate(recipes = ['smoothie', 'juice'],ingredients = [['banana', 'strawberry', 'milk'], ['apple', 'orange', 'water']],supplies = ['banana', 'strawberry', 'milk', 'apple', 'orange']) == ['smoothie']\n assert candidate(recipes = ['fish_stew', 'chicken_stew', 'beef_stew'],ingredients = [['fish', 'potatoes', 'carrots'], ['chicken', 'potatoes', 'carrots'], ['beef', 'potatoes', 'carrots']],supplies = ['potatoes', 'carrots', 'fish', 'chicken']) == ['fish_stew', 'chicken_stew']\n assert candidate(recipes = ['omelette', 'pancake'],ingredients = [['eggs', 'milk'], ['flour', 'eggs', 'milk']],supplies = ['eggs', 'milk', 'flour', 'butter']) == ['omelette', 'pancake']\n assert candidate(recipes = ['cheesecake', 'ice_cream', 'fruit_salad'],ingredients = [['cream', 'sugar', 'cheese'], ['cream', 'sugar'], ['fruit', 'sugar']],supplies = ['cream', 'sugar', 'cheese', 'fruit']) == ['ice_cream', 'cheesecake', 'fruit_salad']\n assert candidate(recipes = ['omelette', 'scrambled_eggs'],ingredients = [['egg', 'cheese', 'milk'], ['egg', 'milk']],supplies = ['egg', 'milk', 'cheese', 'salt']) == ['scrambled_eggs', 'omelette']\n assert candidate(recipes = ['chocolate_cake', 'vanilla_cake'],ingredients = [['flour', 'sugar', 'cocoa'], ['flour', 'sugar']],supplies = ['flour', 'sugar', 'cocoa']) == ['vanilla_cake', 'chocolate_cake']\n assert candidate(recipes = ['bread', 'toast', 'baguette'],ingredients = [['flour', 'yeast'], ['bread'], ['flour', 'yeast', 'oil']],supplies = ['flour', 'yeast', 'oil', 'butter']) == ['bread', 'baguette', 'toast']\n assert candidate(recipes = ['soup', 'stew', 'omelette'],ingredients = [['water', 'vegetables', 'salt'], ['water', 'meat', 'vegetables'], ['eggs', 'cheese', 'pepper']],supplies = ['water', 'vegetables', 'meat', 'eggs', 'cheese', 'pepper']) == ['stew', 'omelette']\n assert candidate(recipes = ['banana_bread', 'apple_pie', 'cheese_pie'],ingredients = [['banana', 'flour', 'eggs', 'sugar'], ['apple', 'flour', 'sugar', 'eggs'], ['cheese', 'flour', 'eggs', 'sugar']],supplies = ['banana', 'apple', 'flour', 'eggs', 'sugar', 'cheese']) == ['banana_bread', 'apple_pie', 'cheese_pie']\n assert candidate(recipes = ['steak_dish', 'chicken_dish', 'beef_dish'],ingredients = [['steak', 'salt', 'pepper'], ['chicken', 'salt', 'pepper'], ['beef', 'salt', 'pepper']],supplies = ['steak', 'chicken', 'beef', 'salt', 'pepper']) == ['steak_dish', 'chicken_dish', 'beef_dish']\n assert candidate(recipes = ['pizza', 'fries', 'burger'],ingredients = [['dough', 'tomato', 'cheese'], ['potato', 'salt'], ['patty', 'cheese', 'bun']],supplies = ['dough', 'tomato', 'cheese', 'potato', 'salt', 'patty', 'bun']) == ['pizza', 'fries', 'burger']\n assert candidate(recipes = ['sushi', 'ramen'],ingredients = [['rice', 'fish', 'seaweed'], ['noodles', 'broth', 'egg']],supplies = ['rice', 'fish', 'seaweed', 'noodles', 'broth', 'egg']) == ['sushi', 'ramen']\n assert candidate(recipes = ['soup', 'stew', 'salad'],ingredients = [['carrot', 'onion'], ['carrot', 'potato', 'beef'], ['lettuce', 'cucumber']],supplies = ['carrot', 'onion', 'beef', 'potato', 'pepper', 'lettuce', 'cucumber']) == ['soup', 'stew', 'salad']\n assert candidate(recipes = ['pizza', 'spaghetti'],ingredients = [['dough', 'tomato_sauce', 'cheese'], ['pasta', 'meat_sauce', 'cheese']],supplies = ['dough', 'pasta', 'cheese']) == []\n assert candidate(recipes = ['cake', 'pie'],ingredients = [['flour', 'eggs', 'sugar'], ['apple', 'flour', 'sugar']],supplies = ['flour', 'eggs', 'sugar', 'milk']) == ['cake']\n assert candidate(recipes = ['pasta', 'pizza', 'lasagna'],ingredients = [['noodles', 'sauce'], ['dough', 'sauce', 'cheese'], ['noodles', 'sauce', 'cheese', 'milk']],supplies = ['noodles', 'sauce', 'cheese', 'dough', 'milk']) == ['pasta', 'pizza', 'lasagna']\n assert candidate(recipes = ['omelette', 'pancake'],ingredients = [['eggs', 'cheese', 'bacon'], ['flour', 'eggs', 'milk']],supplies = ['eggs', 'flour', 'milk']) == ['pancake']\n assert candidate(recipes = ['pizza', 'sandwich', 'omelette', 'burger'],ingredients = [['dough', 'tomato', 'cheese'], ['bread', 'cheese', 'meat'], ['egg', 'milk', 'cheese'], ['patty', 'cheese', 'bun']],supplies = ['dough', 'tomato', 'cheese', 'bread', 'meat', 'egg', 'milk', 'patty', 'bun']) == ['pizza', 'sandwich', 'omelette', 'burger']\n assert candidate(recipes = ['chicken_salad', 'turkey_salad', 'veggie_salad'],ingredients = [['chicken', 'lettuce', 'tomato'], ['turkey', 'lettuce', 'tomato'], ['lettuce', 'tomato', 'carrot']],supplies = ['chicken', 'turkey', 'lettuce', 'tomato', 'carrot']) == ['chicken_salad', 'turkey_salad', 'veggie_salad']\n assert candidate(recipes = ['apple_pie', 'banana_bread', 'cherry_pie'],ingredients = [['apples', 'dough', 'sugar'], ['bananas', 'dough', 'sugar'], ['cherries', 'dough', 'sugar']],supplies = ['apples', 'bananas', 'cherries', 'dough', 'sugar']) == ['apple_pie', 'banana_bread', 'cherry_pie']\n assert candidate(recipes = ['recipe1', 'recipe2', 'recipe3', 'recipe4'],ingredients = [['ing1', 'ing2'], ['recipe1', 'ing3'], ['recipe2', 'ing4'], ['recipe3', 'ing5']],supplies = ['ing1', 'ing2', 'ing3', 'ing4', 'ing5']) == ['recipe1', 'recipe2', 'recipe3', 'recipe4']\n assert candidate(recipes = ['cake', 'pudding', 'pie'],ingredients = [['flour', 'eggs', 'sugar'], ['milk', 'cornstarch'], ['crust', 'apple', 'sugar']],supplies = ['flour', 'eggs', 'milk', 'sugar']) == ['cake']\n assert candidate(recipes = ['ice_cream', 'pudding'],ingredients = [['cream', 'sugar', 'vanilla'], ['milk', 'sugar', 'flour']],supplies = ['cream', 'sugar', 'vanilla', 'milk', 'flour', 'chocolate']) == ['ice_cream', 'pudding']\n assert candidate(recipes = ['salad', 'soup', 'stew'],ingredients = [['lettuce', 'tomato', 'onion'], ['carrot', 'potato', 'beef'], ['carrot', 'potato', 'beef', 'tomato']],supplies = ['lettuce', 'tomato', 'onion', 'carrot', 'potato']) == ['salad']\n assert candidate(recipes = ['omelette', 'scramble', 'frittata'],ingredients = [['eggs', 'cheese'], ['eggs'], ['eggs', 'cheese', 'spinach']],supplies = ['eggs', 'cheese', 'spinach', 'milk']) == ['scramble', 'omelette', 'frittata']\n assert candidate(recipes = ['cake', 'brownie', 'pudding'],ingredients = [['flour', 'sugar', 'eggs', 'milk'], ['flour', 'sugar', 'chocolate'], ['milk', 'sugar', 'gelatin']],supplies = ['flour', 'sugar', 'eggs', 'milk', 'chocolate', 'gelatin']) == ['cake', 'brownie', 'pudding']\n assert candidate(recipes = ['apple_pie', 'cherry_pie', 'blueberry_pie'],ingredients = [['crust', 'apple', 'sugar'], ['crust', 'cherry', 'sugar'], ['crust', 'blueberry', 'sugar']],supplies = ['crust', 'sugar', 'apple', 'blueberry']) == ['apple_pie', 'blueberry_pie']\n assert candidate(recipes = ['soup', 'stew', 'chili'],ingredients = [['water', 'carrot', 'potato'], ['water', 'tomato', 'carrot', 'potato'], ['water', 'tomato', 'beef', 'potato']],supplies = ['water', 'carrot', 'potato', 'tomato', 'beef']) == ['soup', 'stew', 'chili']\n assert candidate(recipes = ['pizza', 'lasagna', 'taco'],ingredients = [['dough', 'tomato', 'cheese'], ['pasta', 'mozzarella', 'sauce'], ['tortilla', 'meat', 'cheese']],supplies = ['dough', 'tomato', 'cheese', 'pasta', 'mozzarella', 'sauce', 'tortilla', 'meat']) == ['pizza', 'lasagna', 'taco']\n assert candidate(recipes = ['omelette', 'french_toast'],ingredients = [['egg', 'milk', 'cheese'], ['egg', 'bread', 'milk']],supplies = ['egg', 'milk', 'cheese', 'bread']) == ['omelette', 'french_toast']\n assert candidate(recipes = ['bread', 'cake', 'pudding'],ingredients = [['flour', 'yeast', 'water'], ['flour', 'eggs', 'sugar'], ['milk', 'cornstarch', 'water']],supplies = ['flour', 'yeast', 'eggs', 'sugar', 'milk']) == ['cake']\n assert candidate(recipes = ['steak_dish', 'chicken_dish'],ingredients = [['steak', 'garlic', 'onion'], ['chicken', 'garlic', 'onion']],supplies = ['steak', 'chicken', 'garlic', 'onion', 'potato']) == ['steak_dish', 'chicken_dish']\n assert candidate(recipes = ['pizza', 'lasagna'],ingredients = [['dough', 'tomato_sauce', 'cheese'], ['pasta', 'meat', 'cheese', 'tomato_sauce']],supplies = ['dough', 'tomato_sauce', 'cheese', 'pasta', 'meat']) == ['pizza', 'lasagna']\n assert candidate(recipes = ['cake', 'brownie', 'tiramisu'],ingredients = [['flour', 'sugar', 'eggs'], ['flour', 'sugar', 'chocolate'], ['coffee', 'brownie', 'cream']],supplies = ['flour', 'sugar', 'eggs', 'chocolate', 'coffee', 'cream']) == ['cake', 'brownie', 'tiramisu']\n assert candidate(recipes = ['pizza', 'calzone', 'taco', 'burrito'],ingredients = [['dough', 'sauce', 'cheese'], ['dough', 'cheese', 'meat'], ['tortilla', 'meat', 'lettuce'], ['tortilla', 'meat', 'beans']],supplies = ['dough', 'sauce', 'cheese', 'meat', 'tortilla', 'lettuce', 'beans']) == ['pizza', 'calzone', 'taco', 'burrito']\n assert candidate(recipes = ['taco', 'burrito'],ingredients = [['tortilla', 'ground_beef', 'cheese'], ['tortilla', 'beans', 'cheese', 'lettuce']],supplies = ['tortilla', 'ground_beef', 'beans', 'cheese', 'lettuce']) == ['taco', 'burrito']\n assert candidate(recipes = ['steak', 'chicken', 'beef'],ingredients = [['meat', 'seasoning'], ['meat', 'vegetables'], ['meat', 'sauce']],supplies = ['meat', 'seasoning', 'vegetables']) == ['steak', 'chicken']\n assert candidate(recipes = ['tacos', 'burritos', 'enchiladas'],ingredients = [['shell', 'ground beef', 'cheese'], ['shell', 'ground beef', 'beans'], ['tortilla', 'ground beef', 'cheese', 'sauce']],supplies = ['shell', 'tortilla', 'ground beef', 'cheese']) == ['tacos']\n assert candidate(recipes = ['taco', 'burrito'],ingredients = [['tortilla', 'beef', 'cheese'], ['tortilla', 'chicken', 'cheese', 'lettuce']],supplies = ['tortilla', 'cheese', 'lettuce']) == []\n assert candidate(recipes = ['muffin', 'brownie', 'cupcake'],ingredients = [['flour', 'eggs', 'milk', 'sugar'], ['flour', 'eggs', 'chocolate', 'sugar'], ['muffin', 'icing']],supplies = ['flour', 'eggs', 'milk', 'sugar', 'chocolate', 'icing']) == ['muffin', 'brownie', 'cupcake']\n assert candidate(recipes = ['soup', 'stew'],ingredients = [['water', 'carrot', 'potato'], ['water', 'tomato', 'carrot', 'potato']],supplies = ['water', 'carrot', 'potato', 'tomato']) == ['soup', 'stew']\n assert candidate(recipes = ['chicken_soup', 'veggie_soup', 'beef_stew'],ingredients = [['chicken', 'carrot', 'potato'], ['carrot', 'potato', 'onion'], ['beef', 'carrot', 'potato']],supplies = ['chicken', 'carrot', 'potato', 'onion', 'beef']) == ['chicken_soup', 'veggie_soup', 'beef_stew']\n assert candidate(recipes = ['taco', 'burrito'],ingredients = [['shell', 'meat', 'cheese'], ['wrap', 'meat', 'cheese', 'lettuce']],supplies = ['shell', 'wrap', 'meat', 'cheese', 'lettuce', 'tomato']) == ['taco', 'burrito']\n assert candidate(recipes = ['cake', 'brownie'],ingredients = [['flour', 'eggs', 'sugar'], ['flour', 'eggs', 'chocolate']],supplies = ['flour', 'eggs', 'sugar', 'chocolate']) == ['cake', 'brownie']\n assert candidate(recipes = ['smoothie', 'juice', 'shake'],ingredients = [['banana', 'milk'], ['orange', 'apple'], ['banana', 'milk', 'peanut_butter']],supplies = ['banana', 'milk', 'orange', 'apple', 'peanut_butter']) == ['smoothie', 'juice', 'shake']\n assert candidate(recipes = ['chocolate_cake', 'vanilla_cake'],ingredients = [['flour', 'sugar', 'cocoa', 'eggs'], ['flour', 'sugar', 'vanilla', 'eggs']],supplies = ['flour', 'sugar', 'eggs', 'vanilla']) == ['vanilla_cake']\n assert candidate(recipes = ['cake', 'muffin', 'brownie'],ingredients = [['flour', 'sugar', 'eggs'], ['flour', 'sugar', 'eggs', 'butter'], ['flour', 'sugar', 'chocolate']],supplies = ['flour', 'sugar', 'eggs', 'butter', 'chocolate']) == ['cake', 'muffin', 'brownie']\n assert candidate(recipes = ['muffin', 'pancake', 'scone'],ingredients = [['flour', 'sugar', 'milk'], ['flour', 'eggs', 'milk'], ['flour', 'butter', 'milk']],supplies = ['flour', 'eggs', 'butter', 'milk']) == ['pancake', 'scone']\n assert candidate(recipes = ['juice', 'smoothie'],ingredients = [['orange', 'apple'], ['banana', 'orange', 'milk']],supplies = ['orange', 'apple', 'banana', 'milk', 'water']) == ['juice', 'smoothie']\n assert candidate(recipes = ['smoothie', 'yogurt_parfait'],ingredients = [['banana', 'mango', 'yogurt'], ['yogurt', 'berry', 'honey']],supplies = ['banana', 'mango', 'yogurt', 'berry', 'honey']) == ['smoothie', 'yogurt_parfait']\n assert candidate(recipes = ['pancake', 'waffle', 'omelette'],ingredients = [['flour', 'eggs', 'milk'], ['flour', 'eggs', 'syrup'], ['eggs', 'milk', 'cheese']],supplies = ['flour', 'eggs', 'milk', 'syrup', 'cheese']) == ['pancake', 'waffle', 'omelette']\n assert candidate(recipes = ['pizza', 'pasta'],ingredients = [['dough', 'sauce', 'cheese'], ['noodles', 'sauce']],supplies = ['dough', 'sauce', 'cheese', 'noodles', 'tomato']) == ['pizza', 'pasta']\n assert candidate(recipes = ['pizza', 'spaghetti'],ingredients = [['dough', 'sauce', 'cheese'], ['pasta', 'sauce', 'meat']],supplies = ['dough', 'sauce', 'pasta']) == []\n assert candidate(recipes = ['chicken_soup', 'beef_stew'],ingredients = [['chicken', 'vegetables', 'water'], ['beef', 'vegetables', 'water', 'potato']],supplies = ['chicken', 'vegetables', 'water', 'beef', 'potato']) == ['chicken_soup', 'beef_stew']\n"}, "metadata": {"canonical_parameter_names": ["recipes", "ingredients", "supplies"], "leetcode_dataset_entry_point": "Solution().findAllRecipes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List findAllRecipes(String[] recipes, List> ingredients, String[] supplies) {", "container": "Solution", "callable": "findAllRecipes", "parameters": [{"name": "recipes", "type": "String[]"}, {"name": "ingredients", "type": "List>"}, {"name": "supplies", "type": "String[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2116, "task_id": "check-if-a-parentheses-string-can-be-valid", "difficulty": "Medium", "problem_description": "A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:\n\nIt is ().\nIt can be written as AB (A concatenated with B), where A and B are valid parentheses strings.\nIt can be written as (A), where A is a valid parentheses string.\n\nYou are given a parentheses string s and a string locked, both of length n. locked is a binary string consisting only of '0's and '1's. For each index i of locked,\n\nIf locked[i] is '1', you cannot change s[i].\nBut if locked[i] is '0', you can change s[i] to either '(' or ')'.\n\nReturn true if you can make s a valid parentheses string. Otherwise, return false.\n \nExample 1:\n\n\nInput: s = \"))()))\", locked = \"010100\"\nOutput: true\nExplanation: locked[1] == '1' and locked[3] == '1', so we cannot change s[1] or s[3].\nWe change s[0] and s[4] to '(' while leaving s[2] and s[5] unchanged to make s valid.\nExample 2:\n\nInput: s = \"()()\", locked = \"0000\"\nOutput: true\nExplanation: We do not need to make any changes because s is already valid.\n\nExample 3:\n\nInput: s = \")\", locked = \"0\"\nOutput: false\nExplanation: locked permits us to change s[0]. \nChanging s[0] to either '(' or ')' will not make s valid.\n\nExample 4:\n\nInput: s = \"(((())(((())\", locked = \"111111010111\"\nOutput: true\nExplanation: locked permits us to change s[6] and s[8]. \nWe change s[6] and s[8] to ')' to make s valid.\n\n \nConstraints:\n\nn == s.length == locked.length\n1 <= n <= 105\ns[i] is either '(' or ')'.\nlocked[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(((())(((())\",locked = \"111111010111\") == True\n assert candidate(s = \"()))()\",locked = \"010100\") == True\n assert candidate(s = \"()()\",locked = \"0000\") == True\n assert candidate(s = \")\",locked = \"0\") == False\n assert candidate(s = \"()()()()()()()()\",locked = \"0000000000000000\") == True\n assert candidate(s = \")()(()()(()()()())\",locked = \"10010101010101\") == False\n assert candidate(s = \"((((((((((((()))))))))())(((())))))\",locked = \"1111111111111100000000001000001001\") == False\n assert candidate(s = \"(((((())))))\",locked = \"000000000000\") == True\n assert candidate(s = \"((((()))))))\",locked = \"000111000111\") == True\n assert candidate(s = \"(()())\",locked = \"100101\") == True\n assert candidate(s = \")(((((()()()()(())))))\",locked = \"10000100100001000010\") == False\n assert candidate(s = \"((()()(()))\",locked = \"10000000000\") == False\n assert candidate(s = \"(((())))()()\",locked = \"000010000000\") == True\n assert candidate(s = \"()((()))()((()))\",locked = \"0011110000111100\") == True\n assert candidate(s = \"()))(((()))\",locked = \"010011100\") == False\n assert candidate(s = \"(()())\",locked = \"000000\") == True\n assert candidate(s = \"()(()))(()(()))\",locked = \"100101100101\") == False\n assert candidate(s = \"(()(()))\",locked = \"00101000\") == True\n assert candidate(s = \"(((()))((())()))\",locked = \"111111010110100100\") == True\n assert candidate(s = \"((()()(())))\",locked = \"010000101001\") == True\n assert candidate(s = \"((((((()))))\",locked = \"000000000001\") == True\n assert candidate(s = \"(()))(\",locked = \"101010\") == True\n assert candidate(s = \"((((((((((((()))))))))))\",locked = \"111111111111110000000000\") == False\n assert candidate(s = \"(((((())))()())\",locked = \"010010000001000\") == False\n assert candidate(s = \"()(()(()(()))\",locked = \"010001000000\") == False\n assert candidate(s = \"((())())\",locked = \"10010010\") == True\n assert candidate(s = \"(()(()(()))\",locked = \"000000000\") == False\n assert candidate(s = \"((())())()\",locked = \"001010000001\") == True\n assert candidate(s = \"((((()))))((((()))))\",locked = \"11111111111111111111\") == True\n assert candidate(s = \"(((()))))()()()()\",locked = \"11111100000\") == False\n assert candidate(s = \"(((((()))))(((())())))\",locked = \"1111111111110101010101010101\") == True\n assert candidate(s = \"()()(()(()))\",locked = \"000001100100\") == True\n assert candidate(s = \"(((((()))(()(()))))()()\",locked = \"1111110100101000001000\") == False\n assert candidate(s = \"())(((()))\",locked = \"01100100\") == False\n assert candidate(s = \"(()(()(()(()))))\",locked = \"1010101010101010\") == True\n assert candidate(s = \")(()(()))\",locked = \"0000000\") == False\n assert candidate(s = \"((((((()))))))\",locked = \"01010101010101\") == True\n assert candidate(s = \"(((())))(((())))\",locked = \"1111111111111111\") == True\n assert candidate(s = \"())(()\",locked = \"001010\") == True\n assert candidate(s = \"(((())))\",locked = \"11111111\") == True\n assert candidate(s = \"((()))\",locked = \"000000\") == True\n assert candidate(s = \")(((((()(()))())(((()))))\",locked = \"11100101001001001001\") == False\n assert candidate(s = \"((())()(()))\",locked = \"110101001101\") == True\n assert candidate(s = \"(((((())))))\",locked = \"111111100001\") == True\n assert candidate(s = \"(()(()(()(()(()))))\",locked = \"01001010100010\") == False\n assert candidate(s = \"((())()(()))\",locked = \"101010101010\") == True\n assert candidate(s = \"((((((((()))))))\",locked = \"000000000000000001\") == True\n assert candidate(s = \"((()(())))\",locked = \"110100110110\") == True\n assert candidate(s = \"(()(()(()))(()(()))\",locked = \"01010101010101\") == False\n assert candidate(s = \"(((((())))))\",locked = \"111100001111\") == True\n assert candidate(s = \"(((((((())))))))\",locked = \"0101010101010101\") == True\n assert candidate(s = \"()()()()\",locked = \"11111111\") == True\n assert candidate(s = \"(((((()))(()(()))(()))())\",locked = \"1111110100101010010010101001\") == False\n assert candidate(s = \")((((()(()))))\",locked = \"110001010010\") == False\n assert candidate(s = \"(((((((((()))(()))))))))\",locked = \"1111111111100010010000000000\") == True\n assert candidate(s = \")()(()(()))(\",locked = \"010101010100\") == True\n assert candidate(s = \"()()()()()()()()()()\",locked = \"00000000000000000000\") == True\n assert candidate(s = \"(()(()))()()\",locked = \"010100101000\") == True\n assert candidate(s = \"(((()(()))(()(()))))\",locked = \"010101010101010101010101\") == True\n assert candidate(s = \"(()))(()))\",locked = \"100110010010\") == True\n assert candidate(s = \"(()(()))((()(())))\",locked = \"010010010010110010\") == True\n assert candidate(s = \"((((()))))\",locked = \"101010101010\") == True\n assert candidate(s = \"()(()())\",locked = \"10010010\") == True\n assert candidate(s = \"(()))(()))(()))\",locked = \"100110010010001100\") == False\n assert candidate(s = \"((((())))(()()(()(())))\",locked = \"1110000010010101010\") == False\n assert candidate(s = \"(()())((()))\",locked = \"000000000000\") == True\n assert candidate(s = \"(()))(()))(()))(()))\",locked = \"100110010010001100100110\") == True\n assert candidate(s = \"())(()))((())\",locked = \"000010001000\") == False\n assert candidate(s = \"((())()(()))\",locked = \"101001010100\") == True\n assert candidate(s = \"((()((())())(()(())))\",locked = \"101010101010101010\") == False\n assert candidate(s = \"()(((()())))()\",locked = \"0000100010000001\") == True\n assert candidate(s = \"(()))(()))\",locked = \"010010100100\") == True\n assert candidate(s = \")()()()()()()()()()()()()()()()()()()()()()\",locked = \"100000000000000000000000000000\") == False\n assert candidate(s = \"((())()(()))\",locked = \"000000000000\") == True\n assert candidate(s = \"(()((()))\",locked = \"1011001\") == False\n assert candidate(s = \")))))))((((((\",locked = \"000000000000\") == False\n assert candidate(s = \"()()()()\",locked = \"00000000\") == True\n assert candidate(s = \"(((((())))))\",locked = \"011100111001\") == True\n assert candidate(s = \"())(((()))\",locked = \"001101010110\") == True\n assert candidate(s = \"(()())()()()\",locked = \"000000000000\") == True\n assert candidate(s = \")(()(()(()))\",locked = \"011001101001\") == True\n"}, "metadata": {"canonical_parameter_names": ["s", "locked"], "leetcode_dataset_entry_point": "Solution().canBeValid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean canBeValid(String s, String locked) {", "container": "Solution", "callable": "canBeValid", "parameters": [{"name": "s", "type": "String"}, {"name": "locked", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2117, "task_id": "abbreviating-the-product-of-a-range", "difficulty": "Hard", "problem_description": "You are given two positive integers left and right with left <= right. Calculate the product of all integers in the inclusive range [left, right].\nSince the product may be very large, you will abbreviate it following these steps:\n\nCount all trailing zeros in the product and remove them. Let us denote this count as C.\n\n\t\nFor example, there are 3 trailing zeros in 1000, and there are 0 trailing zeros in 546.\n\n\nDenote the remaining number of digits in the product as d. If d > 10, then express the product as ... where denotes the first 5 digits of the product, and denotes the last 5 digits of the product after removing all trailing zeros. If d <= 10, we keep it unchanged.\n\t\nFor example, we express 1234567654321 as 12345...54321, but 1234567 is represented as 1234567.\n\n\nFinally, represent the product as a string \"...eC\".\n\t\nFor example, 12345678987600000 will be represented as \"12345...89876e5\".\n\n\n\nReturn a string denoting the abbreviated product of all integers in the inclusive range [left, right].\n \nExample 1:\n\nInput: left = 1, right = 4\nOutput: \"24e0\"\nExplanation: The product is 1 × 2 × 3 × 4 = 24.\nThere are no trailing zeros, so 24 remains the same. The abbreviation will end with \"e0\".\nSince the number of digits is 2, which is less than 10, we do not have to abbreviate it further.\nThus, the final representation is \"24e0\".\n\nExample 2:\n\nInput: left = 2, right = 11\nOutput: \"399168e2\"\nExplanation: The product is 39916800.\nThere are 2 trailing zeros, which we remove to get 399168. The abbreviation will end with \"e2\".\nThe number of digits after removing the trailing zeros is 6, so we do not abbreviate it further.\nHence, the abbreviated product is \"399168e2\".\n\nExample 3:\n\nInput: left = 371, right = 375\nOutput: \"7219856259e3\"\nExplanation: The product is 7219856259000.\n\n \nConstraints:\n\n1 <= left <= right <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(left = 100,right = 105) == \"1158727752e3\"\n assert candidate(left = 1,right = 10000) == \"28462...79008e2499\"\n assert candidate(left = 10,right = 20) == \"6704425728e3\"\n assert candidate(left = 371,right = 375) == \"7219856259e3\"\n assert candidate(left = 1000,right = 1010) == \"10563...82688e5\"\n assert candidate(left = 5000,right = 5010) == \"49367...34144e6\"\n assert candidate(left = 1234,right = 1238) == \"28846...40584e1\"\n assert candidate(left = 999,right = 1000) == \"999e3\"\n assert candidate(left = 1,right = 10) == \"36288e2\"\n assert candidate(left = 1234,right = 1240) == \"44318...63424e2\"\n assert candidate(left = 5,right = 5) == \"5e0\"\n assert candidate(left = 1000,right = 1000) == \"1e3\"\n assert candidate(left = 10,right = 15) == \"36036e2\"\n assert candidate(left = 1000,right = 1004) == \"10100...50024e3\"\n assert candidate(left = 500,right = 510) == \"54464...59744e5\"\n assert candidate(left = 1,right = 100) == \"93326...16864e24\"\n assert candidate(left = 995,right = 1000) == \"98508...27388e4\"\n assert candidate(left = 9995,right = 10000) == \"99850...73988e5\"\n assert candidate(left = 1,right = 4) == \"24e0\"\n assert candidate(left = 2,right = 11) == \"399168e2\"\n assert candidate(left = 500,right = 505) == \"16099...69356e4\"\n assert candidate(left = 5000,right = 5005) == \"15671...18506e5\"\n assert candidate(left = 5,right = 10) == \"1512e2\"\n assert candidate(left = 8000,right = 8003) == \"40990...04048e3\"\n assert candidate(left = 5555,right = 6666) == \"28137...34688e279\"\n assert candidate(left = 9000,right = 9005) == \"53232...19508e4\"\n assert candidate(left = 100,right = 150) == \"61219...44768e15\"\n assert candidate(left = 5,right = 20) == \"10137...00736e4\"\n assert candidate(left = 3000,right = 3100) == \"81710...90592e27\"\n assert candidate(left = 1234,right = 1244) == \"10562...94176e2\"\n assert candidate(left = 1,right = 5000) == \"42285...33472e1249\"\n assert candidate(left = 9000,right = 9050) == \"53429...51328e15\"\n assert candidate(left = 100,right = 1000) == \"43116...46048e227\"\n assert candidate(left = 6000,right = 6005) == \"46772...86472e4\"\n assert candidate(left = 7000,right = 7020) == \"57553...63648e7\"\n assert candidate(left = 100,right = 200) == \"84505...02048e27\"\n assert candidate(left = 1234,right = 1250) == \"39811...24736e7\"\n assert candidate(left = 4000,right = 4100) == \"22481...83456e27\"\n assert candidate(left = 1000,right = 1050) == \"35045...20832e15\"\n assert candidate(left = 4995,right = 5000) == \"15578...18494e5\"\n assert candidate(left = 9500,right = 10000) == \"29333...52864e128\"\n assert candidate(left = 2000,right = 3000) == \"25024...18624e252\"\n assert candidate(left = 6000,right = 6100) == \"90528...09184e27\"\n assert candidate(left = 9995,right = 10005) == \"99999...99856e6\"\n assert candidate(left = 100,right = 2000) == \"35534...18272e477\"\n assert candidate(left = 7000,right = 7050) == \"15097...01664e15\"\n assert candidate(left = 5500,right = 5510) == \"14071...33184e5\"\n assert candidate(left = 9999,right = 10000) == \"9999e4\"\n assert candidate(left = 8000,right = 8010) == \"86491...39904e5\"\n assert candidate(left = 5,right = 50) == \"12672...06688e12\"\n assert candidate(left = 5000,right = 6000) == \"31736...43584e253\"\n assert candidate(left = 8000,right = 8020) == \"94684...81312e7\"\n assert candidate(left = 8000,right = 9000) == \"12498...67872e253\"\n assert candidate(left = 6500,right = 6530) == \"17034...07232e10\"\n assert candidate(left = 3000,right = 3010) == \"18042...06464e5\"\n assert candidate(left = 1000,right = 9999) == \"70734...94464e2249\"\n assert candidate(left = 5000,right = 5015) == \"15629...41184e7\"\n assert candidate(left = 3000,right = 3025) == \"28318...52192e9\"\n assert candidate(left = 1234,right = 5678) == \"11390...64288e1112\"\n assert candidate(left = 1000,right = 2000) == \"82415...74464e253\"\n assert candidate(left = 9000,right = 9999) == \"31626...93632e250\"\n assert candidate(left = 4321,right = 4325) == \"15098...31038e2\"\n assert candidate(left = 8765,right = 8780) == \"12301...69504e5\"\n assert candidate(left = 10000,right = 10010) == \"10055...00288e6\"\n assert candidate(left = 9990,right = 10000) == \"99451...72288e6\"\n assert candidate(left = 2000,right = 2010) == \"21050...98176e5\"\n assert candidate(left = 9990,right = 9999) == \"99451...72288e2\"\n assert candidate(left = 5000,right = 5050) == \"57259...77056e16\"\n assert candidate(left = 2500,right = 2600) == \"11420...49216e28\"\n assert candidate(left = 2500,right = 2510) == \"24371...13072e6\"\n assert candidate(left = 3000,right = 4000) == \"13222...08128e254\"\n assert candidate(left = 1000,right = 10000) == \"70734...94464e2253\"\n assert candidate(left = 7500,right = 7510) == \"42545...13216e6\"\n assert candidate(left = 9000,right = 9010) == \"31573...64992e5\"\n"}, "metadata": {"canonical_parameter_names": ["left", "right"], "leetcode_dataset_entry_point": "Solution().abbreviateProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String abbreviateProduct(int left, int right) {", "container": "Solution", "callable": "abbreviateProduct", "parameters": [{"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2119, "task_id": "a-number-after-a-double-reversal", "difficulty": "Easy", "problem_description": "Reversing an integer means to reverse all its digits.\n\nFor example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.\n\nGiven an integer num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false.\n \nExample 1:\n\nInput: num = 526\nOutput: true\nExplanation: Reverse num to get 625, then reverse 625 to get 526, which equals num.\n\nExample 2:\n\nInput: num = 1800\nOutput: false\nExplanation: Reverse num to get 81, then reverse 81 to get 18, which does not equal num.\n\nExample 3:\n\nInput: num = 0\nOutput: true\nExplanation: Reverse num to get 0, then reverse 0 to get 0, which equals num.\n\n \nConstraints:\n\n0 <= num <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 987654321) == True\n assert candidate(num = 1001) == True\n assert candidate(num = 1000000) == False\n assert candidate(num = 999999) == True\n assert candidate(num = 1200) == False\n assert candidate(num = 0) == True\n assert candidate(num = 1800) == False\n assert candidate(num = 526) == True\n assert candidate(num = 100) == False\n assert candidate(num = 123) == True\n assert candidate(num = 12340000) == False\n assert candidate(num = 100010001) == True\n assert candidate(num = 10) == False\n assert candidate(num = 4005006) == True\n assert candidate(num = 111111111) == True\n assert candidate(num = 100000000) == False\n assert candidate(num = 1234567) == True\n assert candidate(num = 1234321) == True\n assert candidate(num = 1001001) == True\n assert candidate(num = 120120120) == False\n assert candidate(num = 43210000) == False\n assert candidate(num = 10001000) == False\n assert candidate(num = 500500500) == False\n assert candidate(num = 2020202020) == False\n assert candidate(num = 1010101010) == False\n assert candidate(num = 10001) == True\n assert candidate(num = 500500) == False\n assert candidate(num = 500050005) == True\n assert candidate(num = 100001) == True\n assert candidate(num = 5005005) == True\n assert candidate(num = 1000000000) == False\n assert candidate(num = 900000009) == True\n assert candidate(num = 123456789) == True\n assert candidate(num = 9876543210) == False\n assert candidate(num = 10101010) == False\n assert candidate(num = 1000000001) == True\n assert candidate(num = 77777777) == True\n assert candidate(num = 1010101) == True\n assert candidate(num = 1001001001) == True\n assert candidate(num = 1230000) == False\n assert candidate(num = 2468000) == False\n assert candidate(num = 1000) == False\n assert candidate(num = 13579000) == False\n assert candidate(num = 100000001) == True\n assert candidate(num = 1234567890) == False\n assert candidate(num = 9090909090) == False\n assert candidate(num = 123000123) == True\n assert candidate(num = 101010) == False\n assert candidate(num = 40506070) == False\n assert candidate(num = 1230321) == True\n assert candidate(num = 101010101) == True\n assert candidate(num = 900000000) == False\n assert candidate(num = 12301230) == False\n assert candidate(num = 2131200) == False\n assert candidate(num = 20480000) == False\n assert candidate(num = 100100100) == False\n assert candidate(num = 10001000100) == False\n assert candidate(num = 1122334455) == True\n assert candidate(num = 3000003) == True\n assert candidate(num = 100000) == False\n assert candidate(num = 1000000002) == True\n assert candidate(num = 999999999) == True\n assert candidate(num = 123456) == True\n assert candidate(num = 123400000) == False\n assert candidate(num = 1000001) == True\n assert candidate(num = 10000) == False\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().isSameAfterReversals", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isSameAfterReversals(int num) {", "container": "Solution", "callable": "isSameAfterReversals", "parameters": [{"name": "num", "type": "int"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2120, "task_id": "execution-of-all-suffix-instructions-staying-in-a-grid", "difficulty": "Medium", "problem_description": "There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array startPos where startPos = [startrow, startcol] indicates that a robot is initially at cell (startrow, startcol).\nYou are also given a 0-indexed string s of length m where s[i] is the ith instruction for the robot: 'L' (move left), 'R' (move right), 'U' (move up), and 'D' (move down).\nThe robot can begin executing from any ith instruction in s. It executes the instructions one by one towards the end of s but it stops if either of these conditions is met:\n\nThe next instruction will move the robot off the grid.\nThere are no more instructions left to execute.\n\nReturn an array answer of length m where answer[i] is the number of instructions the robot can execute if the robot begins executing from the ith instruction in s.\n \nExample 1:\n\n\nInput: n = 3, startPos = [0,1], s = \"RRDDLU\"\nOutput: [1,5,4,3,1,0]\nExplanation: Starting from startPos and beginning execution from the ith instruction:\n- 0th: \"RRDDLU\". Only one instruction \"R\" can be executed before it moves off the grid.\n- 1st: \"RDDLU\". All five instructions can be executed while it stays in the grid and ends at (1, 1).\n- 2nd: \"DDLU\". All four instructions can be executed while it stays in the grid and ends at (1, 0).\n- 3rd: \"DLU\". All three instructions can be executed while it stays in the grid and ends at (0, 0).\n- 4th: \"LU\". Only one instruction \"L\" can be executed before it moves off the grid.\n- 5th: \"U\". If moving up, it would move off the grid.\n\nExample 2:\n\n\nInput: n = 2, startPos = [1,1], s = \"LURD\"\nOutput: [4,1,0,0]\nExplanation:\n- 0th: \"LURD\".\n- 1st: \"URD\".\n- 2nd: \"RD\".\n- 3rd: \"D\".\n\nExample 3:\n\n\nInput: n = 1, startPos = [0,0], s = \"LRUD\"\nOutput: [0,0,0,0]\nExplanation: No matter which instruction the robot begins execution from, it would move off the grid.\n\n \nConstraints:\n\nm == s.length\n1 <= n, m <= 500\nstartPos.length == 2\n0 <= startrow, startcol < n\ns consists of 'L', 'R', 'U', and 'D'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,startPos = [0, 0],s = \"LRUD\") == [0, 0, 0, 0]\n assert candidate(n = 4,startPos = [2, 2],s = \"DDDD\") == [1, 1, 1, 1]\n assert candidate(n = 5,startPos = [2, 2],s = \"LUDDRL\") == [6, 5, 4, 3, 2, 1]\n assert candidate(n = 4,startPos = [0, 3],s = \"RRRR\") == [0, 0, 0, 0]\n assert candidate(n = 3,startPos = [2, 0],s = \"RRU\") == [3, 2, 1]\n assert candidate(n = 4,startPos = [1, 2],s = \"LURDLU\") == [6, 5, 4, 3, 2, 1]\n assert candidate(n = 4,startPos = [2, 2],s = \"UUDDLLRR\") == [8, 7, 1, 5, 4, 3, 1, 1]\n assert candidate(n = 3,startPos = [0, 1],s = \"RRDDLU\") == [1, 5, 4, 3, 1, 0]\n assert candidate(n = 4,startPos = [3, 0],s = \"DDDD\") == [0, 0, 0, 0]\n assert candidate(n = 5,startPos = [0, 0],s = \"DRDLUR\") == [6, 5, 1, 0, 0, 1]\n assert candidate(n = 2,startPos = [1, 1],s = \"LURD\") == [4, 1, 0, 0]\n assert candidate(n = 5,startPos = [3, 3],s = \"DDDDRRRRUUUULLLL\") == [1, 1, 1, 2, 1, 1, 1, 4, 3, 6, 5, 4, 3, 3, 2, 1]\n assert candidate(n = 3,startPos = [0, 2],s = \"LLD\") == [3, 2, 1]\n assert candidate(n = 4,startPos = [2, 2],s = \"UDLRUDLR\") == [8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 5,startPos = [0, 0],s = \"RRRRUUUUDDDDLLLL\") == [4, 3, 2, 1, 0, 0, 0, 0, 4, 3, 2, 1, 0, 0, 0, 0]\n assert candidate(n = 5,startPos = [3, 3],s = \"RRRDDDDLLLLUUUU\") == [1, 1, 2, 1, 1, 1, 4, 3, 6, 5, 4, 3, 3, 2, 1]\n assert candidate(n = 7,startPos = [3, 3],s = \"LDRURLDRU\") == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 15,startPos = [14, 0],s = \"LLLLDDDDDDDDDDDDUUUUUUUUUUUUUUUU\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 14, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 6,startPos = [2, 2],s = \"UDLRUDLR\") == [8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 8,startPos = [1, 6],s = \"RULDDRRULLUUDD\") == [6, 10, 12, 3, 2, 1, 4, 3, 3, 2, 1, 3, 2, 1]\n assert candidate(n = 9,startPos = [8, 0],s = \"DDDDDDDDDDDDDDDDDD\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 5,startPos = [0, 4],s = \"LLLLDDRRRRUUUU\") == [12, 8, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 13,startPos = [1, 1],s = \"LRRUDLRLRLUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUD\") == [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]\n assert candidate(n = 8,startPos = [0, 0],s = \"RRRRDDDDLLLLUUUUDDDDLLLLUUUU\") == [20, 10, 8, 6, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 10,startPos = [7, 2],s = \"DRLLURDDRLUUDDRR\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 7,startPos = [3, 3],s = \"LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR\") == [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]\n assert candidate(n = 5,startPos = [4, 4],s = \"LULULULULULULULULULU\") == [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 6,startPos = [0, 5],s = \"LLLLDDRRUUDDLLRRUUDDLLRRUUDD\") == [28, 27, 26, 4, 2, 1, 0, 0, 0, 0, 18, 6, 4, 2, 0, 0, 0, 0, 10, 6, 4, 2, 0, 0, 0, 0, 2, 1]\n assert candidate(n = 10,startPos = [5, 5],s = \"LRUDLRUDLRUD\") == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 8,startPos = [7, 0],s = \"RRRRDDDDLLLLUUUU\") == [4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 3, 2, 1]\n assert candidate(n = 6,startPos = [2, 3],s = \"LRRUDLRLRLUDUDUDUD\") == [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 11,startPos = [3, 3],s = \"LRRLDDUUDDUUDDRRLLRRRRUUUUDDDDLLLL\") == [34, 33, 32, 31, 30, 29, 19, 27, 26, 25, 15, 23, 22, 21, 11, 10, 9, 8, 7, 6, 5, 4, 3, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 1]\n assert candidate(n = 400,startPos = [0, 0],s = \"RRRRUUUUDDDDLLLL\") == [4, 3, 2, 1, 0, 0, 0, 0, 4, 3, 2, 1, 0, 0, 0, 0]\n assert candidate(n = 7,startPos = [0, 6],s = \"LLLLLLLLLLLLLLLLLLL\") == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 6,startPos = [3, 3],s = \"LURDLURDLURDLURD\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 7,startPos = [0, 6],s = \"LLLLLLLLRRRRRRRRUUUUUUUDDDDDDD\") == [6, 6, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 7,startPos = [3, 3],s = \"LLLLDDDDRRRRUUUU\") == [3, 6, 5, 4, 3, 6, 5, 4, 3, 6, 5, 4, 3, 3, 2, 1]\n assert candidate(n = 9,startPos = [4, 4],s = \"LURDLURDLURDLURD\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 5,startPos = [2, 2],s = \"LRLRLRLRLRLRLRLR\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 300,startPos = [299, 299],s = \"DDDDRRRRUUUULLLL\") == [0, 0, 0, 0, 0, 0, 0, 0, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 12,startPos = [5, 5],s = \"UDLRUDLRUDLRUDLRUDLR\") == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 10,startPos = [5, 2],s = \"DDUUDDUUDDUUDDUUDDUUDDUUDDUUDDUU\") == [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]\n assert candidate(n = 6,startPos = [5, 0],s = \"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1]\n assert candidate(n = 15,startPos = [14, 14],s = \"LLLLLLLLLLLLLLL\") == [14, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 9,startPos = [4, 4],s = \"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [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, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1]\n assert candidate(n = 6,startPos = [0, 5],s = \"DDDDDDRRRRRDDDRRLUUL\") == [5, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 3, 2, 1, 0, 0, 1, 0, 0, 1]\n assert candidate(n = 8,startPos = [7, 0],s = \"RRRRRRRRUUUUUUUUDDDDDDDDLLLLLLLL\") == [7, 14, 13, 12, 11, 10, 9, 8, 7, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 5,startPos = [0, 4],s = \"LLLLDDDDRRRRUUUU\") == [16, 10, 8, 6, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 5,startPos = [0, 4],s = \"RRRRRRRRRRRRRRRRRRRR\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 9,startPos = [1, 1],s = \"DRDLDRDLDRDLDRDLDRDLDRDLDRDLDRDL\") == [14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 7,startPos = [3, 3],s = \"LUDDRRUULLDD\") == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 5,startPos = [0, 0],s = \"RLRLRLRLRLRLRLRLRLRL\") == [20, 0, 18, 0, 16, 0, 14, 0, 12, 0, 10, 0, 8, 0, 6, 0, 4, 0, 2, 0]\n assert candidate(n = 10,startPos = [5, 5],s = \"LLLLUUUUDDDDRRRRLLLLUUUUDDDDRRRR\") == [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]\n assert candidate(n = 5,startPos = [2, 2],s = \"DDRRUULLUU\") == [10, 8, 6, 5, 4, 4, 4, 3, 2, 1]\n assert candidate(n = 8,startPos = [1, 1],s = \"DDDDUUUUDDDDUUUUDDDDUUUUDDDDUUUUDDDDUUUU\") == [40, 39, 5, 3, 1, 1, 1, 33, 32, 31, 5, 3, 1, 1, 1, 25, 24, 23, 5, 3, 1, 1, 1, 17, 16, 15, 5, 3, 1, 1, 1, 9, 8, 7, 5, 3, 1, 1, 1, 1]\n assert candidate(n = 6,startPos = [4, 5],s = \"RRRDDDDLUUUULLLRRUUDD\") == [0, 0, 0, 1, 1, 1, 12, 10, 9, 9, 11, 10, 9, 8, 2, 0, 0, 4, 3, 1, 1]\n assert candidate(n = 12,startPos = [6, 6],s = \"RRDDLLUUDDRRLLUUDDRRLLUUDDRRLLUUDDRRLLUUDD\") == [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]\n assert candidate(n = 11,startPos = [5, 5],s = \"DDDDDDDDDDDDLLLLLLLLLLLLUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [5, 5, 5, 5, 5, 5, 5, 10, 9, 8, 7, 6, 5, 5, 5, 5, 5, 5, 5, 10, 9, 8, 7, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1]\n assert candidate(n = 20,startPos = [19, 0],s = \"RRRRRRRRRRRRRRRRRRRRLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == [19, 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]\n assert candidate(n = 8,startPos = [4, 4],s = \"UDLRUDLRUDLRUDLR\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 4,startPos = [2, 3],s = \"LLLDDDLLLLUUUUDDDD\") == [4, 3, 2, 1, 1, 4, 3, 5, 4, 3, 2, 2, 5, 3, 1, 1, 1, 1]\n assert candidate(n = 5,startPos = [4, 0],s = \"DDDDDDDDDDDDDDDDDDDD\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 10,startPos = [5, 5],s = \"UUUUDDDDLLLLRRRR\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 8,startPos = [7, 7],s = \"LLLLUUUUDDDDRRRRLLLLUUUUDDDD\") == [28, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 12, 11, 10, 9, 8, 6, 4, 2, 0, 0, 0, 0]\n assert candidate(n = 6,startPos = [4, 1],s = \"LDDRRULUDR\") == [2, 1, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 7,startPos = [6, 6],s = \"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [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, 6, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 5,startPos = [2, 2],s = \"LUDDRRUUDDLL\") == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 4,startPos = [2, 0],s = \"RRRDDDLLLLUUUUDDDD\") == [4, 3, 2, 1, 1, 1, 0, 0, 0, 0, 2, 2, 5, 3, 1, 1, 1, 1]\n assert candidate(n = 5,startPos = [2, 2],s = \"RRDDLLUUURRDDDLLUUU\") == [19, 18, 17, 16, 4, 3, 2, 12, 11, 4, 3, 2, 7, 6, 4, 3, 2, 2, 1]\n assert candidate(n = 10,startPos = [0, 0],s = \"RRRDDDLLLUUUDDDRRRLUUDLLUURDDLL\") == [30, 7, 5, 3, 2, 1, 0, 0, 0, 0, 0, 0, 18, 12, 6, 4, 3, 2, 0, 0, 0, 1, 0, 0, 0, 0, 4, 2, 1, 0, 0]\n assert candidate(n = 3,startPos = [1, 1],s = \"RLLDDRRUUULLDD\") == [4, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1]\n assert candidate(n = 9,startPos = [4, 4],s = \"DDDDDDDDUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [4, 4, 4, 4, 12, 10, 8, 6, 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, 4, 3, 2, 1]\n assert candidate(n = 6,startPos = [2, 2],s = \"LRLRLRLRLRLRLR\") == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 8,startPos = [0, 7],s = \"RRRRRRRRUUUUUUUUDDDDDDDDLDDDDDDD\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 9,startPos = [8, 0],s = \"RRRRRRRRDDDDDDDDDLLLLLLLLLLLLUUUUUUUUUUUUUUUU\") == [8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 12,startPos = [0, 11],s = \"LLLLLLLLLLLL\") == [11, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 9,startPos = [5, 4],s = \"UUDDLLRRUUDDLLRR\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 10,startPos = [5, 5],s = \"UUUUDDDDLLLLRRRRUUUUDDDDLLLLRRRR\") == [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]\n assert candidate(n = 20,startPos = [10, 10],s = \"LDRURLDRURLDRURLDRU\") == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 15,startPos = [7, 7],s = \"RRRRUUUULLLLDDDDRRRRUUUULLLLDDDD\") == [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]\n assert candidate(n = 7,startPos = [3, 3],s = \"UUUUDDDDLLLLRRRRUUDDLL\") == [3, 10, 9, 8, 3, 6, 5, 4, 3, 13, 12, 11, 3, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 9,startPos = [0, 8],s = \"LLLLLLLLUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [8, 7, 6, 5, 4, 3, 2, 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]\n assert candidate(n = 7,startPos = [1, 1],s = \"DDRRLLUUDDRRLLUUDDRRLLUU\") == [24, 23, 5, 4, 1, 2, 1, 17, 16, 15, 5, 4, 1, 2, 1, 9, 8, 7, 5, 4, 1, 2, 1, 1]\n assert candidate(n = 10,startPos = [2, 5],s = \"RRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLL\") == [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]\n assert candidate(n = 10,startPos = [5, 5],s = \"UUUUUUUUUUDDDDDDDDDDLLLLLLLLLLRRRRRRRRRR\") == [5, 5, 5, 5, 5, 14, 12, 10, 8, 6, 4, 4, 4, 4, 4, 4, 9, 8, 7, 6, 5, 5, 5, 5, 5, 14, 12, 10, 8, 6, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1]\n assert candidate(n = 10,startPos = [9, 0],s = \"RRRRRRRRRRUUUUUUUUUUDDDDDDDDDDDLLLLLLLLLL\") == [9, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 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]\n assert candidate(n = 12,startPos = [6, 6],s = \"UUUUUUUUUUUUDDDDDDDDDDDDLLLLLLLLLLLLRRRRRRRRRRRR\") == [6, 6, 6, 6, 6, 6, 17, 15, 13, 11, 9, 7, 5, 5, 5, 5, 5, 5, 5, 11, 10, 9, 8, 7, 6, 6, 6, 6, 6, 6, 17, 15, 13, 11, 9, 7, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1]\n assert candidate(n = 8,startPos = [3, 4],s = \"RRDLULLLUUDDDDRRRRLU\") == [20, 19, 18, 17, 16, 15, 14, 13, 9, 8, 7, 6, 5, 4, 3, 5, 4, 3, 2, 1]\n assert candidate(n = 10,startPos = [5, 5],s = \"LURDLURDLURDLURDLURDLURD\") == [24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n"}, "metadata": {"canonical_parameter_names": ["n", "startPos", "s"], "leetcode_dataset_entry_point": "Solution().executeInstructions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] executeInstructions(int n, int[] startPos, String s) {", "container": "Solution", "callable": "executeInstructions", "parameters": [{"name": "n", "type": "int"}, {"name": "startPos", "type": "int[]"}, {"name": "s", "type": "String"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2121, "task_id": "intervals-between-identical-elements", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of n integers arr.\nThe interval between two elements in arr is defined as the absolute difference between their indices. More formally, the interval between arr[i] and arr[j] is |i - j|.\nReturn an array intervals of length n where intervals[i] is the sum of intervals between arr[i] and each element in arr with the same value as arr[i].\nNote: |x| is the absolute value of x.\n \nExample 1:\n\nInput: arr = [2,1,3,1,2,3,3]\nOutput: [4,2,7,2,4,4,5]\nExplanation:\n- Index 0: Another 2 is found at index 4. |0 - 4| = 4\n- Index 1: Another 1 is found at index 3. |1 - 3| = 2\n- Index 2: Two more 3s are found at indices 5 and 6. |2 - 5| + |2 - 6| = 7\n- Index 3: Another 1 is found at index 1. |3 - 1| = 2\n- Index 4: Another 2 is found at index 0. |4 - 0| = 4\n- Index 5: Two more 3s are found at indices 2 and 6. |5 - 2| + |5 - 6| = 4\n- Index 6: Two more 3s are found at indices 2 and 5. |6 - 2| + |6 - 5| = 5\n\nExample 2:\n\nInput: arr = [10,5,10,10]\nOutput: [5,0,3,4]\nExplanation:\n- Index 0: Two more 10s are found at indices 2 and 3. |0 - 2| + |0 - 3| = 5\n- Index 1: There is only one 5 in the array, so its sum of intervals to identical elements is 0.\n- Index 2: Two more 10s are found at indices 0 and 3. |2 - 0| + |2 - 3| = 3\n- Index 3: Two more 10s are found at indices 0 and 2. |3 - 0| + |3 - 2| = 4\n\n \nConstraints:\n\nn == arr.length\n1 <= n <= 105\n1 <= arr[i] <= 105\n\n \nNote: This question is the same as 2615: Sum of Distances.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == [20, 0, 14, 0, 12, 0, 14, 0, 20, 0]\n assert candidate(arr = [5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0]\n assert candidate(arr = [1, 3, 2, 3, 1, 4, 2, 3, 1, 4, 2]) == [12, 8, 12, 6, 8, 4, 8, 10, 12, 4, 12]\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(arr = [1, 2, 3, 4, 5]) == [0, 0, 0, 0, 0]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(arr = [10, 5, 10, 10]) == [5, 0, 3, 4]\n assert candidate(arr = [5, 5, 5, 5, 5]) == [10, 7, 6, 7, 10]\n assert candidate(arr = [1, 1, 1, 1, 1]) == [10, 7, 6, 7, 10]\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [2, 1, 3, 1, 2, 3, 3]) == [4, 2, 7, 2, 4, 4, 5]\n assert candidate(arr = [1, 2, 2, 1, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [3, 1, 1, 3, 3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 15]\n assert candidate(arr = [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]) == [42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42]\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10]\n assert candidate(arr = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == [38, 34, 30, 26, 22, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 22, 26, 30, 34, 38]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(arr = [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(arr = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10, 110]) == [90, 0, 74, 0, 62, 0, 54, 0, 50, 0, 50, 0, 54, 0, 62, 0, 74, 0, 90, 0]\n assert candidate(arr = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(arr = [1, 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]) == [1, 1, 1, 1, 3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 15, 21, 16, 13, 12, 13, 16, 21]\n assert candidate(arr = [5, 3, 2, 5, 3, 5, 2, 5, 2, 5, 2, 3]) == [24, 13, 18, 15, 10, 13, 10, 15, 10, 21, 14, 17]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 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, 10, 10, 10, 10, 10]\n assert candidate(arr = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n assert candidate(arr = [100000, 50000, 100000, 25000, 100000, 12500, 100000, 6250, 100000, 3125]) == [20, 0, 14, 0, 12, 0, 14, 0, 20, 0]\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == [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(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [145, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 48, 43, 40, 39, 40, 43, 48, 55, 64]\n assert candidate(arr = [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]) == [30, 30, 30, 30, 30, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 30, 30, 30, 30, 30]\n assert candidate(arr = [100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996, 99996, 99995, 99995]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [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]) == [861, 821, 783, 747, 713, 681, 651, 623, 597, 573, 551, 531, 513, 497, 483, 471, 461, 453, 447, 443, 441, 441, 443, 447, 453, 461, 471, 483, 497, 513, 531, 551, 573, 597, 623, 651, 681, 713, 747, 783, 821, 861]\n assert candidate(arr = [5, 3, 2, 3, 5, 3, 2, 5, 2, 2, 5, 2, 3]) == [21, 17, 26, 13, 13, 13, 14, 13, 12, 13, 19, 19, 27]\n assert candidate(arr = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(arr = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 1]) == [21, 3, 19, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 36]\n assert candidate(arr = [5, 2, 5, 5, 3, 2, 5, 3, 5]) == [19, 4, 13, 12, 3, 4, 15, 3, 21]\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99999]) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10]\n assert candidate(arr = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == [20, 20, 14, 14, 12, 12, 14, 14, 20, 20]\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [51, 47, 45, 51, 47, 45, 51, 47, 45, 51, 47, 45, 51, 47, 45, 45, 47, 51, 45, 47, 51, 45, 47, 51, 45, 47, 51, 45, 47, 51]\n assert candidate(arr = [1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2]) == [57, 63, 47, 45, 48, 38, 33, 39, 35, 27, 36, 38, 27, 39, 47, 33, 48, 62, 45, 63]\n assert candidate(arr = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50]) == [43, 47, 43, 39, 35, 33, 31, 29, 27, 27, 27, 27, 19, 19, 30, 32, 34, 27, 29, 43, 47, 51, 37]\n assert candidate(arr = [200000, 150000, 100000, 50000, 1, 50000, 100000, 150000, 200000, 200000, 150000, 100000, 50000, 1, 50000, 100000, 150000, 200000, 1, 200000]) == [53, 30, 26, 22, 23, 18, 18, 18, 29, 28, 18, 18, 18, 14, 22, 26, 30, 36, 19, 42]\n assert candidate(arr = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == [69, 57, 45, 47, 49, 33, 38, 40, 27, 35, 37, 27, 38, 40, 33, 47, 49, 45, 62, 64]\n assert candidate(arr = [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, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [48, 65, 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 39, 51, 53, 55, 57, 59, 61, 63, 65, 67]\n assert candidate(arr = [100000, 99999, 100000, 99998, 100000, 99997, 100000, 99996, 100000, 99995]) == [20, 0, 14, 0, 12, 0, 14, 0, 20, 0]\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [0, 1, 1, 3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 15]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(arr = [7, 4, 7, 2, 7, 4, 2, 7, 4, 2, 7]) == [23, 11, 17, 9, 15, 7, 6, 18, 10, 9, 27]\n assert candidate(arr = [7, 3, 7, 3, 7, 3, 7, 3, 7, 3]) == [20, 20, 14, 14, 12, 12, 14, 14, 20, 20]\n assert candidate(arr = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2]) == [30, 40, 24, 28, 31, 21, 16, 20, 27, 25, 6, 11, 20, 32, 40, 0, 6, 17, 32, 50]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(arr = [50000, 1, 50000, 2, 50000, 3, 50000, 4, 50000, 5, 50000, 6, 50000, 7, 50000, 8, 50000, 9, 50000, 10]) == [90, 0, 74, 0, 62, 0, 54, 0, 50, 0, 50, 0, 54, 0, 62, 0, 74, 0, 90, 0]\n assert candidate(arr = [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]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(arr = [100000, 200000, 300000, 400000, 500000, 100000, 200000, 300000, 400000, 500000]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(arr = [5, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [6, 13, 5, 5, 5, 9, 6, 5, 5, 5, 14]\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [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]) == [0, 1, 1, 3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 15, 21, 16, 13, 12, 13, 16, 21]\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [22, 20, 22, 20, 22, 20, 22, 20, 22, 20, 20, 22, 20, 22, 20, 22, 20, 22, 20, 22]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [300, 277, 256, 237, 220, 205, 192, 181, 172, 165, 160, 157, 156, 157, 160, 165, 172, 181, 192, 205, 220, 237, 256, 277, 300]\n assert candidate(arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [36, 34, 28, 26, 20, 18, 12, 10, 3, 2, 3, 10, 12, 18, 20, 26, 28, 34, 36]\n assert candidate(arr = [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]) == [42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42]\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [26, 24, 24, 22, 22, 20, 20, 18, 18, 16, 24, 22, 20, 18, 16, 34, 32, 30, 28, 26]\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == [25, 29, 25, 21, 17, 17, 17, 17, 17, 17, 17, 17, 9, 10, 23, 27, 31, 26]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [105, 92, 81, 72, 65, 60, 57, 56, 57, 60, 65, 72, 81, 92, 105]\n assert candidate(arr = [5, 3, 5, 2, 3, 3, 5, 3, 2, 2, 5]) == [18, 13, 14, 11, 7, 7, 14, 11, 6, 7, 22]\n assert candidate(arr = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == [20, 20, 14, 14, 12, 12, 14, 14, 20, 20]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 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, 10, 10, 10, 10, 10]\n assert candidate(arr = [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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(arr = [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]) == [50, 50, 50, 50, 50, 35, 35, 35, 35, 35, 30, 30, 30, 30, 30, 35, 35, 35, 35, 35, 50, 50, 50, 50, 50]\n assert candidate(arr = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [46, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 30, 32, 34, 36, 38, 40, 42, 44, 28, 38, 50, 52, 54, 56, 58, 60, 62, 64, 38]\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == [37, 16, 14, 12, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 19, 20]\n assert candidate(arr = [7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == [154, 0, 130, 0, 110, 0, 94, 0, 82, 0, 74, 0, 70, 70, 72, 76, 82, 90, 100, 112]\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(arr = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n assert candidate(arr = [7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(arr = [9, 7, 5, 3, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1]) == [39, 33, 27, 21, 30, 17, 19, 21, 23, 20, 17, 19, 21, 23, 20, 27, 29, 31, 33, 30]\n assert candidate(arr = [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]) == [3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3]\n assert candidate(arr = [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]) == [1, 1, 1, 1, 1, 1, 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": ["arr"], "leetcode_dataset_entry_point": "Solution().getDistances", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long[] getDistances(int[] arr) {", "container": "Solution", "callable": "getDistances", "parameters": [{"name": "arr", "type": "int[]"}], "return_type": "long[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2122, "task_id": "recover-the-original-array", "difficulty": "Hard", "problem_description": "Alice had a 0-indexed array arr consisting of n positive integers. She chose an arbitrary positive integer k and created two new 0-indexed integer arrays lower and higher in the following manner:\n\nlower[i] = arr[i] - k, for every index i where 0 <= i < n\nhigher[i] = arr[i] + k, for every index i where 0 <= i < n\n\nUnfortunately, Alice lost all three arrays. However, she remembers the integers that were present in the arrays lower and higher, but not the array each integer belonged to. Help Alice and recover the original array.\nGiven an array nums consisting of 2n integers, where exactly n of the integers were present in lower and the remaining in higher, return the original array arr. In case the answer is not unique, return any valid array.\nNote: The test cases are generated such that there exists at least one valid array arr.\n \nExample 1:\n\nInput: nums = [2,10,6,4,8,12]\nOutput: [3,7,11]\nExplanation:\nIf arr = [3,7,11] and k = 1, we get lower = [2,6,10] and higher = [4,8,12].\nCombining lower and higher gives us [2,6,10,4,8,12], which is a permutation of nums.\nAnother valid possibility is that arr = [5,7,9] and k = 3. In that case, lower = [2,4,6] and higher = [8,10,12]. \n\nExample 2:\n\nInput: nums = [1,1,3,3]\nOutput: [2,2]\nExplanation:\nIf arr = [2,2] and k = 1, we get lower = [1,1] and higher = [3,3].\nCombining lower and higher gives us [1,1,3,3], which is equal to nums.\nNote that arr cannot be [1,3] because in that case, the only possible way to obtain [1,1,3,3] is with k = 0.\nThis is invalid since k must be positive.\n\nExample 3:\n\nInput: nums = [5,435]\nOutput: [220]\nExplanation:\nThe only possible combination is arr = [220] and k = 215. Using them, we get lower = [5] and higher = [435].\n\n \nConstraints:\n\n2 * n == nums.length\n1 <= n <= 1000\n1 <= nums[i] <= 109\nThe test cases are generated such that there exists at least one valid array arr.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 1, 5, 7, 9, 11]) == [2, 6, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == [15, 35, 55]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == [2, 3, 6, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == []\n assert candidate(nums = [2, 10, 6, 4, 8, 12]) == [3, 7, 11]\n assert candidate(nums = [1, 3, 5, 7]) == [2, 6]\n assert candidate(nums = [7, 9, 11, 13, 15, 17]) == [8, 12, 16]\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == [150, 350, 550]\n assert candidate(nums = [9, 11, 13, 15, 17, 19]) == [10, 14, 18]\n assert candidate(nums = [5, 435]) == [220]\n assert candidate(nums = [1, 1, 3, 3]) == [2, 2]\n assert candidate(nums = [1000000000, 1]) == []\n assert candidate(nums = [2, 2, 2, 2]) == []\n assert candidate(nums = [3, 9, 3, 9, 5, 7]) == []\n assert candidate(nums = [3, 3, 3, 9, 9, 9]) == [6, 6, 6]\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]\n assert candidate(nums = [10, 22, 30, 42, 50, 62, 70, 82, 90, 102, 110, 122]) == [16, 36, 56, 76, 96, 116]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [2, 6, 10, 14, 18, 22, 26, 30]\n assert candidate(nums = [10, 100, 20, 110, 30, 120, 40, 130, 50, 140, 60, 150, 70, 160, 80, 170]) == [15, 35, 55, 75, 105, 125, 145, 165]\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, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == [2, 3, 6, 7, 10, 11, 14, 15, 18, 19]\n assert candidate(nums = [2, 4, 8, 10, 16, 18, 24, 26, 32, 34, 40, 42, 48, 50, 56, 58, 64, 66, 72, 74, 80, 82, 88, 90, 96, 98, 104, 106, 112, 114, 120, 122, 128, 130, 136, 138, 144, 146, 152, 154, 160, 162, 168, 170, 176, 178, 184, 186, 192, 194, 200]) == [3, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105, 113, 121, 129, 137, 145, 153, 161, 169, 177, 185, 193]\n assert candidate(nums = [1, 3, 3, 5, 7, 7, 9, 11, 11, 13, 15, 17, 17, 19]) == []\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [2, 6, 10, 14, 18, 22, 26, 30]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16]) == [3, 7, 11, 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]) == []\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == [150, 350, 550, 750, 950, 1150, 1350, 1550, 1750, 1950]\n assert candidate(nums = [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]) == []\n assert candidate(nums = [5, 9, 13, 17, 21, 25, 29, 33]) == [7, 15, 23, 31]\n assert candidate(nums = [10, 20, 15, 25, 30, 40, 35, 45, 50, 60, 55, 65, 70, 80, 75, 85]) == [15, 20, 35, 40, 55, 60, 75, 80]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == [3, 11, 19, 27, 35]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [2, 3, 6, 7, 10, 11, 14, 15]\n assert candidate(nums = [7, 21, 14, 28, 21, 42, 28, 56, 35, 70, 42, 84, 49, 98, 56, 112]) == []\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995]) == [499999998, 499999999, 500000000, 500000001, 500000002, 500000003]\n assert candidate(nums = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == [11, 15, 19, 23, 27, 31, 35, 39]\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == [2, 3, 999999998, 999999999]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80]) == [15, 35, 55, 75]\n assert candidate(nums = [5, 5, 5, 5, 9, 9, 9, 9]) == [7, 7, 7, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]) == [6, 6, 6, 6, 6, 6, 6, 6, 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == []\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10]) == []\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000]) == [1500000000, 3500000000]\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39]) == [5, 13, 21, 29, 37]\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, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46]\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69]) == [6, 18, 30, 42, 54, 66]\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45]) == [6, 18, 30, 42]\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]) == []\n assert candidate(nums = [5, 5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15]) == []\n assert candidate(nums = [10, 22, 34, 46, 58, 70, 82, 94, 106, 118, 130, 142, 154, 166, 178]) == [16, 40, 64, 88, 112, 136, 160]\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]) == [2, 3, 3, 4, 6, 7, 7, 8, 10, 11, 11]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == [150, 350, 550, 750, 950, 1150]\n assert candidate(nums = [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, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [2, 6, 10, 14, 18, 22, 26]\n assert candidate(nums = [2, 6, 10, 4, 8, 12, 16, 20]) == []\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14]) == []\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53]) == [3, 11, 19, 27, 35, 43, 51]\n assert candidate(nums = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49]) == [7, 15, 23, 31, 39, 47]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == []\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20]) == []\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == [3, 7, 11, 15, 19, 23, 27, 31]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]) == [10, 30, 50, 70, 90, 110]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == [150, 350, 550, 750, 950, 1150, 1350, 1550]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == [3, 7, 11, 15, 19, 23, 27, 31, 35, 39]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [10, 30, 50, 70, 90]\n assert candidate(nums = [10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86]) == [12, 20, 28, 36, 44, 52, 60, 68, 76, 84]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 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]) == [2, 3, 6, 7, 10, 11, 14, 15, 18, 19]\n assert candidate(nums = [1, 1, 1, 1, 3, 3, 3, 3]) == [2, 2, 2, 2]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == [3, 7, 11, 15, 19, 23, 27, 31]\n assert candidate(nums = [1000000000, 2000000000, 500000000, 1500000000, 750000000, 1250000000]) == [750000000, 1000000000, 1750000000]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == [3, 7, 11, 15, 19, 23]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == [6, 9, 18, 21, 30, 33, 42, 45, 54, 57]\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]) == []\n assert candidate(nums = [1, 2, 5, 6, 9, 10, 13, 14, 17, 18]) == []\n assert candidate(nums = [1, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105]) == [5, 21, 37, 53, 69, 85, 101]\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, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == [10, 15, 30, 35, 50, 55, 70, 75, 90, 95, 110, 115, 130, 135, 150, 155, 170, 175, 190, 195]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [2, 6, 10, 14, 18]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [15, 35, 55, 75, 95]\n assert candidate(nums = [2, 14, 8, 6, 10, 18, 12, 4]) == []\n assert candidate(nums = [100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175]) == [105, 110, 125, 130, 145, 150, 165, 170]\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]) == [15, 35, 55, 75, 95, 115, 135, 155, 175, 195, 215, 235]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == [15, 35, 55, 75, 95, 115, 135, 155]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [3, 7, 11, 15, 19]\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004, 1000000005]) == []\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [15, 20, 35, 40, 55, 60, 75, 80, 95, 100]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == [3, 11, 19, 27, 35]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [15, 35, 55, 75, 95, 115, 135]\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165]) == [20, 40, 60, 80, 100, 120, 140, 160]\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, 3, 6, 7, 10, 11, 14, 15, 18, 19]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == [15, 35, 55, 75, 95, 115]\n assert candidate(nums = [1000000000, 2000000000]) == [1500000000]\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47]) == [5, 13, 21, 29, 37, 45]\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, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99]\n assert candidate(nums = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65]) == [7, 15, 23, 31, 39, 47, 55, 63]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [10, 15, 30, 35, 50, 55, 70, 75, 90, 95]\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004, 1000000005]) == []\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]) == [15, 35, 55, 75, 95, 115, 135, 155, 175, 195, 215, 235]\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, 6, 10, 14, 18, 22, 26, 30, 34, 38]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == [15, 35, 55, 75, 95, 115, 135, 155]\n assert candidate(nums = [1, 1, 1, 1, 5, 5, 5, 5]) == [3, 3, 3, 3]\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 2000000000, 2000000001, 2000000002, 2000000003]) == [1000000001, 1000000002, 2000000001, 2000000002]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [15, 35, 55, 75, 95]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [3, 7, 11, 15, 19]\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, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == []\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == [20, 40, 60, 80, 100, 120]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == [10, 15, 30, 35, 50, 55, 70, 75]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == [2, 6, 10, 14, 18, 22]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80]) == [15, 35, 55, 75]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [150, 350, 550, 750, 950]\n assert candidate(nums = [100, 101, 200, 201, 300, 301, 400, 401]) == [150, 151, 350, 351]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().recoverArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] recoverArray(int[] nums) {", "container": "Solution", "callable": "recoverArray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2124, "task_id": "check-if-all-as-appears-before-all-bs", "difficulty": "Easy", "problem_description": "Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.\n \nExample 1:\n\nInput: s = \"aaabbb\"\nOutput: true\nExplanation:\nThe 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5.\nHence, every 'a' appears before every 'b' and we return true.\n\nExample 2:\n\nInput: s = \"abab\"\nOutput: false\nExplanation:\nThere is an 'a' at index 2 and a 'b' at index 1.\nHence, not every 'a' appears before every 'b' and we return false.\n\nExample 3:\n\nInput: s = \"bbb\"\nOutput: true\nExplanation:\nThere are no 'a's, hence, every 'a' appears before every 'b' and we return true.\n\n \nConstraints:\n\n1 <= s.length <= 100\ns[i] is either 'a' or 'b'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"b\") == True\n assert candidate(s = \"aaaaabbbbb\") == True\n assert candidate(s = \"bbb\") == True\n assert candidate(s = \"ab\") == True\n assert candidate(s = \"aabbaa\") == False\n assert candidate(s = \"ba\") == False\n assert candidate(s = \"bba\") == False\n assert candidate(s = \"aaa\") == True\n assert candidate(s = \"aabbaabb\") == False\n assert candidate(s = \"aaabbb\") == True\n assert candidate(s = \"a\") == True\n assert candidate(s = \"aabbabbb\") == False\n assert candidate(s = \"abab\") == False\n assert candidate(s = \"abbb\") == True\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\") == True\n assert candidate(s = \"abababbabababbab\") == False\n assert candidate(s = \"baaa\") == False\n assert candidate(s = \"bbbbbbbbbb\") == True\n assert candidate(s = \"aabababababbb\") == False\n assert candidate(s = \"bbbbbaaaaaaaaa\") == False\n assert candidate(s = \"ababbab\") == False\n assert candidate(s = \"aaaabbbbbaaabb\") == False\n assert candidate(s = \"baaabbb\") == False\n assert candidate(s = \"bbaaabbb\") == False\n assert candidate(s = \"abbbab\") == False\n assert candidate(s = \"aabbbbbba\") == False\n assert candidate(s = \"aabbbbbaaab\") == False\n assert candidate(s = \"aabaa\") == False\n assert candidate(s = \"aabaaabba\") == False\n assert candidate(s = \"aabbbbabbab\") == False\n assert candidate(s = \"aaaaaaaaaa\") == True\n assert candidate(s = \"babbaabbaabbaabb\") == False\n assert candidate(s = \"baaabaaa\") == False\n assert candidate(s = \"bbbbbbbaaaaaa\") == False\n assert candidate(s = \"aaaababbbb\") == False\n assert candidate(s = \"aabbbbaaa\") == False\n assert candidate(s = \"aaaa\") == True\n assert candidate(s = \"bbbbbbbbbaaaaaaaaa\") == False\n assert candidate(s = \"bbbbbaaaa\") == False\n assert candidate(s = \"aabbaabbabba\") == False\n assert candidate(s = \"aaaaaaaaa\") == True\n assert candidate(s = \"aaabbaabbb\") == False\n assert candidate(s = \"bbbbbaaaaa\") == False\n assert candidate(s = \"aaabba\") == False\n assert candidate(s = \"bbbbaaab\") == False\n assert candidate(s = \"aabbabb\") == False\n assert candidate(s = \"bbab\") == False\n assert candidate(s = \"baaaab\") == False\n assert candidate(s = \"bbbbabaa\") == False\n assert candidate(s = \"aabbbbba\") == False\n assert candidate(s = \"baaabbbb\") == False\n assert candidate(s = \"bbbaaa\") == False\n assert candidate(s = \"abbbbaaaaa\") == False\n assert candidate(s = \"aaaaaabbbbbb\") == True\n assert candidate(s = \"aaabbbaa\") == False\n assert candidate(s = \"bbbbba\") == False\n assert candidate(s = \"aaaabbbbaaaa\") == False\n assert candidate(s = \"bab\") == False\n assert candidate(s = \"bbaabbba\") == False\n assert candidate(s = \"aaaaabbbbbaaa\") == False\n assert candidate(s = \"baaaabbb\") == False\n assert candidate(s = \"aabbaabbb\") == False\n assert candidate(s = \"aaaabbbbba\") == False\n assert candidate(s = \"bababababa\") == False\n assert candidate(s = \"abbbbaaa\") == False\n assert candidate(s = \"bbaaaabbb\") == False\n assert candidate(s = \"aabbbbbbaaaa\") == False\n assert candidate(s = \"aaabb\") == True\n assert candidate(s = \"aabaaaabbb\") == False\n assert candidate(s = \"aaaaaaaaaabbbbbbbb\") == True\n assert candidate(s = \"aaabbbaaab\") == False\n assert candidate(s = \"ababababababab\") == False\n assert candidate(s = \"aabbabaa\") == False\n assert candidate(s = \"bbbbaa\") == False\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbb\") == True\n assert candidate(s = \"bbbbbaab\") == False\n assert candidate(s = \"bbbbbaaabbaabbaabb\") == False\n assert candidate(s = \"abbbbbba\") == False\n assert candidate(s = \"aaaaaaaaabbbbbbbb\") == True\n assert candidate(s = \"bbbaaaaa\") == False\n assert candidate(s = \"abbbba\") == False\n assert candidate(s = \"aaaabbbbbbba\") == False\n assert candidate(s = \"aaaaaab\") == True\n assert candidate(s = \"babababaab\") == False\n assert candidate(s = \"abababab\") == False\n assert candidate(s = \"aaaaa\") == True\n assert candidate(s = \"bbaaaa\") == False\n assert candidate(s = \"aabbbbaa\") == False\n assert candidate(s = \"aababbaa\") == False\n assert candidate(s = \"aabbbbbaa\") == False\n assert candidate(s = \"abbbbbbaaaaa\") == False\n assert candidate(s = \"aaabbbbbba\") == False\n assert candidate(s = \"bbbbbbbbaaaa\") == False\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbb\") == True\n assert candidate(s = \"bbbbbaaaaabbb\") == False\n assert candidate(s = \"bbaabbabaa\") == False\n assert candidate(s = \"aabb\") == True\n assert candidate(s = \"ababbabababbab\") == False\n assert candidate(s = \"bbbbbbbbbaaaaa\") == False\n assert candidate(s = \"aaaabbbaaabb\") == False\n assert candidate(s = \"bababaaaabbbb\") == False\n assert candidate(s = \"bbaaa\") == False\n assert candidate(s = \"aabbaaabaaaabbbb\") == False\n assert candidate(s = \"aabababb\") == False\n assert candidate(s = \"bbbb\") == True\n assert candidate(s = \"aabbaabbbb\") == False\n assert candidate(s = \"baaaaa\") == False\n assert candidate(s = \"bbbbbaaaaabbbb\") == False\n assert candidate(s = \"aabbaaa\") == False\n assert candidate(s = \"ababab\") == False\n assert candidate(s = \"babbba\") == False\n assert candidate(s = \"bbbbbbbb\") == True\n assert candidate(s = \"aaabbbab\") == False\n assert candidate(s = \"bbaaaaaaab\") == False\n assert candidate(s = \"aaaaabbbbbbbba\") == False\n assert candidate(s = \"bbbbaaaaaa\") == False\n assert candidate(s = \"aabbabbbaabbb\") == False\n assert candidate(s = \"bababababab\") == False\n assert candidate(s = \"bbbaa\") == False\n assert candidate(s = \"bbbbbbbbb\") == True\n assert candidate(s = \"baaaabbbb\") == False\n assert candidate(s = \"aaaaabbbbbbbbb\") == True\n assert candidate(s = \"aabbba\") == False\n assert candidate(s = \"bababbababababab\") == False\n assert candidate(s = \"bbbbbbbbbaaab\") == False\n assert candidate(s = \"baab\") == False\n assert candidate(s = \"baaabb\") == False\n assert candidate(s = \"ababababbabababb\") == False\n assert candidate(s = \"bababbab\") == False\n assert candidate(s = \"ababababab\") == False\n assert candidate(s = \"bbbaaaaabbbbbbbbaaaa\") == False\n assert candidate(s = \"aabbbbbaaaa\") == False\n assert candidate(s = \"aabbbbb\") == True\n assert candidate(s = \"bbaa\") == False\n assert candidate(s = \"bbbaababbb\") == False\n assert candidate(s = \"bbbbaaaa\") == False\n assert candidate(s = \"baaab\") == False\n assert candidate(s = \"aaaaaabbbbba\") == False\n assert candidate(s = \"abaaa\") == False\n assert candidate(s = \"bbbaaabbb\") == False\n assert candidate(s = \"babababa\") == False\n assert candidate(s = \"aab\") == True\n assert candidate(s = \"bbbbbbbaaaaaaaaa\") == False\n assert candidate(s = \"abbbabab\") == False\n assert candidate(s = \"bbbbaabbaabb\") == False\n assert candidate(s = \"aabbbba\") == False\n assert candidate(s = \"aaaaaaaa\") == True\n assert candidate(s = \"aababbababaa\") == False\n assert candidate(s = \"aabbababab\") == False\n assert candidate(s = \"abbbbaaaab\") == False\n assert candidate(s = \"bbaaabbaaab\") == False\n assert candidate(s = \"aabbaab\") == False\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean checkString(String s) {", "container": "Solution", "callable": "checkString", "parameters": [{"name": "s", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2125, "task_id": "number-of-laser-beams-in-a-bank", "difficulty": "Medium", "problem_description": "Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is an m x n 2D matrix. bank[i] represents the ith row, consisting of '0's and '1's. '0' means the cell is empty, while'1' means the cell has a security device.\nThere is one laser beam between any two security devices if both conditions are met:\n\nThe two devices are located on two different rows: r1 and r2, where r1 < r2.\nFor each row i where r1 < i < r2, there are no security devices in the ith row.\n\nLaser beams are independent, i.e., one beam does not interfere nor join with another.\nReturn the total number of laser beams in the bank.\n \nExample 1:\n\n\nInput: bank = [\"011001\",\"000000\",\"010100\",\"001000\"]\nOutput: 8\nExplanation: Between each of the following device pairs, there is one beam. In total, there are 8 beams:\n * bank[0][1] -- bank[2][1]\n * bank[0][1] -- bank[2][3]\n * bank[0][2] -- bank[2][1]\n * bank[0][2] -- bank[2][3]\n * bank[0][5] -- bank[2][1]\n * bank[0][5] -- bank[2][3]\n * bank[2][1] -- bank[3][2]\n * bank[2][3] -- bank[3][2]\nNote that there is no beam between any device on the 0th row with any on the 3rd row.\nThis is because the 2nd row contains security devices, which breaks the second condition.\n\nExample 2:\n\n\nInput: bank = [\"000\",\"111\",\"000\"]\nOutput: 0\nExplanation: There does not exist two devices located on two different rows.\n\n \nConstraints:\n\nm == bank.length\nn == bank[i].length\n1 <= m, n <= 500\nbank[i][j] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bank = ['00000', '00000', '00000', '00000']) == 0\n assert candidate(bank = ['001', '000', '101', '000', '110']) == 6\n assert candidate(bank = ['111', '000', '111']) == 9\n assert candidate(bank = ['0000', '0000', '0000', '0000']) == 0\n assert candidate(bank = ['11111', '11111', '11111']) == 50\n assert candidate(bank = ['000', '000', '000']) == 0\n assert candidate(bank = ['101', '010', '101', '010']) == 6\n assert candidate(bank = ['000', '111', '000']) == 0\n assert candidate(bank = ['001', '000', '110', '000', '101']) == 6\n assert candidate(bank = ['1', '0', '1', '0', '1']) == 2\n assert candidate(bank = ['111', '000', '111', '000', '111']) == 18\n assert candidate(bank = ['10101', '01010', '10101', '01010']) == 18\n assert candidate(bank = ['001', '010', '100']) == 2\n assert candidate(bank = ['111', '111', '111', '111']) == 27\n assert candidate(bank = ['101', '000', '101', '111']) == 10\n assert candidate(bank = ['1010', '0101', '1010', '0101']) == 12\n assert candidate(bank = ['1111', '0000', '1111', '0000']) == 16\n assert candidate(bank = ['000', '000', '000', '111']) == 0\n assert candidate(bank = ['000', '000', '000', '000']) == 0\n assert candidate(bank = ['11111', '00000', '00000', '00000', '11111']) == 25\n assert candidate(bank = ['11111', '00000', '11111', '00000']) == 25\n assert candidate(bank = ['00000', '00001', '00010', '00100', '01000', '10000']) == 4\n assert candidate(bank = ['011001', '000000', '010100', '001000']) == 8\n assert candidate(bank = ['1', '1', '1', '1']) == 3\n assert candidate(bank = ['1100', '0011', '0000', '1100']) == 8\n assert candidate(bank = ['00100', '01010', '10001']) == 6\n assert candidate(bank = ['01010', '01010', '01010', '01010']) == 12\n assert candidate(bank = ['1111', '0000', '1111', '0000', '1111']) == 32\n assert candidate(bank = ['000000', '110111', '000000', '111011', '000000', '101010', '000000']) == 40\n assert candidate(bank = ['1010101010', '0101010101', '0000000000', '1111111111', '0000000000', '1010101010']) == 125\n assert candidate(bank = ['11111111111111111111', '00000000000000000000', '11111111111111111111', '00000000000000000000', '11111111111111111111']) == 800\n assert candidate(bank = ['100100', '001100', '010101', '101010', '000000', '111111']) == 37\n assert candidate(bank = ['10101', '01010', '10101', '01010', '10101']) == 24\n assert candidate(bank = ['00100', '01010', '10001', '01010', '10001', '01010']) == 18\n assert candidate(bank = ['100000', '010000', '001000', '000100', '000010', '000001']) == 5\n assert candidate(bank = ['1111111111', '0000000000', '1010101010', '0101010101', '0000000000', '1111111111']) == 125\n assert candidate(bank = ['101010', '101010', '101010', '101010', '101010', '101010']) == 45\n assert candidate(bank = ['10001', '01010', '00100', '00000', '10001', '01010', '00100']) == 14\n assert candidate(bank = ['10000001', '00100100', '00011000', '00000000', '11111111', '00000000', '10101010']) == 56\n assert candidate(bank = ['000', '111', '101', '010', '111', '000', '111']) == 20\n assert candidate(bank = ['01010101', '00000000', '10101010', '00000000', '10101010', '00000000', '10101010']) == 48\n assert candidate(bank = ['110011', '000000', '010100', '001000', '000000', '101010']) == 13\n assert candidate(bank = ['000000000', '000000000', '000000000', '000000000', '111111111', '000000000', '111111111', '000000000', '000000000', '000000000']) == 81\n assert candidate(bank = ['11111', '00000', '10001', '00100', '00000', '10001']) == 14\n assert candidate(bank = ['11111', '10001', '01110', '10001', '11111']) == 32\n assert candidate(bank = ['000000000', '000101000', '000000000', '000010000', '000000000', '100000001']) == 4\n assert candidate(bank = ['000000', '000000', '000000', '000000', '000000', '000000']) == 0\n assert candidate(bank = ['0101010101', '1010101010', '0101010101', '1010101010', '0101010101', '1010101010', '0101010101', '1010101010', '0101010101', '1010101010']) == 225\n assert candidate(bank = ['10000001', '00000000', '00010000', '00000000', '00001000', '00000000', '00000100', '00000000']) == 4\n assert candidate(bank = ['00000', '00000', '00000', '00000', '11111', '11111', '00000', '11111']) == 50\n assert candidate(bank = ['111', '111', '111', '111', '111', '111', '111']) == 54\n assert candidate(bank = ['00000', '00000', '00000', '00000', '00000', '11111', '00000', '11111', '00000', '11111']) == 50\n assert candidate(bank = ['1110011', '0000000', '0111011', '0010100', '1111111', '0000000', '1000010']) == 63\n assert candidate(bank = ['00000', '00100', '01110', '00100', '00000', '11111']) == 11\n assert candidate(bank = ['101010', '010101', '101010', '000000', '010101']) == 27\n assert candidate(bank = ['000000', '101010', '010101', '000000', '101010']) == 18\n assert candidate(bank = ['0000000000', '0000000000', '0000000000', '1111111111', '0000000000', '1010101010', '0101010101', '0000000000']) == 75\n assert candidate(bank = ['0010100', '1011011', '0000000', '0000000', '1100110', '0000000', '1001001', '0101010', '0000000', '0000000', '0000000', '1111111']) == 72\n assert candidate(bank = ['111', '000', '000', '000', '111', '111', '000', '000', '111', '111']) == 36\n assert candidate(bank = ['1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1']) == 7\n assert candidate(bank = ['1111111111', '0000000000', '0000000000', '0000000000', '0000000000', '0000000000', '0000000000', '0000000000', '1111111111', '0000000000']) == 100\n assert candidate(bank = ['110000', '001100', '000011', '001100', '110000', '000000', '110000', '001100', '000011', '001100']) == 32\n assert candidate(bank = ['111111', '000000', '000000', '000000', '111111', '000000', '111111']) == 72\n assert candidate(bank = ['101010', '010101', '101010', '000000', '111111']) == 36\n assert candidate(bank = ['1', '0', '1', '0', '1', '0', '1']) == 3\n assert candidate(bank = ['000000000000000000', '111111111111111111', '000000000000000000', '000000000000000000', '111111111111111111', '000000000000000000', '111111111111111111']) == 648\n assert candidate(bank = ['1010101010', '0101010101', '0000000000', '1111111111', '0000000000', '1010101010', '0101010101']) == 150\n assert candidate(bank = ['1010101010', '0000000000', '0000000000', '1010101010', '0000000000', '0000000000', '1010101010']) == 50\n assert candidate(bank = ['00000', '11111', '10101', '01010', '11111', '00000']) == 31\n assert candidate(bank = ['00000000', '00000000', '00000000', '00000001', '00000010', '00000100', '00001000', '00010000', '00100000', '01000000', '10000000', '00000000', '00000000', '00000000']) == 7\n assert candidate(bank = ['1', '0', '1', '0', '1', '0', '1', '0', '1']) == 4\n assert candidate(bank = ['00000', '10001', '01010', '00100', '10001', '01010', '00100', '10001', '01010', '00100']) == 22\n assert candidate(bank = ['000000', '100101', '001000', '000100', '111111', '000000', '110111']) == 40\n assert candidate(bank = ['010101010101010101', '101010101010101010', '000000000000000000', '000000000000000000', '111111111111111111', '000000000000000000', '101010101010101010']) == 405\n assert candidate(bank = ['111000', '000111', '111000', '000111', '111000', '000111']) == 45\n assert candidate(bank = ['0000000', '0000000', '0000000', '0000000', '0000000', '0000000', '1111111', '1111111']) == 49\n assert candidate(bank = ['111111', '010101', '111111', '000000', '111111']) == 72\n assert candidate(bank = ['0101010101', '0000000000', '1111111111', '0000000000', '1111111111', '0000000000', '0101010101', '1010101010', '0000000000', '1111111111']) == 275\n assert candidate(bank = ['0000000', '0000000', '0101010', '0000000', '1010101', '0000000', '0101010']) == 24\n assert candidate(bank = ['000000', '000000', '101010', '010101', '101010', '000000']) == 18\n assert candidate(bank = ['1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0']) == 9\n assert candidate(bank = ['110101', '000000', '011001', '000000', '100100']) == 18\n assert candidate(bank = ['1001', '0110', '0000', '1101', '0010', '1010', '0101', '0000', '1111']) == 27\n assert candidate(bank = ['111111', '000000', '000000', '000000', '111111', '000000', '111111', '000000', '111111']) == 108\n assert candidate(bank = ['0000000000000000000000', '1111111111111111111111', '0000000000000000000000', '0000000000000000000000', '0000000000000000000000', '0000000000000000000000', '1111111111111111111111']) == 484\n assert candidate(bank = ['111', '111', '000', '111', '111', '000', '111', '111', '000', '111']) == 54\n assert candidate(bank = ['01010101', '10101010', '00000000', '11111111', '01010101']) == 80\n assert candidate(bank = ['111000', '000111', '111000', '000111', '111000']) == 36\n assert candidate(bank = ['00000', '11100', '00111', '01010', '10101', '11111', '00000', '11100', '00111', '01010', '10101']) == 72\n assert candidate(bank = ['111111', '000000', '000000', '000000', '000000', '111111']) == 36\n assert candidate(bank = ['0000000001', '0000000010', '0000000100', '0000001000', '0000010000', '0000100000', '0001000000', '0010000000', '0100000000', '1000000000']) == 9\n assert candidate(bank = ['000000', '000100', '100010', '001000', '010000', '100001', '111111']) == 19\n assert candidate(bank = ['00000', '00000', '00000', '11111', '00000', '11111', '00000', '11111']) == 50\n assert candidate(bank = ['10001', '01100', '00000', '00000', '00000', '01100', '10001', '10001', '01100', '00000', '00000', '10001']) == 24\n assert candidate(bank = ['01110', '00000', '11001', '00000', '01110', '00000', '10010']) == 24\n assert candidate(bank = ['111111', '111111', '111111', '111111', '111111', '111111']) == 180\n assert candidate(bank = ['111000', '000111', '111000', '000111', '111000', '000111', '111000', '000111']) == 63\n assert candidate(bank = ['00100', '01010', '00000', '10001', '01010']) == 10\n assert candidate(bank = ['1010101010', '0101010101', '1010101010', '0000000000', '0000000000', '1010101010', '0101010101', '1010101010']) == 125\n assert candidate(bank = ['0000000', '0011000', '0000000', '1100110', '0000000', '0101010', '0000000', '1000100']) == 26\n assert candidate(bank = ['110101', '000000', '101010', '000000', '110101']) == 24\n assert candidate(bank = ['100100', '011011', '000000', '000000', '100100', '011011']) == 24\n assert candidate(bank = ['001000', '001000', '001000', '001000', '001000', '001000']) == 5\n assert candidate(bank = ['1100011', '0000000', '0110101', '0011001', '1010101', '1111111', '0000000', '1111111']) == 117\n assert candidate(bank = ['010101', '101010', '010101', '101010', '010101', '101010', '010101']) == 54\n assert candidate(bank = ['11111', '00000', '00000', '00000', '11111', '00000', '00000', '11111']) == 50\n assert candidate(bank = ['111111', '000000', '110011', '001100', '111111', '000000', '111111']) == 80\n assert candidate(bank = ['110000', '001100', '000011', '000000', '110000', '001100', '000011']) == 20\n assert candidate(bank = ['0000000', '0010000', '0000100', '0000010', '0000001', '0000000', '0000000']) == 3\n assert candidate(bank = ['000000', '000000', '000000', '000000', '110111', '000000', '101010']) == 15\n assert candidate(bank = ['1111111', '0000000', '0101010', '0000000', '1010101', '0000000', '1111111']) == 61\n assert candidate(bank = ['001000', '010100', '000010', '100001', '000000', '100100', '010010', '001001']) == 18\n assert candidate(bank = ['000000', '010101', '101010', '000000', '111111', '000000']) == 27\n assert candidate(bank = ['000000', '000100', '001010', '010001', '100010', '010100', '100001', '001000']) == 20\n assert candidate(bank = ['1010101', '0101010', '1010101', '0101010', '1010101']) == 48\n assert candidate(bank = ['1111111111', '0000000000', '1111111111', '0000000000', '1111111111', '0000000000', '1111111111', '0000000000', '1111111111', '0000000000']) == 400\n assert candidate(bank = ['1111111111', '0000000000', '0000000000', '0000000000', '0000000000', '1111111111']) == 100\n"}, "metadata": {"canonical_parameter_names": ["bank"], "leetcode_dataset_entry_point": "Solution().numberOfBeams", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfBeams(String[] bank) {", "container": "Solution", "callable": "numberOfBeams", "parameters": [{"name": "bank", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2126, "task_id": "destroying-asteroids", "difficulty": "Medium", "problem_description": "You are given an integer mass, which represents the original mass of a planet. You are further given an integer array asteroids, where asteroids[i] is the mass of the ith asteroid.\nYou can arrange for the planet to collide with the asteroids in any arbitrary order. If the mass of the planet is greater than or equal to the mass of the asteroid, the asteroid is destroyed and the planet gains the mass of the asteroid. Otherwise, the planet is destroyed.\nReturn true if all asteroids can be destroyed. Otherwise, return false.\n \nExample 1:\n\nInput: mass = 10, asteroids = [3,9,19,5,21]\nOutput: true\nExplanation: One way to order the asteroids is [9,19,5,3,21]:\n- The planet collides with the asteroid with a mass of 9. New planet mass: 10 + 9 = 19\n- The planet collides with the asteroid with a mass of 19. New planet mass: 19 + 19 = 38\n- The planet collides with the asteroid with a mass of 5. New planet mass: 38 + 5 = 43\n- The planet collides with the asteroid with a mass of 3. New planet mass: 43 + 3 = 46\n- The planet collides with the asteroid with a mass of 21. New planet mass: 46 + 21 = 67\nAll asteroids are destroyed.\n\nExample 2:\n\nInput: mass = 5, asteroids = [4,9,23,4]\nOutput: false\nExplanation: \nThe planet cannot ever gain enough mass to destroy the asteroid with a mass of 23.\nAfter the planet destroys the other asteroids, it will have a mass of 5 + 4 + 9 + 4 = 22.\nThis is less than 23, so a collision would not destroy the last asteroid.\n \nConstraints:\n\n1 <= mass <= 105\n1 <= asteroids.length <= 105\n1 <= asteroids[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mass = 1,asteroids = [100000]) == False\n assert candidate(mass = 1,asteroids = [1, 2, 3, 4, 5]) == True\n assert candidate(mass = 5,asteroids = [4, 9, 23, 4]) == False\n assert candidate(mass = 10,asteroids = [10, 10, 10, 10, 10]) == True\n assert candidate(mass = 20,asteroids = [10, 10, 10, 10, 10]) == True\n assert candidate(mass = 10,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(mass = 100000,asteroids = [100000]) == True\n assert candidate(mass = 10,asteroids = [5, 5, 5, 5, 5]) == True\n assert candidate(mass = 1,asteroids = [1, 1, 1, 1, 1]) == True\n assert candidate(mass = 1,asteroids = [1, 1, 1, 1]) == True\n assert candidate(mass = 10,asteroids = [3, 9, 19, 5, 21]) == True\n assert candidate(mass = 1,asteroids = [2, 2, 2, 2, 2]) == False\n assert candidate(mass = 100,asteroids = [10, 20, 30, 40, 50]) == True\n assert candidate(mass = 25,asteroids = [5, 10, 15]) == True\n assert candidate(mass = 6,asteroids = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(mass = 30,asteroids = [15, 15, 15, 15, 15]) == True\n assert candidate(mass = 100,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(mass = 1000,asteroids = [500, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(mass = 20,asteroids = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(mass = 50,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == False\n assert candidate(mass = 25,asteroids = [10, 20, 5, 15, 25, 30, 5, 10, 20, 5]) == True\n assert candidate(mass = 500,asteroids = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(mass = 30,asteroids = [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(mass = 100,asteroids = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == True\n assert candidate(mass = 1,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100000]) == False\n assert candidate(mass = 25,asteroids = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(mass = 150,asteroids = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == True\n assert candidate(mass = 10,asteroids = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == True\n assert candidate(mass = 300,asteroids = [250, 200, 150, 100, 50, 300]) == True\n assert candidate(mass = 100,asteroids = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == True\n assert candidate(mass = 100,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(mass = 9,asteroids = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(mass = 50,asteroids = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == True\n assert candidate(mass = 25,asteroids = [20, 10, 5, 15, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(mass = 1000,asteroids = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == True\n assert candidate(mass = 1,asteroids = [100000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(mass = 1000,asteroids = [900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 25, 10, 5, 1]) == True\n assert candidate(mass = 1,asteroids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(mass = 1000,asteroids = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == True\n assert candidate(mass = 200,asteroids = [100, 50, 150, 75, 25, 125, 225, 175, 200, 130]) == True\n assert candidate(mass = 75,asteroids = [50, 25, 12, 6, 3, 1, 50, 25, 12, 6, 3, 1, 50, 25, 12, 6, 3, 1]) == True\n assert candidate(mass = 1,asteroids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(mass = 5,asteroids = [3, 7, 2, 8, 6, 4, 10, 1]) == True\n assert candidate(mass = 15,asteroids = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(mass = 5,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(mass = 20,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(mass = 10,asteroids = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n assert candidate(mass = 5,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(mass = 30,asteroids = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == True\n assert candidate(mass = 25,asteroids = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(mass = 75,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(mass = 25,asteroids = [20, 15, 10, 5, 30, 25, 35, 40, 45, 50]) == True\n assert candidate(mass = 1,asteroids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(mass = 10,asteroids = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == False\n assert candidate(mass = 10,asteroids = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == True\n assert candidate(mass = 50,asteroids = [100, 50, 25, 12, 6, 3, 1]) == True\n assert candidate(mass = 200,asteroids = [100, 150, 50, 200, 250, 300, 350, 400, 450, 500]) == True\n assert candidate(mass = 10,asteroids = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == True\n assert candidate(mass = 1,asteroids = [2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == True\n assert candidate(mass = 1,asteroids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(mass = 50,asteroids = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(mass = 50000,asteroids = [10000, 20000, 15000, 5000, 25000, 30000, 40000, 60000]) == True\n assert candidate(mass = 500,asteroids = [100, 200, 150, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == True\n assert candidate(mass = 5,asteroids = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(mass = 50,asteroids = [100, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == True\n assert candidate(mass = 100,asteroids = [20, 30, 50, 10, 40, 60, 70]) == True\n assert candidate(mass = 10000,asteroids = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == True\n assert candidate(mass = 100,asteroids = [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(mass = 100,asteroids = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(mass = 100,asteroids = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(mass = 50,asteroids = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == True\n assert candidate(mass = 5,asteroids = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(mass = 50000,asteroids = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == True\n assert candidate(mass = 20,asteroids = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == True\n assert candidate(mass = 15,asteroids = [20, 25, 30, 5, 10, 15, 35, 40]) == True\n assert candidate(mass = 10,asteroids = [1, 100000, 2, 99999, 3, 99998, 4, 99997]) == False\n assert candidate(mass = 15,asteroids = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(mass = 120,asteroids = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == True\n assert candidate(mass = 50,asteroids = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == True\n assert candidate(mass = 15,asteroids = [10, 5, 15, 20, 25, 5]) == True\n assert candidate(mass = 25,asteroids = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == True\n assert candidate(mass = 100000,asteroids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(mass = 50,asteroids = [10, 20, 30, 40, 50]) == True\n assert candidate(mass = 100,asteroids = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == True\n assert candidate(mass = 15,asteroids = [1, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(mass = 25,asteroids = [24, 23, 22, 21, 20, 19, 18, 17, 16, 15]) == True\n assert candidate(mass = 5,asteroids = [1, 3, 2, 4, 6, 8, 7, 5, 9, 10]) == True\n assert candidate(mass = 20,asteroids = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n"}, "metadata": {"canonical_parameter_names": ["mass", "asteroids"], "leetcode_dataset_entry_point": "Solution().asteroidsDestroyed", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean asteroidsDestroyed(int mass, int[] asteroids) {", "container": "Solution", "callable": "asteroidsDestroyed", "parameters": [{"name": "mass", "type": "int"}, {"name": "asteroids", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2127, "task_id": "maximum-employees-to-be-invited-to-a-meeting", "difficulty": "Hard", "problem_description": "A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees.\nThe employees are numbered from 0 to n - 1. Each employee has a favorite person and they will attend the meeting only if they can sit next to their favorite person at the table. The favorite person of an employee is not themself.\nGiven a 0-indexed integer array favorite, where favorite[i] denotes the favorite person of the ith employee, return the maximum number of employees that can be invited to the meeting.\n \nExample 1:\n\n\nInput: favorite = [2,2,1,2]\nOutput: 3\nExplanation:\nThe above figure shows how the company can invite employees 0, 1, and 2, and seat them at the round table.\nAll employees cannot be invited because employee 2 cannot sit beside employees 0, 1, and 3, simultaneously.\nNote that the company can also invite employees 1, 2, and 3, and give them their desired seats.\nThe maximum number of employees that can be invited to the meeting is 3. \n\nExample 2:\n\nInput: favorite = [1,2,0]\nOutput: 3\nExplanation: \nEach employee is the favorite person of at least one other employee, and the only way the company can invite them is if they invite every employee.\nThe seating arrangement will be the same as that in the figure given in example 1:\n- Employee 0 will sit between employees 2 and 1.\n- Employee 1 will sit between employees 0 and 2.\n- Employee 2 will sit between employees 1 and 0.\nThe maximum number of employees that can be invited to the meeting is 3.\n\nExample 3:\n\n\nInput: favorite = [3,0,1,4,1]\nOutput: 4\nExplanation:\nThe above figure shows how the company will invite employees 0, 1, 3, and 4, and seat them at the round table.\nEmployee 2 cannot be invited because the two spots next to their favorite employee 1 are taken.\nSo the company leaves them out of the meeting.\nThe maximum number of employees that can be invited to the meeting is 4.\n\n \nConstraints:\n\nn == favorite.length\n2 <= n <= 105\n0 <= favorite[i] <= n - 1\nfavorite[i] != i\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(favorite = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 11\n assert candidate(favorite = [1, 0, 0, 2]) == 4\n assert candidate(favorite = [5, 4, 3, 2, 1, 0]) == 6\n assert candidate(favorite = [0, 1, 2, 3, 4]) == 5\n assert candidate(favorite = [2, 0, 1, 4, 5, 3]) == 3\n assert candidate(favorite = [5, 1, 4, 4, 0, 4]) == 3\n assert candidate(favorite = [5, 4, 0, 2, 0, 1]) == 4\n assert candidate(favorite = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(favorite = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(favorite = [1, 2, 0]) == 3\n assert candidate(favorite = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(favorite = [3, 0, 1, 4, 1]) == 4\n assert candidate(favorite = [1, 0, 3, 2]) == 4\n assert candidate(favorite = [3, 3, 0, 2]) == 3\n assert candidate(favorite = [2, 2, 1, 2]) == 3\n assert candidate(favorite = [1, 0, 0, 2, 1, 4, 2]) == 6\n assert candidate(favorite = [1, 0, 3, 4, 2]) == 3\n assert candidate(favorite = [1, 0, 3, 2, 5, 4]) == 6\n assert candidate(favorite = [3, 3, 3, 2, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8]) == 7\n assert candidate(favorite = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1]) == 8\n assert candidate(favorite = [2, 0, 2, 2, 0, 3, 4, 4, 4, 4]) == 4\n assert candidate(favorite = [1, 2, 0, 4, 5, 8, 3, 6, 7, 9]) == 6\n assert candidate(favorite = [2, 0, 1, 4, 3, 6, 5, 8, 7, 9]) == 7\n assert candidate(favorite = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == 9\n assert candidate(favorite = [2, 0, 1, 4, 5, 6, 3, 7, 8, 9]) == 4\n assert candidate(favorite = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == 10\n assert candidate(favorite = [5, 2, 4, 3, 4, 2]) == 5\n assert candidate(favorite = [3, 0, 1, 4, 5, 3, 6, 7, 8, 9, 10, 11, 10]) == 7\n assert candidate(favorite = [2, 2, 1, 0, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 11\n assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 15, 14, 13, 12]) == 16\n assert candidate(favorite = [1, 2, 0, 5, 6, 3, 4, 9, 7, 8]) == 4\n assert candidate(favorite = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 7\n assert candidate(favorite = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 20\n assert candidate(favorite = [1, 2, 0, 4, 5, 3, 7, 8, 9, 6]) == 4\n assert candidate(favorite = [1, 2, 3, 0, 1, 2, 3, 4, 5, 6]) == 4\n assert candidate(favorite = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 15\n assert candidate(favorite = [1, 2, 0, 3, 4, 5, 6, 7, 8, 9]) == 7\n assert candidate(favorite = [2, 0, 2, 0, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18]) == 19\n assert candidate(favorite = [1, 3, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == 16\n assert candidate(favorite = [1, 2, 0, 5, 6, 3, 4, 9, 10, 7, 8, 11]) == 9\n assert candidate(favorite = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 0, 15]) == 8\n assert candidate(favorite = [1, 5, 0, 3, 4, 2, 6, 7, 8, 9]) == 6\n assert candidate(favorite = [1, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2, 3, 4, 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]) == 27\n assert candidate(favorite = [1, 2, 0, 4, 5, 3, 7, 8, 9, 10, 11, 12, 13, 14, 6]) == 9\n assert candidate(favorite = [3, 0, 1, 0, 7, 6, 5, 4, 9, 8]) == 10\n assert candidate(favorite = [5, 8, 1, 4, 7, 5, 7, 5, 8, 7]) == 7\n assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14]) == 15\n assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 16\n assert candidate(favorite = [1, 2, 3, 4, 5, 6, 0, 7, 8, 9]) == 7\n assert candidate(favorite = [5, 1, 0, 6, 2, 3, 4, 9, 7, 8]) == 6\n assert candidate(favorite = [2, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1]) == 15\n assert candidate(favorite = [2, 0, 1, 4, 3, 5, 6, 7, 8, 9]) == 7\n assert candidate(favorite = [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 19\n assert candidate(favorite = [2, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 3, 0]) == 8\n assert candidate(favorite = [2, 0, 1, 5, 3, 4, 8, 6, 7, 12, 9, 10, 11, 16, 13, 14, 15, 18, 19, 17]) == 4\n assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == 10\n assert candidate(favorite = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(favorite = [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, 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\n assert candidate(favorite = [1, 2, 0, 5, 6, 4, 3, 8, 9, 7, 12, 11, 10, 15, 14, 13]) == 6\n assert candidate(favorite = [4, 0, 4, 1, 2, 1, 3, 5, 6, 9]) == 8\n assert candidate(favorite = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == 8\n assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 10]) == 10\n assert candidate(favorite = [1, 3, 0, 2, 5, 4, 7, 6, 9, 8]) == 6\n assert candidate(favorite = [5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 5\n assert candidate(favorite = [4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11, 16, 17, 18, 19]) == 20\n assert candidate(favorite = [1, 5, 3, 7, 9, 2, 4, 6, 8, 0]) == 9\n assert candidate(favorite = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 20\n assert candidate(favorite = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 2\n assert candidate(favorite = [2, 2, 1, 2, 3, 3, 5, 5, 7, 7]) == 6\n assert candidate(favorite = [2, 3, 0, 1, 6, 5, 4, 9, 7, 8]) == 7\n assert candidate(favorite = [1, 4, 3, 6, 5, 8, 7, 2, 9, 0]) == 6\n assert candidate(favorite = [4, 5, 6, 7, 0, 1, 2, 3, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 16]) == 21\n assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 0, 10, 11, 12, 8, 9, 15, 16, 13, 14, 18, 19, 17]) == 8\n assert candidate(favorite = [3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 1, 0]) == 8\n assert candidate(favorite = [3, 3, 0, 2, 5, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 17\n assert candidate(favorite = [5, 1, 2, 3, 4, 0, 7, 8, 9, 6]) == 6\n assert candidate(favorite = [4, 4, 4, 4, 0, 6, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 17\n assert candidate(favorite = [5, 1, 3, 0, 2, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 11\n assert candidate(favorite = [3, 0, 1, 0, 6, 5, 4, 9, 7, 8]) == 7\n assert candidate(favorite = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 20\n assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 10\n assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0]) == 15\n assert candidate(favorite = [5, 5, 5, 5, 5, 3, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9]) == 6\n assert candidate(favorite = [2, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 9\n assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 0, 9]) == 9\n assert candidate(favorite = [1, 0, 3, 4, 5, 6, 7, 8, 9, 2]) == 8\n assert candidate(favorite = [9, 1, 8, 3, 7, 2, 6, 5, 4, 0]) == 5\n assert candidate(favorite = [3, 2, 1, 0, 8, 8, 8, 8, 5, 5, 5, 5, 11, 11, 11, 11]) == 9\n assert candidate(favorite = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 6\n assert candidate(favorite = [1, 2, 0, 4, 5, 6, 3, 8, 9, 7]) == 4\n assert candidate(favorite = [1, 0, 3, 4, 2, 5, 6, 7, 8, 9]) == 7\n assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 13, 14, 15, 12]) == 12\n assert candidate(favorite = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1]) == 10\n assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == 10\n assert candidate(favorite = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5]) == 8\n assert candidate(favorite = [2, 3, 1, 0, 6, 6, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 16\n assert candidate(favorite = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 0]) == 8\n assert candidate(favorite = [1, 0, 3, 2, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13]) == 16\n assert candidate(favorite = [5, 1, 3, 0, 2, 4, 7, 6, 9, 8, 11, 10, 15, 13, 14, 12]) == 11\n assert candidate(favorite = [1, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2]) == 13\n assert candidate(favorite = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10]) == 10\n assert candidate(favorite = [1, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 0]) == 16\n assert candidate(favorite = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8]) == 10\n assert candidate(favorite = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8]) == 7\n assert candidate(favorite = [2, 0, 4, 6, 1, 3, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 19]) == 13\n assert candidate(favorite = [2, 0, 3, 2, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 21\n assert candidate(favorite = [3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18]) == 20\n assert candidate(favorite = [3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12]) == 16\n assert candidate(favorite = [1, 0, 3, 2, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == 16\n assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 10\n assert candidate(favorite = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 21\n assert candidate(favorite = [3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 18\n assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14, 15, 16, 17, 18, 19]) == 20\n assert candidate(favorite = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 4\n assert candidate(favorite = [2, 3, 1, 0, 6, 7, 8, 9, 5, 10, 11, 4]) == 8\n assert candidate(favorite = [4, 4, 4, 4, 2, 6, 6, 6, 6, 8, 8, 8, 8, 10, 10, 10, 10, 12, 12, 12, 12]) == 7\n assert candidate(favorite = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 11, 10, 13, 12, 15, 14]) == 16\n assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == 22\n assert candidate(favorite = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 14, 15, 12, 13]) == 6\n assert candidate(favorite = [3, 0, 0, 2, 5, 5, 6, 7, 8, 9]) == 6\n assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 20\n assert candidate(favorite = [1, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 41\n assert candidate(favorite = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 20\n assert candidate(favorite = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(favorite = [3, 0, 1, 4, 5, 3, 5, 6, 7, 8]) == 3\n assert candidate(favorite = [2, 0, 1, 5, 5, 5, 5, 5, 5, 5]) == 3\n"}, "metadata": {"canonical_parameter_names": ["favorite"], "leetcode_dataset_entry_point": "Solution().maximumInvitations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumInvitations(int[] favorite) {", "container": "Solution", "callable": "maximumInvitations", "parameters": [{"name": "favorite", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2129, "task_id": "capitalize-the-title", "difficulty": "Easy", "problem_description": "You are given a string title consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the string by changing the capitalization of each word such that:\n\nIf the length of the word is 1 or 2 letters, change all letters to lowercase.\nOtherwise, change the first letter to uppercase and the remaining letters to lowercase.\n\nReturn the capitalized title.\n \nExample 1:\n\nInput: title = \"capiTalIze tHe titLe\"\nOutput: \"Capitalize The Title\"\nExplanation:\nSince all the words have a length of at least 3, the first letter of each word is uppercase, and the remaining letters are lowercase.\n\nExample 2:\n\nInput: title = \"First leTTeR of EACH Word\"\nOutput: \"First Letter of Each Word\"\nExplanation:\nThe word \"of\" has length 2, so it is all lowercase.\nThe remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.\n\nExample 3:\n\nInput: title = \"i lOve leetcode\"\nOutput: \"i Love Leetcode\"\nExplanation:\nThe word \"i\" has length 1, so it is lowercase.\nThe remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.\n\n \nConstraints:\n\n1 <= title.length <= 100\ntitle consists of words separated by a single space without any leading or trailing spaces.\nEach word consists of uppercase and lowercase English letters and is non-empty.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(title = \"ai and ml\") == \"ai And ml\"\n assert candidate(title = \"First leTTeR of EACH Word\") == \"First Letter of Each Word\"\n assert candidate(title = \"tHis iS a tEsT\") == \"This is a Test\"\n assert candidate(title = \"a b c\") == \"a b c\"\n assert candidate(title = \"HELLO WORLD\") == \"Hello World\"\n assert candidate(title = \"a b c d e f g\") == \"a b c d e f g\"\n assert candidate(title = \"sMaLl wOrDs\") == \"Small Words\"\n assert candidate(title = \"mY nAmE is Qwen\") == \"my Name is Qwen\"\n assert candidate(title = \"abc\") == \"Abc\"\n assert candidate(title = \"mY sOLution IS Awesome\") == \"my Solution is Awesome\"\n assert candidate(title = \"ab\") == \"ab\"\n assert candidate(title = \"Python Programming\") == \"Python Programming\"\n assert candidate(title = \"this is a test\") == \"This is a Test\"\n assert candidate(title = \"i lOve leetcode\") == \"i Love Leetcode\"\n assert candidate(title = \"mY NaMe Is Qwen\") == \"my Name is Qwen\"\n assert candidate(title = \"capiTalIze tHe titLe\") == \"Capitalize The Title\"\n assert candidate(title = \"Alibaba Cloud\") == \"Alibaba Cloud\"\n assert candidate(title = \"machine learning\") == \"Machine Learning\"\n assert candidate(title = \"tHis is a TeSt\") == \"This is a Test\"\n assert candidate(title = \"a\") == \"a\"\n assert candidate(title = \"hello world\") == \"Hello World\"\n assert candidate(title = \"tHis is A tEsT cASE\") == \"This is a Test Case\"\n assert candidate(title = \"data science\") == \"Data Science\"\n assert candidate(title = \"data science and machine learning\") == \"Data Science And Machine Learning\"\n assert candidate(title = \"the quick\") == \"The Quick\"\n assert candidate(title = \"tiny a big BIGGEST\") == \"Tiny a Big Biggest\"\n assert candidate(title = \"advanced DATABASE MANAGEMENT SYSTEM\") == \"Advanced Database Management System\"\n assert candidate(title = \"FLASK and DJANGO web FRAMEWORKS\") == \"Flask And Django Web Frameworks\"\n assert candidate(title = \"sINGLEcHaRaCters AND twOCHaRaCters\") == \"Singlecharacters And Twocharacters\"\n assert candidate(title = \"PYTHON pROGRAMMING\") == \"Python Programming\"\n assert candidate(title = \"pyThOn cOdInG chAlLenge\") == \"Python Coding Challenge\"\n assert candidate(title = \"data sCience and MaChine LeArning\") == \"Data Science And Machine Learning\"\n assert candidate(title = \"PYTHON programming LANGUAGE\") == \"Python Programming Language\"\n assert candidate(title = \"DESIGN PATTERNS in software ENGINEERING\") == \"Design Patterns in Software Engineering\"\n assert candidate(title = \"lowercase with small words like a and the\") == \"Lowercase With Small Words Like a And The\"\n assert candidate(title = \"wHy cApItAlIzE sOmE wOrDs\") == \"Why Capitalize Some Words\"\n assert candidate(title = \"data sCience and MaChInE lEaRnInG\") == \"Data Science And Machine Learning\"\n assert candidate(title = \"WEB DEVELOPMENT essentials\") == \"Web Development Essentials\"\n assert candidate(title = \"an\") == \"an\"\n assert candidate(title = \"Data Science and Machine Learning\") == \"Data Science And Machine Learning\"\n assert candidate(title = \"INformation TECHNOLOGY\") == \"Information Technology\"\n assert candidate(title = \"cryptography and SECURITY\") == \"Cryptography And Security\"\n assert candidate(title = \"UPPER lower CASE\") == \"Upper Lower Case\"\n assert candidate(title = \"SOFTWARE ENGINEERING principles\") == \"Software Engineering Principles\"\n assert candidate(title = \"LONGEST wORD\") == \"Longest Word\"\n assert candidate(title = \"pYtHoN pRoGrAmMiNg\") == \"Python Programming\"\n assert candidate(title = \"multiple spaces here\") == \"Multiple Spaces Here\"\n assert candidate(title = \"sInGlE\") == \"Single\"\n assert candidate(title = \"openai gpt four\") == \"Openai Gpt Four\"\n assert candidate(title = \"user INTERFACE and user EXPERIENCE\") == \"User Interface And User Experience\"\n assert candidate(title = \"VIRTUALIZATION technology\") == \"Virtualization Technology\"\n assert candidate(title = \"in the land OF wonder AND magic\") == \"in The Land of Wonder And Magic\"\n assert candidate(title = \"CoMpLeX wOrDs LiKe SuPeRcAlIfR aNd qUiXoTtIc\") == \"Complex Words Like Supercalifr And Quixottic\"\n assert candidate(title = \"tHis is A tEsT String\") == \"This is a Test String\"\n assert candidate(title = \"INTERNET of THINGS iot\") == \"Internet of Things Iot\"\n assert candidate(title = \"tHiS is a sHoRt TeSt\") == \"This is a Short Test\"\n assert candidate(title = \"python programming LANGUAGE\") == \"Python Programming Language\"\n assert candidate(title = \"a quick brown fox jumps over the lazy dog\") == \"a Quick Brown Fox Jumps Over The Lazy Dog\"\n assert candidate(title = \"UPPERCASE lowercase MIXEDcase\") == \"Uppercase Lowercase Mixedcase\"\n assert candidate(title = \"a SHORT story IN a SMALL town\") == \"a Short Story in a Small Town\"\n assert candidate(title = \"single\") == \"Single\"\n assert candidate(title = \"data STRUCTURE and ALGORITHMS\") == \"Data Structure And Algorithms\"\n assert candidate(title = \"this is a test STRING with MIXED CASE\") == \"This is a Test String With Mixed Case\"\n assert candidate(title = \"to be or not to be\") == \"to be or Not to be\"\n assert candidate(title = \"wordlengthsofthreetwoone\") == \"Wordlengthsofthreetwoone\"\n assert candidate(title = \"wiTh lOnG wOrDs liKe suPercalifragilisticexpialidocious\") == \"With Long Words Like Supercalifragilisticexpialidocious\"\n assert candidate(title = \"this is a longer sentence with more words to test the function\") == \"This is a Longer Sentence With More Words to Test The Function\"\n assert candidate(title = \"very Very LONG title with MANY Words indeed\") == \"Very Very Long Title With Many Words Indeed\"\n assert candidate(title = \"Algorithms and DATA structures\") == \"Algorithms And Data Structures\"\n assert candidate(title = \"tEsTiNg WoRdS wItH vArIoUs lEnGtHs\") == \"Testing Words With Various Lengths\"\n assert candidate(title = \"a quick brown fox\") == \"a Quick Brown Fox\"\n assert candidate(title = \"tExT pRoCeSsInG\") == \"Text Processing\"\n assert candidate(title = \"the quick BROWN fox JUMPS OVER the LAZY DOG\") == \"The Quick Brown Fox Jumps Over The Lazy Dog\"\n assert candidate(title = \"algorithms and data structures\") == \"Algorithms And Data Structures\"\n assert candidate(title = \"a short AND a LONG word\") == \"a Short And a Long Word\"\n assert candidate(title = \"AlGoRiThM aNd dAtA sTrUcTuRe\") == \"Algorithm And Data Structure\"\n assert candidate(title = \"data sCIENCE and maCHine LEARNING\") == \"Data Science And Machine Learning\"\n assert candidate(title = \"cOnsIdEr tHiS eXaMpLe\") == \"Consider This Example\"\n assert candidate(title = \"cloud COMPUTING\") == \"Cloud Computing\"\n assert candidate(title = \"fLASK aNd dJANGO\") == \"Flask And Django\"\n assert candidate(title = \"To be OR not TO be\") == \"to be or Not to be\"\n assert candidate(title = \"multiple words of varying length and CASE\") == \"Multiple Words of Varying Length And Case\"\n assert candidate(title = \"network SECURITY\") == \"Network Security\"\n assert candidate(title = \"programming IN python\") == \"Programming in Python\"\n assert candidate(title = \"the QUICK brown FOX jumps OVER the LAZY dog\") == \"The Quick Brown Fox Jumps Over The Lazy Dog\"\n assert candidate(title = \"MiXcAsE wOrDlEnGtH\") == \"Mixcase Wordlength\"\n assert candidate(title = \"in\") == \"in\"\n assert candidate(title = \"wiTh grEat pOwEr cOmEs gReAt rEsPoNsIbIlItY\") == \"With Great Power Comes Great Responsibility\"\n assert candidate(title = \"algorithms AND dataSTRUCTURES\") == \"Algorithms And Datastructures\"\n assert candidate(title = \"wiTh gReAt pOWeR cOmEs gReAt rEsPoNsIbIlItY\") == \"With Great Power Comes Great Responsibility\"\n assert candidate(title = \"A B c D E F G\") == \"a b c d e f g\"\n assert candidate(title = \"AI and MACHINE LEARNING\") == \"ai And Machine Learning\"\n assert candidate(title = \"big DATA ANALYSIS\") == \"Big Data Analysis\"\n assert candidate(title = \"mUlTiPlE sMaLl wOrDs\") == \"Multiple Small Words\"\n assert candidate(title = \"LEETcode IS coOL\") == \"Leetcode is Cool\"\n assert candidate(title = \"two Words\") == \"Two Words\"\n assert candidate(title = \"introduction to ARTIFICIAL INTELLIGENCE\") == \"Introduction to Artificial Intelligence\"\n assert candidate(title = \"sOlVe tHe rObOt wOrLd cHAlLeNgEs\") == \"Solve The Robot World Challenges\"\n assert candidate(title = \"mIxEd cAsE iNpUt\") == \"Mixed Case Input\"\n assert candidate(title = \"EACH WORD IN THE TITLE\") == \"Each Word in The Title\"\n assert candidate(title = \"programming in PYTHON\") == \"Programming in Python\"\n assert candidate(title = \"one two three four five six seven eight nine ten\") == \"One Two Three Four Five Six Seven Eight Nine Ten\"\n assert candidate(title = \"very very LONG words in THIS sentence\") == \"Very Very Long Words in This Sentence\"\n assert candidate(title = \"leet code CHALLENGE\") == \"Leet Code Challenge\"\n assert candidate(title = \"the\") == \"The\"\n assert candidate(title = \"double two\") == \"Double Two\"\n assert candidate(title = \"a B c D E F G\") == \"a b c d e f g\"\n assert candidate(title = \"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\"\n assert candidate(title = \"in The HoLlyWoOd\") == \"in The Hollywood\"\n assert candidate(title = \"tHis is a tEsT string\") == \"This is a Test String\"\n assert candidate(title = \"MiXeD CaSe wOrDs\") == \"Mixed Case Words\"\n assert candidate(title = \"multiple small words in here\") == \"Multiple Small Words in Here\"\n assert candidate(title = \"in the HEART of the CITY\") == \"in The Heart of The City\"\n assert candidate(title = \"randomly CaPiTaLiZed WoRds\") == \"Randomly Capitalized Words\"\n assert candidate(title = \"To BE OR NOT to BE\") == \"to be or Not to be\"\n assert candidate(title = \"MiNiMaL MaXiMaL\") == \"Minimal Maximal\"\n assert candidate(title = \"HELLO wORLD\") == \"Hello World\"\n assert candidate(title = \"THE quick BROWN fox JUMPS OVER the LAZY dog\") == \"The Quick Brown Fox Jumps Over The Lazy Dog\"\n assert candidate(title = \"data SCIENCE and MACHINE LEARNING\") == \"Data Science And Machine Learning\"\n assert candidate(title = \"pYthon programming lanGuage\") == \"Python Programming Language\"\n assert candidate(title = \"OpenAI GPT-4\") == \"Openai Gpt-4\"\n assert candidate(title = \"triple three words\") == \"Triple Three Words\"\n assert candidate(title = \"eNcYcLopEdIa oF pHySiCs aNd mAtHeMaTiCs\") == \"Encyclopedia of Physics And Mathematics\"\n assert candidate(title = \"a a a a a a a\") == \"a a a a a a a\"\n assert candidate(title = \"openAI GPT AND machineLEARNING\") == \"Openai Gpt And Machinelearning\"\n assert candidate(title = \"PYTHON programming\") == \"Python Programming\"\n assert candidate(title = \"sOFTWARE dEVELOPMENT\") == \"Software Development\"\n assert candidate(title = \"tHiS iS a TeSt CaSe\") == \"This is a Test Case\"\n assert candidate(title = \"wEb dEveLopMeNt fOr bEgInNeRs\") == \"Web Development For Beginners\"\n assert candidate(title = \"one\") == \"One\"\n assert candidate(title = \"Data STRUCTURES and ALGORITHMs\") == \"Data Structures And Algorithms\"\n assert candidate(title = \"aBcDeFgHiJ kLmNoPqRsT\") == \"Abcdefghij Klmnopqrst\"\n assert candidate(title = \"Python Programming Language\") == \"Python Programming Language\"\n assert candidate(title = \"blockCHAIN technology\") == \"Blockchain Technology\"\n assert candidate(title = \"Python Programming Is Fun\") == \"Python Programming is Fun\"\n assert candidate(title = \"LoNg WoRdS aNd sHoRt wOrDs\") == \"Long Words And Short Words\"\n assert candidate(title = \"tHe qUiCk bRoWn fOx\") == \"The Quick Brown Fox\"\n"}, "metadata": {"canonical_parameter_names": ["title"], "leetcode_dataset_entry_point": "Solution().capitalizeTitle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String capitalizeTitle(String title) {", "container": "Solution", "callable": "capitalizeTitle", "parameters": [{"name": "title", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2130, "task_id": "maximum-twin-sum-of-a-linked-list", "difficulty": "Medium", "problem_description": "In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) - 1.\n\nFor example, if n = 4, then node 0 is the twin of node 3, and node 1 is the twin of node 2. These are the only nodes with twins for n = 4.\n\nThe twin sum is defined as the sum of a node and its twin.\nGiven the head of a linked list with even length, return the maximum twin sum of the linked list.\n \nExample 1:\n\n\nInput: head = [5,4,2,1]\nOutput: 6\nExplanation:\nNodes 0 and 1 are the twins of nodes 3 and 2, respectively. All have twin sum = 6.\nThere are no other nodes with twins in the linked list.\nThus, the maximum twin sum of the linked list is 6. \n\nExample 2:\n\n\nInput: head = [4,2,2,3]\nOutput: 7\nExplanation:\nThe nodes with twins present in this linked list are:\n- Node 0 is the twin of node 3 having a twin sum of 4 + 3 = 7.\n- Node 1 is the twin of node 2 having a twin sum of 2 + 2 = 4.\nThus, the maximum twin sum of the linked list is max(7, 4) = 7. \n\nExample 3:\n\n\nInput: head = [1,100000]\nOutput: 100001\nExplanation:\nThere is only one node with a twin in the linked list having twin sum of 1 + 100000 = 100001.\n\n \nConstraints:\n\nThe number of nodes in the list is an even integer in the range [2, 105].\n1 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(head = list_node([9, 4, 2, 10, 7, 8])) == 17\n assert candidate(head = list_node([4, 2, 2, 3])) == 7\n assert candidate(head = list_node([8, 7, 6, 5, 4, 3, 2, 1])) == 9\n assert candidate(head = list_node([99999, 99999, 99999, 99999])) == 199998\n assert candidate(head = list_node([100000, 1, 100000, 1])) == 100001\n assert candidate(head = list_node([5, 4, 2, 1])) == 6\n assert candidate(head = list_node([1, 100000])) == 100001\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6])) == 7\n assert candidate(head = list_node([9, 4, 2, 10])) == 19\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8])) == 9\n assert candidate(head = list_node([3, 3, 5, 5, 7, 7, 9, 9])) == 12\n assert candidate(head = list_node([8, 9, 10, 11, 12, 13, 14, 15])) == 23\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2])) == 3\n assert candidate(head = list_node([1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 6, 5, 7, 4, 8, 3, 9, 2, 10, 1])) == 20\n assert candidate(head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50])) == 55\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])) == 17\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18])) == 19\n assert candidate(head = list_node([50000, 50000, 50000, 50000, 50000, 50000])) == 100000\n assert candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32])) == 34\n assert candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])) == 32\n assert candidate(head = list_node([99999, 1, 99998, 2, 99997, 3, 99996, 4])) == 100003\n assert candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1])) == 190\n assert candidate(head = list_node([99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984])) == 199983\n assert candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120])) == 130\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == 11\n assert candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120])) == 130\n assert candidate(head = list_node([8, 5, 3, 7, 1, 2, 9, 6])) == 14\n assert candidate(head = list_node([99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5])) == 100004\n assert candidate(head = list_node([1, 10, 2, 9, 3, 8, 4, 7, 5, 6])) == 15\n assert candidate(head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == 10\n assert candidate(head = list_node([1, 9, 2, 8, 3, 7, 4, 6, 5, 5])) == 14\n assert candidate(head = list_node([99999, 1, 99998, 2, 99997, 3, 99996, 4])) == 100003\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == 2\n assert candidate(head = list_node([10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000, 200000])) == 210000\n assert candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970, 99969, 99968, 99967, 99966, 99965, 99964, 99963, 99962, 99961, 99960, 99959, 99958, 99957, 99956, 99955, 99954, 99953, 99952, 99951, 99950, 99949, 99948, 99947, 99946, 99945, 99944, 99943, 99942, 99941, 99940, 99939, 99938, 99937, 99936, 99935, 99934, 99933, 99932, 99931, 99930, 99929, 99928, 99927, 99926, 99925, 99924, 99923, 99922, 99921, 99920, 99919, 99918, 99917, 99916, 99915, 99914, 99913, 99912, 99911, 99910, 99909, 99908, 99907, 99906, 99905, 99904, 99903, 99902, 99901, 99900])) == 199900\n assert candidate(head = list_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])) == 21\n assert candidate(head = list_node([25000, 30000, 35000, 40000, 45000, 40000, 35000, 30000, 25000, 20000, 20000, 25000, 30000, 35000, 40000, 45000])) == 70000\n assert candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])) == 32\n assert candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200])) == 210\n assert candidate(head = list_node([1000, 900, 800, 700, 600, 500, 400, 300, 200, 100])) == 1100\n assert candidate(head = list_node([100000, 200000, 300000, 400000, 500000, 400000, 300000, 200000, 100000, 1])) == 900000\n assert candidate(head = list_node([10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000])) == 130000\n assert candidate(head = list_node([100000, 1, 200000, 2, 300000, 3, 400000, 4, 500000, 5, 600000, 6])) == 600001\n assert candidate(head = list_node([25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000])) == 50000\n assert candidate(head = list_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])) == 21\n assert candidate(head = list_node([5, 3, 6, 7, 1, 9])) == 14\n assert candidate(head = list_node([99999, 99998, 99997, 99996, 1, 2, 3, 4])) == 100003\n assert candidate(head = list_node([1, 99999, 2, 99998, 3, 99997, 4, 99996])) == 100003\n assert candidate(head = list_node([8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23])) == 31\n assert candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0])) == 190\n assert candidate(head = list_node([1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91])) == 110\n assert candidate(head = list_node([50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991])) == 99991\n assert candidate(head = list_node([2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53])) == 55\n assert candidate(head = list_node([5, 6, 7, 8, 9, 10, 1, 2, 3, 4])) == 19\n assert candidate(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\n assert candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5])) == 5\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 21\n assert candidate(head = list_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14])) == 19\n assert candidate(head = list_node([1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995])) == 100004\n assert candidate(head = list_node([50000, 50000, 50000, 50000, 50000, 50000])) == 100000\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])) == 13\n assert candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995])) == 199995\n assert candidate(head = list_node([150000, 1, 150000, 1, 150000, 1, 150000, 1, 150000, 1, 150000, 1, 150000, 1, 150000, 1])) == 150001\n assert candidate(head = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000])) == 1100\n assert candidate(head = list_node([100000, 100000, 100000, 100000, 100000, 100000])) == 200000\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == 2\n assert candidate(head = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600])) == 1700\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == 2\n assert candidate(head = list_node([1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000])) == 100001\n assert candidate(head = list_node([100000, 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, 100000])) == 200000\n assert candidate(head = list_node([50000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 50000])) == 100000\n assert candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23])) == 24\n assert candidate(head = list_node([6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2])) == 8\n assert candidate(head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60])) == 65\n assert candidate(head = list_node([31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1])) == 32\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 21\n assert candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == 20\n assert candidate(head = list_node([8, 7, 6, 5, 4, 3, 2, 1])) == 9\n assert candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100])) == 110\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == 2\n assert candidate(head = list_node([100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3])) == 100003\n assert candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40])) == 42\n assert candidate(head = list_node([100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000])) == 110000\n assert candidate(head = list_node([20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 21\n assert candidate(head = list_node([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, 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, 1009])) == 1011\n assert candidate(head = list_node([99999, 1, 99999, 1, 99999, 1, 99999, 1])) == 100000\n assert candidate(head = list_node([10000, 5000, 1000, 500, 100, 50, 10, 5])) == 10005\n assert candidate(head = list_node([12345, 67890, 54321, 98765, 23456, 87654])) == 153086\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])) == 17\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().pairSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {", "container": "Solution", "callable": "ListNode", "parameters": [], "return_type": "class ListNode {\n * int val;\n * ListNode next;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2131, "task_id": "longest-palindrome-by-concatenating-two-letter-words", "difficulty": "Medium", "problem_description": "You are given an array of strings words. Each element of words consists of two lowercase English letters.\nCreate the longest possible palindrome by selecting some elements from words and concatenating them in any order. Each element can be selected at most once.\nReturn the length of the longest palindrome that you can create. If it is impossible to create any palindrome, return 0.\nA palindrome is a string that reads the same forward and backward.\n \nExample 1:\n\nInput: words = [\"lc\",\"cl\",\"gg\"]\nOutput: 6\nExplanation: One longest palindrome is \"lc\" + \"gg\" + \"cl\" = \"lcggcl\", of length 6.\nNote that \"clgglc\" is another longest palindrome that can be created.\n\nExample 2:\n\nInput: words = [\"ab\",\"ty\",\"yt\",\"lc\",\"cl\",\"ab\"]\nOutput: 8\nExplanation: One longest palindrome is \"ty\" + \"lc\" + \"cl\" + \"yt\" = \"tylcclyt\", of length 8.\nNote that \"lcyttycl\" is another longest palindrome that can be created.\n\nExample 3:\n\nInput: words = [\"cc\",\"ll\",\"xx\"]\nOutput: 2\nExplanation: One longest palindrome is \"cc\", of length 2.\nNote that \"ll\" is another longest palindrome that can be created, and so is \"xx\".\n\n \nConstraints:\n\n1 <= words.length <= 105\nwords[i].length == 2\nwords[i] consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['xy', 'yx', 'xy', 'yx', 'xy', 'yx']) == 12\n assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'ee']) == 2\n assert candidate(words = ['ab', 'ba', 'xy', 'yx', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz']) == 22\n assert candidate(words = ['ab', 'ba', 'cc', 'dd', 'dc', 'ca', 'ac']) == 10\n assert candidate(words = ['cc', 'll', 'xx']) == 2\n assert candidate(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', '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']) == 104\n assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba']) == 16\n assert candidate(words = ['mn', 'nm', 'op', 'po', 'qp', 'pq', 'rs', 'sr', 'tu', 'ut', 'vu', 'uv']) == 24\n assert candidate(words = ['zz', 'aa', 'bb', 'cc', 'zz', 'aa']) == 10\n assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba']) == 52\n assert candidate(words = ['ab', 'ty', 'yt', 'lc', 'cl', 'ab']) == 8\n assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj']) == 2\n assert candidate(words = ['lc', 'cl', 'gg']) == 6\n assert candidate(words = ['aa', 'aa', 'aa', 'aa']) == 8\n assert candidate(words = ['aa', 'aa', 'aa', 'aa', 'aa']) == 10\n assert candidate(words = ['ab', 'ba', 'cc', 'dd', 'ab', 'ba']) == 10\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']) == 52\n assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba']) == 12\n assert candidate(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']) == 2\n assert candidate(words = ['aa', 'aa', 'aa', 'bb', 'bb', 'cc', 'cc', 'cc', 'cc', 'dd', 'dd', 'dd', 'dd']) == 26\n assert candidate(words = ['aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa']) == 52\n assert candidate(words = ['aa', 'aa', 'aa', 'aa', 'ab', 'ba', 'ab', 'ba', 'ac', 'ca', 'ac', 'ca', 'ad', 'da', 'ad', 'da', 'ae', 'ea', 'ae', 'ea', 'af', 'fa', 'af', 'fa', 'ag', 'ga', 'ag', 'ga', 'ah', 'ha', 'ah', 'ha', 'ai', 'ia', 'ai', 'ia', 'aj', 'ja', 'aj', 'ja', 'ak', 'ka', 'ak', 'ka', 'al', 'la', 'al', 'la', 'am', 'ma', 'am', 'ma', 'an', 'na', 'an', 'na', 'ao', 'oa', 'ao', 'oa', 'ap', 'pa', 'ap', 'pa', 'aq', 'qa', 'aq', 'qa', 'ar', 'ra', 'ar', 'ra', 'as', 'sa', 'as', 'sa', 'at', 'ta', 'at', 'ta', 'au', 'ua', 'au', 'ua', 'av', 'va', 'av', 'va', 'aw', 'wa', 'aw', 'wa', 'ax', 'xa', 'ax', 'xa', 'ay', 'ya', 'ay', 'ya', 'az', 'za', 'az', 'za', 'bb', 'bb', 'bb', 'bb', 'cc', 'cc', 'cc', 'cc', 'dd', 'dd', 'dd', 'dd', 'ee', 'ee', 'ee', 'ee', 'ff', 'ff', 'ff', 'ff', 'gg', 'gg', 'gg', 'gg', 'hh', 'hh', 'hh', 'hh', 'ii', 'ii', 'ii', 'ii', 'jj', 'jj', 'jj', 'jj', 'kk', 'kk', 'kk', 'kk', 'll', 'll', 'll', 'll', 'mm', 'mm', 'mm', 'mm', 'nn', 'nn', 'nn', 'nn', 'oo', 'oo', 'oo', 'oo', 'pp', 'pp', 'pp', 'pp', 'qq', 'qq', 'qq', 'qq', 'rr', 'rr', 'rr', 'rr', 'ss', 'ss', 'ss', 'ss', 'tt', 'tt', 'tt', 'tt', 'uu', 'uu', 'uu', 'uu', 'vv', 'vv', 'vv', 'vv', 'ww', 'ww', 'ww', 'ww', 'xx', 'xx', 'xx', 'xx', 'yy', 'yy', 'yy', 'yy', 'zz', 'zz', 'zz', 'zz']) == 408\n assert candidate(words = ['ab', 'ba', 'xy', 'yx', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji']) == 24\n assert candidate(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', 'zz', 'yy', 'xx', 'ww', 'vv', 'uu', 'tt', 'ss', 'rr', 'qq', 'pp', 'oo', 'nn', 'mm', 'll', 'kk', 'jj', 'ii', 'hh', 'gg', 'ff', 'ee', 'dd', 'cc', 'bb', 'aa']) == 104\n assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd']) == 18\n assert candidate(words = ['zz', 'zz', 'xy', 'yx', 'yx', 'xy', 'ab', 'ba', 'ab', 'ba', 'zz', 'zz']) == 24\n assert candidate(words = ['ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'ab', 'ba', 'xy', 'yx', 'zy', 'yz']) == 72\n assert candidate(words = ['xy', 'yx', 'xx', 'yy', 'xy', 'yx', 'xx', 'yy', 'xy', 'yx', 'xx', 'yy']) == 22\n assert candidate(words = ['aa', 'bb', 'cc', 'dd', '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']) == 18\n assert candidate(words = ['aa', 'bb', 'aa', 'bb', 'cc', 'dd', 'cc', 'dd', 'ee', 'ff', 'ee', 'ff']) == 24\n assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd']) == 64\n assert candidate(words = ['xy', 'yx', 'zz', 'zz', 'yx', 'xz', 'zx', 'zz']) == 14\n assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa']) == 18\n assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk']) == 24\n assert candidate(words = ['aa', 'aa', 'aa', 'aa', 'bb', 'bb', 'bb', 'bb', 'cc', 'cc', 'cc', 'cc', 'dd', 'dd', 'dd', 'dd', 'ee', 'ee', 'ee', 'ee', 'ff', 'ff', 'ff', 'ff', 'gg', 'gg', 'gg', 'gg', 'hh', 'hh', 'hh', 'hh']) == 64\n assert candidate(words = ['ab', 'ba', 'xy', 'yx', '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', 'xy', 'yx', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy']) == 112\n assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'cd', 'dc', 'cd', 'dc', 'ef', 'fe', 'ef', 'fe', 'gh', 'hg', 'gh', 'hg']) == 36\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', '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']) == 54\n assert candidate(words = ['xy', 'yx', 'yx', 'xy', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx']) == 304\n assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'bc', 'cb', 'bd', 'db']) == 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', 'zx', 'xz', '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', 'zx', 'xz']) == 112\n assert candidate(words = ['xy', 'yx', 'yy', 'xx', 'zz', 'zz', 'zz', 'zz', 'xy', 'yx', 'xx', 'yy', 'zz', 'zz']) == 28\n assert candidate(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', 'xy', 'yx', 'xz', 'zx', 'yz', 'zy', 'yx', 'zx', 'yz', 'zy', 'yx', 'zx', 'yz', 'zy', 'yx', 'zx', 'yz', 'zy', 'yx', 'zx', 'yz', 'zy']) == 30\n assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'cd', 'dc', 'ab', 'ba', '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', 'gh', 'hg']) == 76\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', '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']) == 102\n assert candidate(words = ['mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'aa', 'bb', 'cc', 'dd']) == 30\n assert candidate(words = ['ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp']) == 14\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', 'zx', 'xz', 'yz', 'zy', 'zx', 'xz', 'yz', 'zy', 'zx', 'xz', 'yz', 'zy', 'zx', 'xz', 'yz', 'zy', 'zx', 'xz']) == 88\n assert candidate(words = ['qq', 'ww', 'ee', 'rr', 'tt', 'yy', 'uu', 'ii', 'oo', 'pp', 'aa', 'ss', 'dd', 'ff', 'gg', 'hh', 'jj', 'kk', 'll', 'zz', 'xx', 'cc', 'vv', 'bb', 'nn', 'mm', 'll', 'kk', 'jj', 'ii', 'hh', 'gg', 'ff', 'dd', 'ss', 'aa', 'pp', 'oo', 'nn', 'mm', 'zz', 'xx', 'vv', 'cc', 'uu', 'tt', 'rr', 'ee', 'ww', 'qq']) == 98\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', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz']) == 92\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', 'zz', 'zz', 'aa', 'aa', 'bb', 'bb', 'cc', 'cc', 'dd', 'dd', 'ee', 'ee', 'ff', 'ff', 'gg', 'gg', 'hh', 'hh', 'ii', 'ii', 'jj', 'jj', 'kk', 'kk', 'll', 'll', 'mm', 'mm', 'nn', 'nn', 'oo', 'oo', 'pp', 'pp', 'qq', 'qq', 'rr', 'rr', 'ss', 'ss', 'tt', 'tt', 'uu', 'uu', 'vv', 'vv', 'ww', 'ww', 'xx', 'xx', 'yy', 'yy']) == 156\n assert candidate(words = ['aa', 'bb', 'cc', 'aa', 'bb', 'cc', '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', 'aa', 'bb', 'cc']) == 26\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().longestPalindrome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestPalindrome(String[] words) {", "container": "Solution", "callable": "longestPalindrome", "parameters": [{"name": "words", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2132, "task_id": "stamping-the-grid", "difficulty": "Hard", "problem_description": "You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied).\nYou are then given stamps of size stampHeight x stampWidth. We want to fit the stamps such that they follow the given restrictions and requirements:\n\nCover all the empty cells.\nDo not cover any of the occupied cells.\nWe can put as many stamps as we want.\nStamps can overlap with each other.\nStamps are not allowed to be rotated.\nStamps must stay completely inside the grid.\n\nReturn true if it is possible to fit the stamps while following the given restrictions and requirements. Otherwise, return false.\n \nExample 1:\n\n\nInput: grid = [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]], stampHeight = 4, stampWidth = 3\nOutput: true\nExplanation: We have two overlapping stamps (labeled 1 and 2 in the image) that are able to cover all the empty cells.\n\nExample 2:\n\n\nInput: grid = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]], stampHeight = 2, stampWidth = 2 \nOutput: false \nExplanation: There is no way to fit the stamps onto all the empty cells without the stamps going outside the grid.\n\n \nConstraints:\n\nm == grid.length\nn == grid[r].length\n1 <= m, n <= 105\n1 <= m * n <= 2 * 105\ngrid[r][c] is either 0 or 1.\n1 <= stampHeight, stampWidth <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],stampHeight = 2,stampWidth = 2) == True\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],stampHeight = 2,stampWidth = 2) == False\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],stampHeight = 1,stampWidth = 1) == True\n assert candidate(grid = [[0, 0], [0, 0]],stampHeight = 1,stampWidth = 1) == True\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]],stampHeight = 3,stampWidth = 3) == True\n assert candidate(grid = [[1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0]],stampHeight = 4,stampWidth = 3) == True\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == True\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 2) == False\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], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],stampHeight = 2,stampWidth = 2) == False\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]],stampHeight = 3,stampWidth = 3) == False\n assert candidate(grid = [[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]],stampHeight = 4,stampWidth = 4) == True\n assert candidate(grid = [[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, 0, 0, 0, 1, 0]],stampHeight = 2,stampWidth = 2) == False\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]],stampHeight = 3,stampWidth = 3) == True\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]],stampHeight = 5,stampWidth = 5) == True\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]],stampHeight = 3,stampWidth = 5) == True\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 2,stampWidth = 3) == False\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], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 5,stampWidth = 5) == True\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == False\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]],stampHeight = 3,stampWidth = 3) == False\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]],stampHeight = 4,stampWidth = 4) == True\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1]],stampHeight = 2,stampWidth = 3) == True\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]],stampHeight = 3,stampWidth = 5) == True\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], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == True\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == False\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\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, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0]],stampHeight = 2,stampWidth = 3) == False\n assert candidate(grid = [[1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0]],stampHeight = 2,stampWidth = 2) == False\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 4) == False\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 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, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\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]],stampHeight = 2,stampWidth = 2) == False\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, 1, 0, 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]],stampHeight = 4,stampWidth = 4) == False\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]],stampHeight = 2,stampWidth = 2) == False\n assert candidate(grid = [[1, 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, 1]],stampHeight = 2,stampWidth = 2) == True\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]],stampHeight = 4,stampWidth = 4) == False\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n assert candidate(grid = [[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, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == False\n assert candidate(grid = [[0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]],stampHeight = 2,stampWidth = 2) == True\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 2,stampWidth = 3) == False\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 5,stampWidth = 10) == True\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1]],stampHeight = 3,stampWidth = 3) == False\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0]],stampHeight = 3,stampWidth = 2) == False\n assert candidate(grid = [[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, 1, 0, 0], [0, 0, 0, 1, 0, 0]],stampHeight = 2,stampWidth = 2) == True\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]],stampHeight = 5,stampWidth = 4) == True\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]],stampHeight = 2,stampWidth = 2) == False\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],stampHeight = 2,stampWidth = 4) == False\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], [0, 0, 0, 1, 0, 0]],stampHeight = 2,stampWidth = 3) == False\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],stampHeight = 2,stampWidth = 2) == False\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]],stampHeight = 2,stampWidth = 2) == False\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, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == False\n assert candidate(grid = [[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]],stampHeight = 4,stampWidth = 3) == False\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == False\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == False\n assert candidate(grid = [[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]],stampHeight = 4,stampWidth = 5) == True\n assert candidate(grid = [[0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == False\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, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 2) == True\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]],stampHeight = 4,stampWidth = 5) == True\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]],stampHeight = 2,stampWidth = 3) == False\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]],stampHeight = 2,stampWidth = 3) == True\n assert candidate(grid = [[1, 0, 0, 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]],stampHeight = 2,stampWidth = 3) == False\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 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, 1, 0, 1, 0, 1, 0, 1, 0]],stampHeight = 3,stampWidth = 3) == False\n assert candidate(grid = [[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]],stampHeight = 3,stampWidth = 4) == True\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]],stampHeight = 2,stampWidth = 2) == False\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [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]],stampHeight = 3,stampWidth = 2) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],stampHeight = 1,stampWidth = 1) == True\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]],stampHeight = 3,stampWidth = 3) == False\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, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 5) == False\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\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]],stampHeight = 3,stampWidth = 4) == True\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, 1, 1, 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]],stampHeight = 4,stampWidth = 4) == False\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]],stampHeight = 5,stampWidth = 4) == True\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]],stampHeight = 5,stampWidth = 5) == True\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, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 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]],stampHeight = 4,stampWidth = 4) == False\n assert candidate(grid = [[1, 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]],stampHeight = 2,stampWidth = 3) == False\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]],stampHeight = 2,stampWidth = 2) == True\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]],stampHeight = 3,stampWidth = 3) == True\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, 0, 1, 0]],stampHeight = 2,stampWidth = 2) == False\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 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]],stampHeight = 3,stampWidth = 2) == False\n"}, "metadata": {"canonical_parameter_names": ["grid", "stampHeight", "stampWidth"], "leetcode_dataset_entry_point": "Solution().possibleToStamp", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean possibleToStamp(int[][] grid, int stampHeight, int stampWidth) {", "container": "Solution", "callable": "possibleToStamp", "parameters": [{"name": "grid", "type": "int[][]"}, {"name": "stampHeight", "type": "int"}, {"name": "stampWidth", "type": "int"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2133, "task_id": "check-if-every-row-and-column-contains-all-numbers", "difficulty": "Easy", "problem_description": "An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).\nGiven an n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false.\n \nExample 1:\n\n\nInput: matrix = [[1,2,3],[3,1,2],[2,3,1]]\nOutput: true\nExplanation: In this case, n = 3, and every row and column contains the numbers 1, 2, and 3.\nHence, we return true.\n\nExample 2:\n\n\nInput: matrix = [[1,1,1],[1,2,3],[1,2,3]]\nOutput: false\nExplanation: In this case, n = 3, but the first row and the first column do not contain the numbers 2 or 3.\nHence, we return false.\n\n \nConstraints:\n\nn == matrix.length == matrix[i].length\n1 <= n <= 100\n1 <= matrix[i][j] <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]]) == True\n assert candidate(matrix = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == False\n assert candidate(matrix = [[4, 3, 2, 1], [1, 4, 3, 2], [2, 1, 4, 3], [3, 2, 1, 4]]) == True\n assert candidate(matrix = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == False\n assert candidate(matrix = [[1]]) == True\n assert candidate(matrix = [[1, 1, 1], [1, 2, 3], [1, 2, 3]]) == False\n assert candidate(matrix = [[1, 2, 3], [3, 1, 2], [2, 3, 1]]) == True\n assert candidate(matrix = [[1, 2], [2, 1]]) == True\n assert candidate(matrix = [[4, 3, 2, 1], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2]]) == False\n assert candidate(matrix = [[7, 4, 3, 8, 5, 6, 2, 1], [1, 5, 6, 2, 8, 3, 7, 4], [8, 1, 7, 4, 2, 5, 3, 6], [2, 6, 5, 3, 7, 1, 8, 5], [6, 7, 8, 5, 1, 4, 5, 2], [3, 8, 4, 6, 5, 2, 1, 7], [5, 2, 1, 7, 6, 8, 4, 3], [4, 3, 2, 1, 4, 7, 6, 5]]) == False\n assert candidate(matrix = [[4, 3, 2, 1], [1, 2, 3, 4], [2, 4, 1, 3], [3, 1, 4, 2]]) == True\n assert candidate(matrix = [[1, 2, 3], [3, 1, 2], [2, 3, 1], [2, 3, 1]]) == False\n assert candidate(matrix = [[7, 2, 5, 3, 8, 9, 4, 6, 1], [6, 4, 9, 1, 7, 5, 3, 2, 8], [1, 8, 3, 6, 4, 2, 5, 7, 9], [8, 9, 4, 5, 6, 7, 2, 1, 3], [5, 6, 7, 8, 9, 3, 1, 4, 2], [3, 1, 2, 4, 5, 6, 8, 9, 7], [2, 7, 6, 9, 1, 4, 9, 3, 5], [4, 5, 8, 2, 3, 1, 6, 7, 9], [9, 3, 1, 7, 2, 8, 4, 5, 6]]) == False\n assert candidate(matrix = [[4, 3, 2, 1], [3, 2, 1, 4], [2, 1, 4, 3], [1, 4, 3, 2]]) == True\n assert candidate(matrix = [[2, 3, 1, 4], [3, 1, 4, 2], [1, 4, 2, 3], [4, 2, 3, 1]]) == True\n assert candidate(matrix = [[7, 3, 5, 1, 6, 2, 4], [4, 6, 2, 5, 3, 7, 1], [1, 2, 4, 7, 1, 5, 3], [5, 4, 3, 6, 7, 1, 2], [3, 1, 6, 2, 4, 5, 7], [2, 7, 1, 4, 5, 3, 6], [6, 5, 7, 3, 2, 4, 1]]) == False\n assert candidate(matrix = [[7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 7], [9, 10, 11, 12, 13, 14, 15, 16, 7, 8], [10, 11, 12, 13, 14, 15, 16, 7, 8, 9], [11, 12, 13, 14, 15, 16, 7, 8, 9, 10], [12, 13, 14, 15, 16, 7, 8, 9, 10, 11], [13, 14, 15, 16, 7, 8, 9, 10, 11, 12], [14, 15, 16, 7, 8, 9, 10, 11, 12, 13], [15, 16, 7, 8, 9, 10, 11, 12, 13, 14], [16, 7, 8, 9, 10, 11, 12, 13, 14, 15]]) == True\n assert candidate(matrix = [[7, 6, 5, 4, 3, 2, 1], [1, 7, 6, 5, 4, 3, 2], [2, 1, 7, 6, 5, 4, 3], [3, 2, 1, 7, 6, 5, 4], [4, 3, 2, 1, 7, 6, 5], [5, 4, 3, 2, 1, 7, 6], [6, 5, 4, 3, 2, 1, 7]]) == True\n assert candidate(matrix = [[7, 6, 5, 4, 3, 2, 1], [2, 7, 6, 5, 4, 3, 1], [4, 3, 2, 1, 7, 6, 5], [6, 5, 4, 3, 2, 1, 7], [3, 2, 1, 7, 6, 5, 4], [1, 7, 6, 5, 4, 3, 2], [5, 4, 3, 2, 1, 7, 6]]) == False\n assert candidate(matrix = [[2, 3, 1], [3, 1, 2], [1, 2, 3]]) == True\n assert candidate(matrix = [[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], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7], [9, 10, 1, 2, 3, 4, 5, 6, 7, 8], [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == True\n assert candidate(matrix = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 4, 1, 3], [3, 1, 4, 2]]) == True\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == True\n assert candidate(matrix = [[9, 5, 7, 4, 3, 8, 1, 2, 6], [4, 2, 6, 8, 7, 1, 3, 9, 5], [8, 1, 3, 9, 5, 4, 7, 6, 2], [5, 7, 4, 3, 8, 6, 9, 1, 2], [2, 8, 1, 6, 9, 5, 4, 3, 7], [3, 6, 9, 1, 2, 7, 8, 5, 4], [7, 4, 2, 5, 1, 9, 6, 8, 3], [6, 9, 5, 7, 4, 3, 2, 1, 8], [1, 3, 8, 2, 6, 2, 5, 4, 9]]) == False\n assert candidate(matrix = [[2, 3, 1, 4], [1, 4, 2, 3], [3, 1, 4, 2], [4, 2, 3, 1]]) == True\n assert candidate(matrix = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 1], [3, 4, 5, 6, 7, 8, 9, 1, 2], [4, 5, 6, 7, 8, 9, 1, 2, 3], [5, 6, 7, 8, 9, 1, 2, 3, 4], [6, 7, 8, 9, 1, 2, 3, 4, 5], [7, 8, 9, 1, 2, 3, 4, 5, 6], [8, 9, 1, 2, 3, 4, 5, 6, 7], [9, 1, 2, 3, 4, 5, 6, 7, 8]]) == False\n assert candidate(matrix = [[5, 2, 1, 4, 3], [3, 5, 4, 2, 1], [4, 1, 3, 5, 2], [2, 4, 5, 1, 3], [1, 3, 2, 3, 4]]) == False\n assert candidate(matrix = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 9, 8, 7, 6, 5, 4, 3, 2], [2, 1, 9, 8, 7, 6, 5, 4, 3], [3, 2, 1, 9, 8, 7, 6, 5, 4], [4, 3, 2, 1, 9, 8, 7, 6, 5], [5, 4, 3, 2, 1, 9, 8, 7, 6], [6, 5, 4, 3, 2, 1, 9, 8, 7], [7, 6, 5, 4, 3, 2, 1, 9, 8], [8, 7, 6, 5, 4, 3, 2, 1, 9]]) == True\n assert candidate(matrix = [[5, 3, 4, 1, 2], [1, 2, 5, 3, 4], [2, 4, 1, 5, 3], [3, 5, 2, 4, 1], [4, 1, 3, 2, 5]]) == True\n assert candidate(matrix = [[5, 1, 4, 2, 3], [2, 3, 5, 4, 1], [4, 5, 2, 1, 3], [3, 4, 1, 5, 2], [1, 2, 3, 3, 4]]) == False\n assert candidate(matrix = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [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], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7], [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]]) == False\n assert candidate(matrix = [[8, 7, 6, 5, 4, 3, 2, 1], [1, 8, 7, 6, 5, 4, 3, 2], [2, 1, 8, 7, 6, 5, 4, 3], [3, 2, 1, 8, 7, 6, 5, 4], [4, 3, 2, 1, 8, 7, 6, 5], [5, 4, 3, 2, 1, 8, 7, 6], [6, 5, 4, 3, 2, 1, 8, 7], [7, 6, 5, 4, 3, 2, 1, 8]]) == True\n assert candidate(matrix = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 10], [8, 7, 6, 5, 4, 3, 2, 1, 10, 9], [7, 6, 5, 4, 3, 2, 1, 10, 9, 8], [6, 5, 4, 3, 2, 1, 10, 9, 8, 7], [5, 4, 3, 2, 1, 10, 9, 8, 7, 6], [4, 3, 2, 1, 10, 9, 8, 7, 6, 5], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [2, 1, 10, 9, 8, 7, 6, 5, 4, 3], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]]) == True\n assert candidate(matrix = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 10], [8, 7, 6, 5, 4, 3, 2, 1, 10, 9], [7, 6, 5, 4, 3, 2, 1, 10, 9, 8], [6, 5, 4, 3, 2, 1, 10, 9, 8, 7], [5, 4, 3, 2, 1, 10, 9, 8, 7, 6], [4, 3, 2, 1, 10, 9, 8, 7, 6, 5], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [2, 1, 10, 9, 8, 7, 6, 5, 4, 3], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]]) == True\n assert candidate(matrix = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 1, 10, 9, 8, 7, 6, 5, 4, 3], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [4, 3, 2, 1, 10, 9, 8, 7, 6, 5], [5, 4, 3, 2, 1, 10, 9, 8, 7, 6], [6, 5, 4, 3, 2, 1, 10, 9, 8, 7], [7, 6, 5, 4, 3, 2, 1, 10, 9, 8], [8, 7, 6, 5, 4, 3, 2, 1, 10, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(matrix = [[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]]) == False\n assert candidate(matrix = [[9, 3, 1, 4, 2, 6, 8, 7, 5], [6, 7, 2, 1, 9, 5, 3, 4, 8], [1, 4, 8, 6, 3, 7, 2, 5, 9], [8, 5, 9, 7, 4, 2, 6, 1, 3], [4, 2, 6, 8, 5, 3, 1, 9, 7], [7, 1, 3, 9, 6, 4, 5, 8, 2], [5, 8, 4, 2, 1, 9, 7, 3, 6], [2, 6, 7, 3, 8, 1, 4, 9, 5], [3, 9, 5, 5, 7, 8, 9, 2, 4]]) == False\n assert candidate(matrix = [[9, 7, 5, 2, 6, 8, 3, 1, 4], [4, 3, 1, 7, 9, 5, 8, 2, 6], [6, 8, 2, 4, 1, 3, 7, 9, 5], [3, 5, 9, 6, 7, 1, 2, 4, 8], [8, 2, 4, 9, 5, 7, 6, 3, 1], [1, 6, 7, 3, 8, 4, 9, 5, 2], [5, 9, 6, 1, 2, 8, 4, 7, 3], [7, 4, 8, 5, 3, 9, 1, 6, 2], [2, 1, 3, 8, 4, 6, 5, 7, 9]]) == False\n assert candidate(matrix = [[9, 5, 1, 6, 7, 2, 8, 4, 3], [2, 8, 7, 4, 1, 3, 6, 9, 5], [6, 4, 3, 8, 2, 5, 9, 1, 7], [5, 9, 6, 1, 4, 7, 3, 2, 8], [8, 2, 4, 9, 3, 1, 5, 7, 6], [7, 1, 9, 5, 6, 8, 4, 3, 2], [3, 6, 5, 7, 9, 4, 2, 8, 1], [4, 7, 8, 2, 5, 6, 1, 3, 9], [1, 3, 2, 3, 8, 9, 7, 5, 4]]) == False\n assert candidate(matrix = [[2, 3, 1], [1, 2, 3], [3, 1, 2]]) == True\n assert candidate(matrix = [[1, 2, 3], [2, 3, 1], [1, 3, 2], [3, 2, 1]]) == False\n assert candidate(matrix = [[7, 5, 6, 4, 3, 2, 1], [1, 7, 5, 6, 4, 3, 2], [2, 1, 7, 5, 6, 4, 3], [3, 2, 1, 7, 5, 6, 4], [4, 3, 2, 1, 7, 5, 6], [5, 4, 3, 2, 1, 7, 5], [6, 5, 4, 3, 2, 1, 7]]) == False\n assert candidate(matrix = [[6, 5, 4, 3, 2, 1], [1, 6, 5, 4, 3, 2], [2, 1, 6, 5, 4, 3], [3, 2, 1, 6, 5, 4], [4, 3, 2, 1, 6, 5], [5, 4, 3, 2, 1, 6]]) == True\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == True\n assert candidate(matrix = [[6, 5, 4, 3, 2, 1], [2, 1, 6, 5, 4, 3], [4, 3, 2, 1, 6, 5], [5, 4, 3, 2, 1, 6], [3, 2, 1, 6, 5, 4], [1, 6, 5, 4, 3, 2]]) == True\n assert candidate(matrix = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2], [2, 1, 10, 9, 8, 7, 6, 5, 4, 3], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [4, 3, 2, 1, 10, 9, 8, 7, 6, 5], [5, 4, 3, 2, 1, 10, 9, 8, 7, 6], [6, 5, 4, 3, 2, 1, 10, 9, 8, 7], [7, 6, 5, 4, 3, 2, 1, 10, 9, 8], [8, 7, 6, 5, 4, 3, 2, 1, 10, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]]) == True\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 1, 5, 4], [4, 5, 2, 1, 3], [3, 1, 4, 3, 2]]) == False\n assert candidate(matrix = [[9, 3, 4, 1, 2], [5, 6, 7, 8, 9], [8, 7, 6, 9, 5], [2, 1, 9, 3, 4], [4, 5, 8, 7, 6]]) == True\n assert candidate(matrix = [[2, 3, 1, 5, 4], [4, 1, 5, 2, 3], [5, 4, 2, 3, 1], [1, 5, 3, 4, 2], [3, 2, 4, 1, 5]]) == True\n assert candidate(matrix = [[5, 3, 4, 1, 2], [2, 1, 5, 3, 4], [4, 5, 3, 2, 1], [1, 4, 2, 5, 3], [3, 2, 1, 4, 5]]) == True\n assert candidate(matrix = [[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]]) == True\n assert candidate(matrix = [[1, 2, 3, 4], [3, 4, 1, 2], [2, 1, 4, 3], [4, 3, 2, 1]]) == True\n assert candidate(matrix = [[1, 2, 3], [2, 1, 3], [3, 2, 1]]) == False\n assert candidate(matrix = [[5, 1, 2, 3, 4], [1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3]]) == True\n assert candidate(matrix = [[9, 3, 7, 1, 2, 8, 5, 6, 4], [5, 8, 4, 7, 6, 2, 3, 9, 1], [6, 1, 2, 5, 9, 3, 4, 7, 8], [7, 4, 9, 2, 5, 6, 1, 3, 8], [8, 6, 5, 9, 3, 1, 7, 4, 2], [2, 7, 3, 6, 4, 8, 9, 1, 5], [1, 5, 6, 8, 7, 9, 2, 4, 3], [3, 9, 1, 4, 2, 5, 8, 6, 7], [4, 2, 8, 3, 1, 7, 6, 5, 9]]) == False\n assert candidate(matrix = [[1, 2, 3], [2, 1, 3], [3, 1, 2]]) == False\n assert candidate(matrix = [[10, 6, 3, 7, 5, 9, 1, 2, 4, 8], [7, 4, 1, 5, 9, 2, 6, 3, 8, 10], [1, 9, 2, 6, 3, 8, 10, 4, 5, 7], [4, 5, 9, 1, 2, 6, 8, 7, 10, 3], [6, 8, 5, 4, 7, 3, 2, 1, 9, 10], [2, 3, 10, 8, 6, 4, 5, 9, 7, 1], [8, 2, 7, 9, 4, 1, 3, 10, 6, 5], [9, 7, 6, 3, 1, 5, 10, 2, 4, 8], [5, 1, 8, 10, 3, 7, 4, 6, 1, 9], [3, 10, 4, 2, 8, 9, 7, 5, 2, 6]]) == False\n"}, "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().checkValid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean checkValid(int[][] matrix) {", "container": "Solution", "callable": "checkValid", "parameters": [{"name": "matrix", "type": "int[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2134, "task_id": "minimum-swaps-to-group-all-1s-together-ii", "difficulty": "Medium", "problem_description": "A swap is defined as taking two distinct positions in an array and swapping the values in them.\nA circular array is defined as an array where we consider the first element and the last element to be adjacent.\nGiven a binary circular array nums, return the minimum number of swaps required to group all 1's present in the array together at any location.\n \nExample 1:\n\nInput: nums = [0,1,0,1,1,0,0]\nOutput: 1\nExplanation: Here are a few of the ways to group all the 1's together:\n[0,0,1,1,1,0,0] using 1 swap.\n[0,1,1,1,0,0,0] using 1 swap.\n[1,1,0,0,0,0,1] using 2 swaps (using the circular property of the array).\nThere is no way to group all 1's together with 0 swaps.\nThus, the minimum number of swaps required is 1.\n\nExample 2:\n\nInput: nums = [0,1,1,1,0,0,1,1,0]\nOutput: 2\nExplanation: Here are a few of the ways to group all the 1's together:\n[1,1,1,0,0,0,0,1,1] using 2 swaps (using the circular property of the array).\n[1,1,1,1,1,0,0,0,0] using 2 swaps.\nThere is no way to group all 1's together with 0 or 1 swaps.\nThus, the minimum number of swaps required is 2.\n\nExample 3:\n\nInput: nums = [1,1,0,0,1]\nOutput: 0\nExplanation: All the 1's are already grouped together due to the circular property of the array.\nThus, the minimum number of swaps required is 0.\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 = [1, 0, 0, 0, 1, 1, 1, 0, 0, 1]) == 2\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]) == 2\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1]) == 0\n assert candidate(nums = [0, 1, 0, 1, 1, 0, 0]) == 1\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1]) == 2\n assert candidate(nums = [1, 1, 0, 0, 1]) == 0\n assert candidate(nums = [1, 0, 0, 1, 0, 1]) == 1\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\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 1, 1, 0, 0, 1, 1, 0]) == 2\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 1, 0]) == 1\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]) == 3\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1]) == 2\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\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]) == 5\n assert candidate(nums = [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\n assert candidate(nums = [0, 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, 0]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0]) == 4\n assert candidate(nums = [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]) == 7\n assert candidate(nums = [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, 0]) == 6\n assert candidate(nums = [0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1]) == 2\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]) == 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 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]) == 5\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 4\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]) == 5\n assert candidate(nums = [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, 0, 0, 0, 0, 0, 0]) == 0\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, 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]) == 9\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == 4\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1]) == 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, 0, 1, 0, 1, 0, 1]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [1, 1, 1, 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]) == 8\n assert candidate(nums = [1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0]) == 5\n assert candidate(nums = [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 3\n assert candidate(nums = [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, 0]) == 0\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]) == 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, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 10\n assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 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, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 7\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 3\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(nums = [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, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]) == 6\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 3\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 4\n assert candidate(nums = [1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) == 3\n assert candidate(nums = [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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [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]) == 7\n assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1]) == 10\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]) == 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\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 4\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 0\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]) == 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, 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, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 3\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, 0, 1, 1, 1]) == 0\n assert candidate(nums = [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]) == 5\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]) == 5\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]) == 4\n assert candidate(nums = [1, 1, 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]) == 6\n assert candidate(nums = [1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1]) == 1\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(nums = [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, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 5\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 3\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, 1, 1, 0, 0, 1, 1]) == 8\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [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, 0, 0, 0, 0, 0, 0]) == 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, 0, 0, 0, 0, 0, 0, 1]) == 0\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]) == 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, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 17\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == 3\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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]) == 0\n assert candidate(nums = [0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0]) == 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]) == 6\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 2\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 3\n assert candidate(nums = [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]) == 0\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]) == 5\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 4\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0]) == 5\n assert candidate(nums = [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\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 0\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]) == 8\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 4\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(nums = [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\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 4\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1]) == 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, 0, 1, 0, 1, 0, 1, 0]) == 8\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 3\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, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 3\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minSwaps(int[] nums) {", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2135, "task_id": "count-words-obtained-after-adding-a-letter", "difficulty": "Medium", "problem_description": "You are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only.\nFor each string in targetWords, check if it is possible to choose a string from startWords and perform a conversion operation on it to be equal to that from targetWords.\nThe conversion operation is described in the following two steps:\n\nAppend any lowercase letter that is not present in the string to its end.\n\n\t\nFor example, if the string is \"abc\", the letters 'd', 'e', or 'y' can be added to it, but not 'a'. If 'd' is added, the resulting string will be \"abcd\".\n\n\nRearrange the letters of the new string in any arbitrary order.\n\t\nFor example, \"abcd\" can be rearranged to \"acbd\", \"bacd\", \"cbda\", and so on. Note that it can also be rearranged to \"abcd\" itself.\n\n\n\nReturn the number of strings in targetWords that can be obtained by performing the operations on any string of startWords.\nNote that you will only be verifying if the string in targetWords can be obtained from a string in startWords by performing the operations. The strings in startWords do not actually change during this process.\n \nExample 1:\n\nInput: startWords = [\"ant\",\"act\",\"tack\"], targetWords = [\"tack\",\"act\",\"acti\"]\nOutput: 2\nExplanation:\n- In order to form targetWords[0] = \"tack\", we use startWords[1] = \"act\", append 'k' to it, and rearrange \"actk\" to \"tack\".\n- There is no string in startWords that can be used to obtain targetWords[1] = \"act\".\n Note that \"act\" does exist in startWords, but we must append one letter to the string before rearranging it.\n- In order to form targetWords[2] = \"acti\", we use startWords[1] = \"act\", append 'i' to it, and rearrange \"acti\" to \"acti\" itself.\n\nExample 2:\n\nInput: startWords = [\"ab\",\"a\"], targetWords = [\"abc\",\"abcd\"]\nOutput: 1\nExplanation:\n- In order to form targetWords[0] = \"abc\", we use startWords[0] = \"ab\", add 'c' to it, and rearrange it to \"abc\".\n- There is no string in startWords that can be used to obtain targetWords[1] = \"abcd\".\n\n \nConstraints:\n\n1 <= startWords.length, targetWords.length <= 5 * 104\n1 <= startWords[i].length, targetWords[j].length <= 26\nEach string of startWords and targetWords consists of lowercase English letters only.\nNo letter occurs more than once in any string of startWords or targetWords.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startWords = ['ant', 'act', 'tack'],targetWords = ['tack', 'act', 'acti']) == 2\n assert candidate(startWords = ['ab', 'a'],targetWords = ['abc', 'abcd']) == 1\n assert candidate(startWords = ['pqrst', 'vwxyz', 'abcdef'],targetWords = ['qrstuvw', 'vwxyzab', 'abcdefg', 'pqrstuv', 'mnopqr']) == 1\n assert candidate(startWords = ['python', 'java', 'c'],targetWords = ['pythonx', 'javaz', 'cb']) == 3\n assert candidate(startWords = ['abcdexyz', 'mnopqr', 'stuv'],targetWords = ['abcdexyzw', 'mnopqrs', 'stuvq']) == 3\n assert candidate(startWords = ['python', 'java', 'csharp'],targetWords = ['pythonic', 'javacoffee', 'csharptool', 'pythonjava', 'javacsharp']) == 0\n assert candidate(startWords = ['abc', 'def', 'ghi', 'jkl', 'mno'],targetWords = ['abcd', 'abce', 'abcf', 'abck', 'abcm']) == 5\n assert candidate(startWords = ['xyz', 'uvw', 'rst'],targetWords = ['xyza', 'uvwq', 'rstv', 'rstw']) == 4\n assert candidate(startWords = ['abcd', 'bcde', 'cdef'],targetWords = ['abcde', 'bcdefg', 'abcdef', 'bcd']) == 1\n assert candidate(startWords = ['a', 'bc', 'def', 'ghij', 'klmno'],targetWords = ['ab', 'bcd', 'cdef', 'defgh', 'efghij', 'fghijk']) == 3\n assert candidate(startWords = ['abcde', 'fghij', 'klmno'],targetWords = ['bcdef', 'ghijk', 'klmnoa', 'mnopqr', 'stuvwx']) == 1\n assert candidate(startWords = ['hello', 'world', 'abc'],targetWords = ['helloa', 'worldb', 'abcd']) == 3\n assert candidate(startWords = ['mnopqr', 'stuvwx', 'yzabcd'],targetWords = ['mnopqrs', 'stuvwxy', 'yzabcde', 'mnopqrst', 'stuvwxyz', 'yzabcdef', 'mnopqrstuv', 'stuvwxyzab', 'yzabcdefg', 'mnopqrstu', 'stuvwxyzabc', 'yzabcdefg', 'mnopqrstuvw', 'stuvwxyzabcd', 'yzabcdefgh', 'mnopqrstuvwx', 'stuvwxyzabcde', 'yzabcdefgij', 'mnopqrstuvwxy', 'stuvwxyzabcdef', 'yzabcdefgijk']) == 3\n assert candidate(startWords = ['xyz', 'uvw', 'qrst'],targetWords = ['xyza', 'uvwxy', 'qrstuv', 'qrstuvw', 'uvwq']) == 2\n assert candidate(startWords = ['mnopqr', 'stuvwx', 'yzabcd', 'efghij', 'klmno'],targetWords = ['mnopqrs', 'stuvwxy', 'yzabcdx', 'efghijk', 'klmnop', 'abcdefgh']) == 5\n assert candidate(startWords = ['abc', 'def', 'ghi'],targetWords = ['abcd', 'abcf', 'defg', 'ghij']) == 4\n assert candidate(startWords = ['abc', 'def', 'ghi'],targetWords = ['abcd', 'efg', 'hij', 'defg', 'ghik']) == 3\n assert candidate(startWords = ['xyz', 'mnop', 'qrst'],targetWords = ['xyzw', 'mnopq', 'qrstuvw']) == 2\n assert candidate(startWords = ['a', 'b', 'c', 'd'],targetWords = ['ab', 'bc', 'cd', 'da', 'abc', 'bcd', 'cda', 'dab']) == 4\n assert candidate(startWords = ['abcdefghij', 'klmnopqr', 'stuvwxyz'],targetWords = ['abcdefghijk', 'klmnopqrs', 'stuvwxyzab', 'abcdefghijl', 'klmnopqrt', 'stuvwxyzabc', 'abcdefghijm', 'klmnopqru', 'stuvwxyzabcd', 'abcdefghijn', 'klmnopqrv', 'stuvwxyzabcde', 'abcdefghijo', 'klmnopqrw', 'stuvwxyzabcdef', 'abcdefghijp', 'klmnopqrx', 'stuvwxyzabcdefg', 'abcdefghirq', 'klmnopqry', 'stuvwxyzabcdefgh', 'abcdefghirs', 'klmnopqrz', 'stuvwxyzabcdefghi', 'abcdefghirt', 'klmnopqs', 'stuvwxyzabcdefghij', 'abcdefghiru', 'klmnopqt', 'stuvwxyzabcdefghijk', 'abcdefghirv', 'klmnopqu', 'stuvwxyzabcdefghijl', 'abcdefghirw', 'klmnopqv', 'stuvwxyzabcdefghijm', 'abcdefghirx', 'klmnopqw', 'stuvwxyzabcdefghijn', 'abcdefghiry', 'klmnopqx', 'stuvwxyzabcdefghijo', 'abcdefghirz', 'klmnopqy', 'stuvwxyzabcdefghijp', 'klmnopqz', 'stuvwxyzabcdefghirq']) == 14\n assert candidate(startWords = ['quick', 'brown', 'fox'],targetWords = ['quicks', 'brownf', 'foxj', 'quickm', 'brownx']) == 5\n assert candidate(startWords = ['a', 'b', 'c'],targetWords = ['ab', 'bc', 'ca', 'abc', 'abcd']) == 3\n assert candidate(startWords = ['abc', 'def', 'ghi'],targetWords = ['abcd', 'efg', 'ghij']) == 2\n assert candidate(startWords = ['zebra', 'dog', 'cat'],targetWords = ['zebrao', 'doge', 'taco']) == 3\n assert candidate(startWords = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],targetWords = ['ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'ha']) == 8\n assert candidate(startWords = ['abcdefgh', 'ijklmnop', 'qrstuvwxyz'],targetWords = ['abcdefghi', 'ijklmnopq', 'qrstuvwxyzx', 'abcdefghjkl', 'ijklmnopqr']) == 2\n assert candidate(startWords = ['xyz', 'abc', 'uvw', 'def', 'ghi'],targetWords = ['xyzab', 'uvwxy', 'defgh', 'abcdef', 'mnopq']) == 0\n assert candidate(startWords = ['pqr', 'stu', 'vwx'],targetWords = ['pqrs', 'stuv', 'vwxy', 'pqrst', 'stuvw', 'vwxys', 'mnopq']) == 3\n assert candidate(startWords = ['quick', 'brown', 'fox'],targetWords = ['quickly', 'brownly', 'foxes', 'quickbrown', 'brownfox']) == 0\n assert candidate(startWords = ['a', 'b', 'c', 'd'],targetWords = ['ab', 'bc', 'cd', 'abc', 'abcd']) == 3\n assert candidate(startWords = ['aabbcc', 'ddeeff', 'gghhii'],targetWords = ['aabbccx', 'ddeeffx', 'gghhia', 'ddeeffg', 'gghhiih']) == 2\n assert candidate(startWords = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx'],targetWords = ['abcdefg', 'ghijklm', 'mnopqrs', 'stuvwxz', 'abcdefghijklmnopqrstuvwxyza', 'ghijklmnopqrstuvwxyz', 'mnopqrstuvwxyzabc', 'stuvwxyzmnopqr']) == 4\n assert candidate(startWords = ['abc', 'de', 'fgh', 'xyz'],targetWords = ['abcd', 'def', 'efg', 'xyzz']) == 2\n assert candidate(startWords = ['jump', 'over', 'lazy'],targetWords = ['jumpo', 'overj', 'lazyr', 'jumpr', 'overv']) == 4\n assert candidate(startWords = ['mnop', 'qrst', 'uvwx'],targetWords = ['mnopq', 'qrstu', 'vwxyz', 'mnopqr', 'qrstuv']) == 2\n assert candidate(startWords = ['abcd', 'efgh', 'ijkl'],targetWords = ['abcde', 'efghi', 'ijklm', 'abcdx', 'efghy', 'ijklz']) == 6\n assert candidate(startWords = ['hello', 'world', 'abc'],targetWords = ['helloz', 'worldy', 'abcd']) == 3\n assert candidate(startWords = ['mnop', 'qrst', 'uvwx'],targetWords = ['mnopq', 'qrstuv', 'uvwxy', 'mnopqr', 'qrstuvw', 'uvwxzy', 'mnopqrst', 'qrstuvwx', 'uvwxyza', 'mnopqrstuvwxyz']) == 2\n assert candidate(startWords = ['programming', 'is', 'fun'],targetWords = ['programmings', 'isis', 'funny', 'programmingis', 'isfun']) == 0\n assert candidate(startWords = ['jump', 'over', 'lazy'],targetWords = ['jumped', 'overly', 'lazily', 'jumpover', 'overlazy']) == 0\n assert candidate(startWords = ['abcdefghij'],targetWords = ['abcdefghijk', 'abcdefghijl', 'abcdefghijm', 'abcdefghijn', 'abcdefghijo', 'abcdefghijp', 'abcdefghijq', 'abcdefghijr', 'abcdefghjis', 'abcdefghijt', 'abcdefghiju', 'abcdefghijv', 'abcdefghijw', 'abcdefghijx', 'abcdefghijy', 'abcdefghijz']) == 16\n assert candidate(startWords = ['abc', 'bcd', 'efg'],targetWords = ['abcd', 'bcde', 'efgh']) == 3\n assert candidate(startWords = ['zebra', 'panda', 'giraffe'],targetWords = ['zebrac', 'pandaf', 'giraffeb', 'zebrad', 'pandaq']) == 5\n assert candidate(startWords = ['jump', 'over', 'lazy'],targetWords = ['jumper', 'overt', 'lazier']) == 1\n assert candidate(startWords = ['a', 'b', 'c'],targetWords = ['ab', 'bc', 'ca', 'abc', 'abcd', 'abcde']) == 3\n assert candidate(startWords = ['xyz', 'wxy', 'uvw'],targetWords = ['xyza', 'wxyb', 'uvwz', 'uvwxy']) == 3\n assert candidate(startWords = ['abcdefgh', 'ijklmnop', 'qrstuvwxyz', 'abcxyz', 'uvwxy'],targetWords = ['abcdefghi', 'ijklmnopq', 'qrstuvwxyzx', 'abcxyzw', 'uvwxyza', 'mnopqrstu']) == 3\n assert candidate(startWords = ['abcd', 'efgh', 'ijkl'],targetWords = ['abcde', 'efghi', 'jklmn', 'abcd']) == 2\n assert candidate(startWords = ['abcd', 'efgh', 'ijkl'],targetWords = ['abcde', 'efghi', 'ijklm', 'mnop']) == 3\n assert candidate(startWords = ['xyz', 'uvw', 'rst'],targetWords = ['xyza', 'uvwq', 'rstu', 'rstuv']) == 3\n assert candidate(startWords = ['abc', 'def', 'ghi'],targetWords = ['abcd', 'defg', 'ghij', 'hijk', 'mnop', 'qrst', 'uvw', 'xyz']) == 3\n assert candidate(startWords = ['quick', 'brown', 'fox'],targetWords = ['quickly', 'brownie', 'foxy', 'quicklybrown', 'brownief', 'quickbrown', 'quickfox', 'brownfox']) == 1\n assert candidate(startWords = ['abcdefghijklmnopqrstuvwxyz'],targetWords = ['abcdefghijklmnopqrstuvwxyza', 'abcdefghijklmnopqrstuvwxyzb']) == 0\n assert candidate(startWords = ['quick', 'brown', 'fox'],targetWords = ['quickly', 'brownish', 'foxy']) == 1\n assert candidate(startWords = ['apple', 'banana', 'cherry'],targetWords = ['appleb', 'bananac', 'cherryd', 'applef', 'bananag']) == 4\n assert candidate(startWords = ['abcd', 'efgh', 'ijkl'],targetWords = ['abcde', 'efghi', 'ijklm']) == 3\n assert candidate(startWords = ['one', 'two', 'three'],targetWords = ['onet', 'twot', 'threet', 'oneto', 'twoto', 'threeto', 'onetwo', 'twotwo', 'threetwo', 'onetwothree', 'twotwothree', 'threetwothree', 'onetwofour', 'twotwofour', 'threetwofour']) == 1\n assert candidate(startWords = ['abcd', 'efgh', 'ijkl'],targetWords = ['abcde', 'efghi', 'ijklm', 'mnopq']) == 3\n assert candidate(startWords = ['hello', 'world'],targetWords = ['hellow', 'worlds', 'dlrow']) == 2\n assert candidate(startWords = ['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'],targetWords = ['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', 'za']) == 26\n assert candidate(startWords = ['zyxwvutsrqponmlkjihgfedcba'],targetWords = ['zyxwvutsrqponmlkjihgfedcbaz', 'zyxwvutsrqponmlkjihgfedcbay', 'zyxwvutsrqponmlkjihgfedcbax', 'zyxwvutsrqponmlkjihgfedcbaw']) == 0\n assert candidate(startWords = ['pqr', 'stu', 'vwx', 'yz', 'abc'],targetWords = ['pqrs', 'stuv', 'vwxy', 'yzab', 'uvwxy', 'mnopq']) == 3\n assert candidate(startWords = ['abcd', 'efgh', 'ijkl', 'mnop'],targetWords = ['abcde', 'efghi', 'ijklm', 'nopqr']) == 3\n assert candidate(startWords = ['hello', 'world'],targetWords = ['ehllo', 'dlrow', 'owrld', 'helloa', 'worldb']) == 2\n assert candidate(startWords = ['a', 'b', 'c', 'd'],targetWords = ['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', 'za']) == 5\n assert candidate(startWords = ['mnopq', 'rstuv', 'wxyz'],targetWords = ['mnopqr', 'rstuvw', 'wxyza', 'mnopqs', 'rstuvx', 'wxyzab', 'mnopqt', 'rstuvy', 'wxyzac', 'mnopqu', 'rstuvz', 'wxyzad', 'mnopqv', 'rstuvw', 'wxyzae']) == 11\n assert candidate(startWords = ['abcdefghijklmnopqrstuvwxyz'],targetWords = ['abcdefghijklmnopqrstuvwxyza', 'abcdefghijklmnopqrstuvwxyzb', 'abcdefghijklmnopqrstuvwxyzc']) == 0\n assert candidate(startWords = ['a', 'b', 'c', 'd'],targetWords = ['ab', 'bc', 'cd', 'da']) == 4\n"}, "metadata": {"canonical_parameter_names": ["startWords", "targetWords"], "leetcode_dataset_entry_point": "Solution().wordCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int wordCount(String[] startWords, String[] targetWords) {", "container": "Solution", "callable": "wordCount", "parameters": [{"name": "startWords", "type": "String[]"}, {"name": "targetWords", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2136, "task_id": "earliest-possible-day-of-full-bloom", "difficulty": "Hard", "problem_description": "You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and growTime, of length n each:\n\nplantTime[i] is the number of full days it takes you to plant the ith seed. Every day, you can work on planting exactly one seed. You do not have to work on planting the same seed on consecutive days, but the planting of a seed is not complete until you have worked plantTime[i] days on planting it in total.\ngrowTime[i] is the number of full days it takes the ith seed to grow after being completely planted. After the last day of its growth, the flower blooms and stays bloomed forever.\n\nFrom the beginning of day 0, you can plant the seeds in any order.\nReturn the earliest possible day where all seeds are blooming.\n \nExample 1:\n\n\nInput: plantTime = [1,4,3], growTime = [2,3,1]\nOutput: 9\nExplanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.\nOne optimal way is:\nOn day 0, plant the 0th seed. The seed grows for 2 full days and blooms on day 3.\nOn days 1, 2, 3, and 4, plant the 1st seed. The seed grows for 3 full days and blooms on day 8.\nOn days 5, 6, and 7, plant the 2nd seed. The seed grows for 1 full day and blooms on day 9.\nThus, on day 9, all the seeds are blooming.\n\nExample 2:\n\n\nInput: plantTime = [1,2,3,2], growTime = [2,1,2,1]\nOutput: 9\nExplanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.\nOne optimal way is:\nOn day 1, plant the 0th seed. The seed grows for 2 full days and blooms on day 4.\nOn days 0 and 3, plant the 1st seed. The seed grows for 1 full day and blooms on day 5.\nOn days 2, 4, and 5, plant the 2nd seed. The seed grows for 2 full days and blooms on day 8.\nOn days 6 and 7, plant the 3rd seed. The seed grows for 1 full day and blooms on day 9.\nThus, on day 9, all the seeds are blooming.\n\nExample 3:\n\nInput: plantTime = [1], growTime = [1]\nOutput: 2\nExplanation: On day 0, plant the 0th seed. The seed grows for 1 full day and blooms on day 2.\nThus, on day 2, all the seeds are blooming.\n\n \nConstraints:\n\nn == plantTime.length == growTime.length\n1 <= n <= 105\n1 <= plantTime[i], growTime[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(plantTime = [1],growTime = [1]) == 2\n assert candidate(plantTime = [2, 2, 2],growTime = [3, 3, 3]) == 9\n assert candidate(plantTime = [2, 2, 2],growTime = [3, 2, 1]) == 7\n assert candidate(plantTime = [10000, 10000],growTime = [10000, 10000]) == 30000\n assert candidate(plantTime = [1, 1, 1, 1, 1],growTime = [5, 4, 3, 2, 1]) == 6\n assert candidate(plantTime = [3, 2, 1],growTime = [10, 20, 30]) == 31\n assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(plantTime = [1, 3, 5, 7],growTime = [7, 5, 3, 1]) == 17\n assert candidate(plantTime = [10, 20, 30],growTime = [1, 2, 3]) == 61\n assert candidate(plantTime = [5, 5, 5],growTime = [5, 5, 5]) == 20\n assert candidate(plantTime = [5, 4, 3, 2, 1],growTime = [1, 2, 3, 4, 5]) == 16\n assert candidate(plantTime = [3, 2, 1],growTime = [2, 1, 3]) == 7\n assert candidate(plantTime = [2, 3, 4],growTime = [3, 2, 1]) == 10\n assert candidate(plantTime = [10000, 10000],growTime = [1, 1]) == 20001\n assert candidate(plantTime = [1, 4, 3],growTime = [2, 3, 1]) == 9\n assert candidate(plantTime = [100, 200, 300],growTime = [100, 200, 300]) == 700\n assert candidate(plantTime = [2, 2, 2, 2],growTime = [4, 3, 2, 1]) == 9\n assert candidate(plantTime = [1, 2, 3, 2],growTime = [2, 1, 2, 1]) == 9\n assert candidate(plantTime = [1, 1, 1, 1],growTime = [1, 1, 1, 1]) == 5\n assert candidate(plantTime = [10, 5, 7],growTime = [4, 6, 8]) == 26\n assert candidate(plantTime = [5, 2, 4],growTime = [3, 1, 2]) == 12\n assert candidate(plantTime = [3, 3, 3],growTime = [3, 3, 3]) == 12\n assert candidate(plantTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],growTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 105\n assert candidate(plantTime = [5, 10, 15, 20],growTime = [20, 15, 10, 5]) == 55\n assert candidate(plantTime = [5, 10, 15, 20],growTime = [20, 15, 10, 5]) == 55\n assert candidate(plantTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],growTime = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 101\n assert candidate(plantTime = [100, 200, 300, 400],growTime = [1000, 500, 700, 200]) == 1200\n assert candidate(plantTime = [500, 500, 500, 500, 500],growTime = [500, 500, 500, 500, 500]) == 3000\n assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1501\n assert candidate(plantTime = [1000, 2000, 3000, 4000, 5000],growTime = [1, 2, 3, 4, 5]) == 15001\n assert candidate(plantTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 101\n assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 21\n assert candidate(plantTime = [10, 20, 30, 40, 50],growTime = [50, 40, 30, 20, 10]) == 160\n assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 56\n assert candidate(plantTime = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],growTime = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6]) == 556\n assert candidate(plantTime = [100, 200, 300, 400, 500],growTime = [500, 400, 300, 200, 100]) == 1600\n assert candidate(plantTime = [10, 20, 30, 40, 50],growTime = [5, 10, 15, 20, 25]) == 155\n assert candidate(plantTime = [5, 10, 4, 6, 8],growTime = [10, 2, 7, 4, 5]) == 35\n assert candidate(plantTime = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],growTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(plantTime = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],growTime = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == 122\n assert candidate(plantTime = [5, 4, 1, 3, 2],growTime = [8, 7, 6, 5, 4]) == 19\n assert candidate(plantTime = [5, 3, 8, 6],growTime = [10, 7, 2, 4]) == 24\n assert candidate(plantTime = [1, 3, 5, 7, 9],growTime = [9, 7, 5, 3, 1]) == 26\n assert candidate(plantTime = [5, 4, 3, 2, 1],growTime = [10, 20, 30, 40, 50]) == 51\n assert candidate(plantTime = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60],growTime = [60, 55, 50, 45, 40, 35, 30, 25, 20, 15]) == 390\n assert candidate(plantTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],growTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 551\n assert candidate(plantTime = [7, 5, 9, 3, 6, 4, 8],growTime = [2, 8, 1, 5, 4, 7, 3]) == 43\n assert candidate(plantTime = [100, 200, 150, 300],growTime = [50, 100, 200, 150]) == 800\n assert candidate(plantTime = [5, 3, 8, 6],growTime = [10, 7, 2, 4]) == 24\n assert candidate(plantTime = [10, 5, 7, 3, 8],growTime = [15, 12, 6, 4, 9]) == 37\n assert candidate(plantTime = [7, 6, 5, 4, 3, 2, 1],growTime = [1, 2, 3, 4, 5, 6, 7]) == 29\n assert candidate(plantTime = [10, 5, 15, 20],growTime = [1, 1, 1, 1]) == 51\n assert candidate(plantTime = [5, 10, 3, 1, 4],growTime = [10, 5, 7, 8, 2]) == 25\n assert candidate(plantTime = [5, 1, 8, 3, 2],growTime = [10, 6, 2, 4, 5]) == 21\n assert candidate(plantTime = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 61\n assert candidate(plantTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],growTime = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 560\n assert candidate(plantTime = [500, 400, 300, 200, 100],growTime = [5, 4, 3, 2, 1]) == 1501\n assert candidate(plantTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 121\n assert candidate(plantTime = [100, 50, 75, 25],growTime = [50, 100, 75, 25]) == 275\n assert candidate(plantTime = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],growTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 5510\n assert candidate(plantTime = [1, 1, 1, 1, 1],growTime = [1000, 1000, 1000, 1000, 1000]) == 1005\n assert candidate(plantTime = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],growTime = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 31\n assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 16\n assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],growTime = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 211\n assert candidate(plantTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],growTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 110\n assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],growTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 56\n assert candidate(plantTime = [100, 200, 300, 400, 500],growTime = [1000, 2000, 3000, 4000, 5000]) == 5500\n assert candidate(plantTime = [1000, 2000, 3000, 4000, 5000],growTime = [5000, 4000, 3000, 2000, 1000]) == 16000\n assert candidate(plantTime = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 31\n assert candidate(plantTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 56\n assert candidate(plantTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],growTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 105\n assert candidate(plantTime = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],growTime = [9, 7, 3, 8, 5, 3, 8, 2, 9, 4, 6]) == 46\n assert candidate(plantTime = [4, 4, 4, 4, 4, 4, 4, 4],growTime = [1, 2, 3, 4, 5, 6, 7, 8]) == 33\n assert candidate(plantTime = [1, 3, 5, 7, 9],growTime = [9, 7, 5, 3, 1]) == 26\n assert candidate(plantTime = [10, 10, 10, 10, 10],growTime = [20, 20, 20, 20, 20]) == 70\n assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 10001\n assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],growTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(plantTime = [1, 1, 1, 1, 1],growTime = [10000, 9999, 9998, 9997, 9996]) == 10001\n assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 101\n assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(plantTime = [1, 10, 100, 1000, 10000],growTime = [10000, 1000, 100, 10, 1]) == 11112\n assert candidate(plantTime = [100, 200, 300, 400, 500],growTime = [1, 2, 3, 4, 5]) == 1501\n assert candidate(plantTime = [7, 14, 21, 28, 35],growTime = [10, 20, 30, 40, 50]) == 118\n assert candidate(plantTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],growTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 110\n assert candidate(plantTime = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],growTime = [9, 7, 3, 8, 5, 3, 0, 9, 4, 6, 8]) == 45\n assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],growTime = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 121\n assert candidate(plantTime = [100, 200, 150, 300],growTime = [500, 400, 300, 200]) == 950\n assert candidate(plantTime = [4, 4, 4, 4, 4],growTime = [9, 8, 7, 6, 5]) == 25\n assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],growTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 56\n assert candidate(plantTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],growTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 103\n assert candidate(plantTime = [3, 5, 7, 9, 11, 13, 15],growTime = [2, 4, 6, 8, 10, 12, 14]) == 65\n assert candidate(plantTime = [100, 200, 300, 400, 500],growTime = [1, 1, 1, 1, 1]) == 1501\n assert candidate(plantTime = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10],growTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 56\n assert candidate(plantTime = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],growTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 21\n assert candidate(plantTime = [50, 40, 30, 20, 10],growTime = [1, 2, 3, 4, 5]) == 151\n assert candidate(plantTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],growTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 101\n assert candidate(plantTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],growTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 551\n assert candidate(plantTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],growTime = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 560\n assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(plantTime = [7, 6, 5, 4, 3, 2, 1],growTime = [1, 2, 3, 4, 5, 6, 7]) == 29\n assert candidate(plantTime = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],growTime = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 46\n"}, "metadata": {"canonical_parameter_names": ["plantTime", "growTime"], "leetcode_dataset_entry_point": "Solution().earliestFullBloom", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int earliestFullBloom(int[] plantTime, int[] growTime) {", "container": "Solution", "callable": "earliestFullBloom", "parameters": [{"name": "plantTime", "type": "int[]"}, {"name": "growTime", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2138, "task_id": "divide-a-string-into-groups-of-size-k", "difficulty": "Easy", "problem_description": "A string s can be partitioned into groups of size k using the following procedure:\n\nThe first group consists of the first k characters of the string, the second group consists of the next k characters of the string, and so on. Each element can be a part of exactly one group.\nFor the last group, if the string does not have k characters remaining, a character fill is used to complete the group.\n\nNote that the partition is done so that after removing the fill character from the last group (if it exists) and concatenating all the groups in order, the resultant string should be s.\nGiven the string s, the size of each group k and the character fill, return a string array denoting the composition of every group s has been divided into, using the above procedure.\n \nExample 1:\n\nInput: s = \"abcdefghi\", k = 3, fill = \"x\"\nOutput: [\"abc\",\"def\",\"ghi\"]\nExplanation:\nThe first 3 characters \"abc\" form the first group.\nThe next 3 characters \"def\" form the second group.\nThe last 3 characters \"ghi\" form the third group.\nSince all groups can be completely filled by characters from the string, we do not need to use fill.\nThus, the groups formed are \"abc\", \"def\", and \"ghi\".\n\nExample 2:\n\nInput: s = \"abcdefghij\", k = 3, fill = \"x\"\nOutput: [\"abc\",\"def\",\"ghi\",\"jxx\"]\nExplanation:\nSimilar to the previous example, we are forming the first three groups \"abc\", \"def\", and \"ghi\".\nFor the last group, we can only use the character 'j' from the string. To complete this group, we add 'x' twice.\nThus, the 4 groups formed are \"abc\", \"def\", \"ghi\", and \"jxx\".\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consists of lowercase English letters only.\n1 <= k <= 100\nfill is a lowercase English letter.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghij\",k = 3,fill = \"x\") == ['abc', 'def', 'ghi', 'jxx']\n assert candidate(s = \"abcdefg\",k = 2,fill = \"z\") == ['ab', 'cd', 'ef', 'gz']\n assert candidate(s = \"abcdefghi\",k = 3,fill = \"x\") == ['abc', 'def', 'ghi']\n assert candidate(s = \"a\",k = 1,fill = \"y\") == ['a']\n assert candidate(s = \"python\",k = 6,fill = \"q\") == ['python']\n assert candidate(s = \"hello world\",k = 4,fill = \"_\") == ['hell', 'o wo', 'rld_']\n assert candidate(s = \"programming\",k = 1,fill = \"a\") == ['p', 'r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g']\n assert candidate(s = \"hello world\",k = 2,fill = \"_\") == ['he', 'll', 'o ', 'wo', 'rl', 'd_']\n assert candidate(s = \"\",k = 3,fill = \"b\") == []\n assert candidate(s = \"hello\",k = 2,fill = \"q\") == ['he', 'll', 'oq']\n assert candidate(s = \"abc\",k = 5,fill = \"z\") == ['abczz']\n assert candidate(s = \"a\",k = 5,fill = \"y\") == ['ayyyy']\n assert candidate(s = \"boundarycase\",k = 8,fill = \"b\") == ['boundary', 'casebbbb']\n assert candidate(s = \"thisisaverylongstring\",k = 5,fill = \"p\") == ['thisi', 'saver', 'ylong', 'strin', 'gpppp']\n assert candidate(s = \"abcdexyz\",k = 2,fill = \"g\") == ['ab', 'cd', 'ex', 'yz']\n assert candidate(s = \"repeatedcharacters\",k = 7,fill = \"e\") == ['repeate', 'dcharac', 'terseee']\n assert candidate(s = \"interview\",k = 2,fill = \"z\") == ['in', 'te', 'rv', 'ie', 'wz']\n assert candidate(s = \"abcdefg\",k = 7,fill = \"z\") == ['abcdefg']\n assert candidate(s = \"abcdefghijk\",k = 5,fill = \"m\") == ['abcde', 'fghij', 'kmmmm']\n assert candidate(s = \"abcdef\",k = 8,fill = \"n\") == ['abcdefnn']\n assert candidate(s = \"programming\",k = 3,fill = \"a\") == ['pro', 'gra', 'mmi', 'nga']\n assert candidate(s = \"complexstringwithfill\",k = 9,fill = \"r\") == ['complexst', 'ringwithf', 'illrrrrrr']\n assert candidate(s = \"abcd\",k = 5,fill = \"t\") == ['abcdt']\n assert candidate(s = \"almostfill\",k = 9,fill = \"l\") == ['almostfil', 'lllllllll']\n assert candidate(s = \"partitioning\",k = 3,fill = \"z\") == ['par', 'tit', 'ion', 'ing']\n assert candidate(s = \"abcdefgxyz\",k = 1,fill = \"m\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z']\n assert candidate(s = \"abcdefg\",k = 1,fill = \"d\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n assert candidate(s = \"hello\",k = 4,fill = \"o\") == ['hell', 'oooo']\n assert candidate(s = \"abcdefghijabcdefghij\",k = 11,fill = \"c\") == ['abcdefghija', 'bcdefghijcc']\n assert candidate(s = \"repeatthispattern\",k = 8,fill = \"m\") == ['repeatth', 'ispatter', 'nmmmmmmm']\n assert candidate(s = \"ab\",k = 2,fill = \"l\") == ['ab']\n assert candidate(s = \"example\",k = 2,fill = \"z\") == ['ex', 'am', 'pl', 'ez']\n assert candidate(s = \"fill\",k = 1,fill = \"f\") == ['f', 'i', 'l', 'l']\n assert candidate(s = \"thisisaverylongstringthatneedstobedivided\",k = 5,fill = \"a\") == ['thisi', 'saver', 'ylong', 'strin', 'gthat', 'needs', 'tobed', 'ivide', 'daaaa']\n assert candidate(s = \"abcdefghijk\",k = 1,fill = \"m\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']\n assert candidate(s = \"short\",k = 5,fill = \"q\") == ['short']\n assert candidate(s = \"thisisaverylongstring\",k = 5,fill = \"m\") == ['thisi', 'saver', 'ylong', 'strin', 'gmmmm']\n assert candidate(s = \"abcdefghij\",k = 2,fill = \"w\") == ['ab', 'cd', 'ef', 'gh', 'ij']\n assert candidate(s = \"hello\",k = 4,fill = \"p\") == ['hell', 'oppp']\n assert candidate(s = \"almostfullgroup\",k = 10,fill = \"a\") == ['almostfull', 'groupaaaaa']\n assert candidate(s = \"qwen\",k = 2,fill = \"q\") == ['qw', 'en']\n assert candidate(s = \"hello\",k = 1,fill = \"b\") == ['h', 'e', 'l', 'l', 'o']\n assert candidate(s = \"abcd\",k = 2,fill = \"p\") == ['ab', 'cd']\n assert candidate(s = \"partitioning\",k = 5,fill = \"p\") == ['parti', 'tioni', 'ngppp']\n assert candidate(s = \"thisisanexample\",k = 3,fill = \"y\") == ['thi', 'sis', 'ane', 'xam', 'ple']\n assert candidate(s = \"abcdefg\",k = 10,fill = \"q\") == ['abcdefgqqq']\n assert candidate(s = \"samecharacter\",k = 2,fill = \"s\") == ['sa', 'me', 'ch', 'ar', 'ac', 'te', 'rs']\n assert candidate(s = \"fillingwithx\",k = 7,fill = \"x\") == ['filling', 'withxxx']\n assert candidate(s = \"longerstring\",k = 6,fill = \"p\") == ['longer', 'string']\n assert candidate(s = \"algorithm\",k = 4,fill = \"m\") == ['algo', 'rith', 'mmmm']\n assert candidate(s = \"xylophone\",k = 6,fill = \"o\") == ['xyloph', 'oneooo']\n assert candidate(s = \"thisisaverylongstringthatneedstobedivided\",k = 5,fill = \"x\") == ['thisi', 'saver', 'ylong', 'strin', 'gthat', 'needs', 'tobed', 'ivide', 'dxxxx']\n assert candidate(s = \"abcdeabcdeabcdea\",k = 4,fill = \"w\") == ['abcd', 'eabc', 'deab', 'cdea']\n assert candidate(s = \"xyz\",k = 1,fill = \"v\") == ['x', 'y', 'z']\n assert candidate(s = \"evenlydivisible\",k = 2,fill = \"q\") == ['ev', 'en', 'ly', 'di', 'vi', 'si', 'bl', 'eq']\n assert candidate(s = \"programming\",k = 3,fill = \"w\") == ['pro', 'gra', 'mmi', 'ngw']\n assert candidate(s = \"boundarycase\",k = 9,fill = \"b\") == ['boundaryc', 'asebbbbbb']\n assert candidate(s = \"onemoretestcase\",k = 6,fill = \"t\") == ['onemor', 'etestc', 'asettt']\n assert candidate(s = \"abcdefg\",k = 3,fill = \"v\") == ['abc', 'def', 'gvv']\n assert candidate(s = \"equalgroups\",k = 5,fill = \"w\") == ['equal', 'group', 'swwww']\n assert candidate(s = \"equalgroups\",k = 3,fill = \"c\") == ['equ', 'alg', 'rou', 'psc']\n assert candidate(s = \"quickbrownfox\",k = 3,fill = \"y\") == ['qui', 'ckb', 'row', 'nfo', 'xyy']\n assert candidate(s = \"abcdef\",k = 7,fill = \"n\") == ['abcdefn']\n assert candidate(s = \"abcdefghij\",k = 4,fill = \"x\") == ['abcd', 'efgh', 'ijxx']\n assert candidate(s = \"abcdef\",k = 7,fill = \"z\") == ['abcdefz']\n assert candidate(s = \"zebra\",k = 1,fill = \"x\") == ['z', 'e', 'b', 'r', 'a']\n assert candidate(s = \"this is a test\",k = 5,fill = \"_\") == ['this ', 'is a ', 'test_']\n assert candidate(s = \"abcdef\",k = 2,fill = \"o\") == ['ab', 'cd', 'ef']\n assert candidate(s = \"thisisalongstring\",k = 4,fill = \"x\") == ['this', 'isal', 'ongs', 'trin', 'gxxx']\n assert candidate(s = \"partitioning\",k = 7,fill = \"f\") == ['partiti', 'oningff']\n assert candidate(s = \"example\",k = 10,fill = \"z\") == ['examplezzz']\n assert candidate(s = \"abcdefghij\",k = 4,fill = \"e\") == ['abcd', 'efgh', 'ijee']\n assert candidate(s = \"programmingisfun\",k = 5,fill = \"a\") == ['progr', 'ammin', 'gisfu', 'naaaa']\n assert candidate(s = \"thisisaverylongstringthatwillneedfilling\",k = 7,fill = \"a\") == ['thisisa', 'verylon', 'gstring', 'thatwil', 'lneedfi', 'llingaa']\n assert candidate(s = \"onetwothreefourfive\",k = 6,fill = \"j\") == ['onetwo', 'threef', 'ourfiv', 'ejjjjj']\n assert candidate(s = \"world\",k = 10,fill = \"c\") == ['worldccccc']\n assert candidate(s = \"xyz\",k = 10,fill = \"a\") == ['xyzaaaaaaa']\n assert candidate(s = \"hello world\",k = 4,fill = \"x\") == ['hell', 'o wo', 'rldx']\n assert candidate(s = \"abcdefgxyz\",k = 4,fill = \"a\") == ['abcd', 'efgx', 'yzaa']\n assert candidate(s = \"abcdefghijk\",k = 4,fill = \"x\") == ['abcd', 'efgh', 'ijkx']\n assert candidate(s = \"partition\",k = 1,fill = \"m\") == ['p', 'a', 'r', 't', 'i', 't', 'i', 'o', 'n']\n assert candidate(s = \"algorithms\",k = 7,fill = \"b\") == ['algorit', 'hmsbbbb']\n assert candidate(s = \"repeatedcharacterstest\",k = 7,fill = \"z\") == ['repeate', 'dcharac', 'terstes', 'tzzzzzz']\n assert candidate(s = \"almostfull\",k = 4,fill = \"i\") == ['almo', 'stfu', 'llii']\n assert candidate(s = \"filler\",k = 11,fill = \"l\") == ['fillerlllll']\n assert candidate(s = \"\",k = 3,fill = \"n\") == []\n assert candidate(s = \"abcdefghijk\",k = 3,fill = \"n\") == ['abc', 'def', 'ghi', 'jkn']\n assert candidate(s = \"elephants\",k = 3,fill = \"p\") == ['ele', 'pha', 'nts']\n assert candidate(s = \"short\",k = 10,fill = \"p\") == ['shortppppp']\n assert candidate(s = \"abcd\",k = 6,fill = \"w\") == ['abcdww']\n assert candidate(s = \"abcdef\",k = 2,fill = \"x\") == ['ab', 'cd', 'ef']\n assert candidate(s = \"quickbrownfox\",k = 4,fill = \"x\") == ['quic', 'kbro', 'wnfo', 'xxxx']\n assert candidate(s = \"qwert\",k = 10,fill = \"n\") == ['qwertnnnnn']\n assert candidate(s = \"machinelearning\",k = 8,fill = \"d\") == ['machinel', 'earningd']\n assert candidate(s = \"abcdef\",k = 1,fill = \"z\") == ['a', 'b', 'c', 'd', 'e', 'f']\n assert candidate(s = \"short\",k = 10,fill = \"b\") == ['shortbbbbb']\n assert candidate(s = \"programming\",k = 7,fill = \"a\") == ['program', 'mingaaa']\n assert candidate(s = \"datastructure\",k = 5,fill = \"a\") == ['datas', 'truct', 'ureaa']\n assert candidate(s = \"helloWorld\",k = 3,fill = \"x\") == ['hel', 'loW', 'orl', 'dxx']\n assert candidate(s = \"abcdefghijkmnopqrstuvwxyz\",k = 5,fill = \"x\") == ['abcde', 'fghij', 'kmnop', 'qrstu', 'vwxyz']\n assert candidate(s = \"abcdefghijk\",k = 3,fill = \"p\") == ['abc', 'def', 'ghi', 'jkp']\n assert candidate(s = \"divisiblebyk\",k = 2,fill = \"h\") == ['di', 'vi', 'si', 'bl', 'eb', 'yk']\n assert candidate(s = \"qwenassistant\",k = 7,fill = \"a\") == ['qwenass', 'istanta']\n assert candidate(s = \"cloudcomputing\",k = 6,fill = \"c\") == ['cloudc', 'omputi', 'ngcccc']\n assert candidate(s = \"longerstringexample\",k = 6,fill = \"n\") == ['longer', 'string', 'exampl', 'ennnnn']\n assert candidate(s = \"abcdefghijklnm\",k = 4,fill = \"r\") == ['abcd', 'efgh', 'ijkl', 'nmrr']\n assert candidate(s = \"algorithm\",k = 5,fill = \"b\") == ['algor', 'ithmb']\n assert candidate(s = \"quickbrownfox\",k = 3,fill = \"m\") == ['qui', 'ckb', 'row', 'nfo', 'xmm']\n assert candidate(s = \"abcd\",k = 4,fill = \"x\") == ['abcd']\n assert candidate(s = \"almostfull\",k = 8,fill = \"o\") == ['almostfu', 'lloooooo']\n"}, "metadata": {"canonical_parameter_names": ["s", "k", "fill"], "leetcode_dataset_entry_point": "Solution().divideString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String[] divideString(String s, int k, char fill) {", "container": "Solution", "callable": "divideString", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}, {"name": "fill", "type": "char"}], "return_type": "String[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2139, "task_id": "minimum-moves-to-reach-target-score", "difficulty": "Medium", "problem_description": "You are playing a game with integers. You start with the integer 1 and you want to reach the integer target.\nIn one move, you can either:\n\nIncrement the current integer by one (i.e., x = x + 1).\nDouble the current integer (i.e., x = 2 * x).\n\nYou can use the increment operation any number of times, however, you can only use the double operation at most maxDoubles times.\nGiven the two integers target and maxDoubles, return the minimum number of moves needed to reach target starting with 1.\n \nExample 1:\n\nInput: target = 5, maxDoubles = 0\nOutput: 4\nExplanation: Keep incrementing by 1 until you reach target.\n\nExample 2:\n\nInput: target = 19, maxDoubles = 2\nOutput: 7\nExplanation: Initially, x = 1\nIncrement 3 times so x = 4\nDouble once so x = 8\nIncrement once so x = 9\nDouble again so x = 18\nIncrement once so x = 19\n\nExample 3:\n\nInput: target = 10, maxDoubles = 4\nOutput: 4\nExplanation: Initially, x = 1\nIncrement once so x = 2\nDouble once so x = 4\nIncrement once so x = 5\nDouble again so x = 10\n\n \nConstraints:\n\n1 <= target <= 109\n0 <= maxDoubles <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = 2,maxDoubles = 1) == 1\n assert candidate(target = 6,maxDoubles = 0) == 5\n assert candidate(target = 1000000000,maxDoubles = 100) == 41\n assert candidate(target = 8,maxDoubles = 3) == 3\n assert candidate(target = 100,maxDoubles = 10) == 8\n assert candidate(target = 256,maxDoubles = 8) == 8\n assert candidate(target = 3,maxDoubles = 1) == 2\n assert candidate(target = 3,maxDoubles = 2) == 2\n assert candidate(target = 7,maxDoubles = 1) == 4\n assert candidate(target = 100,maxDoubles = 5) == 8\n assert candidate(target = 10,maxDoubles = 4) == 4\n assert candidate(target = 100,maxDoubles = 0) == 99\n assert candidate(target = 100,maxDoubles = 1) == 50\n assert candidate(target = 5,maxDoubles = 0) == 4\n assert candidate(target = 7,maxDoubles = 0) == 6\n assert candidate(target = 1,maxDoubles = 5) == 0\n assert candidate(target = 1,maxDoubles = 1) == 0\n assert candidate(target = 1,maxDoubles = 10) == 0\n assert candidate(target = 20,maxDoubles = 0) == 19\n assert candidate(target = 19,maxDoubles = 2) == 7\n assert candidate(target = 6,maxDoubles = 1) == 3\n assert candidate(target = 1023,maxDoubles = 10) == 18\n assert candidate(target = 1000000000,maxDoubles = 50) == 41\n assert candidate(target = 8193,maxDoubles = 13) == 14\n assert candidate(target = 4095,maxDoubles = 10) == 22\n assert candidate(target = 32768,maxDoubles = 16) == 15\n assert candidate(target = 123456789,maxDoubles = 30) == 41\n assert candidate(target = 987654321,maxDoubles = 25) == 66\n assert candidate(target = 34359738367,maxDoubles = 35) == 68\n assert candidate(target = 32767,maxDoubles = 15) == 28\n assert candidate(target = 524288,maxDoubles = 20) == 19\n assert candidate(target = 246813579,maxDoubles = 0) == 246813578\n assert candidate(target = 333333333,maxDoubles = 100) == 43\n assert candidate(target = 8192,maxDoubles = 12) == 13\n assert candidate(target = 15,maxDoubles = 1) == 8\n assert candidate(target = 63,maxDoubles = 3) == 12\n assert candidate(target = 16,maxDoubles = 4) == 4\n assert candidate(target = 4294967295,maxDoubles = 32) == 62\n assert candidate(target = 2147483647,maxDoubles = 20) == 2086\n assert candidate(target = 255,maxDoubles = 7) == 14\n assert candidate(target = 2,maxDoubles = 2) == 1\n assert candidate(target = 8192,maxDoubles = 13) == 13\n assert candidate(target = 131072,maxDoubles = 18) == 17\n assert candidate(target = 4,maxDoubles = 1) == 2\n assert candidate(target = 131071,maxDoubles = 17) == 32\n assert candidate(target = 17179869183,maxDoubles = 34) == 66\n assert candidate(target = 8,maxDoubles = 0) == 7\n assert candidate(target = 1,maxDoubles = 0) == 0\n assert candidate(target = 999999999,maxDoubles = 100) == 49\n assert candidate(target = 777777777,maxDoubles = 75) == 46\n assert candidate(target = 95,maxDoubles = 6) == 11\n assert candidate(target = 68719476735,maxDoubles = 36) == 70\n assert candidate(target = 500,maxDoubles = 9) == 13\n assert candidate(target = 999999999,maxDoubles = 0) == 999999998\n assert candidate(target = 987654321,maxDoubles = 50) == 45\n assert candidate(target = 19,maxDoubles = 1) == 10\n assert candidate(target = 1001,maxDoubles = 10) == 15\n assert candidate(target = 8,maxDoubles = 4) == 3\n assert candidate(target = 16,maxDoubles = 5) == 4\n assert candidate(target = 23,maxDoubles = 3) == 7\n assert candidate(target = 65535,maxDoubles = 16) == 30\n assert candidate(target = 16,maxDoubles = 3) == 4\n assert candidate(target = 31,maxDoubles = 3) == 8\n assert candidate(target = 500000,maxDoubles = 15) == 32\n assert candidate(target = 47,maxDoubles = 5) == 9\n assert candidate(target = 1023,maxDoubles = 0) == 1022\n assert candidate(target = 199999999,maxDoubles = 100) == 46\n assert candidate(target = 500,maxDoubles = 0) == 499\n assert candidate(target = 987654321,maxDoubles = 0) == 987654320\n assert candidate(target = 2048,maxDoubles = 15) == 11\n assert candidate(target = 19,maxDoubles = 3) == 6\n assert candidate(target = 123456789,maxDoubles = 50) == 41\n assert candidate(target = 1023,maxDoubles = 5) == 40\n assert candidate(target = 10000,maxDoubles = 100) == 17\n assert candidate(target = 4,maxDoubles = 2) == 2\n assert candidate(target = 15,maxDoubles = 3) == 6\n assert candidate(target = 2147483647,maxDoubles = 31) == 60\n assert candidate(target = 23456789,maxDoubles = 20) == 51\n assert candidate(target = 1024,maxDoubles = 512) == 10\n assert candidate(target = 8,maxDoubles = 2) == 3\n assert candidate(target = 4095,maxDoubles = 12) == 22\n assert candidate(target = 11,maxDoubles = 2) == 5\n assert candidate(target = 511,maxDoubles = 8) == 16\n assert candidate(target = 127,maxDoubles = 4) == 14\n assert candidate(target = 1000000,maxDoubles = 0) == 999999\n assert candidate(target = 9,maxDoubles = 1) == 5\n assert candidate(target = 32768,maxDoubles = 15) == 15\n assert candidate(target = 8192,maxDoubles = 0) == 8191\n assert candidate(target = 123456,maxDoubles = 20) == 21\n assert candidate(target = 987654321,maxDoubles = 10) == 964519\n assert candidate(target = 262143,maxDoubles = 18) == 34\n assert candidate(target = 128,maxDoubles = 7) == 7\n assert candidate(target = 131072,maxDoubles = 16) == 17\n assert candidate(target = 1048576,maxDoubles = 21) == 20\n assert candidate(target = 31,maxDoubles = 5) == 8\n assert candidate(target = 987654321,maxDoubles = 45) == 45\n assert candidate(target = 65536,maxDoubles = 17) == 16\n assert candidate(target = 127,maxDoubles = 6) == 12\n assert candidate(target = 8589934591,maxDoubles = 33) == 64\n assert candidate(target = 2,maxDoubles = 0) == 1\n assert candidate(target = 16,maxDoubles = 0) == 15\n assert candidate(target = 1023,maxDoubles = 9) == 18\n assert candidate(target = 500000000,maxDoubles = 10) == 488291\n assert candidate(target = 25,maxDoubles = 3) == 6\n assert candidate(target = 1024,maxDoubles = 10) == 10\n assert candidate(target = 8191,maxDoubles = 10) == 26\n assert candidate(target = 16384,maxDoubles = 16) == 14\n assert candidate(target = 678901234,maxDoubles = 50) == 45\n assert candidate(target = 7,maxDoubles = 3) == 4\n assert candidate(target = 63,maxDoubles = 5) == 10\n assert candidate(target = 999999999,maxDoubles = 1) == 500000000\n assert candidate(target = 1048575,maxDoubles = 20) == 38\n assert candidate(target = 64,maxDoubles = 6) == 6\n assert candidate(target = 137438953471,maxDoubles = 37) == 72\n assert candidate(target = 135792468,maxDoubles = 10) == 132623\n assert candidate(target = 8,maxDoubles = 1) == 4\n assert candidate(target = 1048576,maxDoubles = 20) == 20\n assert candidate(target = 123456789,maxDoubles = 25) == 41\n assert candidate(target = 888888888,maxDoubles = 88) == 46\n assert candidate(target = 32,maxDoubles = 5) == 5\n assert candidate(target = 65535,maxDoubles = 0) == 65534\n assert candidate(target = 1000000000,maxDoubles = 1) == 500000000\n assert candidate(target = 16,maxDoubles = 1) == 8\n assert candidate(target = 2047,maxDoubles = 10) == 20\n assert candidate(target = 2048,maxDoubles = 10) == 11\n assert candidate(target = 16,maxDoubles = 2) == 5\n assert candidate(target = 1000,maxDoubles = 10) == 14\n assert candidate(target = 1000000000,maxDoubles = 0) == 999999999\n assert candidate(target = 999999999,maxDoubles = 50) == 49\n assert candidate(target = 65535,maxDoubles = 15) == 30\n assert candidate(target = 7,maxDoubles = 2) == 4\n assert candidate(target = 31,maxDoubles = 4) == 8\n assert candidate(target = 262144,maxDoubles = 19) == 18\n assert candidate(target = 524287,maxDoubles = 19) == 36\n assert candidate(target = 19,maxDoubles = 4) == 6\n assert candidate(target = 268435456,maxDoubles = 28) == 28\n assert candidate(target = 1000000000,maxDoubles = 30) == 41\n assert candidate(target = 512,maxDoubles = 9) == 9\n assert candidate(target = 16383,maxDoubles = 14) == 26\n assert candidate(target = 8973424,maxDoubles = 50) == 32\n"}, "metadata": {"canonical_parameter_names": ["target", "maxDoubles"], "leetcode_dataset_entry_point": "Solution().minMoves", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minMoves(int target, int maxDoubles) {", "container": "Solution", "callable": "minMoves", "parameters": [{"name": "target", "type": "int"}, {"name": "maxDoubles", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2140, "task_id": "solving-questions-with-brainpower", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri].\nThe array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you pointsi points but you will be unable to solve each of the next brainpoweri questions. If you skip question i, you get to make the decision on the next question.\n\nFor example, given questions = [[3, 2], [4, 3], [4, 4], [2, 5]]:\n\n\t\nIf question 0 is solved, you will earn 3 points but you will be unable to solve questions 1 and 2.\nIf instead, question 0 is skipped and question 1 is solved, you will earn 4 points but you will be unable to solve questions 2 and 3.\n\n\n\nReturn the maximum points you can earn for the exam.\n \nExample 1:\n\nInput: questions = [[3,2],[4,3],[4,4],[2,5]]\nOutput: 5\nExplanation: The maximum points can be earned by solving questions 0 and 3.\n- Solve question 0: Earn 3 points, will be unable to solve the next 2 questions\n- Unable to solve questions 1 and 2\n- Solve question 3: Earn 2 points\nTotal points earned: 3 + 2 = 5. There is no other way to earn 5 or more points.\n\nExample 2:\n\nInput: questions = [[1,1],[2,2],[3,3],[4,4],[5,5]]\nOutput: 7\nExplanation: The maximum points can be earned by solving questions 1 and 4.\n- Skip question 0\n- Solve question 1: Earn 2 points, will be unable to solve the next 2 questions\n- Unable to solve questions 2 and 3\n- Solve question 4: Earn 5 points\nTotal points earned: 2 + 5 = 7. There is no other way to earn 7 or more points.\n\n \nConstraints:\n\n1 <= questions.length <= 105\nquestions[i].length == 2\n1 <= pointsi, brainpoweri <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(questions = [[10, 0], [20, 1], [30, 2], [40, 3], [50, 4]]) == 80\n assert candidate(questions = [[5, 10], [10, 5], [15, 1]]) == 15\n assert candidate(questions = [[10, 1], [10, 1], [10, 1], [10, 1], [10, 1]]) == 30\n assert candidate(questions = [[5, 1], [2, 2], [3, 3], [1, 1], [4, 4]]) == 9\n assert candidate(questions = [[1, 5], [2, 3], [3, 2], [4, 1]]) == 4\n assert candidate(questions = [[5, 1], [2, 2], [1, 1]]) == 6\n assert candidate(questions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 6\n assert candidate(questions = [[1, 99], [2, 98], [3, 97], [4, 96], [5, 95]]) == 5\n assert candidate(questions = [[3, 2], [4, 3], [4, 4], [2, 5]]) == 5\n assert candidate(questions = [[100000, 99999], [1, 1], [1, 1], [1, 1], [1, 1]]) == 100000\n assert candidate(questions = [[5, 0], [2, 1], [3, 1], [4, 1], [5, 0]]) == 13\n assert candidate(questions = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 3\n assert candidate(questions = [[1, 2], [2, 1], [3, 2], [4, 1], [5, 0]]) == 7\n assert candidate(questions = [[10, 0], [20, 0], [30, 0], [40, 0], [50, 0]]) == 150\n assert candidate(questions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 7\n assert candidate(questions = [[5, 0], [2, 1], [3, 2], [1, 3]]) == 8\n assert candidate(questions = [[10, 0], [1, 1], [1, 1], [1, 1], [1, 1]]) == 12\n assert candidate(questions = [[3, 3], [2, 2], [1, 1], [4, 0], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 14\n assert candidate(questions = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [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(questions = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 100\n assert candidate(questions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 11\n assert candidate(questions = [[10, 0], [20, 1], [30, 2], [40, 3], [50, 4], [60, 5]]) == 100\n assert candidate(questions = [[100000, 0], [100000, 0], [100000, 0], [100000, 0], [100000, 0], [100000, 0], [100000, 0], [100000, 0], [100000, 0], [100000, 0]]) == 1000000\n assert candidate(questions = [[10, 2], [5, 1], [1, 3], [8, 4], [6, 1]]) == 18\n assert candidate(questions = [[10, 0], [5, 2], [10, 1], [4, 2], [3, 1]]) == 23\n assert candidate(questions = [[50, 4], [30, 1], [20, 2], [10, 3], [5, 5], [1, 6], [2, 7], [3, 8]]) == 53\n assert candidate(questions = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0]]) == 10\n assert candidate(questions = [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]]) == 10\n assert candidate(questions = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 22\n assert candidate(questions = [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 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(questions = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 9\n assert candidate(questions = [[10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10], [100, 11], [110, 12], [120, 13], [130, 14], [140, 15], [150, 16]]) == 230\n assert candidate(questions = [[50000, 10000], [10000, 5000], [5000, 1000], [1000, 500], [500, 100], [100, 50]]) == 50000\n assert candidate(questions = [[10, 2], [5, 1], [1, 4], [7, 3], [8, 0], [2, 2]]) == 20\n assert candidate(questions = [[100, 0], [200, 1], [300, 2], [400, 3], [500, 4], [600, 5], [700, 6], [800, 7], [900, 8], [1000, 9], [1100, 10], [1200, 11]]) == 2200\n assert candidate(questions = [[10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 64\n assert candidate(questions = [[100, 100], [200, 99], [300, 98], [400, 97], [500, 96], [600, 95], [700, 94], [800, 93], [900, 92], [1000, 91]]) == 1000\n assert candidate(questions = [[3, 1], [4, 2], [5, 3], [6, 4], [7, 5], [8, 6], [9, 7], [10, 8]]) == 18\n assert candidate(questions = [[5, 0], [3, 1], [4, 2], [2, 3], [3, 4], [4, 5], [1, 6], [2, 7]]) == 13\n assert candidate(questions = [[90, 5], [80, 4], [70, 3], [60, 2], [50, 1], [40, 0]]) == 90\n assert candidate(questions = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]]) == 55\n assert candidate(questions = [[100000, 99999], [2, 1], [3, 2], [4, 3], [5, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 100000\n assert candidate(questions = [[50, 0], [25, 1], [15, 2], [5, 3], [10, 4], [20, 5], [30, 6], [40, 7], [60, 8], [70, 9]]) == 155\n assert candidate(questions = [[1000, 500], [900, 450], [800, 400], [700, 350], [600, 300], [500, 250], [400, 200], [300, 150], [200, 100], [100, 50]]) == 1000\n assert candidate(questions = [[20, 0], [10, 1], [5, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 32\n assert candidate(questions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8]]) == 120\n assert candidate(questions = [[10, 2], [5, 1], [7, 3], [15, 0], [8, 1], [6, 2]]) == 33\n assert candidate(questions = [[100000, 0], [99999, 1], [99998, 2], [99997, 3], [99996, 4], [99995, 5], [99994, 6], [99993, 7], [99992, 8], [99991, 9]]) == 399989\n assert candidate(questions = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11]]) == 22\n assert candidate(questions = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]]) == 4\n assert candidate(questions = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 4\n assert candidate(questions = [[5, 0], [4, 1], [3, 2], [2, 3], [1, 4], [0, 5], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5]]) == 20\n assert candidate(questions = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9], [0, 10]]) == 19\n assert candidate(questions = [[1, 99999], [2, 99998], [3, 99997], [4, 99996], [5, 99995]]) == 5\n assert candidate(questions = [[1, 1], [10, 1], [100, 1], [1000, 1], [10000, 1], [100000, 1], [1000000, 1]]) == 1010101\n assert candidate(questions = [[1, 99999], [2, 99998], [3, 99997], [4, 99996], [5, 99995], [6, 99994], [7, 99993], [8, 99992], [9, 99991], [10, 99990]]) == 10\n assert candidate(questions = [[10, 2], [5, 1], [8, 3], [6, 4], [7, 0], [9, 1]]) == 26\n assert candidate(questions = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 8\n assert candidate(questions = [[9, 5], [8, 4], [7, 3], [6, 2], [5, 1], [4, 0], [3, 1], [2, 2], [1, 3], [0, 4]]) == 13\n assert candidate(questions = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 10\n assert candidate(questions = [[20, 0], [30, 1], [40, 2], [50, 3], [60, 4], [70, 5], [80, 6], [90, 7], [100, 8], [110, 9]]) == 220\n assert candidate(questions = [[10, 2], [20, 1], [30, 0], [40, 3], [50, 2], [60, 1]]) == 90\n assert candidate(questions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 10\n assert candidate(questions = [[3, 3], [4, 2], [5, 1], [6, 0], [7, 2], [8, 3], [9, 4]]) == 15\n assert candidate(questions = [[10, 5], [20, 3], [30, 1], [40, 2], [50, 4], [60, 0], [70, 6], [80, 7], [90, 8], [100, 9]]) == 190\n assert candidate(questions = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 10\n assert candidate(questions = [[10, 0], [9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9], [0, 10]]) == 29\n assert candidate(questions = [[5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [6, 1], [7, 0]]) == 14\n assert candidate(questions = [[30, 5], [5, 0], [10, 1], [15, 3], [20, 2]]) == 35\n assert candidate(questions = [[5, 2], [3, 1], [7, 3], [2, 0], [8, 2], [6, 1]]) == 15\n assert candidate(questions = [[100, 50], [200, 25], [300, 10], [400, 0], [500, 30], [600, 15], [700, 40]]) == 1100\n assert candidate(questions = [[100, 99], [90, 98], [80, 97], [70, 96], [60, 95], [50, 94], [40, 93], [30, 92], [20, 91], [10, 90]]) == 100\n assert candidate(questions = [[10, 5], [15, 3], [20, 4], [25, 2], [30, 1], [35, 0]]) == 50\n assert candidate(questions = [[10, 0], [20, 1], [30, 2], [40, 3], [50, 4], [60, 5], [70, 6]]) == 110\n assert candidate(questions = [[1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000], [6, 100000]]) == 6\n assert candidate(questions = [[1, 99998], [2, 99997], [3, 99996], [4, 99995], [5, 99994], [6, 99993], [7, 99992], [8, 99991], [9, 99990], [10, 99989]]) == 10\n assert candidate(questions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 10\n assert candidate(questions = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [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(questions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 15\n assert candidate(questions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6]]) == 80\n assert candidate(questions = [[9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 9\n assert candidate(questions = [[5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1]]) == 50\n assert candidate(questions = [[10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1], [10, 0]]) == 10\n assert candidate(questions = [[50, 5], [30, 3], [10, 0], [20, 1], [15, 4], [25, 2]]) == 55\n assert candidate(questions = [[5, 1], [3, 2], [2, 1], [6, 2], [4, 3], [5, 2], [3, 1], [2, 0], [1, 1], [7, 3]]) == 21\n assert candidate(questions = [[10, 0], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9]]) == 40\n assert candidate(questions = [[5, 5], [10, 4], [15, 3], [20, 2], [25, 1], [30, 0]]) == 30\n assert candidate(questions = [[10, 0], [20, 1], [30, 2], [40, 3], [50, 4], [60, 5], [70, 6], [80, 7], [90, 8], [100, 9]]) == 180\n assert candidate(questions = [[5, 0], [4, 1], [3, 2], [2, 3], [1, 4], [0, 5]]) == 11\n assert candidate(questions = [[1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1], [7, 0], [8, 1], [9, 0], [10, 1]]) == 35\n assert candidate(questions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]) == 19\n assert candidate(questions = [[100, 50], [90, 40], [80, 30], [70, 20], [60, 10], [50, 0], [40, 10], [30, 20], [20, 30], [10, 40]]) == 100\n assert candidate(questions = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0]]) == 6\n assert candidate(questions = [[100, 0], [50, 1], [25, 2], [12, 3], [6, 4], [3, 5], [1, 6]]) == 162\n assert candidate(questions = [[100, 99], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8]]) == 100\n assert candidate(questions = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 10\n assert candidate(questions = [[10, 0], [9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]]) == 29\n assert candidate(questions = [[30, 3], [20, 2], [10, 1], [40, 0], [50, 3]]) == 90\n assert candidate(questions = [[100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1]]) == 1000000\n assert candidate(questions = [[100, 10], [90, 9], [80, 8], [70, 7], [60, 6], [50, 5], [40, 4], [30, 3], [20, 2], [10, 1]]) == 100\n assert candidate(questions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7]]) == 110\n assert candidate(questions = [[10, 5], [3, 1], [5, 2], [7, 1], [8, 4], [10, 0]]) == 20\n assert candidate(questions = [[10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10], [100, 11]]) == 150\n assert candidate(questions = [[10000, 9999], [9999, 9998], [9998, 9997], [9997, 9996], [9996, 9995], [9995, 9994], [9994, 9993], [9993, 9992], [9992, 9991], [9991, 9990]]) == 10000\n assert candidate(questions = [[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]]) == 4\n assert candidate(questions = [[20, 3], [15, 2], [10, 5], [5, 1], [1, 1], [2, 2], [3, 3]]) == 24\n assert candidate(questions = [[1, 10], [10, 1], [100, 10], [1000, 100], [10000, 1000], [100000, 10000]]) == 100010\n assert candidate(questions = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1], [60, 0]]) == 60\n"}, "metadata": {"canonical_parameter_names": ["questions"], "leetcode_dataset_entry_point": "Solution().mostPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long mostPoints(int[][] questions) {", "container": "Solution", "callable": "mostPoints", "parameters": [{"name": "questions", "type": "int[][]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2141, "task_id": "maximum-running-time-of-n-computers", "difficulty": "Hard", "problem_description": "You have n computers. You are given the integer n and a 0-indexed integer array batteries where the ith battery can run a computer for batteries[i] minutes. You are interested in running all n computers simultaneously using the given batteries.\nInitially, you can insert at most one battery into each computer. After that and at any integer time moment, you can remove a battery from a computer and insert another battery any number of times. The inserted battery can be a totally new battery or a battery from another computer. You may assume that the removing and inserting processes take no time.\nNote that the batteries cannot be recharged.\nReturn the maximum number of minutes you can run all the n computers simultaneously.\n \nExample 1:\n\n\nInput: n = 2, batteries = [3,3,3]\nOutput: 4\nExplanation: \nInitially, insert battery 0 into the first computer and battery 1 into the second computer.\nAfter two minutes, remove battery 1 from the second computer and insert battery 2 instead. Note that battery 1 can still run for one minute.\nAt the end of the third minute, battery 0 is drained, and you need to remove it from the first computer and insert battery 1 instead.\nBy the end of the fourth minute, battery 1 is also drained, and the first computer is no longer running.\nWe can run the two computers simultaneously for at most 4 minutes, so we return 4.\n\n\nExample 2:\n\n\nInput: n = 2, batteries = [1,1,1,1]\nOutput: 2\nExplanation: \nInitially, insert battery 0 into the first computer and battery 2 into the second computer. \nAfter one minute, battery 0 and battery 2 are drained so you need to remove them and insert battery 1 into the first computer and battery 3 into the second computer. \nAfter another minute, battery 1 and battery 3 are also drained so the first and second computers are no longer running.\nWe can run the two computers simultaneously for at most 2 minutes, so we return 2.\n\n \nConstraints:\n\n1 <= n <= batteries.length <= 105\n1 <= batteries[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,batteries = [1, 2, 3, 4, 5]) == 1\n assert candidate(n = 4,batteries = [10, 10, 3, 5]) == 3\n assert candidate(n = 2,batteries = [1000000000, 1000000000]) == 1000000000\n assert candidate(n = 2,batteries = [9, 4, 10]) == 11\n assert candidate(n = 3,batteries = [10, 20, 30, 40]) == 30\n assert candidate(n = 3,batteries = [5, 8, 5]) == 5\n assert candidate(n = 10,batteries = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n assert candidate(n = 5,batteries = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 18\n assert candidate(n = 4,batteries = [1, 2, 3, 4, 5]) == 3\n assert candidate(n = 2,batteries = [1, 1, 1, 1]) == 2\n assert candidate(n = 2,batteries = [3, 3, 3]) == 4\n assert candidate(n = 1,batteries = [5]) == 5\n assert candidate(n = 1,batteries = [100]) == 100\n assert candidate(n = 1,batteries = [10]) == 10\n assert candidate(n = 5,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(n = 10,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(n = 3,batteries = [10, 10, 3, 5]) == 8\n assert candidate(n = 3,batteries = [1, 2, 3, 4, 5, 6]) == 7\n assert candidate(n = 3,batteries = [10, 10, 10]) == 10\n assert candidate(n = 5,batteries = [1, 1, 1, 1, 1000000000]) == 1\n assert candidate(n = 3,batteries = [2, 6, 4, 5]) == 5\n assert candidate(n = 4,batteries = [5, 5, 5, 5, 5]) == 6\n assert candidate(n = 5,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(n = 3,batteries = [1, 2, 999999999]) == 1\n assert candidate(n = 2,batteries = [10, 20]) == 10\n assert candidate(n = 2,batteries = [2, 3, 4, 5]) == 7\n assert candidate(n = 3,batteries = [5, 5, 5, 5, 5]) == 8\n assert candidate(n = 4,batteries = [8, 8, 8, 8, 8, 8]) == 12\n assert candidate(n = 10,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 110\n assert candidate(n = 5,batteries = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 350\n assert candidate(n = 10,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(n = 4,batteries = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 2500000000\n assert candidate(n = 5,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(n = 15,batteries = [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\n assert candidate(n = 5,batteries = [10, 20, 30, 40, 50, 60]) == 30\n assert candidate(n = 5,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 420\n assert candidate(n = 4,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 13\n assert candidate(n = 10,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 1\n assert candidate(n = 4,batteries = [100, 100, 100, 1]) == 1\n assert candidate(n = 5,batteries = [1000000, 2000000, 3000000, 4000000, 5000000]) == 1000000\n assert candidate(n = 3,batteries = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 70\n assert candidate(n = 3,batteries = [1000000000, 1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 13\n assert candidate(n = 15,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100]) == 3\n assert candidate(n = 2,batteries = [1, 1000000000]) == 1\n assert candidate(n = 5,batteries = [10, 20, 30, 40, 50]) == 10\n assert candidate(n = 10,batteries = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(n = 10,batteries = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 1]) == 50\n assert candidate(n = 3,batteries = [1000000000, 1000000000, 1000000000, 1]) == 1000000000\n assert candidate(n = 6,batteries = [100, 100, 100, 100, 100, 100, 1]) == 100\n assert candidate(n = 7,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1714\n assert candidate(n = 4,batteries = [100, 100, 100, 100, 1, 1, 1, 1]) == 101\n assert candidate(n = 5,batteries = [10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 18\n assert candidate(n = 5,batteries = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 18\n assert candidate(n = 1,batteries = [1000000000]) == 1000000000\n assert candidate(n = 4,batteries = [2, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 16\n assert candidate(n = 2,batteries = [1000000000, 1]) == 1\n assert candidate(n = 4,batteries = [1, 1, 1, 1, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000001\n assert candidate(n = 4,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 52\n assert candidate(n = 8,batteries = [8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(n = 7,batteries = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 46\n assert candidate(n = 7,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(n = 5,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(n = 10,batteries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(n = 5,batteries = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 2000\n assert candidate(n = 10,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 500\n assert candidate(n = 3,batteries = [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]) == 108\n assert candidate(n = 6,batteries = [100, 100, 100, 100, 100, 100, 1, 1, 1, 1]) == 100\n assert candidate(n = 8,batteries = [8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 24\n assert candidate(n = 5,batteries = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999]) == 1999999998\n assert candidate(n = 4,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 13\n assert candidate(n = 5,batteries = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 125\n assert candidate(n = 3,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(n = 15,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 110\n assert candidate(n = 6,batteries = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 30\n assert candidate(n = 8,batteries = [50, 40, 30, 20, 10, 5, 3, 1, 2, 4, 6, 8, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 75\n assert candidate(n = 5,batteries = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 200\n assert candidate(n = 8,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(n = 4,batteries = [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]) == 116\n assert candidate(n = 9,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 23\n assert candidate(n = 3,batteries = [1, 1000000000, 1]) == 1\n assert candidate(n = 3,batteries = [1000, 1000, 1000, 1, 1, 1, 1, 1, 1, 1]) == 1002\n assert candidate(n = 7,batteries = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 85\n assert candidate(n = 2,batteries = [1000000000, 1000000000]) == 1000000000\n assert candidate(n = 5,batteries = [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]) == 250\n assert candidate(n = 3,batteries = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 1333333333\n assert candidate(n = 5,batteries = [1, 1, 1, 1, 1, 1000]) == 1\n assert candidate(n = 7,batteries = [50, 40, 30, 20, 10, 5, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(n = 8,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(n = 5,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(n = 2,batteries = [1000000000, 1000000000, 1000000000, 1000000000]) == 2000000000\n assert candidate(n = 3,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(n = 7,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 70\n assert candidate(n = 4,batteries = [100, 100, 100, 100, 1]) == 100\n assert candidate(n = 6,batteries = [100, 100, 100, 100, 100, 100, 1, 1, 1, 1, 1, 1]) == 101\n assert candidate(n = 10,batteries = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 999999991\n assert candidate(n = 3,batteries = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 30\n assert candidate(n = 10,batteries = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(n = 4,batteries = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 1000000000\n assert candidate(n = 5,batteries = [10, 20, 30, 40, 50, 60]) == 30\n assert candidate(n = 6,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(n = 3,batteries = [10, 20, 30, 40, 50]) == 50\n assert candidate(n = 10,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 100\n assert candidate(n = 7,batteries = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 14\n assert candidate(n = 6,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 90\n assert candidate(n = 7,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(n = 4,batteries = [10, 20, 30, 40, 50]) == 30\n assert candidate(n = 2,batteries = [999999999, 1]) == 1\n assert candidate(n = 6,batteries = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 57\n assert candidate(n = 7,batteries = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 28\n assert candidate(n = 6,batteries = [1000, 2000, 3000, 4000, 5000, 6000]) == 1000\n assert candidate(n = 10,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1100\n assert candidate(n = 3,batteries = [1000000000, 1000000000, 1000000000, 1000000000]) == 1333333333\n assert candidate(n = 5,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(n = 20,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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"}, "metadata": {"canonical_parameter_names": ["n", "batteries"], "leetcode_dataset_entry_point": "Solution().maxRunTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxRunTime(int n, int[] batteries) {", "container": "Solution", "callable": "maxRunTime", "parameters": [{"name": "n", "type": "int"}, {"name": "batteries", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2144, "task_id": "minimum-cost-of-buying-candies-with-discount", "difficulty": "Easy", "problem_description": "A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free.\nThe customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought.\n\nFor example, if there are 4 candies with costs 1, 2, 3, and 4, and the customer buys candies with costs 2 and 3, they can take the candy with cost 1 for free, but not the candy with cost 4.\n\nGiven a 0-indexed integer array cost, where cost[i] denotes the cost of the ith candy, return the minimum cost of buying all the candies.\n \nExample 1:\n\nInput: cost = [1,2,3]\nOutput: 5\nExplanation: We buy the candies with costs 2 and 3, and take the candy with cost 1 for free.\nThe total cost of buying all candies is 2 + 3 = 5. This is the only way we can buy the candies.\nNote that we cannot buy candies with costs 1 and 3, and then take the candy with cost 2 for free.\nThe cost of the free candy has to be less than or equal to the minimum cost of the purchased candies.\n\nExample 2:\n\nInput: cost = [6,5,7,9,2,2]\nOutput: 23\nExplanation: The way in which we can get the minimum cost is described below:\n- Buy candies with costs 9 and 7\n- Take the candy with cost 6 for free\n- We buy candies with costs 5 and 2\n- Take the last remaining candy with cost 2 for free\nHence, the minimum cost to buy all candies is 9 + 7 + 5 + 2 = 23.\n\nExample 3:\n\nInput: cost = [5,5]\nOutput: 10\nExplanation: Since there are only 2 candies, we buy both of them. There is not a third candy we can take for free.\nHence, the minimum cost to buy all candies is 5 + 5 = 10.\n\n \nConstraints:\n\n1 <= cost.length <= 100\n1 <= cost[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cost = [100]) == 100\n assert candidate(cost = [50, 25, 75, 100, 125]) == 300\n assert candidate(cost = [1, 1, 1, 1, 1, 1]) == 4\n assert candidate(cost = [10, 20, 30, 40, 50]) == 120\n assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 663\n assert candidate(cost = [10, 20]) == 30\n assert candidate(cost = [1]) == 1\n assert candidate(cost = [100, 100, 100, 100, 100, 100]) == 400\n assert candidate(cost = [80, 80, 80, 80, 80, 80, 80, 80, 80, 80]) == 560\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(cost = [5, 5]) == 10\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 40\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 40\n assert candidate(cost = [3, 2, 1]) == 5\n assert candidate(cost = [1, 2]) == 3\n assert candidate(cost = [50, 25, 75, 100, 200]) == 375\n assert candidate(cost = [1, 2, 3]) == 5\n assert candidate(cost = [6, 5, 7, 9, 2, 2]) == 23\n assert candidate(cost = [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]) == 1483\n assert candidate(cost = [5, 4, 3, 2, 1, 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]) == 2575\n assert candidate(cost = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 700\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 70\n assert candidate(cost = [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]) == 1700\n assert candidate(cost = [3, 6, 1, 9, 4, 8, 2, 7, 5, 10]) == 40\n assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 663\n assert candidate(cost = [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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 4, 1]) == 241\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 130\n assert candidate(cost = [30, 15, 45, 10, 25, 55, 5, 35, 20, 40, 60, 65, 50, 70, 75, 80, 85, 90, 95, 100, 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]) == 2433\n assert candidate(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, 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, 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]) == 5292\n assert candidate(cost = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6, 93, 7, 92, 8, 91, 9, 90, 10]) == 700\n assert candidate(cost = [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]) == 3333\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(cost = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 350\n assert candidate(cost = [1, 3, 2, 6, 5, 4, 9, 8, 7, 12, 11, 10]) == 56\n assert candidate(cost = [10, 20, 30, 40, 50, 60]) == 160\n assert candidate(cost = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 400\n assert candidate(cost = [3, 6, 1, 8, 2, 7, 4, 5, 9]) == 33\n assert candidate(cost = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 147\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 56\n assert candidate(cost = [100, 1, 100, 2, 100, 3, 100, 4, 100, 5, 100, 6, 100, 7, 100, 8, 100, 9, 100, 10]) == 737\n assert candidate(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, 270, 280, 290, 300]) == 3200\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 40\n assert candidate(cost = [45, 45, 45, 45, 45, 45, 45, 45, 45, 45]) == 315\n assert candidate(cost = [8, 6, 7, 5, 3, 0, 9]) == 28\n assert candidate(cost = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10]) == 4037\n assert candidate(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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 42\n assert candidate(cost = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 707\n assert candidate(cost = [100, 50, 25, 10, 5, 1, 100, 50, 25, 10, 5, 1]) == 301\n assert candidate(cost = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 760\n assert candidate(cost = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == 17\n assert candidate(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]) == 225\n assert candidate(cost = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == 707\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 1253\n assert candidate(cost = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33]) == 528\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 84\n assert candidate(cost = [50, 20, 30, 10, 40, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1470\n assert candidate(cost = [30, 40, 10, 50, 60, 20]) == 160\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 65\n assert candidate(cost = [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]) == 2567\n assert candidate(cost = [50, 40, 30, 20, 10, 5, 4, 3, 2, 1]) == 128\n assert candidate(cost = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == 935\n assert candidate(cost = [1, 3, 2, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13]) == 85\n assert candidate(cost = [1, 3, 2, 4, 6, 5, 7, 9, 8, 11, 13, 12, 15, 17, 16, 19, 21, 20, 23, 25, 24, 27, 29, 28, 31, 33, 32, 35, 37, 36, 39, 41, 40, 43, 45, 44, 47, 49, 48, 50]) == 680\n assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 1253\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 850\n assert candidate(cost = [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]) == 1700\n assert candidate(cost = [45, 30, 10, 20, 50, 60, 15, 25, 35, 40]) == 240\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 77\n assert candidate(cost = [100, 100, 100, 99, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 90, 89, 89, 89, 88, 88, 88, 87, 87, 87, 86, 86, 86, 85, 85, 85]) == 2960\n assert candidate(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, 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]) == 3400\n assert candidate(cost = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11]) == 85\n assert candidate(cost = [30, 10, 20, 40, 50, 60]) == 160\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 147\n assert candidate(cost = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 400\n assert candidate(cost = [30, 10, 40, 20, 50, 60, 70]) == 210\n assert candidate(cost = [45, 30, 75, 60, 90, 15, 10, 5]) == 255\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 400\n assert candidate(cost = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 500\n assert candidate(cost = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 1400\n assert candidate(cost = [50, 25, 75, 100, 200, 150, 80, 120, 90, 60, 30, 180, 140, 110, 40]) == 1035\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 85\n assert candidate(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]) == 320\n assert candidate(cost = [5, 4, 3, 2, 1, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == 947\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1470\n assert candidate(cost = [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, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 3500\n assert candidate(cost = [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]) == 867\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 40\n assert candidate(cost = [23, 45, 12, 89, 34, 78, 67, 56, 90, 11]) == 370\n assert candidate(cost = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 70\n assert candidate(cost = [8, 12, 15, 7, 10, 14, 9]) == 55\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 560\n assert candidate(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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 43\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(cost = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 735\n assert candidate(cost = [42, 23, 65, 12, 89, 34, 78, 56, 90, 21, 33, 55, 77, 66, 88, 44, 55, 66, 77, 88]) == 808\n"}, "metadata": {"canonical_parameter_names": ["cost"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumCost(int[] cost) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "cost", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2145, "task_id": "count-the-hidden-sequences", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of n integers differences, which describes the differences between each pair of consecutive integers of a hidden sequence of length (n + 1). More formally, call the hidden sequence hidden, then we have that differences[i] = hidden[i + 1] - hidden[i].\nYou are further given two integers lower and upper that describe the inclusive range of values [lower, upper] that the hidden sequence can contain.\n\nFor example, given differences = [1, -3, 4], lower = 1, upper = 6, the hidden sequence is a sequence of length 4 whose elements are in between 1 and 6 (inclusive).\n\n\t\n[3, 4, 1, 5] and [4, 5, 2, 6] are possible hidden sequences.\n[5, 6, 3, 7] is not possible since it contains an element greater than 6.\n[1, 2, 3, 4] is not possible since the differences are not correct.\n\n\n\nReturn the number of possible hidden sequences there are. If there are no possible sequences, return 0.\n \nExample 1:\n\nInput: differences = [1,-3,4], lower = 1, upper = 6\nOutput: 2\nExplanation: The possible hidden sequences are:\n- [3, 4, 1, 5]\n- [4, 5, 2, 6]\nThus, we return 2.\n\nExample 2:\n\nInput: differences = [3,-4,5,1,-2], lower = -4, upper = 5\nOutput: 4\nExplanation: The possible hidden sequences are:\n- [-3, 0, -4, 1, 2, 0]\n- [-2, 1, -3, 2, 3, 1]\n- [-1, 2, -2, 3, 4, 2]\n- [0, 3, -1, 4, 5, 3]\nThus, we return 4.\n\nExample 3:\n\nInput: differences = [4,-7,2], lower = 3, upper = 6\nOutput: 0\nExplanation: There are no possible hidden sequences. Thus, we return 0.\n\n \nConstraints:\n\nn == differences.length\n1 <= n <= 105\n-105 <= differences[i] <= 105\n-105 <= lower <= upper <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(differences = [0, 0, 0],lower = 1,upper = 1) == 1\n assert candidate(differences = [5, -5, 5, -5],lower = -10,upper = 10) == 16\n assert candidate(differences = [3, -4, 5, 1, -2],lower = -4,upper = 5) == 4\n assert candidate(differences = [1, -3, 4],lower = 1,upper = 6) == 2\n assert candidate(differences = [-1, -1, -1],lower = -3,upper = 3) == 4\n assert candidate(differences = [-1],lower = -2,upper = -1) == 1\n assert candidate(differences = [-1, -2, -3, -4, -5],lower = -100,upper = 1) == 87\n assert candidate(differences = [100000, -100000, 100000, -100000],lower = -100000,upper = 100000) == 100001\n assert candidate(differences = [10, -5, 15, -10],lower = -10,upper = 10) == 1\n assert candidate(differences = [0, 0, 0],lower = 1,upper = 5) == 5\n assert candidate(differences = [1, 1, 1],lower = -5,upper = -1) == 2\n assert candidate(differences = [100000, -100000],lower = -100000,upper = 100000) == 100001\n assert candidate(differences = [1, 2, 3],lower = 0,upper = 10) == 5\n assert candidate(differences = [-1, -2, -3],lower = -10,upper = 0) == 5\n assert candidate(differences = [10, -10, 10, -10],lower = -5,upper = 5) == 1\n assert candidate(differences = [100000, -100000, 100000],lower = -100000,upper = 100000) == 100001\n assert candidate(differences = [0, 0, 0],lower = 0,upper = 0) == 1\n assert candidate(differences = [1],lower = 1,upper = 2) == 1\n assert candidate(differences = [-1, -2, -3],lower = -5,upper = 5) == 5\n assert candidate(differences = [-1, -1, -1],lower = 1,upper = 5) == 2\n assert candidate(differences = [1, 2, 3, 4, 5],lower = 1,upper = 100) == 85\n assert candidate(differences = [0, 0, 0],lower = 0,upper = 10) == 11\n assert candidate(differences = [4, -7, 2],lower = 3,upper = 6) == 0\n assert candidate(differences = [2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],lower = -15,upper = 15) == 21\n assert candidate(differences = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],lower = -10,upper = 10) == 11\n assert candidate(differences = [2, 3, 4, 5, 6, 7, 8, 9, 10],lower = 0,upper = 100) == 47\n assert candidate(differences = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10],lower = 0,upper = 500) == 0\n assert candidate(differences = [5, 10, 15, 20, 25, 30],lower = 0,upper = 100) == 0\n assert candidate(differences = [1000, -500, 200, -100, 50, -25, 10],lower = -1000,upper = 1000) == 1001\n assert candidate(differences = [100000, 0, -100000, 0, 100000, 0, -100000],lower = -200000,upper = 200000) == 300001\n assert candidate(differences = [-5, -10, -15, -20, -25, -30],lower = -100,upper = 0) == 0\n assert candidate(differences = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],lower = 0,upper = 2) == 2\n assert candidate(differences = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],lower = 10,upper = 60) == 1\n assert candidate(differences = [5, -2, 8, -3, 7],lower = -5,upper = 20) == 11\n assert candidate(differences = [10000, -20000, 30000, -40000, 50000],lower = -100000,upper = 100000) == 150001\n assert candidate(differences = [-1, 2, -1, 2, -1],lower = -10,upper = 10) == 18\n assert candidate(differences = [-1, 0, 1, 0, -1],lower = -5,upper = 5) == 10\n assert candidate(differences = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],lower = -20,upper = -10) == 0\n assert candidate(differences = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],lower = 1,upper = 50) == 20\n assert candidate(differences = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],lower = 0,upper = 1) == 1\n assert candidate(differences = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],lower = 0,upper = 10) == 1\n assert candidate(differences = [50000, -50000, 50000, -50000, 50000, -50000, 50000, -50000],lower = -100000,upper = 100000) == 150001\n assert candidate(differences = [100000, 100000, 100000, -300000, 100000, 100000, 100000],lower = -100000,upper = 100000) == 0\n assert candidate(differences = [-1, 1, -1, 1, -1],lower = 0,upper = 5) == 5\n assert candidate(differences = [10000, -10000, 20000, -20000],lower = -50000,upper = 50000) == 80001\n assert candidate(differences = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],lower = -10,upper = 10) == 11\n assert candidate(differences = [-5, 10, -15, 20, -25],lower = -30,upper = 30) == 36\n assert candidate(differences = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],lower = 5,upper = 5) == 1\n assert candidate(differences = [0, 0, 0, 0, 0],lower = -1,upper = 1) == 3\n assert candidate(differences = [-1, 2, -3, 4, -5, 6, -7, 8],lower = -10,upper = 10) == 13\n assert candidate(differences = [-1, 2, -3, 4, -5, 6, -7],lower = -20,upper = 20) == 34\n assert candidate(differences = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],lower = 0,upper = 100) == 0\n assert candidate(differences = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],lower = 1,upper = 1000) == 450\n assert candidate(differences = [5, -2, 3, 7, -4],lower = 1,upper = 20) == 7\n assert candidate(differences = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],lower = -100,upper = 0) == 0\n assert candidate(differences = [5, -5, 5, -5, 5, -5],lower = -10,upper = 10) == 16\n assert candidate(differences = [0, 0, 0, 0, 0],lower = 1,upper = 1) == 1\n assert candidate(differences = [-1, 2, -2, 1, -1],lower = -5,upper = 5) == 9\n assert candidate(differences = [10, 20, 30, 40, 50],lower = 0,upper = 200) == 51\n assert candidate(differences = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],lower = 1,upper = 10) == 0\n assert candidate(differences = [50, -25, 75, -37, 100, -50, 125, -62, 150, -75, 175, -87, 200, -93, 225, -100, 250, -112, 275, -125],lower = 0,upper = 300) == 0\n assert candidate(differences = [100000, -100000, 100000, -100000, 100000],lower = -50000,upper = 50000) == 1\n assert candidate(differences = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],lower = -100,upper = 100) == 151\n assert candidate(differences = [1, -1, 1, -1, 1],lower = 1,upper = 5) == 4\n assert candidate(differences = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],lower = -55,upper = -45) == 0\n assert candidate(differences = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],lower = -10,upper = 0) == 0\n assert candidate(differences = [1, 2, -3, 4, -5, 6],lower = 1,upper = 10) == 4\n assert candidate(differences = [100, -50, 200, -100, 50, -200, 100],lower = -1000,upper = 1000) == 1751\n assert candidate(differences = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1],lower = -1,upper = 1) == 2\n assert candidate(differences = [-1, -2, -3, -4, -5, -6],lower = -15,upper = -5) == 0\n assert candidate(differences = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],lower = -1000,upper = 1) == 452\n assert candidate(differences = [-15, 14, -13, 12, -11, 10, -9, 8, -7, 6, -5, 4, -3, 2, -1],lower = -20,upper = 20) == 26\n assert candidate(differences = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],lower = -10,upper = 10) == 16\n assert candidate(differences = [5, 10, -15, 20, -25],lower = -100,upper = 100) == 176\n assert candidate(differences = [100000, -50000, 50000, -100000, 50000],lower = -100000,upper = 100000) == 100001\n assert candidate(differences = [100, -50, 25, -10, 5],lower = 0,upper = 200) == 101\n assert candidate(differences = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5],lower = -50,upper = 0) == 1\n assert candidate(differences = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],lower = 10,upper = 20) == 0\n assert candidate(differences = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],lower = 100,upper = 1000) == 351\n assert candidate(differences = [5, -2, 3, -4, 1],lower = 1,upper = 10) == 4\n assert candidate(differences = [2, -1, 3, -2, 4, -3, 5, -4],lower = -5,upper = 10) == 8\n assert candidate(differences = [0, 0, 0, 0, 0],lower = 0,upper = 10) == 11\n assert candidate(differences = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],lower = -10,upper = -1) == 0\n assert candidate(differences = [5, -2, 3, -1, 4],lower = -5,upper = 5) == 2\n assert candidate(differences = [100000, -50000, 25000, -12500, 6250, -3125, 1562, -781, 390, -195],lower = 0,upper = 100000) == 1\n assert candidate(differences = [-10, 20, -30, 40, -50, 60],lower = -20,upper = 20) == 0\n assert candidate(differences = [-10, -20, -30, -40, -50],lower = -200,upper = 0) == 51\n assert candidate(differences = [5, 10, -5, -10, 15, -15, 20, -20],lower = -100,upper = 100) == 181\n assert candidate(differences = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],lower = -10,upper = 0) == 1\n assert candidate(differences = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],lower = 0,upper = 50) == 1\n assert candidate(differences = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],lower = -50,upper = 50) == 91\n assert candidate(differences = [20, -10, 30, -15, 5, -1],lower = -100,upper = 100) == 161\n assert candidate(differences = [2, 3, -2, 1, -3, 2],lower = -5,upper = 15) == 16\n assert candidate(differences = [2, 3, -5, 2, 3, -5],lower = -3,upper = 3) == 2\n assert candidate(differences = [100, -50, 25, -10, 5],lower = -20,upper = 200) == 121\n assert candidate(differences = [100000, 0, -100000, 0, 100000],lower = 50000,upper = 150000) == 1\n assert candidate(differences = [-100000, 50000, -50000, 100000, -50000],lower = -100000,upper = 100000) == 100001\n assert candidate(differences = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],lower = -1,upper = 1) == 3\n assert candidate(differences = [1, -1, 1, -1, 1, -1],lower = 1,upper = 5) == 4\n assert candidate(differences = [1, 2, 3, -1, -2, -3, 1, 2, 3, -1, -2, -3],lower = -5,upper = 5) == 5\n assert candidate(differences = [10, -10, 10, -10, 10, -10, 10, -10],lower = 0,upper = 20) == 11\n assert candidate(differences = [10, -20, 30, -40, 50],lower = 5,upper = 15) == 0\n assert candidate(differences = [2, 4, -6, 8, -10, 12, -14],lower = -15,upper = 15) == 17\n assert candidate(differences = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],lower = 0,upper = 10) == 0\n assert candidate(differences = [10, 20, 30, 40, 50],lower = 100,upper = 200) == 0\n assert candidate(differences = [5, -5, 10, -10, 15, -15],lower = -50,upper = 50) == 86\n assert candidate(differences = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],lower = -50,upper = 0) == 0\n assert candidate(differences = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],lower = -1,upper = 1) == 2\n assert candidate(differences = [5, -2, 8, -6, 3],lower = 2,upper = 12) == 0\n assert candidate(differences = [100, -50, 25, -12, 6, -3, 1],lower = 0,upper = 500) == 401\n assert candidate(differences = [1, 2, 3, 4, 5, 6],lower = 5,upper = 15) == 0\n assert candidate(differences = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],lower = 0,upper = 50) == 0\n assert candidate(differences = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],lower = -10,upper = 10) == 16\n assert candidate(differences = [0, 0, 0, 0, 0],lower = 0,upper = 0) == 1\n assert candidate(differences = [5, -2, 3, -4, 7, -1],lower = -5,upper = 15) == 12\n assert candidate(differences = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],lower = 0,upper = 0) == 1\n assert candidate(differences = [-3, -3, -3, -3, -3, -3, -3, -3, -3, -3],lower = -50,upper = -1) == 20\n assert candidate(differences = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16],lower = -100,upper = 100) == 185\n assert candidate(differences = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],lower = -50,upper = 50) == 86\n assert candidate(differences = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],lower = -1000,upper = -100) == 351\n assert candidate(differences = [5, -2, 3, 7, -5, 8, -6],lower = -10,upper = 20) == 15\n assert candidate(differences = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],lower = -5,upper = 5) == 1\n assert candidate(differences = [-1, -2, -3, -4, -5],lower = -15,upper = -5) == 0\n"}, "metadata": {"canonical_parameter_names": ["differences", "lower", "upper"], "leetcode_dataset_entry_point": "Solution().numberOfArrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfArrays(int[] differences, int lower, int upper) {", "container": "Solution", "callable": "numberOfArrays", "parameters": [{"name": "differences", "type": "int[]"}, {"name": "lower", "type": "int"}, {"name": "upper", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2146, "task_id": "k-highest-ranked-items-within-a-price-range", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop. The integers in the grid represent the following:\n\n0 represents a wall that you cannot pass through.\n1 represents an empty cell that you can freely move to and from.\nAll other positive integers represent the price of an item in that cell. You may also freely move to and from these item cells.\n\nIt takes 1 step to travel between adjacent grid cells.\nYou are also given integer arrays pricing and start where pricing = [low, high] and start = [row, col] indicates that you start at the position (row, col) and are interested only in items with a price in the range of [low, high] (inclusive). You are further given an integer k.\nYou are interested in the positions of the k highest-ranked items whose prices are within the given price range. The rank is determined by the first of these criteria that is different:\n\nDistance, defined as the length of the shortest path from the start (shorter distance has a higher rank).\nPrice (lower price has a higher rank, but it must be in the price range).\nThe row number (smaller row number has a higher rank).\nThe column number (smaller column number has a higher rank).\n\nReturn the k highest-ranked items within the price range sorted by their rank (highest to lowest). If there are fewer than k reachable items within the price range, return all of them.\n \nExample 1:\n\n\nInput: grid = [[1,2,0,1],[1,3,0,1],[0,2,5,1]], pricing = [2,5], start = [0,0], k = 3\nOutput: [[0,1],[1,1],[2,1]]\nExplanation: You start at (0,0).\nWith a price range of [2,5], we can take items from (0,1), (1,1), (2,1) and (2,2).\nThe ranks of these items are:\n- (0,1) with distance 1\n- (1,1) with distance 2\n- (2,1) with distance 3\n- (2,2) with distance 4\nThus, the 3 highest ranked items in the price range are (0,1), (1,1), and (2,1).\n\nExample 2:\n\n\nInput: grid = [[1,2,0,1],[1,3,3,1],[0,2,5,1]], pricing = [2,3], start = [2,3], k = 2\nOutput: [[2,1],[1,2]]\nExplanation: You start at (2,3).\nWith a price range of [2,3], we can take items from (0,1), (1,1), (1,2) and (2,1).\nThe ranks of these items are:\n- (2,1) with distance 2, price 2\n- (1,2) with distance 2, price 3\n- (1,1) with distance 3\n- (0,1) with distance 4\nThus, the 2 highest ranked items in the price range are (2,1) and (1,2).\n\nExample 3:\n\n\nInput: grid = [[1,1,1],[0,0,1],[2,3,4]], pricing = [2,3], start = [0,0], k = 3\nOutput: [[2,1],[2,0]]\nExplanation: You start at (0,0).\nWith a price range of [2,3], we can take items from (2,0) and (2,1). \nThe ranks of these items are: \n- (2,1) with distance 5\n- (2,0) with distance 6\nThus, the 2 highest ranked items in the price range are (2,1) and (2,0). \nNote that k = 3 but there are only 2 reachable items within the price range.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 105\n1 <= m * n <= 105\n0 <= grid[i][j] <= 105\npricing.length == 2\n2 <= low <= high <= 105\nstart.length == 2\n0 <= row <= m - 1\n0 <= col <= n - 1\ngrid[row][col] > 0\n1 <= k <= m * n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [0, 0, 1], [2, 3, 4]],pricing = [2, 3],start = [0, 0],k = 3) == [[2, 1], [2, 0]]\n assert candidate(grid = [[1, 2, 0, 1], [1, 3, 3, 1], [0, 2, 5, 1]],pricing = [2, 3],start = [2, 3],k = 2) == [[2, 1], [1, 2]]\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],pricing = [15, 85],start = [1, 1],k = 5) == [[1, 1], [0, 1], [1, 0], [1, 2], [2, 1]]\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1], [1, 1, 1, 1]],pricing = [1, 1],start = [0, 0],k = 10) == [[0, 0], [0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [2, 1], [3, 0], [1, 3], [2, 2]]\n assert candidate(grid = [[1, 2, 0, 1], [1, 3, 0, 1], [0, 2, 5, 1]],pricing = [2, 5],start = [0, 0],k = 3) == [[0, 1], [1, 1], [2, 1]]\n assert candidate(grid = [[1, 3, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1], [1, 0, 1, 1, 1]],pricing = [2, 3],start = [0, 0],k = 1) == [[0, 1]]\n assert candidate(grid = [[100, 200, 0, 300], [400, 500, 600, 700], [0, 0, 800, 0], [900, 1000, 1100, 1200]],pricing = [300, 900],start = [1, 1],k = 8) == [[1, 1], [1, 0], [1, 2], [1, 3], [2, 2], [0, 3], [3, 0]]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],pricing = [1, 9],start = [0, 0],k = 9) == [[0, 0], [0, 1], [1, 0], [0, 2], [1, 1], [2, 0], [1, 2], [2, 1], [2, 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]],pricing = [1, 1],start = [2, 2],k = 15) == [[2, 2], [1, 2], [2, 1], [2, 3], [3, 2], [0, 2], [1, 1], [1, 3], [2, 0], [2, 4], [3, 1], [3, 3], [4, 2], [0, 1], [0, 3]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [5, 4, 3, 2, 1], [0, 0, 0, 0, 0], [1, 2, 3, 4, 5]],pricing = [2, 4],start = [1, 1],k = 7) == [[0, 1], [2, 1], [0, 2], [2, 2], [2, 3], [0, 3]]\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 10, 20, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 30, 40, 1, 0], [0, 0, 1, 1, 0, 0]],pricing = [5, 30],start = [1, 1],k = 5) == [[1, 2], [1, 3], [3, 2]]\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]],pricing = [5, 25],start = [1, 1],k = 15) == [[1, 1], [1, 0], [1, 2], [2, 1], [1, 3], [2, 0], [2, 2], [1, 4], [2, 3], [0, 4], [1, 5], [2, 4], [0, 5], [1, 6], [0, 6]]\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]],pricing = [5, 25],start = [0, 5],k = 15) == [[0, 5], [0, 4], [1, 5], [1, 4], [2, 5], [1, 3], [2, 4], [3, 5], [1, 2], [2, 3], [3, 4], [1, 1], [2, 2], [3, 3], [1, 0]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [4, 6],start = [5, 5],k = 20) == [[5, 5], [5, 6], [4, 5], [5, 4], [4, 4], [7, 5], [4, 3], [2, 5], [7, 4], [8, 5], [2, 6], [7, 3], [8, 6], [1, 5], [2, 4], [8, 4], [1, 4], [1, 3]]\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, 0, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [3, 3],k = 10) == [[2, 3], [3, 2], [2, 2]]\n assert candidate(grid = [[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]],pricing = [2, 8],start = [1, 1],k = 15) == [[1, 1], [0, 1], [2, 1], [1, 2], [0, 2], [2, 2], [1, 3], [0, 3], [2, 3], [1, 4], [0, 4], [2, 4], [1, 5], [0, 5], [2, 5]]\n assert candidate(grid = [[5, 0, 5, 0, 5], [0, 5, 0, 5, 0], [5, 0, 5, 0, 5], [0, 5, 0, 5, 0], [5, 0, 5, 0, 5]],pricing = [4, 6],start = [0, 0],k = 10) == [[0, 0]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [5, 4, 3, 2, 1]],pricing = [2, 4],start = [1, 1],k = 12) == [[0, 1], [2, 1], [3, 1], [0, 2], [2, 2], [2, 3], [3, 2], [0, 3], [3, 3]]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],pricing = [5, 15],start = [0, 2],k = 10) == [[1, 2], [1, 1], [2, 2], [2, 1], [3, 2], [2, 0], [3, 1], [4, 2], [3, 0], [4, 1]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 1], [1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [2, 2],k = 7) == [[1, 2], [2, 1], [2, 3], [3, 2], [0, 2], [2, 0], [4, 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]],pricing = [1, 1],start = [2, 2],k = 5) == [[2, 2]]\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]],pricing = [1, 1],start = [0, 0],k = 1) == [[0, 0]]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1], [1, 0, 1, 1, 1]],pricing = [2, 3],start = [0, 0],k = 5) == []\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [3, 3],k = 20) == []\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]],pricing = [10, 20],start = [0, 0],k = 10) == [[2, 0], [2, 1], [3, 0], [2, 2], [3, 1], [1, 4], [2, 3], [3, 2], [2, 4], [3, 3]]\n assert candidate(grid = [[1, 2, 0, 0, 5], [0, 3, 4, 0, 6], [7, 0, 8, 9, 0], [0, 10, 11, 0, 12], [13, 0, 14, 15, 0]],pricing = [1, 15],start = [0, 4],k = 15) == [[0, 4], [1, 4]]\n assert candidate(grid = [[0, 0, 0, 0], [0, 10, 20, 0], [0, 30, 40, 0], [0, 0, 0, 0]],pricing = [10, 40],start = [1, 1],k = 2) == [[1, 1], [1, 2]]\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]],pricing = [1, 1],start = [2, 2],k = 4) == [[1, 2], [2, 1], [2, 3], [3, 2]]\n assert candidate(grid = [[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]],pricing = [200, 400],start = [2, 5],k = 12) == [[2, 5], [2, 4], [2, 6], [3, 5], [2, 3], [2, 7], [3, 4], [3, 6], [2, 2], [2, 8], [3, 3], [3, 7]]\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1]],pricing = [1, 1],start = [2, 2],k = 5) == []\n assert candidate(grid = [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200]],pricing = [250, 1050],start = [1, 1],k = 8) == [[1, 1], [1, 0], [1, 2], [2, 1], [0, 2], [2, 0], [2, 2], [3, 0]]\n assert candidate(grid = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]],pricing = [15, 95],start = [0, 9],k = 8) == [[0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]]\n assert candidate(grid = [[1, 2, 3, 0, 5], [0, 6, 0, 7, 8], [9, 10, 11, 12, 0], [13, 14, 0, 15, 16]],pricing = [5, 15],start = [0, 0],k = 5) == [[1, 1], [2, 1], [2, 0], [2, 2], [3, 1]]\n assert candidate(grid = [[5, 15, 25, 35, 45], [10, 20, 30, 40, 50], [55, 65, 75, 85, 95]],pricing = [10, 90],start = [1, 2],k = 15) == [[1, 2], [1, 1], [0, 2], [1, 3], [2, 2], [1, 0], [0, 1], [0, 3], [1, 4], [2, 1], [2, 3], [0, 4], [2, 0]]\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 2, 3, 0], [0, 4, 5, 6, 0], [0, 7, 8, 9, 0], [0, 0, 0, 0, 0]],pricing = [1, 9],start = [2, 2],k = 8) == [[2, 2], [1, 2], [2, 1], [2, 3], [3, 2], [1, 1], [1, 3], [3, 1]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],pricing = [1, 10],start = [0, 0],k = 10) == [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 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]],pricing = [5, 35],start = [1, 2],k = 12) == [[1, 2], [1, 1], [1, 3], [2, 2], [1, 0], [1, 4], [2, 1], [2, 3], [3, 2], [0, 4], [1, 5], [2, 0]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],pricing = [5, 15],start = [0, 0],k = 10) == [[1, 0], [1, 1], [1, 2], [0, 4], [1, 3], [0, 5], [1, 4], [0, 6], [0, 7], [0, 8]]\n assert candidate(grid = [[10, 0, 30, 40, 50], [10, 0, 30, 40, 50], [10, 20, 0, 40, 50], [10, 20, 30, 0, 50], [10, 20, 30, 40, 0]],pricing = [20, 40],start = [0, 0],k = 5) == [[2, 1], [3, 1], [4, 1], [3, 2], [4, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 0, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],pricing = [5, 15],start = [2, 2],k = 10) == [[1, 2], [2, 1], [2, 3], [1, 1], [1, 3], [2, 0], [2, 4], [1, 0], [1, 4], [0, 4]]\n assert candidate(grid = [[100, 200, 300, 400, 500], [600, 700, 0, 800, 900], [1000, 1100, 1200, 1300, 0], [0, 1400, 1500, 1600, 1700]],pricing = [300, 1500],start = [1, 1],k = 10) == [[1, 1], [1, 0], [2, 1], [0, 2], [2, 0], [2, 2], [3, 1], [0, 3], [2, 3], [3, 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]],pricing = [1, 1],start = [0, 0],k = 8) == [[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, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],pricing = [1, 1],start = [2, 2],k = 15) == [[2, 2]]\n assert candidate(grid = [[5, 0, 5, 0, 5, 0, 5, 0, 5], [0, 5, 0, 5, 0, 5, 0, 5, 0], [5, 0, 5, 0, 5, 0, 5, 0, 5], [0, 5, 0, 5, 0, 5, 0, 5, 0], [5, 0, 5, 0, 5, 0, 5, 0, 5]],pricing = [5, 5],start = [4, 4],k = 15) == [[4, 4]]\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]],pricing = [1, 1],start = [2, 2],k = 8) == [[1, 2], [2, 1], [1, 1], [1, 3], [3, 1], [1, 4], [4, 1], [2, 4]]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 1, 1, 1, 1, 1, 1, 1, 1, 5], [5, 1, 5, 5, 5, 5, 5, 5, 1, 5], [5, 1, 5, 1, 1, 1, 1, 5, 1, 5], [5, 1, 5, 1, 5, 5, 1, 5, 1, 5], [5, 1, 5, 1, 5, 0, 1, 5, 1, 5], [5, 1, 5, 1, 1, 1, 1, 5, 1, 5], [5, 1, 5, 5, 5, 5, 5, 5, 1, 5], [5, 1, 1, 1, 1, 1, 1, 1, 1, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]],pricing = [1, 5],start = [5, 5],k = 20) == [[5, 6], [6, 5], [4, 5], [5, 4], [3, 5], [4, 6], [5, 3], [6, 4], [6, 6], [4, 4], [5, 7], [7, 5], [3, 4], [3, 6], [4, 3], [5, 8], [6, 3], [8, 5], [2, 5], [4, 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], [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], [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], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],pricing = [1, 10],start = [0, 0],k = 15) == [[0, 0], [0, 1], [1, 0], [2, 0], [0, 2], [1, 1], [2, 1], [0, 3], [1, 2], [3, 0], [4, 0], [2, 2], [0, 4], [1, 3], [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, 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]],pricing = [5, 9],start = [2, 4],k = 20) == [[2, 4], [1, 4], [2, 5], [3, 4], [0, 4], [1, 5], [3, 5], [4, 4], [1, 3], [2, 6], [3, 3], [0, 5], [4, 5], [1, 2], [2, 7], [3, 2], [0, 6], [4, 6], [1, 1], [2, 8]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [4, 4],k = 20) == [[4, 4]]\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]],pricing = [5, 25],start = [0, 0],k = 15) == [[1, 0], [1, 1], [2, 0], [1, 2], [2, 1], [0, 4], [1, 3], [2, 2], [0, 5], [1, 4], [2, 3], [0, 6], [1, 5], [2, 4], [0, 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], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],pricing = [3, 8],start = [0, 0],k = 15) == [[0, 2], [0, 3], [1, 2], [2, 2], [0, 4], [1, 3], [2, 3], [0, 5], [1, 4], [1, 5], [2, 4], [0, 6], [1, 6], [2, 5], [0, 7]]\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 2, 2, 2, 10], [10, 2, 3, 2, 10], [10, 2, 2, 2, 10], [10, 10, 10, 10, 10]],pricing = [2, 3],start = [2, 2],k = 8) == [[2, 2], [1, 2], [2, 1], [2, 3], [3, 2], [1, 1], [1, 3], [3, 1]]\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]],pricing = [1, 1],start = [0, 0],k = 15) == [[0, 0]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [3, 3],k = 5) == [[2, 3], [3, 2], [3, 4], [4, 3], [2, 2]]\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], [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]],pricing = [3, 7],start = [2, 4],k = 15) == [[2, 4], [2, 3], [1, 4], [3, 4], [2, 5], [2, 2], [1, 5], [3, 5], [0, 4], [4, 4], [1, 3], [3, 3], [2, 6], [1, 6], [3, 6]]\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]],pricing = [3, 8],start = [4, 4],k = 10) == [[3, 4], [4, 3], [2, 4], [3, 3], [4, 2], [1, 4], [2, 3], [3, 2], [4, 1], [0, 4]]\n assert candidate(grid = [[100, 200, 300, 400, 500], [100, 200, 300, 400, 500], [100, 200, 300, 400, 500], [100, 200, 300, 400, 500], [100, 200, 300, 400, 500]],pricing = [150, 450],start = [2, 2],k = 15) == [[2, 2], [2, 1], [1, 2], [3, 2], [2, 3], [1, 1], [3, 1], [0, 2], [4, 2], [1, 3], [3, 3], [0, 1], [4, 1], [0, 3], [4, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [0, 0],k = 20) == [[0, 0], [0, 1], [1, 0], [0, 2], [1, 1], [2, 0], [0, 3], [1, 2], [2, 1], [3, 0], [0, 4], [1, 3], [2, 2], [3, 1], [4, 0], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [2, 8],start = [4, 4],k = 20) == []\n assert candidate(grid = [[5, 10, 15, 20, 25, 30], [35, 40, 45, 50, 55, 60], [65, 70, 75, 80, 85, 90]],pricing = [20, 70],start = [1, 2],k = 12) == [[1, 2], [1, 1], [1, 3], [0, 3], [1, 0], [1, 4], [2, 1], [0, 4], [1, 5], [2, 0], [0, 5]]\n assert candidate(grid = [[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], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]],pricing = [15, 45],start = [2, 2],k = 10) == [[2, 2], [1, 2], [3, 2], [2, 3], [0, 2], [4, 2], [1, 3], [3, 3], [2, 4], [0, 3]]\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]],pricing = [1, 100],start = [2, 2],k = 1) == []\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]],pricing = [1, 1],start = [1, 1],k = 3) == [[0, 1], [1, 0], [0, 0]]\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]],pricing = [1, 1],start = [2, 2],k = 8) == []\n assert candidate(grid = [[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]],pricing = [500, 2000],start = [2, 2],k = 10) == [[2, 2], [1, 2], [2, 1], [2, 3], [3, 2], [1, 1], [1, 3], [2, 0], [2, 4], [3, 1]]\n assert candidate(grid = [[5, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],pricing = [1, 5],start = [2, 2],k = 10) == [[3, 2], [3, 1], [3, 3], [4, 2], [3, 0], [3, 4], [4, 1], [4, 3], [2, 0], [2, 4]]\n assert candidate(grid = [[5, 2, 3, 4, 1], [0, 0, 0, 0, 0], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]],pricing = [1, 20],start = [0, 0],k = 15) == [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]\n assert candidate(grid = [[1, 2, 3, 0, 0], [4, 5, 6, 0, 0], [7, 8, 9, 0, 0], [10, 11, 12, 0, 0], [13, 14, 15, 0, 0]],pricing = [5, 10],start = [0, 0],k = 10) == [[1, 1], [2, 0], [1, 2], [2, 1], [3, 0], [2, 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]],pricing = [1, 1],start = [2, 2],k = 5) == [[2, 2]]\n assert candidate(grid = [[10, 15, 20, 0, 25], [5, 0, 30, 0, 35], [40, 45, 50, 55, 60]],pricing = [10, 50],start = [0, 0],k = 7) == [[0, 0], [0, 1], [0, 2], [2, 0], [1, 2], [2, 1], [2, 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, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]],pricing = [1, 1],start = [0, 0],k = 10) == [[0, 0]]\n assert candidate(grid = [[100000, 0, 100000, 0, 100000], [0, 100000, 0, 100000, 0], [100000, 0, 100000, 0, 100000], [0, 100000, 0, 100000, 0], [100000, 0, 100000, 0, 100000]],pricing = [50000, 150000],start = [1, 1],k = 12) == [[1, 1]]\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]],pricing = [3, 7],start = [0, 0],k = 8) == [[1, 0], [0, 2], [1, 1], [1, 2], [2, 1], [0, 3], [0, 4], [2, 2]]\n assert candidate(grid = [[1, 2, 3, 0, 4, 5, 6], [7, 8, 9, 0, 10, 11, 12], [0, 0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18, 19]],pricing = [1, 18],start = [2, 2],k = 5) == [[2, 2], [2, 3], [3, 2], [1, 2], [0, 2]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [4, 5],k = 10) == [[4, 5], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 4], [9, 3], [9, 5], [9, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],pricing = [1, 10],start = [4, 0],k = 10) == [[4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9]]\n assert candidate(grid = [[10, 10, 10, 10], [10, 0, 0, 10], [10, 10, 10, 10], [10, 10, 10, 10]],pricing = [5, 15],start = [1, 1],k = 1) == [[0, 1]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 2, 3, 4, 5, 6, 7, 0, 1], [1, 0, 8, 9, 10, 11, 12, 13, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [2, 12],start = [2, 2],k = 7) == [[2, 2], [2, 3], [3, 2], [2, 4], [3, 3], [2, 5], [3, 4]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 0, 0, 0, 1], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5]],pricing = [2, 4],start = [2, 2],k = 5) == [[1, 2], [3, 2], [1, 3], [3, 3], [0, 2]]\n"}, "metadata": {"canonical_parameter_names": ["grid", "pricing", "start", "k"], "leetcode_dataset_entry_point": "Solution().highestRankedKItems", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List> highestRankedKItems(int[][] grid, int[] pricing, int[] start, int k) {", "container": "Solution", "callable": "highestRankedKItems", "parameters": [{"name": "grid", "type": "int[][]"}, {"name": "pricing", "type": "int[]"}, {"name": "start", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "List>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2147, "task_id": "number-of-ways-to-divide-a-long-corridor", "difficulty": "Hard", "problem_description": "Along a long library corridor, there is a line of seats and decorative plants. You are given a 0-indexed string corridor of length n consisting of letters 'S' and 'P' where each 'S' represents a seat and each 'P' represents a plant.\nOne room divider has already been installed to the left of index 0, and another to the right of index n - 1. Additional room dividers can be installed. For each position between indices i - 1 and i (1 <= i <= n - 1), at most one divider can be installed.\nDivide the corridor into non-overlapping sections, where each section has exactly two seats with any number of plants. There may be multiple ways to perform the division. Two ways are different if there is a position with a room divider installed in the first way but not in the second way.\nReturn the number of ways to divide the corridor. Since the answer may be very large, return it modulo 109 + 7. If there is no way, return 0.\n \nExample 1:\n\n\nInput: corridor = \"SSPPSPS\"\nOutput: 3\nExplanation: There are 3 different ways to divide the corridor.\nThe black bars in the above image indicate the two room dividers already installed.\nNote that in each of the ways, each section has exactly two seats.\n\nExample 2:\n\n\nInput: corridor = \"PPSPSP\"\nOutput: 1\nExplanation: There is only 1 way to divide the corridor, by not installing any additional dividers.\nInstalling any would create some section that does not have exactly two seats.\n\nExample 3:\n\n\nInput: corridor = \"S\"\nOutput: 0\nExplanation: There is no way to divide the corridor because there will always be a section that does not have exactly two seats.\n\n \nConstraints:\n\nn == corridor.length\n1 <= n <= 105\ncorridor[i] is either 'S' or 'P'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(corridor = \"PPPPSSPPPPSSPPPP\") == 5\n assert candidate(corridor = \"SSSSSSSSSS\") == 1\n assert candidate(corridor = \"SPSPSPSP\") == 2\n assert candidate(corridor = \"SSSPPSS\") == 0\n assert candidate(corridor = \"PSSPSPSPPS\") == 0\n assert candidate(corridor = \"SS\") == 1\n assert candidate(corridor = \"PPPP\") == 0\n assert candidate(corridor = \"SSPPSS\") == 3\n assert candidate(corridor = \"SSSSPPSSSS\") == 3\n assert candidate(corridor = \"SSPSSP\") == 2\n assert candidate(corridor = \"SSPSSPSS\") == 4\n assert candidate(corridor = \"SSPPPPPSSPPPPSS\") == 30\n assert candidate(corridor = \"SSPSPSPSPS\") == 4\n assert candidate(corridor = \"SSSS\") == 1\n assert candidate(corridor = \"SSSPPPSS\") == 0\n assert candidate(corridor = \"SSSPPS\") == 1\n assert candidate(corridor = \"PPSSPPSSPP\") == 3\n assert candidate(corridor = \"SSPPSSPPSS\") == 9\n assert candidate(corridor = \"SSPPSPS\") == 3\n assert candidate(corridor = \"SSPPSPPS\") == 3\n assert candidate(corridor = \"S\") == 0\n assert candidate(corridor = \"PPSPSP\") == 1\n assert candidate(corridor = \"SPPSPPSPPS\") == 3\n assert candidate(corridor = \"PPSPSPSPSPSPSPSPSP\") == 8\n assert candidate(corridor = \"SSSPSSSSPPSSPPSSSSPPSSSSPPSSSSSSSSSS\") == 0\n assert candidate(corridor = \"SPPSPSPSPSPSPSPSPS\") == 0\n assert candidate(corridor = \"SSPSSPSSPSSPSSPSSPSS\") == 64\n assert candidate(corridor = \"PPSSPPSPSSPPSS\") == 0\n assert candidate(corridor = \"SSPPSSSSSSSSPPSSSSSSSSPPSSSSSSSSSS\") == 27\n assert candidate(corridor = \"SSPPSSPPSSPPSS\") == 27\n assert candidate(corridor = \"SPSSPSSPSSPSSPSS\") == 0\n assert candidate(corridor = \"PPPPPPSSPPPPSSPPPP\") == 5\n assert candidate(corridor = \"SSPPPPPPSSPPPPSSPPPPSSPPSS\") == 525\n assert candidate(corridor = \"PPSSPPSSPPSSPPSS\") == 27\n assert candidate(corridor = \"PPPPSSPPPPSSPPPPSSPPPPSSPPPPSSPPPP\") == 625\n assert candidate(corridor = \"SSSPSPSPSPSPSSSSPSPS\") == 0\n assert candidate(corridor = \"SSPPSPSPSSSSPPPPSS\") == 30\n assert candidate(corridor = \"SSPPSSSSSSSSSSSSSS\") == 3\n assert candidate(corridor = \"PPPPPPPPPPPPPPPPPP\") == 0\n assert candidate(corridor = \"SPPSPSPSPSPSPSPSPSPS\") == 16\n assert candidate(corridor = \"SPSPPSPSPPSPSPPSPSPP\") == 27\n assert candidate(corridor = \"PPSSPPSSPPSSPP\") == 9\n assert candidate(corridor = \"SSPSPSPSPSPS\") == 0\n assert candidate(corridor = \"SSSPSSSPSSSPSSSPSS\") == 4\n assert candidate(corridor = \"PPSSPPSSSSSSSSSSSS\") == 3\n assert candidate(corridor = \"SSPPPPPPPPSSPPPPSS\") == 45\n assert candidate(corridor = \"SSPPSSSSSSPPSS\") == 9\n assert candidate(corridor = \"SSPPPPPPSSPPPPPSS\") == 42\n assert candidate(corridor = \"SSSSPPPPSSPPSSPPSSSSPPPPSSSSSS\") == 225\n assert candidate(corridor = \"SSPPPPSSPPSS\") == 15\n assert candidate(corridor = \"SSSSPPPPSSPPPPSSSSPPPPSS\") == 125\n assert candidate(corridor = \"SSPPPPSSPPPPSSPPPPSSPPPPSS\") == 625\n assert candidate(corridor = \"SSPPSPSSSSSSSSSSPPSS\") == 0\n assert candidate(corridor = \"SPPSPPSPPSPPS\") == 0\n assert candidate(corridor = \"SSPSPPSPSPSPSPPPSS\") == 0\n assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSS\") == 177147\n assert candidate(corridor = \"PPPPPPSPPPPSPPPPSPPPPS\") == 5\n assert candidate(corridor = \"SSSSSSSSSSSSSSSS\") == 1\n assert candidate(corridor = \"SSPPSPSSPPSPSSPPSPSS\") == 0\n assert candidate(corridor = \"PPSSPPSSPPSS\") == 9\n assert candidate(corridor = \"SSPPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPS\") == 1536\n assert candidate(corridor = \"SSSPSSPPSSPPSSSSPPSSPPSSPPSSSSPPSSSS\") == 0\n assert candidate(corridor = \"SSSSSSSSSSSSSSSSSSSSSSSSSS\") == 1\n assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSSSPPSSSSPPSSSS\") == 729\n assert candidate(corridor = \"SSPPSPPPSPSPPS\") == 6\n assert candidate(corridor = \"SSPPPPSSPPPPSSPPSSPPPPSS\") == 375\n assert candidate(corridor = \"SSPPPPPPSPPPPPSSSSPP\") == 0\n assert candidate(corridor = \"PPSSSSPPPPSS\") == 5\n assert candidate(corridor = \"SSPPSPPPSSSSPPSPSS\") == 6\n assert candidate(corridor = \"PPPPPPSSPPSS\") == 3\n assert candidate(corridor = \"SSPPSPSSPPSPSSPPSPSSPPSPSS\") == 36\n assert candidate(corridor = \"SSSPSSSPSSSPSSSPSSSPSSSPSSS\") == 0\n assert candidate(corridor = \"SSSPSSSSPPSSPPSSSSPPSSSSPPSSSS\") == 0\n assert candidate(corridor = \"SPPPPPPPPPPP\") == 0\n assert candidate(corridor = \"PPPPSPSPPPPSPSPPPPSP\") == 0\n assert candidate(corridor = \"PPSSPPSSPPSSPPSSPPSSPPSSPPSS\") == 729\n assert candidate(corridor = \"PPPPPPPPPPPPPPPPPPPP\") == 0\n assert candidate(corridor = \"SSPSSPSSPSSPSSPSSPSSPSS\") == 128\n assert candidate(corridor = \"SSPPPPSPSPPPSS\") == 20\n assert candidate(corridor = \"PPSSPSSPPSSPSSPPSSPSSPPSS\") == 216\n assert candidate(corridor = \"SSPPPSSPPPSSPPPSS\") == 64\n assert candidate(corridor = \"SSPSSSPSSPSSPSSPSS\") == 0\n assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPPSSPPSS\") == 729\n assert candidate(corridor = \"PPSSPPPPSSPPPPSS\") == 25\n assert candidate(corridor = \"SPSSSPSSSPSSSPSSSPSS\") == 0\n assert candidate(corridor = \"PSPSPSPSPSPSPSPSPS\") == 0\n assert candidate(corridor = \"SSPPSSPSPSPSSP\") == 12\n assert candidate(corridor = \"SSSSSSSSSSSSSSSSSS\") == 1\n assert candidate(corridor = \"SSPPSSPPSSPPSPSSPPSS\") == 0\n assert candidate(corridor = \"SSPPSPSPPPSSSPPSS\") == 0\n assert candidate(corridor = \"SSPPSSSSPPSSSSPPS\") == 0\n assert candidate(corridor = \"SSPPPPPPSSSSSSSSSS\") == 7\n assert candidate(corridor = \"SSPPPPSSPPPPSSSSPPPPSSSSPPPPSSSS\") == 625\n assert candidate(corridor = \"SSSSSSSSSSPPPPPPSS\") == 7\n assert candidate(corridor = \"SSSSPPSSSSSSPPSSSS\") == 9\n assert candidate(corridor = \"SSPSSPSSPSSPSSPSSPSSPSSPSSPS\") == 0\n assert candidate(corridor = \"SSPPSPSPSPPSS\") == 0\n assert candidate(corridor = \"PPSSPPPPSSPPSSPP\") == 15\n assert candidate(corridor = \"SPSSSPSSSPSSSPSS\") == 4\n assert candidate(corridor = \"PSPPSPSPSPSPSPSPSPSP\") == 0\n assert candidate(corridor = \"SSSSSSPPSSSSSSPPSSSSSSPPSSSSSS\") == 27\n assert candidate(corridor = \"SSPPSSPSSPPSSPSSPPSS\") == 108\n assert candidate(corridor = \"SSSPSPSPSPSPSPSPSPSPSP\") == 16\n assert candidate(corridor = \"PPPPPPSSPPPP\") == 1\n assert candidate(corridor = \"PPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSS\") == 19683\n assert candidate(corridor = \"SSPPSPSSPSPSSPSPSSPSPSS\") == 24\n assert candidate(corridor = \"SSSPPSSSPPPSSS\") == 0\n assert candidate(corridor = \"SSSSSSSSSSSS\") == 1\n assert candidate(corridor = \"SSSSSPPPSSSSSPPPSSSS\") == 4\n assert candidate(corridor = \"SSSSSSSSPPPPPPPPSSSSSSSSPPPPPPPPSSSS\") == 81\n assert candidate(corridor = \"SSSSSS\") == 1\n assert candidate(corridor = \"SSPPPPPPSSSSSSPPSSPP\") == 21\n assert candidate(corridor = \"SSPSPSPSPSPSPSPSPSPSPSPSPSPSPS\") == 128\n assert candidate(corridor = \"SSPPSSPPSSPPSSPPSS\") == 81\n assert candidate(corridor = \"SSSSPPPPSSSSPPPPSSSS\") == 25\n assert candidate(corridor = \"SSPSPPSSPSPPSSPSPPSS\") == 0\n assert candidate(corridor = \"SPSPSP\") == 0\n assert candidate(corridor = \"SSPPPPSPSSPPPSS\") == 0\n assert candidate(corridor = \"SSSSPSPSPSPS\") == 4\n assert candidate(corridor = \"PPPPPP\") == 0\n assert candidate(corridor = \"SSPPPPPPPPPPSSPPPPSSPPSS\") == 165\n assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSS\") == 6561\n assert candidate(corridor = \"SSPPPPSSPPPPSSPPSS\") == 75\n assert candidate(corridor = \"SSSSSSSSSSSSSSSSSSSS\") == 1\n assert candidate(corridor = \"SSSSPPPPSSSSPPSSSS\") == 15\n assert candidate(corridor = \"PPPPPPPPPPPPPPPP\") == 0\n assert candidate(corridor = \"SSSPSPSPSPSPSPSPSPSS\") == 16\n assert candidate(corridor = \"SSPPSPSSSSPPSPSSSS\") == 6\n assert candidate(corridor = \"SSPSSPSSPSSPSSPSS\") == 32\n assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPP\") == 81\n assert candidate(corridor = \"PPPPSSPPPPSSPPPPSSPPPPSSPPPPSS\") == 625\n assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPPSSPPSSPPSS\") == 2187\n assert candidate(corridor = \"SSSSPPSSSSPPSSSS\") == 9\n assert candidate(corridor = \"SSSSSSPPPPSSSSPPPPSSSSSSPPPP\") == 25\n assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPPSS\") == 243\n assert candidate(corridor = \"SSPPSSPPSSPPSSSS\") == 27\n assert candidate(corridor = \"SSPSPSPSPSPSPSPS\") == 0\n assert candidate(corridor = \"SSPPSPSPSPSPSS\") == 12\n assert candidate(corridor = \"SPSPSPSPSPSPSPSPSPSP\") == 16\n assert candidate(corridor = \"SSPPSSSSPPPPSSSSSSSS\") == 15\n assert candidate(corridor = \"PPPPSSPPSSPPSSPPPP\") == 9\n assert candidate(corridor = \"SPSPPSPSPPSPSPPSPSPPSP\") == 0\n assert candidate(corridor = \"PPSPSPSPSPSPPSPSPS\") == 8\n assert candidate(corridor = \"SPSPSPSPPSPS\") == 6\n assert candidate(corridor = \"SSPPSSPPSSPPSSSSPPSSPPSSSSPPSS\") == 729\n"}, "metadata": {"canonical_parameter_names": ["corridor"], "leetcode_dataset_entry_point": "Solution().numberOfWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfWays(String corridor) {", "container": "Solution", "callable": "numberOfWays", "parameters": [{"name": "corridor", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2148, "task_id": "count-elements-with-strictly-smaller-and-greater-elements", "difficulty": "Easy", "problem_description": "Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.\n \nExample 1:\n\nInput: nums = [11,7,2,15]\nOutput: 2\nExplanation: The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it.\nElement 11 has element 7 strictly smaller than it and element 15 strictly greater than it.\nIn total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.\n\nExample 2:\n\nInput: nums = [-3,3,3,90]\nOutput: 2\nExplanation: The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it.\nSince there are two elements with the value 3, in total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n-105 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 4\n assert candidate(nums = [-100000, 100000]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [100000, -100000, 0, 1, 2]) == 3\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 8, 9]) == 1\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 2\n assert candidate(nums = [100000, -100000, 0, 10, 20]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 6\n assert candidate(nums = [11, 7, 2, 15]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 3\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500]) == 3\n assert candidate(nums = [0, 0, 0, 1]) == 0\n assert candidate(nums = [-1, 0, 1]) == 1\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [1, 2, 3, 3, 3, 4, 5]) == 5\n assert candidate(nums = [-3, 3, 3, 90]) == 2\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]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 10, 11]) == 12\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000]) == 19\n assert candidate(nums = [50000, -50000, 0, 1000, 500, 250, 750, 150, 300, 600]) == 8\n assert candidate(nums = [100000, 100000, 99999, 99999, 50000, 50000, -50000, -50000, -99999, -99999, -100000, -100000]) == 8\n assert candidate(nums = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(nums = [50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250, 3125, -3125]) == 8\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7]) == 8\n assert candidate(nums = [-1000, -500, -250, -100, -50, -25, 0, 25, 50, 100, 250, 500, 1000]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 6\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == 8\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 8\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10]) == 8\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 13\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 18\n assert candidate(nums = [10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12]) == 4\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 6\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 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]) == 28\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15]) == 4\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 49990, 49989, 49988, 49987, 49986, 49985, 49984, 49983, 49982, 49981]) == 18\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 13\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 15\n assert candidate(nums = [-100000, 100000, -90000, 90000, -80000, 80000, -70000, 70000, -60000, 60000]) == 8\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 9\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500]) == 12\n assert candidate(nums = [10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 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]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 13\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 10\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 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]) == 23\n assert candidate(nums = [-10000, -9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10]) == 8\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, -1, -1, -1, -1]) == 4\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1, 10, 100, 1000, 10000, 100000]) == 8\n assert candidate(nums = [50, 50, 50, 50, 50, 49, 48, 47, 46, 45, 51, 52, 53, 54, 55]) == 13\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996]) == 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]) == 18\n assert candidate(nums = [10000, 10000, 10001, 10001, 9999, 9999, 9998, 9998, 10002, 10002]) == 6\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 18\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 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]) == 18\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\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]) == 28\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 14\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]) == 23\n assert candidate(nums = [30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 13\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]) == 15\n assert candidate(nums = [300, 200, 100, 400, 500, 600, 150, 250, 350, 450]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -10, -20, -30, -40, -50]) == 13\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == 6\n assert candidate(nums = [1, 100000, -1, -100000, 50000, 50001, 50002, 50003, 50004, 50005]) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 13\n assert candidate(nums = [-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000, -1000, -2000, -3000, -4000, -5000]) == 12\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 12\n assert candidate(nums = [50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(nums = [100, 101, 99, 102, 98, 103, 97, 104, 96, 105]) == 8\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 8\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 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\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 14\n assert candidate(nums = [100000, 100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996]) == 6\n assert candidate(nums = [-50000, 50000, 0, 1, 2, -1, -2, -3, 3, 4, -4, 5, -5, 6, -6]) == 13\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 16\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 8\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 8\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 18\n assert candidate(nums = [50000, 50000, 50000, 40000, 60000, 30000, 70000, 20000, 80000, 10000]) == 8\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 18\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 8\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 1000, 2000, 3000, 4000, 5000]) == 12\n assert candidate(nums = [12345, -12345, 67890, -67890, 11111, -11111, 22222, -22222, 33333, -33333, 44444, -44444, 55555, -55555]) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 13\n assert candidate(nums = [-100000, -50000, -10000, -5000, -1000, -500, -100, -50, -10, -5, 0, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000]) == 19\n assert candidate(nums = [10, 20, 20, 30, 30, 40, 40, 50, 50]) == 6\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countElements", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countElements(int[] nums) {", "container": "Solution", "callable": "countElements", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2149, "task_id": "rearrange-array-elements-by-sign", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.\nYou should return the array of nums such that the the array follows the given conditions:\n\nEvery consecutive pair of integers have opposite signs.\nFor all integers with the same sign, the order in which they were present in nums is preserved.\nThe rearranged array begins with a positive integer.\n\nReturn the modified array after rearranging the elements to satisfy the aforementioned conditions.\n \nExample 1:\n\nInput: nums = [3,1,-2,-5,2,-4]\nOutput: [3,-2,1,-5,2,-4]\nExplanation:\nThe positive integers in nums are [3,1,2]. The negative integers are [-2,-5,-4].\nThe only possible way to rearrange them such that they satisfy all conditions is [3,-2,1,-5,2,-4].\nOther ways such as [1,-2,2,-5,3,-4], [3,1,2,-2,-5,-4], [-2,3,-5,1,-4,2] are incorrect because they do not satisfy one or more conditions. \n\nExample 2:\n\nInput: nums = [-1,1]\nOutput: [1,-1]\nExplanation:\n1 is the only positive integer and -1 the only negative integer in nums.\nSo nums is rearranged to [1,-1].\n\n \nConstraints:\n\n2 <= nums.length <= 2 * 105\nnums.length is even\n1 <= |nums[i]| <= 105\nnums consists of equal number of positive and negative integers.\n\n \nIt is not required to do the modifications in-place.", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 2, -3, -1, 5, -6]) == [4, -3, 2, -1, 5, -6]\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == [1, -1, 2, -2, 3, -3]\n assert candidate(nums = [4, -3, 2, -5, 6, -7]) == [4, -3, 2, -5, 6, -7]\n assert candidate(nums = [3, 1, -2, -5, 2, -4]) == [3, -2, 1, -5, 2, -4]\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == [10, -10, 20, -20, 30, -30]\n assert candidate(nums = [7, 10, -5, -3, 2, -8]) == [7, -5, 10, -3, 2, -8]\n assert candidate(nums = [-1, 1]) == [1, -1]\n assert candidate(nums = [8, 5, -7, -3, 4, -6]) == [8, -7, 5, -3, 4, -6]\n assert candidate(nums = [5, -5, 6, -6, 7, -7]) == [5, -5, 6, -6, 7, -7]\n assert candidate(nums = [9, -2, 6, -1, 3, -4]) == [9, -2, 6, -1, 3, -4]\n assert candidate(nums = [4, -3, 2, -1, 6, -5]) == [4, -3, 2, -1, 6, -5]\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, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50]\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n assert candidate(nums = [-2, 2, -4, 4, -6, 6, -8, 8, -10, 10, -12, 12, -14, 14, -16, 16, -18, 18, -20, 20]) == [2, -2, 4, -4, 6, -6, 8, -8, 10, -10, 12, -12, 14, -14, 16, -16, 18, -18, 20, -20]\n assert candidate(nums = [21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30]) == [21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30]\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600]) == [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600]\n assert candidate(nums = [6, -2, 3, -1, 7, -5, 8, -4, 9, -6, 10, -8, 11, -7, 12, -9]) == [6, -2, 3, -1, 7, -5, 8, -4, 9, -6, 10, -8, 11, -7, 12, -9]\n assert candidate(nums = [5, 15, 25, 35, 45, -5, -15, -25, -35, -45, 65, -65]) == [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 65, -65]\n assert candidate(nums = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3]) == [21, -21, 19, -19, 17, -17, 15, -15, 13, -13, 11, -11, 9, -9, 7, -7, 5, -5, 3, -3]\n assert candidate(nums = [12, -12, 24, -24, 36, -36, 48, -48, 60, -60, 72, -72]) == [12, -12, 24, -24, 36, -36, 48, -48, 60, -60, 72, -72]\n assert candidate(nums = [42, -84, 21, -42, 63, -126, 84, -168, 105, -210]) == [42, -84, 21, -42, 63, -126, 84, -168, 105, -210]\n assert candidate(nums = [2, 4, 6, 8, 10, -2, -4, -6, -8, -10, 12, 14, -12, -14, 16, -16, 18, -18]) == [2, -2, 4, -4, 6, -6, 8, -8, 10, -10, 12, -12, 14, -14, 16, -16, 18, -18]\n assert candidate(nums = [10, -11, 20, -21, 30, -31, 40, -41, 50, -51, 60, -61, 70, -71, 80, -81, 90, -91, 100, -101, 110, -111, 120, -121]) == [10, -11, 20, -21, 30, -31, 40, -41, 50, -51, 60, -61, 70, -71, 80, -81, 90, -91, 100, -101, 110, -111, 120, -121]\n assert candidate(nums = [10, 20, 30, -1, -2, -3, 40, -4, 50, -5]) == [10, -1, 20, -2, 30, -3, 40, -4, 50, -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]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n assert candidate(nums = [-10, 11, -12, 13, -14, 15, -16, 17, -18, 19]) == [11, -10, 13, -12, 15, -14, 17, -16, 19, -18]\n assert candidate(nums = [100000, 50000, -50000, -100000, 25000, -25000, 12500, -12500, 6250, -6250]) == [100000, -50000, 50000, -100000, 25000, -25000, 12500, -12500, 6250, -6250]\n assert candidate(nums = [20, 10, -10, -20, 30, 40, -30, -40, 50, 60, -50, -60]) == [20, -10, 10, -20, 30, -30, 40, -40, 50, -50, 60, -60]\n assert candidate(nums = [2, 4, 6, 8, 10, -2, -4, -6, -8, -10, 12, 14, 16, 18, 20, -12, -14, -16, -18, -20]) == [2, -2, 4, -4, 6, -6, 8, -8, 10, -10, 12, -12, 14, -14, 16, -16, 18, -18, 20, -20]\n assert candidate(nums = [15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85]) == [15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85]\n assert candidate(nums = [5, 10, -5, -10, 15, 20, -15, -20, 25, 30, -25, -30]) == [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30]\n assert candidate(nums = [5, -3, 2, -8, 6, -1, 4, -7]) == [5, -3, 2, -8, 6, -1, 4, -7]\n assert candidate(nums = [100, 200, -100, -200, 300, -300, 400, -400, 500, -500]) == [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]\n assert candidate(nums = [50, -25, 75, -37, 100, -50, 125, -62, 150, -75, 175, -87, 200, -100]) == [50, -25, 75, -37, 100, -50, 125, -62, 150, -75, 175, -87, 200, -100]\n assert candidate(nums = [100000, 200000, -100000, -200000, 300000, 400000, -300000, -400000, 500000, -500000]) == [100000, -100000, 200000, -200000, 300000, -300000, 400000, -400000, 500000, -500000]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15]) == [1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -15]\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65]) == [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65]\n assert candidate(nums = [21, 17, 3, -21, 13, -17, -3, 19, -19, 11, -11, 5, -5]) == [21, -21, 17, -17, 3, -3, 13, -19, 19, -11, 11, -5, 5]\n assert candidate(nums = [5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14]) == [5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14]\n assert candidate(nums = [7, -7, 14, -14, 21, -21, 28, -28, 35, -35]) == [7, -7, 14, -14, 21, -21, 28, -28, 35, -35]\n assert candidate(nums = [100, 200, -50, -150, 300, -250, 400, -350, 500, -450]) == [100, -50, 200, -150, 300, -250, 400, -350, 500, -450]\n assert candidate(nums = [15, 3, -9, -6, 12, -5, 20, -7, 18, -11]) == [15, -9, 3, -6, 12, -5, 20, -7, 18, -11]\n assert candidate(nums = [99, -98, 97, -96, 95, -94, 93, -92, 91, -90, 89, -88, 87, -86, 85, -84]) == [99, -98, 97, -96, 95, -94, 93, -92, 91, -90, 89, -88, 87, -86, 85, -84]\n assert candidate(nums = [50, -50, 25, -25, 75, -75, 100, -100, 200, -200, 300, -300]) == [50, -50, 25, -25, 75, -75, 100, -100, 200, -200, 300, -300]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == [10, -10, 20, -20, 30, -30, 40, -40]\n assert candidate(nums = [7, -7, 14, -14, 21, -21, 28, -28, 35, -35, 42, -42, 49, -49, 56, -56]) == [7, -7, 14, -14, 21, -21, 28, -28, 35, -35, 42, -42, 49, -49, 56, -56]\n assert candidate(nums = [15, -20, 25, -30, 35, -40, 45, -50, 55, -60]) == [15, -20, 25, -30, 35, -40, 45, -50, 55, -60]\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000]) == [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000]\n assert candidate(nums = [1, 3, 5, 7, 9, -1, -3, -5, -7, -9, 2, 4, 6, 8, 10, -2, -4, -6, -8, -10]) == [1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 2, -2, 4, -4, 6, -6, 8, -8, 10, -10]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, -1, -3, -5, -7, -9, -11]) == [1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11]\n assert candidate(nums = [31, 41, 59, 26, -31, -41, -59, -26, 53, 58, 97, 93, -53, -58, -97, -93, 23, 84, -23, -84]) == [31, -31, 41, -41, 59, -59, 26, -26, 53, -53, 58, -58, 97, -97, 93, -93, 23, -23, 84, -84]\n assert candidate(nums = [-9, 1, -8, 2, -7, 3, -6, 4, -5, 5, -4, 6, -3, 7, -2, 8, -1, 9]) == [1, -9, 2, -8, 3, -7, 4, -6, 5, -5, 6, -4, 7, -3, 8, -2, 9, -1]\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500]) == [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]\n assert candidate(nums = [9, 11, -9, -11, 12, 13, -12, -13, 14, -14, 15, -15, 16, -16]) == [9, -9, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16]\n assert candidate(nums = [1, 1, 1, 1, -1, -1, -1, -1, 2, 2, 2, 2, -2, -2, -2, -2, 3, 3, 3, 3, -3, -3, -3, -3]) == [1, -1, 1, -1, 1, -1, 1, -1, 2, -2, 2, -2, 2, -2, 2, -2, 3, -3, 3, -3, 3, -3, 3, -3]\n assert candidate(nums = [7, -7, 6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]) == [7, -7, 6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1563, 782, 391, 195, -100000, -50000, -25000, -12500, -6250, -3125, -1563, -782, -391, -195]) == [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250, 3125, -3125, 1563, -1563, 782, -782, 391, -391, 195, -195]\n assert candidate(nums = [6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]) == [6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]\n assert candidate(nums = [9, -9, 8, -8, 7, -7, 6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]) == [9, -9, 8, -8, 7, -7, 6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000, 7000, -7000, 8000, -8000, 9000, -9000, 10000, -10000]) == [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000, 7000, -7000, 8000, -8000, 9000, -9000, 10000, -10000]\n assert candidate(nums = [10, 20, -10, 30, -20, 40, -30, 50, -40, 60, -50, -60, 70, 80, -70, -80]) == [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]\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 = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50]) == [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]\n assert candidate(nums = [7, 14, -7, -14, 21, 28, -21, -28, 35, 42, -35, -42, 49, 56, -49, -56]) == [7, -7, 14, -14, 21, -21, 28, -28, 35, -35, 42, -42, 49, -49, 56, -56]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, -1, -2, -3, -4, -5, -6]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]\n assert candidate(nums = [7, 11, -3, -8, 9, -4, 6, -2, 13, -5]) == [7, -3, 11, -8, 9, -4, 6, -2, 13, -5]\n assert candidate(nums = [22, 33, -22, -33, 44, 55, -44, -55, 66, 77, -66, -77, 88, 99, -88, -99, 11, 22, -11, -22]) == [22, -22, 33, -33, 44, -44, 55, -55, 66, -66, 77, -77, 88, -88, 99, -99, 11, -11, 22, -22]\n assert candidate(nums = [100, -99, 101, -98, 102, -97, 103, -96, 104, -95]) == [100, -99, 101, -98, 102, -97, 103, -96, 104, -95]\n assert candidate(nums = [10, 15, -5, -10, 20, -20, 25, -25]) == [10, -5, 15, -10, 20, -20, 25, -25]\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]) == [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]\n assert candidate(nums = [34, 56, -34, -56, 78, 90, -78, -90, 12, 34, -12, -34, 56, 78, -56, -78]) == [34, -34, 56, -56, 78, -78, 90, -90, 12, -12, 34, -34, 56, -56, 78, -78]\n assert candidate(nums = [101, 202, 303, 404, 505, -101, -202, -303, -404, -505, 606, 707, -606, -707, 808, 909, -808, -909]) == [101, -101, 202, -202, 303, -303, 404, -404, 505, -505, 606, -606, 707, -707, 808, -808, 909, -909]\n assert candidate(nums = [15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85, 95, -95, 105, -105, 115, -115, 125, -125]) == [15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85, 95, -95, 105, -105, 115, -115, 125, -125]\n assert candidate(nums = [21, -21, 32, -32, 43, -43, 54, -54, 65, -65, 76, -76, 87, -87, 98, -98, 109, -109, 120, -120]) == [21, -21, 32, -32, 43, -43, 54, -54, 65, -65, 76, -76, 87, -87, 98, -98, 109, -109, 120, -120]\n assert candidate(nums = [10, 9, -10, -9, 8, 7, -8, -7, 6, 5, -6, -5, 4, 3, -4, -3, 2, 1, -2, -1]) == [10, -10, 9, -9, 8, -8, 7, -7, 6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]\n assert candidate(nums = [21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28]) == [21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28]\n assert candidate(nums = [9, -9, 7, -7, 5, -5, 3, -3, 1, -1]) == [9, -9, 7, -7, 5, -5, 3, -3, 1, -1]\n assert candidate(nums = [3, -3, 6, -6, 9, -9, 12, -12, 15, -15, 18, -18, 21, -21, 24, -24, 27, -27]) == [3, -3, 6, -6, 9, -9, 12, -12, 15, -15, 18, -18, 21, -21, 24, -24, 27, -27]\n assert candidate(nums = [6, -6, 3, -3, 9, -9, 12, -12, 15, -15, 18, -18]) == [6, -6, 3, -3, 9, -9, 12, -12, 15, -15, 18, -18]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]\n assert candidate(nums = [7, 3, -3, -7, 9, -9, 11, -11, 13, -13]) == [7, -3, 3, -7, 9, -9, 11, -11, 13, -13]\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]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12]\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 = [15, -5, 20, -10, 25, -15, 30, -20, 35, -25, 40, -30, 45, -35]) == [15, -5, 20, -10, 25, -15, 30, -20, 35, -25, 40, -30, 45, -35]\n assert candidate(nums = [7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13]) == [7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13]\n assert candidate(nums = [100, -50, 75, -25, 125, -62, 150, -87, 200, -12]) == [100, -50, 75, -25, 125, -62, 150, -87, 200, -12]\n assert candidate(nums = [10, 20, -10, -20, 30, -30, 40, -40]) == [10, -10, 20, -20, 30, -30, 40, -40]\n assert candidate(nums = [20, -30, 21, -31, 22, -32, 23, -33, 24, -34, 25, -35]) == [20, -30, 21, -31, 22, -32, 23, -33, 24, -34, 25, -35]\n assert candidate(nums = [13, -13, 11, -11, 9, -9, 7, -7, 5, -5, 3, -3, 1, -1, 14, -14, 12, -12, 10, -10, 8, -8, 6, -6, 4, -4, 2, -2]) == [13, -13, 11, -11, 9, -9, 7, -7, 5, -5, 3, -3, 1, -1, 14, -14, 12, -12, 10, -10, 8, -8, 6, -6, 4, -4, 2, -2]\n assert candidate(nums = [7, 10, -1, -4, 9, -2, 6, -8]) == [7, -1, 10, -4, 9, -2, 6, -8]\n assert candidate(nums = [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, 3, 5, 7, -1, -3, -5, -7, 9, 11, -9, -11, 13, 15, -13, -15]) == [1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -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, 21, -22, 23, -24, 25, -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, -25]\n assert candidate(nums = [10, -1, 12, -2, 14, -3, 15, -4, 16, -5]) == [10, -1, 12, -2, 14, -3, 15, -4, 16, -5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, -10, -20, -30, -40, -50, -60]) == [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60]\n assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, -20, -18, -16, -14, -12, -10, -8, -6, -4, -2]) == [20, -20, 18, -18, 16, -16, 14, -14, 12, -12, 10, -10, 8, -8, 6, -6, 4, -4, 2, -2]\n assert candidate(nums = [7, 10, -2, -8, 1, -3, 9, -4, 5, -6]) == [7, -2, 10, -8, 1, -3, 9, -4, 5, -6]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().rearrangeArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] rearrangeArray(int[] nums) {", "container": "Solution", "callable": "rearrangeArray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2150, "task_id": "find-all-lonely-numbers-in-the-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums. A number x is lonely when it appears only once, and no adjacent numbers (i.e. x + 1 and x - 1) appear in the array.\nReturn all lonely numbers in nums. You may return the answer in any order.\n \nExample 1:\n\nInput: nums = [10,6,5,8]\nOutput: [10,8]\nExplanation: \n- 10 is a lonely number since it appears exactly once and 9 and 11 does not appear in nums.\n- 8 is a lonely number since it appears exactly once and 7 and 9 does not appear in nums.\n- 5 is not a lonely number since 6 appears in nums and vice versa.\nHence, the lonely numbers in nums are [10, 8].\nNote that [8, 10] may also be returned.\n\nExample 2:\n\nInput: nums = [1,3,5,3]\nOutput: [1,5]\nExplanation: \n- 1 is a lonely number since it appears exactly once and 0 and 2 does not appear in nums.\n- 5 is a lonely number since it appears exactly once and 4 and 6 does not appear in nums.\n- 3 is not a lonely number since it appears twice.\nHence, the lonely numbers in nums are [1, 5].\nNote that [5, 1] may also be returned.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == []\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14]) == [2, 4, 6, 8, 10, 12, 14]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == []\n assert candidate(nums = [10, 6, 5, 8]) == [10, 8]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == []\n assert candidate(nums = [1, 2, 3, 5, 7, 9, 11]) == [5, 7, 9, 11]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == []\n assert candidate(nums = [1, 2, 3, 5, 7, 8, 10]) == [5, 10]\n assert candidate(nums = [1, 1, 3, 3, 5, 5, 7, 7, 9, 9]) == []\n assert candidate(nums = [2]) == [2]\n assert candidate(nums = [5, 5, 5, 5, 5]) == []\n assert candidate(nums = [0, 0, 0, 0, 0]) == []\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(nums = [1, 2, 3, 4, 5]) == []\n assert candidate(nums = [1, 2, 4, 6, 8, 10]) == [4, 6, 8, 10]\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10, 10]) == []\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == []\n assert candidate(nums = [1000000]) == [1000000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == []\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6]) == []\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10]) == []\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == []\n assert candidate(nums = [1, 3, 5, 3]) == [1, 5]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == []\n assert candidate(nums = [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]) == []\n assert candidate(nums = [5, 7, 9, 11, 13, 15]) == [5, 7, 9, 11, 13, 15]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]\n assert candidate(nums = [1, 3, 6, 8, 10, 12, 15, 17, 19, 21, 24, 26, 28, 30, 33, 35, 37]) == [1, 3, 6, 8, 10, 12, 15, 17, 19, 21, 24, 26, 28, 30, 33, 35, 37]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520]) == []\n assert candidate(nums = [100000, 99998, 100002, 99996, 99994, 100004, 100006, 100010, 100012, 100014]) == [100000, 99998, 100002, 99996, 99994, 100004, 100006, 100010, 100012, 100014]\n assert candidate(nums = [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, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]) == []\n assert candidate(nums = [1000000, 999998, 999999, 1, 0, 2, 3, 4, 5, 6, 7, 8, 9]) == []\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]) == []\n assert candidate(nums = [3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28]) == []\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117]) == [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117]\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]) == []\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136]) == [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136]\n assert candidate(nums = [1, 2, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55]) == [4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\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, 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]\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, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]\n assert candidate(nums = [999999, 999997, 999995, 999993, 999991, 999989, 999987, 999985, 999983, 999981, 999979, 999977, 999975]) == [999999, 999997, 999995, 999993, 999991, 999989, 999987, 999985, 999983, 999981, 999979, 999977, 999975]\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, 42, 44, 46, 48, 50]) == [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(nums = [1000000, 1000001, 1000003, 1000005, 1000007, 1000009, 1000011, 1000013, 1000015, 1000017, 1000019, 1000021, 1000023, 1000025, 1000027, 1000029, 1000031, 1000033, 1000035, 1000037, 1000039, 1000041, 1000043, 1000045, 1000047, 1000049, 1000051, 1000053, 1000055, 1000057, 1000059, 1000061, 1000063, 1000065, 1000067, 1000069, 1000071, 1000073, 1000075, 1000077, 1000079, 1000081, 1000083, 1000085, 1000087, 1000089, 1000091, 1000093, 1000095, 1000097, 1000099, 1000101, 1000103, 1000105, 1000107, 1000109, 1000111, 1000113, 1000115, 1000117, 1000119]) == [1000003, 1000005, 1000007, 1000009, 1000011, 1000013, 1000015, 1000017, 1000019, 1000021, 1000023, 1000025, 1000027, 1000029, 1000031, 1000033, 1000035, 1000037, 1000039, 1000041, 1000043, 1000045, 1000047, 1000049, 1000051, 1000053, 1000055, 1000057, 1000059, 1000061, 1000063, 1000065, 1000067, 1000069, 1000071, 1000073, 1000075, 1000077, 1000079, 1000081, 1000083, 1000085, 1000087, 1000089, 1000091, 1000093, 1000095, 1000097, 1000099, 1000101, 1000103, 1000105, 1000107, 1000109, 1000111, 1000113, 1000115, 1000117, 1000119]\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]) == []\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, 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]\n assert candidate(nums = [1, 1, 2, 3, 3, 5, 7, 8, 8, 10, 11, 13, 13, 15]) == [5, 15]\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78]) == [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10]) == []\n assert candidate(nums = [100, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125]) == [103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125]\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59]) == [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]) == [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]\n assert candidate(nums = [5, 5, 5, 5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45]) == [45]\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [5, 9, 15, 21, 27, 33, 39, 45, 51, 57]) == [5, 9, 15, 21, 27, 33, 39, 45, 51, 57]\n assert candidate(nums = [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]) == [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]\n assert candidate(nums = [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]) == [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]\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89]) == [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120]\n assert candidate(nums = [100, 102, 104, 105, 107, 109, 110, 112, 114]) == [100, 102, 107, 112, 114]\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, 27, 28, 29, 30]) == []\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]\n assert candidate(nums = [42, 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]) == [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]\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]) == [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]\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]) == []\n assert candidate(nums = [1000000, 1000002, 1000004, 1000006, 1000008, 1000010, 1000012, 1000014, 1000016, 1000018]) == [1000000, 1000002, 1000004, 1000006, 1000008, 1000010, 1000012, 1000014, 1000016, 1000018]\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35]) == [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90]) == []\n assert candidate(nums = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]\n assert candidate(nums = [100000, 100001, 100003, 100005, 100007, 100009, 100011, 100013, 100015, 100017]) == [100003, 100005, 100007, 100009, 100011, 100013, 100015, 100017]\n assert candidate(nums = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]) == [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]\n assert candidate(nums = [10, 11, 12, 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 27, 28]) == []\n assert candidate(nums = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]) == [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]\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, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]) == [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 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]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 3, 4, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16]) == []\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58]) == [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58]\n assert candidate(nums = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]\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]) == []\n assert candidate(nums = [500000, 500002, 500004, 500006, 500008, 500010, 500012, 500014, 500016, 500018, 500020]) == [500000, 500002, 500004, 500006, 500008, 500010, 500012, 500014, 500016, 500018, 500020]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]\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]) == [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]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]\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]) == []\n assert candidate(nums = [1000000, 999998, 1000002, 500000, 499998, 500002]) == [1000000, 999998, 1000002, 500000, 499998, 500002]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]\n assert candidate(nums = [50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78]) == [50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]) == [5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16, 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 = [1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30, 33, 34]) == []\n assert candidate(nums = [6, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 27, 28, 30, 31]) == []\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 11, 12, 13, 16, 17, 18, 21, 22, 23, 26, 27, 28, 31, 32, 33, 36, 37, 38, 41, 42, 43]) == []\n assert candidate(nums = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81]) == [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81]\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26]) == []\n assert candidate(nums = [2, 4, 7, 9, 11, 13, 16, 18, 20, 22, 25, 27, 29, 31, 34, 36, 38]) == [2, 4, 7, 9, 11, 13, 16, 18, 20, 22, 25, 27, 29, 31, 34, 36, 38]\n assert candidate(nums = [1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020, 1022, 1024]) == [1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020, 1022, 1024]\n assert candidate(nums = [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, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]\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, 24, 26, 28, 30, 32, 34, 36, 38, 40]\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]) == [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]\n assert candidate(nums = [1000000, 999998, 999996, 999994, 999992, 999990, 999988]) == [1000000, 999998, 999996, 999994, 999992, 999990, 999988]\n assert candidate(nums = [2, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52]) == [2, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52]\n assert candidate(nums = [100000, 100001, 100003, 100005, 100007, 100009, 100011, 100013, 100015, 100017, 100019, 100021, 100023, 100025, 100027, 100029, 100031]) == [100003, 100005, 100007, 100009, 100011, 100013, 100015, 100017, 100019, 100021, 100023, 100025, 100027, 100029, 100031]\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]) == []\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31]) == [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]\n assert candidate(nums = [1000000, 1000002, 1000004, 1000006, 1000008, 1000010, 1000012, 1000014, 1000016]) == [1000000, 1000002, 1000004, 1000006, 1000008, 1000010, 1000012, 1000014, 1000016]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]\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]) == []\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]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]\n assert candidate(nums = [1, 1, 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(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == [5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]\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, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43]) == [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43]\n assert candidate(nums = [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, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]\n assert candidate(nums = [5, 7, 12, 15, 16, 18, 20, 22, 25, 26, 27, 30]) == [5, 7, 12, 18, 20, 22, 30]\n assert candidate(nums = [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138]\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 15, 16, 16, 17, 18, 19, 20]) == []\n assert candidate(nums = [1000, 1002, 1003, 1005, 1007, 1008, 1010, 1011, 1013, 1015, 1017, 1019]) == [1000, 1005, 1013, 1015, 1017, 1019]\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == []\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [3, 4, 7, 8, 11, 12, 15, 16, 19, 20, 23, 24, 27, 28, 31, 32, 35, 36]) == []\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == []\n assert candidate(nums = [2, 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]) == [2, 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]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81]) == [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81]\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]) == [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]\n assert candidate(nums = [100, 101, 103, 104, 106, 108, 110, 111, 113, 115, 117, 119]) == [106, 108, 113, 115, 117, 119]\n assert candidate(nums = [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]) == [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]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20]) == []\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60]) == [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60]\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840]) == [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findLonely", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List findLonely(int[] nums) {", "container": "Solution", "callable": "findLonely", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2151, "task_id": "maximum-good-people-based-on-statements", "difficulty": "Hard", "problem_description": "There are two types of persons:\n\nThe good person: The person who always tells the truth.\nThe bad person: The person who might tell the truth and might lie.\n\nYou are given a 0-indexed 2D integer array statements of size n x n that represents the statements made by n people about each other. More specifically, statements[i][j] could be one of the following:\n\n0 which represents a statement made by person i that person j is a bad person.\n1 which represents a statement made by person i that person j is a good person.\n2 represents that no statement is made by person i about person j.\n\nAdditionally, no person ever makes a statement about themselves. Formally, we have that statements[i][i] = 2 for all 0 <= i < n.\nReturn the maximum number of people who can be good based on the statements made by the n people.\n \nExample 1:\n\n\nInput: statements = [[2,1,2],[1,2,2],[2,0,2]]\nOutput: 2\nExplanation: Each person makes a single statement.\n- Person 0 states that person 1 is good.\n- Person 1 states that person 0 is good.\n- Person 2 states that person 1 is bad.\nLet's take person 2 as the key.\n- Assuming that person 2 is a good person:\n - Based on the statement made by person 2, person 1 is a bad person.\n - Now we know for sure that person 1 is bad and person 2 is good.\n - Based on the statement made by person 1, and since person 1 is bad, they could be:\n - telling the truth. There will be a contradiction in this case and this assumption is invalid.\n - lying. In this case, person 0 is also a bad person and lied in their statement.\n - Following that person 2 is a good person, there will be only one good person in the group.\n- Assuming that person 2 is a bad person:\n - Based on the statement made by person 2, and since person 2 is bad, they could be:\n - telling the truth. Following this scenario, person 0 and 1 are both bad as explained before.\n - Following that person 2 is bad but told the truth, there will be no good persons in the group.\n - lying. In this case person 1 is a good person.\n - Since person 1 is a good person, person 0 is also a good person.\n - Following that person 2 is bad and lied, there will be two good persons in the group.\nWe can see that at most 2 persons are good in the best case, so we return 2.\nNote that there is more than one way to arrive at this conclusion.\n\nExample 2:\n\n\nInput: statements = [[2,0],[0,2]]\nOutput: 1\nExplanation: Each person makes a single statement.\n- Person 0 states that person 1 is bad.\n- Person 1 states that person 0 is bad.\nLet's take person 0 as the key.\n- Assuming that person 0 is a good person:\n - Based on the statement made by person 0, person 1 is a bad person and was lying.\n - Following that person 0 is a good person, there will be only one good person in the group.\n- Assuming that person 0 is a bad person:\n - Based on the statement made by person 0, and since person 0 is bad, they could be:\n - telling the truth. Following this scenario, person 0 and 1 are both bad.\n - Following that person 0 is bad but told the truth, there will be no good persons in the group.\n - lying. In this case person 1 is a good person.\n - Following that person 0 is bad and lied, there will be only one good person in the group.\nWe can see that at most, one person is good in the best case, so we return 1.\nNote that there is more than one way to arrive at this conclusion.\n\n \nConstraints:\n\nn == statements.length == statements[i].length\n2 <= n <= 15\nstatements[i][j] is either 0, 1, or 2.\nstatements[i][i] == 2\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(statements = [[2, 1, 2], [1, 2, 2], [2, 0, 2]]) == 2\n assert candidate(statements = [[2, 1, 0], [1, 2, 1], [0, 1, 0]]) == 0\n assert candidate(statements = [[2, 1, 0, 2], [1, 2, 2, 0], [0, 2, 2, 1], [2, 0, 1, 2]]) == 2\n assert candidate(statements = [[2, 2], [2, 2]]) == 2\n assert candidate(statements = [[2, 1, 0, 0], [0, 2, 1, 0], [1, 1, 2, 0], [0, 0, 0, 2]]) == 1\n assert candidate(statements = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 2\n assert candidate(statements = [[2, 1, 1], [0, 2, 1], [0, 0, 2]]) == 1\n assert candidate(statements = [[2, 2, 0, 0], [2, 2, 0, 0], [0, 0, 2, 1], [0, 0, 1, 2]]) == 2\n assert candidate(statements = [[2, 0, 0], [0, 2, 0], [0, 0, 2]]) == 1\n assert candidate(statements = [[2, 2, 2], [2, 2, 2], [2, 2, 2]]) == 3\n assert candidate(statements = [[2, 0, 0, 0, 0], [0, 2, 1, 1, 1], [0, 1, 2, 1, 0], [0, 1, 1, 2, 1], [0, 1, 0, 1, 2]]) == 1\n assert candidate(statements = [[2, 1], [0, 2]]) == 1\n assert candidate(statements = [[2, 1, 0], [1, 2, 1], [0, 1, 2]]) == 0\n assert candidate(statements = [[2, 2, 2, 2], [2, 2, 0, 2], [2, 0, 2, 2], [2, 2, 2, 2]]) == 3\n assert candidate(statements = [[2, 0, 0, 0], [0, 2, 0, 0], [0, 0, 2, 0], [0, 0, 0, 2]]) == 1\n assert candidate(statements = [[2, 1, 1], [1, 2, 1], [1, 1, 2]]) == 3\n assert candidate(statements = [[2, 0], [0, 2]]) == 1\n assert candidate(statements = [[2, 2, 2, 0], [2, 2, 2, 1], [2, 2, 2, 0], [1, 0, 1, 2]]) == 2\n assert candidate(statements = [[2, 0, 1], [0, 2, 1], [1, 1, 2]]) == 0\n assert candidate(statements = [[2, 0, 1, 2], [1, 2, 0, 2], [0, 0, 2, 1], [2, 2, 1, 2]]) == 2\n assert candidate(statements = [[2, 0, 0, 1, 0, 1], [0, 2, 1, 0, 0, 0], [0, 1, 2, 1, 1, 0], [1, 0, 1, 2, 1, 1], [0, 0, 1, 1, 2, 0], [1, 0, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 1, 0, 2, 1, 2, 1, 2, 0], [1, 2, 2, 0, 1, 0, 1, 0, 1], [0, 2, 2, 1, 0, 1, 0, 1, 0], [2, 0, 1, 2, 0, 2, 1, 2, 1], [1, 1, 0, 0, 2, 1, 0, 1, 0], [2, 0, 1, 2, 1, 2, 1, 2, 0], [1, 0, 1, 0, 0, 1, 2, 1, 1], [2, 1, 0, 2, 0, 2, 1, 2, 0], [0, 1, 0, 1, 0, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[1, 0, 1, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0], [1, 0, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 1], [0, 1, 0, 1, 0, 0, 1, 1]]) == 0\n assert candidate(statements = [[2, 1, 0, 2, 1], [1, 2, 1, 0, 2], [0, 1, 2, 1, 0], [2, 0, 1, 2, 0], [1, 2, 0, 0, 2]]) == 0\n assert candidate(statements = [[2, 0, 2, 1, 0, 2, 0], [0, 2, 0, 0, 2, 0, 1], [2, 0, 2, 0, 2, 1, 0], [1, 0, 0, 2, 0, 0, 1], [0, 2, 2, 0, 2, 0, 0], [2, 0, 1, 0, 0, 2, 1], [0, 1, 0, 1, 0, 1, 2]]) == 1\n assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2], [2, 2, 1, 0, 0, 0, 0], [2, 1, 2, 1, 0, 0, 0], [2, 0, 1, 2, 1, 0, 0], [2, 0, 0, 1, 2, 1, 0], [2, 0, 0, 0, 1, 2, 1], [2, 0, 0, 0, 0, 1, 2]]) == 1\n assert candidate(statements = [[2, 0, 0, 1, 1, 0], [0, 2, 1, 0, 1, 1], [0, 1, 2, 1, 0, 0], [1, 0, 1, 2, 1, 1], [1, 1, 0, 1, 2, 0], [0, 1, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 2, 2, 1, 0, 0, 1, 0], [2, 2, 1, 1, 0, 2, 2, 0], [2, 1, 2, 2, 0, 0, 2, 1], [1, 1, 2, 2, 2, 1, 0, 0], [0, 0, 0, 2, 2, 0, 2, 1], [0, 2, 0, 1, 0, 2, 2, 1], [1, 2, 2, 0, 2, 2, 2, 0], [0, 0, 1, 0, 1, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 0, 0, 0, 0, 0, 0, 0, 0], [2, 0, 2, 0, 0, 0, 0, 0, 0, 0], [2, 0, 0, 2, 0, 0, 0, 0, 0, 0], [2, 0, 0, 0, 2, 0, 0, 0, 0, 0], [2, 0, 0, 0, 0, 2, 0, 0, 0, 0], [2, 0, 0, 0, 0, 0, 2, 0, 0, 0], [2, 0, 0, 0, 0, 0, 0, 2, 0, 0], [2, 0, 0, 0, 0, 0, 0, 0, 2, 0], [2, 0, 0, 0, 0, 0, 0, 0, 0, 2]]) == 2\n assert candidate(statements = [[2, 1, 1, 0, 0], [1, 2, 1, 0, 0], [1, 1, 2, 1, 1], [0, 0, 1, 2, 0], [0, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 1, 0, 1, 0], [1, 2, 1, 0, 1], [0, 1, 2, 0, 0], [1, 0, 0, 2, 1], [0, 1, 0, 1, 2]]) == 0\n assert candidate(statements = [[2, 0, 0, 1, 0, 0], [0, 2, 1, 0, 1, 0], [0, 1, 2, 0, 0, 1], [1, 0, 0, 2, 1, 0], [0, 1, 0, 1, 2, 0], [0, 0, 1, 0, 0, 2]]) == 0\n assert candidate(statements = [[2, 0, 1, 0, 1, 1, 0, 1, 0], [0, 2, 1, 0, 1, 0, 1, 1, 0], [1, 1, 2, 0, 1, 0, 0, 0, 1], [0, 0, 0, 2, 1, 1, 1, 0, 1], [1, 1, 1, 1, 2, 1, 0, 0, 0], [1, 0, 0, 1, 1, 2, 1, 0, 1], [0, 1, 0, 1, 0, 1, 2, 1, 0], [1, 1, 0, 0, 0, 0, 1, 2, 1], [0, 0, 1, 1, 0, 1, 0, 1, 2]]) == 0\n assert candidate(statements = [[2, 0, 1, 1, 0, 0, 1, 0, 1, 1], [0, 2, 0, 0, 1, 1, 0, 1, 0, 0], [1, 0, 2, 1, 0, 1, 0, 1, 1, 0], [1, 0, 1, 2, 0, 1, 1, 0, 0, 1], [0, 1, 0, 0, 2, 1, 0, 1, 1, 0], [0, 1, 1, 1, 1, 2, 0, 0, 1, 1], [1, 0, 1, 0, 0, 0, 2, 1, 1, 0], [0, 1, 0, 1, 1, 0, 1, 2, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 2, 0], [1, 0, 0, 1, 0, 1, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 1, 0, 0, 0, 0, 0, 0], [1, 2, 1, 0, 0, 0, 0, 0], [0, 1, 2, 1, 0, 0, 0, 0], [0, 0, 1, 2, 1, 0, 0, 0], [0, 0, 0, 1, 2, 1, 0, 0], [0, 0, 0, 0, 1, 2, 1, 0], [0, 0, 0, 0, 0, 1, 2, 1], [0, 0, 0, 0, 0, 0, 1, 2]]) == 0\n assert candidate(statements = [[2, 2, 1, 0, 2, 0, 2, 1, 0, 1, 2], [2, 2, 0, 1, 2, 0, 2, 0, 1, 0, 2], [1, 0, 2, 2, 0, 1, 2, 1, 2, 0, 1], [0, 1, 2, 2, 1, 0, 2, 0, 1, 2, 0], [2, 2, 0, 1, 2, 0, 2, 0, 1, 0, 2], [0, 0, 1, 0, 0, 2, 2, 0, 0, 1, 1], [2, 2, 2, 0, 2, 2, 2, 0, 2, 0, 2], [1, 0, 1, 0, 0, 0, 0, 2, 1, 0, 1], [0, 1, 2, 1, 1, 0, 2, 1, 2, 0, 0], [1, 0, 0, 2, 0, 1, 0, 0, 0, 2, 1], [2, 2, 1, 0, 2, 1, 2, 1, 0, 1, 2]]) == 1\n assert candidate(statements = [[2, 0, 1, 1, 0, 1, 0], [0, 2, 0, 0, 1, 0, 1], [1, 0, 2, 0, 0, 1, 0], [1, 0, 0, 2, 1, 0, 1], [0, 1, 0, 1, 2, 1, 0], [1, 0, 1, 0, 1, 2, 1], [0, 1, 0, 1, 0, 1, 2]]) == 0\n assert candidate(statements = [[2, 2, 2, 0, 1, 0], [2, 2, 0, 1, 0, 1], [2, 0, 2, 1, 1, 0], [0, 1, 1, 2, 2, 2], [1, 0, 1, 2, 2, 0], [0, 1, 0, 2, 0, 2]]) == 0\n assert candidate(statements = [[2, 0, 1, 0, 1, 1], [0, 2, 0, 0, 0, 0], [1, 0, 2, 1, 1, 0], [0, 0, 1, 2, 0, 1], [1, 0, 1, 0, 2, 1], [1, 0, 0, 1, 1, 2]]) == 1\n assert candidate(statements = [[2, 1, 2, 0, 2], [1, 2, 0, 1, 2], [2, 0, 2, 1, 0], [0, 1, 1, 2, 2], [2, 2, 0, 2, 1]]) == 1\n assert candidate(statements = [[2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2]]) == 1\n assert candidate(statements = [[2, 1, 0, 2, 1], [1, 2, 1, 2, 0], [0, 1, 2, 0, 2], [2, 2, 0, 2, 1], [1, 0, 2, 1, 2]]) == 0\n assert candidate(statements = [[2, 0, 0, 0, 0, 0, 0], [0, 2, 1, 1, 1, 1, 0], [0, 1, 2, 1, 0, 0, 1], [0, 1, 1, 2, 1, 0, 1], [0, 1, 0, 1, 2, 1, 0], [0, 1, 0, 0, 1, 2, 1], [0, 0, 1, 1, 0, 1, 2]]) == 1\n assert candidate(statements = [[2, 2, 2, 0, 0, 0, 0, 0], [2, 2, 0, 2, 0, 0, 0, 0], [2, 0, 2, 0, 2, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 2, 0, 2, 0, 2], [0, 0, 0, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 2, 0, 2]]) == 2\n assert candidate(statements = [[2, 2, 1, 0, 0], [2, 2, 0, 0, 1], [1, 0, 2, 0, 1], [0, 0, 0, 2, 0], [0, 1, 1, 0, 2]]) == 1\n assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2], [2, 2, 0, 0, 0, 0, 0], [2, 0, 2, 0, 1, 0, 1], [2, 0, 0, 2, 0, 1, 0], [2, 0, 1, 0, 2, 0, 1], [2, 0, 0, 1, 0, 2, 0], [2, 0, 1, 0, 1, 0, 2]]) == 4\n assert candidate(statements = [[2, 1, 0, 0, 0, 0, 1], [1, 2, 1, 1, 1, 0, 0], [0, 1, 2, 0, 1, 1, 1], [0, 1, 0, 2, 1, 0, 0], [0, 1, 1, 1, 2, 1, 0], [0, 0, 1, 0, 1, 2, 1], [1, 0, 1, 0, 0, 1, 2]]) == 0\n assert candidate(statements = [[2, 2, 0, 1, 1, 0], [2, 2, 1, 1, 0, 0], [0, 1, 2, 0, 1, 1], [1, 1, 0, 2, 0, 1], [1, 0, 1, 0, 2, 0], [0, 0, 1, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 2, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 2, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 2, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 2, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]]) == 10\n assert candidate(statements = [[2, 0, 1, 1, 0, 0], [0, 2, 2, 1, 1, 0], [1, 2, 2, 0, 0, 1], [1, 1, 0, 2, 2, 1], [0, 1, 0, 2, 2, 0], [0, 0, 1, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 0, 0, 1, 1, 0, 0], [2, 0, 2, 1, 2, 0, 1, 1], [2, 0, 1, 2, 0, 1, 0, 1], [2, 1, 2, 0, 2, 0, 1, 0], [2, 1, 0, 1, 0, 2, 1, 0], [2, 0, 1, 0, 1, 1, 2, 1], [2, 0, 1, 1, 0, 0, 1, 2]]) == 1\n assert candidate(statements = [[2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2]]) == 8\n assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 12\n assert candidate(statements = [[2, 2, 2, 2, 1, 0], [2, 2, 2, 1, 0, 2], [2, 2, 2, 1, 2, 1], [2, 1, 1, 2, 0, 1], [1, 0, 2, 0, 2, 2], [0, 2, 1, 1, 2, 2]]) == 4\n assert candidate(statements = [[2, 1, 0, 0, 0, 0, 0, 0, 0], [1, 2, 1, 1, 1, 1, 1, 1, 1], [0, 1, 2, 0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 0, 0, 0, 0], [0, 1, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 0, 0, 2, 0, 0, 0], [0, 1, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 2, 0], [0, 1, 0, 0, 0, 0, 0, 0, 2]]) == 0\n assert candidate(statements = [[2, 2, 1, 0, 0, 0, 0, 0], [2, 2, 0, 1, 0, 0, 0, 0], [1, 0, 2, 0, 1, 0, 0, 0], [0, 1, 0, 2, 0, 1, 0, 0], [0, 0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 1, 0, 2, 0, 1], [0, 0, 0, 0, 1, 0, 2, 0], [0, 0, 0, 0, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 1, 1, 0, 1], [1, 2, 0, 1, 0], [1, 0, 2, 0, 1], [0, 1, 0, 2, 1], [1, 0, 1, 1, 2]]) == 0\n assert candidate(statements = [[2, 1, 1, 1, 0, 1], [1, 2, 0, 0, 1, 0], [1, 0, 2, 1, 0, 0], [1, 0, 1, 2, 1, 0], [0, 1, 0, 1, 2, 1], [1, 0, 0, 0, 1, 2]]) == 0\n assert candidate(statements = [[2, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 2, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 2, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 2, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 2, 0], [0, 0, 0, 0, 1, 0, 0, 1, 0, 2]]) == 2\n assert candidate(statements = [[2, 2, 2, 2, 0, 0, 0, 0], [2, 2, 2, 2, 0, 0, 0, 0], [2, 2, 2, 2, 0, 0, 0, 0], [2, 2, 2, 2, 0, 0, 0, 0], [0, 0, 0, 0, 2, 2, 2, 2], [0, 0, 0, 0, 2, 2, 2, 2], [0, 0, 0, 0, 2, 2, 2, 2], [0, 0, 0, 0, 2, 2, 2, 2]]) == 4\n assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1], [2, 2, 2, 1, 2, 2, 2, 2, 2], [2, 2, 2, 1, 2, 2, 2, 2, 2], [2, 2, 2, 1, 2, 2, 2, 2, 2], [2, 2, 2, 1, 2, 2, 2, 2, 2], [2, 2, 2, 1, 2, 2, 2, 2, 2]]) == 9\n assert candidate(statements = [[2, 1, 1, 0, 1, 2, 0], [1, 2, 0, 1, 0, 1, 0], [1, 0, 2, 1, 0, 0, 1], [0, 1, 1, 2, 0, 0, 0], [1, 0, 0, 0, 2, 1, 1], [2, 1, 0, 0, 1, 2, 0], [0, 0, 1, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 0, 0, 1, 0, 0], [0, 2, 1, 0, 1, 1], [0, 1, 2, 1, 0, 0], [1, 0, 1, 2, 0, 1], [0, 1, 0, 0, 2, 0], [0, 1, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 2, 1, 0, 0, 0, 0], [2, 2, 1, 0, 0, 0, 0], [1, 1, 2, 1, 1, 1, 0], [0, 0, 1, 2, 1, 0, 1], [0, 0, 1, 1, 2, 1, 0], [0, 0, 1, 0, 1, 2, 1], [0, 0, 0, 1, 0, 1, 2]]) == 0\n assert candidate(statements = [[2, 1, 2, 0, 2, 1, 2, 0, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 0, 2, 1, 2, 0, 2, 1], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2], [2, 1, 2, 0, 2, 1, 2, 0, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 0, 2, 1, 2, 0, 2, 1], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2], [2, 1, 2, 0, 2, 1, 2, 0, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 8\n assert candidate(statements = [[2, 1, 1, 1, 0, 1, 1, 0], [1, 2, 0, 0, 1, 0, 1, 0], [1, 0, 2, 1, 0, 0, 0, 1], [1, 0, 1, 2, 1, 0, 1, 0], [0, 1, 0, 1, 2, 1, 1, 0], [1, 0, 0, 0, 1, 2, 0, 1], [1, 1, 0, 1, 1, 0, 2, 0], [0, 0, 1, 0, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 1, 1, 1, 0, 0], [1, 2, 0, 0, 1, 1], [1, 0, 2, 1, 0, 0], [1, 0, 1, 2, 1, 0], [0, 1, 0, 1, 2, 1], [0, 1, 0, 0, 1, 2]]) == 0\n assert candidate(statements = [[2, 1, 1, 0, 0, 0, 0, 0, 0], [1, 2, 0, 1, 0, 0, 0, 0, 0], [1, 0, 2, 0, 1, 0, 0, 0, 0], [0, 1, 0, 2, 0, 1, 0, 0, 0], [0, 0, 1, 0, 2, 0, 1, 0, 0], [0, 0, 0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 0, 1, 0, 2, 0, 1], [0, 0, 0, 0, 0, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 2, 2, 1, 2, 0, 1, 0], [2, 2, 2, 0, 2, 1, 0, 1], [2, 2, 2, 1, 0, 0, 0, 0], [1, 0, 1, 2, 2, 1, 0, 0], [2, 2, 0, 2, 2, 0, 1, 0], [0, 1, 0, 1, 0, 2, 0, 1], [1, 0, 0, 0, 1, 0, 2, 0], [0, 1, 0, 0, 0, 1, 0, 2]]) == 0\n assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2], [2, 2, 1, 1, 0, 0, 0], [2, 1, 2, 0, 2, 1, 0], [2, 1, 0, 2, 2, 0, 1], [2, 0, 2, 2, 2, 1, 1], [2, 0, 1, 0, 1, 2, 0], [2, 0, 0, 1, 1, 0, 2]]) == 1\n assert candidate(statements = [[2, 1, 0, 2, 1, 2], [1, 2, 2, 0, 1, 0], [0, 2, 2, 1, 0, 1], [2, 0, 1, 2, 0, 2], [1, 1, 0, 0, 2, 1], [2, 0, 1, 2, 1, 2]]) == 0\n assert candidate(statements = [[2, 1, 2, 0, 1, 0, 1, 0, 0], [1, 2, 0, 1, 0, 1, 0, 1, 1], [2, 0, 2, 1, 0, 0, 1, 0, 0], [0, 1, 1, 2, 0, 0, 0, 1, 1], [1, 0, 0, 0, 2, 1, 1, 0, 0], [0, 1, 0, 1, 1, 2, 0, 1, 1], [1, 0, 1, 0, 1, 0, 2, 0, 0], [0, 1, 0, 1, 0, 1, 0, 2, 1], [0, 1, 0, 1, 0, 1, 0, 1, 2]]) == 0\n assert candidate(statements = [[2, 1, 0, 0, 0, 0, 0, 0], [1, 2, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 1, 1, 0, 0], [0, 0, 0, 2, 0, 0, 1, 0], [0, 0, 1, 0, 2, 0, 0, 1], [0, 0, 1, 0, 0, 2, 1, 0], [0, 0, 0, 1, 0, 1, 2, 0], [0, 0, 0, 0, 1, 0, 0, 2]]) == 2\n assert candidate(statements = [[2, 1, 1, 0, 0, 0, 0, 0, 0], [1, 2, 0, 1, 0, 0, 0, 0, 0], [1, 0, 2, 1, 0, 0, 0, 0, 0], [0, 1, 1, 2, 0, 1, 0, 0, 0], [0, 0, 0, 0, 2, 0, 1, 0, 1], [0, 0, 0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 0, 1, 0, 2, 1, 0], [0, 0, 0, 0, 0, 1, 1, 2, 0], [0, 0, 0, 0, 1, 0, 0, 0, 2]]) == 0\n assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2], [2, 2, 0, 1, 1, 1, 0], [2, 0, 2, 0, 1, 0, 0], [2, 1, 0, 2, 0, 1, 1], [2, 1, 1, 0, 2, 0, 1], [2, 1, 0, 1, 0, 2, 0], [2, 0, 0, 1, 1, 0, 2]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["statements"], "leetcode_dataset_entry_point": "Solution().maximumGood", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumGood(int[][] statements) {", "container": "Solution", "callable": "maximumGood", "parameters": [{"name": "statements", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2154, "task_id": "keep-multiplying-found-values-by-two", "difficulty": "Easy", "problem_description": "You are given an array of integers nums. You are also given an integer original which is the first number that needs to be searched for in nums.\nYou then do the following steps:\n\nIf original is found in nums, multiply it by two (i.e., set original = 2 * original).\nOtherwise, stop the process.\nRepeat this process with the new number as long as you keep finding the number.\n\nReturn the final value of original.\n \nExample 1:\n\nInput: nums = [5,3,6,1,12], original = 3\nOutput: 24\nExplanation: \n- 3 is found in nums. 3 is multiplied by 2 to obtain 6.\n- 6 is found in nums. 6 is multiplied by 2 to obtain 12.\n- 12 is found in nums. 12 is multiplied by 2 to obtain 24.\n- 24 is not found in nums. Thus, 24 is returned.\n\nExample 2:\n\nInput: nums = [2,7,9], original = 4\nOutput: 4\nExplanation:\n- 4 is not found in nums. Thus, 4 is returned.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i], original <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],original = 5) == 5\n assert candidate(nums = [1000, 500, 250, 125, 625],original = 5) == 5\n assert candidate(nums = [3, 6, 9, 12, 15],original = 3) == 24\n assert candidate(nums = [1, 2, 4, 8],original = 1) == 16\n assert candidate(nums = [8, 16, 32, 64, 128],original = 8) == 256\n assert candidate(nums = [2, 7, 9],original = 4) == 4\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000],original = 1000) == 2000\n assert candidate(nums = [1, 3, 5, 7, 9],original = 2) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],original = 10) == 80\n assert candidate(nums = [2, 2, 2, 2, 2],original = 2) == 4\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512],original = 4) == 4\n assert candidate(nums = [1000, 500, 250, 125, 62, 31],original = 1) == 1\n assert candidate(nums = [1, 1, 1, 1, 1],original = 1) == 2\n assert candidate(nums = [1, 2, 4, 8, 16],original = 1) == 32\n assert candidate(nums = [4, 8, 16, 32, 64],original = 2) == 2\n assert candidate(nums = [5, 3, 6, 1, 12],original = 3) == 24\n assert candidate(nums = [1000, 500, 250, 125],original = 125) == 2000\n assert candidate(nums = [10, 20, 40, 80, 160],original = 10) == 320\n assert candidate(nums = [7, 14, 28, 56, 112],original = 7) == 224\n assert candidate(nums = [1, 3, 5, 7, 9],original = 1) == 2\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448],original = 7) == 896\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],original = 3) == 24\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],original = 10) == 160\n assert candidate(nums = [13, 26, 52, 104, 208, 416, 832, 1664, 3328, 6656],original = 13) == 13312\n assert candidate(nums = [9, 18, 36, 72, 144, 288, 576, 1152, 2304],original = 9) == 4608\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],original = 1) == 2\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 11, 13, 14, 17, 19, 21, 22, 23, 26, 29, 31],original = 2) == 4\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180],original = 9) == 288\n assert candidate(nums = [11, 22, 44, 88, 176, 352, 704, 1408, 2816, 5632],original = 11) == 11264\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024],original = 4) == 2048\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],original = 2) == 32\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],original = 2) == 2\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80],original = 4) == 128\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],original = 1) == 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],original = 1) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],original = 1) == 2048\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],original = 1) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],original = 2) == 4\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],original = 4) == 65536\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300],original = 15) == 480\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],original = 10) == 160\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],original = 1) == 1024\n assert candidate(nums = [4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144],original = 4) == 8\n assert candidate(nums = [6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152],original = 6) == 98304\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],original = 1) == 32\n assert candidate(nums = [13, 26, 52, 104, 208, 416, 832, 1664, 3328],original = 13) == 6656\n assert candidate(nums = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],original = 500) == 8000\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],original = 10) == 320\n assert candidate(nums = [3, 9, 27, 81, 243, 729],original = 3) == 6\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],original = 1) == 2\n assert candidate(nums = [29, 58, 116, 232, 464, 928, 1856],original = 29) == 3712\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],original = 13) == 208\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],original = 7) == 112\n assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640, 1280],original = 5) == 2560\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561],original = 3) == 6\n assert candidate(nums = [11, 22, 44, 88, 176, 352, 704, 1408, 2816, 5632, 11264, 22528, 45056, 90112],original = 11) == 180224\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560],original = 10) == 5120\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220],original = 11) == 352\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],original = 10) == 320\n assert candidate(nums = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],original = 500) == 8000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],original = 5) == 80\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],original = 7) == 112\n assert candidate(nums = [13, 26, 52, 104, 208, 416, 832, 1664, 3328, 6656, 13312],original = 13) == 26624\n assert candidate(nums = [250, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000],original = 250) == 256000\n assert candidate(nums = [15, 30, 60, 120, 240, 480, 960, 1920, 3840],original = 15) == 7680\n assert candidate(nums = [19, 38, 76, 152, 304, 608, 1216, 2432, 4864, 9728],original = 19) == 19456\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],original = 1) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],original = 1) == 16\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66],original = 6) == 96\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792],original = 7) == 3584\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],original = 1) == 2\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180],original = 6) == 192\n assert candidate(nums = [13, 26, 52, 104, 208, 416, 832],original = 13) == 1664\n assert candidate(nums = [2, 6, 18, 54, 162, 486, 1458, 4374, 13122, 39366],original = 2) == 4\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561],original = 1) == 2\n assert candidate(nums = [11, 22, 44, 88, 176, 352, 704, 1408, 2816],original = 11) == 5632\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],original = 1) == 2\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],original = 5) == 80\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584],original = 7) == 7168\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],original = 15) == 240\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],original = 7) == 224\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],original = 990) == 1980\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683],original = 3) == 6\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260],original = 13) == 416\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792],original = 7) == 3584\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],original = 5) == 160\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],original = 9) == 144\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],original = 2) == 2048\n assert candidate(nums = [17, 34, 68, 136, 272, 544, 1088, 2176, 4352],original = 17) == 8704\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120],original = 10) == 10240\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509],original = 500) == 1000\n assert candidate(nums = [13, 26, 52, 104, 208, 416, 832, 1664, 3328, 6656, 13312, 26624, 53248, 106496],original = 13) == 212992\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],original = 7) == 112\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340],original = 17) == 544\n assert candidate(nums = [19, 38, 76, 152, 304, 608, 1216],original = 19) == 2432\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],original = 4) == 128\n assert candidate(nums = [100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400],original = 100) == 204800\n assert candidate(nums = [23, 46, 92, 184, 368, 736, 1472],original = 23) == 2944\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],original = 2) == 4\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400],original = 1) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],original = 1) == 2048\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980],original = 980) == 1960\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049],original = 3) == 6\n assert candidate(nums = [6, 12, 24, 48, 96, 192, 384, 768, 1536],original = 6) == 3072\n assert candidate(nums = [1, 2, 3, 5, 6, 10, 12, 15, 20, 30, 60, 120, 240, 480, 960],original = 1) == 4\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896],original = 7) == 1792\n assert candidate(nums = [9, 18, 36, 72, 144, 288, 576, 1152, 2304],original = 9) == 4608\n assert candidate(nums = [5, 15, 45, 135, 405, 1215, 3645, 10935, 32805],original = 5) == 10\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],original = 8) == 128\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240],original = 10) == 20480\n assert candidate(nums = [11, 22, 44, 88, 176, 352, 704],original = 11) == 1408\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512],original = 2) == 1024\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, 3, 3],original = 3) == 6\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683],original = 3) == 6\n assert candidate(nums = [14, 28, 56, 112, 224, 448, 896, 1792, 3584],original = 14) == 7168\n"}, "metadata": {"canonical_parameter_names": ["nums", "original"], "leetcode_dataset_entry_point": "Solution().findFinalValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findFinalValue(int[] nums, int original) {", "container": "Solution", "callable": "findFinalValue", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "original", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2155, "task_id": "all-divisions-with-the-highest-score-of-a-binary-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary array nums of length n. nums can be divided at index i (where 0 <= i <= n) into two arrays (possibly empty) numsleft and numsright:\n\nnumsleft has all the elements of nums between index 0 and i - 1 (inclusive), while numsright has all the elements of nums between index i and n - 1 (inclusive).\nIf i == 0, numsleft is empty, while numsright has all the elements of nums.\nIf i == n, numsleft has all the elements of nums, while numsright is empty.\n\nThe division score of an index i is the sum of the number of 0's in numsleft and the number of 1's in numsright.\nReturn all distinct indices that have the highest possible division score. You may return the answer in any order.\n \nExample 1:\n\nInput: nums = [0,0,1,0]\nOutput: [2,4]\nExplanation: Division at index\n- 0: numsleft is []. numsright is [0,0,1,0]. The score is 0 + 1 = 1.\n- 1: numsleft is [0]. numsright is [0,1,0]. The score is 1 + 1 = 2.\n- 2: numsleft is [0,0]. numsright is [1,0]. The score is 2 + 1 = 3.\n- 3: numsleft is [0,0,1]. numsright is [0]. The score is 2 + 0 = 2.\n- 4: numsleft is [0,0,1,0]. numsright is []. The score is 3 + 0 = 3.\nIndices 2 and 4 both have the highest possible division score 3.\nNote the answer [4,2] would also be accepted.\nExample 2:\n\nInput: nums = [0,0,0]\nOutput: [3]\nExplanation: Division at index\n- 0: numsleft is []. numsright is [0,0,0]. The score is 0 + 0 = 0.\n- 1: numsleft is [0]. numsright is [0,0]. The score is 1 + 0 = 1.\n- 2: numsleft is [0,0]. numsright is [0]. The score is 2 + 0 = 2.\n- 3: numsleft is [0,0,0]. numsright is []. The score is 3 + 0 = 3.\nOnly index 3 has the highest possible division score 3.\n\nExample 3:\n\nInput: nums = [1,1]\nOutput: [0]\nExplanation: Division at index\n- 0: numsleft is []. numsright is [1,1]. The score is 0 + 2 = 2.\n- 1: numsleft is [1]. numsright is [1]. The score is 0 + 1 = 1.\n- 2: numsleft is [1,1]. numsright is []. The score is 0 + 0 = 0.\nOnly index 0 has the highest possible division score 2.\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\nnums[i] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 1]) == [4]\n assert candidate(nums = [0, 0, 0]) == [3]\n assert candidate(nums = [0, 0, 1, 0]) == [2, 4]\n assert candidate(nums = [0, 1, 0, 1, 0, 1]) == [1, 3, 5]\n assert candidate(nums = [1, 0, 1, 0, 1]) == [0, 2, 4]\n assert candidate(nums = [1, 1]) == [0]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0]) == [7]\n assert candidate(nums = [0, 1, 0, 1, 0]) == [1, 3, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == [0]\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == [6, 16]\n assert candidate(nums = [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1]) == [4, 8]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == [0, 12, 24]\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0]) == [0, 2, 4, 6, 8]\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, 5, 9, 13, 17, 21, 25, 29]\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == [5, 11, 17]\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, 0, 0]) == [0, 8, 16, 24]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1]) == [6, 18, 30]\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, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 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, 1, 0, 1]) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]\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, 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(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 = [1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == [0]\n assert candidate(nums = [1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1]) == [16]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]) == [0]\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, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 1, 0, 0]) == [6, 10]\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1]) == [4]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [10]\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == [1, 5, 9, 13, 17]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]) == [3, 17]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == [22]\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, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0]) == [3, 9]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 3, 5, 7, 9, 11, 13, 15, 17]\n assert candidate(nums = [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, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == [0, 12]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == [5]\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [0, 2, 4, 6, 8, 10, 12, 14, 16]\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == [2, 6, 10, 14]\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 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, 0, 1, 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, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0]) == [0, 12, 24]\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == [2]\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]) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1]) == [0, 8]\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]) == [4, 12, 20, 28]\n assert candidate(nums = [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, 0, 0]) == [12]\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0]) == [3]\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0]) == [30]\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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [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, 52, 54, 56, 58, 60, 62, 64, 66, 68]\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [0, 2, 4, 6, 8, 10]\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == [0, 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, 0, 0, 0, 0, 0, 0]) == [0]\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, 5, 9, 13, 17, 21, 25]\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]) == [30]\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]) == [2, 6, 10, 14, 18, 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]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [15]\n assert candidate(nums = [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]) == [38]\n assert candidate(nums = [0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0]) == [22]\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, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == [4, 12]\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == [0, 4, 8, 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]) == [0]\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1]\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0]) == [6]\n assert candidate(nums = [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]) == [9]\n assert candidate(nums = [0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0]) == [2]\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, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [20]\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == [3, 7, 11, 15, 19]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0]) == [5, 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, 0, 1]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33]\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, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n assert candidate(nums = [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]) == [15]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]) == [8]\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]) == [3, 9, 15, 21]\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1]) == [0, 10]\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, 4, 8, 12, 16, 20]\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]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]\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, 1, 1]) == [31]\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1]) == [0, 8, 10]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0]\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]) == [3, 7, 11, 15, 19, 23, 27]\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [2, 6, 10]\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, 3, 5, 7, 9, 11, 13, 15, 17, 19]\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, 1]) == [27]\n assert candidate(nums = [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, 0, 0, 0, 0, 0]) == [0, 16]\n assert candidate(nums = [0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1]) == [2]\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == [0, 8, 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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]\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, 1, 1]) == [0, 4, 8, 12, 16, 20, 24, 28]\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == [0, 6, 12]\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1]) == [0, 8, 12]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxScoreIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List maxScoreIndices(int[] nums) {", "container": "Solution", "callable": "maxScoreIndices", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2156, "task_id": "find-substring-with-given-hash-value", "difficulty": "Hard", "problem_description": "The hash of a 0-indexed string s of length k, given integers p and m, is computed using the following function:\n\nhash(s, p, m) = (val(s[0]) * p0 + val(s[1]) * p1 + ... + val(s[k-1]) * pk-1) mod m.\n\nWhere val(s[i]) represents the index of s[i] in the alphabet from val('a') = 1 to val('z') = 26.\nYou are given a string s and the integers power, modulo, k, and hashValue. Return sub, the first substring of s of length k such that hash(sub, power, modulo) == hashValue.\nThe test cases will be generated such that an answer always exists.\nA substring is a contiguous non-empty sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"leetcode\", power = 7, modulo = 20, k = 2, hashValue = 0\nOutput: \"ee\"\nExplanation: The hash of \"ee\" can be computed to be hash(\"ee\", 7, 20) = (5 * 1 + 5 * 7) mod 20 = 40 mod 20 = 0. \n\"ee\" is the first substring of length 2 with hashValue 0. Hence, we return \"ee\".\n\nExample 2:\n\nInput: s = \"fbxzaad\", power = 31, modulo = 100, k = 3, hashValue = 32\nOutput: \"fbx\"\nExplanation: The hash of \"fbx\" can be computed to be hash(\"fbx\", 31, 100) = (6 * 1 + 2 * 31 + 24 * 312) mod 100 = 23132 mod 100 = 32. \nThe hash of \"bxz\" can be computed to be hash(\"bxz\", 31, 100) = (2 * 1 + 24 * 31 + 26 * 312) mod 100 = 25732 mod 100 = 32. \n\"fbx\" is the first substring of length 3 with hashValue 32. Hence, we return \"fbx\".\nNote that \"bxz\" also has a hash of 32 but it appears later than \"fbx\".\n\n \nConstraints:\n\n1 <= k <= s.length <= 2 * 104\n1 <= power, modulo <= 109\n0 <= hashValue < modulo\ns consists of lowercase English letters only.\nThe test cases are generated such that an answer always exists.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zxcvbnm\",power = 10,modulo = 1000000007,k = 4,hashValue = 807311072) == \"vbnm\"\n assert candidate(s = \"abracadabra\",power = 5,modulo = 11,k = 3,hashValue = 4) == \"dab\"\n assert candidate(s = \"zzzzzzzzzz\",power = 29,modulo = 1000000007,k = 4,hashValue = 78608631) == \"zzzz\"\n assert candidate(s = \"leetcode\",power = 7,modulo = 20,k = 2,hashValue = 0) == \"ee\"\n assert candidate(s = \"fbxzaad\",power = 31,modulo = 100,k = 3,hashValue = 32) == \"fbx\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",power = 26,modulo = 101,k = 5,hashValue = 53) == \"vwxyz\"\n assert candidate(s = \"a\",power = 1,modulo = 1,k = 1,hashValue = 0) == \"a\"\n assert candidate(s = \"zaz\",power = 26,modulo = 29,k = 2,hashValue = 27) == \"az\"\n assert candidate(s = \"a\",power = 13,modulo = 97,k = 1,hashValue = 1) == \"a\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",power = 13,modulo = 50,k = 5,hashValue = 37) == \"klmno\"\n assert candidate(s = \"abcde\",power = 2,modulo = 11,k = 3,hashValue = 7) == \"cde\"\n assert candidate(s = \"a\",power = 5,modulo = 13,k = 1,hashValue = 1) == \"a\"\n assert candidate(s = \"mmcp\",power = 13,modulo = 457,k = 2,hashValue = 33) == \"cp\"\n assert candidate(s = \"thisisaverylongstringthatweneedtofindasubstringwithagivenhashvalue\",power = 5,modulo = 1000000009,k = 12,hashValue = 543) == \"venhashvalue\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 29,modulo = 101,k = 20,hashValue = 95) == \"zzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"hellothereeveryone\",power = 37,modulo = 101,k = 6,hashValue = 74) == \"eryone\"\n assert candidate(s = \"complexityisimportantinbigdatatechnology\",power = 19,modulo = 1000000009,k = 8,hashValue = 543210987) == \"chnology\"\n assert candidate(s = \"zxcvbnmasdfghjklqwertyuiop\",power = 29,modulo = 1000000007,k = 6,hashValue = 563872) == \"tyuiop\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 19,modulo = 1000000007,k = 26,hashValue = 267973410) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",power = 17,modulo = 1000000009,k = 7,hashValue = 123456789) == \"wxxyyzz\"\n assert candidate(s = \"abababababababababababababababababababababababababab\",power = 5,modulo = 1000000003,k = 11,hashValue = 543210987) == \"bababababab\"\n assert candidate(s = \"a\",power = 7,modulo = 13,k = 1,hashValue = 1) == \"a\"\n assert candidate(s = \"mississippi\",power = 19,modulo = 1000000007,k = 4,hashValue = 683) == \"ippi\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 11,modulo = 79,k = 20,hashValue = 10) == \"zzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",power = 19,modulo = 83,k = 15,hashValue = 28) == \"abcabcabcabcabc\"\n assert candidate(s = \"lkjihgfedcbazyxwvutsrqponml\",power = 41,modulo = 1000000009,k = 14,hashValue = 102474831) == \"yxwvutsrqponml\"\n assert candidate(s = \"ababababababababababababababababababababababababababababababab\",power = 11,modulo = 1000000007,k = 10,hashValue = 543210987) == \"ababababab\"\n assert candidate(s = \"powerrangers\",power = 29,modulo = 97,k = 4,hashValue = 53) == \"gers\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 17,modulo = 53,k = 10,hashValue = 49) == \"qrstuvwxyz\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",power = 2,modulo = 13,k = 8,hashValue = 7) == \"bcdefghi\"\n assert candidate(s = \"mmmmmmmmmabcdefghimnopqrstuvwxyz\",power = 37,modulo = 1000000007,k = 8,hashValue = 987654321) == \"stuvwxyz\"\n assert candidate(s = \"thisisaverylongstringthatweneedtofindthesubstringwiththespecifiedhashvalue\",power = 13,modulo = 1000000007,k = 20,hashValue = 345234657) == \"hespecifiedhashvalue\"\n assert candidate(s = \"thisisjustanexampleofalongsstringwithseveralhashvalues\",power = 3,modulo = 100,k = 4,hashValue = 15) == \"lues\"\n assert candidate(s = \"qponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\",power = 43,modulo = 1000000007,k = 22,hashValue = 872889924) == \"efghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",power = 37,modulo = 100000007,k = 50,hashValue = 876543210) == \"bbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",power = 43,modulo = 1000000007,k = 25,hashValue = 54321) == \"yxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"xylophonepianoxylophonepianoxylophonepianoxyloph\",power = 23,modulo = 1000000009,k = 9,hashValue = 765432109) == \"anoxyloph\"\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijk\",power = 19,modulo = 1000000009,k = 11,hashValue = 123456789) == \"abcdefghijk\"\n assert candidate(s = \"mississippiissi\",power = 5,modulo = 1000000007,k = 7,hashValue = 432109876) == \"ppiissi\"\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\",power = 17,modulo = 1000000007,k = 12,hashValue = 617980928) == \"bcbcbcbcbcbc\"\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",power = 37,modulo = 1000000007,k = 15,hashValue = 756839574) == \"soverthelazydog\"\n assert candidate(s = \"mississippiisaverypopularstring\",power = 23,modulo = 107,k = 9,hashValue = 62) == \"larstring\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",power = 29,modulo = 999983,k = 9,hashValue = 456789) == \"bcdefghij\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 10,modulo = 10007,k = 10,hashValue = 7007) == \"zzzzzzzzzz\"\n assert candidate(s = \"abacabadabacaba\",power = 10,modulo = 61,k = 5,hashValue = 31) == \"acaba\"\n assert candidate(s = \"programmingisfun\",power = 5,modulo = 1000000009,k = 8,hashValue = 77777777) == \"ingisfun\"\n assert candidate(s = \"thisisaverylongstringthatwillbeusedtohashandfindthesubstring\",power = 19,modulo = 1000003,k = 12,hashValue = 876543) == \"thesubstring\"\n assert candidate(s = \"xyzabcxyz\",power = 17,modulo = 101,k = 4,hashValue = 70) == \"cxyz\"\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",power = 11,modulo = 997,k = 12,hashValue = 896) == \"erthelazydog\"\n assert candidate(s = \"banana\",power = 5,modulo = 10007,k = 2,hashValue = 22) == \"na\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",power = 19,modulo = 47,k = 15,hashValue = 29) == \"onmlkjihgfedcba\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 31,modulo = 1000000007,k = 5,hashValue = 35852459) == \"zzzzz\"\n assert candidate(s = \"kjfslafjslkafjslkfjslkfjlskjflskjflskfjslkfjslkfjslk\",power = 11,modulo = 1000000001,k = 8,hashValue = 987654321) == \"slkfjslk\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",power = 13,modulo = 1000000007,k = 20,hashValue = 689648594) == \"tsrqponmlkjihgfedcba\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 23,modulo = 999983,k = 15,hashValue = 123456) == \"zzzzzzzzzzzzzzz\"\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",power = 41,modulo = 1000000009,k = 6,hashValue = 345678) == \"azydog\"\n assert candidate(s = \"thisisaverylongstringthatcontainsmanywordsandcharactersforhashing\",power = 41,modulo = 1000000009,k = 18,hashValue = 897530987) == \"aractersforhashing\"\n assert candidate(s = \"thepowerofhashing\",power = 17,modulo = 10007,k = 9,hashValue = 9999) == \"ofhashing\"\n assert candidate(s = \"racecar\",power = 17,modulo = 1000000009,k = 3,hashValue = 113) == \"car\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",power = 23,modulo = 1000000009,k = 21,hashValue = 850494334) == \"ghijklmnopqrstuvwxyza\"\n assert candidate(s = \"racecarannakayak\",power = 37,modulo = 109,k = 7,hashValue = 87) == \"nakayak\"\n assert candidate(s = \"rollinghashingisaveryefficientalgorithm\",power = 29,modulo = 1000000007,k = 10,hashValue = 987654321) == \"talgorithm\"\n assert candidate(s = \"hashfunctionexample\",power = 31,modulo = 1000000007,k = 13,hashValue = 234567890) == \"nctionexample\"\n assert candidate(s = \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\",power = 7,modulo = 13,k = 5,hashValue = 5) == \"eabcd\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",power = 31,modulo = 1000000009,k = 10,hashValue = 109876543) == \"abcdefghij\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 27,modulo = 10007,k = 26,hashValue = 4750) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"thisproblemisfunandchallengingandfunandchallenging\",power = 41,modulo = 1000000011,k = 14,hashValue = 543210987) == \"andchallenging\"\n assert candidate(s = \"jqwertyuiopasdfghjklzxcvbnmnbvcxzlkjhgfdsapoiuytrewq\",power = 17,modulo = 1000000009,k = 15,hashValue = 765432109) == \"gfdsapoiuytrewq\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 1000000007,modulo = 1000000009,k = 10,hashValue = 999999939) == \"zzzzzzzzzz\"\n assert candidate(s = \"acacacacacacacacacacacacacacacacacacacacacacacacacacac\",power = 19,modulo = 1000000007,k = 12,hashValue = 876543210) == \"acacacacacac\"\n assert candidate(s = \"loremipsumdolorsitametloremipsumdolorsitametlorem\",power = 43,modulo = 1000000017,k = 15,hashValue = 432109876) == \"lorsitametlorem\"\n assert candidate(s = \"mnopqrstuvwxyzaabcdefghijklmnopqr\",power = 37,modulo = 1000000007,k = 25,hashValue = 519164833) == \"uvwxyzaabcdefghijklmnopqr\"\n assert candidate(s = \"thesoundofsilencethesoundofsilencethesoundofsilence\",power = 37,modulo = 1000000013,k = 13,hashValue = 654321098) == \"oundofsilence\"\n assert candidate(s = \"ababababababababababababababababababababababababab\",power = 23,modulo = 29,k = 7,hashValue = 17) == \"bababab\"\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzxy\",power = 31,modulo = 1000000009,k = 15,hashValue = 987654321) == \"zzzzzzzzzzzzzxy\"\n assert candidate(s = \"aaaaabbbbbccccdddddeeeeefffffggggghhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\",power = 11,modulo = 100000007,k = 13,hashValue = 111222) == \"mmmnnnnnooooo\"\n assert candidate(s = \"thisisaverylongstringthatshouldworkwiththehashingfunctioncorrectly\",power = 13,modulo = 107,k = 25,hashValue = 67) == \"ehashingfunctioncorrectly\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",power = 97,modulo = 10007,k = 6,hashValue = 10001) == \"cdabcd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 17,modulo = 89,k = 10,hashValue = 67) == \"qrstuvwxyz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",power = 7,modulo = 1000000009,k = 15,hashValue = 324434711) == \"sttuuvvwwxxyyzz\"\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\",power = 11,modulo = 97,k = 6,hashValue = 76) == \"xyzzxy\"\n assert candidate(s = \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\",power = 5,modulo = 17,k = 14,hashValue = 11) == \"abcdeabcdeabcd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 13,modulo = 101,k = 10,hashValue = 97) == \"qrstuvwxyz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 13,modulo = 101,k = 10,hashValue = 60) == \"xyzabcdefg\"\n assert candidate(s = \"hashingisawesome\",power = 37,modulo = 1000000007,k = 7,hashValue = 88888888) == \"awesome\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",power = 23,modulo = 41,k = 7,hashValue = 35) == \"cdefghi\"\n assert candidate(s = \"thefastbrownfoxjumpedoverthelazydog\",power = 43,modulo = 1000000007,k = 5,hashValue = 234567) == \"zydog\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",power = 26,modulo = 1000000009,k = 26,hashValue = 987654321) == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 1000000007,modulo = 1000000009,k = 10,hashValue = 876543210) == \"qrstuvwxyz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 31,modulo = 1000000007,k = 26,hashValue = 680151233) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"onetwothreefourfivesixseveneightnineseveneightsixfiv foureventhreetwooneonetwothreefourfivesix\",power = 13,modulo = 103,k = 8,hashValue = 45) == \"veneight\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",power = 5,modulo = 1000000009,k = 10,hashValue = 740006228) == \"cabcabcabc\"\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",power = 33,modulo = 1000000007,k = 4,hashValue = 123) == \"ydog\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",power = 5,modulo = 1000,k = 7,hashValue = 500) == \"wxxyyzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 31,modulo = 1000000007,k = 15,hashValue = 123456789) == \"zzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\",power = 41,modulo = 997,k = 12,hashValue = 500) == \"abcdefabcdef\"\n"}, "metadata": {"canonical_parameter_names": ["s", "power", "modulo", "k", "hashValue"], "leetcode_dataset_entry_point": "Solution().subStrHash", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String subStrHash(String s, int power, int modulo, int k, int hashValue) {", "container": "Solution", "callable": "subStrHash", "parameters": [{"name": "s", "type": "String"}, {"name": "power", "type": "int"}, {"name": "modulo", "type": "int"}, {"name": "k", "type": "int"}, {"name": "hashValue", "type": "int"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2157, "task_id": "groups-of-strings", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array of strings words. Each string consists of lowercase English letters only. No letter occurs more than once in any string of words.\nTwo strings s1 and s2 are said to be connected if the set of letters of s2 can be obtained from the set of letters of s1 by any one of the following operations:\n\nAdding exactly one letter to the set of the letters of s1.\nDeleting exactly one letter from the set of the letters of s1.\nReplacing exactly one letter from the set of the letters of s1 with any letter, including itself.\n\nThe array words can be divided into one or more non-intersecting groups. A string belongs to a group if any one of the following is true:\n\nIt is connected to at least one other string of the group.\nIt is the only string present in the group.\n\nNote that the strings in words should be grouped in such a manner that a string belonging to a group cannot be connected to a string present in any other group. It can be proved that such an arrangement is always unique.\nReturn an array ans of size 2 where:\n\nans[0] is the maximum number of groups words can be divided into, and\nans[1] is the size of the largest group.\n\n \nExample 1:\n\nInput: words = [\"a\",\"b\",\"ab\",\"cde\"]\nOutput: [2,3]\nExplanation:\n- words[0] can be used to obtain words[1] (by replacing 'a' with 'b'), and words[2] (by adding 'b'). So words[0] is connected to words[1] and words[2].\n- words[1] can be used to obtain words[0] (by replacing 'b' with 'a'), and words[2] (by adding 'a'). So words[1] is connected to words[0] and words[2].\n- words[2] can be used to obtain words[0] (by deleting 'b'), and words[1] (by deleting 'a'). So words[2] is connected to words[0] and words[1].\n- words[3] is not connected to any string in words.\nThus, words can be divided into 2 groups [\"a\",\"b\",\"ab\"] and [\"cde\"]. The size of the largest group is 3. \n\nExample 2:\n\nInput: words = [\"a\",\"ab\",\"abc\"]\nOutput: [1,3]\nExplanation:\n- words[0] is connected to words[1].\n- words[1] is connected to words[0] and words[2].\n- words[2] is connected to words[1].\nSince all strings are connected to each other, they should be grouped together.\nThus, the size of the largest group is 3.\n\n \nConstraints:\n\n1 <= words.length <= 2 * 104\n1 <= words[i].length <= 26\nwords[i] consists of lowercase English letters only.\nNo letter occurs more than once in words[i].\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'bcd', 'ace', 'bce']) == [1, 4]\n assert candidate(words = ['abcd', 'ac', 'ab', 'abc', 'a']) == [1, 5]\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde']) == [1, 7]\n assert candidate(words = ['a', 'b', 'ab', 'cde']) == [2, 3]\n assert candidate(words = ['abcd', 'ab', 'cd', 'a', 'b', 'c', 'd']) == [2, 6]\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g']) == [1, 7]\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == [9, 1]\n assert candidate(words = ['a', 'ab', 'abc']) == [1, 3]\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']) == [1, 26]\n assert candidate(words = ['abc', 'abcd', 'abde', 'acde', 'bcde']) == [1, 5]\n assert candidate(words = ['abc', 'bcd', 'ace', 'xyz']) == [2, 3]\n assert candidate(words = ['xyz', 'xy', 'yz', 'xz', 'x', 'y', 'z']) == [1, 7]\n assert candidate(words = ['abc', 'bcd', 'ace', 'bd', 'abcde']) == [2, 4]\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijl', 'abcdefghijkml', 'abcdefghijkmn', 'abcdefghijkop', 'abcdefghijkmnop', 'abcdefghijkmnopq']) == [5, 30]\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn', 'jklmno', 'klmnop', 'lmnopq', 'mnopqr', 'nopqrs', 'opqrst', 'pqrstu', 'qrstuv', 'rstuvw', 'stuvwx', 'tuvwxy', 'uvwxyz']) == [1, 21]\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn', 'jklmno', 'klmnop', 'lmnopq', 'mnopqr', 'nopqrs', 'opqrst', 'pqrs']) == [2, 15]\n assert candidate(words = ['abc', 'ab', 'a', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij']) == [1, 10]\n assert candidate(words = ['pqrst', 'pqrstuvw', 'pqrstu', 'pqrs', 'pqr', 'pq', 'p', 'qrstuv', 'qrstu', 'qrst', 'qrs', 'qr', 'q', 'rstuv', 'rstu', 'rst', 'rs', 'r', 'stuv', 'stu', 'st', 's', 'tuv', 'tu', 't', 'uv', 'u', 'v']) == [2, 27]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu']) == [2, 4]\n assert candidate(words = ['abc', 'abcd', 'ab', 'a', 'bc', 'b', 'c', 'ac', 'd', 'de', 'def', 'defg', 'defgh', 'defghi', 'defghij', 'defghijk', 'defghijkl', 'defghijklm', 'defghijklmn', 'defghijklmno', 'defghijklmnop', 'defghijklmnopq', 'defghijklmnopqr', 'defghijklmnopqrs', 'defghijklmnopqrst', 'defghijklmnopqrstu', 'defghijklmnopqrstuv', 'defghijklmnopqrstuvw', 'defghijklmnopqrstuvwx', 'defghijklmnopqrstuvwxy', 'defghijklmnopqrstuvwxyz']) == [1, 31]\n assert candidate(words = ['ab', 'ac', 'ad', 'bc', 'bd', 'cd', 'abc', 'abd', 'acd', 'bcd', 'abcd', 'abcde', 'abcf', 'abcdg', 'abde', 'acde', 'bcde', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz']) == [4, 17]\n assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'x', 'y', 'z', 'xyza', 'xyzab', 'xyzabc', 'xyzabcd', 'xyzabcde', 'xyzabcdef', 'xyzabcdefg', 'xyzabcdefgh', 'xyzabcdefghi', 'xyzabcdefghij', 'xyzabcdefghijk', 'xyzabcdefghijkl', 'xyzabcdefghijklm', 'xyzabcdefghijklmn', 'xyzabcdefghijklmno', 'xyzabcdefghijklmnop', 'xyzabcdefghijklmnopq', 'xyzabcdefghijklmnopqr', 'xyzabcdefghijklmnopqrst', 'xyzabcdefghijklmnopqrstu', 'xyzabcdefghijklmnopqrstuv', 'xyzabcdefghijklmnopqrstuvw', 'xyzabcdefghijklmnopqrstuvwxy', 'xyzabcdefghijklmnopqrstuvwxyz']) == [2, 25]\n assert candidate(words = ['ab', 'ac', 'ad', 'bc', 'bd', 'cd', 'abcd', 'abef', 'acde', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz']) == [3, 24]\n assert candidate(words = ['abc', 'abd', 'abe', 'abf', 'abg', 'abh', 'abi', 'abj', 'abk', 'abl', 'abm', 'abn', 'abo', 'abp', 'abq', 'abr', 'abs', 'abt', 'abu', 'abv', 'abw', 'abx', 'aby', 'abz', 'acb', 'adb', 'aeb', 'afb', 'agb', 'ahb', 'aib', 'ajb', 'akb', 'alb', 'amb', 'anb', 'aob', 'apb', 'aqb', 'arb', 'asb', 'atb', 'aub', 'avb', 'awb', 'axb', 'ayb', 'azb']) == [1, 48]\n assert candidate(words = ['abcd', 'abcf', 'acdf', 'bcdf', 'abcdg', 'abcfg', 'abdfg', 'acdfg', 'bcdfg', 'abcdef', 'abcdfg', 'abcfgh', 'abcdefg', 'abcdefh', 'abcddef', 'abcedef', 'abcfdef', 'abcdefg', 'abcdefh', 'abcdefi', 'abcdefj', 'abcdefk', 'abcdefl', 'abcdefm', 'abcdefn', 'abcdefo', 'abcdefp', 'abcdefq', 'abcdefr', 'abcdefs', 'abcdeft', 'abcdefu', 'abcdefv', 'abcdefw', 'abcdefx', 'abcdefy', 'abcdefz']) == [1, 37]\n assert candidate(words = ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh']) == [1, 9]\n assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'x', 'y', 'z', 'abc', 'ab', 'ac', 'bc', 'a', 'b', 'c', 'abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmnop']) == [2, 30]\n assert candidate(words = ['xyz', 'xy', 'yz', 'xz', 'x', 'y', 'z', 'xyw', 'yzw', 'xzw', 'w', 'xyzw']) == [1, 12]\n assert candidate(words = ['abc', 'ac', 'ab', 'b', 'c', 'bcd', 'bc', 'cd', 'd', 'abcd', 'abdc', 'bacd', 'cabd', 'acbd', 'bcad', 'bcda']) == [1, 16]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqr', 'abcdefghijklmnopq', 'abcdefghijklmnop', 'abcdefghijklmno']) == [3, 4]\n assert candidate(words = ['abcdefg', 'abc', 'def', 'ghijkl', 'mnopqr', 'stuv', 'wxyz', 'abcdefghij']) == [8, 1]\n assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'a', 'b', 'c', 'abc', 'abcd']) == [3, 4]\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde', 'abcdf', 'abcef', 'abdef', 'acdef', 'bcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz']) == [2, 20]\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd', 'efghi', 'jklmn', 'opqrs', 'tuvwx', 'yzabc', 'defgh', 'ijklm', 'nopqr', 'stuvw', 'xyzab', 'cdefg', 'hijkl', 'mnopq', 'rstuv', 'wxyza', 'bcdef', 'ghijk', 'lmnop', 'opqrs', 'tuvwx', 'yzabc']) == [11, 22]\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz', 'abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab']) == [14, 3]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyzq', 'abcdefghijklmnopqrstuvwxyzp', 'abcdefghijklmnopqrstuvwxyzr', 'abcdefghijklmnopqrstuvwxyzs']) == [1, 5]\n assert candidate(words = ['abcd', 'abcf', 'abdf', 'acdf', 'bcdf', 'abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn', 'jklmno', 'klmnop', 'lmnopq', 'mnopqr', 'nopqrs', 'opqrst', 'pqrstu', 'qrstuv', 'rstuvw', 'stuvwx', 'tuvwxy', 'uvwxy']) == [2, 21]\n assert candidate(words = ['pqr', 'pq', 'pr', 'qr', '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']) == [1, 30]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw']) == [1, 4]\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaaa', 'aaaaaaaaaaaa', 'aaaaaaaaaaaaa', 'aaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']) == [1, 31]\n assert candidate(words = ['abcd', 'abef', 'acgh', 'bcdf', 'cdef', 'efgh', 'efgi', 'efgj', 'efgk', 'efgl', 'efgm', 'efgn', 'efgo', 'efgp', 'efgq', 'efgr', 'efgs', 'efgt', 'efgu', 'efgv', 'efgw', 'efgx', 'efgy', 'efgz']) == [4, 19]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqr', 'abcdefghijklmnopq', 'abcdefghijklmnop', 'abcdefghijklmno', 'abcdefghijklmn', 'abcdefghijklm', 'abcdefghijkl', 'abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a']) == [2, 18]\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']) == [1, 26]\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde', 'abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde']) == [1, 14]\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']) == [1, 30]\n assert candidate(words = ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstvwxy', 'abcdefghijklmnopqrstuvwxyz']) == [3, 24]\n assert candidate(words = ['abcdef', 'abc', 'def', 'abcd', 'abef', 'acdf', 'bcde', 'abcf', 'abcdg', 'abcde', 'abcdefg']) == [2, 10]\n assert candidate(words = ['mnop', 'mno', 'mnp', 'mop', 'nop', 'npp', 'ppp', 'pp', 'p', 'z', 'zz', 'zzz', 'zzzz', 'zzzzz', 'zzzzzz', 'zzzzzzz', 'zzzzzzzz', 'zzzzzzzzz', 'zzzzzzzzzz']) == [1, 19]\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcdefghi', 'jklmnopqr', 'stuvwxyz', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'z', 'abcdefghijkl', 'mnopqrstu', 'vwxyz', 'abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yz']) == [18, 4]\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzab', 'cdefgh', 'ijklmn', 'opqrst', 'uvwxyl', 'zabcde', 'fghijk', 'lmnopq', 'rstuvw', 'xylzab', 'cdefgh', 'ijklmn', 'opqrst', 'vwxyza', 'yzabcd', 'efghij', 'klmnop', 'qrstuv', 'wxylza', 'bcdefg', 'hijklm', 'nopqrs', 'tuvwxy', 'zabcde', 'fghijk', 'lmnopq', 'rstuvw', 'wxylza', 'cdefgh', 'ijklmn', 'opqrst', 'vwxyza', 'yzabcd']) == [15, 9]\n assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'x', 'y', 'z', 'xyza', 'xyzb', 'xyzc', 'xyzd', 'xyze', 'xyzf', 'xyzg', 'xyzh', 'xyzi', 'xyzj', 'xyzk', 'xyzl', 'xyzm', 'xyzn', 'xyzo', 'xyzp', 'xyzq', 'xyxr', 'xyxs', 'xyxt', 'xyxu', 'xyxv', 'xyxw', 'xyxx', 'xyxy', 'xyxz']) == [1, 33]\n assert candidate(words = ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz']) == [2, 15]\n assert candidate(words = ['abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f', 'g']) == [1, 13]\n assert candidate(words = ['abc', 'abd', 'acd', 'bcd', 'abcde', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij']) == [2, 6]\n assert candidate(words = ['abcdef', 'abcdeg', 'abcef', 'bcdef', 'acdef', 'abdef', 'abcdf', 'abcdg', 'abc', 'ab', 'ac', 'ad', 'ae', 'af', 'ag', 'a', 'b', 'c', 'd', 'e', 'f', 'g']) == [2, 14]\n assert candidate(words = ['ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak', 'al', 'am', 'an', 'ao', 'ap', 'aq', 'ar', 'as', 'at', 'au', 'av', 'aw', 'ax', 'ay', 'az', 'ba', 'ca', 'da', 'ea', 'fa', 'ga', 'ha', 'ia', 'ja', 'ka', 'la', 'ma', 'na', 'oa', 'pa', 'qa', 'ra', 'sa', 'ta', 'ua', 'va', 'wa', 'xa', 'ya', 'za']) == [1, 50]\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy']) == [1, 25]\n assert candidate(words = ['abcdef', 'abcde', 'abcef', 'abdef', 'acdef', 'bcdef', 'abcdefg', 'abcdefgh', 'abcdefghi']) == [1, 9]\n assert candidate(words = ['a', 'b', 'c', 'ab', 'bc', 'ac', 'abc', 'abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz', 'mnopqrstuvwxy', 'mnopqrstuvwx', 'mnopqrstuvw', 'mnopqrstuv', 'mnopqrstu', 'mnopqrst', 'mnopqr', 'mnopq', 'mnop', 'mon', 'mo', 'm', 'nopqrstuvwxyz', 'nopqrstuvwx', 'nopqrstuvw', 'nopqrstuv', 'nopqrstu', 'nopqrst', 'nopqr', 'nopq', 'nop', 'no', 'n', 'opqrstuvwxyz', 'opqrstuvwx', 'opqrstuvw', 'opqrstuv', 'opqrstu', 'opqrst', 'opqr', 'opq', 'op', 'o', 'pqrstuvwxyz', 'pqrstuvwx', 'pqrstuvw', 'pqrstuv', 'pqrstu', 'pqrs', 'pqr', 'pq', 'p']) == [3, 42]\n assert candidate(words = ['mnopqr', 'mnopqs', 'mnopqt', 'mnoprs', 'mnoprt', 'mnopst', 'mnoqrs', 'mnoqrt', 'mnoqst', 'mnoprs', 'mnoprt', 'mnopst', 'mnoqrt', 'mnoqst', 'mnoprt', 'mnopst', 'mnoqrs', 'mnopqr', 'mnopqs', 'mnopqt', 'mnoprs', 'mnoprt', 'mnopst', 'mnoqrt', 'mnoqst', 'mnoprt', 'mnopst']) == [1, 27]\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde', 'bcdef', 'acdef', 'abcef', 'abdef', 'acdefg', 'bcdefg', 'cdefgh', 'defghi']) == [1, 15]\n assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'x', 'y', 'z', 'xyzu', 'xyvz', 'xywz', 'xyxz', 'xyyz', 'xyzv', 'xyzw', 'xyzz', 'xzu', 'xvz', 'xwz', 'xxz', 'xzz', 'yzu', 'yvz', 'ywz', 'yyz', 'yzv', 'yzw', 'yzz', 'zvu', 'zwv', 'zzv', 'zzw', 'zzz', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz', 'vwxyz', 'vwxyza', 'vwxyzab', 'vwxyzabc', 'vwxyzabcd']) == [1, 84]\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', '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']) == [1, 51]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstu']) == [1, 10]\n assert candidate(words = ['abc', 'abd', 'acd', 'bcd', 'abcd', 'ab', 'ac', 'ad', 'bc', 'bd', 'cd', 'a', 'b', 'c', 'd']) == [1, 15]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu']) == [1, 13]\n assert candidate(words = ['abc', 'abd', 'acd', 'bcd', 'abcd', 'ab', 'bc', 'cd', 'ac', 'a', 'b', 'c', 'd']) == [1, 13]\n assert candidate(words = ['pqrst', 'pqsrt', 'pqrst', 'pqrsu', 'pqrs', 'pqrt', 'pqst', 'prst', 'qrst', 'pq', 'qr', 'qs', 'qt', 'pr', 'ps', 'pt', 'rs', 'rt', 'st', 'p', 'q', 'r', 's', 't']) == [2, 15]\n assert candidate(words = ['abcdefghij', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', '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']) == [2, 33]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrt', 'abcdefghijklmnopqr', 'abcdefghijklmnopq', 'abcdefghijklmnop', 'abcdefghijklmno', 'abcdefghijklmn', 'abcdefghijklm', 'abcdefghijkl', 'abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a']) == [3, 20]\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().groupStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] groupStrings(String[] words) {", "container": "Solution", "callable": "groupStrings", "parameters": [{"name": "words", "type": "String[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2160, "task_id": "minimum-sum-of-four-digit-number-after-splitting-digits", "difficulty": "Easy", "problem_description": "You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.\n\nFor example, given num = 2932, you have the following digits: two 2's, one 9 and one 3. Some of the possible pairs [new1, new2] are [22, 93], [23, 92], [223, 9] and [2, 329].\n\nReturn the minimum possible sum of new1 and new2.\n \nExample 1:\n\nInput: num = 2932\nOutput: 52\nExplanation: Some possible pairs [new1, new2] are [29, 23], [223, 9], etc.\nThe minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52.\n\nExample 2:\n\nInput: num = 4009\nOutput: 13\nExplanation: Some possible pairs [new1, new2] are [0, 49], [490, 0], etc. \nThe minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13.\n\n \nConstraints:\n\n1000 <= num <= 9999\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 8765) == 125\n assert candidate(num = 2309) == 32\n assert candidate(num = 5678) == 125\n assert candidate(num = 1098) == 27\n assert candidate(num = 1111) == 22\n assert candidate(num = 3333) == 66\n assert candidate(num = 4009) == 13\n assert candidate(num = 9999) == 198\n assert candidate(num = 1000) == 1\n assert candidate(num = 2932) == 52\n assert candidate(num = 9876) == 147\n assert candidate(num = 4321) == 37\n assert candidate(num = 1234) == 37\n assert candidate(num = 2020) == 4\n assert candidate(num = 6666) == 132\n assert candidate(num = 5631) == 51\n assert candidate(num = 7899) == 168\n assert candidate(num = 8821) == 46\n assert candidate(num = 9503) == 44\n assert candidate(num = 3867) == 105\n assert candidate(num = 5555) == 110\n assert candidate(num = 6789) == 147\n assert candidate(num = 1928) == 47\n assert candidate(num = 9900) == 18\n assert candidate(num = 6600) == 12\n assert candidate(num = 4444) == 88\n assert candidate(num = 4628) == 74\n assert candidate(num = 1119) == 30\n assert candidate(num = 2229) == 51\n assert candidate(num = 6644) == 92\n assert candidate(num = 1122) == 24\n assert candidate(num = 7824) == 75\n assert candidate(num = 3223) == 46\n assert candidate(num = 1201) == 13\n assert candidate(num = 9990) == 108\n assert candidate(num = 1221) == 24\n assert candidate(num = 2345) == 59\n assert candidate(num = 1357) == 52\n assert candidate(num = 1199) == 38\n assert candidate(num = 5600) == 11\n assert candidate(num = 6677) == 134\n assert candidate(num = 2099) == 38\n assert candidate(num = 3939) == 78\n assert candidate(num = 5611) == 31\n assert candidate(num = 7700) == 14\n assert candidate(num = 7711) == 34\n assert candidate(num = 2288) == 56\n assert candidate(num = 9009) == 18\n assert candidate(num = 5647) == 103\n assert candidate(num = 3928) == 67\n assert candidate(num = 7654) == 103\n assert candidate(num = 1991) == 38\n assert candidate(num = 8231) == 41\n assert candidate(num = 1001) == 2\n assert candidate(num = 8888) == 176\n assert candidate(num = 3456) == 81\n assert candidate(num = 6084) == 54\n assert candidate(num = 7209) == 36\n assert candidate(num = 2468) == 74\n assert candidate(num = 2019) == 21\n assert candidate(num = 1129) == 31\n assert candidate(num = 5551) == 70\n assert candidate(num = 5234) == 59\n assert candidate(num = 2233) == 46\n assert candidate(num = 6633) == 72\n assert candidate(num = 1299) == 48\n assert candidate(num = 3030) == 6\n assert candidate(num = 1100) == 2\n assert candidate(num = 7891) == 97\n assert candidate(num = 3405) == 39\n assert candidate(num = 7111) == 28\n assert candidate(num = 2244) == 48\n assert candidate(num = 8800) == 16\n assert candidate(num = 1298) == 47\n assert candidate(num = 7777) == 154\n assert candidate(num = 6530) == 41\n assert candidate(num = 7770) == 84\n assert candidate(num = 9000) == 9\n assert candidate(num = 9123) == 42\n assert candidate(num = 5670) == 63\n assert candidate(num = 1179) == 36\n assert candidate(num = 1987) == 97\n assert candidate(num = 4466) == 92\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().minimumSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumSum(int num) {", "container": "Solution", "callable": "minimumSum", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2161, "task_id": "partition-array-according-to-given-pivot", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:\n\nEvery element less than pivot appears before every element greater than pivot.\nEvery element equal to pivot appears in between the elements less than and greater than pivot.\nThe relative order of the elements less than pivot and the elements greater than pivot is maintained.\n\t\nMore formally, consider every pi, pj where pi is the new position of the ith element and pj is the new position of the jth element. If i < j and both elements are smaller (or larger) than pivot, then pi < pj.\n\n\n\nReturn nums after the rearrangement.\n \nExample 1:\n\nInput: nums = [9,12,5,10,14,3,10], pivot = 10\nOutput: [9,5,3,10,10,12,14]\nExplanation: \nThe elements 9, 5, and 3 are less than the pivot so they are on the left side of the array.\nThe elements 12 and 14 are greater than the pivot so they are on the right side of the array.\nThe relative ordering of the elements less than and greater than pivot is also maintained. [9, 5, 3] and [12, 14] are the respective orderings.\n\nExample 2:\n\nInput: nums = [-3,4,3,2], pivot = 2\nOutput: [-3,2,4,3]\nExplanation: \nThe element -3 is less than the pivot so it is on the left side of the array.\nThe elements 4 and 3 are greater than the pivot so they are on the right side of the array.\nThe relative ordering of the elements less than and greater than pivot is also maintained. [-3] and [4, 3] are the respective orderings.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-106 <= nums[i] <= 106\npivot equals to an element of nums.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 0, 1, 0, 1, 0, 0],pivot = 0) == [0, 0, 0, 0, 0, 0, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1]\n assert candidate(nums = [0, 0, 1, 1, 0, 1, 0, 1, 0, 0],pivot = 1) == [0, 0, 0, 0, 0, 0, 1, 1, 1, 1]\n assert candidate(nums = [5, 4, 3, 2, 1],pivot = 3) == [2, 1, 3, 5, 4]\n assert candidate(nums = [10, 10, 10, 10],pivot = 10) == [10, 10, 10, 10]\n assert candidate(nums = [5, 5, 5, 5, 5],pivot = 5) == [5, 5, 5, 5, 5]\n assert candidate(nums = [4, 3, 2, 2, 5, 2, 3],pivot = 2) == [2, 2, 2, 4, 3, 5, 3]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 5) == [4, 3, 2, 1, 5, 10, 9, 8, 7, 6]\n assert candidate(nums = [10, 10, 10, 10, 10],pivot = 10) == [10, 10, 10, 10, 10]\n assert candidate(nums = [10, 9, 8, 7, 6],pivot = 8) == [7, 6, 8, 10, 9]\n assert candidate(nums = [5, -1, 3, 2, 4, 6, 0],pivot = 4) == [-1, 3, 2, 0, 4, 5, 6]\n assert candidate(nums = [10, 9, 8, 7, 6],pivot = 7) == [6, 7, 10, 9, 8]\n assert candidate(nums = [9, 12, 5, 10, 14, 3, 10],pivot = 10) == [9, 5, 3, 10, 10, 12, 14]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3],pivot = 3) == [3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [5, -10, 4],pivot = 5) == [-10, 4, 5]\n assert candidate(nums = [-3, 4, 3, 2],pivot = 2) == [-3, 2, 4, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pivot = 5) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5],pivot = 3) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],pivot = 0) == [-1000000, -500000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000, 500000]\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],pivot = 0) == [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 0, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100],pivot = 300) == [100, 200, 200, 100, 300, 300, 400, 500, 400]\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, 3, 9, 3, 2, 8, 5, 6, 9, 0],pivot = 5) == [3, 1, 4, 1, 2, 3, 3, 2, 3, 4, 2, 4, 3, 3, 3, 2, 0, 2, 4, 1, 1, 3, 3, 2, 0, 5, 5, 5, 5, 5, 9, 6, 9, 7, 9, 8, 6, 6, 8, 7, 9, 8, 8, 9, 7, 9, 8, 6, 9]\n assert candidate(nums = [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],pivot = 13) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 13, 14, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25]\n assert candidate(nums = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],pivot = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 19, 18, 17, 16, 15, 14, 13, 12, 11]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pivot = 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 = [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],pivot = 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]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],pivot = 50) == [10, 20, 30, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pivot = 5) == [1, 2, 3, 4, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 6, 5, 1, 0, 8, 9, 10, 11, 2, 3, 4],pivot = 5) == [1, 0, 2, 3, 4, 5, 7, 6, 8, 9, 10, 11]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 10, 20, 30, 40, 60, 70, 80, 90, 100, 50],pivot = 50) == [10, 20, 30, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [3, 6, 3, 8, 8, 6, 1, 2, 1, 2, 6, 8, 3, 6, 8, 3, 6, 3, 6, 8],pivot = 6) == [3, 3, 1, 2, 1, 2, 3, 3, 3, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8]\n assert candidate(nums = [10, 20, 5, 15, 0, 25, 10, 5, 30, 10],pivot = 10) == [5, 0, 5, 10, 10, 10, 20, 15, 25, 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],pivot = 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 = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],pivot = 0) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 5, 3, 8, 2, 9, 1, 4, 6, 0, 11, 12, 13],pivot = 5) == [3, 2, 1, 4, 0, 5, 7, 8, 9, 6, 11, 12, 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],pivot = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500],pivot = 300) == [100, 200, 200, 100, 0, -100, -200, -300, -400, -500, 300, 300, 400, 500, 400]\n assert candidate(nums = [-1, -2, -3, -4, -5, 0, 5, 4, 3, 2, 1],pivot = 0) == [-1, -2, -3, -4, -5, 0, 5, 4, 3, 2, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pivot = 500) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10],pivot = 10) == [10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 8) == [7, 6, 5, 4, 3, 2, 1, 8, 15, 14, 13, 12, 11, 10, 9]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],pivot = 5) == [4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 5, 9, 8, 7, 6, 9, 8, 7, 6]\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],pivot = 31250) == [15625, 7812, 3906, 1953, 31250, 1000000, 500000, 250000, 125000, 62500]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],pivot = 5) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 6, 7, 8, 9]\n assert candidate(nums = [-10, -20, -30, -40, -50, -40, -30, -20, -10],pivot = -30) == [-40, -50, -40, -30, -30, -10, -20, -20, -10]\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3],pivot = 2) == [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],pivot = 995) == [994, 993, 992, 991, 995, 1000, 999, 998, 997, 996]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],pivot = 5) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],pivot = 0) == [-1, -2, -3, -4, -5, 0, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pivot = 8) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],pivot = 0) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0, 9, 8, 7, 6, 5, 4, 3, 2, 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],pivot = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [7, 1, 5, 2, 3, 6, 4, 5, 8, 1, 9, 5, 5, 5],pivot = 5) == [1, 2, 3, 4, 1, 5, 5, 5, 5, 5, 7, 6, 8, 9]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],pivot = 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 = [-10, 100, -50, 50, -20, 20, -30, 30, -40, 40],pivot = 0) == [-10, -50, -20, -30, -40, 100, 50, 20, 30, 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],pivot = 15) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 20, 19, 18, 17, 16]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5],pivot = 5) == [3, 1, 4, 1, 2, 3, 2, 3, 5, 5, 5, 5, 5, 9, 6, 9, 6]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 5, 5, 5, 5, 4, 3, 2, 1, 0],pivot = 5) == [4, 3, 2, 1, 0, 5, 5, 5, 5, 5, 10, 9, 8, 7, 6]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],pivot = 3) == [2, 1, 0, -1, -2, -3, -4, -5, 3, 10, 9, 8, 7, 6, 5, 4]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30],pivot = 50) == [40, 30, 20, 10, 0, -10, -20, -30, 50, 100, 90, 80, 70, 60]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 51, 53, 55, 57, 59],pivot = 30) == [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]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],pivot = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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],pivot = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],pivot = 5) == [3, 1, 4, 1, 2, 3, 5, 5, 5, 9, 6]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 5) == [4, 3, 2, 1, 4, 3, 2, 1, 5, 5, 10, 9, 8, 7, 6, 10, 9, 8, 7, 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, 7, 8, 9, 10],pivot = 6) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10],pivot = 5) == [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7],pivot = 0) == [-1, -2, -3, -4, -5, -6, -7, 0, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 5) == [1, 2, 3, 4, 4, 3, 2, 1, 5, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6]\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],pivot = -5) == [-6, -7, -8, -9, -10, -5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 11, 13, 15, 17, 19],pivot = 10) == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 11, 13, 15, 17, 19]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],pivot = 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 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],pivot = 25) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pivot = 7) == [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],pivot = -5) == [-6, -7, -8, -9, -10, -5, -1, -2, -3, -4]\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, 3, 2, 1],pivot = 2) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1],pivot = 2) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000, 0, 1000000, -1000000],pivot = 0) == [-1000000, -500000, -250000, -1000000, 0, 1000000, 500000, 250000, 1000000]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 1, 3, 5, 7, 9],pivot = 10) == [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],pivot = 3) == [1, 2, 1, 2, 1, 2, 1, 2, 3, 3, 3, 3, 4, 5, 4, 5, 4, 5, 4, 5]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],pivot = -8) == [-9, -10, -11, -12, -13, -14, -15, -8, -1, -2, -3, -4, -5, -6, -7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100],pivot = 500) == [100, 200, 300, 400, 100, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [7, 3, 5, 10, 8, 5, 1, 9, 4, 5],pivot = 5) == [3, 1, 4, 5, 5, 5, 7, 10, 8, 9]\n assert candidate(nums = [-1000000, -500000, -250000, -125000, -62500, -31250, -15625, -7812, -3906, -1953],pivot = -125000) == [-1000000, -500000, -250000, -125000, -62500, -31250, -15625, -7812, -3906, -1953]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],pivot = 5) == [1, 2, 3, 4, 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 7],pivot = 21) == [7, 14, 7, 21, 28, 35, 42, 49, 56, 63, 70]\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],pivot = 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 = [1000000, 100000, 10000, 1000, 100, 10, 1, 0, -1, -10, -100, -1000, -10000, -100000, -1000000],pivot = 100) == [10, 1, 0, -1, -10, -100, -1000, -10000, -100000, -1000000, 100, 1000000, 100000, 10000, 1000]\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],pivot = -500) == [-600, -700, -800, -900, -1000, -500, -100, -200, -300, -400]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pivot = 10) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],pivot = 125000) == [62500, 31250, 15625, 7812, 3906, 1953, 125000, 1000000, 500000, 250000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],pivot = 70) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]\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],pivot = 15) == [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(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],pivot = 25) == [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]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]\n assert candidate(nums = [3, 8, 2, 4, 5, 7, 9, 1],pivot = 5) == [3, 2, 4, 1, 5, 8, 7, 9]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000],pivot = 7000) == [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000]\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],pivot = 300) == [100, 200, 100, 200, 100, 200, 300, 300, 300, 400, 500, 400, 500, 400, 500]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25],pivot = 25) == [5, 10, 15, 20, 5, 10, 15, 20, 25, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [5, 3, 1, 2, 4, 1, 5, 3, 2, 4, 1, 5, 3, 2, 4, 1, 5, 3, 2, 4, 1, 5, 3, 2, 4],pivot = 3) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 3, 3, 3, 3, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4]\n"}, "metadata": {"canonical_parameter_names": ["nums", "pivot"], "leetcode_dataset_entry_point": "Solution().pivotArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] pivotArray(int[] nums, int pivot) {", "container": "Solution", "callable": "pivotArray", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "pivot", "type": "int"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2162, "task_id": "minimum-cost-to-set-cooking-time", "difficulty": "Medium", "problem_description": "A generic microwave supports cooking times for:\n\nat least 1 second.\nat most 99 minutes and 99 seconds.\n\nTo set the cooking time, you push at most four digits. The microwave normalizes what you push as four digits by prepending zeroes. It interprets the first two digits as the minutes and the last two digits as the seconds. It then adds them up as the cooking time. For example,\n\nYou push 9 5 4 (three digits). It is normalized as 0954 and interpreted as 9 minutes and 54 seconds.\nYou push 0 0 0 8 (four digits). It is interpreted as 0 minutes and 8 seconds.\nYou push 8 0 9 0. It is interpreted as 80 minutes and 90 seconds.\nYou push 8 1 3 0. It is interpreted as 81 minutes and 30 seconds.\n\nYou are given integers startAt, moveCost, pushCost, and targetSeconds. Initially, your finger is on the digit startAt. Moving the finger above any specific digit costs moveCost units of fatigue. Pushing the digit below the finger once costs pushCost units of fatigue.\nThere can be multiple ways to set the microwave to cook for targetSeconds seconds but you are interested in the way with the minimum cost.\nReturn the minimum cost to set targetSeconds seconds of cooking time.\nRemember that one minute consists of 60 seconds.\n \nExample 1:\n\n\nInput: startAt = 1, moveCost = 2, pushCost = 1, targetSeconds = 600\nOutput: 6\nExplanation: The following are the possible ways to set the cooking time.\n- 1 0 0 0, interpreted as 10 minutes and 0 seconds.\n  The finger is already on digit 1, pushes 1 (with cost 1), moves to 0 (with cost 2), pushes 0 (with cost 1), pushes 0 (with cost 1), and pushes 0 (with cost 1).\n  The cost is: 1 + 2 + 1 + 1 + 1 = 6. This is the minimum cost.\n- 0 9 6 0, interpreted as 9 minutes and 60 seconds. That is also 600 seconds.\n  The finger moves to 0 (with cost 2), pushes 0 (with cost 1), moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).\n  The cost is: 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 = 12.\n- 9 6 0, normalized as 0960 and interpreted as 9 minutes and 60 seconds.\n  The finger moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).\n  The cost is: 2 + 1 + 2 + 1 + 2 + 1 = 9.\n\nExample 2:\n\n\nInput: startAt = 0, moveCost = 1, pushCost = 2, targetSeconds = 76\nOutput: 6\nExplanation: The optimal way is to push two digits: 7 6, interpreted as 76 seconds.\nThe finger moves to 7 (with cost 1), pushes 7 (with cost 2), moves to 6 (with cost 1), and pushes 6 (with cost 2). The total cost is: 1 + 2 + 1 + 2 = 6\nNote other possible ways are 0076, 076, 0116, and 116, but none of them produces the minimum cost.\n\n \nConstraints:\n\n0 <= startAt <= 9\n1 <= moveCost, pushCost <= 105\n1 <= targetSeconds <= 6039\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startAt = 1,moveCost = 2,pushCost = 1,targetSeconds = 600) == 6\n assert candidate(startAt = 0,moveCost = 1,pushCost = 2,targetSeconds = 76) == 6\n assert candidate(startAt = 2,moveCost = 2,pushCost = 3,targetSeconds = 599) == 15\n assert candidate(startAt = 6,moveCost = 3,pushCost = 2,targetSeconds = 3599) == 20\n assert candidate(startAt = 9,moveCost = 5,pushCost = 10,targetSeconds = 99) == 20\n assert candidate(startAt = 5,moveCost = 1,pushCost = 1,targetSeconds = 120) == 5\n assert candidate(startAt = 3,moveCost = 3,pushCost = 2,targetSeconds = 300) == 12\n assert candidate(startAt = 8,moveCost = 2,pushCost = 1,targetSeconds = 1) == 3\n assert candidate(startAt = 7,moveCost = 4,pushCost = 5,targetSeconds = 180) == 23\n assert candidate(startAt = 4,moveCost = 1,pushCost = 1,targetSeconds = 6039) == 5\n assert candidate(startAt = 7,moveCost = 6,pushCost = 3,targetSeconds = 59) == 18\n assert candidate(startAt = 8,moveCost = 3,pushCost = 5,targetSeconds = 3001) == 29\n assert candidate(startAt = 9,moveCost = 2,pushCost = 1,targetSeconds = 1) == 3\n assert candidate(startAt = 9,moveCost = 1,pushCost = 10,targetSeconds = 6039) == 40\n assert candidate(startAt = 4,moveCost = 30,pushCost = 20,targetSeconds = 1234) == 170\n assert candidate(startAt = 0,moveCost = 6,pushCost = 5,targetSeconds = 99) == 16\n assert candidate(startAt = 6,moveCost = 5,pushCost = 1,targetSeconds = 480) == 13\n assert candidate(startAt = 0,moveCost = 1,pushCost = 10,targetSeconds = 1000) == 44\n assert candidate(startAt = 1,moveCost = 8,pushCost = 5,targetSeconds = 1234) == 36\n assert candidate(startAt = 7,moveCost = 200,pushCost = 150,targetSeconds = 99) == 500\n assert candidate(startAt = 9,moveCost = 5,pushCost = 2,targetSeconds = 6039) == 8\n assert candidate(startAt = 8,moveCost = 2,pushCost = 2,targetSeconds = 2039) == 14\n assert candidate(startAt = 6,moveCost = 2,pushCost = 1,targetSeconds = 99) == 4\n assert candidate(startAt = 6,moveCost = 1,pushCost = 1,targetSeconds = 59) == 4\n assert candidate(startAt = 5,moveCost = 15,pushCost = 25,targetSeconds = 2345) == 160\n assert candidate(startAt = 7,moveCost = 2,pushCost = 1,targetSeconds = 99) == 4\n assert candidate(startAt = 1,moveCost = 20,pushCost = 5,targetSeconds = 900) == 60\n assert candidate(startAt = 2,moveCost = 5,pushCost = 3,targetSeconds = 5999) == 27\n assert candidate(startAt = 9,moveCost = 10,pushCost = 1,targetSeconds = 1234) == 34\n assert candidate(startAt = 2,moveCost = 1,pushCost = 5,targetSeconds = 240) == 17\n assert candidate(startAt = 9,moveCost = 5,pushCost = 3,targetSeconds = 6039) == 12\n assert candidate(startAt = 1,moveCost = 4,pushCost = 4,targetSeconds = 3159) == 28\n assert candidate(startAt = 4,moveCost = 3,pushCost = 7,targetSeconds = 60) == 20\n assert candidate(startAt = 1,moveCost = 5,pushCost = 1,targetSeconds = 9999) == inf\n assert candidate(startAt = 8,moveCost = 3,pushCost = 7,targetSeconds = 119) == 30\n assert candidate(startAt = 0,moveCost = 20,pushCost = 10,targetSeconds = 3600) == 80\n assert candidate(startAt = 3,moveCost = 2,pushCost = 3,targetSeconds = 3540) == 18\n assert candidate(startAt = 3,moveCost = 5,pushCost = 3,targetSeconds = 5999) == 27\n assert candidate(startAt = 6,moveCost = 3,pushCost = 7,targetSeconds = 2900) == 40\n assert candidate(startAt = 5,moveCost = 5,pushCost = 3,targetSeconds = 5999) == 27\n assert candidate(startAt = 0,moveCost = 7,pushCost = 2,targetSeconds = 4567) == 36\n assert candidate(startAt = 9,moveCost = 10,pushCost = 1,targetSeconds = 6039) == 4\n assert candidate(startAt = 5,moveCost = 7,pushCost = 2,targetSeconds = 5432) == 29\n assert candidate(startAt = 1,moveCost = 1,pushCost = 10,targetSeconds = 300) == 32\n assert candidate(startAt = 4,moveCost = 10,pushCost = 1,targetSeconds = 1800) == 24\n assert candidate(startAt = 8,moveCost = 10,pushCost = 5,targetSeconds = 900) == 50\n assert candidate(startAt = 5,moveCost = 7,pushCost = 4,targetSeconds = 1234) == 37\n assert candidate(startAt = 2,moveCost = 15,pushCost = 3,targetSeconds = 480) == 39\n assert candidate(startAt = 1,moveCost = 100,pushCost = 50,targetSeconds = 120) == 350\n assert candidate(startAt = 6,moveCost = 50,pushCost = 25,targetSeconds = 1800) == 200\n assert candidate(startAt = 7,moveCost = 1,pushCost = 2,targetSeconds = 6000) == 11\n assert candidate(startAt = 3,moveCost = 2,pushCost = 3,targetSeconds = 300) == 13\n assert candidate(startAt = 2,moveCost = 4,pushCost = 6,targetSeconds = 2345) == 40\n assert candidate(startAt = 0,moveCost = 1,pushCost = 1000,targetSeconds = 60) == 2002\n assert candidate(startAt = 4,moveCost = 7,pushCost = 4,targetSeconds = 360) == 26\n assert candidate(startAt = 5,moveCost = 20,pushCost = 10,targetSeconds = 3540) == 80\n assert candidate(startAt = 9,moveCost = 7,pushCost = 4,targetSeconds = 5999) == 30\n assert candidate(startAt = 4,moveCost = 3,pushCost = 4,targetSeconds = 1000) == 28\n assert candidate(startAt = 1,moveCost = 1,pushCost = 9,targetSeconds = 50) == 20\n assert candidate(startAt = 6,moveCost = 2,pushCost = 1,targetSeconds = 59) == 6\n assert candidate(startAt = 9,moveCost = 10,pushCost = 2,targetSeconds = 5959) == 28\n assert candidate(startAt = 0,moveCost = 2,pushCost = 1,targetSeconds = 120) == 7\n assert candidate(startAt = 4,moveCost = 2,pushCost = 3,targetSeconds = 60) == 10\n assert candidate(startAt = 7,moveCost = 4,pushCost = 2,targetSeconds = 60) == 12\n assert candidate(startAt = 3,moveCost = 2,pushCost = 3,targetSeconds = 4321) == 20\n assert candidate(startAt = 3,moveCost = 5,pushCost = 3,targetSeconds = 2345) == 27\n assert candidate(startAt = 8,moveCost = 2,pushCost = 3,targetSeconds = 100) == 15\n assert candidate(startAt = 7,moveCost = 9,pushCost = 3,targetSeconds = 3598) == 48\n assert candidate(startAt = 8,moveCost = 7,pushCost = 4,targetSeconds = 1000) == 44\n assert candidate(startAt = 2,moveCost = 15,pushCost = 3,targetSeconds = 123) == 39\n assert candidate(startAt = 5,moveCost = 10,pushCost = 5,targetSeconds = 3149) == 40\n assert candidate(startAt = 1,moveCost = 9,pushCost = 2,targetSeconds = 999) == 26\n assert candidate(startAt = 8,moveCost = 15,pushCost = 8,targetSeconds = 4321) == 92\n assert candidate(startAt = 1,moveCost = 1,pushCost = 1,targetSeconds = 359) == 5\n assert candidate(startAt = 5,moveCost = 1,pushCost = 10,targetSeconds = 3959) == 43\n assert candidate(startAt = 9,moveCost = 2,pushCost = 4,targetSeconds = 5999) == 20\n assert candidate(startAt = 2,moveCost = 6,pushCost = 2,targetSeconds = 5678) == 32\n assert candidate(startAt = 8,moveCost = 3,pushCost = 4,targetSeconds = 6039) == 19\n assert candidate(startAt = 3,moveCost = 5,pushCost = 3,targetSeconds = 5400) == 22\n assert candidate(startAt = 6,moveCost = 3,pushCost = 4,targetSeconds = 999) == 25\n assert candidate(startAt = 3,moveCost = 1,pushCost = 5,targetSeconds = 90) == 12\n assert candidate(startAt = 0,moveCost = 10,pushCost = 1,targetSeconds = 5999) == 34\n assert candidate(startAt = 9,moveCost = 1,pushCost = 2,targetSeconds = 123) == 9\n assert candidate(startAt = 3,moveCost = 4,pushCost = 2,targetSeconds = 300) == 14\n assert candidate(startAt = 5,moveCost = 7,pushCost = 3,targetSeconds = 1234) == 33\n assert candidate(startAt = 8,moveCost = 5,pushCost = 3,targetSeconds = 60) == 16\n assert candidate(startAt = 8,moveCost = 3,pushCost = 2,targetSeconds = 99) == 7\n assert candidate(startAt = 3,moveCost = 2,pushCost = 3,targetSeconds = 60) == 10\n assert candidate(startAt = 9,moveCost = 5,pushCost = 10,targetSeconds = 5999) == 50\n assert candidate(startAt = 8,moveCost = 3,pushCost = 5,targetSeconds = 59) == 16\n assert candidate(startAt = 2,moveCost = 4,pushCost = 5,targetSeconds = 720) == 32\n assert candidate(startAt = 4,moveCost = 4,pushCost = 4,targetSeconds = 5432) == 28\n assert candidate(startAt = 7,moveCost = 7,pushCost = 8,targetSeconds = 1) == 15\n assert candidate(startAt = 0,moveCost = 5,pushCost = 10,targetSeconds = 360) == 40\n assert candidate(startAt = 0,moveCost = 7,pushCost = 1,targetSeconds = 5999) == 25\n assert candidate(startAt = 6,moveCost = 4,pushCost = 6,targetSeconds = 200) == 30\n assert candidate(startAt = 9,moveCost = 10,pushCost = 1,targetSeconds = 5432) == 34\n assert candidate(startAt = 2,moveCost = 2,pushCost = 3,targetSeconds = 3600) == 16\n assert candidate(startAt = 5,moveCost = 10,pushCost = 5,targetSeconds = 3999) == 50\n assert candidate(startAt = 2,moveCost = 10,pushCost = 5,targetSeconds = 3660) == 50\n assert candidate(startAt = 0,moveCost = 3,pushCost = 7,targetSeconds = 90) == 20\n assert candidate(startAt = 3,moveCost = 1,pushCost = 1,targetSeconds = 599) == 6\n assert candidate(startAt = 7,moveCost = 6,pushCost = 4,targetSeconds = 4567) == 34\n assert candidate(startAt = 3,moveCost = 20,pushCost = 5,targetSeconds = 300) == 55\n assert candidate(startAt = 4,moveCost = 6,pushCost = 2,targetSeconds = 900) == 26\n assert candidate(startAt = 1,moveCost = 5,pushCost = 1,targetSeconds = 540) == 13\n assert candidate(startAt = 6,moveCost = 15,pushCost = 5,targetSeconds = 999) == 65\n assert candidate(startAt = 5,moveCost = 1,pushCost = 2,targetSeconds = 480) == 8\n assert candidate(startAt = 0,moveCost = 3,pushCost = 2,targetSeconds = 120) == 12\n assert candidate(startAt = 2,moveCost = 1,pushCost = 1,targetSeconds = 99) == 3\n assert candidate(startAt = 1,moveCost = 6,pushCost = 1,targetSeconds = 59) == 14\n assert candidate(startAt = 7,moveCost = 2,pushCost = 6,targetSeconds = 1000) == 32\n assert candidate(startAt = 4,moveCost = 4,pushCost = 3,targetSeconds = 1500) == 24\n assert candidate(startAt = 6,moveCost = 2,pushCost = 9,targetSeconds = 9999) == inf\n assert candidate(startAt = 0,moveCost = 1,pushCost = 1,targetSeconds = 1234) == 7\n assert candidate(startAt = 2,moveCost = 20,pushCost = 10,targetSeconds = 1020) == 100\n assert candidate(startAt = 4,moveCost = 8,pushCost = 2,targetSeconds = 100) == 30\n assert candidate(startAt = 7,moveCost = 5,pushCost = 2,targetSeconds = 1234) == 23\n"}, "metadata": {"canonical_parameter_names": ["startAt", "moveCost", "pushCost", "targetSeconds"], "leetcode_dataset_entry_point": "Solution().minCostSetTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {", "container": "Solution", "callable": "minCostSetTime", "parameters": [{"name": "startAt", "type": "int"}, {"name": "moveCost", "type": "int"}, {"name": "pushCost", "type": "int"}, {"name": "targetSeconds", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2163, "task_id": "minimum-difference-in-sums-after-removal-of-elements", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums consisting of 3 * n elements.\nYou are allowed to remove any subsequence of elements of size exactly n from nums. The remaining 2 * n elements will be divided into two equal parts:\n\nThe first n elements belonging to the first part and their sum is sumfirst.\nThe next n elements belonging to the second part and their sum is sumsecond.\n\nThe difference in sums of the two parts is denoted as sumfirst - sumsecond.\n\nFor example, if sumfirst = 3 and sumsecond = 2, their difference is 1.\nSimilarly, if sumfirst = 2 and sumsecond = 3, their difference is -1.\n\nReturn the minimum difference possible between the sums of the two parts after the removal of n elements.\n \nExample 1:\n\nInput: nums = [3,1,2]\nOutput: -1\nExplanation: Here, nums has 3 elements, so n = 1. \nThus we have to remove 1 element from nums and divide the array into two equal parts.\n- If we remove nums[0] = 3, the array will be [1,2]. The difference in sums of the two parts will be 1 - 2 = -1.\n- If we remove nums[1] = 1, the array will be [3,2]. The difference in sums of the two parts will be 3 - 2 = 1.\n- If we remove nums[2] = 2, the array will be [3,1]. The difference in sums of the two parts will be 3 - 1 = 2.\nThe minimum difference between sums of the two parts is min(-1,1,2) = -1. \n\nExample 2:\n\nInput: nums = [7,9,5,8,1,3]\nOutput: 1\nExplanation: Here n = 2. So we must remove 2 elements and divide the remaining array into two parts containing two elements each.\nIf we remove nums[2] = 5 and nums[3] = 8, the resultant array will be [7,9,1,3]. The difference in sums will be (7+9) - (1+3) = 12.\nTo obtain the minimum difference, we should remove nums[1] = 9 and nums[4] = 1. The resultant array becomes [7,5,8,3]. The difference in sums of the two parts is (7+5) - (8+3) = 1.\nIt can be shown that it is not possible to obtain a difference smaller than 1.\n\n \nConstraints:\n\nnums.length == 3 * n\n1 <= n <= 105\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == -80\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -180\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -18\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == -36\n assert candidate(nums = [1, 2, 3, 100, 100, 100]) == -197\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == -8\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1]) == -99999\n assert candidate(nums = [3, 1, 2]) == -1\n assert candidate(nums = [7, 9, 5, 8, 1, 3]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 50\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]) == 0\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6]) == -147\n assert candidate(nums = [5, 3, 8, 1, 4, 7, 2, 6, 9]) == -14\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == -18000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == -20\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == -80\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 160\n assert candidate(nums = [2, 1, 3, 2, 1, 3, 2, 1, 3]) == -4\n assert candidate(nums = [3, 3, 3, 2, 2, 2, 1, 1, 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]) == -54\n assert candidate(nums = [1, 2, 3, 100, 200, 300, 4, 5, 6]) == -594\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8]) == -12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == -12\n assert candidate(nums = [1, 100000, 1, 2, 100000, 2, 3, 100000, 3, 4, 100000, 4]) == -200002\n assert candidate(nums = [3, 5, 2, 8, 1, 9]) == -12\n assert candidate(nums = [6, 1, 5, 2, 4, 3]) == -4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == -100\n assert candidate(nums = [99999, 99999, 99999, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 0, 11, 13]) == -24\n assert candidate(nums = [3, 2, 1, 6, 5, 4, 9, 8, 7]) == -18\n assert candidate(nums = [1, 1, 1, 1, 100000, 100000, 100000, 100000, 100000]) == -299997\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 1, 2, 3]) == 9\n assert candidate(nums = [100000, 1, 2, 3, 100000, 4, 5, 6, 100000]) == -200000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -50\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14]) == -34\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 0\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9, 1, 4, 2, 7, 6]) == -12\n assert candidate(nums = [100000, 100000, 100000, 1, 1, 1, 100000, 100000, 100000]) == -299997\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == -1800\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == -3\n assert candidate(nums = [9, 7, 5, 3, 1, 11, 13, 15, 17, 19, 21, 23]) == -64\n assert candidate(nums = [100000, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == -99999\n assert candidate(nums = [200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100]) == -200\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995]) == -199989\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1, 10, 100]) == -110889\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == -32\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12]) == -26\n assert candidate(nums = [1, 2, 100000, 3, 100000, 4, 5, 100000, 6]) == -200000\n assert candidate(nums = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == -199998\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == -1800\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1, 10, 100, 1000, 10000, 100000]) == -218889\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 2, 4, 6]) == -18\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == -16\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == -36\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]) == -162\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5]) == -199994\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == -3200\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -180\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100]) == -200\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88]) == 16\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 5, 3, 8]) == -13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -50\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == -30\n assert candidate(nums = [30000, 20000, 10000, 50000, 40000, 60000, 90000, 80000, 70000]) == -180000\n assert candidate(nums = [1, 1, 1, 100000, 100000, 100000, 1, 1, 1]) == -299997\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 100000, 100000, 100000]) == -299997\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 100000, 100000, 100000]) == -299997\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95]) == -284\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == -300\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == -320\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == -360\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 1, 2, 3]) == -900000\n assert candidate(nums = [99999, 99998, 99997, 1, 2, 3, 4, 5, 6]) == -9\n assert candidate(nums = [1, 2, 3, 100000, 100000, 100000]) == -199997\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992]) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == -16\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1]) == -2\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == -10\n assert candidate(nums = [12345, 67890, 54321, 98765, 43210, 87654, 32109, 76543, 21098]) == -128406\n assert candidate(nums = [9, 3, 6, 3, 9, 3, 6, 3, 9, 3, 6, 3, 9, 3, 6, 3, 9, 3, 6, 3, 9, 3, 6, 3]) == -21\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 1, 2, 3, 4, 5, 6]) == 199976\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1]) == -10\n assert candidate(nums = [50, 50, 50, 1, 1, 1, 100, 100, 100]) == -297\n assert candidate(nums = [50, 25, 100, 75, 150, 125, 200, 175, 225]) == -450\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == -199998\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == -20\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 90000, 80000, 70000, 60000]) == -180000\n assert candidate(nums = [5, 4, 3, 2, 1, 9, 8, 7, 6]) == -18\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == -72\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 8, 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, 7, 2, 8, 1, 5, 9, 7, 6, 3, 128, 256, 128]) == -563\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20]) == 90\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995]) == -199989\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -18\n assert candidate(nums = [7, 3, 5, 1, 9, 4, 6, 8, 2, 10, 12, 11]) == -28\n assert candidate(nums = [1, 3, 5, 2, 4, 6]) == -7\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8]) == -15\n assert candidate(nums = [3, 1, 2, 5, 4, 6, 9, 7, 8]) == -18\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == -12\n assert candidate(nums = [100000, 100000, 1, 1, 100000, 100000, 1, 1, 100000]) == -199998\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2]) == 10\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995]) == -299984\n assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6]) == -1497\n assert candidate(nums = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == -36\n assert candidate(nums = [6, 2, 8, 4, 10, 12, 1, 3, 5, 7, 9, 11]) == -22\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 1, 2, 3]) == -900\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 1, 2, 3, 4, 5, 6]) == -100011\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumDifference(int[] nums) {", "container": "Solution", "callable": "minimumDifference", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2164, "task_id": "sort-even-and-odd-indices-independently", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules:\n\nSort the values at odd indices of nums in non-increasing order.\n\n\t\nFor example, if nums = [4,1,2,3] before this step, it becomes [4,3,2,1] after. The values at odd indices 1 and 3 are sorted in non-increasing order.\n\n\nSort the values at even indices of nums in non-decreasing order.\n\t\nFor example, if nums = [4,1,2,3] before this step, it becomes [2,1,4,3] after. The values at even indices 0 and 2 are sorted in non-decreasing order.\n\n\n\nReturn the array formed after rearranging the values of nums.\n \nExample 1:\n\nInput: nums = [4,1,2,3]\nOutput: [2,3,4,1]\nExplanation: \nFirst, we sort the values present at odd indices (1 and 3) in non-increasing order.\nSo, nums changes from [4,1,2,3] to [4,3,2,1].\nNext, we sort the values present at even indices (0 and 2) in non-decreasing order.\nSo, nums changes from [4,1,2,3] to [2,3,4,1].\nThus, the array formed after rearranging the values is [2,3,4,1].\n\nExample 2:\n\nInput: nums = [2,1]\nOutput: [2,1]\nExplanation: \nSince there is exactly one odd index and one even index, no rearrangement of values takes place.\nThe resultant array formed is [2,1], which is the same as the initial array. \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 = [1]) == [1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95]) == [96, 99, 98, 97, 100, 95]\n assert candidate(nums = [1, 3, 2, 2, 3, 1]) == [1, 3, 2, 2, 3, 1]\n assert candidate(nums = [1, 9, 3, 7, 5, 6, 2, 8, 4]) == [1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(nums = [5, 3, 2, 4, 1, 6]) == [1, 6, 2, 4, 5, 3]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70]) == [10, 60, 30, 40, 50, 20, 70]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5]) == [1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [10, 40, 30, 20, 50]\n assert candidate(nums = [4, 1, 2, 3]) == [2, 3, 4, 1]\n assert candidate(nums = [5, 3, 2, 8, 1, 4]) == [1, 8, 2, 4, 5, 3]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1, 8, 3, 6, 5, 4, 7, 2, 9, 0]\n assert candidate(nums = [2, 1]) == [2, 1]\n assert candidate(nums = [5, 6, 3, 4, 7]) == [3, 6, 5, 4, 7]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 9, 4, 7, 6, 5, 8, 3, 10, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 10, 3, 8, 5, 6, 7, 4, 9, 2]\n assert candidate(nums = [1, 9, 3, 7, 5, 11, 2, 8, 4, 6, 10, 12, 14, 13, 15]) == [1, 13, 2, 12, 3, 11, 4, 9, 5, 8, 10, 7, 14, 6, 15]\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, 19, 4, 17, 6, 15, 8, 13, 10, 11, 12, 9, 14, 7, 16, 5, 18, 3, 20, 1]\n assert candidate(nums = [7, 5, 9, 3, 8, 6, 10, 2, 4]) == [4, 6, 7, 5, 8, 3, 9, 2, 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]) == [1, 20, 3, 18, 5, 16, 7, 14, 9, 12, 11, 10, 13, 8, 15, 6, 17, 4, 19, 2, 21]\n assert candidate(nums = [8, 6, 4, 2, 0, 9, 7, 5, 3, 1, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [0, 29, 3, 25, 4, 21, 7, 17, 8, 13, 11, 9, 15, 6, 19, 5, 23, 2, 27, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 15, 2, 13, 3, 11, 4, 9, 5, 7, 6, 6, 7, 5, 8, 4, 10, 3, 12, 2, 14, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [1, 31, 5, 27, 9, 23, 13, 19, 17, 15, 21, 11, 25, 7, 29, 3]\n assert candidate(nums = [9, 7, 5, 3, 1, 8, 6, 4, 2]) == [1, 8, 2, 7, 5, 4, 6, 3, 9]\n assert candidate(nums = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 15, 4, 13, 6, 11, 8, 9, 10, 7, 12, 5, 14, 3, 16, 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]) == [1, 11, 2, 10, 3, 9, 4, 8, 5, 7, 6, 6, 7, 5, 8, 4, 9, 3, 10, 2, 11, 1]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [2, 9, 3, 6, 4, 3, 5, 1, 5, 1, 5]\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, 19, 4, 17, 6, 15, 8, 13, 10, 11, 12, 9, 14, 7, 16, 5, 18, 3, 20, 1]\n assert candidate(nums = [50, 40, 30, 20, 10, 5, 45, 35, 25, 15, 55, 45, 35, 25, 15, 5, 65, 55, 45, 35, 25, 15, 5]) == [5, 55, 10, 45, 15, 40, 25, 35, 25, 35, 30, 25, 35, 20, 45, 15, 45, 15, 50, 5, 55, 5, 65]\n assert candidate(nums = [64, 34, 25, 12, 22, 11, 90]) == [22, 34, 25, 12, 64, 11, 90]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95]) == [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 14, 3, 12, 5, 10, 7, 8, 9, 6, 11, 4, 13, 2, 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, 9, 2, 9, 3, 9, 3, 9, 3, 8, 3, 8, 3, 6, 4, 6, 4, 6, 4, 3, 5, 3, 5, 2, 5, 2, 5, 1, 7, 1, 7, 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]\n assert candidate(nums = [50, 25, 100, 50, 75, 1, 200, 10, 300, 15, 400, 20]) == [50, 50, 75, 25, 100, 20, 200, 15, 300, 10, 400, 1]\n assert candidate(nums = [34, 23, 12, 45, 56, 78, 89, 90, 100, 11, 22, 33]) == [12, 90, 22, 78, 34, 45, 56, 33, 89, 23, 100, 11]\n assert candidate(nums = [15, 10, 25, 20, 35, 30, 45, 40, 55, 50, 65, 60]) == [15, 60, 25, 50, 35, 40, 45, 30, 55, 20, 65, 10]\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]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10]) == [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]\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, 59, 5, 55, 9, 51, 13, 47, 17, 43, 21, 39, 25, 35, 29, 31, 33, 27, 37, 23, 41, 19, 45, 15, 49, 11, 53, 7, 57, 3]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 14, 3, 12, 5, 10, 7, 8, 9, 6, 11, 4, 13, 2, 15]\n assert candidate(nums = [42, 84, 21, 63, 42, 84, 21, 63, 42, 84, 21, 63]) == [21, 84, 21, 84, 21, 84, 42, 63, 42, 63, 42, 63]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 20, 3, 18, 5, 16, 7, 14, 9, 12, 11, 10, 13, 8, 15, 6, 17, 4, 19, 2]\n assert candidate(nums = [34, 78, 23, 67, 89, 45, 12, 90, 100, 56, 34, 23, 56, 78, 90, 12]) == [12, 90, 23, 78, 34, 78, 34, 67, 56, 56, 89, 45, 90, 23, 100, 12]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 14, 3, 12, 5, 10, 7, 8, 9, 6, 11, 4, 13, 2, 15]\n assert candidate(nums = [33, 1, 66, 2, 99, 3, 44, 4, 77, 5, 88, 6, 11, 7, 22, 8, 55, 9, 33, 10]) == [11, 10, 22, 9, 33, 8, 33, 7, 44, 6, 55, 5, 66, 4, 77, 3, 88, 2, 99, 1]\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5]) == [96, 5, 97, 4, 98, 3, 99, 2, 100, 1]\n assert candidate(nums = [7, 11, 5, 15, 3, 19, 1, 23, 9, 29, 6, 33, 2, 37, 8, 41]) == [1, 41, 2, 37, 3, 33, 5, 29, 6, 23, 7, 19, 8, 15, 9, 11]\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [3, 29, 7, 25, 11, 21, 15, 17, 19, 13, 23, 9, 27, 5, 31, 1]\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [21, 30, 23, 28, 25, 26, 27, 24, 29, 22, 31]\n assert candidate(nums = [25, 20, 15, 10, 5, 30, 25, 20, 15, 10, 5, 35, 30, 25, 20, 15, 10, 5, 40, 35, 30, 25, 20, 15, 10, 5]) == [5, 35, 5, 35, 10, 30, 10, 25, 15, 25, 15, 20, 20, 20, 20, 15, 25, 15, 25, 10, 30, 10, 30, 5, 40, 5]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 19, 2, 17, 4, 15, 6, 13, 8, 11, 10, 9, 12, 7, 14, 5, 16, 3, 18, 1, 20]\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]\n assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6, 93, 7, 92, 8, 91, 9, 90, 10]) == [90, 10, 91, 9, 92, 8, 93, 7, 94, 6, 95, 5, 96, 4, 97, 3, 98, 2, 99, 1]\n assert candidate(nums = [9, 7, 5, 3, 1, 8, 6, 4, 2, 0]) == [1, 8, 2, 7, 5, 4, 6, 3, 9, 0]\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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 4, 9, 6, 5, 2, 0, 7, 0, 9, 2, 9, 0, 4, 5, 6, 2, 9, 0, 0, 5, 1, 7, 3, 4, 8, 8, 0, 3, 0, 4, 1, 5, 2, 0]) == [0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 1, 9, 1, 9, 2, 9, 2, 9, 2, 8, 2, 8, 2, 8, 2, 8, 2, 8, 2, 8, 3, 7, 3, 7, 3, 7, 3, 6, 3, 6, 3, 6, 3, 6, 4, 6, 4, 6, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 2, 5, 2, 5, 2, 5, 2, 6, 2, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 0, 8, 0, 8, 0, 8, 0, 9, 0, 9, 0, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [1, 27, 5, 23, 9, 19, 13, 15, 17, 11, 21, 7, 25, 3, 29]\n assert candidate(nums = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 8, 6, 4, 2, 0]) == [1, 19, 2, 15, 5, 11, 6, 8, 9, 7, 13, 4, 17, 3, 21, 0]\n assert candidate(nums = [8, 1, 6, 3, 4, 5, 2, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == [2, 15, 4, 13, 6, 11, 8, 9, 10, 7, 12, 5, 14, 3, 16, 1]\n assert candidate(nums = [23, 18, 34, 15, 29, 10, 40, 25, 39, 20, 22, 35, 41, 5, 38]) == [22, 35, 23, 25, 29, 20, 34, 18, 38, 15, 39, 10, 40, 5, 41]\n assert candidate(nums = [5, 1, 9, 3, 7, 5, 3, 2, 6, 8, 4, 10, 12, 11]) == [3, 11, 4, 10, 5, 8, 6, 5, 7, 3, 9, 2, 12, 1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [90, 99, 92, 97, 94, 95, 96, 93, 98, 91, 100]\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == [91, 10, 92, 9, 93, 8, 94, 7, 95, 6, 96, 5, 97, 4, 98, 3, 99, 2, 100, 1]\n assert candidate(nums = [45, 67, 23, 89, 12, 34, 56, 78, 90]) == [12, 89, 23, 78, 45, 67, 56, 34, 90]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 0]) == [1, 9, 2, 8, 3, 7, 4, 6, 5, 0]\n assert candidate(nums = [8, 1, 6, 3, 5, 7, 4, 9, 2]) == [2, 9, 4, 7, 5, 3, 6, 1, 8]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 5, 5]) == [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 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]) == [1, 20, 3, 18, 5, 16, 7, 14, 9, 12, 11, 10, 13, 8, 15, 6, 17, 4, 19, 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, 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]\n assert candidate(nums = [50, 51, 49, 52, 48, 53, 47, 54, 46, 55, 45, 56, 44, 57, 43, 58]) == [43, 58, 44, 57, 45, 56, 46, 55, 47, 54, 48, 53, 49, 52, 50, 51]\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]\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9, 2, 4, 1]) == [3, 6, 4, 5, 7, 2, 8, 1, 9, 0]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 15, 2, 13, 4, 11, 6, 9, 8, 7, 10, 5, 12, 3, 14]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89]) == [90, 99, 92, 97, 94, 95, 96, 93, 98, 91, 100, 89]\n assert candidate(nums = [55, 22, 66, 33, 77, 44, 88, 55, 99, 66, 11, 77, 33, 44, 22, 88]) == [11, 88, 22, 77, 33, 66, 55, 55, 66, 44, 77, 44, 88, 33, 99, 22]\n assert candidate(nums = [50, 10, 40, 20, 30, 30, 20, 40, 10, 50]) == [10, 50, 20, 40, 30, 30, 40, 20, 50, 10]\n assert candidate(nums = [1, 9, 3, 7, 5, 11, 2, 8, 6, 4, 10]) == [1, 11, 2, 9, 3, 8, 5, 7, 6, 4, 10]\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, 29, 4, 27, 6, 25, 8, 23, 10, 21, 12, 19, 14, 17, 16, 15, 18, 13, 20, 11, 22, 9, 24, 7, 26, 5, 28, 3, 30, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16]) == [1, 20, 3, 18, 5, 16, 7, 14, 9, 12, 11, 10, 13, 8, 15, 6, 17, 4, 19, 2]\n assert candidate(nums = [8, 2, 4, 6, 10, 1, 9, 3, 7, 5, 11, 13, 15, 17, 19, 21]) == [4, 21, 7, 17, 8, 13, 9, 6, 10, 5, 11, 3, 15, 2, 19, 1]\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6]) == [95, 6, 96, 5, 97, 4, 98, 3, 99, 2, 100, 1]\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95]) == [95, 5, 96, 4, 97, 3, 98, 2, 99, 1, 100]\n assert candidate(nums = [50, 25, 75, 100, 200, 150, 300, 200, 100, 50]) == [50, 200, 75, 150, 100, 100, 200, 50, 300, 25]\n assert candidate(nums = [50, 30, 20, 40, 10, 60, 70, 80, 90, 100, 110, 120]) == [10, 120, 20, 100, 50, 80, 70, 60, 90, 40, 110, 30]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6]) == [1, 10, 3, 8, 5, 6, 7, 4, 9, 2, 11, 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]) == [2, 40, 6, 36, 10, 32, 14, 28, 18, 24, 22, 20, 26, 16, 30, 12, 34, 8, 38, 4]\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, 9, 3, 2, 3, 8, 4, 6]) == [1, 9, 2, 9, 2, 9, 2, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 8, 3, 8, 3, 8, 3, 8, 4, 6, 4, 6, 4, 6, 4, 6, 5, 4, 5, 3, 5, 3, 5, 3, 6, 2, 7, 2, 7, 2, 7, 1, 7, 1, 8, 1, 9, 0]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6]) == [1, 14, 1, 12, 3, 10, 3, 8, 5, 6, 5, 6, 7, 4, 9, 4, 11, 2, 13, 2, 15, 0]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 9, 2, 7, 3, 5, 4, 4, 5, 3, 6, 2, 8, 1, 10, 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]\n assert candidate(nums = [7, 5, 3, 9, 1, 8, 6, 2, 4, 0]) == [1, 9, 3, 8, 4, 5, 6, 2, 7, 0]\n assert candidate(nums = [50, 25, 45, 15, 35, 5, 20, 10, 30, 40]) == [20, 40, 30, 25, 35, 15, 45, 10, 50, 5]\n assert candidate(nums = [7, 5, 3, 1, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]) == [2, 15, 3, 12, 6, 11, 7, 8, 9, 5, 10, 4, 13, 1, 14]\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == [1, 10, 4, 7, 5, 6, 8, 3, 9, 2]\n assert candidate(nums = [45, 32, 21, 18, 30, 29, 20, 19, 25, 15, 35, 10, 40, 5, 50, 1]) == [20, 32, 21, 29, 25, 19, 30, 18, 35, 15, 40, 10, 45, 5, 50, 1]\n assert candidate(nums = [34, 78, 12, 56, 90, 32, 45, 89, 23, 67, 54, 10, 76, 9, 5, 11]) == [5, 89, 12, 78, 23, 67, 34, 56, 45, 32, 54, 11, 76, 10, 90, 9]\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0, 2, 4, 6, 8]) == [1, 27, 2, 23, 5, 19, 6, 15, 9, 11, 13, 8, 17, 7, 21, 4, 25, 3, 29, 0]\n assert candidate(nums = [5, 1, 9, 3, 7, 5, 11, 7, 13, 9, 15, 11, 17, 13, 19, 15, 21, 17, 23, 19, 25, 21, 27, 23, 29, 25, 31, 27, 33, 29, 35]) == [5, 29, 7, 27, 9, 25, 11, 23, 13, 21, 15, 19, 17, 17, 19, 15, 21, 13, 23, 11, 25, 9, 27, 7, 29, 5, 31, 3, 33, 1, 35]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10]) == [1, 10, 3, 8, 5, 6, 7, 4, 9, 2]\n assert candidate(nums = [42, 24, 31, 29, 48, 17, 11, 35, 22, 44, 55, 50, 47, 60, 53, 58, 65, 62, 63, 68, 70, 72, 71, 80, 79, 78, 77, 76, 75, 74, 73]) == [11, 80, 22, 78, 31, 76, 42, 74, 47, 72, 48, 68, 53, 62, 55, 60, 63, 58, 65, 50, 70, 44, 71, 35, 73, 29, 75, 24, 77, 17, 79]\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]\n assert candidate(nums = [40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [4, 38, 8, 34, 12, 30, 16, 26, 20, 22, 24, 18, 28, 14, 32, 10, 36, 6, 40, 2]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 18, 17, 16, 15, 14, 13, 12, 11, 10, 19]) == [0, 19, 2, 17, 4, 15, 6, 13, 8, 11, 10, 9, 12, 7, 14, 5, 16, 3, 18, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [1, 16, 3, 14, 5, 12, 7, 10, 9, 8, 11, 6, 13, 4, 15, 2]\n assert candidate(nums = [8, 6, 4, 2, 0, 9, 7, 5, 3, 1]) == [0, 9, 3, 6, 4, 5, 7, 2, 8, 1]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10]) == [1, 11, 2, 9, 4, 7, 6, 5, 8, 3, 10]\n assert candidate(nums = [5, 9, 1, 8, 3, 7, 2, 6, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 30, 2, 28, 3, 26, 4, 24, 5, 22, 11, 20, 13, 18, 15, 16, 17, 14, 19, 12, 21, 10, 23, 9, 25, 8, 27, 7, 29, 6]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sortEvenOdd", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] sortEvenOdd(int[] nums) {", "container": "Solution", "callable": "sortEvenOdd", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2165, "task_id": "smallest-value-of-the-rearranged-number", "difficulty": "Medium", "problem_description": "You are given an integer num. Rearrange the digits of num such that its value is minimized and it does not contain any leading zeros.\nReturn the rearranged number with minimal value.\nNote that the sign of the number does not change after rearranging the digits.\n \nExample 1:\n\nInput: num = 310\nOutput: 103\nExplanation: The possible arrangements for the digits of 310 are 013, 031, 103, 130, 301, 310. \nThe arrangement with the smallest value that does not contain any leading zeros is 103.\n\nExample 2:\n\nInput: num = -7605\nOutput: -7650\nExplanation: Some possible arrangements for the digits of -7605 are -7650, -6705, -5076, -0567.\nThe arrangement with the smallest value that does not contain any leading zeros is -7650.\n\n \nConstraints:\n\n-1015 <= num <= 1015\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 2020) == 2002\n assert candidate(num = 10) == 10\n assert candidate(num = -10000000000) == -10000000000\n assert candidate(num = 10000000000) == 10000000000\n assert candidate(num = 10001) == 10001\n assert candidate(num = 123456789) == 123456789\n assert candidate(num = 9876543210) == 1023456789\n assert candidate(num = 310) == 103\n assert candidate(num = 1000) == 1000\n assert candidate(num = -10001) == -11000\n assert candidate(num = -9876543210) == -9876543210\n assert candidate(num = 1001) == 1001\n assert candidate(num = 987654321) == 123456789\n assert candidate(num = -100) == -100\n assert candidate(num = 0) == 0\n assert candidate(num = -7605) == -7650\n assert candidate(num = -1001) == -1100\n assert candidate(num = -123456789) == -987654321\n assert candidate(num = 100) == 100\n assert candidate(num = -12345) == -54321\n assert candidate(num = 54321) == 12345\n assert candidate(num = -10) == -10\n assert candidate(num = -900) == -900\n assert candidate(num = 20001002003004005) == 10000000000022345\n assert candidate(num = -600500400300201) == -654321000000000\n assert candidate(num = 3000000000000000000) == 3000000000000000000\n assert candidate(num = -999999999) == -999999999\n assert candidate(num = 101010101010101) == 100000001111111\n assert candidate(num = 505050505050505) == 500000005555555\n assert candidate(num = -123456789012345) == -987655443322110\n assert candidate(num = -1230456) == -6543210\n assert candidate(num = 2100000000000000) == 1000000000000002\n assert candidate(num = 1000000000) == 1000000000\n assert candidate(num = -202020202020202) == -222222220000000\n assert candidate(num = 213004005) == 100002345\n assert candidate(num = -999999999999999) == -999999999999999\n assert candidate(num = -987654321012345) == -987655443322110\n assert candidate(num = -543210000) == -543210000\n assert candidate(num = -12000210) == -22110000\n assert candidate(num = -99999999999999) == -99999999999999\n assert candidate(num = 101010101) == 100001111\n assert candidate(num = 303030303030303) == 300000003333333\n assert candidate(num = 56789) == 56789\n assert candidate(num = 1230000000) == 1000000023\n assert candidate(num = 100000000000001) == 100000000000001\n assert candidate(num = 1234567890987654) == 1023445566778899\n assert candidate(num = 111222333444555666777888999) == 111222333444555666777888999\n assert candidate(num = 1000100) == 1000001\n assert candidate(num = 120030400500600) == 100000000023456\n assert candidate(num = 20000000000000) == 20000000000000\n assert candidate(num = 1000000000000000) == 1000000000000000\n assert candidate(num = -111111111111111) == -111111111111111\n assert candidate(num = -300000000000000) == -300000000000000\n assert candidate(num = 1000000000000001) == 1000000000000001\n assert candidate(num = 100000000000000) == 100000000000000\n assert candidate(num = 2000000000000000001) == 1000000000000000002\n assert candidate(num = 202020202020202) == 200000002222222\n assert candidate(num = 1002003004) == 1000000234\n assert candidate(num = 1000000001) == 1000000001\n assert candidate(num = -123456789098765) == -998877665543210\n assert candidate(num = -200100000000000) == -210000000000000\n assert candidate(num = -111222333) == -333222111\n assert candidate(num = -9999999999999) == -9999999999999\n assert candidate(num = 12003004005) == 10000002345\n assert candidate(num = 999999999) == 999999999\n assert candidate(num = -50000000000000) == -50000000000000\n assert candidate(num = 1111111111111) == 1111111111111\n assert candidate(num = -2000000000000000000) == -2000000000000000000\n assert candidate(num = -2000000000000000001) == -2100000000000000000\n assert candidate(num = -1000000000000000000) == -1000000000000000000\n assert candidate(num = 1010101010) == 1000001111\n assert candidate(num = 10000000000000000) == 10000000000000000\n assert candidate(num = -111000000) == -111000000\n assert candidate(num = 10000000000000001) == 10000000000000001\n assert candidate(num = -1) == -1\n assert candidate(num = -543210987654321) == -987655443322110\n assert candidate(num = 2003005006) == 2000000356\n assert candidate(num = 30000123) == 10000233\n assert candidate(num = 1000002) == 1000002\n assert candidate(num = 999999999999999) == 999999999999999\n assert candidate(num = -999888777666) == -999888777666\n assert candidate(num = 100001000010000) == 100000000000011\n assert candidate(num = 500000000000000) == 500000000000000\n assert candidate(num = -222222222) == -222222222\n assert candidate(num = -1000000000000000001) == -1100000000000000000\n assert candidate(num = -200000000000001) == -210000000000000\n assert candidate(num = 2000000001) == 1000000002\n assert candidate(num = -100000000000001) == -110000000000000\n assert candidate(num = 111000222333) == 100011222333\n assert candidate(num = -900000000000001) == -910000000000000\n assert candidate(num = 5000000000000000000) == 5000000000000000000\n assert candidate(num = 5000000000000000001) == 1000000000000000005\n assert candidate(num = -1000000000000000) == -1000000000000000\n assert candidate(num = 111111111111111) == 111111111111111\n assert candidate(num = -303030303030303) == -333333330000000\n assert candidate(num = 503020104) == 100002345\n assert candidate(num = 900000000000000) == 900000000000000\n assert candidate(num = 200000000000001) == 100000000000002\n assert candidate(num = -50006007008) == -87650000000\n assert candidate(num = 100020003000) == 100000000023\n assert candidate(num = 99999999999999) == 99999999999999\n assert candidate(num = 3003003) == 3000033\n assert candidate(num = -10000100001000) == -11100000000000\n assert candidate(num = -100000000000000) == -100000000000000\n assert candidate(num = 100000000000000000) == 100000000000000000\n assert candidate(num = 1234567890) == 1023456789\n assert candidate(num = 10000000000000) == 10000000000000\n assert candidate(num = 1000000000000000002) == 1000000000000000002\n assert candidate(num = -2100300) == -3210000\n assert candidate(num = 2000000000000000000) == 2000000000000000000\n assert candidate(num = 1000000000000000000) == 1000000000000000000\n assert candidate(num = 123456789012345) == 101223344556789\n assert candidate(num = 123000456) == 100023456\n assert candidate(num = -987000000000000) == -987000000000000\n assert candidate(num = 1000000000000000001) == 1000000000000000001\n assert candidate(num = -202020202) == -222220000\n assert candidate(num = 2003004005) == 2000000345\n assert candidate(num = -1234567890) == -9876543210\n assert candidate(num = -5000000) == -5000000\n assert candidate(num = -56789) == -98765\n assert candidate(num = -1000000000000001) == -1100000000000000\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().smallestNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long smallestNumber(long num) {", "container": "Solution", "callable": "smallestNumber", "parameters": [{"name": "num", "type": "long"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2167, "task_id": "minimum-time-to-remove-all-cars-containing-illegal-goods", "difficulty": "Hard", "problem_description": "You are given a 0-indexed binary string s which represents a sequence of train cars. s[i] = '0' denotes that the ith car does not contain illegal goods and s[i] = '1' denotes that the ith car does contain illegal goods.\nAs the train conductor, you would like to get rid of all the cars containing illegal goods. You can do any of the following three operations any number of times:\n\nRemove a train car from the left end (i.e., remove s[0]) which takes 1 unit of time.\nRemove a train car from the right end (i.e., remove s[s.length - 1]) which takes 1 unit of time.\nRemove a train car from anywhere in the sequence which takes 2 units of time.\n\nReturn the minimum time to remove all the cars containing illegal goods.\nNote that an empty sequence of cars is considered to have no cars containing illegal goods.\n \nExample 1:\n\nInput: s = \"1100101\"\nOutput: 5\nExplanation: \nOne way to remove all the cars containing illegal goods from the sequence is to\n- remove a car from the left end 2 times. Time taken is 2 * 1 = 2.\n- remove a car from the right end. Time taken is 1.\n- remove the car containing illegal goods found in the middle. Time taken is 2.\nThis obtains a total time of 2 + 1 + 2 = 5. \n\nAn alternative way is to\n- remove a car from the left end 2 times. Time taken is 2 * 1 = 2.\n- remove a car from the right end 3 times. Time taken is 3 * 1 = 3.\nThis also obtains a total time of 2 + 3 = 5.\n\n5 is the minimum time taken to remove all the cars containing illegal goods. \nThere are no other ways to remove them with less time.\n\nExample 2:\n\nInput: s = \"0010\"\nOutput: 2\nExplanation:\nOne way to remove all the cars containing illegal goods from the sequence is to\n- remove a car from the left end 3 times. Time taken is 3 * 1 = 3.\nThis obtains a total time of 3.\n\nAnother way to remove all the cars containing illegal goods from the sequence is to\n- remove the car containing illegal goods found in the middle. Time taken is 2.\nThis obtains a total time of 2.\n\nAnother way to remove all the cars containing illegal goods from the sequence is to \n- remove a car from the right end 2 times. Time taken is 2 * 1 = 2. \nThis obtains a total time of 2.\n\n2 is the minimum time taken to remove all the cars containing illegal goods. \nThere are no other ways to remove them with less time.\n \nConstraints:\n\n1 <= s.length <= 2 * 105\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"100100100100\") == 7\n assert candidate(s = \"110110110110110110110110110110110110110110110110\") == 47\n assert candidate(s = \"1100101\") == 5\n assert candidate(s = \"1001001001\") == 6\n assert candidate(s = \"11111\") == 5\n assert candidate(s = \"111111\") == 6\n assert candidate(s = \"0101010101\") == 9\n assert candidate(s = \"0\") == 0\n assert candidate(s = \"000000\") == 0\n assert candidate(s = \"0010\") == 2\n assert candidate(s = \"111000111\") == 6\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"000111000\") == 6\n assert candidate(s = \"1010101010\") == 9\n assert candidate(s = \"101101101101101\") == 14\n assert candidate(s = \"111100001111\") == 8\n assert candidate(s = \"1\") == 1\n assert candidate(s = \"101010101010101\") == 14\n assert candidate(s = \"1101001010111001010111001010111001010111001010111001\") == 50\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101\") == 62\n assert candidate(s = \"111000111000111000\") == 15\n assert candidate(s = \"11010101010101010101010101010101010101\") == 37\n assert candidate(s = \"0000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"010101010101010101010101010101010101\") == 35\n assert candidate(s = \"111111111111111111111111111111111111111111111111\") == 48\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == 49\n assert candidate(s = \"1000100010001000100010001000100010001000100010001000\") == 25\n assert candidate(s = \"000000000000000000000000000000000000000001\") == 1\n assert candidate(s = \"111011101110111011101110111011101110111011101110\") == 47\n assert candidate(s = \"010101010101010101010101\") == 23\n assert candidate(s = \"00001111000011110000\") == 16\n assert candidate(s = \"111000111000111\") == 12\n assert candidate(s = \"100011110000111100001111\") == 20\n assert candidate(s = \"10101010101010101010101010101010101010101010101\") == 46\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010\") == 53\n assert candidate(s = \"110101010101010101010101010101010101010101010101\") == 47\n assert candidate(s = \"111111111110111111111111\") == 23\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100\") == 50\n assert candidate(s = \"1000000000000000000001\") == 2\n assert candidate(s = \"000001000001000001000001\") == 7\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"11110000000000001111\") == 8\n assert candidate(s = \"111111000000111111000000\") == 18\n assert candidate(s = \"111100001111000011110000\") == 20\n assert candidate(s = \"0010101010101010101010101010101010101010101010101010\") == 50\n assert candidate(s = \"0111111111111111111111111111111111111110\") == 39\n assert candidate(s = \"011011011011011011011011011011011011011011011011\") == 47\n assert candidate(s = \"1010101010101010101010101010101010101010101010101011\") == 51\n assert candidate(s = \"00001010101010101000\") == 14\n assert candidate(s = \"1110010100101001010010100101001010010100101001010010\") == 41\n assert candidate(s = \"11111111111111111111111111111111111111111111111\") == 47\n assert candidate(s = \"010101010101010101010101010101010101010101010101\") == 47\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101010101010101010101\") == 71\n assert candidate(s = \"000000000000111111111111000000000000111111111111\") == 36\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000\") == 57\n assert candidate(s = \"110011001100110011001100110011001100110011001100\") == 46\n assert candidate(s = \"101010101010101010101010101010101010101\") == 38\n assert candidate(s = \"00000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"1110001110001110001110001110001110001110001110001110\") == 49\n assert candidate(s = \"000000000000000011111111111111110000000000000000\") == 32\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010\") == 63\n assert candidate(s = \"000110001100011000110001100011000110001100011000110001100011\") == 46\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111\") == 52\n assert candidate(s = \"00110011001100110011001100\") == 24\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000\") == 1\n assert candidate(s = \"111100001111000011110000111100001111000011110000\") == 44\n assert candidate(s = \"01010101010101010101010101010101\") == 31\n assert candidate(s = \"11110000111100001111000011110000111100001111000011110000\") == 52\n assert candidate(s = \"00000000111111110000000011111111000000001111111100000000\") == 48\n assert candidate(s = \"0000011111000001111100000111110000011111000001111100\") == 47\n assert candidate(s = \"1101010101010101010101\") == 21\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101\") == 53\n assert candidate(s = \"1111100000111110000011111000001111100000111110000011\") == 47\n assert candidate(s = \"000000000000000\") == 0\n assert candidate(s = \"00000000000000000000000000000000000000000000000000001\") == 1\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111\") == 54\n assert candidate(s = \"100010001000100010001000100010001000100010001000\") == 23\n assert candidate(s = \"1111111111111111111111111111111111111111\") == 40\n assert candidate(s = \"0001001001001001001001001001001001001001001001001001\") == 33\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001\") == 38\n assert candidate(s = \"1001100110011001100110011001100110011001100110011001100110011001\") == 62\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\") == 51\n assert candidate(s = \"00000000000000000000\") == 0\n assert candidate(s = \"111111000000111111000000111111000000111111000000111111000000\") == 54\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 55\n assert candidate(s = \"1110000111100001111000011110000111100001111000011110\") == 48\n assert candidate(s = \"11010101010101010101\") == 19\n assert candidate(s = \"1010101010101010101010101010101010101010101010\") == 45\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"1010101010101010101010\") == 21\n assert candidate(s = \"0000000000000000000000000000000000000000000000001\") == 1\n assert candidate(s = \"1111000001111000001111\") == 16\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100\") == 62\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\") == 51\n assert candidate(s = \"011001100110011001100110011001100110011001100110\") == 46\n assert candidate(s = \"000000000001000000000001\") == 3\n assert candidate(s = \"10000000000000000001\") == 2\n assert candidate(s = \"011011011011011011011011011011011011011011011011011011011011011011011011\") == 71\n assert candidate(s = \"0001111111000000111111111000000111111111100000011111\") == 46\n assert candidate(s = \"10101010101010101010\") == 19\n assert candidate(s = \"0000000000000000000000\") == 0\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumTime(String s) {", "container": "Solution", "callable": "minimumTime", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2169, "task_id": "count-operations-to-obtain-zero", "difficulty": "Easy", "problem_description": "You are given two non-negative integers num1 and num2.\nIn one operation, if num1 >= num2, you must subtract num2 from num1, otherwise subtract num1 from num2.\n\nFor example, if num1 = 5 and num2 = 4, subtract num2 from num1, thus obtaining num1 = 1 and num2 = 4. However, if num1 = 4 and num2 = 5, after one operation, num1 = 4 and num2 = 1.\n\nReturn the number of operations required to make either num1 = 0 or num2 = 0.\n \nExample 1:\n\nInput: num1 = 2, num2 = 3\nOutput: 3\nExplanation: \n- Operation 1: num1 = 2, num2 = 3. Since num1 < num2, we subtract num1 from num2 and get num1 = 2, num2 = 3 - 2 = 1.\n- Operation 2: num1 = 2, num2 = 1. Since num1 > num2, we subtract num2 from num1.\n- Operation 3: num1 = 1, num2 = 1. Since num1 == num2, we subtract num2 from num1.\nNow num1 = 0 and num2 = 1. Since num1 == 0, we do not need to perform any further operations.\nSo the total number of operations required is 3.\n\nExample 2:\n\nInput: num1 = 10, num2 = 10\nOutput: 1\nExplanation: \n- Operation 1: num1 = 10, num2 = 10. Since num1 == num2, we subtract num2 from num1 and get num1 = 10 - 10 = 0.\nNow num1 = 0 and num2 = 10. Since num1 == 0, we are done.\nSo the total number of operations required is 1.\n\n \nConstraints:\n\n0 <= num1, num2 <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num1 = 0,num2 = 5) == 0\n assert candidate(num1 = 100,num2 = 1) == 100\n assert candidate(num1 = 123,num2 = 456) == 12\n assert candidate(num1 = 8,num2 = 12) == 3\n assert candidate(num1 = 1,num2 = 1) == 1\n assert candidate(num1 = 100000,num2 = 100000) == 1\n assert candidate(num1 = 100000,num2 = 1) == 100000\n assert candidate(num1 = 100,num2 = 50) == 2\n assert candidate(num1 = 5,num2 = 0) == 0\n assert candidate(num1 = 2,num2 = 3) == 3\n assert candidate(num1 = 10,num2 = 10) == 1\n assert candidate(num1 = 7,num2 = 3) == 5\n assert candidate(num1 = 81,num2 = 27) == 3\n assert candidate(num1 = 99999,num2 = 1) == 99999\n assert candidate(num1 = 333,num2 = 111) == 3\n assert candidate(num1 = 10000,num2 = 9999) == 10000\n assert candidate(num1 = 2020,num2 = 1870) == 22\n assert candidate(num1 = 60,num2 = 20) == 3\n assert candidate(num1 = 101,num2 = 100) == 101\n assert candidate(num1 = 42,num2 = 29) == 10\n assert candidate(num1 = 100000,num2 = 0) == 0\n assert candidate(num1 = 45678,num2 = 45678) == 1\n assert candidate(num1 = 88888,num2 = 22222) == 4\n assert candidate(num1 = 618,num2 = 359) == 15\n assert candidate(num1 = 100000,num2 = 99999) == 100000\n assert candidate(num1 = 42,num2 = 7) == 6\n assert candidate(num1 = 98765,num2 = 43210) == 1241\n assert candidate(num1 = 2,num2 = 34567) == 17285\n assert candidate(num1 = 1,num2 = 99999) == 99999\n assert candidate(num1 = 1000,num2 = 333) == 336\n assert candidate(num1 = 88888,num2 = 11111) == 8\n assert candidate(num1 = 9,num2 = 1) == 9\n assert candidate(num1 = 1000,num2 = 1) == 1000\n assert candidate(num1 = 55555,num2 = 22222) == 4\n assert candidate(num1 = 87,num2 = 3) == 29\n assert candidate(num1 = 15,num2 = 10) == 3\n assert candidate(num1 = 60000,num2 = 30000) == 2\n assert candidate(num1 = 22222,num2 = 11111) == 2\n assert candidate(num1 = 65536,num2 = 1) == 65536\n assert candidate(num1 = 65432,num2 = 12345) == 80\n assert candidate(num1 = 20,num2 = 30) == 3\n assert candidate(num1 = 50000,num2 = 25000) == 2\n assert candidate(num1 = 13579,num2 = 24680) == 39\n assert candidate(num1 = 777,num2 = 111) == 7\n assert candidate(num1 = 88888,num2 = 44444) == 2\n assert candidate(num1 = 12345,num2 = 54321) == 177\n assert candidate(num1 = 5000,num2 = 7500) == 3\n assert candidate(num1 = 25,num2 = 5) == 5\n assert candidate(num1 = 23456,num2 = 65432) == 44\n assert candidate(num1 = 45678,num2 = 87654) == 45\n assert candidate(num1 = 12345,num2 = 67890) == 418\n assert candidate(num1 = 42,num2 = 30) == 5\n assert candidate(num1 = 789,num2 = 987) == 70\n assert candidate(num1 = 99999,num2 = 99999) == 1\n assert candidate(num1 = 456,num2 = 123) == 12\n assert candidate(num1 = 0,num2 = 0) == 0\n assert candidate(num1 = 55,num2 = 20) == 6\n assert candidate(num1 = 33333,num2 = 22222) == 3\n assert candidate(num1 = 54321,num2 = 12345) == 177\n assert candidate(num1 = 1,num2 = 100000) == 100000\n assert candidate(num1 = 32768,num2 = 16384) == 2\n assert candidate(num1 = 1000,num2 = 100) == 10\n assert candidate(num1 = 2,num2 = 8) == 4\n assert candidate(num1 = 101010,num2 = 10101) == 10\n assert candidate(num1 = 75,num2 = 25) == 3\n assert candidate(num1 = 83456,num2 = 37821) == 38\n assert candidate(num1 = 23456,num2 = 12345) == 262\n assert candidate(num1 = 123,num2 = 321) == 11\n assert candidate(num1 = 8,num2 = 3) == 5\n assert candidate(num1 = 50,num2 = 25) == 2\n assert candidate(num1 = 13,num2 = 13) == 1\n assert candidate(num1 = 12345,num2 = 1) == 12345\n assert candidate(num1 = 55555,num2 = 55555) == 1\n assert candidate(num1 = 3,num2 = 8) == 5\n assert candidate(num1 = 30000,num2 = 15000) == 2\n assert candidate(num1 = 999,num2 = 999) == 1\n assert candidate(num1 = 56789,num2 = 12345) == 260\n assert candidate(num1 = 25,num2 = 15) == 4\n"}, "metadata": {"canonical_parameter_names": ["num1", "num2"], "leetcode_dataset_entry_point": "Solution().countOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countOperations(int num1, int num2) {", "container": "Solution", "callable": "countOperations", "parameters": [{"name": "num1", "type": "int"}, {"name": "num2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2170, "task_id": "minimum-operations-to-make-the-array-alternating", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums consisting of n positive integers.\nThe array nums is called alternating if:\n\nnums[i - 2] == nums[i], where 2 <= i <= n - 1.\nnums[i - 1] != nums[i], where 1 <= i <= n - 1.\n\nIn one operation, you can choose an index i and change nums[i] into any positive integer.\nReturn the minimum number of operations required to make the array alternating.\n \nExample 1:\n\nInput: nums = [3,1,3,2,4,3]\nOutput: 3\nExplanation:\nOne way to make the array alternating is by converting it to [3,1,3,1,3,1].\nThe number of operations required in this case is 3.\nIt can be proven that it is not possible to make the array alternating in less than 3 operations. \n\nExample 2:\n\nInput: nums = [1,2,2,2,2]\nOutput: 2\nExplanation:\nOne way to make the array alternating is by converting it to [1,2,1,2,1].\nThe number of operations required in this case is 2.\nNote that the array cannot be converted to [2,2,2,2,2] because in this case nums[0] == nums[1] which violates the conditions of an alternating array.\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, 5, 5, 5, 5, 5, 5, 5]) == 4\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 1]) == 2\n assert candidate(nums = [1, 3, 1, 3, 2, 3, 1, 3, 1, 3]) == 1\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 3, 2, 3]) == 1\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1]) == 0\n assert candidate(nums = [3, 1, 3, 2, 4, 3]) == 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]) == 18\n assert candidate(nums = [1, 2, 3, 4, 5]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [2, 3, 2, 3, 2, 3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 4\n assert candidate(nums = [1, 2, 2, 2, 2]) == 2\n assert candidate(nums = [1, 3, 1, 3, 1, 3]) == 0\n assert candidate(nums = [100000, 99999, 100000, 99999, 100000]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 2\n assert candidate(nums = [100000, 99999, 100000, 99999, 100000]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [1, 100000, 1, 100000, 1, 100000, 1]) == 0\n assert candidate(nums = [1, 3, 5, 3, 1]) == 1\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1]) == 0\n assert candidate(nums = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 0\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]) == 13\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 10\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10, 110]) == 9\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]) == 13\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\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]) == 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, 3]) == 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]) == 23\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 = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9]) == 80\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]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 14\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]) == 17\n assert candidate(nums = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 0\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]) == 13\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]) == 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]) == 28\n assert candidate(nums = [100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101]) == 0\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(nums = [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, 1, 1, 1, 2, 2, 2]) == 24\n assert candidate(nums = [99999, 1, 99999, 2, 99999, 3, 99999, 4, 99999, 5]) == 4\n assert candidate(nums = [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]) == 20\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1]) == 5\n assert candidate(nums = [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]) == 0\n assert candidate(nums = [2, 1, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 10, 2, 11]) == 9\n assert candidate(nums = [42, 17, 42, 17, 42, 17, 42, 17, 42, 17, 42, 17, 42, 17, 42, 17]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == 11\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 0\n assert candidate(nums = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1]) == 0\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]) == 10\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]) == 18\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]) == 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]) == 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, 1]) == 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]) == 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]) == 18\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]) == 13\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]) == 16\n assert candidate(nums = [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]) == 0\n assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5]) == 0\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 6, 5, 7, 5, 8, 5, 9, 5, 10]) == 9\n assert candidate(nums = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 0\n assert candidate(nums = [50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51]) == 0\n assert candidate(nums = [5, 6, 5, 7, 5, 8, 5, 9, 5, 10, 5, 11, 5, 12]) == 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]) == 18\n assert candidate(nums = [99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999]) == 0\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 10\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1]) == 3\n assert candidate(nums = [100000, 99999, 100000, 99999, 100000, 99999, 100000, 99999, 100000, 99999]) == 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]) == 14\n assert candidate(nums = [1, 2, 1, 3, 4, 1, 2, 1, 3, 4, 1, 2, 1, 3, 4, 1, 2, 1, 3, 4, 1]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 16\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 16\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6]) == 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, 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]) == 0\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]) == 5\n assert candidate(nums = [10, 9, 10, 8, 10, 7, 10, 6, 10, 5, 10, 4, 10, 3, 10, 2, 10, 1]) == 8\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 6, 5, 7, 5, 8, 5, 9, 5, 10]) == 9\n assert candidate(nums = [100000, 99999, 100000, 99998, 100000, 99997, 100000, 99996, 100000, 99995]) == 4\n assert candidate(nums = [2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 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, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15]) == 41\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 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]) == 10\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 11\n assert candidate(nums = [1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1]) == 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, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 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]) == 18\n assert candidate(nums = [9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8]) == 0\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 0\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11]) == 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]) == 0\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]) == 16\n assert candidate(nums = [99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7]) == 0\n assert candidate(nums = [6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2]) == 0\n assert candidate(nums = [2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 5\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]) == 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, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 28\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]) == 0\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 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]) == 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 15\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11]) == 9\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8]) == 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, 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]) == 24\n assert candidate(nums = [9, 8, 9, 7, 9, 6, 9, 5, 9, 4, 9, 3, 9, 2, 9, 1, 9, 0, 9, 8, 9]) == 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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5, 100000]) == 4\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 0\n assert candidate(nums = [50000, 50000, 50001, 50001, 50002, 50002, 50003, 50003, 50004, 50004, 50005, 50005, 50006, 50006, 50007, 50007]) == 14\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]) == 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]) == 10\n assert candidate(nums = [99999, 99998, 99999, 99998, 99999, 99998, 99999, 99998, 99999, 99997]) == 1\n assert candidate(nums = [7, 5, 7, 2, 7, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 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, 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]) == 48\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 11\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]) == 24\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 0\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 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]) == 17\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumOperations(int[] nums) {", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2171, "task_id": "removing-minimum-number-of-magic-beans", "difficulty": "Medium", "problem_description": "You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag.\nRemove any number of beans (possibly none) from each bag such that the number of beans in each remaining non-empty bag (still containing at least one bean) is equal. Once a bean has been removed from a bag, you are not allowed to return it to any of the bags.\nReturn the minimum number of magic beans that you have to remove.\n \nExample 1:\n\nInput: beans = [4,1,6,5]\nOutput: 4\nExplanation: \n- We remove 1 bean from the bag with only 1 bean.\n This results in the remaining bags: [4,0,6,5]\n- Then we remove 2 beans from the bag with 6 beans.\n This results in the remaining bags: [4,0,4,5]\n- Then we remove 1 bean from the bag with 5 beans.\n This results in the remaining bags: [4,0,4,4]\nWe removed a total of 1 + 2 + 1 = 4 beans to make the remaining non-empty bags have an equal number of beans.\nThere are no other solutions that remove 4 beans or fewer.\n\nExample 2:\n\nInput: beans = [2,10,3,2]\nOutput: 7\nExplanation:\n- We remove 2 beans from one of the bags with 2 beans.\n This results in the remaining bags: [0,10,3,2]\n- Then we remove 2 beans from the other bag with 2 beans.\n This results in the remaining bags: [0,10,3,0]\n- Then we remove 3 beans from the bag with 3 beans. \n This results in the remaining bags: [0,10,0,0]\nWe removed a total of 2 + 2 + 3 = 7 beans to make the remaining non-empty bags have an equal number of beans.\nThere are no other solutions that removes 7 beans or fewer.\n\n \nConstraints:\n\n1 <= beans.length <= 105\n1 <= beans[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(beans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(beans = [4, 1, 6, 5]) == 4\n assert candidate(beans = [5, 5, 5, 5]) == 0\n assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100000]) == 45\n assert candidate(beans = [10, 10, 10, 10]) == 0\n assert candidate(beans = [5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 18\n assert candidate(beans = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 9\n assert candidate(beans = [1, 2, 3, 4, 5]) == 6\n assert candidate(beans = [100000, 99999, 99998, 99997, 99996]) == 10\n assert candidate(beans = [100000, 1, 100000, 1, 100000]) == 2\n assert candidate(beans = [1]) == 0\n assert candidate(beans = [100000]) == 0\n assert candidate(beans = [5, 5, 5, 5, 5]) == 0\n assert candidate(beans = [1, 1, 1, 1, 1]) == 0\n assert candidate(beans = [99999, 99999, 99999, 99999, 99999]) == 0\n assert candidate(beans = [2, 10, 3, 2]) == 7\n assert candidate(beans = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 25\n assert candidate(beans = [5, 4, 3, 2, 1]) == 6\n assert candidate(beans = [100000, 1, 100000, 1, 100000]) == 2\n assert candidate(beans = [100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(beans = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 19\n assert candidate(beans = [1, 100000, 1, 100000]) == 2\n assert candidate(beans = [10, 1, 10, 1, 10]) == 2\n assert candidate(beans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 19\n assert candidate(beans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 9\n assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100]) == 55\n assert candidate(beans = [9, 7, 3, 8, 6, 4]) == 13\n assert candidate(beans = [100, 50, 150, 200, 250, 300]) == 450\n assert candidate(beans = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(beans = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 25\n assert candidate(beans = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(beans = [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, 1]) == 313\n assert candidate(beans = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 2500\n assert candidate(beans = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 1]) == 1\n assert candidate(beans = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 99803\n assert candidate(beans = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 50\n assert candidate(beans = [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]) == 625\n assert candidate(beans = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 3, 1]) == 259\n assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 100\n assert candidate(beans = [1, 99999, 2, 99998, 3, 99997, 4, 99996]) == 16\n assert candidate(beans = [50, 50, 50, 50, 50, 1, 1, 1, 1, 1]) == 5\n assert candidate(beans = [50000, 50000, 50000, 50000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(beans = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(beans = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 190\n assert candidate(beans = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 18\n assert candidate(beans = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 12\n assert candidate(beans = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 190\n assert candidate(beans = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(beans = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 78\n assert candidate(beans = [10, 20, 30, 40, 50]) == 60\n assert candidate(beans = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50]) == 180\n assert candidate(beans = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 45\n assert candidate(beans = [210, 190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1]) == 805\n assert candidate(beans = [5, 7, 8, 9, 9, 10, 10, 10, 10, 10]) == 24\n assert candidate(beans = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 560\n assert candidate(beans = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 120\n assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(beans = [50000, 50000, 50000, 50000, 50000, 1, 2, 3, 4, 5]) == 15\n assert candidate(beans = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500]) == 1200\n assert candidate(beans = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 120\n assert candidate(beans = [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]) == 225\n assert candidate(beans = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(beans = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 10\n assert candidate(beans = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 524287\n assert candidate(beans = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60]) == 130\n assert candidate(beans = [99999, 100000, 99998, 100000, 99997, 100000]) == 12\n assert candidate(beans = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(beans = [2, 4, 6, 8, 10, 8, 6, 4, 2]) == 20\n assert candidate(beans = [1, 10, 100, 1000, 10000, 100000, 100000, 10000, 1000, 100]) == 22211\n assert candidate(beans = [20000, 20000, 20000, 20000, 20000, 10000, 10000, 10000, 10000, 10000, 10000]) == 50000\n assert candidate(beans = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 805\n assert candidate(beans = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(beans = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(beans = [1, 10, 100, 1000, 10000, 100000, 1, 10, 100, 1000, 10000, 100000, 1, 10, 100, 1000, 10000, 100000, 1, 10]) == 33344\n assert candidate(beans = [99999, 99999, 99999, 99999, 99999, 1, 2, 3, 4, 5]) == 15\n assert candidate(beans = [99999, 99998, 99997, 99996, 99995]) == 10\n assert candidate(beans = [33, 33, 33, 33, 33, 1, 2, 3, 4, 5]) == 15\n assert candidate(beans = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 45\n assert candidate(beans = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 500\n assert candidate(beans = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 250000\n assert candidate(beans = [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]) == 0\n assert candidate(beans = [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]) == 2915\n assert candidate(beans = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 250\n assert candidate(beans = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 50\n assert candidate(beans = [5, 1, 1, 1, 5, 5, 5, 1, 5, 1, 1, 5]) == 6\n assert candidate(beans = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 9\n assert candidate(beans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(beans = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(beans = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 120\n assert candidate(beans = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 5600\n assert candidate(beans = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 12\n assert candidate(beans = [7, 5, 9, 3, 6, 2, 8, 1, 4, 10]) == 25\n assert candidate(beans = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 2500\n assert candidate(beans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(beans = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 150\n assert candidate(beans = [50000, 50000, 50000, 50000, 50000, 1, 1, 1]) == 3\n assert candidate(beans = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 25000\n assert candidate(beans = [3, 6, 1, 9, 4, 2, 8, 7, 5]) == 20\n assert candidate(beans = [50, 40, 30, 20, 10, 50, 40, 30, 20, 10, 50, 40, 30, 20, 10, 50, 40, 30, 20, 10]) == 240\n assert candidate(beans = [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]) == 312\n assert candidate(beans = [1, 100, 1000, 10000, 100000]) == 11101\n assert candidate(beans = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 1]) == 1\n assert candidate(beans = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 25\n assert candidate(beans = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 24\n assert candidate(beans = [10, 10, 20, 20, 30, 30, 40, 40]) == 80\n assert candidate(beans = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 31\n"}, "metadata": {"canonical_parameter_names": ["beans"], "leetcode_dataset_entry_point": "Solution().minimumRemoval", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumRemoval(int[] beans) {", "container": "Solution", "callable": "minimumRemoval", "parameters": [{"name": "beans", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2172, "task_id": "maximum-and-sum-of-array", "difficulty": "Hard", "problem_description": "You are given an integer array nums of length n and an integer numSlots such that 2 * numSlots >= n. There are numSlots slots numbered from 1 to numSlots.\nYou have to place all n integers into the slots such that each slot contains at most two numbers. The AND sum of a given placement is the sum of the bitwise AND of every number with its respective slot number.\n\nFor example, the AND sum of placing the numbers [1, 3] into slot 1 and [4, 6] into slot 2 is equal to (1 AND 1) + (3 AND 1) + (4 AND 2) + (6 AND 2) = 1 + 1 + 0 + 2 = 4.\n\nReturn the maximum possible AND sum of nums given numSlots slots.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5,6], numSlots = 3\nOutput: 9\nExplanation: One possible placement is [1, 4] into slot 1, [2, 6] into slot 2, and [3, 5] into slot 3. \nThis gives the maximum AND sum of (1 AND 1) + (4 AND 1) + (2 AND 2) + (6 AND 2) + (3 AND 3) + (5 AND 3) = 1 + 0 + 2 + 2 + 3 + 1 = 9.\n\nExample 2:\n\nInput: nums = [1,3,10,4,7,1], numSlots = 9\nOutput: 24\nExplanation: One possible placement is [1, 1] into slot 1, [3] into slot 3, [4] into slot 4, [7] into slot 7, and [10] into slot 9.\nThis gives the maximum AND sum of (1 AND 1) + (1 AND 1) + (3 AND 3) + (4 AND 4) + (7 AND 7) + (10 AND 9) = 1 + 1 + 3 + 4 + 7 + 8 = 24.\nNote that slots 2, 5, 6, and 8 are empty which is permitted.\n\n \nConstraints:\n\nn == nums.length\n1 <= numSlots <= 9\n1 <= n <= 2 * numSlots\n1 <= nums[i] <= 15\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1],numSlots = 2) == 2\n assert candidate(nums = [1, 2, 3],numSlots = 2) == 5\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15],numSlots = 8) == 52\n assert candidate(nums = [15, 15, 15],numSlots = 2) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6],numSlots = 3) == 9\n assert candidate(nums = [7, 11, 4, 1, 3, 10, 4, 9],numSlots = 5) == 23\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numSlots = 8) == 8\n assert candidate(nums = [1, 2],numSlots = 1) == 1\n assert candidate(nums = [4, 10, 7, 6, 9, 8, 3, 9, 8, 1, 2, 6, 8, 7, 8],numSlots = 9) == 72\n assert candidate(nums = [1, 1, 1, 1, 1, 1],numSlots = 3) == 4\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],numSlots = 6) == 42\n assert candidate(nums = [1, 3, 10, 4, 7, 1],numSlots = 9) == 24\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numSlots = 8) == 8\n assert candidate(nums = [7, 11, 4, 1],numSlots = 3) == 7\n assert candidate(nums = [1, 2, 3],numSlots = 3) == 6\n assert candidate(nums = [1],numSlots = 1) == 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],numSlots = 10) == 110\n assert candidate(nums = [15, 10, 5, 1, 14, 9, 4, 2, 13, 8, 3, 6, 12, 7, 11],numSlots = 8) == 71\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numSlots = 9) == 84\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15],numSlots = 9) == 84\n assert candidate(nums = [15, 10, 5, 3, 8, 2, 7, 1, 14, 12, 9, 13, 4, 6, 11],numSlots = 8) == 71\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],numSlots = 7) == 56\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numSlots = 10) == 10\n assert candidate(nums = [15, 7, 8, 9, 10, 11, 12, 13, 14, 1, 2, 3, 4, 5, 6, 15, 1, 2],numSlots = 9) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],numSlots = 7) == 49\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numSlots = 9) == 84\n assert candidate(nums = [8, 5, 6, 7, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14, 15],numSlots = 8) == 71\n assert candidate(nums = [11, 5, 7, 3, 14, 10, 9, 8],numSlots = 4) == 19\n assert candidate(nums = [15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3],numSlots = 9) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1],numSlots = 9) == 85\n assert candidate(nums = [12, 6, 7, 10, 5, 11, 4, 8, 15, 14, 2, 13, 3, 9, 1],numSlots = 8) == 71\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],numSlots = 9) == 86\n assert candidate(nums = [5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6],numSlots = 9) == 84\n assert candidate(nums = [8, 3, 15, 2, 12, 6, 1, 7, 4, 14, 10, 13, 9, 5, 11],numSlots = 7) == 53\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],numSlots = 9) == 84\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numSlots = 8) == 71\n assert candidate(nums = [14, 3, 5, 7, 10, 2, 8, 13],numSlots = 4) == 19\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8],numSlots = 5) == 29\n assert candidate(nums = [7, 5, 2, 9, 1, 12, 3, 8, 6, 11, 14, 15],numSlots = 6) == 40\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],numSlots = 9) == 87\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3],numSlots = 8) == 72\n assert candidate(nums = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numSlots = 7) == 49\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],numSlots = 7) == 7\n assert candidate(nums = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numSlots = 8) == 64\n assert candidate(nums = [14, 7, 9, 12, 11, 8, 5, 10, 3, 2, 15, 6, 1, 4, 13],numSlots = 8) == 71\n assert candidate(nums = [13, 9, 7, 5, 3, 1],numSlots = 4) == 16\n assert candidate(nums = [15, 13, 11, 9, 7, 5, 3, 1],numSlots = 4) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],numSlots = 9) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],numSlots = 8) == 71\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9],numSlots = 8) == 71\n assert candidate(nums = [14, 14, 14, 14, 14, 14, 14, 14, 14, 14],numSlots = 5) == 24\n assert candidate(nums = [2, 5, 7, 9, 1, 3, 6, 8, 10, 12, 14, 15, 11, 4, 13],numSlots = 7) == 51\n assert candidate(nums = [8, 6, 4, 2, 10, 14, 12, 1],numSlots = 5) == 21\n assert candidate(nums = [15, 8, 7, 1, 2, 3, 14, 9, 10, 11, 12, 13, 4, 5, 6],numSlots = 8) == 71\n assert candidate(nums = [3, 5, 15, 7, 9, 11, 13, 14, 12, 10],numSlots = 6) == 39\n assert candidate(nums = [10, 14, 7, 11, 8, 12, 13, 9, 6, 4, 5, 2, 3, 15, 1],numSlots = 8) == 71\n assert candidate(nums = [8, 9, 10, 11, 12, 13, 14],numSlots = 7) == 21\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],numSlots = 9) == 90\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],numSlots = 8) == 40\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14],numSlots = 8) == 71\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],numSlots = 6) == 39\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15],numSlots = 8) == 72\n assert candidate(nums = [1, 13, 5, 9, 11, 15, 3, 7, 14, 12, 2, 6, 10, 4, 8],numSlots = 8) == 71\n assert candidate(nums = [14, 7, 13, 5, 11, 6, 2, 9],numSlots = 4) == 20\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],numSlots = 5) == 29\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],numSlots = 8) == 72\n assert candidate(nums = [9, 6, 11, 12, 14, 15, 7, 8, 10],numSlots = 5) == 26\n assert candidate(nums = [6, 12, 10, 14, 1, 5, 11, 13, 7, 9, 3, 8, 2, 4, 15],numSlots = 7) == 49\n assert candidate(nums = [1, 3, 2, 5, 4, 6, 8, 7, 15, 14, 13, 12, 11, 10, 9],numSlots = 9) == 84\n assert candidate(nums = [7, 13, 11, 1, 15, 5, 9, 3, 14, 12, 8, 10, 6, 2, 4],numSlots = 8) == 71\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1],numSlots = 4) == 19\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16],numSlots = 4) == 16\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11],numSlots = 10) == 110\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56],numSlots = 4) == 19\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],numSlots = 5) == 30\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18],numSlots = 9) == 46\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],numSlots = 8) == 40\n assert candidate(nums = [14, 12, 10, 8, 6, 4, 2, 15, 13, 11, 9, 7, 5, 3, 1],numSlots = 8) == 71\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9],numSlots = 8) == 71\n assert candidate(nums = [3, 5, 7, 11, 13, 17],numSlots = 3) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],numSlots = 9) == 84\n assert candidate(nums = [15, 1, 7, 15, 9, 7, 3, 10, 2, 14, 11, 13, 5, 4, 6, 8],numSlots = 9) == 87\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 1, 3, 5, 7, 9, 11, 13, 15],numSlots = 9) == 86\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7],numSlots = 10) == 62\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],numSlots = 5) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 18],numSlots = 10) == 102\n assert candidate(nums = [15, 9, 6, 11, 13, 7, 12, 1, 5, 3, 2, 4, 8, 14, 10],numSlots = 8) == 71\n assert candidate(nums = [10, 15, 9, 4, 14, 8, 13, 7, 12, 2, 3, 11, 6, 5, 1],numSlots = 8) == 71\n assert candidate(nums = [5, 14, 12, 3, 7, 9, 1, 13, 11, 8, 6, 4, 2, 15, 10],numSlots = 8) == 71\n"}, "metadata": {"canonical_parameter_names": ["nums", "numSlots"], "leetcode_dataset_entry_point": "Solution().maximumANDSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumANDSum(int[] nums, int numSlots) {", "container": "Solution", "callable": "maximumANDSum", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "numSlots", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2176, "task_id": "count-equal-and-divisible-pairs-in-an-array", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums of length n and an integer k, return the number of pairs (i, j) where 0 <= i < j < n, such that nums[i] == nums[j] and (i * j) is divisible by k.\n \nExample 1:\n\nInput: nums = [3,1,2,2,2,1,3], k = 2\nOutput: 4\nExplanation:\nThere are 4 pairs that meet all the requirements:\n- nums[0] == nums[6], and 0 * 6 == 0, which is divisible by 2.\n- nums[2] == nums[3], and 2 * 3 == 6, which is divisible by 2.\n- nums[2] == nums[4], and 2 * 4 == 8, which is divisible by 2.\n- nums[3] == nums[4], and 3 * 4 == 12, which is divisible by 2.\n\nExample 2:\n\nInput: nums = [1,2,3,4], k = 1\nOutput: 0\nExplanation: Since no value in nums is repeated, there are no pairs (i,j) that meet all the requirements.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i], k <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n assert candidate(nums = [6, 6, 6, 6],k = 2) == 5\n assert candidate(nums = [3, 1, 2, 2, 2, 1, 3],k = 2) == 4\n assert candidate(nums = [9, 9, 9],k = 9) == 2\n assert candidate(nums = [10, 20, 10, 20, 10],k = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 30\n assert candidate(nums = [10, 20, 10, 20, 10],k = 5) == 2\n assert candidate(nums = [1, 1, 1, 1],k = 1) == 6\n assert candidate(nums = [7, 11, 7, 11, 7, 11],k = 3) == 4\n assert candidate(nums = [1, 3, 1, 3, 1, 3],k = 3) == 4\n assert candidate(nums = [7, 3, 8, 7, 3, 8, 7],k = 7) == 2\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7],k = 1) == 28\n assert candidate(nums = [2, 4, 6, 8, 10],k = 2) == 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) == 70\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 0\n assert candidate(nums = [100, 100, 100],k = 3) == 2\n assert candidate(nums = [1, 2, 3, 4],k = 1) == 0\n assert candidate(nums = [5, 5, 5, 5],k = 2) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 45\n assert candidate(nums = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99],k = 99) == 21\n assert candidate(nums = [2, 3, 4, 2, 5, 3, 2, 2, 4, 2],k = 4) == 5\n assert candidate(nums = [25, 10, 10, 25, 10, 10, 25, 25, 25, 10, 10, 25],k = 10) == 12\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],k = 25) == 63\n assert candidate(nums = [9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8],k = 2) == 120\n assert candidate(nums = [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, 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],k = 100) == 129\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 = 1) == 465\n assert candidate(nums = [15, 15, 10, 15, 10, 15, 10, 15, 10],k = 15) == 5\n assert candidate(nums = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1],k = 3) == 14\n assert candidate(nums = [21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21],k = 7) == 140\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 2) == 15\n assert candidate(nums = [3, 5, 3, 3, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5],k = 15) == 23\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 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 4) == 95\n assert candidate(nums = [15, 25, 15, 25, 15, 25, 15, 25],k = 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],k = 1) == 190\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],k = 7) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 1) == 0\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],k = 10) == 120\n assert candidate(nums = [60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60],k = 15) == 418\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],k = 4) == 56\n assert candidate(nums = [5, 5, 5, 5, 10, 10, 10, 10],k = 5) == 6\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],k = 2) == 330\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 = 3) == 20\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],k = 25) == 210\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10],k = 5) == 5\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11],k = 1) == 45\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 = 3) == 7\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, 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, 4, 4, 4],k = 20) == 392\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 = 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 = 20) == 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],k = 25) == 69\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) == 145\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 = 2) == 145\n assert candidate(nums = [11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11],k = 4) == 95\n assert candidate(nums = [10, 20, 30, 10, 20, 30, 10, 20],k = 5) == 3\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],k = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 17\n assert candidate(nums = [21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21],k = 7) == 21\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],k = 8) == 152\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 2, 4, 6, 8, 10],k = 10) == 1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 4) == 25\n assert candidate(nums = [10, 20, 10, 30, 10, 20, 10],k = 5) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 30\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, 2, 2, 2],k = 10) == 563\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],k = 6) == 215\n assert candidate(nums = [15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50, 55, 55, 60, 60],k = 10) == 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],k = 50) == 164\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 6) == 8\n assert candidate(nums = [5, 15, 25, 5, 25, 15, 5, 15, 25, 5],k = 10) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 3) == 15\n assert candidate(nums = [15, 15, 25, 25, 15, 25, 15, 25, 15, 25],k = 5) == 8\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, 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],k = 1) == 8256\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 3) == 30\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) == 65\n assert candidate(nums = [6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3],k = 9) == 28\n assert candidate(nums = [2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4],k = 2) == 210\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 = 14) == 45\n assert candidate(nums = [11, 11, 22, 22, 33, 33, 44, 44, 55, 55, 66, 66, 77, 77, 88, 88, 99, 99, 100, 100],k = 11) == 2\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],k = 10) == 0\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10],k = 10) == 3\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 18) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 17\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 = 5) == 70\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 18\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 = 7) == 140\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 9) == 28\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 11, 22, 33, 44, 55, 66, 77, 88, 99],k = 11) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countPairs(int[] nums, int k) {", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2177, "task_id": "find-three-consecutive-integers-that-sum-to-a-given-number", "difficulty": "Medium", "problem_description": "Given an integer num, return three consecutive integers (as a sorted array) that sum to num. If num cannot be expressed as the sum of three consecutive integers, return an empty array.\n \nExample 1:\n\nInput: num = 33\nOutput: [10,11,12]\nExplanation: 33 can be expressed as 10 + 11 + 12 = 33.\n10, 11, 12 are 3 consecutive integers, so we return [10, 11, 12].\n\nExample 2:\n\nInput: num = 4\nOutput: []\nExplanation: There is no way to express 4 as the sum of 3 consecutive integers.\n\n \nConstraints:\n\n0 <= num <= 1015\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 9) == [2, 3, 4]\n assert candidate(num = 1000000000001) == []\n assert candidate(num = 0) == [-1, 0, 1]\n assert candidate(num = 4) == []\n assert candidate(num = 33) == [10, 11, 12]\n assert candidate(num = 1000000000000) == []\n assert candidate(num = 3) == [0, 1, 2]\n assert candidate(num = 15) == [4, 5, 6]\n assert candidate(num = 100000000000000) == []\n assert candidate(num = 300000000000003) == [100000000000000, 100000000000001, 100000000000002]\n assert candidate(num = 3000000000) == [999999999, 1000000000, 1000000001]\n assert candidate(num = 3000000000000) == [999999999999, 1000000000000, 1000000000001]\n assert candidate(num = 999) == [332, 333, 334]\n assert candidate(num = 1000000000003) == []\n assert candidate(num = 27) == [8, 9, 10]\n assert candidate(num = 45) == [14, 15, 16]\n assert candidate(num = 999999999999) == [333333333332, 333333333333, 333333333334]\n assert candidate(num = 300000000000000) == [99999999999999, 100000000000000, 100000000000001]\n assert candidate(num = 99) == [32, 33, 34]\n assert candidate(num = 1234567890125) == []\n assert candidate(num = 3000000000001) == []\n assert candidate(num = 123456789) == [41152262, 41152263, 41152264]\n assert candidate(num = 777777777777777) == [259259259259258, 259259259259259, 259259259259260]\n assert candidate(num = 2999999999997) == [999999999998, 999999999999, 1000000000000]\n assert candidate(num = 299999999999997) == [99999999999998, 99999999999999, 100000000000000]\n assert candidate(num = 105) == [34, 35, 36]\n assert candidate(num = 999999999999999) == [333333333333332, 333333333333333, 333333333333334]\n assert candidate(num = 1000) == []\n assert candidate(num = 81) == [26, 27, 28]\n assert candidate(num = 1000000000000002) == [333333333333333, 333333333333334, 333333333333335]\n assert candidate(num = 1000000000002) == [333333333333, 333333333334, 333333333335]\n assert candidate(num = 987654321) == [329218106, 329218107, 329218108]\n assert candidate(num = 7500000000000) == [2499999999999, 2500000000000, 2500000000001]\n assert candidate(num = 1001) == []\n assert candidate(num = 21) == [6, 7, 8]\n assert candidate(num = 123456789012345) == [41152263004114, 41152263004115, 41152263004116]\n assert candidate(num = 6) == [1, 2, 3]\n assert candidate(num = 299792458) == []\n assert candidate(num = 2) == []\n assert candidate(num = 1) == []\n assert candidate(num = 100) == []\n assert candidate(num = 1500000000000) == [499999999999, 500000000000, 500000000001]\n assert candidate(num = 999999999) == [333333332, 333333333, 333333334]\n assert candidate(num = 500000000000001) == [166666666666666, 166666666666667, 166666666666668]\n assert candidate(num = 1000000) == []\n assert candidate(num = 1234567890123) == [411522630040, 411522630041, 411522630042]\n assert candidate(num = 1234567890124) == []\n assert candidate(num = 1000000000000000) == []\n assert candidate(num = 180) == [59, 60, 61]\n assert candidate(num = 101) == []\n assert candidate(num = 8999999999997) == [2999999999998, 2999999999999, 3000000000000]\n assert candidate(num = 1000000000000001) == []\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().sumOfThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long[] sumOfThree(long num) {", "container": "Solution", "callable": "sumOfThree", "parameters": [{"name": "num", "type": "long"}], "return_type": "long[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2178, "task_id": "maximum-split-of-positive-even-integers", "difficulty": "Medium", "problem_description": "You are given an integer finalSum. Split it into a sum of a maximum number of unique positive even integers.\n\nFor example, given finalSum = 12, the following splits are valid (unique positive even integers summing up to finalSum): (12), (2 + 10), (2 + 4 + 6), and (4 + 8). Among them, (2 + 4 + 6) contains the maximum number of integers. Note that finalSum cannot be split into (2 + 2 + 4 + 4) as all the numbers should be unique.\n\nReturn a list of integers that represent a valid split containing a maximum number of integers. If no valid split exists for finalSum, return an empty list. You may return the integers in any order.\n \nExample 1:\n\nInput: finalSum = 12\nOutput: [2,4,6]\nExplanation: The following are valid splits: (12), (2 + 10), (2 + 4 + 6), and (4 + 8).\n(2 + 4 + 6) has the maximum number of integers, which is 3. Thus, we return [2,4,6].\nNote that [2,6,4], [6,2,4], etc. are also accepted.\n\nExample 2:\n\nInput: finalSum = 7\nOutput: []\nExplanation: There are no valid splits for the given finalSum.\nThus, we return an empty array.\n\nExample 3:\n\nInput: finalSum = 28\nOutput: [6,8,2,12]\nExplanation: The following are valid splits: (2 + 26), (6 + 8 + 2 + 12), and (4 + 24). \n(6 + 8 + 2 + 12) has the maximum number of integers, which is 4. Thus, we return [6,8,2,12].\nNote that [10,2,4,12], [6,2,4,16], etc. are also accepted.\n\n \nConstraints:\n\n1 <= finalSum <= 1010\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(finalSum = 10) == [2, 8]\n assert candidate(finalSum = 7) == []\n assert candidate(finalSum = 28) == [2, 4, 6, 16]\n assert candidate(finalSum = 2) == [2]\n assert candidate(finalSum = 12) == [2, 4, 6]\n assert candidate(finalSum = 100) == [2, 4, 6, 8, 10, 12, 14, 16, 28]\n assert candidate(finalSum = 198) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 42]\n assert candidate(finalSum = 300) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 60]\n assert candidate(finalSum = 2048) == [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, 156]\n assert candidate(finalSum = 4) == [4]\n assert candidate(finalSum = 512) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 50]\n assert candidate(finalSum = 60) == [2, 4, 6, 8, 10, 12, 18]\n assert candidate(finalSum = 50) == [2, 4, 6, 8, 10, 20]\n assert candidate(finalSum = 101) == []\n assert candidate(finalSum = 200) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 44]\n assert candidate(finalSum = 32) == [2, 4, 6, 8, 12]\n assert candidate(finalSum = 123456789) == []\n assert candidate(finalSum = 8192) == [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, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 182]\n assert candidate(finalSum = 254) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 44]\n assert candidate(finalSum = 256) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 46]\n assert candidate(finalSum = 9999999999) == []\n assert candidate(finalSum = 450) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 70]\n assert candidate(finalSum = 8) == [2, 6]\n assert candidate(finalSum = 30) == [2, 4, 6, 8, 10]\n assert candidate(finalSum = 1998) == [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, 106]\n assert candidate(finalSum = 3) == []\n assert candidate(finalSum = 128) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 38]\n assert candidate(finalSum = 5050) == [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, 122, 124, 126, 128, 130, 132, 134, 136, 138, 220]\n assert candidate(finalSum = 100000) == [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, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 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, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 1090]\n assert candidate(finalSum = 1000000) == [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, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 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, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998, 1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020, 1022, 1024, 1026, 1028, 1030, 1032, 1034, 1036, 1038, 1040, 1042, 1044, 1046, 1048, 1050, 1052, 1054, 1056, 1058, 1060, 1062, 1064, 1066, 1068, 1070, 1072, 1074, 1076, 1078, 1080, 1082, 1084, 1086, 1088, 1090, 1092, 1094, 1096, 1098, 1100, 1102, 1104, 1106, 1108, 1110, 1112, 1114, 1116, 1118, 1120, 1122, 1124, 1126, 1128, 1130, 1132, 1134, 1136, 1138, 1140, 1142, 1144, 1146, 1148, 1150, 1152, 1154, 1156, 1158, 1160, 1162, 1164, 1166, 1168, 1170, 1172, 1174, 1176, 1178, 1180, 1182, 1184, 1186, 1188, 1190, 1192, 1194, 1196, 1198, 1200, 1202, 1204, 1206, 1208, 1210, 1212, 1214, 1216, 1218, 1220, 1222, 1224, 1226, 1228, 1230, 1232, 1234, 1236, 1238, 1240, 1242, 1244, 1246, 1248, 1250, 1252, 1254, 1256, 1258, 1260, 1262, 1264, 1266, 1268, 1270, 1272, 1274, 1276, 1278, 1280, 1282, 1284, 1286, 1288, 1290, 1292, 1294, 1296, 1298, 1300, 1302, 1304, 1306, 1308, 1310, 1312, 1314, 1316, 1318, 1320, 1322, 1324, 1326, 1328, 1330, 1332, 1334, 1336, 1338, 1340, 1342, 1344, 1346, 1348, 1350, 1352, 1354, 1356, 1358, 1360, 1362, 1364, 1366, 1368, 1370, 1372, 1374, 1376, 1378, 1380, 1382, 1384, 1386, 1388, 1390, 1392, 1394, 1396, 1398, 1400, 1402, 1404, 1406, 1408, 1410, 1412, 1414, 1416, 1418, 1420, 1422, 1424, 1426, 1428, 1430, 1432, 1434, 1436, 1438, 1440, 1442, 1444, 1446, 1448, 1450, 1452, 1454, 1456, 1458, 1460, 1462, 1464, 1466, 1468, 1470, 1472, 1474, 1476, 1478, 1480, 1482, 1484, 1486, 1488, 1490, 1492, 1494, 1496, 1498, 1500, 1502, 1504, 1506, 1508, 1510, 1512, 1514, 1516, 1518, 1520, 1522, 1524, 1526, 1528, 1530, 1532, 1534, 1536, 1538, 1540, 1542, 1544, 1546, 1548, 1550, 1552, 1554, 1556, 1558, 1560, 1562, 1564, 1566, 1568, 1570, 1572, 1574, 1576, 1578, 1580, 1582, 1584, 1586, 1588, 1590, 1592, 1594, 1596, 1598, 1600, 1602, 1604, 1606, 1608, 1610, 1612, 1614, 1616, 1618, 1620, 1622, 1624, 1626, 1628, 1630, 1632, 1634, 1636, 1638, 1640, 1642, 1644, 1646, 1648, 1650, 1652, 1654, 1656, 1658, 1660, 1662, 1664, 1666, 1668, 1670, 1672, 1674, 1676, 1678, 1680, 1682, 1684, 1686, 1688, 1690, 1692, 1694, 1696, 1698, 1700, 1702, 1704, 1706, 1708, 1710, 1712, 1714, 1716, 1718, 1720, 1722, 1724, 1726, 1728, 1730, 1732, 1734, 1736, 1738, 1740, 1742, 1744, 1746, 1748, 1750, 1752, 1754, 1756, 1758, 1760, 1762, 1764, 1766, 1768, 1770, 1772, 1774, 1776, 1778, 1780, 1782, 1784, 1786, 1788, 1790, 1792, 1794, 1796, 1798, 1800, 1802, 1804, 1806, 1808, 1810, 1812, 1814, 1816, 1818, 1820, 1822, 1824, 1826, 1828, 1830, 1832, 1834, 1836, 1838, 1840, 1842, 1844, 1846, 1848, 1850, 1852, 1854, 1856, 1858, 1860, 1862, 1864, 1866, 1868, 1870, 1872, 1874, 1876, 1878, 1880, 1882, 1884, 1886, 1888, 1890, 1892, 1894, 1896, 1898, 1900, 1902, 1904, 1906, 1908, 1910, 1912, 1914, 1916, 1918, 1920, 1922, 1924, 1926, 1928, 1930, 1932, 1934, 1936, 1938, 1940, 1942, 1944, 1946, 1948, 1950, 1952, 1954, 1956, 1958, 1960, 1962, 1964, 1966, 1968, 1970, 1972, 1974, 1976, 1978, 1980, 1982, 1984, 1986, 1988, 1990, 1992, 1994, 1996, 2998]\n assert candidate(finalSum = 1024) == [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, 94]\n assert candidate(finalSum = 64) == [2, 4, 6, 8, 10, 12, 22]\n assert candidate(finalSum = 26) == [2, 4, 6, 14]\n assert candidate(finalSum = 498) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 78]\n assert candidate(finalSum = 18) == [2, 4, 12]\n assert candidate(finalSum = 1111111111) == []\n assert candidate(finalSum = 500) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 80]\n assert candidate(finalSum = 16) == [2, 4, 10]\n assert candidate(finalSum = 2000) == [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, 108]\n assert candidate(finalSum = 20) == [2, 4, 6, 8]\n assert candidate(finalSum = 1000) == [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, 70]\n assert candidate(finalSum = 1999) == []\n assert candidate(finalSum = 150) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40]\n assert candidate(finalSum = 88) == [2, 4, 6, 8, 10, 12, 14, 32]\n assert candidate(finalSum = 1) == []\n assert candidate(finalSum = 1000000001) == []\n assert candidate(finalSum = 10000) == [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, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 298]\n assert candidate(finalSum = 42) == [2, 4, 6, 8, 10, 12]\n assert candidate(finalSum = 37) == []\n assert candidate(finalSum = 33) == []\n"}, "metadata": {"canonical_parameter_names": ["finalSum"], "leetcode_dataset_entry_point": "Solution().maximumEvenSplit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List maximumEvenSplit(long finalSum) {", "container": "Solution", "callable": "maximumEvenSplit", "parameters": [{"name": "finalSum", "type": "long"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2179, "task_id": "count-good-triplets-in-an-array", "difficulty": "Hard", "problem_description": "You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1].\nA good triplet is a set of 3 distinct values which are present in increasing order by position both in nums1 and nums2. In other words, if we consider pos1v as the index of the value v in nums1 and pos2v as the index of the value v in nums2, then a good triplet will be a set (x, y, z) where 0 <= x, y, z <= n - 1, such that pos1x < pos1y < pos1z and pos2x < pos2y < pos2z.\nReturn the total number of good triplets.\n \nExample 1:\n\nInput: nums1 = [2,0,1,3], nums2 = [0,1,2,3]\nOutput: 1\nExplanation: \nThere are 4 triplets (x,y,z) such that pos1x < pos1y < pos1z. They are (2,0,1), (2,0,3), (2,1,3), and (0,1,3). \nOut of those triplets, only the triplet (0,1,3) satisfies pos2x < pos2y < pos2z. Hence, there is only 1 good triplet.\n\nExample 2:\n\nInput: nums1 = [4,0,1,3,2], nums2 = [4,1,0,2,3]\nOutput: 4\nExplanation: The 4 good triplets are (4,0,3), (4,0,2), (4,1,3), and (4,1,2).\n\n \nConstraints:\n\nn == nums1.length == nums2.length\n3 <= n <= 105\n0 <= nums1[i], nums2[i] <= n - 1\nnums1 and nums2 are permutations of [0, 1, ..., n - 1].\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [0, 1, 2, 3],nums2 = [3, 2, 1, 0]) == 0\n assert candidate(nums1 = [1, 0, 3, 2],nums2 = [2, 3, 0, 1]) == 0\n assert candidate(nums1 = [2, 0, 1, 3],nums2 = [0, 1, 2, 3]) == 1\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [0, 1, 2, 3, 4, 5]) == 20\n assert candidate(nums1 = [3, 2, 1, 0],nums2 = [3, 2, 1, 0]) == 4\n assert candidate(nums1 = [0, 1, 2, 3, 4],nums2 = [0, 1, 2, 3, 4]) == 10\n assert candidate(nums1 = [3, 2, 1, 0],nums2 = [0, 1, 2, 3]) == 0\n assert candidate(nums1 = [0, 1, 2],nums2 = [2, 1, 0]) == 0\n assert candidate(nums1 = [5, 4, 3, 2, 1, 0],nums2 = [5, 4, 3, 2, 1, 0]) == 20\n assert candidate(nums1 = [4, 0, 1, 3, 2],nums2 = [4, 1, 0, 2, 3]) == 4\n assert candidate(nums1 = [1, 0, 2, 3],nums2 = [3, 2, 1, 0]) == 0\n assert candidate(nums1 = [1, 0, 3, 2, 5, 4],nums2 = [0, 5, 2, 4, 3, 1]) == 2\n assert candidate(nums1 = [5, 3, 4, 0, 2, 1],nums2 = [1, 2, 0, 5, 4, 3]) == 0\n assert candidate(nums1 = [5, 1, 4, 2, 3, 0, 6],nums2 = [0, 1, 2, 3, 4, 5, 6]) == 5\n assert candidate(nums1 = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 84\n assert candidate(nums1 = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],nums2 = [9, 1, 3, 5, 7, 0, 2, 4, 6, 8]) == 68\n assert candidate(nums1 = [7, 3, 5, 0, 2, 6, 4, 1],nums2 = [1, 0, 4, 6, 2, 7, 5, 3]) == 0\n assert candidate(nums1 = [5, 2, 6, 0, 3, 1, 4],nums2 = [0, 1, 2, 3, 4, 5, 6]) == 3\n assert candidate(nums1 = [10, 7, 2, 9, 3, 5, 1, 6, 8, 0, 4],nums2 = [4, 0, 5, 8, 10, 6, 9, 2, 1, 7, 3]) == 5\n assert candidate(nums1 = [6, 3, 2, 1, 5, 0, 4],nums2 = [3, 2, 5, 6, 4, 0, 1]) == 8\n assert candidate(nums1 = [2, 4, 6, 1, 3, 5, 0],nums2 = [6, 5, 0, 1, 2, 3, 4]) == 2\n assert candidate(nums1 = [1, 4, 5, 6, 7, 8, 9, 0, 2, 3],nums2 = [5, 6, 7, 8, 9, 0, 1, 4, 2, 3]) == 60\n assert candidate(nums1 = [2, 8, 0, 1, 5, 9, 6, 7, 4, 3],nums2 = [7, 6, 3, 5, 8, 0, 9, 1, 2, 4]) == 8\n assert candidate(nums1 = [2, 1, 3, 0, 5, 4],nums2 = [0, 4, 5, 1, 3, 2]) == 0\n assert candidate(nums1 = [1, 3, 2, 5, 4, 0, 6, 7],nums2 = [0, 1, 2, 3, 4, 5, 6, 7]) == 26\n assert candidate(nums1 = [1, 2, 0, 3, 4, 5],nums2 = [0, 1, 5, 3, 2, 4]) == 3\n assert candidate(nums1 = [2, 1, 3, 0, 5, 4],nums2 = [5, 4, 2, 0, 3, 1]) == 0\n assert candidate(nums1 = [3, 0, 1, 4, 2, 5],nums2 = [2, 1, 0, 5, 3, 4]) == 0\n assert candidate(nums1 = [4, 2, 3, 5, 1, 0],nums2 = [1, 5, 4, 2, 0, 3]) == 2\n assert candidate(nums1 = [0, 3, 1, 5, 2, 4],nums2 = [5, 2, 4, 0, 3, 1]) == 2\n assert candidate(nums1 = [7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7]) == 0\n assert candidate(nums1 = [0, 3, 2, 5, 4, 1],nums2 = [2, 3, 1, 0, 5, 4]) == 3\n assert candidate(nums1 = [1, 0, 7, 6, 5, 4, 3, 2],nums2 = [3, 2, 5, 7, 6, 0, 4, 1]) == 1\n assert candidate(nums1 = [2, 4, 1, 3, 5, 0, 6],nums2 = [5, 6, 2, 0, 4, 1, 3]) == 4\n assert candidate(nums1 = [3, 0, 1, 4, 2, 5],nums2 = [5, 2, 4, 3, 1, 0]) == 0\n assert candidate(nums1 = [2, 4, 6, 8, 0, 3, 5, 7, 9, 1],nums2 = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == 68\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums1 = [3, 1, 2, 5, 4, 0, 6],nums2 = [6, 0, 5, 2, 1, 4, 3]) == 0\n assert candidate(nums1 = [2, 1, 0, 3, 4, 5, 6, 7, 8],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == 65\n assert candidate(nums1 = [5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums1 = [9, 5, 4, 7, 6, 3, 8, 0, 1, 2],nums2 = [0, 2, 1, 9, 3, 5, 4, 8, 7, 6]) == 14\n assert candidate(nums1 = [8, 6, 7, 5, 3, 0, 9, 4, 2, 1],nums2 = [1, 2, 4, 9, 0, 3, 5, 7, 8, 6]) == 0\n assert candidate(nums1 = [6, 2, 0, 4, 5, 1, 3],nums2 = [4, 2, 0, 6, 3, 5, 1]) == 7\n assert candidate(nums1 = [7, 2, 4, 3, 0, 6, 5, 1],nums2 = [4, 0, 7, 1, 3, 6, 2, 5]) == 12\n assert candidate(nums1 = [6, 4, 8, 5, 3, 9, 1, 2, 7, 0],nums2 = [7, 1, 2, 6, 0, 8, 5, 3, 4, 9]) == 12\n assert candidate(nums1 = [6, 3, 0, 4, 2, 5, 1],nums2 = [5, 1, 2, 6, 0, 4, 3]) == 1\n assert candidate(nums1 = [5, 2, 4, 0, 3, 1],nums2 = [3, 1, 0, 5, 4, 2]) == 0\n assert candidate(nums1 = [8, 5, 7, 6, 2, 9, 3, 4, 0, 1],nums2 = [4, 0, 8, 7, 5, 6, 1, 2, 9, 3]) == 36\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [3, 0, 5, 2, 7, 6, 1, 4, 8],nums2 = [7, 5, 8, 4, 0, 3, 6, 1, 2]) == 4\n assert candidate(nums1 = [5, 1, 4, 2, 3, 0, 8, 6, 7, 9],nums2 = [1, 0, 2, 3, 4, 5, 6, 7, 8, 9]) == 46\n assert candidate(nums1 = [5, 3, 4, 0, 2, 1],nums2 = [1, 0, 2, 5, 4, 3]) == 0\n assert candidate(nums1 = [0, 4, 1, 5, 2, 6, 3, 7],nums2 = [7, 3, 6, 2, 5, 1, 4, 0]) == 0\n assert candidate(nums1 = [6, 0, 1, 5, 2, 3, 4],nums2 = [1, 3, 5, 4, 6, 2, 0]) == 3\n assert candidate(nums1 = [0, 2, 1, 4, 3],nums2 = [4, 0, 1, 2, 3]) == 2\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums1 = [4, 3, 7, 8, 9, 1, 5, 6, 2, 0],nums2 = [6, 5, 0, 2, 1, 8, 9, 7, 3, 4]) == 0\n assert candidate(nums1 = [7, 5, 6, 3, 4, 1, 2, 0],nums2 = [3, 6, 2, 7, 0, 1, 4, 5]) == 2\n assert candidate(nums1 = [8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == 0\n assert candidate(nums1 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 240\n assert candidate(nums1 = [10, 1, 5, 9, 8, 2, 6, 7, 3, 4, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 13\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7]) == 0\n assert candidate(nums1 = [0, 4, 1, 5, 2, 6, 3],nums2 = [1, 2, 3, 4, 5, 6, 0]) == 4\n assert candidate(nums1 = [3, 0, 2, 4, 5, 1, 6],nums2 = [6, 1, 3, 5, 0, 2, 4]) == 4\n assert candidate(nums1 = [1, 9, 2, 8, 3, 7, 4, 6, 5, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 20\n assert candidate(nums1 = [3, 0, 5, 2, 4, 1],nums2 = [4, 1, 0, 5, 3, 2]) == 1\n assert candidate(nums1 = [0, 2, 5, 3, 1, 4],nums2 = [1, 4, 3, 0, 2, 5]) == 1\n assert candidate(nums1 = [8, 6, 7, 2, 5, 4, 3, 0, 1],nums2 = [1, 0, 2, 5, 4, 3, 8, 7, 6]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 0],nums2 = [0, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [5, 3, 2, 4, 1, 6, 0],nums2 = [0, 3, 1, 5, 2, 4, 6]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums2 = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 84\n assert candidate(nums1 = [7, 3, 0, 4, 6, 1, 5, 2],nums2 = [5, 2, 6, 0, 3, 7, 4, 1]) == 3\n assert candidate(nums1 = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5],nums2 = [5, 4, 6, 3, 7, 2, 8, 1, 9, 0]) == 0\n assert candidate(nums1 = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 84\n assert candidate(nums1 = [5, 0, 2, 1, 3, 4],nums2 = [0, 1, 4, 2, 5, 3]) == 3\n assert candidate(nums1 = [3, 1, 2, 0, 7, 5, 6, 4],nums2 = [7, 5, 6, 4, 3, 1, 2, 0]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums2 = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 120\n assert candidate(nums1 = [3, 5, 7, 0, 2, 4, 6, 8, 1, 9],nums2 = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == 19\n assert candidate(nums1 = [2, 5, 3, 1, 0, 4],nums2 = [3, 5, 1, 4, 0, 2]) == 4\n assert candidate(nums1 = [5, 3, 8, 6, 2, 7, 4, 0, 1, 9],nums2 = [9, 1, 0, 2, 4, 6, 3, 8, 7, 5]) == 1\n assert candidate(nums1 = [1, 6, 3, 2, 7, 4, 5, 0],nums2 = [0, 5, 7, 2, 3, 1, 6, 4]) == 1\n assert candidate(nums1 = [4, 7, 1, 8, 3, 0, 9, 2, 5, 6],nums2 = [9, 2, 6, 0, 7, 3, 5, 8, 4, 1]) == 3\n assert candidate(nums1 = [6, 3, 0, 5, 2, 8, 1, 7, 4, 9],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 28\n assert candidate(nums1 = [4, 0, 3, 5, 2, 6, 1, 7],nums2 = [1, 5, 0, 3, 6, 2, 4, 7]) == 9\n assert candidate(nums1 = [2, 1, 4, 3, 6, 5, 8, 7, 0, 9],nums2 = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == 10\n assert candidate(nums1 = [5, 1, 4, 3, 2, 0],nums2 = [0, 2, 1, 5, 4, 3]) == 2\n assert candidate(nums1 = [9, 7, 1, 5, 6, 8, 0, 2, 3, 4],nums2 = [7, 4, 1, 5, 6, 0, 8, 2, 9, 3]) == 50\n assert candidate(nums1 = [0, 1, 5, 4, 3, 2, 6],nums2 = [6, 0, 5, 3, 2, 1, 4]) == 6\n assert candidate(nums1 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums1 = [6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [0, 3, 1, 6, 5, 4, 2],nums2 = [1, 6, 4, 5, 3, 0, 2]) == 7\n assert candidate(nums1 = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8],nums2 = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == 20\n assert candidate(nums1 = [1, 3, 2, 0, 5, 4],nums2 = [4, 0, 5, 2, 1, 3]) == 0\n assert candidate(nums1 = [2, 0, 4, 3, 5, 1],nums2 = [5, 4, 1, 0, 3, 2]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().goodTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long goodTriplets(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "goodTriplets", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2180, "task_id": "count-integers-with-even-digit-sum", "difficulty": "Easy", "problem_description": "Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are even.\nThe digit sum of a positive integer is the sum of all its digits.\n \nExample 1:\n\nInput: num = 4\nOutput: 2\nExplanation:\nThe only integers less than or equal to 4 whose digit sums are even are 2 and 4. \n\nExample 2:\n\nInput: num = 30\nOutput: 14\nExplanation:\nThe 14 integers less than or equal to 30 whose digit sums are even are\n2, 4, 6, 8, 11, 13, 15, 17, 19, 20, 22, 24, 26, and 28.\n\n \nConstraints:\n\n1 <= num <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 30) == 14\n assert candidate(num = 10) == 4\n assert candidate(num = 999) == 499\n assert candidate(num = 500) == 249\n assert candidate(num = 4) == 2\n assert candidate(num = 2) == 1\n assert candidate(num = 1) == 0\n assert candidate(num = 100) == 49\n assert candidate(num = 750) == 375\n assert candidate(num = 1000) == 499\n assert candidate(num = 432) == 215\n assert candidate(num = 666) == 333\n assert candidate(num = 456) == 227\n assert candidate(num = 250) == 124\n assert candidate(num = 345) == 172\n assert candidate(num = 99) == 49\n assert candidate(num = 222) == 111\n assert candidate(num = 200) == 100\n assert candidate(num = 444) == 222\n assert candidate(num = 555) == 277\n assert candidate(num = 888) == 444\n assert candidate(num = 123) == 61\n assert candidate(num = 789) == 394\n assert candidate(num = 333) == 166\n assert candidate(num = 375) == 187\n assert candidate(num = 256) == 127\n assert candidate(num = 800) == 400\n assert candidate(num = 678) == 338\n assert candidate(num = 623) == 311\n assert candidate(num = 600) == 300\n assert candidate(num = 777) == 388\n assert candidate(num = 850) == 424\n assert candidate(num = 899) == 449\n assert candidate(num = 299) == 149\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().countEven", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countEven(int num) {", "container": "Solution", "callable": "countEven", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2181, "task_id": "merge-nodes-in-between-zeros", "difficulty": "Medium", "problem_description": "You are given the head of a linked list, which contains a series of integers separated by 0's. The beginning and end of the linked list will have Node.val == 0.\nFor every two consecutive 0's, merge all the nodes lying in between them into a single node whose value is the sum of all the merged nodes. The modified list should not contain any 0's.\nReturn the head of the modified linked list.\n \nExample 1:\n\n\nInput: head = [0,3,1,0,4,5,2,0]\nOutput: [4,11]\nExplanation: \nThe above figure represents the given linked list. The modified list contains\n- The sum of the nodes marked in green: 3 + 1 = 4.\n- The sum of the nodes marked in red: 4 + 5 + 2 = 11.\n\nExample 2:\n\n\nInput: head = [0,1,0,3,0,2,2,0]\nOutput: [1,3,4]\nExplanation: \nThe above figure represents the given linked list. The modified list contains\n- The sum of the nodes marked in green: 1 = 1.\n- The sum of the nodes marked in red: 3 = 3.\n- The sum of the nodes marked in yellow: 2 + 2 = 4.\n\n \nConstraints:\n\nThe number of nodes in the list is in the range [3, 2 * 105].\n0 <= Node.val <= 1000\nThere are no two consecutive nodes with Node.val == 0.\nThe beginning and end of the linked list have Node.val == 0.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(head = list_node([0, 3, 1, 0, 4, 5, 2, 0])), list_node([4, 11]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 0])), list_node([15, 30]))\n assert is_same_list(candidate(head = list_node([0, 10, 0])), list_node([10]))\n assert is_same_list(candidate(head = list_node([0, 5, 6, 7, 8, 0, 9, 10, 11, 0])), list_node([26, 30]))\n assert is_same_list(candidate(head = list_node([0, 10, 20, 30, 0, 40, 50, 60, 0])), list_node([60, 150]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 0, 4, 5, 6, 0])), list_node([6, 15]))\n assert is_same_list(candidate(head = list_node([0, 999, 0, 1, 2, 3, 0, 1000, 0])), list_node([999, 6, 1000]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 3, 0, 2, 2, 0])), list_node([1, 3, 4]))\n assert is_same_list(candidate(head = list_node([0, 10, 0, 20, 30, 0, 40, 50, 0])), list_node([10, 50, 90]))\n assert is_same_list(candidate(head = list_node([0, 10, 20, 30, 0, 5, 5, 0, 4, 4, 4, 0])), list_node([60, 10, 12]))\n assert is_same_list(candidate(head = list_node([0, 999, 999, 999, 0])), list_node([2997]))\n assert is_same_list(candidate(head = list_node([0, 0])), list_node([0]))\n assert is_same_list(candidate(head = list_node([0, 1000, 0, 1000, 1000, 0])), list_node([1000, 2000]))\n assert is_same_list(candidate(head = list_node([0, 1000, 0])), list_node([1000]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0])), list_node([1, 0, 1, 0, 1, 0, 1, 0, 1]))\n assert is_same_list(candidate(head = list_node([0, 100, 0, 200, 0, 300, 0, 400, 0, 500, 0, 600, 0, 700, 0])), list_node([100, 200, 300, 400, 500, 600, 700]))\n assert is_same_list(candidate(head = list_node([0, 10, 20, 30, 40, 50, 0, 60, 70, 80, 90, 100, 0, 110, 120, 130, 0])), list_node([150, 400, 360]))\n assert is_same_list(candidate(head = list_node([0, 10, 0, 20, 0, 30, 0, 40, 0, 50, 0, 60, 0, 70, 0])), list_node([10, 20, 30, 40, 50, 60, 70]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0])), list_node([210]))\n assert is_same_list(candidate(head = list_node([0, 10, 20, 30, 40, 50, 0, 60, 70, 80, 90, 100, 0, 110, 120, 130, 0, 140, 150, 160, 170, 180, 190, 0])), list_node([150, 400, 360, 990]))\n assert is_same_list(candidate(head = list_node([0, 10, 20, 30, 40, 50, 0, 60, 70, 80, 90, 100, 0, 110, 120, 130, 140, 150, 0, 160, 170, 180, 190, 200, 0])), list_node([150, 400, 650, 900]))\n assert is_same_list(candidate(head = list_node([0, 999, 1, 0, 998, 2, 0, 997, 3, 0])), list_node([1000, 1000, 1000]))\n assert is_same_list(candidate(head = list_node([0, 999, 1, 2, 3, 0, 456, 789, 0, 101, 202, 303, 404, 0])), list_node([1005, 1245, 1010]))\n assert is_same_list(candidate(head = list_node([0, 100, 200, 300, 400, 500, 0, 600, 700, 800, 900, 1000, 0])), list_node([1500, 4000]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 10, 11, 12, 0, 13, 14, 15, 0, 16, 17, 18, 0, 19, 20, 21, 0])), list_node([6, 15, 24, 33, 42, 51, 60]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0])), list_node([120]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 10, 0, 11, 12, 13, 14, 0, 15, 16, 17, 0, 18, 19, 20, 0])), list_node([15, 40, 50, 48, 57]))\n assert is_same_list(candidate(head = list_node([0, 999, 999, 999, 999, 999, 0, 999, 999, 999, 999, 999, 0])), list_node([4995, 4995]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 0, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0])), list_node([6, 39, 145]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 0, 10, 11, 12, 0, 13, 14, 15, 16, 17, 0, 18, 19, 20, 0])), list_node([15, 30, 33, 75, 57]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([0, 100, 200, 300, 400, 0, 500, 600, 700, 800, 900, 0, 1000, 0])), list_node([1000, 3500, 1000]))\n assert is_same_list(candidate(head = list_node([0, 100, 200, 0, 300, 400, 500, 0, 600, 700, 800, 900, 1000, 0])), list_node([300, 1200, 4000]))\n assert is_same_list(candidate(head = list_node([0, 100, 200, 300, 400, 0, 500, 600, 700, 800, 0, 900, 1000, 0])), list_node([1000, 2600, 1900]))\n assert is_same_list(candidate(head = list_node([0, 999, 0, 998, 0, 997, 0, 996, 0, 995, 0, 994, 0, 993, 0, 992, 0, 991, 0])), list_node([999, 998, 997, 996, 995, 994, 993, 992, 991]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 10, 11, 12, 0])), list_node([6, 15, 24, 33]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0, 0])), list_node([0, 0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([0, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 0, 3, 3, 0])), list_node([4, 10, 6]))\n assert is_same_list(candidate(head = list_node([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])), list_node([325]))\n assert is_same_list(candidate(head = list_node([0, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 0, 3, 3, 3, 3, 3, 0])), list_node([5, 10, 15]))\n assert is_same_list(candidate(head = list_node([0, 10, 10, 10, 10, 0, 10, 10, 10, 10, 0, 10, 10, 10, 10, 0])), list_node([40, 40, 40]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])), list_node([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 is_same_list(candidate(head = list_node([0, 100, 200, 300, 400, 0, 500, 600, 700, 800, 900, 0, 1000, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0])), list_node([1000, 3500, 1000, 45]))\n assert is_same_list(candidate(head = list_node([0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0])), list_node([45, 55]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 0, 3, 4, 5, 0, 6, 7, 8, 9, 10, 0])), list_node([3, 12, 40]))\n assert is_same_list(candidate(head = list_node([0, 999, 0, 999, 999, 0, 999, 999, 999, 0, 999, 999, 999, 0])), list_node([999, 1998, 2997, 2997]))\n assert is_same_list(candidate(head = list_node([0, 100, 200, 300, 0, 400, 500, 600, 0, 700, 800, 900, 0])), list_node([600, 1500, 2400]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0])), list_node([45, 145]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15, 0])), list_node([45, 75]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 20, 21, 22, 23, 24, 25, 0])), list_node([15, 30, 145, 135]))\n assert is_same_list(candidate(head = list_node([0, 100, 200, 0, 300, 400, 500, 0, 600, 700, 0, 800, 900, 0])), list_node([300, 1200, 1300, 1700]))\n assert is_same_list(candidate(head = list_node([0, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 0, 3, 3, 3, 3, 3, 0, 4, 4, 4, 4, 4, 0])), list_node([5, 10, 15, 20]))\n assert is_same_list(candidate(head = list_node([0, 999, 1, 0, 998, 2, 0, 997, 3, 0, 996, 4, 0, 995, 5, 0])), list_node([1000, 1000, 1000, 1000, 1000]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 30, 0])), list_node([45, 145, 135, 140]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0])), list_node([45, 45]))\n assert is_same_list(candidate(head = list_node([0, 50, 50, 0, 100, 100, 100, 0, 150, 150, 150, 150, 0])), list_node([100, 300, 600]))\n assert is_same_list(candidate(head = list_node([0, 100, 200, 300, 0, 400, 500, 0, 600, 700, 0, 800, 900, 0, 1000, 0])), list_node([600, 900, 1300, 1700, 1000]))\n assert is_same_list(candidate(head = list_node([0, 10, 0, 20, 0, 30, 0, 40, 0, 50, 0, 60, 0, 70, 0, 80, 0, 90, 0, 100, 0])), list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0])), list_node([1, 3, 6, 10, 15]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 0, 15, 16, 17, 18, 19, 20, 0])), list_node([45, 60, 105]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9]))\n assert is_same_list(candidate(head = list_node([0, 500, 0, 500, 0, 500, 0, 500, 0, 500, 0, 500, 0, 500, 0, 500, 0, 500, 0])), list_node([500, 500, 500, 500, 500, 500, 500, 500, 500]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0])), list_node([1, 2, 3, 4, 5]))\n assert is_same_list(candidate(head = list_node([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])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 0, 4, 5, 0, 6, 7, 8, 0, 9, 10, 11, 0, 12, 13, 14, 0, 15, 16, 17, 0])), list_node([6, 9, 21, 30, 39, 48]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 0, 7, 8, 9, 10, 11, 0, 12, 13, 14, 0])), list_node([21, 45, 39]))\n assert is_same_list(candidate(head = list_node([0, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 0])), list_node([25, 25, 25]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))\n assert is_same_list(candidate(head = list_node([0, 250, 250, 250, 0, 750, 0, 125, 125, 125, 125, 0, 625, 625, 0])), list_node([750, 750, 500, 1250]))\n assert is_same_list(candidate(head = list_node([0, 100, 0, 200, 0, 300, 0, 400, 0, 500, 0, 600, 0, 700, 0, 800, 0, 900, 0, 1000, 0])), list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]))\n assert is_same_list(candidate(head = list_node([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0])), list_node([10, 20, 30]))\n assert is_same_list(candidate(head = list_node([0, 50, 50, 50, 50, 0, 50, 50, 50, 50, 0, 50, 50, 50, 50, 0, 50, 50, 50, 50, 0, 50, 50, 50, 50, 0])), list_node([200, 200, 200, 200, 200]))\n assert is_same_list(candidate(head = list_node([0, 999, 1, 0, 998, 2, 0, 997, 3, 0, 996, 4, 0])), list_node([1000, 1000, 1000, 1000]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 10, 0])), list_node([6, 15, 34]))\n assert is_same_list(candidate(head = list_node([0, 50, 25, 0, 75, 100, 0, 200, 150, 0, 300, 400, 0, 500, 600, 0, 700, 800, 900, 0])), list_node([75, 175, 350, 700, 1100, 2400]))\n assert is_same_list(candidate(head = list_node([0, 999, 0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0])), list_node([999, 15, 30, 165]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])), list_node([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 is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0])), list_node([55, 155]))\n assert is_same_list(candidate(head = list_node([0, 100, 200, 300, 400, 0, 500, 600, 700, 800, 900, 0, 1000, 1000, 1000, 0])), list_node([1000, 3500, 3000]))\n assert is_same_list(candidate(head = list_node([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])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0])), list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]))\n assert is_same_list(candidate(head = list_node([0, 100, 200, 0, 300, 400, 500, 0, 600, 700, 0])), list_node([300, 1200, 1300]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 2, 3, 4, 0, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15, 0, 16, 17, 18, 19, 20, 0])), list_node([1, 9, 35, 75, 90]))\n assert is_same_list(candidate(head = list_node([0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0])), list_node([45, 45]))\n assert is_same_list(candidate(head = list_node([0, 100, 200, 0, 300, 400, 500, 0, 600, 700, 800, 900, 0])), list_node([300, 1200, 3000]))\n assert is_same_list(candidate(head = list_node([0, 500, 400, 300, 200, 100, 0, 900, 800, 700, 600, 500, 0, 400, 300, 200, 100, 0, 900, 800, 700, 600, 500, 0, 400, 300, 200, 100, 0])), list_node([1500, 3500, 1000, 3500, 1000]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])), list_node([1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0])), list_node([19]))\n assert is_same_list(candidate(head = list_node([0, 10, 20, 0, 30, 40, 0, 50, 60, 70, 0, 80, 90, 0])), list_node([30, 70, 180, 170]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])), list_node([1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0])), list_node([0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([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, 0])), list_node([820]))\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().mergeNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {", "container": "Solution", "callable": "ListNode", "parameters": [], "return_type": "class ListNode {\n * int val;\n * ListNode next;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2182, "task_id": "construct-string-with-repeat-limit", "difficulty": "Medium", "problem_description": "You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from s.\nReturn the lexicographically largest repeatLimitedString possible.\nA string a is lexicographically larger than a string b if in the first position where a and b differ, string a has a letter that appears later in the alphabet than the corresponding letter in b. If the first min(a.length, b.length) characters do not differ, then the longer string is the lexicographically larger one.\n \nExample 1:\n\nInput: s = \"cczazcc\", repeatLimit = 3\nOutput: \"zzcccac\"\nExplanation: We use all of the characters from s to construct the repeatLimitedString \"zzcccac\".\nThe letter 'a' appears at most 1 time in a row.\nThe letter 'c' appears at most 3 times in a row.\nThe letter 'z' appears at most 2 times in a row.\nHence, no letter appears more than repeatLimit times in a row and the string is a valid repeatLimitedString.\nThe string is the lexicographically largest repeatLimitedString possible so we return \"zzcccac\".\nNote that the string \"zzcccca\" is lexicographically larger but the letter 'c' appears more than 3 times in a row, so it is not a valid repeatLimitedString.\n\nExample 2:\n\nInput: s = \"aababab\", repeatLimit = 2\nOutput: \"bbabaa\"\nExplanation: We use only some of the characters from s to construct the repeatLimitedString \"bbabaa\". \nThe letter 'a' appears at most 2 times in a row.\nThe letter 'b' appears at most 2 times in a row.\nHence, no letter appears more than repeatLimit times in a row and the string is a valid repeatLimitedString.\nThe string is the lexicographically largest repeatLimitedString possible so we return \"bbabaa\".\nNote that the string \"bbabaaa\" is lexicographically larger but the letter 'a' appears more than 2 times in a row, so it is not a valid repeatLimitedString.\n\n \nConstraints:\n\n1 <= repeatLimit <= s.length <= 105\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbccddeeff\",repeatLimit = 1) == \"fefedcdcbaba\"\n assert candidate(s = \"aabbccddeeff\",repeatLimit = 3) == \"ffeeddccbbaa\"\n assert candidate(s = \"cczazcc\",repeatLimit = 3) == \"zzcccac\"\n assert candidate(s = \"zzzzzzyyy\",repeatLimit = 2) == \"zzyzzyzzy\"\n assert candidate(s = \"zzzzzzzzz\",repeatLimit = 3) == \"zzz\"\n assert candidate(s = \"aababab\",repeatLimit = 2) == \"bbabaa\"\n assert candidate(s = \"leetcode\",repeatLimit = 3) == \"toleeedc\"\n assert candidate(s = \"a\",repeatLimit = 1) == \"a\"\n assert candidate(s = \"aabbcc\",repeatLimit = 1) == \"cbcba\"\n assert candidate(s = \"bbccddeee\",repeatLimit = 2) == \"eededccbb\"\n assert candidate(s = \"abcd\",repeatLimit = 1) == \"dcba\"\n assert candidate(s = \"zzzzzzzzzz\",repeatLimit = 2) == \"zz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",repeatLimit = 2) == \"zz\"\n assert candidate(s = \"abcabcabc\",repeatLimit = 1) == \"cbcbcba\"\n assert candidate(s = \"aaaaaabbbccc\",repeatLimit = 1) == \"cbcbcba\"\n assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpppppppppppppppppppppppppppppppp\",repeatLimit = 5) == \"qqqqqpqqqqqpqqqqqpqqqqqpqqqqqpqqqqqpqqppppp\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeeffffffffggggggggghhhhhhhhhiiiiiiiiijjjjjjjjkkkkkkkkklllllllllmmmmmmmmmnnnnnnnnnoooooooooppppppppqqqqqqqqqrrrrrrrrrssssssssstttttttttuuuuuuuuuvvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyzzzzzzzzz\",repeatLimit = 4) == \"zzzzyzzzzyzyyyyxyyxxxxwxxxxwwwwvwwwwvvvvuvvvvuuuutuuuuttttsttttssssrssssrrrrqrrrrqqqqpqqqqppppopppoooonoooonnnnmnnnnmmmmlmmmmllllkllllkkkkjkkkkjjjjijjjiiiihiiiihhhhghhhhggggfggggffffefffeeeedeeeeddddcdddccccbcccbbbbabbbaaaa\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",repeatLimit = 5) == \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"mmmmmmmllllllkkkkkkjjjjjjiiiiiihhhhhhggggggffffffeeeeee\",repeatLimit = 4) == \"mmmmlmmmllllklkkkkjkjjjjijiiiihihhhhghggggfgffffefeeee\"\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\",repeatLimit = 1) == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 10) == \"zzzzzzzzzz\"\n assert candidate(s = \"aabbbccccddeeeffffgggghhhhiiiiijjjjkkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxxyyyyyzzzzzzzzzzzz\",repeatLimit = 4) == \"zzzzyzzzzyzzzzyyyxxxxwxwwwvvvvuuuuttttssssrrrrqqqqppppoooonnnnmmmmllllkkkkjkjjjiiiihihhhggggffffeeeddccccbbbaa\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",repeatLimit = 2) == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",repeatLimit = 1) == \"zyzyxwxwvuvutstsrqrqpoponmnmlklkjijihghgfefedcdcbaba\"\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggg\",repeatLimit = 4) == \"ggggffffeeeeddddccccbbbbaaaa\"\n assert candidate(s = \"zzzzzzzzzzzzzzzyyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\",repeatLimit = 1) == \"zyzyzyzyzyzyzyzyzyzyzyzxzxzxzxwxwxwxwxwvwvuvuvuvuvutututststststrtrtrqrqpqpqpqpqoqnqnmnmnmlmlklkjkjijihihigfgfgfgfefefdcdcdcbab\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxxyyyyyzzzzz\",repeatLimit = 2) == \"zzyzzyzyyxyxxwxxwwvwvvuvuututtstssrsrrqrqqpqppopoononnmnmmlmllklkkjkjjijiihihhggfgffeededdccbcbbaa\"\n assert candidate(s = \"pppppppppooooooonnnnmmmllllkkkkjjjjiiiihhhhhggggfffffeeeee\",repeatLimit = 4) == \"ppppoppppopoooononnnmmmllllkkkkjjjjiiiihhhhghgggffffefeeee\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",repeatLimit = 2) == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"zzzzzzzzzzzzzzzyyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\",repeatLimit = 5) == \"zzzzzyzzzzzyzzzzzyyyyyxyyyyxxxxxwxxwwwwwvvvvvuvuuuuututttttstttsssrrrrqqqqqpqqqppponnnnmmmmlllkkkjjjiiiihhggggfffffefedddcccbba\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",repeatLimit = 1) == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeefffffff\",repeatLimit = 3) == \"fffefffefeeedeeededddcdddcccbcccbcbbbabbbaaa\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 1) == \"z\"\n assert candidate(s = \"zzzzzzzzzzzzzzzyyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\",repeatLimit = 3) == \"zzzyzzzyzzzyzzzyzzzyyyxyyyxyxxxwxxxwwwvwwvvvuvvuuutuuutttstttsttssrrrqrqqqpqqqpqpponnnmnmmmlllkkkjjjiiihihgggfgfffeffedddcccbba\"\n assert candidate(s = \"zzzzzzzzzzzzzzzyyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\",repeatLimit = 10) == \"zzzzzzzzzzyzzzzzyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\"\n assert candidate(s = \"xyzzzzzzzzzzyx\",repeatLimit = 5) == \"zzzzzyzzzzzyxx\"\n assert candidate(s = \"zzzzzzzzzzzzzzzyyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\",repeatLimit = 2) == \"zzyzzyzzyzzyzzyzzyzzyzyyxyyxxwxxwxxwxwwvwvvuvvuvuutuututtsttsttstsrrqrrqqpqqpqqpqponnmnnmmlmllkkjkjjiihiihggfggffeffefddcdccbba\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 5) == \"zzzzzyzzzzzxzzzzzwzzzzzvzzzzzuzzzzztzzzzzszzzzzrzzqponmlkjihgfedcba\"\n assert candidate(s = \"nnnnnnnnnmmmmmmmmmllllllllllkkkkkkkkkkjjjjjjjjjjiiiiiiiiiihhhhhhhhhhggggggggggffffffeeeeeeeeddddddddccccccccbbbaaaaaaaa\",repeatLimit = 10) == \"nnnnnnnnnmmmmmmmmmllllllllllkkkkkkkkkkjjjjjjjjjjiiiiiiiiiihhhhhhhhhhggggggggggffffffeeeeeeeeddddddddccccccccbbbaaaaaaaa\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 5) == \"zzzzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 5) == \"zzzzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 5) == \"zzzzz\"\n assert candidate(s = \"mnlkjihgfedcba\",repeatLimit = 1) == \"nmlkjihgfedcba\"\n assert candidate(s = \"aaaaaaaaaaaabbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccdddddddddddddddddddddddddddddddddddddddddd\",repeatLimit = 5) == \"dddddcdddddcdddddcdddddcdddddcdddddcdddddcdddddcddcccccbcccccbcccccbcccccbbbbbabbbbbabbbbbabaaaaa\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 1) == \"z\"\n assert candidate(s = \"pppppqqqqqrrrrrssssstttttuuuuuvvvvvwwwwwxxxxxyyyyyzzzzz\",repeatLimit = 2) == \"zzyzzyzyyxyxxwxxwwvwwvvuvvuutuuttsttssrssrrqrrqqpqqpp\"\n assert candidate(s = \"aaaaaaaaaaaaaabbbbbbbbbbbbccccccccccccddddddddddddd\",repeatLimit = 3) == \"dddcdddcdddcdddcdcccbcccbccbbbabbbabbbabaaa\"\n assert candidate(s = \"zzzzzyyyyxxxxwwvvuttrrssqqppoonnmmllkkjjiihhggffeeddccbbaaa\",repeatLimit = 10) == \"zzzzzyyyyxxxxwwvvuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaaa\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 3) == \"zzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 15) == \"zzzzzzzzzzzzzzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 10) == \"zzzzzzzzzz\"\n assert candidate(s = \"zzzzzyyyyxxwwvvuuuutttssrrqqppoonnmmllkkjjiihhhggffeeddccbbaa\",repeatLimit = 2) == \"zzyzzyzyyxxwwvvuutuuttssrrqqppoonnmmllkkjjiihhghgffeeddccbbaa\"\n assert candidate(s = \"abacabadabacaba\",repeatLimit = 2) == \"dccbbabbaa\"\n assert candidate(s = \"ssssssssssssssssssssssssssssssss\",repeatLimit = 2) == \"ss\"\n assert candidate(s = \"zzzzzzzyyyy\",repeatLimit = 3) == \"zzzyzzzyzyy\"\n assert candidate(s = \"pppppppppppppppppppppppppppppppp\",repeatLimit = 3) == \"ppp\"\n assert candidate(s = \"zzzzzyyyyxxxxwwvvuttrrssqqppoonnmmllkkjjiihhggffeeddccbbaaa\",repeatLimit = 2) == \"zzyzzyzyyxxwxxwvvuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 5) == \"zzzzz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",repeatLimit = 4) == \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"a\",repeatLimit = 10) == \"a\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 10) == \"zzzzzzzzzz\"\n assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",repeatLimit = 7) == \"qqqqqqq\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 1) == \"z\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",repeatLimit = 1) == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",repeatLimit = 3) == \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",repeatLimit = 10) == \"zyxwvutsrqponmlkjihgfedcba\"\n"}, "metadata": {"canonical_parameter_names": ["s", "repeatLimit"], "leetcode_dataset_entry_point": "Solution().repeatLimitedString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String repeatLimitedString(String s, int repeatLimit) {", "container": "Solution", "callable": "repeatLimitedString", "parameters": [{"name": "s", "type": "String"}, {"name": "repeatLimit", "type": "int"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2183, "task_id": "count-array-pairs-divisible-by-k", "difficulty": "Hard", "problem_description": "Given a 0-indexed integer array nums of length n and an integer k, return the number of pairs (i, j) such that:\n\n0 <= i < j <= n - 1 and\nnums[i] * nums[j] is divisible by k.\n\n \nExample 1:\n\nInput: nums = [1,2,3,4,5], k = 2\nOutput: 7\nExplanation: \nThe 7 pairs of indices whose corresponding products are divisible by 2 are\n(0, 1), (0, 3), (1, 2), (1, 3), (1, 4), (2, 3), and (3, 4).\nTheir products are 2, 4, 6, 8, 10, 12, and 20 respectively.\nOther pairs such as (0, 2) and (2, 4) have products 3 and 15 respectively, which are not divisible by 2. \n\nExample 2:\n\nInput: nums = [1,2,3,4], k = 5\nOutput: 0\nExplanation: There does not exist any pair of indices whose corresponding product is divisible by 5.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i], k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7],k = 7) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 10\n assert candidate(nums = [5, 5, 5, 5],k = 5) == 6\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 7\n assert candidate(nums = [6, 12, 18, 24],k = 12) == 6\n assert candidate(nums = [1, 3, 5, 7, 9],k = 3) == 7\n assert candidate(nums = [7, 14, 21, 28, 35],k = 7) == 10\n assert candidate(nums = [2, 4, 6, 8, 10],k = 3) == 4\n assert candidate(nums = [10, 20, 30, 40],k = 10) == 6\n assert candidate(nums = [5, 10, 15, 20, 25],k = 5) == 10\n assert candidate(nums = [7, 14, 21, 28],k = 7) == 6\n assert candidate(nums = [1, 3, 5, 7, 9],k = 2) == 0\n assert candidate(nums = [2, 4, 6, 8, 10],k = 4) == 10\n assert candidate(nums = [1, 2, 3, 4],k = 5) == 0\n assert candidate(nums = [3, 5, 7, 11],k = 1) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 45\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240],k = 12) == 190\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],k = 101) == 45\n assert candidate(nums = [100, 200, 300, 400, 500, 600],k = 100) == 15\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 5) == 45\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 13) == 45\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 13) == 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],k = 6) == 185\n assert candidate(nums = [24, 48, 72, 96, 120],k = 24) == 10\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 9) == 45\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24],k = 3) == 28\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 5) == 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],k = 1) == 190\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) == 190\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 45\n assert candidate(nums = [8, 12, 18, 24, 30, 36, 42],k = 6) == 21\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 10\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255],k = 17) == 105\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 45\n assert candidate(nums = [15, 25, 35, 45, 55],k = 15) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 5) == 105\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195],k = 13) == 105\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 14) == 35\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132],k = 11) == 66\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 45\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77],k = 11) == 21\n assert candidate(nums = [7, 14, 28, 56, 112],k = 14) == 10\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81],k = 9) == 36\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 100000) == 9\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],k = 100000) == 15\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],k = 9) == 55\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996],k = 5) == 4\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],k = 8) == 45\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 17\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 4) == 45\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170],k = 17) == 45\n assert candidate(nums = [13, 26, 39, 52, 65],k = 13) == 10\n assert candidate(nums = [6, 12, 18, 24, 30],k = 12) == 10\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 15) == 45\n assert candidate(nums = [77, 154, 231, 308, 385, 462, 539, 616, 693, 770],k = 11) == 45\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],k = 9) == 66\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 21) == 45\n assert candidate(nums = [6, 12, 18, 24, 30],k = 6) == 10\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],k = 101) == 45\n assert candidate(nums = [9, 18, 27, 36, 45],k = 9) == 10\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 16) == 101\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 = 5) == 190\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 21) == 45\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 = 1) == 190\n assert candidate(nums = [49, 98, 147, 196, 245, 294, 343, 392, 441, 490],k = 49) == 45\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 11) == 45\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 0\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190],k = 19) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 3) == 60\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],k = 100) == 32\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105],k = 15) == 21\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 7) == 105\n assert candidate(nums = [6, 8, 10, 12, 14, 16, 18],k = 12) == 15\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],k = 3) == 21\n assert candidate(nums = [8, 16, 32, 64, 128],k = 8) == 10\n assert candidate(nums = [15, 30, 45, 60, 75],k = 15) == 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 = 3) == 112\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135],k = 9) == 105\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90],k = 6) == 105\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 5) == 66\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 45\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 15) == 45\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 = 2) == 300\n assert candidate(nums = [15, 25, 35, 45, 55],k = 5) == 10\n assert candidate(nums = [6, 12, 18, 24, 30, 36],k = 12) == 15\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == 45\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 7) == 45\n assert candidate(nums = [11, 22, 33, 44, 55],k = 11) == 10\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],k = 8) == 105\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260],k = 13) == 190\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 45\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230],k = 23) == 45\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],k = 100000) == 10\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64],k = 16) == 28\n assert candidate(nums = [25, 50, 75, 100, 125, 150],k = 25) == 15\n assert candidate(nums = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116],k = 11) == 37\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 3) == 34\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],k = 5) == 44\n assert candidate(nums = [10, 20, 30, 40, 50],k = 20) == 10\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 11) == 45\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96],k = 8) == 66\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countPairs(int[] nums, int k) {", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2185, "task_id": "counting-words-with-a-given-prefix", "difficulty": "Easy", "problem_description": "You are given an array of strings words and a string pref.\nReturn the number of strings in words that contain pref as a prefix.\nA prefix of a string s is any leading contiguous substring of s.\n \nExample 1:\n\nInput: words = [\"pay\",\"attention\",\"practice\",\"attend\"], pref = \"at\"\nOutput: 2\nExplanation: The 2 strings that contain \"at\" as a prefix are: \"attention\" and \"attend\".\n\nExample 2:\n\nInput: words = [\"leetcode\",\"win\",\"loops\",\"success\"], pref = \"code\"\nOutput: 0\nExplanation: There are no strings that contain \"code\" as a prefix.\n\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length, pref.length <= 100\nwords[i] and pref consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['test', 'testing', 'tested', 'testing'],pref = \"test\") == 4\n assert candidate(words = ['abc', 'bcd', 'cde'],pref = \"a\") == 1\n assert candidate(words = ['hello', 'world', 'helium', 'helper'],pref = \"hel\") == 3\n assert candidate(words = ['banana', 'bandana', 'banner', 'balance'],pref = \"ban\") == 3\n assert candidate(words = ['hello', 'hell', 'hero', 'herald'],pref = \"he\") == 4\n assert candidate(words = ['pay', 'attention', 'practice', 'attend'],pref = \"at\") == 2\n assert candidate(words = ['hello', 'world'],pref = \"hi\") == 0\n assert candidate(words = ['hello', 'hell', 'helper'],pref = \"hel\") == 3\n assert candidate(words = ['apple', 'apricot', 'application'],pref = \"app\") == 2\n assert candidate(words = ['apple', 'apricot', 'application', 'appetite'],pref = \"app\") == 3\n assert candidate(words = ['cat', 'caterpillar', 'catalog', 'category'],pref = \"cat\") == 4\n assert candidate(words = ['apple', 'apricot', 'banana', 'apex'],pref = \"ap\") == 3\n assert candidate(words = ['banana', 'band', 'ball'],pref = \"ba\") == 3\n assert candidate(words = ['banana', 'bandana', 'baptism'],pref = \"ban\") == 2\n assert candidate(words = ['apple', 'application', 'apricot', 'apex'],pref = \"ap\") == 4\n assert candidate(words = ['leetcode', 'win', 'loops', 'success'],pref = \"code\") == 0\n assert candidate(words = ['database', 'datacenter', 'datamine', 'data'],pref = \"data\") == 4\n assert candidate(words = ['integration', 'integrate', 'interact', 'interactive'],pref = \"inte\") == 4\n assert candidate(words = ['algorithm', 'array', 'application', 'arithmetic'],pref = \"arr\") == 1\n assert candidate(words = ['intersection', 'interface', 'internal', 'interact'],pref = \"inter\") == 4\n assert candidate(words = ['unpredictable', 'unpredicted', 'unpredictably', 'unpredicting'],pref = \"unpred\") == 4\n assert candidate(words = ['prefix', 'prepend', 'presentation', 'preference'],pref = \"pre\") == 4\n assert candidate(words = ['challenge', 'champion', 'chance', 'character'],pref = \"cha\") == 4\n assert candidate(words = ['management', 'manager', 'manufacture', 'maintain'],pref = \"man\") == 3\n assert candidate(words = ['interpolation', 'interpolate', 'interpolator', 'interpolated'],pref = \"inter\") == 4\n assert candidate(words = ['technology', 'technique', 'technical', 'technological'],pref = \"tech\") == 4\n assert candidate(words = ['universe', 'uniform', 'unique', 'unit'],pref = \"uni\") == 4\n assert candidate(words = ['programming', 'python', 'problem', 'project', 'practice'],pref = \"pro\") == 3\n assert candidate(words = ['document', 'documentation', 'documentary', 'documents'],pref = \"docu\") == 4\n assert candidate(words = ['environment', 'envelope', 'encyclopedia', 'enterprise'],pref = \"env\") == 2\n assert candidate(words = ['interview', 'international', 'internet', 'introduce'],pref = \"inter\") == 3\n assert candidate(words = ['communication', 'community', 'commemoration', 'commentary'],pref = \"comm\") == 4\n assert candidate(words = ['algorithm', 'array', 'application', 'apricot'],pref = \"app\") == 1\n assert candidate(words = ['cryptography', 'cryptanalysis', 'cryptographic', 'cryptology'],pref = \"crypto\") == 3\n assert candidate(words = ['interact', 'interaction', 'interactive', 'interior', 'intercept'],pref = \"inter\") == 5\n assert candidate(words = ['fantastic', 'fancy', 'fantasy', 'fanatic'],pref = \"fan\") == 4\n assert candidate(words = ['pseudo', 'pseudocode', 'pseudorandom', 'pseudoscience'],pref = \"pseudo\") == 4\n assert candidate(words = ['mathematical', 'mathematics', 'mathematically', 'mathematize'],pref = \"math\") == 4\n assert candidate(words = ['programming', 'problem', 'prefix', 'preference'],pref = \"pre\") == 2\n assert candidate(words = ['biography', 'biologist', 'biological', 'biographical'],pref = \"bio\") == 4\n assert candidate(words = ['unbelievable', 'universe', 'unique', 'unanimous'],pref = \"un\") == 4\n assert candidate(words = ['congratulations', 'congratulate', 'congratulatory', 'congregate', 'congruity'],pref = \"cong\") == 5\n assert candidate(words = ['supplementary', 'supplement', 'supplier', 'suppose'],pref = \"sup\") == 4\n assert candidate(words = ['community', 'commune', 'communicate', 'common'],pref = \"comm\") == 4\n assert candidate(words = ['extraterrestrial', 'extraterrestrial', 'extraterrestrial', 'extraterrestrial'],pref = \"extra\") == 4\n assert candidate(words = ['algorithm', 'array', 'application', 'applet'],pref = \"app\") == 2\n assert candidate(words = ['abracadabra', 'abstract', 'absorb', 'academic'],pref = \"abs\") == 2\n assert candidate(words = ['congruence', 'congruent', 'congruently', 'congruency'],pref = \"congru\") == 4\n assert candidate(words = ['meticulous', 'meticulate', 'metaphor', 'metaphysics'],pref = \"metic\") == 2\n assert candidate(words = ['biological', 'biography', 'biologist', 'biology', 'bioluminescence'],pref = \"biol\") == 4\n assert candidate(words = ['application', 'approach', 'appetizer', 'append'],pref = \"app\") == 4\n assert candidate(words = ['scientific', 'scientist', 'science', 'sciences'],pref = \"sci\") == 4\n assert candidate(words = ['communication', 'community', 'common', 'commodity'],pref = \"com\") == 4\n assert candidate(words = ['quantization', 'quantize', 'quantitative', 'quantitative'],pref = \"quant\") == 4\n assert candidate(words = ['prefix', 'prepend', 'presentation', 'premature'],pref = \"pre\") == 4\n assert candidate(words = ['continuous', 'concurrent', 'conclusion', 'condition'],pref = \"con\") == 4\n assert candidate(words = ['programming', 'program', 'pro', 'professor'],pref = \"pro\") == 4\n assert candidate(words = ['management', 'manager', 'manage', 'mandate'],pref = \"man\") == 4\n assert candidate(words = ['transformation', 'transmit', 'transparent', 'transient'],pref = \"tran\") == 4\n assert candidate(words = ['administrator', 'administration', 'administrative', 'administratively'],pref = \"admin\") == 4\n assert candidate(words = ['circumstance', 'circuit', 'circulate', 'circulation', 'circular'],pref = \"circu\") == 5\n assert candidate(words = ['characterization', 'character', 'characteristic', 'characterization'],pref = \"char\") == 4\n assert candidate(words = ['environment', 'envy', 'envelope', 'evening'],pref = \"env\") == 3\n assert candidate(words = ['database', 'data', 'datagram', 'datastructure'],pref = \"data\") == 4\n assert candidate(words = ['celebration', 'celebrate', 'celebrity', 'celebratory', 'celestial'],pref = \"celeb\") == 4\n assert candidate(words = ['cryptography', 'crypt', 'crypto', 'cryptanalysis'],pref = \"crypt\") == 4\n assert candidate(words = ['photography', 'photo', 'photobook', 'photographer'],pref = \"photo\") == 4\n assert candidate(words = ['magnify', 'magnificent', 'magnetic', 'magnetism'],pref = \"mag\") == 4\n assert candidate(words = ['organization', 'organize', 'organ', 'organically'],pref = \"org\") == 4\n assert candidate(words = ['algorithm', 'algebra', 'almond', 'alert'],pref = \"alg\") == 2\n assert candidate(words = ['algorithm', 'array', 'application', 'apple'],pref = \"app\") == 2\n assert candidate(words = ['communication', 'community', 'commitment', 'common'],pref = \"comm\") == 4\n assert candidate(words = ['developer', 'debug', 'deploy', 'document'],pref = \"de\") == 3\n assert candidate(words = ['perpendicular', 'perpendicularity', 'perpendicularity', 'perpendicularly'],pref = \"perpendicular\") == 4\n assert candidate(words = ['environment', 'engine', 'error', 'example'],pref = \"en\") == 2\n assert candidate(words = ['university', 'uniform', 'unique', 'universe'],pref = \"uni\") == 4\n assert candidate(words = ['community', 'communist', 'common', 'comment'],pref = \"comm\") == 4\n assert candidate(words = ['literature', 'literacy', 'literary', 'literate'],pref = \"lit\") == 4\n assert candidate(words = ['sequoia', 'sequence', 'series', 'serial'],pref = \"ser\") == 2\n assert candidate(words = ['communication', 'community', 'companion', 'commune'],pref = \"comm\") == 3\n assert candidate(words = ['algorithm', 'algebra', 'alignment', 'algorithmic'],pref = \"algo\") == 2\n assert candidate(words = ['character', 'chart', 'chapter', 'charge'],pref = \"char\") == 3\n assert candidate(words = ['transport', 'trap', 'trapezium', 'traverse'],pref = \"tra\") == 4\n assert candidate(words = ['communication', 'commute', 'community', 'commotion', 'common'],pref = \"comm\") == 5\n assert candidate(words = ['environment', 'energy', 'engage', 'engageable'],pref = \"en\") == 4\n assert candidate(words = ['identification', 'individual', 'idea', 'illegal'],pref = \"iden\") == 1\n assert candidate(words = ['supreme', 'superior', 'surpass', 'surround'],pref = \"sur\") == 2\n assert candidate(words = ['transformation', 'transmit', 'transit', 'transformation', 'transition'],pref = \"trans\") == 5\n assert candidate(words = ['automation', 'automatic', 'automate', 'auto'],pref = \"auto\") == 4\n assert candidate(words = ['configuration', 'compute', 'container', 'cloud'],pref = \"con\") == 2\n assert candidate(words = ['communication', 'community', 'commitment', 'compassionate'],pref = \"comm\") == 3\n assert candidate(words = ['programming', 'program', 'pro', 'progress'],pref = \"pro\") == 4\n assert candidate(words = ['absolutely', 'absolute', 'absorb', 'abnormal'],pref = \"abs\") == 3\n assert candidate(words = ['statistics', 'statistical', 'statue', 'status'],pref = \"stat\") == 4\n assert candidate(words = ['prefix', 'prefixes', 'preferring', 'preference'],pref = \"pref\") == 4\n assert candidate(words = ['congratulations', 'congratulate', 'congratulatory', 'congratulated'],pref = \"congrat\") == 4\n assert candidate(words = ['environment', 'essential', 'establish', 'engage'],pref = \"en\") == 2\n assert candidate(words = ['substitution', 'substitute', 'substituted', 'substituting'],pref = \"sub\") == 4\n assert candidate(words = ['distribution', 'distribute', 'disastrous', 'discuss', 'disease'],pref = \"dis\") == 5\n assert candidate(words = ['development', 'deploy', 'debug', 'document'],pref = \"de\") == 3\n assert candidate(words = ['super', 'superhero', 'supercalifragilisticexpialidocious', 'supervillain'],pref = \"super\") == 4\n assert candidate(words = ['maintenance', 'maintain', 'maintenance', 'maintained'],pref = \"maint\") == 4\n assert candidate(words = ['python', 'pyramid', 'pythia', 'pyrotechnic'],pref = \"pyt\") == 2\n assert candidate(words = ['algorithm', 'algebra', 'alibi', 'alien', 'alimony'],pref = \"ali\") == 3\n assert candidate(words = ['remarkable', 'remark', 'remember', 'remind'],pref = \"rem\") == 4\n assert candidate(words = ['septagon', 'septagonal', 'septembre', 'septenary'],pref = \"sept\") == 4\n assert candidate(words = ['programming', 'progress', 'prompt', 'priority'],pref = \"pro\") == 3\n assert candidate(words = ['document', 'documentation', 'documentary', 'documents'],pref = \"doc\") == 4\n assert candidate(words = ['monarch', 'monarchy', 'monarchic', 'monarchically'],pref = \"monarch\") == 4\n assert candidate(words = ['hemisphere', 'hemispherical', 'hemispheres', 'hemispheric'],pref = \"hemis\") == 4\n assert candidate(words = ['environment', 'engage', 'enhance', 'enforce', 'ensure'],pref = \"enf\") == 1\n assert candidate(words = ['persistent', 'perspective', 'personality', 'person', 'personnel'],pref = \"pers\") == 5\n assert candidate(words = ['prefix', 'preference', 'presentation', 'prevent', 'president'],pref = \"pre\") == 5\n assert candidate(words = ['parallelogram', 'parallelepiped', 'parallel', 'parallelograms'],pref = \"parallel\") == 4\n assert candidate(words = ['intelligence', 'integrate', 'intensity', 'interact'],pref = \"inte\") == 4\n assert candidate(words = ['information', 'infrastructure', 'insurance', 'initial'],pref = \"in\") == 4\n assert candidate(words = ['transport', 'transmit', 'transformation', 'transition'],pref = \"trans\") == 4\n assert candidate(words = ['establish', 'estimate', 'essential', 'establishment'],pref = \"est\") == 3\n assert candidate(words = ['algorithm', 'algebra', 'alchemist', 'alchemy'],pref = \"alg\") == 2\n assert candidate(words = ['environment', 'envelope', 'engage', 'enhance'],pref = \"en\") == 4\n assert candidate(words = ['transport', 'transmit', 'transit', 'transformation', 'transition'],pref = \"trans\") == 5\n assert candidate(words = ['programming', 'problem', 'process', 'productivity'],pref = \"pro\") == 4\n assert candidate(words = ['programming', 'pro', 'processor', 'productivity'],pref = \"pro\") == 4\n assert candidate(words = ['encyclopedia', 'encyclopedias', 'encyclopedic', 'encyclopedically'],pref = \"ency\") == 4\n assert candidate(words = ['apple', 'application', 'appetite', 'apparent'],pref = \"app\") == 4\n assert candidate(words = ['zebra', 'zephyr', 'zoo', 'zealous'],pref = \"ze\") == 3\n assert candidate(words = ['prefix', 'prefixes', 'preference', 'preferring'],pref = \"pref\") == 4\n assert candidate(words = ['communication', 'community', 'commitment', 'commission'],pref = \"com\") == 4\n assert candidate(words = ['hypothesis', 'historical', 'hyphen', 'hydrogen'],pref = \"hy\") == 3\n assert candidate(words = ['transformation', 'transfer', 'transform', 'transformer'],pref = \"trans\") == 4\n assert candidate(words = ['transaction', 'transfer', 'transition', 'transportation'],pref = \"tran\") == 4\n assert candidate(words = ['abracadabra', 'abrakadabras', 'abracadabrac', 'abracadabrad'],pref = \"abrac\") == 3\n assert candidate(words = ['interview', 'integrate', 'interaction', 'interface'],pref = \"inte\") == 4\n assert candidate(words = ['fantastic', 'fantasy', 'fancy', 'fantastician'],pref = \"fant\") == 3\n assert candidate(words = ['communication', 'communicate', 'communist', 'commune'],pref = \"comm\") == 4\n assert candidate(words = ['environment', 'environ', 'environmental', 'envelope'],pref = \"env\") == 4\n assert candidate(words = ['education', 'educational', 'educate', 'educator'],pref = \"edu\") == 4\n assert candidate(words = ['automation', 'automobile', 'automatic', 'automate'],pref = \"auto\") == 4\n assert candidate(words = ['customization', 'customize', 'custom', 'customarily'],pref = \"cust\") == 4\n assert candidate(words = ['environment', 'encourage', 'endure', 'ensure'],pref = \"en\") == 4\n assert candidate(words = ['prefix', 'predict', 'prevent', 'preach', 'prelude'],pref = \"pre\") == 5\n assert candidate(words = ['elephant', 'elegant', 'elephantine', 'election'],pref = \"ele\") == 4\n assert candidate(words = ['celebration', 'celebrity', 'celebratory', 'celebration'],pref = \"celeb\") == 4\n assert candidate(words = ['achievement', 'achieve', 'achiever', 'achievable'],pref = \"achi\") == 4\n assert candidate(words = ['development', 'debug', 'document', 'disk'],pref = \"de\") == 2\n assert candidate(words = ['prefix', 'preference', 'prevent', 'president'],pref = \"pre\") == 4\n assert candidate(words = ['automobile', 'automatic', 'automate', 'automaton'],pref = \"auto\") == 4\n assert candidate(words = ['terrific', 'terrify', 'terrestrial', 'territory'],pref = \"terr\") == 4\n assert candidate(words = ['synchronization', 'synchronous', 'synchronize', 'synchronized'],pref = \"synch\") == 4\n assert candidate(words = ['abbreviation', 'abrupt', 'absorb', 'absolute'],pref = \"abs\") == 2\n assert candidate(words = ['repetition', 'reproductive', 'represent', 'reputation', 'reprehend'],pref = \"rep\") == 5\n assert candidate(words = ['apple', 'application', 'applicant', 'appetite'],pref = \"app\") == 4\n assert candidate(words = ['xylophone', 'xylography', 'xylophone', 'xylophone'],pref = \"xy\") == 4\n"}, "metadata": {"canonical_parameter_names": ["words", "pref"], "leetcode_dataset_entry_point": "Solution().prefixCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int prefixCount(String[] words, String pref) {", "container": "Solution", "callable": "prefixCount", "parameters": [{"name": "words", "type": "String[]"}, {"name": "pref", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2186, "task_id": "minimum-number-of-steps-to-make-two-strings-anagram-ii", "difficulty": "Medium", "problem_description": "You are given two strings s and t. In one step, you can append any character to either s or t.\nReturn the minimum number of steps to make s and t anagrams of each other.\nAn anagram of a string is a string that contains the same characters with a different (or the same) ordering.\n \nExample 1:\n\nInput: s = \"leetcode\", t = \"coats\"\nOutput: 7\nExplanation: \n- In 2 steps, we can append the letters in \"as\" onto s = \"leetcode\", forming s = \"leetcodeas\".\n- In 5 steps, we can append the letters in \"leede\" onto t = \"coats\", forming t = \"coatsleede\".\n\"leetcodeas\" and \"coatsleede\" are now anagrams of each other.\nWe used a total of 2 + 5 = 7 steps.\nIt can be shown that there is no way to make them anagrams of each other with less than 7 steps.\n\nExample 2:\n\nInput: s = \"night\", t = \"thing\"\nOutput: 0\nExplanation: The given strings are already anagrams of each other. Thus, we do not need any further steps.\n\n \nConstraints:\n\n1 <= s.length, t.length <= 2 * 105\ns and t consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaa\",t = \"bbbb\") == 8\n assert candidate(s = \"aabbcc\",t = \"abc\") == 3\n assert candidate(s = \"anagram\",t = \"nagaram\") == 0\n assert candidate(s = \"rat\",t = \"car\") == 2\n assert candidate(s = \"xyz\",t = \"zyxwvut\") == 4\n assert candidate(s = \"\",t = \"\") == 0\n assert candidate(s = \"leetcode\",t = \"coats\") == 7\n assert candidate(s = \"aaaaa\",t = \"bbbbb\") == 10\n assert candidate(s = \"ab\",t = \"ba\") == 0\n assert candidate(s = \"night\",t = \"thing\") == 0\n assert candidate(s = \"abacabadaba\",t = \"zzzzz\") == 16\n assert candidate(s = \"aa\",t = \"bb\") == 4\n assert candidate(s = \"a\",t = \"a\") == 0\n assert candidate(s = \"abcd\",t = \"dcba\") == 0\n assert candidate(s = \"abc\",t = \"def\") == 6\n assert candidate(s = \"a\",t = \"b\") == 2\n assert candidate(s = \"abacabadabacaba\",t = \"abcde\") == 12\n assert candidate(s = \"same\",t = \"same\") == 0\n assert candidate(s = \"aabbccddeeff\",t = \"abcdef\") == 6\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"\") == 26\n assert candidate(s = \"oneonetwothree\",t = \"threeonetwoone\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\") == 50\n assert candidate(s = \"thisisateststring\",t = \"testingstring\") == 8\n assert candidate(s = \"aabbccddeeff\",t = \"ffeeddccbbAA\") == 4\n assert candidate(s = \"anagram\",t = \"mangaar\") == 0\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",t = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 88\n assert candidate(s = \"hello\",t = \"world\") == 6\n assert candidate(s = \"mississippi\",t = \"ississimppimiss\") == 4\n assert candidate(s = \"pythonprogramming\",t = \"javaprogramming\") == 10\n assert candidate(s = \"repeatrepeatrepeat\",t = \"peatpeatpeatre\") == 4\n assert candidate(s = \"xxyyzz\",t = \"zzzzyyxx\") == 2\n assert candidate(s = \"deified\",t = \"deified\") == 0\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",t = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"programmingpython\") == 0\n assert candidate(s = \"thisisalongstringsample\",t = \"samplesamplealongstringthisis\") == 6\n assert candidate(s = \"complexinputfortesting\",t = \"testingfortestingcomplex\") == 6\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzxxccvvaabbeeffgghhiijjkkllmmnnooppqqrrssttuuvvww\") == 6\n assert candidate(s = \"abracadabra\",t = \"barbarian\") == 6\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 1\n assert candidate(s = \"abracadabra\",t = \"abrakadabracadabra\") == 7\n assert candidate(s = \"balancedstring\",t = \"stringbalanced\") == 0\n assert candidate(s = \"abcdefghij\",t = \"abcdefghijjihgfedcba\") == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxy\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"aaabbbccc\",t = \"bbbaaaccc\") == 0\n assert candidate(s = \"thisisatest\",t = \"testthisis\") == 1\n assert candidate(s = \"encyclopedia\",t = \"dictionary\") == 8\n assert candidate(s = \"mississippi\",t = \"missisippi\") == 1\n assert candidate(s = \"aaaaabbbbbcccccd\",t = \"dddddccccbbbbbaaaaa\") == 5\n assert candidate(s = \"repeatedcharacterss\",t = \"charactersrepeatedss\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"\") == 52\n assert candidate(s = \"thisisananagram\",t = \"isananagramthis\") == 0\n assert candidate(s = \"abcdefg\",t = \"hijklmn\") == 14\n assert candidate(s = \"aaaabbbbccccdddd\",t = \"ddddccccbbbbaaaa\") == 0\n assert candidate(s = \"rhinoceros\",t = \"orchestrer\") == 6\n assert candidate(s = \"samecharacters\",t = \"characterssame\") == 0\n assert candidate(s = \"onetwothreefourfivesixseveneightnine\",t = \"nineseveneightsixfvierthreeonotwo\") == 3\n assert candidate(s = \"12345\",t = \"54321\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 0\n assert candidate(s = \"anagram\",t = \"manga\") == 2\n assert candidate(s = \"samestring\",t = \"samestring\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"thisisaverylongstringthatwearegoingtouseasourtestcase\",t = \"anotherlongstringthatwillbeusedasourtestcase\") == 17\n assert candidate(s = \"uniquecharacters\",t = \"charactersunique\") == 0\n assert candidate(s = \"elephant\",t = \"television\") == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",t = \"abcdefghijklmnopqrstuvwxyz\") == 44\n assert candidate(s = \"repeatedcharactersrepeated\",t = \"charactersrepeatedcharacters\") == 10\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",t = \"doglazytheoverjumpsonbrowquickthe\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"abcd\",t = \"efghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"a\",t = \"abcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"level\",t = \"level\") == 0\n assert candidate(s = \"equalnumberofchars\",t = \"equalnumberofchars\") == 0\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 25\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",t = \"zzzzzzzzzzzzzzzzzzzz\") == 68\n assert candidate(s = \"longstringwithrepeatedcharacters\",t = \"characterswithrepeatedlongstring\") == 0\n assert candidate(s = \"uniquecharacters\",t = \"differentcharacters\") == 9\n assert candidate(s = \"\",t = \"b\") == 1\n assert candidate(s = \"mississippi\",t = \"pensil\") == 11\n assert candidate(s = \"xyxxyxyxyx\",t = \"yyxyxyxyxy\") == 4\n assert candidate(s = \"abracadabra\",t = \"abracadabracadabra\") == 7\n assert candidate(s = \"redder\",t = \"redder\") == 0\n assert candidate(s = \"hello\",t = \"billion\") == 6\n assert candidate(s = \"xylophone\",t = \"xylophon\") == 1\n assert candidate(s = \"thqwhrwhrwhr\",t = \"tttttttttttt\") == 22\n assert candidate(s = \"xylophone\",t = \"polyrhythm\") == 9\n assert candidate(s = \"unique\",t = \"distinct\") == 10\n assert candidate(s = \"mississippi\",t = \"pensylvania\") == 16\n assert candidate(s = \"xyzxyzxyz\",t = \"abcabcabc\") == 18\n assert candidate(s = \"racecar\",t = \"carrace\") == 0\n assert candidate(s = \"abcdefg\",t = \"hijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"a\",t = \"\") == 1\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 0\n assert candidate(s = \"abcde\",t = \"fghij\") == 10\n assert candidate(s = \"abcdabcdabcdabcd\",t = \"dcba\") == 12\n assert candidate(s = \"\",t = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"longerstringwithmorecharacters\",t = \"shortstring\") == 19\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"longerstringhere\",t = \"short\") == 11\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzzyyxxwwvvuuttssrrqqppoonnmlkkjjiihhggffeeeeddccbbaa\") == 5\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",t = \"thequickbrownfoxjumpsoverthelazydog\") == 0\n assert candidate(s = \"abcdefghijkllllllllllllmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 11\n assert candidate(s = \"xxyyzz\",t = \"xxxyyyzzz\") == 3\n assert candidate(s = \"elephant\",t = \"relevant\") == 4\n assert candidate(s = \"pythonprogramming\",t = \"java\") == 19\n assert candidate(s = \"mississippi\",t = \"pennsylvania\") == 17\n assert candidate(s = \"aaaaa\",t = \"bbbbbbaaaaa\") == 6\n assert candidate(s = \"rotor\",t = \"rotor\") == 0\n"}, "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().minSteps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minSteps(String s, String t) {", "container": "Solution", "callable": "minSteps", "parameters": [{"name": "s", "type": "String"}, {"name": "t", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2187, "task_id": "minimum-time-to-complete-trips", "difficulty": "Medium", "problem_description": "You are given an array time where time[i] denotes the time taken by the ith bus to complete one trip.\nEach bus can make multiple trips successively; that is, the next trip can start immediately after completing the current trip. Also, each bus operates independently; that is, the trips of one bus do not influence the trips of any other bus.\nYou are also given an integer totalTrips, which denotes the number of trips all buses should make in total. Return the minimum time required for all buses to complete at least totalTrips trips.\n \nExample 1:\n\nInput: time = [1,2,3], totalTrips = 5\nOutput: 3\nExplanation:\n- At time t = 1, the number of trips completed by each bus are [1,0,0]. \n The total number of trips completed is 1 + 0 + 0 = 1.\n- At time t = 2, the number of trips completed by each bus are [2,1,0]. \n The total number of trips completed is 2 + 1 + 0 = 3.\n- At time t = 3, the number of trips completed by each bus are [3,1,1]. \n The total number of trips completed is 3 + 1 + 1 = 5.\nSo the minimum time needed for all buses to complete at least 5 trips is 3.\n\nExample 2:\n\nInput: time = [2], totalTrips = 1\nOutput: 2\nExplanation:\nThere is only one bus, and it will complete its first trip at t = 2.\nSo the minimum time needed to complete 1 trip is 2.\n\n \nConstraints:\n\n1 <= time.length <= 105\n1 <= time[i], totalTrips <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(time = [1, 2, 3],totalTrips = 5) == 3\n assert candidate(time = [10000000],totalTrips = 10000000) == 100000000000000\n assert candidate(time = [10, 20, 30],totalTrips = 100) == 550\n assert candidate(time = [1, 1, 1, 1, 1],totalTrips = 100000) == 20000\n assert candidate(time = [1, 1, 1, 1, 1],totalTrips = 10000) == 2000\n assert candidate(time = [5, 10, 15],totalTrips = 9) == 30\n assert candidate(time = [5, 10, 15],totalTrips = 10) == 30\n assert candidate(time = [2],totalTrips = 1) == 2\n assert candidate(time = [1, 1, 1, 1],totalTrips = 10) == 3\n assert candidate(time = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],totalTrips = 15000) == 3000\n assert candidate(time = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],totalTrips = 500) == 305\n assert candidate(time = [7, 14, 21, 28, 35, 42],totalTrips = 100) == 294\n assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],totalTrips = 50000) == 13900\n assert candidate(time = [3, 6, 9, 12],totalTrips = 20) == 30\n assert candidate(time = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],totalTrips = 100000) == 100000\n assert candidate(time = [100, 200, 300, 400],totalTrips = 500) == 24000\n assert candidate(time = [5, 8, 12, 16, 20],totalTrips = 100) == 195\n assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],totalTrips = 100) == 36\n assert candidate(time = [2, 3, 5, 7, 11, 13, 17, 19],totalTrips = 50) == 36\n assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],totalTrips = 50000) == 21408\n assert candidate(time = [2, 3, 4, 5, 6, 7, 8, 9, 10],totalTrips = 50) == 28\n assert candidate(time = [3, 5, 7, 9],totalTrips = 20) == 27\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 5000) == 17090\n assert candidate(time = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],totalTrips = 1500) == 1539\n assert candidate(time = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],totalTrips = 1000000) == 250000\n assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],totalTrips = 5000) == 1392\n assert candidate(time = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],totalTrips = 150) == 132\n assert candidate(time = [100, 200, 300, 400, 500],totalTrips = 1500) == 65800\n assert candidate(time = [10, 20, 30, 40, 50],totalTrips = 50) == 230\n assert candidate(time = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],totalTrips = 1000000) == 500004\n assert candidate(time = [1, 2, 4, 8, 16, 32, 64, 128],totalTrips = 1000) == 504\n assert candidate(time = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],totalTrips = 5000) == 731\n assert candidate(time = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],totalTrips = 10000) == 2500\n assert candidate(time = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],totalTrips = 1000) == 655\n assert candidate(time = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],totalTrips = 1000) == 500\n assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],totalTrips = 15000) == 6425\n assert candidate(time = [3, 6, 9, 12],totalTrips = 25) == 36\n assert candidate(time = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],totalTrips = 15000) == 46107\n assert candidate(time = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],totalTrips = 5000) == 2500\n assert candidate(time = [3, 6, 9, 12, 15],totalTrips = 20) == 30\n assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],totalTrips = 100) == 49\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 1000) == 3430\n assert candidate(time = [1, 2, 4, 8, 16, 32, 64],totalTrips = 5000) == 2521\n assert candidate(time = [100, 200, 300, 400, 500],totalTrips = 5000) == 219000\n assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],totalTrips = 10000) == 17080\n assert candidate(time = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],totalTrips = 1023) == 512\n assert candidate(time = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],totalTrips = 50000) == 17072000\n assert candidate(time = [7, 14, 21, 28, 35],totalTrips = 30) == 98\n assert candidate(time = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],totalTrips = 100) == 18\n assert candidate(time = [10000000, 9999999, 9999998, 9999997, 9999996],totalTrips = 10000000) == 20000000000000\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 500) == 1720\n assert candidate(time = [10000, 5000, 2500, 1250, 625],totalTrips = 1000000) == 322581250\n assert candidate(time = [3, 6, 9, 12, 15],totalTrips = 25) == 36\n assert candidate(time = [1, 2, 4, 8, 16, 32, 64],totalTrips = 1000) == 506\n assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],totalTrips = 10000) == 17080\n assert candidate(time = [2, 5, 7, 10],totalTrips = 20) == 22\n assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],totalTrips = 1000) == 1400\n assert candidate(time = [2, 4, 6, 8, 10, 12, 14],totalTrips = 70) == 56\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 10000) == 34160\n assert candidate(time = [2, 5, 8, 11],totalTrips = 20) == 24\n assert candidate(time = [3, 6, 9, 12, 15, 18],totalTrips = 100) == 126\n assert candidate(time = [3, 9, 27, 81],totalTrips = 100) == 207\n assert candidate(time = [100, 200, 300, 400, 500],totalTrips = 5000) == 219000\n assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],totalTrips = 10000) == 3016\n assert candidate(time = [100000, 200000, 300000, 400000, 500000],totalTrips = 1000000) == 43795700000\n assert candidate(time = [3, 6, 9, 12],totalTrips = 20) == 30\n assert candidate(time = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],totalTrips = 1000) == 1372\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],totalTrips = 20000) == 60300\n assert candidate(time = [10000, 20000, 30000, 40000],totalTrips = 100000) == 480000000\n assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],totalTrips = 100000) == 34144\n assert candidate(time = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],totalTrips = 3000) == 1959\n assert candidate(time = [100, 200, 300, 400, 500],totalTrips = 1000) == 43900\n assert candidate(time = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],totalTrips = 25000) == 15072\n assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],totalTrips = 150) == 265\n assert candidate(time = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630],totalTrips = 10000) == 126672\n assert candidate(time = [7, 14, 21, 28, 35],totalTrips = 100) == 315\n assert candidate(time = [10, 20, 30, 40, 50, 60],totalTrips = 100) == 420\n assert candidate(time = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],totalTrips = 2500) == 5870\n assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],totalTrips = 200000) == 277965\n assert candidate(time = [4, 8, 12, 16, 20],totalTrips = 50) == 92\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 10000) == 34160\n assert candidate(time = [2, 3, 5, 7, 11],totalTrips = 30) == 25\n assert candidate(time = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],totalTrips = 20000) == 88790\n assert candidate(time = [1, 2, 4, 8, 16, 32, 64],totalTrips = 100000) == 50396\n assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],totalTrips = 200) == 96\n assert candidate(time = [7, 14, 21, 28, 35, 42],totalTrips = 100) == 294\n assert candidate(time = [2, 3, 5, 7],totalTrips = 20) == 18\n assert candidate(time = [3, 6, 9, 12],totalTrips = 15) == 24\n assert candidate(time = [7, 14, 21, 28, 35],totalTrips = 50) == 161\n assert candidate(time = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],totalTrips = 500000) == 48814545\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 200) == 700\n assert candidate(time = [10000, 20000, 30000],totalTrips = 100000) == 545460000\n assert candidate(time = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],totalTrips = 1000000) == 550002\n assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],totalTrips = 1000000) == 403282\n assert candidate(time = [7, 14, 21, 28],totalTrips = 25) == 84\n assert candidate(time = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],totalTrips = 300) == 184\n assert candidate(time = [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],totalTrips = 100000) == 38597\n assert candidate(time = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],totalTrips = 100000) == 50050\n assert candidate(time = [1, 3, 7, 15],totalTrips = 30) == 21\n assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],totalTrips = 1000) == 343\n assert candidate(time = [4, 5, 6, 7, 8],totalTrips = 30) == 36\n assert candidate(time = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],totalTrips = 200) == 490\n assert candidate(time = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],totalTrips = 500) == 110\n"}, "metadata": {"canonical_parameter_names": ["time", "totalTrips"], "leetcode_dataset_entry_point": "Solution().minimumTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumTime(int[] time, int totalTrips) {", "container": "Solution", "callable": "minimumTime", "parameters": [{"name": "time", "type": "int[]"}, {"name": "totalTrips", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2188, "task_id": "minimum-time-to-finish-the-race", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array tires where tires[i] = [fi, ri] indicates that the ith tire can finish its xth successive lap in fi * ri(x-1) seconds.\n\nFor example, if fi = 3 and ri = 2, then the tire would finish its 1st lap in 3 seconds, its 2nd lap in 3 * 2 = 6 seconds, its 3rd lap in 3 * 22 = 12 seconds, etc.\n\nYou are also given an integer changeTime and an integer numLaps.\nThe race consists of numLaps laps and you may start the race with any tire. You have an unlimited supply of each tire and after every lap, you may change to any given tire (including the current tire type) if you wait changeTime seconds.\nReturn the minimum time to finish the race.\n \nExample 1:\n\nInput: tires = [[2,3],[3,4]], changeTime = 5, numLaps = 4\nOutput: 21\nExplanation: \nLap 1: Start with tire 0 and finish the lap in 2 seconds.\nLap 2: Continue with tire 0 and finish the lap in 2 * 3 = 6 seconds.\nLap 3: Change tires to a new tire 0 for 5 seconds and then finish the lap in another 2 seconds.\nLap 4: Continue with tire 0 and finish the lap in 2 * 3 = 6 seconds.\nTotal time = 2 + 6 + 5 + 2 + 6 = 21 seconds.\nThe minimum time to complete the race is 21 seconds.\n\nExample 2:\n\nInput: tires = [[1,10],[2,2],[3,4]], changeTime = 6, numLaps = 5\nOutput: 25\nExplanation: \nLap 1: Start with tire 1 and finish the lap in 2 seconds.\nLap 2: Continue with tire 1 and finish the lap in 2 * 2 = 4 seconds.\nLap 3: Change tires to a new tire 1 for 6 seconds and then finish the lap in another 2 seconds.\nLap 4: Continue with tire 1 and finish the lap in 2 * 2 = 4 seconds.\nLap 5: Change tires to tire 0 for 6 seconds then finish the lap in another 1 second.\nTotal time = 2 + 4 + 6 + 2 + 4 + 6 + 1 = 25 seconds.\nThe minimum time to complete the race is 25 seconds. \n\n \nConstraints:\n\n1 <= tires.length <= 105\ntires[i].length == 2\n1 <= fi, changeTime <= 105\n2 <= ri <= 105\n1 <= numLaps <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tires = [[2, 3], [3, 4]],changeTime = 5,numLaps = 4) == 21\n assert candidate(tires = [[5, 2], [3, 3]],changeTime = 4,numLaps = 3) == 17\n assert candidate(tires = [[5, 5], [3, 3]],changeTime = 10,numLaps = 6) == 56\n assert candidate(tires = [[100000, 2]],changeTime = 100000,numLaps = 1000) == 199900000\n assert candidate(tires = [[5, 2]],changeTime = 3,numLaps = 3) == 21\n assert candidate(tires = [[10, 10], [5, 5], [2, 2]],changeTime = 5,numLaps = 3) == 13\n assert candidate(tires = [[10, 5], [20, 2]],changeTime = 7,numLaps = 8) == 129\n assert candidate(tires = [[1, 2]],changeTime = 3,numLaps = 1) == 1\n assert candidate(tires = [[5, 5], [10, 2]],changeTime = 7,numLaps = 3) == 29\n assert candidate(tires = [[10, 5], [2, 2]],changeTime = 1,numLaps = 10) == 29\n assert candidate(tires = [[5, 2]],changeTime = 3,numLaps = 2) == 13\n assert candidate(tires = [[1, 10], [2, 2], [3, 4]],changeTime = 6,numLaps = 5) == 25\n assert candidate(tires = [[1, 2]],changeTime = 3,numLaps = 10) == 27\n assert candidate(tires = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],changeTime = 5,numLaps = 750) == 4495\n assert candidate(tires = [[2, 3], [3, 4], [5, 6], [7, 8]],changeTime = 5,numLaps = 15) == 93\n assert candidate(tires = [[1, 100000], [2, 90000], [3, 80000], [4, 70000], [5, 60000], [6, 50000], [7, 40000], [8, 30000], [9, 20000], [10, 10000]],changeTime = 100000,numLaps = 1000) == 99900500\n assert candidate(tires = [[10, 5], [2, 2], [3, 3]],changeTime = 6,numLaps = 20) == 114\n assert candidate(tires = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],changeTime = 1,numLaps = 900) == 1799\n assert candidate(tires = [[1, 5], [2, 3], [3, 2]],changeTime = 7,numLaps = 15) == 92\n assert candidate(tires = [[1, 2], [1, 3], [1, 4], [1, 5]],changeTime = 1,numLaps = 50) == 99\n assert candidate(tires = [[5, 3], [2, 8], [7, 2]],changeTime = 5,numLaps = 200) == 1395\n assert candidate(tires = [[100, 100], [200, 200], [300, 300]],changeTime = 50,numLaps = 1000) == 149950\n assert candidate(tires = [[2, 10], [3, 9], [4, 8], [5, 7], [6, 6], [7, 5], [8, 4], [9, 3], [10, 2]],changeTime = 5,numLaps = 500) == 3495\n assert candidate(tires = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]],changeTime = 20,numLaps = 500) == 12480\n assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],changeTime = 5,numLaps = 50) == 195\n assert candidate(tires = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],changeTime = 50,numLaps = 750) == 12100\n assert candidate(tires = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],changeTime = 10,numLaps = 999) == 8984\n assert candidate(tires = [[1, 2], [3, 4], [5, 6]],changeTime = 10,numLaps = 15) == 75\n assert candidate(tires = [[2, 3], [3, 4], [1, 5]],changeTime = 5,numLaps = 10) == 50\n assert candidate(tires = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],changeTime = 10,numLaps = 25) == 190\n assert candidate(tires = [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8]],changeTime = 7,numLaps = 50) == 318\n assert candidate(tires = [[100, 2], [200, 3], [300, 4], [400, 5]],changeTime = 150,numLaps = 600) == 134850\n assert candidate(tires = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],changeTime = 10,numLaps = 1000) == 7990\n assert candidate(tires = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],changeTime = 1,numLaps = 1000) == 1999\n assert candidate(tires = [[1000, 2], [500, 3], [250, 4]],changeTime = 500,numLaps = 100) == 74500\n assert candidate(tires = [[5, 3], [7, 4], [2, 2]],changeTime = 10,numLaps = 20) == 150\n assert candidate(tires = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6]],changeTime = 5,numLaps = 500) == 5495\n assert candidate(tires = [[1, 2], [1, 3], [1, 4], [1, 5]],changeTime = 1,numLaps = 100) == 199\n assert candidate(tires = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],changeTime = 100000,numLaps = 1) == 1\n assert candidate(tires = [[1, 10000], [2, 5000], [3, 1000], [4, 500], [5, 250], [6, 125], [7, 62], [8, 31], [9, 15], [10, 7]],changeTime = 1000,numLaps = 1000) == 522400\n assert candidate(tires = [[1, 10], [2, 5], [3, 3]],changeTime = 15,numLaps = 500) == 6485\n assert candidate(tires = [[1, 10], [2, 2], [3, 4], [4, 5]],changeTime = 5,numLaps = 30) == 160\n assert candidate(tires = [[100, 100], [200, 50], [300, 25]],changeTime = 100,numLaps = 300) == 59900\n assert candidate(tires = [[10, 10], [20, 20], [30, 30]],changeTime = 50,numLaps = 750) == 44950\n assert candidate(tires = [[1, 2], [1, 2], [1, 2]],changeTime = 0,numLaps = 100) == 100\n assert candidate(tires = [[2, 2], [3, 2], [4, 2], [5, 2], [6, 2]],changeTime = 10,numLaps = 500) == 3990\n assert candidate(tires = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],changeTime = 15,numLaps = 50) == 470\n assert candidate(tires = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],changeTime = 5,numLaps = 15) == 55\n assert candidate(tires = [[3, 5], [2, 3], [4, 4]],changeTime = 10,numLaps = 15) == 128\n assert candidate(tires = [[5, 10], [3, 3], [2, 2]],changeTime = 10,numLaps = 20) == 150\n assert candidate(tires = [[100000, 100000], [50000, 50000], [25000, 25000], [12500, 12500], [6250, 6250]],changeTime = 100000,numLaps = 1000) == 106150000\n assert candidate(tires = [[100, 10], [50, 5], [25, 2]],changeTime = 20,numLaps = 1000) == 44980\n assert candidate(tires = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],changeTime = 3,numLaps = 40) == 197\n assert candidate(tires = [[10, 10], [20, 20], [30, 30]],changeTime = 100,numLaps = 50) == 5150\n assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5]],changeTime = 1,numLaps = 1) == 1\n assert candidate(tires = [[10000, 2], [5000, 3], [1000, 4], [500, 5], [250, 6], [125, 7], [62, 8], [31, 9], [15, 10], [7, 11]],changeTime = 10000,numLaps = 1000) == 3639260\n assert candidate(tires = [[3, 2], [4, 3], [5, 4], [6, 5], [7, 6]],changeTime = 15,numLaps = 30) == 345\n assert candidate(tires = [[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]],changeTime = 5,numLaps = 200) == 795\n assert candidate(tires = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],changeTime = 10,numLaps = 1000) == 14990\n assert candidate(tires = [[1, 2], [2, 3], [3, 4]],changeTime = 0,numLaps = 100) == 100\n assert candidate(tires = [[1, 2], [1, 3], [1, 4], [1, 5]],changeTime = 5,numLaps = 15) == 55\n assert candidate(tires = [[5, 2], [8, 3], [1, 2]],changeTime = 20,numLaps = 20) == 155\n assert candidate(tires = [[5, 2], [10, 2], [15, 2]],changeTime = 20,numLaps = 1000) == 17480\n assert candidate(tires = [[9, 9], [8, 8], [7, 7], [6, 6], [5, 5]],changeTime = 10,numLaps = 800) == 11990\n assert candidate(tires = [[2, 3], [5, 7], [8, 9]],changeTime = 5,numLaps = 20) == 125\n assert candidate(tires = [[5, 3], [10, 2], [2, 6]],changeTime = 7,numLaps = 15) == 128\n assert candidate(tires = [[5, 2], [3, 3], [4, 4]],changeTime = 10,numLaps = 20) == 210\n assert candidate(tires = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],changeTime = 7,numLaps = 60) == 443\n assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5]],changeTime = 5,numLaps = 30) == 115\n assert candidate(tires = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]],changeTime = 1,numLaps = 1000) == 1999\n assert candidate(tires = [[50, 50], [25, 25], [10, 10], [5, 5], [2, 2]],changeTime = 25,numLaps = 750) == 9725\n assert candidate(tires = [[100000, 2], [50000, 3]],changeTime = 50000,numLaps = 500) == 49950000\n assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],changeTime = 5,numLaps = 50) == 195\n assert candidate(tires = [[3, 5], [5, 3], [7, 2]],changeTime = 15,numLaps = 200) == 3285\n assert candidate(tires = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],changeTime = 10,numLaps = 200) == 1125\n assert candidate(tires = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],changeTime = 20,numLaps = 800) == 11180\n assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],changeTime = 5,numLaps = 50) == 195\n assert candidate(tires = [[10, 10], [5, 5], [1, 2]],changeTime = 5,numLaps = 30) == 115\n assert candidate(tires = [[1, 100000], [2, 50000], [3, 25000], [4, 10000], [5, 5000]],changeTime = 100000,numLaps = 1000) == 62402500\n assert candidate(tires = [[10, 10], [20, 20], [30, 30]],changeTime = 15,numLaps = 100) == 2485\n assert candidate(tires = [[1, 10], [2, 20], [3, 30], [4, 40]],changeTime = 100,numLaps = 500) == 27650\n assert candidate(tires = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],changeTime = 100,numLaps = 900) == 23480\n assert candidate(tires = [[1000, 1000], [1000, 1000], [1000, 1000]],changeTime = 100000,numLaps = 1000) == 100900000\n assert candidate(tires = [[2, 3], [5, 7], [3, 4]],changeTime = 8,numLaps = 100) == 792\n assert candidate(tires = [[2, 5], [3, 4], [4, 3]],changeTime = 10,numLaps = 100) == 1090\n assert candidate(tires = [[1, 10], [2, 5], [3, 2]],changeTime = 10,numLaps = 999) == 9482\n assert candidate(tires = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],changeTime = 25,numLaps = 1000) == 27475\n assert candidate(tires = [[1, 100], [2, 50], [3, 25], [4, 10]],changeTime = 5,numLaps = 50) == 295\n assert candidate(tires = [[1, 2], [1, 3], [1, 4]],changeTime = 5,numLaps = 50) == 195\n assert candidate(tires = [[7, 2], [6, 3], [5, 4], [4, 5], [3, 6], [2, 7], [1, 8]],changeTime = 8,numLaps = 100) == 842\n assert candidate(tires = [[5, 2], [4, 3], [3, 4], [2, 5]],changeTime = 1,numLaps = 999) == 2996\n assert candidate(tires = [[1000, 100], [500, 50], [250, 25], [100, 10], [50, 5]],changeTime = 500,numLaps = 500) == 199500\n assert candidate(tires = [[2, 2], [3, 3], [4, 4]],changeTime = 10,numLaps = 25) == 190\n assert candidate(tires = [[100, 100], [50, 50], [25, 25], [10, 10]],changeTime = 20,numLaps = 50) == 1480\n assert candidate(tires = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],changeTime = 1,numLaps = 1000) == 1999\n assert candidate(tires = [[2, 5], [1, 3], [3, 2], [2, 4]],changeTime = 7,numLaps = 30) == 158\n assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5]],changeTime = 2,numLaps = 100) == 248\n assert candidate(tires = [[1, 2], [1, 2], [1, 2], [1, 2]],changeTime = 10,numLaps = 50) == 275\n assert candidate(tires = [[100000, 100000]],changeTime = 100000,numLaps = 1000) == 199900000\n assert candidate(tires = [[1, 1000], [2, 500], [3, 250]],changeTime = 50,numLaps = 20) == 970\n"}, "metadata": {"canonical_parameter_names": ["tires", "changeTime", "numLaps"], "leetcode_dataset_entry_point": "Solution().minimumFinishTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumFinishTime(int[][] tires, int changeTime, int numLaps) {", "container": "Solution", "callable": "minimumFinishTime", "parameters": [{"name": "tires", "type": "int[][]"}, {"name": "changeTime", "type": "int"}, {"name": "numLaps", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2190, "task_id": "most-frequent-number-following-key-in-an-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. You are also given an integer key, which is present in nums.\nFor every unique integer target in nums, count the number of times target immediately follows an occurrence of key in nums. In other words, count the number of indices i such that:\n\n0 <= i <= nums.length - 2,\nnums[i] == key and,\nnums[i + 1] == target.\n\nReturn the target with the maximum count. The test cases will be generated such that the target with maximum count is unique.\n \nExample 1:\n\nInput: nums = [1,100,200,1,100], key = 1\nOutput: 100\nExplanation: For target = 100, there are 2 occurrences at indices 1 and 4 which follow an occurrence of key.\nNo other integers follow an occurrence of key, so we return 100.\n\nExample 2:\n\nInput: nums = [2,2,2,2,3], key = 2\nOutput: 2\nExplanation: For target = 2, there are 3 occurrences at indices 1, 2, and 3 which follow an occurrence of key.\nFor target = 3, there is only one occurrence at index 4 which follows an occurrence of key.\ntarget = 2 has the maximum number of occurrences following an occurrence of key, so we return 2.\n\n \nConstraints:\n\n2 <= nums.length <= 1000\n1 <= nums[i] <= 1000\nThe test cases will be generated such that the answer is unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],key = 1) == 2\n assert candidate(nums = [1, 2, 2, 3, 2, 1, 2, 4],key = 2) == 2\n assert candidate(nums = [3, 1, 3, 1, 3, 1, 3, 1, 3, 2],key = 1) == 3\n assert candidate(nums = [10, 20, 20, 10, 10, 30, 20, 10],key = 10) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],key = 5) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2],key = 1) == 2\n assert candidate(nums = [2, 2, 2, 2, 3],key = 2) == 2\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],key = 5) == 1\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5],key = 5) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3],key = 3) == 3\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],key = 1) == 2\n assert candidate(nums = [5, 1, 4, 1, 5, 1, 4, 1, 5],key = 1) == 4\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 1, 2, 1],key = 1) == 2\n assert candidate(nums = [1, 3, 2, 3, 2, 1, 3, 2, 1],key = 3) == 2\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4],key = 5) == 1\n assert candidate(nums = [1, 100, 200, 1, 100],key = 1) == 100\n assert candidate(nums = [500, 100, 500, 200, 500, 300, 500, 400, 500, 500, 500, 600],key = 500) == 500\n assert candidate(nums = [666, 111, 666, 222, 666, 333, 666, 444, 666, 555, 666, 111, 666, 222, 666, 333, 666, 444, 666, 555, 666, 111, 666, 222, 666, 333, 666, 444, 666, 555],key = 666) == 111\n assert candidate(nums = [9, 5, 9, 9, 1, 9, 5, 9, 5, 5],key = 9) == 5\n assert candidate(nums = [10, 20, 30, 10, 20, 10, 30, 10, 20, 10, 30, 10, 20, 10, 30],key = 10) == 20\n assert candidate(nums = [11, 22, 33, 44, 11, 22, 33, 44, 11, 22, 33, 44, 11],key = 11) == 22\n assert candidate(nums = [100, 200, 100, 300, 100, 200, 100, 400, 100, 500, 100, 600, 100, 700],key = 100) == 200\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 1, 5, 2, 5, 3, 5, 4, 5, 1, 5, 2],key = 5) == 1\n assert candidate(nums = [7, 8, 9, 7, 8, 7, 9, 7, 8, 7, 8, 7, 8, 7, 9],key = 7) == 8\n assert candidate(nums = [4, 6, 4, 4, 4, 3, 4, 6, 4, 4, 6, 4],key = 4) == 4\n assert candidate(nums = [7, 3, 7, 4, 7, 5, 7, 6, 7, 3, 7, 4],key = 7) == 3\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],key = 5) == 5\n assert candidate(nums = [10, 11, 10, 12, 10, 13, 10, 14, 10, 15, 10, 16, 10, 17, 10, 18],key = 10) == 11\n assert candidate(nums = [8, 2, 8, 3, 8, 4, 8, 5, 8, 6, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],key = 8) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 1) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10],key = 1) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],key = 1) == 2\n assert candidate(nums = [99, 88, 77, 66, 55, 99, 88, 77, 66, 55, 99, 88, 77, 66],key = 99) == 88\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1],key = 9) == 1\n assert candidate(nums = [4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 4, 10, 4, 11, 4, 12, 4, 13, 4, 14],key = 4) == 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, 2],key = 1) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1],key = 1) == 1\n assert candidate(nums = [123, 456, 123, 789, 123, 456, 123, 789, 123, 456, 123, 789, 123, 456, 123, 789, 123, 456, 123, 789, 123, 456, 123, 789, 123, 456, 123, 789],key = 123) == 456\n assert candidate(nums = [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],key = 3) == 3\n assert candidate(nums = [11, 22, 11, 33, 11, 44, 11, 55, 11, 66, 11, 77, 11, 88, 11, 99, 11, 100, 11, 111],key = 11) == 22\n assert candidate(nums = [42, 10, 42, 20, 42, 30, 42, 10, 42, 20, 42, 30, 42, 10],key = 42) == 10\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3],key = 3) == 3\n assert candidate(nums = [3, 3, 3, 4, 4, 4, 3, 4, 3, 4, 3, 3, 4, 3, 3, 3, 4, 3, 3, 3, 3, 4, 3, 3, 3, 4, 3, 3],key = 3) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],key = 100) == 200\n assert candidate(nums = [3, 7, 3, 8, 3, 7, 3, 8, 3, 9],key = 3) == 7\n assert candidate(nums = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100],key = 100) == 200\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990],key = 999) == 998\n assert candidate(nums = [42, 84, 42, 168, 42, 210, 42, 252, 42, 294, 42, 336],key = 42) == 84\n assert candidate(nums = [7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3],key = 7) == 3\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8],key = 7) == 7\n assert candidate(nums = [2000, 1500, 2000, 1600, 2000, 1700, 2000, 1800, 2000, 1900, 2000, 2000, 2000, 2100],key = 2000) == 2000\n assert candidate(nums = [7, 3, 7, 7, 4, 7, 3, 7, 3, 7, 5],key = 7) == 3\n assert candidate(nums = [9, 3, 9, 5, 9, 3, 9, 5, 9, 2, 9],key = 9) == 3\n assert candidate(nums = [42, 13, 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, 13],key = 42) == 42\n assert candidate(nums = [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],key = 1) == 2\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10],key = 1) == 2\n assert candidate(nums = [500, 400, 300, 200, 100, 500, 400, 300, 200, 100, 500, 400],key = 500) == 400\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],key = 10) == 20\n assert candidate(nums = [6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 6],key = 6) == 7\n assert candidate(nums = [3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1],key = 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, 1, 2, 3, 4, 5],key = 5) == 6\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 1, 5, 9],key = 5) == 9\n assert candidate(nums = [8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 1],key = 8) == 8\n assert candidate(nums = [9, 1, 2, 9, 1, 2, 9, 1, 2, 9, 1, 2, 9, 1],key = 9) == 1\n assert candidate(nums = [999, 1, 999, 2, 999, 3, 999, 4, 999, 5, 999, 1, 999, 2, 999, 3, 999, 4, 999, 5],key = 999) == 1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],key = 4) == 4\n assert candidate(nums = [100, 200, 300, 100, 100, 200, 100, 300, 100, 200, 100, 300, 100],key = 100) == 200\n assert candidate(nums = [500, 600, 500, 700, 500, 800, 500, 900, 500, 1000],key = 500) == 600\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 5, 5, 6, 6, 6, 5, 6, 6, 6, 5, 6],key = 5) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 10) == 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, 2, 3, 4, 5],key = 1) == 2\n assert candidate(nums = [1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2],key = 1) == 1\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],key = 3) == 8\n assert candidate(nums = [500, 400, 300, 200, 100, 500, 400, 300, 200, 100, 500, 400, 300, 200, 100, 500, 400, 300, 200, 100],key = 500) == 400\n assert candidate(nums = [200, 300, 200, 300, 200, 300, 200, 300, 200, 300, 200, 300, 200, 300, 200, 300, 200, 300, 200, 200],key = 200) == 300\n assert candidate(nums = [7, 7, 7, 8, 9, 8, 10, 8, 7, 11, 7, 8, 8, 9],key = 7) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 1) == 2\n assert candidate(nums = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5, 10, 6, 10, 7, 10, 8, 10, 9, 10, 1, 10, 2, 10, 3, 10, 4, 10, 5],key = 10) == 1\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60],key = 10) == 20\n assert candidate(nums = [6, 1, 6, 2, 6, 3, 6, 4, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],key = 6) == 6\n assert candidate(nums = [3, 1, 9, 3, 1, 9, 3, 1, 9, 10],key = 3) == 1\n assert candidate(nums = [7, 3, 7, 2, 7, 7, 3, 3, 2, 7],key = 7) == 3\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43],key = 42) == 42\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, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],key = 2) == 1\n assert candidate(nums = [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999],key = 999) == 1000\n assert candidate(nums = [888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999],key = 888) == 999\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 90],key = 10) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 100, 200, 300, 400, 500, 600, 700, 800, 900, 100, 100],key = 100) == 200\n assert candidate(nums = [15, 20, 15, 25, 15, 30, 15, 35, 15, 40, 15, 45, 15, 50, 15, 55, 15, 60, 15, 65, 15, 70, 15, 75, 15, 80, 15, 85, 15, 90, 15, 95, 15, 100],key = 15) == 20\n assert candidate(nums = [666, 777, 666, 888, 666, 999, 666, 111, 666, 222, 666, 333, 666, 444, 666, 555],key = 666) == 777\n assert candidate(nums = [555, 666, 555, 666, 555, 666, 555, 666, 555, 666, 555, 666, 555, 666, 555, 666, 555, 666, 555, 777],key = 555) == 666\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 1],key = 1) == 2\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],key = 7) == 7\n assert candidate(nums = [2, 3, 4, 3, 2, 3, 4, 5, 6, 4, 3, 2, 3, 4, 3, 3, 3, 4],key = 3) == 4\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 30],key = 10) == 30\n assert candidate(nums = [123, 456, 123, 789, 123, 101, 123, 102, 123, 103, 123, 104],key = 123) == 456\n assert candidate(nums = [100, 200, 100, 300, 400, 500, 600, 100, 700, 800, 900, 100, 100, 100, 100, 100],key = 100) == 100\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9],key = 9) == 8\n assert candidate(nums = [42, 99, 42, 55, 42, 99, 42, 66, 42, 55, 42, 99],key = 42) == 99\n assert candidate(nums = [7, 11, 7, 11, 7, 11, 7, 8, 7, 9],key = 7) == 11\n assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 50],key = 50) == 100\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10],key = 10) == 20\n assert candidate(nums = [999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 999, 1, 2, 3, 4, 5, 6, 7, 8, 999],key = 999) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums", "key"], "leetcode_dataset_entry_point": "Solution().mostFrequent", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int mostFrequent(int[] nums, int key) {", "container": "Solution", "callable": "mostFrequent", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "key", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2191, "task_id": "sort-the-jumbled-numbers", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array mapping which represents the mapping rule of a shuffled decimal system. mapping[i] = j means digit i should be mapped to digit j in this system.\nThe mapped value of an integer is the new integer obtained by replacing each occurrence of digit i in the integer with mapping[i] for all 0 <= i <= 9.\nYou are also given another integer array nums. Return the array nums sorted in non-decreasing order based on the mapped values of its elements.\nNotes:\n\nElements with the same mapped values should appear in the same relative order as in the input.\nThe elements of nums should only be sorted based on their mapped values and not be replaced by them.\n\n \nExample 1:\n\nInput: mapping = [8,9,4,0,2,1,3,5,7,6], nums = [991,338,38]\nOutput: [338,38,991]\nExplanation: \nMap the number 991 as follows:\n1. mapping[9] = 6, so all occurrences of the digit 9 will become 6.\n2. mapping[1] = 9, so all occurrences of the digit 1 will become 9.\nTherefore, the mapped value of 991 is 669.\n338 maps to 007, or 7 after removing the leading zeros.\n38 maps to 07, which is also 7 after removing leading zeros.\nSince 338 and 38 share the same mapped value, they should remain in the same relative order, so 338 comes before 38.\nThus, the sorted array is [338,38,991].\n\nExample 2:\n\nInput: mapping = [0,1,2,3,4,5,6,7,8,9], nums = [789,456,123]\nOutput: [123,456,789]\nExplanation: 789 maps to 789, 456 maps to 456, and 123 maps to 123. Thus, the sorted array is [123,456,789].\n\n \nConstraints:\n\nmapping.length == 10\n0 <= mapping[i] <= 9\nAll the values of mapping[i] are unique.\n1 <= nums.length <= 3 * 104\n0 <= nums[i] < 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mapping = [5, 8, 9, 2, 1, 6, 7, 0, 3, 4],nums = [345, 123, 678]) == [345, 678, 123]\n assert candidate(mapping = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5],nums = [10, 100, 1000, 10000]) == [10, 100, 1000, 10000]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [90, 12, 34]) == [90, 12, 34]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50]\n assert candidate(mapping = [8, 9, 4, 0, 2, 1, 3, 5, 7, 6],nums = [991, 338, 38]) == [338, 38, 991]\n assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [10, 20, 30]) == [30, 20, 10]\n assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [123, 456, 789]) == [789, 456, 123]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [90, 81, 72]) == [90, 72, 81]\n assert candidate(mapping = [5, 8, 9, 0, 1, 2, 3, 4, 6, 7],nums = [555, 888, 999]) == [555, 888, 999]\n assert candidate(mapping = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [789, 456, 123]) == [123, 456, 789]\n assert candidate(mapping = [5, 8, 1, 2, 9, 4, 6, 0, 3, 7],nums = [512, 345, 890]) == [345, 890, 512]\n assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [100, 200, 300]) == [300, 200, 100]\n assert candidate(mapping = [5, 8, 9, 2, 1, 6, 3, 7, 0, 4],nums = [12, 34, 56, 78, 90]) == [34, 90, 56, 78, 12]\n assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [1234, 5678, 91011]) == [5678, 1234, 91011]\n assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [12345, 67890, 11111]) == [67890, 12345, 11111]\n assert candidate(mapping = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4],nums = [123, 456, 789]) == [789, 123, 456]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [10, 20, 30]) == [10, 20, 30]\n assert candidate(mapping = [8, 6, 4, 2, 0, 9, 7, 5, 3, 1],nums = [8642097531, 1357902468, 9876543210]) == [9876543210, 8642097531, 1357902468]\n assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [1000000000, 2000000000, 3000000000, 4000000000]) == [4000000000, 3000000000, 2000000000, 1000000000]\n assert candidate(mapping = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8],nums = [13579, 24680, 101010, 202020, 303030, 123123123]) == [13579, 101010, 24680, 303030, 202020, 123123123]\n assert candidate(mapping = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8],nums = [1357902468, 8642097531, 111333555777999, 2468013579]) == [1357902468, 2468013579, 8642097531, 111333555777999]\n assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [999999999, 888888888, 777777777, 666666666, 555555555]) == [999999999, 888888888, 777777777, 666666666, 555555555]\n assert candidate(mapping = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums = [111, 101, 110, 100, 1, 0]) == [111, 1, 110, 0, 101, 100]\n assert candidate(mapping = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0]) == [111, 0, 222, 333, 444, 555, 666, 777, 888, 999]\n assert candidate(mapping = [5, 9, 8, 2, 7, 6, 3, 1, 4, 0],nums = [555, 999, 888, 222, 777, 666, 333, 111, 444, 0]) == [999, 0, 777, 333, 666, 888, 555, 444, 222, 111]\n assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [101010, 202020, 303030, 404040, 505050]) == [505050, 404040, 303030, 202020, 101010]\n assert candidate(mapping = [6, 5, 4, 3, 2, 1, 0, 9, 8, 7],nums = [654321, 123456, 987654]) == [654321, 123456, 987654]\n assert candidate(mapping = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums = [999888777666, 888777666555, 777666555444, 666555444333]) == [666555444333, 777666555444, 888777666555, 999888777666]\n assert candidate(mapping = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8],nums = [10203040506070809, 9876543210, 112233445566778899]) == [9876543210, 10203040506070809, 112233445566778899]\n assert candidate(mapping = [0, 2, 1, 4, 3, 6, 5, 8, 7, 9],nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == [222222222, 123456789, 111111111, 444444444, 333333333, 666666666, 555555555, 888888888, 777777777, 987654321, 999999999]\n assert candidate(mapping = [5, 0, 1, 2, 3, 4, 6, 7, 8, 9],nums = [501234, 55555, 12345]) == [12345, 55555, 501234]\n assert candidate(mapping = [3, 5, 4, 6, 2, 7, 9, 1, 8, 0],nums = [3546279180, 3546279, 35462, 354, 35]) == [35, 354, 35462, 3546279, 3546279180]\n assert candidate(mapping = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9],nums = [111222333444, 888777666555, 444333222111]) == [888777666555, 444333222111, 111222333444]\n assert candidate(mapping = [3, 4, 5, 6, 7, 8, 9, 0, 1, 2],nums = [1234567890, 3456789012, 5678901234, 7890123456, 9012345678]) == [7890123456, 9012345678, 1234567890, 3456789012, 5678901234]\n assert candidate(mapping = [5, 9, 0, 2, 8, 6, 7, 3, 4, 1],nums = [123456789, 1029384756, 987654321]) == [987654321, 123456789, 1029384756]\n assert candidate(mapping = [9, 0, 8, 0, 7, 0, 6, 0, 5, 0],nums = [9876543210, 1234567890, 9090909090, 1010101010, 8080808080]) == [9876543210, 1234567890, 9090909090, 1010101010, 8080808080]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [987654321, 876543210, 765432109]) == [987654321, 765432109, 876543210]\n assert candidate(mapping = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9],nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000]) == [8000000000, 7000000000, 6000000000, 5000000000, 4000000000, 3000000000, 2000000000, 1000000000, 9000000000]\n assert candidate(mapping = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],nums = [1234567890, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == [111, 222, 333, 444, 555, 666, 777, 888, 999, 1234567890]\n assert candidate(mapping = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums = [900, 899, 798, 697, 596, 495, 394, 293, 192, 91]) == [91, 192, 293, 394, 495, 596, 697, 798, 899, 900]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 0]) == [999, 0, 111, 222, 333, 444, 555, 666, 777, 888]\n assert candidate(mapping = [2, 1, 4, 3, 6, 5, 8, 7, 0, 9],nums = [24680, 13579, 112233]) == [13579, 24680, 112233]\n assert candidate(mapping = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums = [123, 456, 789, 101, 202, 303]) == [123, 456, 789, 101, 202, 303]\n assert candidate(mapping = [2, 3, 4, 5, 6, 7, 8, 9, 0, 1],nums = [1234567890, 9876543210, 5678901234]) == [9876543210, 1234567890, 5678901234]\n assert candidate(mapping = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6],nums = [543210, 109876, 210987, 678905, 432109]) == [543210, 432109, 210987, 109876, 678905]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [1001001001, 2002002002, 3003003003, 4004004004]) == [1001001001, 2002002002, 3003003003, 4004004004]\n assert candidate(mapping = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8],nums = [7654321, 6543210, 5432109, 4321098, 3210987]) == [7654321, 6543210, 5432109, 4321098, 3210987]\n assert candidate(mapping = [2, 5, 9, 6, 0, 7, 8, 4, 3, 1],nums = [123456789, 987654321, 1122334455]) == [987654321, 123456789, 1122334455]\n assert candidate(mapping = [7, 8, 9, 0, 1, 2, 3, 4, 5, 6],nums = [7890123456, 6543210987, 789789789]) == [789789789, 6543210987, 7890123456]\n assert candidate(mapping = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [1000000000, 999999999, 888888888]) == [888888888, 999999999, 1000000000]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [111111111, 222222222, 333333333, 444444444]) == [111111111, 222222222, 333333333, 444444444]\n assert candidate(mapping = [4, 5, 6, 7, 8, 9, 0, 1, 2, 3],nums = [4567890123, 3210987654, 1112223334]) == [1112223334, 3210987654, 4567890123]\n assert candidate(mapping = [0, 2, 1, 3, 4, 5, 6, 7, 8, 9],nums = [987654321, 123456789]) == [123456789, 987654321]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [123456789, 234567890, 345678901, 456789012]) == [123456789, 234567890, 345678901, 456789012]\n assert candidate(mapping = [0, 2, 1, 4, 3, 6, 5, 8, 7, 9],nums = [123456789, 987654321, 43210]) == [43210, 123456789, 987654321]\n assert candidate(mapping = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [9876543210, 102030405060708090, 98765432109876543210]) == [9876543210, 102030405060708090, 98765432109876543210]\n assert candidate(mapping = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],nums = [13579, 24680, 97531, 86420, 12345]) == [97531, 12345, 13579, 24680, 86420]\n assert candidate(mapping = [3, 6, 9, 2, 5, 8, 1, 4, 7, 0],nums = [1000000000, 2121212121, 3232323232, 4343434343, 5454545454]) == [3232323232, 4343434343, 1000000000, 5454545454, 2121212121]\n assert candidate(mapping = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2],nums = [1098765432, 1234567890, 1122334455]) == [1122334455, 1098765432, 1234567890]\n assert candidate(mapping = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4],nums = [5678901234, 4567890123, 3456789012, 2345678901]) == [5678901234, 2345678901, 3456789012, 4567890123]\n assert candidate(mapping = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums = [987654321, 123456789, 111111111]) == [987654321, 123456789, 111111111]\n assert candidate(mapping = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5],nums = [999111333555, 888000222444, 777999111333, 666888000222]) == [666888000222, 888000222444, 999111333555, 777999111333]\n assert candidate(mapping = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [9876543210, 9999999999, 1111111111]) == [1111111111, 9876543210, 9999999999]\n assert candidate(mapping = [2, 0, 4, 6, 8, 1, 3, 5, 7, 9],nums = [1234567890, 9876543210, 55555, 24680]) == [55555, 24680, 1234567890, 9876543210]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [1234567890, 9876543210, 1020304050]) == [9876543210, 1020304050, 1234567890]\n assert candidate(mapping = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums = [1234567890, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == [1234567890, 111, 222, 333, 444, 555, 666, 777, 888, 999]\n assert candidate(mapping = [0, 2, 1, 4, 3, 6, 5, 8, 7, 9],nums = [10000, 20001, 30002, 40003, 50004, 60005, 70006, 80007, 90008]) == [20001, 10000, 40003, 30002, 60005, 50004, 80007, 70006, 90008]\n assert candidate(mapping = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums = [123456789, 987654321, 111111111, 222222222, 333333333]) == [123456789, 987654321, 111111111, 222222222, 333333333]\n assert candidate(mapping = [6, 3, 1, 7, 8, 9, 0, 5, 2, 4],nums = [6317890524, 1234567890, 9876543210, 4321098765, 5678901234]) == [6317890524, 1234567890, 9876543210, 4321098765, 5678901234]\n assert candidate(mapping = [2, 0, 4, 6, 8, 1, 3, 5, 7, 9],nums = [123456789, 987654321, 246801357]) == [123456789, 246801357, 987654321]\n assert candidate(mapping = [6, 5, 4, 3, 2, 1, 0, 9, 8, 7],nums = [1234567890, 1010101010, 2222222222]) == [2222222222, 1234567890, 1010101010]\n assert candidate(mapping = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3],nums = [3141592653, 141592653, 41592653, 1592653, 592653, 92653, 2653, 653, 53, 3]) == [3, 53, 653, 2653, 92653, 592653, 1592653, 41592653, 141592653, 3141592653]\n assert candidate(mapping = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums = [9876543210, 8765432109, 7654321098, 6543210987, 5432109876]) == [9876543210, 8765432109, 7654321098, 6543210987, 5432109876]\n assert candidate(mapping = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5],nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == [2222, 4444, 6666, 8888, 9999, 7777, 5555, 3333, 1111]\n assert candidate(mapping = [8, 9, 4, 0, 2, 1, 3, 5, 7, 6],nums = [1234567890, 9876543210, 1111111111, 0]) == [0, 9876543210, 1234567890, 1111111111]\n assert candidate(mapping = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],nums = [99999, 88888, 77777, 66666, 55555]) == [99999, 55555, 66666, 77777, 88888]\n assert candidate(mapping = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [10, 12, 14, 16, 18, 11, 13, 15, 17, 19]\n assert candidate(mapping = [4, 3, 2, 1, 0, 9, 8, 7, 6, 5],nums = [1234567890, 9876543210, 1357924680, 1098765432]) == [1357924680, 1234567890, 1098765432, 9876543210]\n assert candidate(mapping = [3, 4, 5, 6, 7, 8, 9, 0, 1, 2],nums = [10000, 10001, 10010, 10100, 11000, 123456789, 987654321]) == [10000, 10001, 10010, 10100, 11000, 987654321, 123456789]\n assert candidate(mapping = [1, 9, 0, 8, 2, 7, 6, 5, 4, 3],nums = [1908276543, 9082765431, 1029475863, 3210987654, 4321098765]) == [4321098765, 9082765431, 3210987654, 1029475863, 1908276543]\n assert candidate(mapping = [9, 7, 5, 3, 1, 8, 6, 4, 2, 0],nums = [999, 777, 555, 333, 111, 888, 666, 444, 222, 0]) == [999, 0, 444, 888, 333, 777, 222, 666, 111, 555]\n assert candidate(mapping = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8],nums = [7654321098, 6543210987, 5432109876, 4321098765]) == [7654321098, 6543210987, 5432109876, 4321098765]\n assert candidate(mapping = [3, 9, 5, 7, 0, 1, 2, 4, 6, 8],nums = [3957012468, 876543210, 333333333, 999999999]) == [876543210, 333333333, 999999999, 3957012468]\n assert candidate(mapping = [9, 0, 8, 1, 7, 2, 6, 3, 5, 4],nums = [9876543210, 8765432109, 7654321098, 6543210987]) == [7654321098, 9876543210, 8765432109, 6543210987]\n assert candidate(mapping = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9],nums = [13579, 24680, 11111, 22222]) == [11111, 13579, 22222, 24680]\n assert candidate(mapping = [2, 0, 1, 3, 4, 5, 6, 7, 8, 9],nums = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == [21, 22, 20, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(mapping = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9],nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == [888, 777, 666, 555, 444, 333, 222, 111, 999]\n assert candidate(mapping = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8],nums = [1122, 2233, 3344, 4455, 5566]) == [1122, 3344, 2233, 5566, 4455]\n assert candidate(mapping = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8],nums = [7654321098, 7654321098, 1234567890, 1234567890, 1111111111, 2222222222]) == [7654321098, 7654321098, 2222222222, 1234567890, 1234567890, 1111111111]\n assert candidate(mapping = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [9876543210, 987654321, 98765432, 9876543, 987654]) == [987654, 9876543, 98765432, 987654321, 9876543210]\n assert candidate(mapping = [0, 2, 1, 4, 3, 6, 5, 8, 7, 9],nums = [1020304050, 9080706050, 4030201000]) == [1020304050, 4030201000, 9080706050]\n assert candidate(mapping = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums = [0, 10, 100, 1000, 10000, 101, 1001, 10001]) == [0, 10, 100, 101, 1000, 1001, 10000, 10001]\n assert candidate(mapping = [3, 2, 1, 6, 5, 4, 9, 8, 7, 0],nums = [3216549870, 123456789, 987654321]) == [987654321, 123456789, 3216549870]\n assert candidate(mapping = [0, 6, 1, 7, 2, 8, 3, 9, 4, 5],nums = [6789012345, 1234567890, 9876543210, 5432109876]) == [6789012345, 9876543210, 1234567890, 5432109876]\n assert candidate(mapping = [8, 6, 4, 2, 0, 9, 7, 5, 3, 1],nums = [24680, 13579, 86420, 97531]) == [97531, 86420, 24680, 13579]\n assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [1, 10, 100, 1000, 10000, 100000]) == [1, 10, 100, 1000, 10000, 100000]\n assert candidate(mapping = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8],nums = [1357902468, 3579024681, 5790246813, 7902468135, 9024681357]) == [5790246813, 1357902468, 7902468135, 3579024681, 9024681357]\n assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [9876543210, 9999999999, 8888888888, 7777777777, 6666666666, 5555555555, 4444444444, 3333333333, 2222222222, 1111111111, 0]) == [9999999999, 0, 9876543210, 8888888888, 7777777777, 6666666666, 5555555555, 4444444444, 3333333333, 2222222222, 1111111111]\n assert candidate(mapping = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums = [9012345678, 8901234567, 7890123456]) == [7890123456, 8901234567, 9012345678]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [1098765432, 210987654, 321098765, 432109876, 543210987]) == [210987654, 321098765, 432109876, 543210987, 1098765432]\n assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0]) == [999, 0, 111, 222, 333, 444, 555, 666, 777, 888]\n assert candidate(mapping = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3],nums = [314159, 271828, 161803, 141421, 173205]) == [314159, 161803, 141421, 173205, 271828]\n assert candidate(mapping = [8, 0, 9, 4, 6, 5, 3, 7, 2, 1],nums = [1234567890, 9876543210, 1357924680]) == [1357924680, 1234567890, 9876543210]\n assert candidate(mapping = [2, 0, 9, 1, 5, 6, 3, 8, 4, 7],nums = [1029, 2056, 3084, 4073]) == [1029, 3084, 4073, 2056]\n assert candidate(mapping = [8, 3, 5, 2, 7, 1, 9, 4, 0, 6],nums = [321, 654, 987, 123, 456, 789]) == [321, 123, 789, 987, 456, 654]\n assert candidate(mapping = [9, 0, 8, 1, 7, 2, 6, 3, 5, 4],nums = [999999999, 111111111, 123456789, 987654321, 135792468, 864201357]) == [111111111, 135792468, 123456789, 999999999, 987654321, 864201357]\n assert candidate(mapping = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2],nums = [1234567890, 9876543210, 112233445566778899, 223344556677889900]) == [1234567890, 9876543210, 112233445566778899, 223344556677889900]\n assert candidate(mapping = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums = [123456789, 987654321, 111222333]) == [987654321, 123456789, 111222333]\n assert candidate(mapping = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2],nums = [1111111111, 2222222222, 3333333333, 4444444444, 5555555555, 6666666666, 7777777777, 8888888888, 9999999999]) == [1111111111, 9999999999, 8888888888, 7777777777, 6666666666, 5555555555, 4444444444, 3333333333, 2222222222]\n assert candidate(mapping = [9, 7, 5, 3, 1, 8, 6, 4, 2, 0],nums = [97531, 86420, 13579]) == [97531, 86420, 13579]\n"}, "metadata": {"canonical_parameter_names": ["mapping", "nums"], "leetcode_dataset_entry_point": "Solution().sortJumbled", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] sortJumbled(int[] mapping, int[] nums) {", "container": "Solution", "callable": "sortJumbled", "parameters": [{"name": "mapping", "type": "int[]"}, {"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2192, "task_id": "all-ancestors-of-a-node-in-a-directed-acyclic-graph", "difficulty": "Medium", "problem_description": "You are given a positive integer n representing the number of nodes of a Directed Acyclic Graph (DAG). The nodes are numbered from 0 to n - 1 (inclusive).\nYou are also given a 2D integer array edges, where edges[i] = [fromi, toi] denotes that there is a unidirectional edge from fromi to toi in the graph.\nReturn a list answer, where answer[i] is the list of ancestors of the ith node, sorted in ascending order.\nA node u is an ancestor of another node v if u can reach v via a set of edges.\n \nExample 1:\n\n\nInput: n = 8, edgeList = [[0,3],[0,4],[1,3],[2,4],[2,7],[3,5],[3,6],[3,7],[4,6]]\nOutput: [[],[],[],[0,1],[0,2],[0,1,3],[0,1,2,3,4],[0,1,2,3]]\nExplanation:\nThe above diagram represents the input graph.\n- Nodes 0, 1, and 2 do not have any ancestors.\n- Node 3 has two ancestors 0 and 1.\n- Node 4 has two ancestors 0 and 2.\n- Node 5 has three ancestors 0, 1, and 3.\n- Node 6 has five ancestors 0, 1, 2, 3, and 4.\n- Node 7 has four ancestors 0, 1, 2, and 3.\n\nExample 2:\n\n\nInput: n = 5, edgeList = [[0,1],[0,2],[0,3],[0,4],[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]\nOutput: [[],[0],[0,1],[0,1,2],[0,1,2,3]]\nExplanation:\nThe above diagram represents the input graph.\n- Node 0 does not have any ancestor.\n- Node 1 has one ancestor 0.\n- Node 2 has two ancestors 0 and 1.\n- Node 3 has three ancestors 0, 1, and 2.\n- Node 4 has four ancestors 0, 1, 2, and 3.\n\n \nConstraints:\n\n1 <= n <= 1000\n0 <= edges.length <= min(2000, n * (n - 1) / 2)\nedges[i].length == 2\n0 <= fromi, toi <= n - 1\nfromi != toi\nThere are no duplicate edges.\nThe graph is directed and acyclic.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[0, 2], [2, 3], [1, 3], [4, 5]]) == [[], [], [0], [0, 1, 2], [], [4]]\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]]) == [[], [0], [0, 1], [0, 1, 2]]\n assert candidate(n = 8,edges = [[0, 3], [0, 4], [1, 3], [2, 4], [2, 7], [3, 5], [3, 6], [3, 7], [4, 6]]) == [[], [], [], [0, 1], [0, 2], [0, 1, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3]]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2]]\n assert candidate(n = 3,edges = [[0, 1], [0, 2]]) == [[], [0], [0]]\n assert candidate(n = 1,edges = []) == [[]]\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3]]\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [15, 21], [16, 22], [17, 23], [18, 24]]) == [[], [0], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 3], [0, 3], [0, 1, 4], [0, 1, 5], [0, 2, 6], [0, 2, 7], [0, 3, 8], [0, 3, 9], [0, 1, 4, 10], [0, 1, 5, 11], [0, 2, 6, 12], [0, 2, 7, 13], [0, 3, 8, 14], [0, 3, 9, 15], [0, 1, 4, 10, 16], [0, 1, 5, 11, 17], [0, 2, 6, 12, 18]]\n assert candidate(n = 12,edges = [[0, 3], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [10, 11]]) == [[], [], [], [0, 1, 2], [0, 1, 2], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(n = 12,edges = [[0, 3], [1, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [6, 9], [7, 10], [8, 10], [9, 11]]) == [[], [], [], [0, 1], [2], [0, 1, 3], [0, 1, 3], [2, 4], [2, 4], [0, 1, 3, 5, 6], [2, 4, 7, 8], [0, 1, 3, 5, 6, 9]]\n assert candidate(n = 14,edges = [[0, 4], [1, 4], [2, 5], [2, 6], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 10], [6, 11], [7, 12], [8, 12], [9, 13], [10, 13], [11, 13]]) == [[], [], [], [], [0, 1], [2], [2, 3], [0, 1, 4], [0, 1, 4], [2, 5], [2, 3, 5, 6], [2, 3, 6], [0, 1, 4, 7, 8], [2, 3, 5, 6, 9, 10, 11]]\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(n = 10,edges = [[0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 5], [2, 6], [3, 6], [4, 6], [5, 7], [6, 7], [6, 8], [7, 9], [8, 9]]) == [[], [], [0, 1], [0, 1], [0], [1], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 20,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, 16], [8, 17], [9, 17], [9, 18], [10, 18], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 2, 5], [0, 2, 5], [0, 2, 6], [0, 2, 6], [0, 1, 3, 7], [0, 1, 3, 7, 8], [0, 1, 3, 4, 8, 9], [0, 1, 4, 9, 10], [0, 1, 2, 4, 5, 6, 10, 11, 12, 13, 14]]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 8], [8, 9], [9, 10], [10, 11]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3, 7], [0, 1, 3, 4, 7, 8], [0, 1, 3, 4, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(n = 18,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17]]) == [[], [0], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 3], [0, 3], [0, 1, 4], [0, 1, 5], [0, 2, 6], [0, 2, 7], [0, 3, 8], [0, 3, 9], [0, 1, 4, 10], [0, 1, 5, 11]]\n assert candidate(n = 10,edges = [[0, 5], [1, 5], [2, 6], [3, 6], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]]) == [[], [], [], [], [], [0, 1], [2, 3], [4], [0, 1, 2, 3, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 15,edges = [[0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [[], [], [], [0, 1, 2], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 2, 4], [0, 1, 2, 3, 5], [0, 1, 2, 3, 5], [0, 1, 2, 3, 6], [0, 1, 2, 3, 6]]\n assert candidate(n = 18,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 5], [2, 6], [3, 6], [3, 7], [4, 8], [5, 8], [5, 9], [6, 9], [6, 10], [7, 10], [8, 11], [9, 11], [9, 12], [10, 12], [11, 13], [12, 13], [12, 14], [13, 15], [14, 15], [14, 16], [15, 17]]) == [[], [0], [0], [0], [0, 1], [0, 1, 2], [0, 2, 3], [0, 3], [0, 1, 2, 4, 5], [0, 1, 2, 3, 5, 6], [0, 2, 3, 6, 7], [0, 1, 2, 3, 4, 5, 6, 8, 9], [0, 1, 2, 3, 5, 6, 7, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 5, 6, 7, 9, 10, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [0, 1, 2, 3, 5, 6, 7, 9, 10, 12, 14], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 9], [5, 8], [5, 10], [6, 9], [6, 10], [7, 11], [8, 11], [9, 11], [10, 11], [11, 12], [11, 13], [12, 14], [12, 15], [13, 14], [13, 16], [14, 17], [15, 17], [15, 18], [16, 18], [16, 19], [17, 19], [18, 19]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3, 4], [0, 1, 2, 3, 5], [0, 1, 2, 4, 6], [0, 2, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [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], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]]\n assert candidate(n = 20,edges = [[0, 5], [0, 10], [0, 15], [1, 5], [1, 6], [2, 6], [2, 7], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [5, 11], [6, 11], [6, 12], [7, 12], [7, 13], [8, 13], [8, 14], [9, 14], [10, 15], [10, 16], [11, 16], [11, 17], [12, 17], [12, 18], [13, 18], [13, 19], [14, 19]]) == [[], [], [], [], [], [0, 1], [1, 2], [2, 3], [3, 4], [4], [0, 1, 5], [0, 1, 2, 5, 6], [1, 2, 3, 6, 7], [2, 3, 4, 7, 8], [3, 4, 8, 9], [0, 1, 5, 10], [0, 1, 2, 5, 6, 10, 11], [0, 1, 2, 3, 5, 6, 7, 11, 12], [1, 2, 3, 4, 6, 7, 8, 12, 13], [2, 3, 4, 7, 8, 9, 13, 14]]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 8], [8, 9], [9, 10]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3, 7], [0, 1, 3, 4, 7, 8], [0, 1, 3, 4, 7, 8, 9], [0, 2, 5, 6]]\n assert candidate(n = 15,edges = [[0, 5], [0, 6], [1, 5], [1, 7], [2, 6], [2, 8], [3, 7], [3, 9], [4, 8], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14]]) == [[], [], [], [], [], [0, 1], [0, 2], [1, 3], [2, 4], [3], [4], [0, 1, 5], [0, 2, 6], [1, 3, 7], [2, 4, 8]]\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [1, 8], [1, 9], [2, 9]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 9,edges = [[0, 1], [0, 4], [0, 5], [1, 2], [1, 3], [2, 4], [2, 6], [3, 5], [3, 7], [4, 6], [4, 8], [5, 7], [6, 8], [7, 8]]) == [[], [0], [0, 1], [0, 1], [0, 1, 2], [0, 1, 3], [0, 1, 2, 4], [0, 1, 3, 5], [0, 1, 2, 3, 4, 5, 6, 7]]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 8], [5, 9], [6, 9]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3, 4], [0, 2, 5, 6]]\n assert candidate(n = 16,edges = [[0, 3], [1, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 10], [6, 11], [7, 12], [8, 12], [9, 13], [10, 13], [10, 14], [11, 14], [12, 15], [13, 15], [14, 15]]) == [[], [], [], [0, 1], [2], [0, 1, 3], [0, 1, 3], [2, 4], [2, 4], [0, 1, 3, 5], [0, 1, 3, 5, 6], [0, 1, 3, 6], [2, 4, 7, 8], [0, 1, 3, 5, 6, 9, 10], [0, 1, 3, 5, 6, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5], [4, 6], [5, 6], [5, 7], [6, 7], [6, 8], [7, 8], [7, 9], [8, 9]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 10], [5, 11], [6, 12], [6, 13], [7, 12], [7, 13], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14]]) == [[], [0], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 3], [0, 3], [0, 1, 4, 5], [0, 1, 4, 5], [0, 2, 6, 7], [0, 2, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]]\n assert candidate(n = 12,edges = [[0, 3], [0, 4], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 11], [8, 11], [9, 10], [10, 11]]) == [[], [], [], [0, 1], [0, 1], [2], [2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 2, 4, 5, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(n = 20,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], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 2, 5], [0, 2, 5], [0, 2, 6], [0, 2, 6], [0, 1, 3, 7], [0, 1, 3, 7], [0, 1, 3, 8], [0, 1, 3, 8], [0, 1, 2, 4, 5, 6, 9, 10, 11, 12, 13, 14]]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 2, 5]]\n assert candidate(n = 30,edges = [[0, 15], [1, 16], [2, 17], [3, 18], [4, 19], [5, 20], [6, 21], [7, 22], [8, 23], [9, 24], [10, 25], [11, 26], [12, 27], [13, 28], [14, 29], [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]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [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, 14]]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 8], [4, 9], [5, 9], [6, 9]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3, 4], [0, 1, 2, 4, 5, 6]]\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6]]) == [[], [0], [0, 1], [0, 1], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5]]\n assert candidate(n = 15,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]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]]\n assert candidate(n = 14,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], [7, 11], [8, 12], [9, 13], [10, 13]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 1, 2, 3, 5, 7], [0, 1, 2, 3, 5, 8], [0, 1, 2, 4, 6, 9, 10]]\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8]]) == [[], [0], [0], [0, 1, 2], [0, 1, 2], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6, 7]]\n assert candidate(n = 10,edges = [[0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 6], [4, 5], [4, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 9], [8, 9]]) == [[], [], [0, 1], [0, 1], [0, 1], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 11,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(n = 15,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]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 2, 5], [0, 2, 5], [0, 2, 6], [0, 2, 6]]\n assert candidate(n = 15,edges = [[0, 5], [0, 6], [1, 6], [1, 7], [2, 7], [2, 8], [3, 8], [3, 9], [4, 9], [4, 10], [5, 11], [6, 11], [7, 12], [8, 12], [9, 13], [10, 13], [11, 14], [12, 14]]) == [[], [], [], [], [], [0], [0, 1], [1, 2], [2, 3], [3, 4], [4], [0, 1, 5, 6], [1, 2, 3, 7, 8], [3, 4, 9, 10], [0, 1, 2, 3, 5, 6, 7, 8, 11, 12]]\n assert candidate(n = 20,edges = [[0, 5], [0, 6], [1, 7], [1, 8], [2, 9], [2, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [6, 15], [7, 16], [8, 16], [9, 17], [10, 17], [11, 18], [12, 18], [13, 19], [14, 19], [15, 19], [16, 19], [17, 19], [18, 19]]) == [[], [], [], [], [], [0], [0], [1], [1], [2], [2], [3], [3], [4], [4], [0, 5, 6], [1, 7, 8], [2, 9, 10], [3, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]]\n assert candidate(n = 15,edges = [[0, 5], [1, 5], [1, 6], [2, 7], [2, 8], [3, 8], [3, 9], [4, 9], [4, 10], [5, 11], [5, 12], [6, 12], [7, 13], [7, 14], [8, 14], [9, 14]]) == [[], [], [], [], [], [0, 1], [1], [2], [2, 3], [3, 4], [4], [0, 1, 5], [0, 1, 5, 6], [2, 7], [2, 3, 4, 7, 8, 9]]\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 8]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3, 4], [0, 1, 2, 3, 4, 5, 6, 7]]\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 5], [3, 6], [4, 6], [4, 7], [5, 7], [6, 8], [7, 8]]) == [[], [0], [0], [0, 1, 2], [0, 1], [0, 2], [0, 1, 2, 3, 4], [0, 1, 2, 4, 5], [0, 1, 2, 3, 4, 5, 6, 7]]\n assert candidate(n = 12,edges = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10], [10, 11]]) == [[], [], [], [], [0], [1], [2], [3], [0, 1, 4, 5], [2, 3, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(n = 15,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, 11], [8, 12]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 1, 2, 3, 5, 7], [0, 1, 2, 3, 5, 8], [0, 2, 6], [0, 2, 6]]\n assert candidate(n = 20,edges = [[0, 5], [0, 6], [1, 7], [1, 8], [2, 9], [2, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [8, 19], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19]]) == [[], [], [], [], [], [0], [0], [1], [1], [2], [2], [3], [3], [4], [4], [0, 5], [0, 5], [0, 6], [0, 6], [1, 2, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14]]\n assert candidate(n = 20,edges = [[0, 5], [1, 5], [2, 6], [3, 6], [4, 7], [5, 8], [5, 9], [6, 10], [6, 11], [7, 12], [8, 13], [9, 13], [10, 14], [10, 15], [11, 14], [12, 15], [13, 16], [13, 17], [14, 18], [14, 19], [15, 18], [16, 19]]) == [[], [], [], [], [], [0, 1], [2, 3], [4], [0, 1, 5], [0, 1, 5], [2, 3, 6], [2, 3, 6], [4, 7], [0, 1, 5, 8, 9], [2, 3, 6, 10, 11], [2, 3, 4, 6, 7, 10, 12], [0, 1, 5, 8, 9, 13], [0, 1, 5, 8, 9, 13], [2, 3, 4, 6, 7, 10, 11, 12, 14, 15], [0, 1, 2, 3, 5, 6, 8, 9, 10, 11, 13, 14, 16]]\n assert candidate(n = 10,edges = [[0, 5], [0, 6], [1, 5], [1, 7], [2, 6], [2, 8], [3, 7], [3, 9], [4, 8], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [[], [], [], [], [], [0, 1], [0, 2], [1, 3], [2, 4], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 20,edges = [[0, 10], [1, 10], [2, 10], [3, 11], [4, 11], [5, 11], [6, 12], [7, 12], [8, 12], [9, 13], [10, 14], [11, 14], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19]]) == [[], [], [], [], [], [], [], [], [], [], [0, 1, 2], [3, 4, 5], [6, 7, 8], [9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12], [9, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14], [9, 13, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16], [9, 13, 15, 17]]\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 9], [5, 8], [5, 10], [6, 9], [6, 10], [7, 10], [8, 10], [9, 10]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3, 4], [0, 1, 2, 3, 5], [0, 1, 2, 4, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(n = 20,edges = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [0, 2], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [0, 1, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1], [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, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 5], [2, 6], [3, 6], [4, 7], [5, 7], [6, 7], [7, 8], [8, 9]]) == [[], [0], [0], [0], [0, 1], [0, 1, 2], [0, 2, 3], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8], [5, 9], [5, 10], [6, 9], [6, 10], [7, 11], [8, 11], [9, 11], [10, 11]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3, 4], [0, 1, 3, 4], [0, 2, 5, 6], [0, 2, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3, 4], [0, 2, 5, 6], [0, 1, 3, 4, 7]]\n assert candidate(n = 25,edges = [[0, 12], [0, 13], [1, 12], [1, 13], [2, 14], [2, 15], [3, 15], [3, 16], [4, 16], [4, 17], [5, 17], [5, 18], [6, 18], [6, 19], [7, 19], [7, 20], [8, 20], [8, 21], [9, 21], [9, 22], [10, 22], [10, 23], [11, 23], [11, 24]]) == [[], [], [], [], [], [], [], [], [], [], [], [], [0, 1], [0, 1], [2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11]]\n assert candidate(n = 20,edges = [[0, 10], [0, 11], [1, 10], [1, 11], [2, 12], [2, 13], [3, 13], [3, 14], [4, 14], [4, 15], [5, 15], [5, 16], [6, 16], [6, 17], [7, 17], [7, 18], [8, 18], [8, 19], [9, 19]]) == [[], [], [], [], [], [], [], [], [], [], [0, 1], [0, 1], [2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]\n assert candidate(n = 12,edges = [[0, 5], [0, 6], [1, 6], [1, 7], [2, 7], [2, 8], [3, 8], [3, 9], [4, 9], [5, 10], [6, 10], [7, 10], [8, 11], [9, 11], [10, 11]]) == [[], [], [], [], [], [0], [0, 1], [1, 2], [2, 3], [3, 4], [0, 1, 2, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().getAncestors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List> getAncestors(int n, int[][] edges) {", "container": "Solution", "callable": "getAncestors", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}], "return_type": "List>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2193, "task_id": "minimum-number-of-moves-to-make-palindrome", "difficulty": "Hard", "problem_description": "You are given a string s consisting only of lowercase English letters.\nIn one move, you can select any two adjacent characters of s and swap them.\nReturn the minimum number of moves needed to make s a palindrome.\nNote that the input will be generated such that s can always be converted to a palindrome.\n \nExample 1:\n\nInput: s = \"aabb\"\nOutput: 2\nExplanation:\nWe can obtain two palindromes from s, \"abba\" and \"baab\". \n- We can obtain \"abba\" from s in 2 moves: \"aabb\" -> \"abab\" -> \"abba\".\n- We can obtain \"baab\" from s in 2 moves: \"aabb\" -> \"abab\" -> \"baab\".\nThus, the minimum number of moves needed to make s a palindrome is 2.\n\nExample 2:\n\nInput: s = \"letelt\"\nOutput: 2\nExplanation:\nOne of the palindromes we can obtain from s in 2 moves is \"lettel\".\nOne of the ways we can obtain it is \"letelt\" -> \"letetl\" -> \"lettel\".\nOther palindromes such as \"tleelt\" can also be obtained in 2 moves.\nIt can be shown that it is not possible to obtain a palindrome in less than 2 moves.\n\n \nConstraints:\n\n1 <= s.length <= 2000\ns consists only of lowercase English letters.\ns can be converted to a palindrome using a finite number of moves.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == 0\n assert candidate(s = \"letelt\") == 2\n assert candidate(s = \"abcdcba\") == 0\n assert candidate(s = \"aabbaa\") == 0\n assert candidate(s = \"abcdedcba\") == 0\n assert candidate(s = \"mamad\") == 3\n assert candidate(s = \"aabbc\") == 4\n assert candidate(s = \"aabb\") == 2\n assert candidate(s = \"racecar\") == 0\n assert candidate(s = \"abcdefgfedcba\") == 0\n assert candidate(s = \"noon\") == 0\n assert candidate(s = \"deeee\") == 2\n assert candidate(s = \"nnnnn\") == 0\n assert candidate(s = \"aabbcc\") == 6\n assert candidate(s = \"elvtoelvtoe\") == 6\n assert candidate(s = \"aabbab\") == 3\n assert candidate(s = \"asflkj\") == 5\n assert candidate(s = \"abca\") == 1\n assert candidate(s = \"abcdefghgfedcba\") == 0\n assert candidate(s = \"zzzyzzyzz\") == 1\n assert candidate(s = \"noonappa\") == 8\n assert candidate(s = \"abcdcbad\") == 3\n assert candidate(s = \"aabaaabbaaaaaabbbbaa\") == 11\n assert candidate(s = \"aabbaabbaabb\") == 6\n assert candidate(s = \"jlvaj\") == 1\n assert candidate(s = \"xyzyzyzyzyx\") == 0\n assert candidate(s = \"qpwoeirutoip\") == 12\n assert candidate(s = \"abbbacaba\") == 3\n assert candidate(s = \"abcabcabcabc\") == 6\n assert candidate(s = \"noonnoon\") == 0\n assert candidate(s = \"aaaaabbbb\") == 10\n assert candidate(s = \"mnopqponmlkjihgfedcbaaaabbbccc\") == 161\n assert candidate(s = \"aabbccddeeefffgggggffffeeeeddccbaaabb\") == 37\n assert candidate(s = \"lplllp\") == 1\n assert candidate(s = \"aabbbbaaa\") == 2\n assert candidate(s = \"aaabbbcccdddcccbbaaa\") == 5\n assert candidate(s = \"mmnmm\") == 0\n assert candidate(s = \"mnvovnm\") == 0\n assert candidate(s = \"aabbccddeee\") == 24\n assert candidate(s = \"xyzzyx\") == 0\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmmlkjhgfdsapoiuytrewq\") == 9\n assert candidate(s = \"aabbaabbaabbaabb\") == 8\n assert candidate(s = \"abcdddcb\") == 4\n assert candidate(s = \"abcdxyzzyxcba\") == 3\n assert candidate(s = \"aabbccddeeeeddcbaabbaa\") == 22\n assert candidate(s = \"aabbccddeeefffgggghhhggggfffeeeedddccbbaa\") == 20\n assert candidate(s = \"aaaabbbbccccddddeeeeffffggggggg\") == 204\n assert candidate(s = \"ppqqrrssrqqpp\") == 1\n assert candidate(s = \"aaabbbb\") == 6\n assert candidate(s = \"abcdedcbaa\") == 4\n assert candidate(s = \"aabbccddeeffeecdccbbaa\") == 7\n assert candidate(s = \"aabbccddeeefffggggffffeeeeddccbaaabb\") == 38\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"abcdeedcba\") == 0\n assert candidate(s = \"abacabad\") == 4\n assert candidate(s = \"xyzyxzyxzyxzyx\") == 2\n assert candidate(s = \"aaabbbaaa\") == 0\n assert candidate(s = \"aabbabaa\") == 1\n assert candidate(s = \"abcbaabcba\") == 0\n assert candidate(s = \"zazbzazbzaz\") == 0\n assert candidate(s = \"abcdeffedcba\") == 0\n assert candidate(s = \"abcbca\") == 1\n assert candidate(s = \"abcdefedcba\") == 0\n assert candidate(s = \"aabbccdd\") == 12\n assert candidate(s = \"level\") == 0\n assert candidate(s = \"abcabcba\") == 1\n assert candidate(s = \"aaaabbbb\") == 8\n assert candidate(s = \"madam\") == 0\n assert candidate(s = \"aabababaab\") == 3\n assert candidate(s = \"aabccbaa\") == 0\n assert candidate(s = \"abacabadabacaba\") == 0\n assert candidate(s = \"aabbccddeeeffffgggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwxxyyzz\") == 1192\n assert candidate(s = \"qwertewq\") == 1\n assert candidate(s = \"qwertytrewq\") == 0\n assert candidate(s = \"abcbad\") == 3\n assert candidate(s = \"abbaaccdaabb\") == 5\n assert candidate(s = \"aababbaaabbbbbaaaaa\") == 8\n assert candidate(s = \"aabaaa\") == 1\n assert candidate(s = \"aaabaaaabbaa\") == 4\n assert candidate(s = \"xyzyzyx\") == 0\n assert candidate(s = \"abccba\") == 0\n assert candidate(s = \"zxcvbnmlkjhgfdasqwertyuiopoiuytrewqasdfghjklmnbvcxz\") == 1\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbaaaaaaaaa\") == 6\n assert candidate(s = \"aabbccddeeeeddcbbbaa\") == 10\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 650\n assert candidate(s = \"aabbabba\") == 2\n assert candidate(s = \"mmnnllkkjjiihhggffeeddccbbaa\") == 182\n assert candidate(s = \"aaaaabbbaaaa\") == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"nnnmmmnnn\") == 0\n assert candidate(s = \"repaper\") == 0\n assert candidate(s = \"abacdfgdcaba\") == 1\n assert candidate(s = \"aabbccddeeefffgggfhheeeddccbaa\") == 22\n assert candidate(s = \"abbaabba\") == 0\n assert candidate(s = \"zyxzyzyx\") == 4\n assert candidate(s = \"abcddcba\") == 0\n assert candidate(s = \"rotor\") == 0\n assert candidate(s = \"abcdefghihgfedcba\") == 0\n assert candidate(s = \"aabbccddeeeffggffeeddccbbaa\") == 3\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == 115\n assert candidate(s = \"aabbccddeeeffffgggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == 1311\n assert candidate(s = \"levellol\") == 6\n assert candidate(s = \"mississippi\") == 13\n assert candidate(s = \"abcdeffgfedcba\") == 1\n assert candidate(s = \"aabbccddeedcbaa\") == 6\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minMovesToMakePalindrome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minMovesToMakePalindrome(String s) {", "container": "Solution", "callable": "minMovesToMakePalindrome", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2194, "task_id": "cells-in-a-range-on-an-excel-sheet", "difficulty": "Easy", "problem_description": "A cell (r, c) of an excel sheet is represented as a string \"\" where:\n\n denotes the column number c of the cell. It is represented by alphabetical letters.\n\n\t\nFor example, the 1st column is denoted by 'A', the 2nd by 'B', the 3rd by 'C', and so on.\n\n\n is the row number r of the cell. The rth row is represented by the integer r.\n\nYou are given a string s in the format \":\", where represents the column c1, represents the row r1, represents the column c2, and represents the row r2, such that r1 <= r2 and c1 <= c2.\nReturn the list of cells (x, y) such that r1 <= x <= r2 and c1 <= y <= c2. The cells should be represented as strings in the format mentioned above and be sorted in non-decreasing order first by columns and then by rows.\n \nExample 1:\n\n\nInput: s = \"K1:L2\"\nOutput: [\"K1\",\"K2\",\"L1\",\"L2\"]\nExplanation:\nThe above diagram shows the cells which should be present in the list.\nThe red arrows denote the order in which the cells should be presented.\n\nExample 2:\n\n\nInput: s = \"A1:F1\"\nOutput: [\"A1\",\"B1\",\"C1\",\"D1\",\"E1\",\"F1\"]\nExplanation:\nThe above diagram shows the cells which should be present in the list.\nThe red arrow denotes the order in which the cells should be presented.\n\n \nConstraints:\n\ns.length == 5\n'A' <= s[0] <= s[3] <= 'Z'\n'1' <= s[1] <= s[4] <= '9'\ns consists of uppercase English letters, digits and ':'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"D4:H6\") == ['D4', 'D5', 'D6', 'E4', 'E5', 'E6', 'F4', 'F5', 'F6', 'G4', 'G5', 'G6', 'H4', 'H5', 'H6']\n assert candidate(s = \"K1:L2\") == ['K1', 'K2', 'L1', 'L2']\n assert candidate(s = \"A1:F1\") == ['A1', 'B1', 'C1', 'D1', 'E1', 'F1']\n assert candidate(s = \"B2:D3\") == ['B2', 'B3', 'C2', 'C3', 'D2', 'D3']\n assert candidate(s = \"Z1:Z9\") == ['Z1', 'Z2', 'Z3', 'Z4', 'Z5', 'Z6', 'Z7', 'Z8', 'Z9']\n assert candidate(s = \"Z1:Z5\") == ['Z1', 'Z2', 'Z3', 'Z4', 'Z5']\n assert candidate(s = \"A1:A1\") == ['A1']\n assert candidate(s = \"B2:C3\") == ['B2', 'B3', 'C2', 'C3']\n assert candidate(s = \"Y2:Z8\") == ['Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8', 'Z2', 'Z3', 'Z4', 'Z5', 'Z6', 'Z7', 'Z8']\n assert candidate(s = \"L2:W7\") == ['L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7']\n assert candidate(s = \"Y5:Z8\") == ['Y5', 'Y6', 'Y7', 'Y8', 'Z5', 'Z6', 'Z7', 'Z8']\n assert candidate(s = \"T1:U8\") == ['T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'U1', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8']\n assert candidate(s = \"V6:W15\") == []\n assert candidate(s = \"Z1:Z26\") == []\n assert candidate(s = \"C1:C26\") == []\n assert candidate(s = \"D5:D5\") == ['D5']\n assert candidate(s = \"J2:L3\") == ['J2', 'J3', 'K2', 'K3', 'L2', 'L3']\n assert candidate(s = \"A1:Z9\") == ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'I8', 'I9', 'J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'K1', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8', 'K9', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8', 'L9', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'N9', 'O1', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'U1', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8', 'U9', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9', 'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8', 'Y9', 'Z1', 'Z2', 'Z3', 'Z4', 'Z5', 'Z6', 'Z7', 'Z8', 'Z9']\n assert candidate(s = \"F1:F26\") == []\n assert candidate(s = \"S1:T7\") == ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7']\n assert candidate(s = \"M3:P7\") == ['M3', 'M4', 'M5', 'M6', 'M7', 'N3', 'N4', 'N5', 'N6', 'N7', 'O3', 'O4', 'O5', 'O6', 'O7', 'P3', 'P4', 'P5', 'P6', 'P7']\n assert candidate(s = \"F4:H7\") == ['F4', 'F5', 'F6', 'F7', 'G4', 'G5', 'G6', 'G7', 'H4', 'H5', 'H6', 'H7']\n assert candidate(s = \"Q1:Z2\") == ['Q1', 'Q2', 'R1', 'R2', 'S1', 'S2', 'T1', 'T2', 'U1', 'U2', 'V1', 'V2', 'W1', 'W2', 'X1', 'X2', 'Y1', 'Y2', 'Z1', 'Z2']\n assert candidate(s = \"I1:I26\") == []\n assert candidate(s = \"M1:N6\") == ['M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6']\n assert candidate(s = \"Q7:R10\") == []\n assert candidate(s = \"W1:W26\") == []\n assert candidate(s = \"CD10:CE15\") == []\n assert candidate(s = \"M3:N4\") == ['M3', 'M4', 'N3', 'N4']\n assert candidate(s = \"T2:U5\") == ['T2', 'T3', 'T4', 'T5', 'U2', 'U3', 'U4', 'U5']\n assert candidate(s = \"D8:F11\") == []\n assert candidate(s = \"N3:O5\") == ['N3', 'N4', 'N5', 'O3', 'O4', 'O5']\n assert candidate(s = \"G1:V9\") == ['G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'I8', 'I9', 'J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'K1', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8', 'K9', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8', 'L9', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'N9', 'O1', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'U1', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8', 'U9', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9']\n assert candidate(s = \"B1:B26\") == []\n assert candidate(s = \"A1:AC5\") == ['A1', 'A2', 'A3', 'A4', 'A5', 'B1', 'B2', 'B3', 'B4', 'B5', 'C1', 'C2', 'C3', 'C4', 'C5']\n assert candidate(s = \"D1:D9\") == ['D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9']\n assert candidate(s = \"R1:T4\") == ['R1', 'R2', 'R3', 'R4', 'S1', 'S2', 'S3', 'S4', 'T1', 'T2', 'T3', 'T4']\n assert candidate(s = \"K1:K26\") == []\n assert candidate(s = \"Y1:Z2\") == ['Y1', 'Y2', 'Z1', 'Z2']\n assert candidate(s = \"I2:J5\") == ['I2', 'I3', 'I4', 'I5', 'J2', 'J3', 'J4', 'J5']\n assert candidate(s = \"E3:G7\") == ['E3', 'E4', 'E5', 'E6', 'E7', 'F3', 'F4', 'F5', 'F6', 'F7', 'G3', 'G4', 'G5', 'G6', 'G7']\n assert candidate(s = \"V1:V26\") == []\n assert candidate(s = \"O1:O26\") == []\n assert candidate(s = \"V5:X8\") == ['V5', 'V6', 'V7', 'V8', 'W5', 'W6', 'W7', 'W8', 'X5', 'X6', 'X7', 'X8']\n assert candidate(s = \"Q1:R26\") == []\n assert candidate(s = \"R1:R26\") == []\n assert candidate(s = \"M1:M10\") == []\n assert candidate(s = \"N5:N9\") == ['N5', 'N6', 'N7', 'N8', 'N9']\n assert candidate(s = \"G1:H10\") == []\n assert candidate(s = \"X1:Y2\") == ['X1', 'X2', 'Y1', 'Y2']\n assert candidate(s = \"W1:X10\") == []\n assert candidate(s = \"E1:F10\") == []\n assert candidate(s = \"F3:K8\") == ['F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'I3', 'I4', 'I5', 'I6', 'I7', 'I8', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8']\n assert candidate(s = \"J2:T6\") == ['J2', 'J3', 'J4', 'J5', 'J6', 'K2', 'K3', 'K4', 'K5', 'K6', 'L2', 'L3', 'L4', 'L5', 'L6', 'M2', 'M3', 'M4', 'M5', 'M6', 'N2', 'N3', 'N4', 'N5', 'N6', 'O2', 'O3', 'O4', 'O5', 'O6', 'P2', 'P3', 'P4', 'P5', 'P6', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'R2', 'R3', 'R4', 'R5', 'R6', 'S2', 'S3', 'S4', 'S5', 'S6', 'T2', 'T3', 'T4', 'T5', 'T6']\n assert candidate(s = \"E5:T10\") == []\n assert candidate(s = \"X1:X9\") == ['X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9']\n assert candidate(s = \"Y1:Z10\") == []\n assert candidate(s = \"D1:G3\") == ['D1', 'D2', 'D3', 'E1', 'E2', 'E3', 'F1', 'F2', 'F3', 'G1', 'G2', 'G3']\n assert candidate(s = \"A1:Z1\") == ['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1', 'H1', 'I1', 'J1', 'K1', 'L1', 'M1', 'N1', 'O1', 'P1', 'Q1', 'R1', 'S1', 'T1', 'U1', 'V1', 'W1', 'X1', 'Y1', 'Z1']\n assert candidate(s = \"T1:U5\") == ['T1', 'T2', 'T3', 'T4', 'T5', 'U1', 'U2', 'U3', 'U4', 'U5']\n assert candidate(s = \"Y10:Z15\") == []\n assert candidate(s = \"J1:J26\") == []\n assert candidate(s = \"E1:E26\") == []\n assert candidate(s = \"X5:AA10\") == []\n assert candidate(s = \"G10:H12\") == []\n assert candidate(s = \"Q1:R10\") == []\n assert candidate(s = \"A1:BC3\") == ['A1', 'A2', 'A3', 'B1', 'B2', 'B3', 'C1', 'C2', 'C3']\n assert candidate(s = \"B1:Z9\") == ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'I8', 'I9', 'J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'K1', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8', 'K9', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8', 'L9', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'N9', 'O1', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'U1', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8', 'U9', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9', 'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8', 'Y9', 'Z1', 'Z2', 'Z3', 'Z4', 'Z5', 'Z6', 'Z7', 'Z8', 'Z9']\n assert candidate(s = \"R15:S25\") == []\n assert candidate(s = \"S1:T10\") == []\n assert candidate(s = \"P1:S4\") == ['P1', 'P2', 'P3', 'P4', 'Q1', 'Q2', 'Q3', 'Q4', 'R1', 'R2', 'R3', 'R4', 'S1', 'S2', 'S3', 'S4']\n assert candidate(s = \"A1:A26\") == []\n assert candidate(s = \"R2:S6\") == ['R2', 'R3', 'R4', 'R5', 'R6', 'S2', 'S3', 'S4', 'S5', 'S6']\n assert candidate(s = \"M1:N1\") == ['M1', 'N1']\n assert candidate(s = \"A10:A12\") == []\n assert candidate(s = \"A1:Z26\") == []\n assert candidate(s = \"F1:J10\") == []\n assert candidate(s = \"G2:H2\") == ['G2', 'H2']\n assert candidate(s = \"Z1:AA5\") == []\n assert candidate(s = \"Y1:Y26\") == []\n assert candidate(s = \"C2:Y7\") == ['C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7']\n assert candidate(s = \"X3:Y7\") == ['X3', 'X4', 'X5', 'X6', 'X7', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7']\n assert candidate(s = \"X25:Y30\") == []\n assert candidate(s = \"A1:AA26\") == []\n assert candidate(s = \"C3:D7\") == ['C3', 'C4', 'C5', 'C6', 'C7', 'D3', 'D4', 'D5', 'D6', 'D7']\n assert candidate(s = \"C1:D5\") == ['C1', 'C2', 'C3', 'C4', 'C5', 'D1', 'D2', 'D3', 'D4', 'D5']\n assert candidate(s = \"A1:X9\") == ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'I8', 'I9', 'J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'K1', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8', 'K9', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8', 'L9', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'N9', 'O1', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'U1', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8', 'U9', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9']\n assert candidate(s = \"H8:H8\") == ['H8']\n assert candidate(s = \"G7:H9\") == ['G7', 'G8', 'G9', 'H7', 'H8', 'H9']\n assert candidate(s = \"M5:N10\") == []\n assert candidate(s = \"U1:V10\") == []\n assert candidate(s = \"M5:R10\") == []\n assert candidate(s = \"A1:AB1\") == ['A1', 'B1']\n assert candidate(s = \"A1:B10\") == []\n assert candidate(s = \"T1:T26\") == []\n assert candidate(s = \"W10:X20\") == []\n assert candidate(s = \"Y1:Z3\") == ['Y1', 'Y2', 'Y3', 'Z1', 'Z2', 'Z3']\n assert candidate(s = \"H1:H26\") == []\n assert candidate(s = \"X1:Y6\") == ['X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6']\n assert candidate(s = \"D1:F9\") == ['D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9']\n assert candidate(s = \"B4:E8\") == ['B4', 'B5', 'B6', 'B7', 'B8', 'C4', 'C5', 'C6', 'C7', 'C8', 'D4', 'D5', 'D6', 'D7', 'D8', 'E4', 'E5', 'E6', 'E7', 'E8']\n assert candidate(s = \"F6:F20\") == []\n assert candidate(s = \"L1:L26\") == []\n assert candidate(s = \"Y20:AB25\") == []\n assert candidate(s = \"Q20:R22\") == []\n assert candidate(s = \"J10:K15\") == []\n assert candidate(s = \"AA10:AB10\") == []\n assert candidate(s = \"D5:H7\") == ['D5', 'D6', 'D7', 'E5', 'E6', 'E7', 'F5', 'F6', 'F7', 'G5', 'G6', 'G7', 'H5', 'H6', 'H7']\n assert candidate(s = \"X1:Z1\") == ['X1', 'Y1', 'Z1']\n assert candidate(s = \"S1:Z3\") == ['S1', 'S2', 'S3', 'T1', 'T2', 'T3', 'U1', 'U2', 'U3', 'V1', 'V2', 'V3', 'W1', 'W2', 'W3', 'X1', 'X2', 'X3', 'Y1', 'Y2', 'Y3', 'Z1', 'Z2', 'Z3']\n assert candidate(s = \"I5:K7\") == ['I5', 'I6', 'I7', 'J5', 'J6', 'J7', 'K5', 'K6', 'K7']\n assert candidate(s = \"P10:Q20\") == []\n assert candidate(s = \"M10:N15\") == []\n assert candidate(s = \"J1:K5\") == ['J1', 'J2', 'J3', 'J4', 'J5', 'K1', 'K2', 'K3', 'K4', 'K5']\n assert candidate(s = \"M1:N12\") == []\n assert candidate(s = \"M5:T8\") == ['M5', 'M6', 'M7', 'M8', 'N5', 'N6', 'N7', 'N8', 'O5', 'O6', 'O7', 'O8', 'P5', 'P6', 'P7', 'P8', 'Q5', 'Q6', 'Q7', 'Q8', 'R5', 'R6', 'R7', 'R8', 'S5', 'S6', 'S7', 'S8', 'T5', 'T6', 'T7', 'T8']\n assert candidate(s = \"A2:A9\") == ['A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9']\n assert candidate(s = \"G1:G26\") == []\n assert candidate(s = \"J2:L5\") == ['J2', 'J3', 'J4', 'J5', 'K2', 'K3', 'K4', 'K5', 'L2', 'L3', 'L4', 'L5']\n assert candidate(s = \"G5:I8\") == ['G5', 'G6', 'G7', 'G8', 'H5', 'H6', 'H7', 'H8', 'I5', 'I6', 'I7', 'I8']\n assert candidate(s = \"U1:U26\") == []\n assert candidate(s = \"B1:B10\") == []\n assert candidate(s = \"O1:P10\") == []\n assert candidate(s = \"A3:C6\") == ['A3', 'A4', 'A5', 'A6', 'B3', 'B4', 'B5', 'B6', 'C3', 'C4', 'C5', 'C6']\n assert candidate(s = \"M1:M26\") == []\n assert candidate(s = \"Q1:R9\") == ['Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9']\n assert candidate(s = \"D4:P12\") == []\n assert candidate(s = \"Y10:Y20\") == []\n assert candidate(s = \"Z1:Z10\") == []\n assert candidate(s = \"AA1:AB10\") == []\n assert candidate(s = \"X5:Z9\") == ['X5', 'X6', 'X7', 'X8', 'X9', 'Y5', 'Y6', 'Y7', 'Y8', 'Y9', 'Z5', 'Z6', 'Z7', 'Z8', 'Z9']\n assert candidate(s = \"T1:U4\") == ['T1', 'T2', 'T3', 'T4', 'U1', 'U2', 'U3', 'U4']\n assert candidate(s = \"P1:P26\") == []\n assert candidate(s = \"A1:A9\") == ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9']\n assert candidate(s = \"B10:B19\") == []\n assert candidate(s = \"F1:F9\") == ['F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9']\n assert candidate(s = \"M5:O8\") == ['M5', 'M6', 'M7', 'M8', 'N5', 'N6', 'N7', 'N8', 'O5', 'O6', 'O7', 'O8']\n assert candidate(s = \"N1:N26\") == []\n assert candidate(s = \"Y1:AA2\") == []\n assert candidate(s = \"J1:K3\") == ['J1', 'J2', 'J3', 'K1', 'K2', 'K3']\n assert candidate(s = \"F2:J7\") == ['F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7']\n assert candidate(s = \"B9:D12\") == []\n assert candidate(s = \"C1:D10\") == []\n assert candidate(s = \"A1:B1\") == ['A1', 'B1']\n assert candidate(s = \"M1:N10\") == []\n assert candidate(s = \"D1:D26\") == []\n assert candidate(s = \"X1:X26\") == []\n assert candidate(s = \"K1:L10\") == []\n assert candidate(s = \"G5:H8\") == ['G5', 'G6', 'G7', 'G8', 'H5', 'H6', 'H7', 'H8']\n assert candidate(s = \"R3:X8\") == ['R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8']\n assert candidate(s = \"C3:F7\") == ['C3', 'C4', 'C5', 'C6', 'C7', 'D3', 'D4', 'D5', 'D6', 'D7', 'E3', 'E4', 'E5', 'E6', 'E7', 'F3', 'F4', 'F5', 'F6', 'F7']\n assert candidate(s = \"I1:J10\") == []\n assert candidate(s = \"C1:C5\") == ['C1', 'C2', 'C3', 'C4', 'C5']\n assert candidate(s = \"H1:H9\") == ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9']\n assert candidate(s = \"C4:E6\") == ['C4', 'C5', 'C6', 'D4', 'D5', 'D6', 'E4', 'E5', 'E6']\n assert candidate(s = \"E5:F7\") == ['E5', 'E6', 'E7', 'F5', 'F6', 'F7']\n assert candidate(s = \"P1:Q9\") == ['P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9']\n assert candidate(s = \"V1:W3\") == ['V1', 'V2', 'V3', 'W1', 'W2', 'W3']\n assert candidate(s = \"A5:C10\") == []\n assert candidate(s = \"C4:D8\") == ['C4', 'C5', 'C6', 'C7', 'C8', 'D4', 'D5', 'D6', 'D7', 'D8']\n assert candidate(s = \"F1:H4\") == ['F1', 'F2', 'F3', 'F4', 'G1', 'G2', 'G3', 'G4', 'H1', 'H2', 'H3', 'H4']\n assert candidate(s = \"G1:H1\") == ['G1', 'H1']\n assert candidate(s = \"W3:X6\") == ['W3', 'W4', 'W5', 'W6', 'X3', 'X4', 'X5', 'X6']\n assert candidate(s = \"J9:K12\") == []\n assert candidate(s = \"N3:Q6\") == ['N3', 'N4', 'N5', 'N6', 'O3', 'O4', 'O5', 'O6', 'P3', 'P4', 'P5', 'P6', 'Q3', 'Q4', 'Q5', 'Q6']\n assert candidate(s = \"A10:C12\") == []\n assert candidate(s = \"J4:L7\") == ['J4', 'J5', 'J6', 'J7', 'K4', 'K5', 'K6', 'K7', 'L4', 'L5', 'L6', 'L7']\n assert candidate(s = \"F2:H5\") == ['F2', 'F3', 'F4', 'F5', 'G2', 'G3', 'G4', 'G5', 'H2', 'H3', 'H4', 'H5']\n assert candidate(s = \"X5:Y8\") == ['X5', 'X6', 'X7', 'X8', 'Y5', 'Y6', 'Y7', 'Y8']\n assert candidate(s = \"W2:Y5\") == ['W2', 'W3', 'W4', 'W5', 'X2', 'X3', 'X4', 'X5', 'Y2', 'Y3', 'Y4', 'Y5']\n assert candidate(s = \"B3:D15\") == []\n assert candidate(s = \"W1:X3\") == ['W1', 'W2', 'W3', 'X1', 'X2', 'X3']\n assert candidate(s = \"Q1:Q26\") == []\n assert candidate(s = \"P1:Q1\") == ['P1', 'Q1']\n assert candidate(s = \"S1:S26\") == []\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().cellsInRange", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List cellsInRange(String s) {", "container": "Solution", "callable": "cellsInRange", "parameters": [{"name": "s", "type": "String"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2195, "task_id": "append-k-integers-with-minimal-sum", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k. Append k unique positive integers that do not appear in nums to nums such that the resulting total sum is minimum.\nReturn the sum of the k integers appended to nums.\n \nExample 1:\n\nInput: nums = [1,4,25,10,25], k = 2\nOutput: 5\nExplanation: The two unique positive integers that do not appear in nums which we append are 2 and 3.\nThe resulting sum of nums is 1 + 4 + 25 + 10 + 25 + 2 + 3 = 70, which is the minimum.\nThe sum of the two integers appended is 2 + 3 = 5, so we return 5.\nExample 2:\n\nInput: nums = [5,6], k = 6\nOutput: 25\nExplanation: The six unique positive integers that do not appear in nums which we append are 1, 2, 3, 4, 7, and 8.\nThe resulting sum of nums is 5 + 6 + 1 + 2 + 3 + 4 + 7 + 8 = 36, which is the minimum. \nThe sum of the six integers appended is 1 + 2 + 3 + 4 + 7 + 8 = 25, so we return 25.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= k <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 21\n assert candidate(nums = [1, 4, 25, 10, 25],k = 2) == 5\n assert candidate(nums = [1000000000],k = 100000) == 5000050000\n assert candidate(nums = [1000000000],k = 1) == 1\n assert candidate(nums = [1, 3, 5, 7, 9],k = 10) == 95\n assert candidate(nums = [1],k = 1) == 2\n assert candidate(nums = [1, 3, 5, 7, 9],k = 5) == 30\n assert candidate(nums = [10, 20, 30, 40, 50],k = 5) == 15\n assert candidate(nums = [5, 6],k = 6) == 25\n assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 2\n assert candidate(nums = [1000000000],k = 100000000) == 5000000050000000\n assert candidate(nums = [10, 20, 30],k = 5) == 15\n assert candidate(nums = [5, 15, 25, 35, 45],k = 15) == 133\n assert candidate(nums = [100, 200, 300, 400, 500],k = 50) == 1275\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],k = 50) == 1445\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 155\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 30) == 603\n assert candidate(nums = [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],k = 25) == 442\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 65\n assert candidate(nums = [1],k = 1000000) == 500001500000\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 50) == 1513\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 = 50) == 1390\n assert candidate(nums = [999999998, 999999999, 1000000000],k = 100000) == 5000050000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 20) == 210\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 100000) == 5000050000\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 = 10) == 110\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 = 25) == 950\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 11, 12, 13, 16, 17, 18],k = 15) == 264\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000],k = 500000) == 125000250000\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 10) == 57\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 126\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 215\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 20) == 233\n assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5],k = 15) == 175\n assert candidate(nums = [1000000000],k = 1000000) == 500000500000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 155\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 241\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) == 570\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 1390\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 = 25) == 391\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 1390\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 50000) == 1250025000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 25) == 391\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],k = 100) == 6940\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 = 10) == 100\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) == 610\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 30) == 691\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 = 100) == 6815\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 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],k = 5) == 115\n assert candidate(nums = [500000000, 600000000, 700000000, 800000000, 900000000],k = 100000) == 5000050000\n assert candidate(nums = [5, 15, 25, 35, 45],k = 10) == 61\n assert candidate(nums = [2, 4, 6, 8, 10],k = 5) == 25\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 25) == 361\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) == 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 50) == 2775\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 100\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10) == 63\n assert candidate(nums = [2],k = 1000000) == 500001499999\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23],k = 15) == 224\n assert candidate(nums = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46],k = 20) == 315\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 = 50) == 3275\n assert candidate(nums = [1000000000, 1000000001, 1000000002],k = 100000) == 5000050000\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 15) == 225\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],k = 100) == 5556\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 = 35) == 766\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 = 100) == 10050\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000],k = 100000) == 5000050000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 223\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98],k = 25) == 433\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 100) == 5556\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50) == 1275\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29],k = 20) == 520\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 215\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 15) == 160\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50) == 1275\n assert candidate(nums = [999999990, 999999991, 999999992, 999999993, 999999994],k = 5) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 110\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 100000) == 5000050000\n assert candidate(nums = [3, 9, 2, 8, 6, 7],k = 3) == 10\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240],k = 30) == 534\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) == 115\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 65\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 365\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 100) == 6330\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 223\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) == 810\n assert candidate(nums = [999999998, 999999999, 1000000000],k = 3) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 365\n assert candidate(nums = [1000000000],k = 500000) == 125000250000\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 20) == 295\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],k = 200) == 21990\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000],k = 10000) == 50005000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 25) == 391\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 = 100) == 10050\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) == 7050\n assert candidate(nums = [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],k = 25) == 442\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) == 255\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 30\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 15) == 141\n assert candidate(nums = [3, 5, 7, 9, 11],k = 10) == 85\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 = 30) == 1215\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 500000) == 125000250000\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 = 50) == 2775\n assert candidate(nums = [5, 15, 25, 35, 45],k = 10) == 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],k = 100) == 7050\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100) == 6050\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 110\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 = 15) == 225\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 56\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimalKSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimalKSum(int[] nums, int k) {", "container": "Solution", "callable": "minimalKSum", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2196, "task_id": "create-binary-tree-from-descriptions", "difficulty": "Medium", "problem_description": "You are given a 2D integer array descriptions where descriptions[i] = [parenti, childi, isLefti] indicates that parenti is the parent of childi in a binary tree of unique values. Furthermore,\n\nIf isLefti == 1, then childi is the left child of parenti.\nIf isLefti == 0, then childi is the right child of parenti.\n\nConstruct the binary tree described by descriptions and return its root.\nThe test cases will be generated such that the binary tree is valid.\n \nExample 1:\n\n\nInput: descriptions = [[20,15,1],[20,17,0],[50,20,1],[50,80,0],[80,19,1]]\nOutput: [50,20,80,15,17,19]\nExplanation: The root node is the node with value 50 since it has no parent.\nThe resulting binary tree is shown in the diagram.\n\nExample 2:\n\n\nInput: descriptions = [[1,2,1],[2,3,0],[3,4,1]]\nOutput: [1,2,null,null,3,4]\nExplanation: The root node is the node with value 1 since it has no parent.\nThe resulting binary tree is shown in the diagram.\n\n \nConstraints:\n\n1 <= descriptions.length <= 104\ndescriptions[i].length == 3\n1 <= parenti, childi <= 105\n0 <= isLefti <= 1\nThe binary tree described by descriptions is valid.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_tree(candidate(descriptions = [[1, 2, 1], [2, 3, 0], [3, 4, 1]]), tree_node([1, 2, None, None, 3, 4]))\n assert is_same_tree(candidate(descriptions = [[20, 15, 1], [20, 17, 0], [50, 20, 1], [50, 80, 0], [80, 19, 1]]), tree_node([50, 20, 80, 15, 17, 19]))\n assert is_same_tree(candidate(descriptions = [[10, 5, 1], [10, 15, 0], [5, 3, 1], [5, 7, 0], [15, 12, 1], [15, 18, 0], [3, 1, 1], [3, 4, 0], [7, 6, 1], [7, 8, 0]]), tree_node([10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8]))\n assert is_same_tree(candidate(descriptions = [[1, 2, 1], [1, 3, 0], [2, 4, 1], [2, 5, 0], [3, 6, 1], [3, 7, 0], [4, 8, 1], [4, 9, 0], [5, 10, 1], [5, 11, 0], [6, 12, 1], [6, 13, 0], [7, 14, 1], [7, 15, 0]]), tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_tree(candidate(descriptions = [[99, 98, 1], [98, 97, 1], [97, 96, 1], [96, 95, 1], [95, 94, 1], [94, 93, 1], [93, 92, 1], [92, 91, 1], [91, 90, 1], [90, 89, 1], [89, 88, 1], [88, 87, 1], [87, 86, 1], [86, 85, 1]]), tree_node([99, 98, None, 97, None, 96, None, 95, None, 94, None, 93, None, 92, None, 91, None, 90, None, 89, None, 88, None, 87, None, 86, None, 85]))\n assert is_same_tree(candidate(descriptions = [[1, 2, 1], [2, 4, 1], [4, 8, 1], [8, 16, 1], [16, 32, 1], [32, 64, 1], [64, 128, 1], [1, 3, 0], [3, 5, 1], [5, 9, 1], [9, 17, 1], [17, 33, 1], [33, 65, 1], [65, 129, 1], [1, 6, 0], [6, 10, 1], [10, 18, 1], [18, 34, 1], [34, 66, 1], [66, 130, 1], [1, 7, 0], [7, 11, 1], [11, 19, 1], [19, 35, 1], [35, 67, 1], [67, 131, 1], [1, 8, 0], [8, 12, 1], [12, 20, 1], [20, 36, 1], [36, 68, 1], [68, 132, 1], [1, 9, 0], [9, 13, 1], [13, 21, 1], [21, 37, 1], [37, 69, 1], [69, 133, 1], [1, 10, 0], [10, 14, 1], [14, 22, 1], [22, 38, 1], [38, 70, 1], [70, 134, 1]]), tree_node([1, 2, 10, 4, None, 14, None, 8, None, 22, None, 12, None, 38, None, 20, None, 70, None, 36, None, 134, None, 68, None, None, None, 132]))\n assert is_same_tree(candidate(descriptions = [[2, 1, 1], [2, 3, 0], [3, 6, 0], [6, 12, 0], [12, 24, 0], [24, 48, 0], [48, 96, 0], [96, 192, 0], [192, 384, 0], [384, 768, 0]]), tree_node([2, 1, 3, None, None, None, 6, None, 12, None, 24, None, 48, None, 96, None, 192, None, 384, None, 768]))\n assert is_same_tree(candidate(descriptions = [[1, 2, 1], [2, 4, 1], [2, 5, 0], [1, 3, 0], [3, 6, 1], [3, 7, 0], [7, 14, 1], [7, 15, 0], [15, 30, 1], [15, 31, 0], [31, 62, 1], [31, 63, 0], [63, 126, 1], [63, 127, 0]]), tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 14, 15, None, None, 30, 31, None, None, 62, 63, None, None, 126, 127]))\n assert is_same_tree(candidate(descriptions = [[100, 50, 1], [100, 150, 0], [50, 25, 1], [50, 75, 0], [150, 125, 1], [150, 175, 0]]), tree_node([100, 50, 150, 25, 75, 125, 175]))\n assert is_same_tree(candidate(descriptions = [[1000, 500, 1], [500, 250, 1], [500, 750, 0], [1000, 1500, 0], [1500, 1250, 1], [1500, 1750, 0], [1750, 1600, 1], [1750, 1800, 0], [1800, 1775, 1], [1800, 1825, 0]]), tree_node([1000, 500, 1500, 250, 750, 1250, 1750, None, None, None, None, None, None, 1600, 1800, None, None, 1775, 1825]))\n assert is_same_tree(candidate(descriptions = [[1, 2, 1], [2, 4, 1], [2, 5, 0], [4, 8, 1], [4, 9, 0], [5, 10, 1], [5, 11, 0], [1, 3, 0], [3, 6, 1], [3, 7, 0]]), tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]))\n assert is_same_tree(candidate(descriptions = [[1000, 500, 1], [1000, 1500, 0], [500, 250, 1], [500, 750, 0], [1500, 1250, 1], [1500, 1750, 0], [750, 375, 1], [750, 1125, 0], [1250, 625, 1], [1250, 937, 0], [1750, 1562, 1], [1750, 1875, 0], [375, 187, 1], [375, 562, 0], [1125, 843, 1], [1125, 1406, 0], [625, 312, 1], [625, 468, 0], [937, 468, 1], [937, 703, 0], [1562, 781, 1], [1562, 1281, 0], [1875, 937, 1], [1875, 938, 0]]), tree_node([1000, 500, 1500, 250, 750, 1250, 1750, None, None, 375, 1125, 625, 937, 1562, 1875, 187, 562, 843, 1406, 312, 468, 468, 703, 781, 1281, 937, 938, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 468, 703]))\n assert is_same_tree(candidate(descriptions = [[5, 3, 1], [5, 8, 0], [3, 2, 1], [3, 4, 0], [8, 7, 1], [8, 9, 0], [4, 6, 0], [9, 10, 1]]), tree_node([5, 3, 8, 2, 4, 7, 9, None, None, None, 6, None, None, 10]))\n assert is_same_tree(candidate(descriptions = [[60, 30, 1], [60, 90, 0], [30, 15, 1], [30, 45, 0], [45, 40, 1], [45, 50, 0], [90, 75, 1], [90, 105, 0], [105, 100, 1], [105, 110, 0]]), tree_node([60, 30, 90, 15, 45, 75, 105, None, None, 40, 50, None, None, 100, 110]))\n assert is_same_tree(candidate(descriptions = [[100, 50, 1], [100, 150, 0], [50, 25, 1], [50, 75, 0], [150, 125, 1], [150, 175, 0], [175, 160, 1], [175, 190, 0]]), tree_node([100, 50, 150, 25, 75, 125, 175, None, None, None, None, None, None, 160, 190]))\n assert is_same_tree(candidate(descriptions = [[30, 20, 1], [30, 40, 0], [20, 10, 1], [20, 25, 0], [40, 35, 1], [40, 45, 0], [10, 5, 1], [10, 15, 0]]), tree_node([30, 20, 40, 10, 25, 35, 45, 5, 15]))\n assert is_same_tree(candidate(descriptions = [[1000, 500, 1], [1000, 1500, 0], [500, 250, 1], [500, 750, 0], [1500, 1250, 1], [1500, 1750, 0], [1250, 1125, 1], [1250, 1375, 0], [1750, 1625, 1], [1750, 1875, 0], [1875, 1825, 1], [1875, 1925, 0]]), tree_node([1000, 500, 1500, 250, 750, 1250, 1750, None, None, None, None, 1125, 1375, 1625, 1875, None, None, None, None, None, None, 1825, 1925]))\n assert is_same_tree(candidate(descriptions = [[100, 50, 1], [100, 150, 0], [50, 25, 1], [50, 75, 0], [150, 125, 1], [150, 175, 0], [175, 200, 0]]), tree_node([100, 50, 150, 25, 75, 125, 175, None, None, None, None, None, None, None, 200]))\n assert is_same_tree(candidate(descriptions = [[99, 88, 1], [99, 77, 0], [88, 66, 1], [88, 55, 0], [77, 44, 1], [77, 33, 0], [66, 22, 1], [66, 11, 0], [55, 9, 1], [55, 8, 0], [44, 7, 1], [44, 6, 0], [33, 5, 1], [33, 4, 0], [22, 3, 1], [22, 2, 0], [11, 1, 1], [11, 0, 0]]), tree_node([99, 88, 77, 66, 55, 44, 33, 22, 11, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]))\n assert is_same_tree(candidate(descriptions = [[25, 10, 1], [25, 30, 0], [10, 5, 1], [10, 15, 0], [30, 28, 1], [30, 32, 0], [5, 3, 1], [5, 7, 0], [15, 12, 1], [15, 18, 0], [28, 26, 1], [28, 29, 0], [32, 31, 1], [32, 33, 0]]), tree_node([25, 10, 30, 5, 15, 28, 32, 3, 7, 12, 18, 26, 29, 31, 33]))\n assert is_same_tree(candidate(descriptions = [[1, 3, 1], [1, 2, 0], [3, 5, 1], [3, 4, 0], [5, 7, 1], [5, 6, 0], [7, 11, 1], [7, 8, 0], [8, 9, 1], [8, 10, 0]]), tree_node([1, 3, 2, 5, 4, None, None, 7, 6, None, None, 11, 8, None, None, None, None, 9, 10]))\n assert is_same_tree(candidate(descriptions = [[100, 50, 1], [100, 150, 0], [50, 25, 1], [50, 75, 0], [150, 125, 1], [150, 175, 0], [75, 60, 0], [175, 180, 0]]), tree_node([100, 50, 150, 25, 75, 125, 175, None, None, None, 60, None, None, None, 180]))\n assert is_same_tree(candidate(descriptions = [[200, 100, 1], [200, 300, 0], [100, 50, 1], [100, 150, 0], [300, 250, 1], [300, 350, 0], [150, 125, 1], [150, 175, 0], [350, 325, 1], [350, 375, 0]]), tree_node([200, 100, 300, 50, 150, 250, 350, None, None, 125, 175, None, None, 325, 375]))\n assert is_same_tree(candidate(descriptions = [[30, 20, 1], [30, 40, 0], [20, 10, 1], [20, 25, 0], [40, 35, 1], [40, 50, 0], [50, 45, 1], [50, 55, 0]]), tree_node([30, 20, 40, 10, 25, 35, 50, None, None, None, None, None, None, 45, 55]))\n assert is_same_tree(candidate(descriptions = [[10, 5, 1], [10, 15, 0], [5, 3, 1], [5, 7, 0], [15, 12, 1], [15, 18, 0], [18, 17, 1], [18, 19, 0], [19, 16, 0], [19, 20, 1]]), tree_node([10, 5, 15, 3, 7, 12, 18, None, None, None, None, None, None, 17, 19, None, None, 20, 16]))\n assert is_same_tree(candidate(descriptions = [[100, 50, 1], [100, 150, 0], [50, 25, 1], [50, 75, 0], [150, 125, 1], [150, 175, 0], [25, 10, 1], [75, 60, 0], [125, 110, 0], [175, 190, 1]]), tree_node([100, 50, 150, 25, 75, 125, 175, 10, None, None, 60, None, 110, 190]))\n assert is_same_tree(candidate(descriptions = [[8, 4, 1], [8, 12, 0], [4, 2, 1], [4, 6, 0], [12, 10, 1], [12, 14, 0], [2, 1, 1], [2, 3, 0], [6, 5, 1], [6, 7, 0]]), tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7]))\n assert is_same_tree(candidate(descriptions = [[99, 66, 1], [66, 33, 1], [33, 16, 1], [16, 8, 1], [8, 4, 1], [4, 2, 1], [2, 1, 1], [99, 77, 0], [77, 55, 0], [55, 38, 0], [38, 19, 0], [19, 9, 0], [9, 4, 0], [4, 2, 0], [99, 88, 0], [88, 55, 1], [55, 34, 1], [34, 17, 1], [17, 8, 0]]), tree_node([99, 66, 88, 33, None, 55, None, 16, None, 34, 38, 8, None, 17, None, None, 19, 4, None, None, 8, None, 9, 2, 2, 4, None, None, 4, 1, None, 1, None, 2, 2, 2, 2, None, None, None, None, 1, None, 1, None, 1, None, 1]))\n assert is_same_tree(candidate(descriptions = [[100, 50, 1], [100, 150, 0], [50, 25, 1], [50, 75, 0], [150, 125, 1], [150, 175, 0], [25, 10, 1], [25, 40, 0], [75, 60, 1], [75, 85, 0], [125, 110, 1], [125, 135, 0], [175, 160, 1], [175, 185, 0]]), tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 85, 110, 135, 160, 185]))\n assert is_same_tree(candidate(descriptions = [[5, 3, 1], [5, 7, 0], [3, 2, 1], [3, 4, 0], [7, 6, 1], [7, 8, 0], [2, 1, 1], [4, 9, 0], [9, 10, 1]]), tree_node([5, 3, 7, 2, 4, 6, 8, 1, None, None, 9, None, None, None, None, None, None, 10]))\n assert is_same_tree(candidate(descriptions = [[30, 20, 1], [20, 10, 1], [20, 25, 0], [30, 40, 0], [40, 35, 1], [40, 45, 0], [35, 32, 1], [35, 37, 0], [45, 42, 1], [45, 47, 0]]), tree_node([30, 20, 40, 10, 25, 35, 45, None, None, None, None, 32, 37, 42, 47]))\n assert is_same_tree(candidate(descriptions = [[5, 3, 1], [5, 7, 0], [3, 1, 1], [3, 4, 0], [7, 6, 1], [7, 8, 0], [8, 9, 1], [9, 10, 0], [10, 11, 1], [11, 12, 0], [12, 13, 1]]), tree_node([5, 3, 7, 1, 4, 6, 8, None, None, None, None, None, None, 9, None, None, 10, 11, None, None, 12, 13]))\n assert is_same_tree(candidate(descriptions = [[1, 3, 1], [1, 2, 0], [2, 4, 1], [2, 5, 0], [3, 6, 1], [3, 7, 0], [4, 8, 1], [4, 9, 0], [5, 10, 1], [5, 11, 0], [6, 12, 1], [6, 13, 0], [7, 14, 1], [7, 15, 0], [8, 16, 1], [8, 17, 0], [9, 18, 1], [9, 19, 0]]), tree_node([1, 3, 2, 6, 7, 4, 5, 12, 13, 14, 15, 8, 9, 10, 11, None, None, None, None, None, None, None, None, 16, 17, 18, 19]))\n assert is_same_tree(candidate(descriptions = [[10, 5, 1], [10, 15, 0], [5, 3, 1], [5, 7, 0], [15, 12, 1], [15, 18, 0]]), tree_node([10, 5, 15, 3, 7, 12, 18]))\n assert is_same_tree(candidate(descriptions = [[500, 250, 1], [500, 750, 0], [250, 125, 1], [250, 375, 0], [750, 625, 1], [750, 875, 0], [125, 60, 1], [125, 180, 0], [375, 290, 1], [375, 440, 0], [625, 550, 1], [625, 680, 0], [875, 800, 1], [875, 940, 0]]), tree_node([500, 250, 750, 125, 375, 625, 875, 60, 180, 290, 440, 550, 680, 800, 940]))\n assert is_same_tree(candidate(descriptions = [[5, 4, 1], [5, 6, 0], [4, 3, 1], [4, 2, 0], [6, 7, 1], [6, 8, 0], [7, 9, 1], [7, 10, 0], [8, 11, 1], [8, 12, 0], [9, 13, 1], [9, 14, 0], [10, 15, 1], [10, 16, 0], [11, 17, 1], [11, 18, 0], [12, 19, 1], [12, 20, 0], [13, 21, 1], [13, 22, 0], [14, 23, 1], [14, 24, 0], [15, 25, 1], [15, 26, 0], [16, 27, 1], [16, 28, 0]]), tree_node([5, 4, 6, 3, 2, 7, 8, None, None, None, None, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]))\n assert is_same_tree(candidate(descriptions = [[7, 3, 1], [7, 10, 0], [3, 1, 1], [3, 5, 0], [10, 8, 1], [10, 12, 0], [5, 4, 0], [5, 6, 1], [8, 9, 1], [12, 11, 0]]), tree_node([7, 3, 10, 1, 5, 8, 12, None, None, 6, 4, 9, None, None, 11]))\n assert is_same_tree(candidate(descriptions = [[60, 30, 1], [60, 90, 0], [30, 15, 1], [30, 45, 0], [90, 75, 1], [90, 105, 0], [15, 10, 1], [15, 20, 0], [45, 35, 1], [45, 50, 0], [75, 65, 1], [75, 85, 0], [105, 100, 1], [105, 110, 0]]), tree_node([60, 30, 90, 15, 45, 75, 105, 10, 20, 35, 50, 65, 85, 100, 110]))\n assert is_same_tree(candidate(descriptions = [[5, 3, 1], [5, 7, 0], [3, 2, 1], [3, 4, 0], [7, 6, 1], [7, 8, 0], [2, 1, 1], [4, 9, 0], [6, 11, 1], [8, 13, 0], [1, 0, 1], [9, 12, 0], [11, 10, 0], [13, 14, 1]]), tree_node([5, 3, 7, 2, 4, 6, 8, 1, None, None, 9, 11, None, None, 13, 0, None, None, 12, None, 10, 14]))\n assert is_same_tree(candidate(descriptions = [[100, 50, 1], [100, 150, 0], [50, 25, 1], [50, 75, 0], [150, 125, 1], [150, 175, 0], [75, 60, 1], [75, 90, 0]]), tree_node([100, 50, 150, 25, 75, 125, 175, None, None, 60, 90]))\n assert is_same_tree(candidate(descriptions = [[100, 50, 1], [100, 150, 0], [50, 25, 1], [50, 75, 0], [150, 125, 1], [150, 175, 0], [175, 160, 1]]), tree_node([100, 50, 150, 25, 75, 125, 175, None, None, None, None, None, None, 160]))\n assert is_same_tree(candidate(descriptions = [[1000, 500, 1], [1000, 1500, 0], [500, 250, 1], [500, 750, 0], [1500, 1250, 1], [1500, 1750, 0], [250, 100, 1], [750, 600, 0], [1250, 1100, 0], [1750, 1900, 1], [100, 50, 1], [600, 550, 0], [1100, 1050, 0], [1900, 1850, 1]]), tree_node([1000, 500, 1500, 250, 750, 1250, 1750, 100, None, None, 600, None, 1100, 1900, None, 50, None, None, 550, None, 1050, 1850]))\n assert is_same_tree(candidate(descriptions = [[30, 20, 1], [30, 40, 0], [20, 10, 1], [20, 25, 0], [40, 35, 1], [40, 45, 0], [10, 5, 1], [25, 15, 0], [35, 32, 1], [45, 47, 0]]), tree_node([30, 20, 40, 10, 25, 35, 45, 5, None, None, 15, 32, None, None, 47]))\n assert is_same_tree(candidate(descriptions = [[30, 20, 1], [20, 10, 1], [10, 5, 1], [5, 2, 1], [30, 40, 0], [40, 50, 0], [50, 60, 0]]), tree_node([30, 20, 40, 10, None, None, 50, 5, None, None, 60, 2]))\n assert is_same_tree(candidate(descriptions = [[1, 3, 1], [1, 2, 0], [2, 4, 1], [2, 5, 0], [3, 6, 1], [3, 7, 0], [4, 8, 1], [4, 9, 0], [5, 10, 1], [5, 11, 0]]), tree_node([1, 3, 2, 6, 7, 4, 5, None, None, None, None, 8, 9, 10, 11]))\n assert is_same_tree(candidate(descriptions = [[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], [19, 20, 1]]), tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20]))\n assert is_same_tree(candidate(descriptions = [[1, 2, 1], [2, 3, 0], [3, 4, 1], [4, 5, 0], [5, 6, 1], [6, 7, 0], [7, 8, 1], [8, 9, 0], [9, 10, 1], [10, 11, 0]]), tree_node([1, 2, None, None, 3, 4, None, None, 5, 6, None, None, 7, 8, None, None, 9, 10, None, None, 11]))\n assert is_same_tree(candidate(descriptions = [[5, 3, 1], [5, 8, 0], [3, 2, 1], [3, 4, 0], [8, 7, 1], [8, 9, 0], [7, 6, 1], [9, 10, 0], [6, 11, 1], [6, 12, 0], [10, 13, 1], [10, 14, 0], [12, 15, 1], [12, 16, 0]]), tree_node([5, 3, 8, 2, 4, 7, 9, None, None, None, None, 6, None, None, 10, 11, 12, 13, 14, None, None, 15, 16]))\n"}, "metadata": {"canonical_parameter_names": ["descriptions"], "leetcode_dataset_entry_point": "Solution().createBinaryTree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2197, "task_id": "replace-non-coprime-numbers-in-array", "difficulty": "Hard", "problem_description": "You are given an array of integers nums. Perform the following steps:\n\nFind any two adjacent numbers in nums that are non-coprime.\nIf no such numbers are found, stop the process.\nOtherwise, delete the two numbers and replace them with their LCM (Least Common Multiple).\nRepeat this process as long as you keep finding two adjacent non-coprime numbers.\n\nReturn the final modified array. It can be shown that replacing adjacent non-coprime numbers in any arbitrary order will lead to the same result.\nThe test cases are generated such that the values in the final array are less than or equal to 108.\nTwo values x and y are non-coprime if GCD(x, y) > 1 where GCD(x, y) is the Greatest Common Divisor of x and y.\n \nExample 1:\n\nInput: nums = [6,4,3,2,7,6,2]\nOutput: [12,7,6]\nExplanation: \n- (6, 4) are non-coprime with LCM(6, 4) = 12. Now, nums = [12,3,2,7,6,2].\n- (12, 3) are non-coprime with LCM(12, 3) = 12. Now, nums = [12,2,7,6,2].\n- (12, 2) are non-coprime with LCM(12, 2) = 12. Now, nums = [12,7,6,2].\n- (6, 2) are non-coprime with LCM(6, 2) = 6. Now, nums = [12,7,6].\nThere are no more adjacent non-coprime numbers in nums.\nThus, the final modified array is [12,7,6].\nNote that there are other ways to obtain the same resultant array.\n\nExample 2:\n\nInput: nums = [2,2,1,1,3,3,3]\nOutput: [2,1,1,3]\nExplanation: \n- (3, 3) are non-coprime with LCM(3, 3) = 3. Now, nums = [2,2,1,1,3,3].\n- (3, 3) are non-coprime with LCM(3, 3) = 3. Now, nums = [2,2,1,1,3].\n- (2, 2) are non-coprime with LCM(2, 2) = 2. Now, nums = [2,1,1,3].\nThere are no more adjacent non-coprime numbers in nums.\nThus, the final modified array is [2,1,1,3].\nNote that there are other ways to obtain the same resultant array.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 105\nThe test cases are generated such that the values in the final array are less than or equal to 108.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 6, 8, 10, 12]) == [120]\n assert candidate(nums = [100000, 100000, 100000, 100000]) == [100000]\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 = [2, 2, 1, 1, 3, 3, 3]) == [2, 1, 1, 3]\n assert candidate(nums = [9, 27, 81, 243, 729]) == [729]\n assert candidate(nums = [42, 56, 70, 84, 98]) == [5880]\n assert candidate(nums = [7, 3, 5, 2, 8, 6]) == [7, 3, 5, 24]\n assert candidate(nums = [9, 3, 6, 12, 24, 48]) == [144]\n assert candidate(nums = [100, 200, 300, 400, 500]) == [6000]\n assert candidate(nums = [7, 11, 13, 17, 19]) == [7, 11, 13, 17, 19]\n assert candidate(nums = [7, 3, 5, 2, 11]) == [7, 3, 5, 2, 11]\n assert candidate(nums = [5, 10, 15, 20, 25]) == [300]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [9]\n assert candidate(nums = [5, 10, 15, 20]) == [60]\n assert candidate(nums = [60, 45, 30, 15, 5]) == [180]\n assert candidate(nums = [6, 4, 3, 2, 7, 6, 2]) == [12, 7, 6]\n assert candidate(nums = [8, 12, 18, 24, 30]) == [360]\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16]) == [1680]\n assert candidate(nums = [2, 3, 5, 6, 9, 15, 20, 30, 45]) == [180]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == [17640]\n assert candidate(nums = [225, 315, 405, 15, 21, 27, 33, 39, 45]) == [2027025]\n assert candidate(nums = [31, 32, 34, 38, 44, 46, 52, 58, 62, 68]) == [30561598496]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125]) == [100000]\n assert candidate(nums = [9, 3, 27, 81, 243, 729, 2187]) == [2187]\n assert candidate(nums = [9, 15, 18, 24, 30, 36, 45]) == [360]\n assert candidate(nums = [210, 154, 110, 77, 49, 35, 21, 7]) == [16170]\n assert candidate(nums = [360, 420, 480, 12, 15, 18, 21, 24, 27]) == [30240]\n assert candidate(nums = [25, 15, 10, 20, 12, 30, 18]) == [900]\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [1024]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == [2522520]\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]\n assert candidate(nums = [9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == [1081080]\n assert candidate(nums = [14, 21, 35, 56, 98, 112]) == [11760]\n assert candidate(nums = [72, 48, 32, 16, 8, 4, 2]) == [288]\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [720720]\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40]) == [4200]\n assert candidate(nums = [525, 630, 735, 15, 21, 27, 33, 39, 45]) == [9459450]\n assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60]) == [15120]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49]) == [2940]\n assert candidate(nums = [21, 28, 35, 42, 49, 56, 63, 70, 77, 84]) == [194040]\n assert candidate(nums = [204, 260, 312, 13, 17, 21, 23, 29, 31]) == [185640, 23, 29, 31]\n assert candidate(nums = [45, 63, 81, 99, 117, 135, 153, 171, 189, 207]) == [3011753745]\n assert candidate(nums = [18, 24, 30, 12, 15, 20, 25, 35, 40]) == [12600]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [12600]\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130]) == [32760]\n assert candidate(nums = [15, 10, 20, 25, 30, 35, 40, 45, 50]) == [12600]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]\n assert candidate(nums = [1000, 1250, 1500, 1750, 2000, 2250, 2500]) == [630000]\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500]) == [126000]\n assert candidate(nums = [9, 15, 21, 27, 33, 39, 45, 51, 57, 63]) == [43648605]\n assert candidate(nums = [256, 192, 128, 64, 32, 16, 8, 4, 2]) == [768]\n assert candidate(nums = [110, 154, 198, 11, 14, 18, 22, 26, 30]) == [90090]\n assert candidate(nums = [123456, 987654, 111111, 222222, 333333, 444444, 555555]) == [11289971323350720]\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == [32768]\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [72747675]\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95]) == [72747675]\n assert candidate(nums = [210, 273, 330, 21, 27, 33, 39, 45, 51]) == [4594590]\n assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90, 99]) == [249480]\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == [3963960]\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500]) == [126000]\n assert candidate(nums = [84, 140, 196, 252, 308, 364, 420, 476, 532, 588, 644]) == [9369900540]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == [17640]\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [138600]\n assert candidate(nums = [12, 15, 20, 25, 30, 35]) == [2100]\n assert candidate(nums = [495, 595, 693, 11, 13, 17, 19, 23, 29]) == [58905, 13, 17, 19, 23, 29]\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [1024]\n assert candidate(nums = [100, 25, 50, 20, 40, 80, 160]) == [800]\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [720720]\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [138600]\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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == [254520]\n assert candidate(nums = [100, 50, 25, 125, 200, 80]) == [2000]\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == [27720]\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890]) == [24044013243300726813942720]\n assert candidate(nums = [8, 4, 2, 1, 2, 4, 8, 16, 32, 64]) == [8, 1, 64]\n assert candidate(nums = [21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == [2522520]\n assert candidate(nums = [25, 45, 65, 85, 105, 125]) == [1740375]\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]\n assert candidate(nums = [63, 77, 91, 14, 18, 22, 26, 30, 34]) == [1531530]\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [210, 105, 35, 10, 5, 7, 14, 28, 56]) == [840]\n assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560]) == [2560]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [25200]\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == [59049]\n assert candidate(nums = [98, 49, 21, 14, 7, 3, 1]) == [294, 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, 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]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == [3045900000]\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 = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == [2162160]\n assert candidate(nums = [100, 75, 150, 25, 50, 125, 200]) == [3000]\n assert candidate(nums = [45, 90, 135, 180, 225, 270, 315, 360, 405, 450, 495, 540, 585, 630, 675, 720, 765, 810, 855, 900]) == [10475665200]\n assert candidate(nums = [121, 143, 169, 11, 13, 17, 19, 23, 29]) == [20449, 17, 19, 23, 29]\n assert candidate(nums = [210, 330, 450, 570, 690, 810, 930, 1050, 1170]) == [54920215350]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [5040]\n assert candidate(nums = [98, 42, 56, 28, 14, 7, 1]) == [1176, 1]\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [18, 27, 36, 45, 54, 63]) == [3780]\n assert candidate(nums = [45, 90, 135, 270, 540, 1080, 2160]) == [2160]\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240]) == [10240]\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250]) == [63000]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700]) == [42000]\n assert candidate(nums = [20, 30, 40, 50, 60, 70, 80, 90, 100]) == [25200]\n assert candidate(nums = [231, 105, 63, 21, 7, 1]) == [3465, 1]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == [7560]\n assert candidate(nums = [720, 360, 180, 90, 45, 22, 11]) == [7920]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1163962800]\n assert candidate(nums = [49, 42, 35, 28, 21, 14, 7]) == [2940]\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109]\n assert candidate(nums = [9, 15, 45, 30, 18, 60, 20]) == [180]\n assert candidate(nums = [42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182, 196]) == [5045040]\n assert candidate(nums = [12345, 67890, 11111, 22222, 33333, 44444, 55555]) == [1241620250340]\n assert candidate(nums = [6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == [1081080]\n assert candidate(nums = [42, 56, 98, 14, 28, 49, 7, 35]) == [5880]\n assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60, 66]) == [166320]\n assert candidate(nums = [24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240]) == [2793510720]\n assert candidate(nums = [105, 135, 165, 15, 25, 35, 45, 55, 65]) == [675675]\n assert candidate(nums = [77, 91, 143, 169, 221, 287, 323, 391, 437]) == [3963616657]\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570, 600]) == [6983776800]\n assert candidate(nums = [100, 75, 50, 25, 10, 5, 1]) == [300, 1]\n assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1163962800]\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120]) == [5120]\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1024, 1]\n assert candidate(nums = [9, 81, 729, 6561, 59049, 531441]) == [531441]\n assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60, 66]) == [166320]\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == [1536]\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == [59049]\n assert candidate(nums = [18, 24, 30, 42, 54, 66, 78, 90, 102, 114]) == [349188840]\n assert candidate(nums = [1000, 1500, 2000, 2500, 3000]) == [30000]\n assert candidate(nums = [144, 180, 216, 12, 15, 18, 21, 24, 27]) == [15120]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 15625]) == [500000]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [252000]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().replaceNonCoprimes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List replaceNonCoprimes(int[] nums) {", "container": "Solution", "callable": "replaceNonCoprimes", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2200, "task_id": "find-all-k-distant-indices-in-an-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums and two integers key and k. A k-distant index is an index i of nums for which there exists at least one index j such that |i - j| <= k and nums[j] == key.\nReturn a list of all k-distant indices sorted in increasing order.\n \nExample 1:\n\nInput: nums = [3,4,9,1,3,9,5], key = 9, k = 1\nOutput: [1,2,3,4,5,6]\nExplanation: Here, nums[2] == key and nums[5] == key.\n- For index 0, |0 - 2| > k and |0 - 5| > k, so there is no j where |0 - j| <= k and nums[j] == key. Thus, 0 is not a k-distant index.\n- For index 1, |1 - 2| <= k and nums[2] == key, so 1 is a k-distant index.\n- For index 2, |2 - 2| <= k and nums[2] == key, so 2 is a k-distant index.\n- For index 3, |3 - 2| <= k and nums[2] == key, so 3 is a k-distant index.\n- For index 4, |4 - 5| <= k and nums[5] == key, so 4 is a k-distant index.\n- For index 5, |5 - 5| <= k and nums[5] == key, so 5 is a k-distant index.\n- For index 6, |6 - 5| <= k and nums[5] == key, so 6 is a k-distant index.\nThus, we return [1,2,3,4,5,6] which is sorted in increasing order. \n\nExample 2:\n\nInput: nums = [2,2,2,2,2], key = 2, k = 2\nOutput: [0,1,2,3,4]\nExplanation: For all indices i in nums, there exists some index j such that |i - j| <= k and nums[j] == key, so every index is a k-distant index. \nHence, we return [0,1,2,3,4].\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 1000\nkey is an integer from the array nums.\n1 <= k <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 1, 4, 1, 5],key = 5,k = 2) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1],key = 1,k = 3) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 30, 40, 50],key = 40,k = 0) == [3]\n assert candidate(nums = [1, 3, 5, 7, 9],key = 3,k = 2) == [0, 1, 2, 3]\n assert candidate(nums = [1, 3, 5, 7, 9],key = 5,k = 0) == [2]\n assert candidate(nums = [1, 2, 3, 4, 5],key = 3,k = 0) == [2]\n assert candidate(nums = [5, 5, 5, 5, 5, 5],key = 5,k = 3) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 20],key = 20,k = 2) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5],key = 1,k = 2) == [0, 1, 2]\n assert candidate(nums = [2, 2, 2, 2, 2],key = 2,k = 2) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5],key = 5,k = 2) == [2, 3, 4]\n assert candidate(nums = [10, 20, 30, 40, 50],key = 30,k = 2) == [0, 1, 2, 3, 4]\n assert candidate(nums = [5, 1, 5, 1, 5],key = 5,k = 1) == [0, 1, 2, 3, 4]\n assert candidate(nums = [3, 4, 9, 1, 3, 9, 5],key = 9,k = 1) == [1, 2, 3, 4, 5, 6]\n assert candidate(nums = [5, 4, 3, 2, 1],key = 1,k = 1) == [3, 4]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],key = 60,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],key = 50,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = [10, 20, 30, 40, 50, 20, 30, 40, 50],key = 20,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],key = 5,k = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],key = 996,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 5,k = 2) == [2, 3, 4, 5, 6]\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4],key = 4,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],key = 11,k = 4) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],key = 7,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],key = 1,k = 3) == [5, 6, 7, 8]\n assert candidate(nums = [7, 3, 4, 7, 1, 7, 5, 7, 3, 7],key = 7,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],key = 0,k = 1) == [8, 9]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],key = 16,k = 4) == [3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],key = 500,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],key = 3,k = 4) == [3, 4, 5, 6, 7, 8, 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],key = 7,k = 2) == [10, 11, 12, 13, 14, 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],key = 5,k = 2) == [6, 7, 8, 9, 10, 11]\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9],key = 3,k = 0) == [4]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],key = 10,k = 2) == [2, 3, 4, 5, 6]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],key = 13,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 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],key = 7,k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],key = 5,k = 2) == [2, 3, 4, 5, 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],key = 10,k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],key = 6,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],key = 7,k = 5) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10],key = 30,k = 1) == [1, 2, 3, 5, 6, 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],key = 3,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],key = 7,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],key = 15,k = 2) == [5, 6, 7, 8, 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],key = 100,k = 5) == [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],key = 500,k = 2) == [2, 3, 4, 5, 6]\n assert candidate(nums = [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000],key = 999,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],key = 5,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 5,k = 2) == [2, 3, 4, 5, 6]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],key = 3,k = 1) == [3, 4, 5, 6]\n assert candidate(nums = [7, 1, 5, 3, 6, 2, 4, 8, 9, 7, 5, 3, 1],key = 7,k = 3) == [0, 1, 2, 3, 6, 7, 8, 9, 10, 11, 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],key = 10,k = 5) == [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\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],key = 9,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],key = 80,k = 5) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],key = 50,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],key = 5,k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],key = 21,k = 0) == [2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 10,k = 4) == [5, 6, 7, 8, 9]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],key = 49,k = 5) == [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],key = 10,k = 3) == [6, 7, 8, 9, 10, 11, 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],key = 3,k = 1) == [3, 4, 5, 6]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],key = 25,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],key = 60,k = 1) == [4, 5, 6]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],key = 5,k = 3) == [1, 2, 3, 4, 5, 6, 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],key = 1,k = 3) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],key = 30,k = 1) == [1, 2, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],key = 1,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],key = 8,k = 3) == [4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],key = 3,k = 2) == [2, 3, 4, 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],key = 10,k = 5) == [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [7, 1, 5, 3, 9, 5, 7, 5, 2, 5],key = 5,k = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],key = 7,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],key = 5,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = [100, 200, 300, 400, 500, 300, 200, 100],key = 300,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],key = 13,k = 4) == [2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],key = 3,k = 3) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],key = 15,k = 5) == [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, 11, 12, 13, 14, 15],key = 8,k = 5) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],key = 50,k = 4) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],key = 500,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19],key = 7,k = 2) == [0, 1, 2, 3, 4]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],key = 13,k = 2) == [3, 4, 5, 6, 7]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],key = 5,k = 2) == [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],key = 10,k = 4) == [5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],key = 0,k = 3) == [2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],key = 5,k = 1) == [3, 4, 5, 7, 8, 9, 10]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],key = 3,k = 2) == [2, 3, 4, 5, 6, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 5,k = 1) == [3, 4, 5]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],key = 5,k = 3) == [2, 3, 4, 5, 6, 7, 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],key = 5,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],key = 5,k = 2) == [2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 5,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],key = 15,k = 6) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],key = 5,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n assert candidate(nums = [1, 3, 2, 3, 1, 3, 2, 3, 1, 3],key = 3,k = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],key = 5,k = 2) == [2, 3, 4, 5, 6]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],key = 7,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 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],key = 15,k = 5) == [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],key = 9,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],key = 90,k = 4) == [4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],key = 15,k = 3) == [4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],key = 1,k = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],key = 7,k = 3) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],key = 21,k = 6) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],key = 5,k = 2) == [2, 3, 4, 5, 6, 10, 11, 12, 13, 14]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],key = 19,k = 7) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],key = 3,k = 3) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n"}, "metadata": {"canonical_parameter_names": ["nums", "key", "k"], "leetcode_dataset_entry_point": "Solution().findKDistantIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List findKDistantIndices(int[] nums, int key, int k) {", "container": "Solution", "callable": "findKDistantIndices", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "key", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2201, "task_id": "count-artifacts-that-can-be-extracted", "difficulty": "Medium", "problem_description": "There is an n x n 0-indexed grid with some artifacts buried in it. You are given the integer n and a 0-indexed 2D integer array artifacts describing the positions of the rectangular artifacts where artifacts[i] = [r1i, c1i, r2i, c2i] denotes that the ith artifact is buried in the subgrid where:\n\n(r1i, c1i) is the coordinate of the top-left cell of the ith artifact and\n(r2i, c2i) is the coordinate of the bottom-right cell of the ith artifact.\n\nYou will excavate some cells of the grid and remove all the mud from them. If the cell has a part of an artifact buried underneath, it will be uncovered. If all the parts of an artifact are uncovered, you can extract it.\nGiven a 0-indexed 2D integer array dig where dig[i] = [ri, ci] indicates that you will excavate the cell (ri, ci), return the number of artifacts that you can extract.\nThe test cases are generated such that:\n\nNo two artifacts overlap.\nEach artifact only covers at most 4 cells.\nThe entries of dig are unique.\n\n \nExample 1:\n\n\nInput: n = 2, artifacts = [[0,0,0,0],[0,1,1,1]], dig = [[0,0],[0,1]]\nOutput: 1\nExplanation: \nThe different colors represent different artifacts. Excavated cells are labeled with a 'D' in the grid.\nThere is 1 artifact that can be extracted, namely the red artifact.\nThe blue artifact has one part in cell (1,1) which remains uncovered, so we cannot extract it.\nThus, we return 1.\n\nExample 2:\n\n\nInput: n = 2, artifacts = [[0,0,0,0],[0,1,1,1]], dig = [[0,0],[0,1],[1,1]]\nOutput: 2\nExplanation: Both the red and blue artifacts have all parts uncovered (labeled with a 'D') and can be extracted, so we return 2. \n\n \nConstraints:\n\n1 <= n <= 1000\n1 <= artifacts.length, dig.length <= min(n2, 105)\nartifacts[i].length == 4\ndig[i].length == 2\n0 <= r1i, c1i, r2i, c2i, ri, ci <= n - 1\nr1i <= r2i\nc1i <= c2i\nNo two artifacts will overlap.\nThe number of cells covered by an artifact is at most 4.\nThe entries of dig are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,artifacts = [[0, 0, 0, 0], [1, 1, 2, 2], [3, 3, 3, 3]],dig = [[0, 0], [1, 1], [2, 2], [3, 3]]) == 2\n assert candidate(n = 5,artifacts = [[0, 0, 0, 1], [1, 1, 2, 2], [3, 3, 4, 4]],dig = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4]]) == 3\n assert candidate(n = 5,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 4, 4]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4]]) == 3\n assert candidate(n = 3,artifacts = [[0, 0, 0, 1], [1, 0, 1, 1], [2, 0, 2, 1]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]) == 3\n assert candidate(n = 3,artifacts = [[0, 0, 0, 1], [1, 1, 2, 2]],dig = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 1], [2, 2]]) == 2\n assert candidate(n = 3,artifacts = [[0, 0, 0, 1], [1, 1, 2, 2]],dig = [[0, 0], [0, 1], [1, 1], [2, 2]]) == 1\n assert candidate(n = 4,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]]) == 2\n assert candidate(n = 3,artifacts = [[0, 0, 1, 1], [1, 2, 2, 2]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 2]]) == 2\n assert candidate(n = 4,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],dig = [[0, 0], [1, 1], [2, 2], [3, 3]]) == 4\n assert candidate(n = 5,artifacts = [[0, 0, 0, 1], [1, 1, 1, 2], [2, 2, 2, 3], [3, 3, 3, 4]],dig = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 2], [2, 3], [3, 3], [3, 4]]) == 4\n assert candidate(n = 3,artifacts = [[0, 0, 1, 1], [1, 1, 2, 2]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]) == 1\n assert candidate(n = 3,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2]],dig = [[0, 0], [1, 1], [2, 2]]) == 3\n assert candidate(n = 2,artifacts = [[0, 0, 0, 0], [0, 1, 1, 1]],dig = [[0, 0], [0, 1], [1, 1]]) == 2\n assert candidate(n = 2,artifacts = [[0, 0, 0, 0], [0, 1, 1, 1]],dig = [[0, 0], [0, 1]]) == 1\n assert candidate(n = 3,artifacts = [[0, 0, 0, 1], [1, 1, 1, 2]],dig = [[0, 0], [0, 1], [1, 1]]) == 1\n assert candidate(n = 7,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 6, 6], [0, 2, 1, 3], [2, 4, 3, 6], [4, 0, 5, 2]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 0], [4, 1], [4, 2], [5, 0], [5, 1], [5, 2], [6, 6]]) == 4\n assert candidate(n = 8,artifacts = [[0, 0, 1, 2], [2, 3, 3, 4], [4, 5, 5, 6], [6, 7, 7, 7]],dig = [[0, 0], [0, 1], [0, 2], [2, 3], [2, 4], [3, 3], [3, 4], [4, 5], [4, 6], [5, 5], [5, 6], [6, 7], [7, 7]]) == 3\n assert candidate(n = 10,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 8, 8], [7, 7, 9, 9]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6], [6, 7], [6, 8], [7, 6], [7, 7], [7, 8], [8, 6], [8, 7], [8, 8], [7, 7], [7, 8], [9, 7], [9, 8], [9, 9]]) == 3\n assert candidate(n = 9,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 8, 8]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [6, 6], [6, 7], [6, 8], [7, 6], [7, 7], [7, 8], [8, 6], [8, 7], [8, 8]]) == 2\n assert candidate(n = 10,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 9, 9]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9]]) == 5\n assert candidate(n = 7,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 4, 4], [5, 5, 6, 6]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == 1\n assert candidate(n = 8,artifacts = [[0, 0, 0, 1], [1, 0, 1, 1], [2, 0, 2, 1], [3, 0, 3, 1], [4, 0, 4, 1], [5, 0, 5, 1], [6, 0, 6, 1], [7, 0, 7, 1]],dig = [[0, 0], [1, 1], [2, 0], [3, 1], [4, 0], [5, 1], [6, 0], [7, 1], [0, 1], [1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1], [7, 0]]) == 8\n assert candidate(n = 20,artifacts = [[0, 0, 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, 14, 15, 15], [16, 16, 17, 17], [18, 18, 19, 19]],dig = [[0, 0], [0, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11], [12, 12], [12, 13], [13, 12], [13, 13], [14, 14], [14, 15], [15, 14], [15, 15], [16, 16], [16, 17], [17, 16], [17, 17], [18, 18], [18, 19], [19, 18], [19, 19]]) == 10\n assert candidate(n = 15,artifacts = [[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, 14, 14]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11], [12, 12], [12, 13], [13, 12], [13, 13], [14, 14]]) == 8\n assert candidate(n = 15,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 8, 8], [9, 9, 11, 11], [12, 12, 14, 14]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6], [6, 7], [6, 8], [7, 6], [7, 7], [7, 8], [8, 6], [8, 7], [8, 8], [9, 9], [9, 10], [9, 11], [10, 9], [10, 10], [10, 11], [11, 9], [11, 10], [11, 11], [12, 12], [12, 13], [12, 14], [13, 12], [13, 13], [13, 14], [14, 12], [14, 13], [14, 14]]) == 5\n assert candidate(n = 20,artifacts = [[0, 0, 0, 0], [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, 11, 11, 11], [12, 12, 12, 12], [13, 13, 13, 13], [14, 14, 14, 14], [15, 15, 15, 15], [16, 16, 16, 16], [17, 17, 17, 17], [18, 18, 18, 18], [19, 19, 19, 19]],dig = [[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]]) == 20\n assert candidate(n = 500,artifacts = [[0, 0, 1, 1], [498, 498, 499, 499]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [498, 498], [498, 499], [499, 498], [499, 499]]) == 2\n assert candidate(n = 7,artifacts = [[0, 0, 0, 3], [1, 1, 2, 2], [3, 3, 4, 4], [5, 5, 6, 6]],dig = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6]]) == 4\n assert candidate(n = 7,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 6, 6]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6]]) == 4\n assert candidate(n = 15,artifacts = [[0, 0, 0, 3], [1, 1, 1, 4], [2, 2, 2, 5], [3, 3, 3, 6], [4, 4, 4, 7], [5, 5, 5, 8], [6, 6, 6, 9], [7, 7, 7, 10], [8, 8, 8, 11], [9, 9, 9, 12]],dig = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [1, 4], [2, 2], [2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [5, 8], [6, 6], [6, 7], [6, 8], [6, 9], [7, 7], [7, 8], [7, 9], [7, 10], [8, 8], [8, 9], [8, 10], [8, 11], [9, 9], [9, 10], [9, 11], [9, 12]]) == 10\n assert candidate(n = 6,artifacts = [[0, 0, 2, 1], [3, 2, 4, 3], [1, 4, 2, 5], [4, 0, 5, 1]],dig = [[0, 0], [0, 1], [1, 4], [1, 5], [2, 0], [2, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [5, 0], [5, 1]]) == 2\n assert candidate(n = 1000,artifacts = [[0, 0, 0, 0], [999, 999, 999, 999]],dig = [[0, 0], [999, 999]]) == 2\n assert candidate(n = 12,artifacts = [[0, 0, 0, 2], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 9, 9], [10, 10, 11, 11]],dig = [[0, 0], [0, 1], [0, 2], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11]]) == 6\n assert candidate(n = 5,artifacts = [[0, 0, 1, 2], [2, 0, 3, 1], [4, 2, 4, 4]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [3, 0], [3, 1], [4, 2], [4, 3], [4, 4]]) == 3\n assert candidate(n = 100,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [98, 98, 98, 98], [99, 99, 99, 99]],dig = [[0, 0], [1, 1], [98, 98], [99, 99]]) == 4\n assert candidate(n = 20,artifacts = [[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]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11], [12, 12], [12, 13], [13, 12], [13, 13], [14, 14], [14, 15], [15, 14], [15, 15], [16, 16], [16, 17], [17, 16], [17, 17], [18, 18], [18, 19], [19, 18], [19, 19]]) == 10\n assert candidate(n = 1000,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [998, 998, 999, 999]],dig = [[0, 0], [1, 1], [998, 998], [999, 999]]) == 2\n assert candidate(n = 6,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 6\n assert candidate(n = 10,artifacts = [[0, 0, 2, 1], [3, 3, 5, 4], [6, 6, 8, 7]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1], [3, 3], [3, 4], [4, 3], [4, 4], [5, 3], [5, 4], [6, 6], [6, 7], [7, 6], [7, 7], [8, 6], [8, 7]]) == 3\n assert candidate(n = 8,artifacts = [[0, 0, 0, 1], [1, 2, 2, 3], [3, 4, 4, 5], [5, 6, 6, 7]],dig = [[0, 0], [0, 1], [1, 2], [1, 3], [2, 2], [2, 3], [3, 4], [3, 5], [4, 4], [4, 5], [5, 6], [5, 7], [6, 6], [6, 7]]) == 4\n assert candidate(n = 10,artifacts = [[0, 0, 0, 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, 9]],dig = [[0, 0], [0, 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]]) == 10\n assert candidate(n = 12,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 9, 9], [10, 10, 11, 11]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11]]) == 6\n assert candidate(n = 7,artifacts = [[0, 0, 1, 1], [2, 2, 2, 3], [3, 3, 4, 4], [5, 5, 6, 6]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6]]) == 4\n assert candidate(n = 10,artifacts = [[0, 0, 2, 2], [3, 3, 4, 4], [5, 5, 6, 6], [7, 7, 8, 8], [1, 1, 2, 2], [3, 5, 4, 6], [7, 9, 8, 9]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [7, 8], [7, 9], [8, 7], [8, 8], [8, 9], [3, 5], [3, 6], [4, 5], [4, 6]]) == 7\n assert candidate(n = 8,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1]]) == 4\n assert candidate(n = 5,artifacts = [[0, 0, 1, 1], [1, 2, 2, 3], [3, 4, 3, 4]],dig = [[0, 0], [0, 1], [1, 2], [1, 3], [2, 2], [2, 3], [3, 4]]) == 2\n assert candidate(n = 9,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 8, 8], [0, 2, 1, 3], [2, 4, 3, 6], [4, 0, 5, 2], [6, 4, 7, 6]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 0], [4, 1], [4, 2], [5, 0], [5, 1], [5, 2], [6, 4], [6, 5], [6, 6], [7, 4], [7, 5], [7, 6], [8, 8]]) == 5\n assert candidate(n = 20,artifacts = [[0, 0, 3, 3], [4, 4, 7, 7], [8, 8, 11, 11], [12, 12, 15, 15], [16, 16, 19, 19]],dig = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3], [3, 0], [3, 1], [3, 2], [3, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 4], [5, 5], [5, 6], [5, 7], [6, 4], [6, 5], [6, 6], [6, 7], [7, 4], [7, 5], [7, 6], [7, 7], [8, 8], [8, 9], [8, 10], [8, 11], [9, 8], [9, 9], [9, 10], [9, 11], [10, 8], [10, 9], [10, 10], [10, 11], [11, 8], [11, 9], [11, 10], [11, 11], [12, 12], [12, 13], [12, 14], [12, 15], [13, 12], [13, 13], [13, 14], [13, 15], [14, 12], [14, 13], [14, 14], [14, 15], [15, 12], [15, 13], [15, 14], [15, 15], [16, 16], [16, 17], [16, 18], [16, 19], [17, 16], [17, 17], [17, 18], [17, 19], [18, 16], [18, 17], [18, 18], [18, 19], [19, 16], [19, 17], [19, 18], [19, 19]]) == 5\n assert candidate(n = 10,artifacts = [[0, 0, 1, 1], [3, 3, 4, 4], [6, 6, 7, 7], [9, 9, 9, 9]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [3, 3], [3, 4], [4, 3], [4, 4], [6, 6], [6, 7], [7, 6], [7, 7], [9, 9]]) == 4\n assert candidate(n = 6,artifacts = [[0, 0, 0, 1], [1, 1, 1, 2], [2, 2, 2, 3], [3, 3, 3, 4], [4, 4, 4, 5], [5, 5, 5, 5]],dig = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 2], [2, 3], [3, 3], [3, 4], [4, 4], [4, 5], [5, 5]]) == 6\n assert candidate(n = 1000,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 5\n assert candidate(n = 10,artifacts = [[0, 0, 1, 1], [3, 3, 5, 5], [7, 7, 9, 9]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [4, 4], [5, 3], [5, 4], [5, 5], [7, 7], [7, 8], [7, 9], [8, 7], [8, 8], [8, 9], [9, 7], [9, 8], [9, 9]]) == 2\n assert candidate(n = 10,artifacts = [[0, 0, 0, 3], [1, 1, 2, 2], [3, 3, 3, 3]],dig = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3]]) == 3\n assert candidate(n = 10,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 8, 8], [9, 9, 9, 9]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6], [6, 7], [6, 8], [7, 6], [7, 7], [7, 8], [8, 6], [8, 7], [8, 8], [9, 9]]) == 4\n assert candidate(n = 8,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 7, 7]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7]]) == 3\n assert candidate(n = 8,artifacts = [[0, 0, 0, 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], [0, 2, 1, 3], [2, 4, 3, 5], [4, 6, 5, 7]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [1, 3], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [3, 5], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6], [5, 7], [6, 6], [6, 7]]) == 7\n assert candidate(n = 5,artifacts = [[0, 0, 2, 2], [1, 1, 3, 3]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2]]) == 1\n assert candidate(n = 15,artifacts = [[1, 1, 2, 2], [3, 3, 4, 4], [5, 5, 6, 6], [7, 7, 8, 8]],dig = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [7, 8], [8, 7], [8, 8]]) == 4\n assert candidate(n = 15,artifacts = [[0, 0, 0, 1], [1, 0, 1, 1], [2, 0, 2, 1], [3, 0, 3, 1], [4, 0, 4, 1], [5, 0, 5, 1], [6, 0, 6, 1], [7, 0, 7, 1], [8, 0, 8, 1], [9, 0, 9, 1], [10, 0, 10, 1], [11, 0, 11, 1], [12, 0, 12, 1], [13, 0, 13, 1], [14, 0, 14, 1]],dig = [[0, 0], [1, 1], [2, 0], [3, 1], [4, 0], [5, 1], [6, 0], [7, 1], [8, 0], [9, 1], [10, 0], [11, 1], [12, 0], [13, 1], [14, 0]]) == 0\n assert candidate(n = 9,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 8, 8]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8]]) == 5\n assert candidate(n = 10,artifacts = [[0, 0, 1, 1], [3, 3, 4, 4], [6, 6, 7, 7], [8, 8, 9, 9]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [3, 3], [3, 4], [4, 3], [4, 4], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9]]) == 4\n assert candidate(n = 10,artifacts = [[0, 0, 0, 1], [1, 0, 1, 1], [2, 0, 2, 1], [3, 0, 3, 1], [4, 0, 4, 1], [5, 0, 5, 1], [6, 0, 6, 1], [7, 0, 7, 1], [8, 0, 8, 1], [9, 0, 9, 1]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 1], [1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1], [7, 0], [8, 1], [9, 0]]) == 2\n assert candidate(n = 8,artifacts = [[0, 0, 0, 2], [1, 1, 1, 3], [2, 2, 2, 4], [3, 3, 3, 5], [4, 4, 4, 6], [5, 5, 5, 7], [6, 6, 6, 7]],dig = [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [1, 3], [2, 2], [2, 3], [2, 4], [3, 3], [3, 4], [3, 5], [4, 4], [4, 5], [4, 6], [5, 5], [5, 6], [5, 7], [6, 6], [6, 7]]) == 7\n assert candidate(n = 10,artifacts = [[0, 0, 0, 0], [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]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 10\n assert candidate(n = 9,artifacts = [[0, 0, 0, 0], [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]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 9\n assert candidate(n = 10,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 8, 8], [7, 7, 9, 9]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6], [6, 7], [6, 8], [7, 6], [7, 7], [7, 8], [8, 6], [8, 7], [8, 8], [7, 7], [9, 9]]) == 3\n"}, "metadata": {"canonical_parameter_names": ["n", "artifacts", "dig"], "leetcode_dataset_entry_point": "Solution().digArtifacts", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int digArtifacts(int n, int[][] artifacts, int[][] dig) {", "container": "Solution", "callable": "digArtifacts", "parameters": [{"name": "n", "type": "int"}, {"name": "artifacts", "type": "int[][]"}, {"name": "dig", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2202, "task_id": "maximize-the-topmost-element-after-k-moves", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums representing the contents of a pile, where nums[0] is the topmost element of the pile.\nIn one move, you can perform either of the following:\n\nIf the pile is not empty, remove the topmost element of the pile.\nIf there are one or more removed elements, add any one of them back onto the pile. This element becomes the new topmost element.\n\nYou are also given an integer k, which denotes the total number of moves to be made.\nReturn the maximum value of the topmost element of the pile possible after exactly k moves. In case it is not possible to obtain a non-empty pile after k moves, return -1.\n \nExample 1:\n\nInput: nums = [5,2,2,4,0,6], k = 4\nOutput: 5\nExplanation:\nOne of the ways we can end with 5 at the top of the pile after 4 moves is as follows:\n- Step 1: Remove the topmost element = 5. The pile becomes [2,2,4,0,6].\n- Step 2: Remove the topmost element = 2. The pile becomes [2,4,0,6].\n- Step 3: Remove the topmost element = 2. The pile becomes [4,0,6].\n- Step 4: Add 5 back onto the pile. The pile becomes [5,4,0,6].\nNote that this is not the only way to end with 5 at the top of the pile. It can be shown that 5 is the largest answer possible after 4 moves.\n\nExample 2:\n\nInput: nums = [2], k = 1\nOutput: -1\nExplanation: \nIn the first move, our only option is to pop the topmost element of the pile.\nSince it is not possible to obtain a non-empty pile after one move, we return -1.\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 = [7, 7, 7, 7, 7],k = 2) == 7\n assert candidate(nums = [9, 8, 7, 6, 5],k = 5) == 9\n assert candidate(nums = [10],k = 2) == 10\n assert candidate(nums = [8, 6, 4, 2, 0],k = 7) == 8\n assert candidate(nums = [7, 7, 7, 7, 7],k = 3) == 7\n assert candidate(nums = [1000000000],k = 0) == 1000000000\n assert candidate(nums = [5, 4, 3, 2, 1],k = 2) == 5\n assert candidate(nums = [1],k = 2) == 1\n assert candidate(nums = [1, 3, 5, 7, 9],k = 10) == 9\n assert candidate(nums = [3, 3, 3, 3, 3, 3],k = 1000000000) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 4\n assert candidate(nums = [2],k = 1) == -1\n assert candidate(nums = [9, 7, 5, 3, 1],k = 5) == 9\n assert candidate(nums = [10],k = 0) == 10\n assert candidate(nums = [1, 3, 5, 7, 9],k = 2) == 5\n assert candidate(nums = [9],k = 0) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(nums = [0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(nums = [1, 3, 5, 7, 9],k = 0) == 1\n assert candidate(nums = [1000000000],k = 1000000000) == 1000000000\n assert candidate(nums = [1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(nums = [5, 2, 2, 4, 0, 6],k = 4) == 5\n assert candidate(nums = [1, 2],k = 2) == 1\n assert candidate(nums = [3, 3, 3, 3, 3],k = 5) == 3\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 9) == 9\n assert candidate(nums = [1, 1, 1, 1, 1],k = 0) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 0) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 5) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 10\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 6\n assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],k = 9) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 15) == 19\n assert candidate(nums = [3, 7, 2, 8, 6, 4, 1, 9],k = 3) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 10\n assert candidate(nums = [5, 2, 9, 1, 5, 6, 7, 3, 4, 8],k = 15) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 19) == 10\n assert candidate(nums = [5, 2, 2, 4, 0, 6],k = 6) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 9\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 7) == 9\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10],k = 7) == 90\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 90\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 60\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 9) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 18) == 19\n assert candidate(nums = [1],k = 1000000000) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 8) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 90\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 2) == 1000000000\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 20) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 8\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 11) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 2) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 21) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 25) == 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 = 20) == 19\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 10) == 9\n assert candidate(nums = [5, 1, 3, 2, 8, 7],k = 3) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 7) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 10) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 9\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 10) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 11) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],k = 3) == 7\n assert candidate(nums = [5, 2, 9, 1, 5, 6],k = 3) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 8) == 45\n assert candidate(nums = [10, 20, 30, 40, 50],k = 3) == 40\n assert candidate(nums = [7, 3, 5, 4, 1, 9, 8, 6, 2],k = 6) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 60\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 8) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 1\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 100\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 10) == 7\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 999999) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 10\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 8) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 14) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 12) == 13\n assert candidate(nums = [1, 2, 3, 4, 5],k = 100) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 13) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 17\n assert candidate(nums = [7, 1, 5, 3, 6, 4],k = 3) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == 1\n assert candidate(nums = [3, 7, 2, 5, 8, 6, 1],k = 10) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 999999999) == 100\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 6\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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9],k = 100) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 19\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 9) == 100\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 7) == 9\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 10) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],k = 9) == 5\n assert candidate(nums = [5, 1, 3, 2, 8, 7],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],k = 18) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == 5\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 12) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2) == 30\n assert candidate(nums = [1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 19\n assert candidate(nums = [100, 90, 80, 70, 60],k = 6) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 4\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777],k = 4) == 1000000000\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 4) == 100\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 9) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 12) == 10\n assert candidate(nums = [5, 3, 1, 4, 9, 8],k = 5) == 8\n assert candidate(nums = [100, 200, 300, 400, 500],k = 2) == 300\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 11) == 9\n assert candidate(nums = [1, 3, 5, 7, 9],k = 5) == 7\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 9) == 2\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 15) == 100\n assert candidate(nums = [1, 2, 3, 4, 5],k = 0) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 7) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 9\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 9) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666],k = 10) == 1000000000\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9],k = 8) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 9\n assert candidate(nums = [5, 4, 3, 2, 1],k = 2) == 5\n assert candidate(nums = [50, 50, 50, 50, 50],k = 4) == 50\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == 5\n assert candidate(nums = [10, 20, 30, 40, 50],k = 1) == 20\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumTop", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumTop(int[] nums, int k) {", "container": "Solution", "callable": "maximumTop", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2203, "task_id": "minimum-weighted-subgraph-with-the-required-paths", "difficulty": "Hard", "problem_description": "You are given an integer n denoting the number of nodes of a weighted directed graph. The nodes are numbered from 0 to n - 1.\nYou are also given a 2D integer array edges where edges[i] = [fromi, toi, weighti] denotes that there exists a directed edge from fromi to toi with weight weighti.\nLastly, you are given three distinct integers src1, src2, and dest denoting three distinct nodes of the graph.\nReturn the minimum weight of a subgraph of the graph such that it is possible to reach dest from both src1 and src2 via a set of edges of this subgraph. In case such a subgraph does not exist, return -1.\nA subgraph is a graph whose vertices and edges are subsets of the original graph. The weight of a subgraph is the sum of weights of its constituent edges.\n \nExample 1:\n\n\nInput: n = 6, edges = [[0,2,2],[0,5,6],[1,0,3],[1,4,5],[2,1,1],[2,3,3],[2,3,4],[3,4,2],[4,5,1]], src1 = 0, src2 = 1, dest = 5\nOutput: 9\nExplanation:\nThe above figure represents the input graph.\nThe blue edges represent one of the subgraphs that yield the optimal answer.\nNote that the subgraph [[1,0,3],[0,5,6]] also yields the optimal answer. It is not possible to get a subgraph with less weight satisfying all the constraints.\n\nExample 2:\n\n\nInput: n = 3, edges = [[0,1,1],[2,1,1]], src1 = 0, src2 = 1, dest = 2\nOutput: -1\nExplanation:\nThe above figure represents the input graph.\nIt can be seen that there does not exist any path from node 1 to node 2, hence there are no subgraphs satisfying all the constraints.\n\n \nConstraints:\n\n3 <= n <= 105\n0 <= edges.length <= 105\nedges[i].length == 3\n0 <= fromi, toi, src1, src2, dest <= n - 1\nfromi != toi\nsrc1, src2, and dest are pairwise distinct.\n1 <= weight[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[0, 2, 2], [0, 5, 6], [1, 0, 3], [1, 4, 5], [2, 1, 1], [2, 3, 3], [2, 3, 4], [3, 4, 2], [4, 5, 1]],src1 = 0,src2 = 1,dest = 5) == 9\n assert candidate(n = 6,edges = [[1, 2, 2], [1, 3, 1], [2, 4, 5], [3, 4, 3], [4, 5, 2]],src1 = 1,src2 = 2,dest = 5) == 9\n assert candidate(n = 3,edges = [[0, 1, 1], [2, 1, 1]],src1 = 0,src2 = 1,dest = 2) == -1\n assert candidate(n = 5,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 0, 50]],src1 = 0,src2 = 2,dest = 4) == 100\n assert candidate(n = 4,edges = [[0, 1, 2], [0, 2, 2], [1, 3, 1], [2, 3, 1]],src1 = 0,src2 = 1,dest = 3) == 3\n assert candidate(n = 5,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 0, 5]],src1 = 0,src2 = 1,dest = 4) == 10\n assert candidate(n = 5,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 1], [1, 4, 2], [2, 3, 4], [2, 4, 3]],src1 = 0,src2 = 1,dest = 4) == 10\n assert candidate(n = 5,edges = [[0, 1, 10], [0, 2, 3], [1, 3, 2], [2, 1, 4], [2, 3, 8], [2, 4, 2]],src1 = 0,src2 = 2,dest = 3) == 9\n assert candidate(n = 4,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 1, 4]],src1 = 0,src2 = 2,dest = 3) == 6\n assert candidate(n = 5,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [2, 3, 1], [2, 4, 4]],src1 = 0,src2 = 2,dest = 3) == 4\n assert candidate(n = 4,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 1], [2, 3, 3]],src1 = 0,src2 = 1,dest = 3) == 3\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [1, 4, 2], [2, 5, 1], [2, 6, 2], [3, 6, 1], [4, 6, 2]],src1 = 0,src2 = 1,dest = 6) == 3\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]],src1 = 0,src2 = 6,dest = 11) == 66\n assert candidate(n = 10,edges = [[0, 1, 20], [0, 2, 30], [1, 3, 40], [1, 4, 50], [2, 4, 60], [2, 5, 70], [3, 6, 80], [3, 7, 90], [4, 7, 100], [4, 8, 110], [5, 8, 120], [5, 9, 130], [6, 9, 140], [7, 9, 150]],src1 = 0,src2 = 2,dest = 9) == 230\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 5], [4, 5, 6]],src1 = 0,src2 = 1,dest = 5) == 9\n assert candidate(n = 20,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, 0, 20], [0, 10, 1], [1, 11, 2], [2, 12, 3], [3, 13, 4], [4, 14, 5], [5, 15, 6], [6, 16, 7], [7, 17, 8], [8, 18, 9], [9, 19, 10], [10, 0, 11], [11, 1, 12], [12, 2, 13], [13, 3, 14], [14, 4, 15], [15, 5, 16], [16, 6, 17], [17, 7, 18], [18, 8, 19], [19, 9, 20]],src1 = 0,src2 = 2,dest = 19) == 55\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [3, 6, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 7, 12]],src1 = 0,src2 = 3,dest = 7) == 22\n assert candidate(n = 15,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 3], [1, 4, 1], [2, 3, 1], [2, 4, 5], [3, 5, 2], [4, 5, 3], [5, 6, 4], [6, 7, 1], [7, 8, 3], [8, 9, 2], [9, 10, 4], [10, 11, 5], [11, 12, 6], [12, 13, 7], [13, 14, 8]],src1 = 0,src2 = 1,dest = 14) == 46\n assert candidate(n = 9,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, 8, 9], [6, 7, 10]],src1 = 0,src2 = 2,dest = 8) == 16\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [3, 6, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 7, 12], [7, 8, 13], [8, 9, 14], [8, 10, 15], [9, 11, 16], [10, 11, 17]],src1 = 0,src2 = 5,dest = 11) == 65\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], [0, 5, 1], [1, 6, 2], [2, 7, 3], [3, 8, 4], [4, 9, 5], [5, 10, 6], [6, 11, 7], [7, 0, 8], [8, 1, 9], [9, 2, 10], [10, 3, 11], [11, 4, 12]],src1 = 0,src2 = 2,dest = 11) == 21\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [3, 6, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 7, 12], [7, 8, 13]],src1 = 0,src2 = 4,dest = 8) == 38\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 2], [2, 4, 3], [3, 5, 1], [3, 6, 2], [4, 5, 2], [4, 6, 3], [5, 7, 1], [6, 7, 2]],src1 = 0,src2 = 2,dest = 7) == 6\n assert candidate(n = 7,edges = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 8], [2, 3, 4], [2, 4, 9], [3, 4, 1], [3, 5, 6], [4, 5, 7], [4, 6, 10], [5, 6, 5]],src1 = 0,src2 = 2,dest = 6) == 20\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 3, 1], [2, 5, 7], [3, 6, 3], [4, 6, 2], [5, 6, 6]],src1 = 0,src2 = 2,dest = 6) == 7\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], [9, 0, 10], [0, 9, 15], [1, 8, 14], [2, 7, 13], [3, 6, 12], [4, 5, 11]],src1 = 0,src2 = 1,dest = 9) == 24\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 3], [1, 4, 5], [2, 4, 1], [2, 5, 6], [3, 6, 7], [4, 6, 8], [4, 7, 9], [5, 7, 3], [6, 7, 10]],src1 = 0,src2 = 1,dest = 7) == 16\n assert candidate(n = 12,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, 0, 13], [0, 5, 1], [1, 6, 2], [2, 7, 3], [3, 8, 4], [4, 9, 5], [5, 10, 6], [6, 11, 7], [7, 0, 8], [8, 1, 9], [9, 2, 10], [10, 3, 11], [11, 4, 12]],src1 = 0,src2 = 6,dest = 11) == 11\n assert candidate(n = 8,edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 0, 40], [0, 3, 2], [1, 4, 3], [2, 5, 4], [3, 6, 5], [4, 7, 6]],src1 = 0,src2 = 1,dest = 7) == 14\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [0, 3, 5], [1, 4, 6], [2, 5, 7], [3, 6, 8], [4, 7, 9], [5, 8, 10], [6, 9, 11]],src1 = 0,src2 = 2,dest = 9) == 25\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], [5, 7, 9], [6, 7, 10]],src1 = 0,src2 = 1,dest = 7) == 11\n assert candidate(n = 8,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [1, 4, 40], [2, 5, 50], [2, 6, 60], [3, 7, 70], [4, 7, 80], [5, 7, 90], [6, 7, 100]],src1 = 0,src2 = 2,dest = 7) == 160\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [4, 5, 8], [5, 6, 9]],src1 = 0,src2 = 1,dest = 6) == 20\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], [9, 0, 10]],src1 = 0,src2 = 5,dest = 9) == 45\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 5, 6], [3, 6, 7], [3, 7, 8], [4, 7, 9], [4, 8, 10], [5, 8, 11], [6, 8, 12]],src1 = 0,src2 = 2,dest = 8) == 19\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]],src1 = 0,src2 = 7,dest = 14) == 105\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 1], [1, 4, 4], [2, 1, 2], [2, 3, 6], [3, 4, 2], [4, 5, 7], [5, 6, 1], [6, 7, 2], [7, 8, 3], [8, 9, 1]],src1 = 0,src2 = 2,dest = 9) == 22\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 5, 6], [2, 6, 7], [3, 7, 8], [4, 8, 1], [5, 9, 2], [6, 9, 3], [7, 9, 9], [8, 9, 6]],src1 = 0,src2 = 2,dest = 9) == 11\n assert candidate(n = 11,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [1, 4, 40], [2, 4, 50], [2, 5, 60], [3, 6, 70], [3, 7, 80], [4, 7, 90], [4, 8, 100], [5, 8, 110], [5, 9, 120], [6, 9, 130], [6, 10, 140], [7, 10, 150], [8, 10, 160]],src1 = 0,src2 = 2,dest = 10) == 310\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], [9, 12, 19], [10, 13, 20], [11, 13, 21], [12, 14, 22]],src1 = 0,src2 = 5,dest = 14) == 62\n assert candidate(n = 15,edges = [[0, 1, 10], [0, 5, 20], [1, 2, 5], [1, 3, 15], [2, 4, 10], [3, 6, 20], [4, 7, 5], [5, 8, 15], [6, 9, 20], [7, 10, 10], [8, 11, 20], [9, 12, 25], [10, 13, 15], [11, 14, 25], [12, 13, 5], [13, 14, 20]],src1 = 0,src2 = 5,dest = 14) == 80\n assert candidate(n = 7,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 1], [1, 4, 2], [2, 5, 4], [2, 6, 5], [3, 4, 3], [4, 5, 2], [5, 6, 1]],src1 = 0,src2 = 1,dest = 6) == 14\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], [5, 7, 9], [6, 7, 10], [3, 4, 11], [5, 6, 12]],src1 = 0,src2 = 2,dest = 7) == 16\n assert candidate(n = 15,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 1], [1, 4, 2], [2, 5, 4], [2, 6, 5], [3, 7, 6], [4, 8, 7], [5, 9, 8], [6, 10, 9], [7, 11, 10], [8, 12, 11], [9, 13, 12], [10, 14, 13], [11, 14, 14]],src1 = 0,src2 = 1,dest = 14) == 33\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, 8, 10], [7, 9, 11], [8, 9, 12]],src1 = 0,src2 = 2,dest = 9) == 16\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], [11, 14, 15], [12, 14, 16]],src1 = 0,src2 = 2,dest = 14) == 32\n assert candidate(n = 7,edges = [[0, 1, 5], [0, 2, 10], [1, 3, 3], [1, 4, 4], [2, 1, 6], [2, 4, 8], [2, 5, 7], [3, 6, 2], [4, 6, 5], [5, 6, 1]],src1 = 0,src2 = 2,dest = 6) == 16\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], [11, 12, 15], [12, 13, 16], [13, 14, 17]],src1 = 0,src2 = 1,dest = 14) == 58\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, 10]],src1 = 0,src2 = 1,dest = 9) == -1\n assert candidate(n = 10,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 1], [1, 4, 3], [2, 5, 2], [2, 6, 5], [3, 7, 1], [4, 7, 2], [5, 8, 3], [6, 8, 4], [7, 9, 5], [8, 9, 6]],src1 = 0,src2 = 2,dest = 9) == 15\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 6], [2, 3, 5], [2, 5, 1], [3, 6, 3], [4, 6, 2], [5, 6, 7]],src1 = 0,src2 = 1,dest = 6) == 9\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], [0, 6, 8], [1, 5, 9], [2, 4, 10]],src1 = 0,src2 = 3,dest = 6) == 21\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 3, 1], [2, 5, 7], [3, 6, 3], [4, 6, 2], [5, 7, 6], [6, 8, 2], [7, 8, 5], [8, 9, 10]],src1 = 0,src2 = 1,dest = 9) == 21\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], [9, 11, 13], [10, 11, 14]],src1 = 0,src2 = 2,dest = 11) == 29\n assert candidate(n = 6,edges = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 0, 600]],src1 = 0,src2 = 3,dest = 5) == 1500\n assert candidate(n = 20,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], [0, 19, 1]],src1 = 0,src2 = 10,dest = 19) == 136\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 1, 4], [2, 3, 8], [2, 4, 2], [3, 5, 1], [4, 5, 3], [5, 6, 2], [6, 7, 1], [7, 8, 3], [8, 9, 2], [9, 6, 4]],src1 = 0,src2 = 2,dest = 8) == 14\n assert candidate(n = 6,edges = [[0, 1, 1000], [1, 2, 2000], [2, 3, 3000], [3, 4, 4000], [4, 5, 5000], [5, 0, 6000], [0, 2, 1500], [1, 3, 2500], [2, 4, 3500], [3, 5, 4500]],src1 = 0,src2 = 1,dest = 5) == 8000\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "src1", "src2", "dest"], "leetcode_dataset_entry_point": "Solution().minimumWeight", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumWeight(int n, int[][] edges, int src1, int src2, int dest) {", "container": "Solution", "callable": "minimumWeight", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}, {"name": "src1", "type": "int"}, {"name": "src2", "type": "int"}, {"name": "dest", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2206, "task_id": "divide-array-into-equal-pairs", "difficulty": "Easy", "problem_description": "You are given an integer array nums consisting of 2 * n integers.\nYou need to divide nums into n pairs such that:\n\nEach element belongs to exactly one pair.\nThe elements present in a pair are equal.\n\nReturn true if nums can be divided into n pairs, otherwise return false.\n \nExample 1:\n\nInput: nums = [3,2,3,2,2,2]\nOutput: true\nExplanation: \nThere are 6 elements in nums, so they should be divided into 6 / 2 = 3 pairs.\nIf nums is divided into the pairs (2, 2), (3, 3), and (2, 2), it will satisfy all the conditions.\n\nExample 2:\n\nInput: nums = [1,2,3,4]\nOutput: false\nExplanation: \nThere is no way to divide nums into 4 / 2 = 2 pairs such that the pairs satisfy every condition.\n\n \nConstraints:\n\nnums.length == 2 * n\n1 <= n <= 500\n1 <= nums[i] <= 500\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 1, 3, 2, 3]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == True\n assert candidate(nums = [100, 100, 200, 200, 300, 300]) == True\n assert candidate(nums = [100, 200, 100, 200, 100, 200]) == False\n assert candidate(nums = [4, 4, 5, 5, 6, 6, 7, 7]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == True\n assert candidate(nums = [1, 2, 3, 4]) == False\n assert candidate(nums = [4, 4, 5, 5, 6, 6]) == True\n assert candidate(nums = [5, 5, 6, 6, 7, 7, 8, 8]) == True\n assert candidate(nums = [499, 499, 500, 500, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 2]) == False\n assert candidate(nums = [2, 3, 2, 3, 2, 3]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [3, 2, 3, 2, 2, 2]) == True\n assert candidate(nums = [8, 8, 8, 8, 9, 9, 9, 9]) == 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 = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == False\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [500, 500, 499, 499, 498, 498]) == True\n assert candidate(nums = [1, 2, 1, 2, 3, 3]) == True\n assert candidate(nums = [499, 499, 498, 498, 497, 497]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [42, 42, 24, 24, 13, 13, 88, 88, 17, 17, 56, 56, 99, 99, 101, 101, 202, 202, 303, 303, 404, 404, 505, 505, 606, 606]) == True\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 = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499]) == True\n assert candidate(nums = [499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490]) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\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]) == True\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]) == 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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(nums = [50, 50, 50, 50, 20, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 10, 10, 10, 10, 60, 60, 60, 60, 70, 70, 70, 70]) == 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, 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]) == False\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [250, 250, 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 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 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, 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]) == True\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493]) == 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 = [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]) == 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]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 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]) == True\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, 250, 250, 250, 250, 250, 250, 250, 250]) == 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]) == 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 = [100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107]) == True\n assert candidate(nums = [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]) == True\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, 488, 488, 487, 487, 486, 486]) == True\n assert candidate(nums = [450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6]) == 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, 110, 110, 120, 120, 130, 130, 140, 140, 150, 150]) == True\n assert candidate(nums = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500, 600, 600, 700, 700, 800, 800, 900, 900, 100, 100]) == True\n assert candidate(nums = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == True\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, 488, 488, 487, 487, 486, 486, 485, 485, 484, 484, 483, 483, 482, 482, 481, 481, 480, 480]) == True\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]) == 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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\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, 2, 2]) == True\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495]) == True\n assert candidate(nums = [1, 1, 1, 1, 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]) == 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, 2, 2, 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, 3]) == 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, 11, 11, 12, 12, 13, 13]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\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]) == False\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491]) == True\n assert candidate(nums = [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]) == True\n assert candidate(nums = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 7, 7, 7, 7, 9, 9, 9, 9, 8, 8, 8, 8, 6, 6, 6, 6, 4, 4, 4, 4]) == True\n assert candidate(nums = [10, 10, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30]) == True\n assert candidate(nums = [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, 3, 3, 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, 4, 4, 4, 4, 4]) == False\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, 488, 488, 487, 487, 486, 486, 485, 485]) == True\n assert candidate(nums = [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]) == True\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]) == True\n assert candidate(nums = [499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == 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, 17, 17, 18, 18, 19, 19, 20, 20]) == True\n assert candidate(nums = [123, 123, 456, 456, 789, 789, 101, 101, 202, 202, 303, 303, 404, 404, 505, 505]) == True\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [250, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255, 255, 256, 256, 257, 257, 258, 258, 259, 259, 260, 260]) == True\n assert candidate(nums = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == True\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]) == True\n assert candidate(nums = [100, 100, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108]) == True\n assert candidate(nums = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150]) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == False\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().divideArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean divideArray(int[] nums) {", "container": "Solution", "callable": "divideArray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2207, "task_id": "maximize-number-of-subsequences-in-a-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string text and another 0-indexed string pattern of length 2, both of which consist of only lowercase English letters.\nYou can add either pattern[0] or pattern[1] anywhere in text exactly once. Note that the character can be added even at the beginning or at the end of text.\nReturn the maximum number of times pattern can occur as a subsequence of the modified text.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n \nExample 1:\n\nInput: text = \"abdcdbc\", pattern = \"ac\"\nOutput: 4\nExplanation:\nIf we add pattern[0] = 'a' in between text[1] and text[2], we get \"abadcdbc\". Now, the number of times \"ac\" occurs as a subsequence is 4.\nSome other strings which have 4 subsequences \"ac\" after adding a character to text are \"aabdcdbc\" and \"abdacdbc\".\nHowever, strings such as \"abdcadbc\", \"abdccdbc\", and \"abdcdbcc\", although obtainable, have only 3 subsequences \"ac\" and are thus suboptimal.\nIt can be shown that it is not possible to get more than 4 subsequences \"ac\" by adding only one character.\n\nExample 2:\n\nInput: text = \"aabb\", pattern = \"ab\"\nOutput: 6\nExplanation:\nSome of the strings which can be obtained from text and have 6 subsequences \"ab\" are \"aaabb\", \"aaabb\", and \"aabbb\".\n\n \nConstraints:\n\n1 <= text.length <= 105\npattern.length == 2\ntext and pattern consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"bbbb\",pattern = \"bb\") == 10\n assert candidate(text = \"aaaaa\",pattern = \"aa\") == 15\n assert candidate(text = \"zzzz\",pattern = \"zz\") == 10\n assert candidate(text = \"abdcdbc\",pattern = \"ac\") == 4\n assert candidate(text = \"abc\",pattern = \"ca\") == 1\n assert candidate(text = \"babab\",pattern = \"ba\") == 6\n assert candidate(text = \"zzz\",pattern = \"zz\") == 6\n assert candidate(text = \"abcabc\",pattern = \"aa\") == 3\n assert candidate(text = \"a\",pattern = \"ab\") == 1\n assert candidate(text = \"ab\",pattern = \"ba\") == 1\n assert candidate(text = \"aabb\",pattern = \"ab\") == 6\n assert candidate(text = \"aaa\",pattern = \"aa\") == 6\n assert candidate(text = \"b\",pattern = \"ab\") == 1\n assert candidate(text = \"aaaa\",pattern = \"aa\") == 10\n assert candidate(text = \"xyzxyz\",pattern = \"yx\") == 3\n assert candidate(text = \"abcabc\",pattern = \"ac\") == 5\n assert candidate(text = \"xyz\",pattern = \"xz\") == 2\n assert candidate(text = \"\",pattern = \"ab\") == 0\n assert candidate(text = \"\",pattern = \"xy\") == 0\n assert candidate(text = \"abxyabxyabxy\",pattern = \"bx\") == 9\n assert candidate(text = \"zxyzxyzxyz\",pattern = \"yz\") == 10\n assert candidate(text = \"xyzyzyzyzyzx\",pattern = \"yx\") == 10\n assert candidate(text = \"zzzzzzzzzzz\",pattern = \"zz\") == 66\n assert candidate(text = \"pqrsrstq\",pattern = \"pq\") == 4\n assert candidate(text = \"bbabbaaa\",pattern = \"ba\") == 18\n assert candidate(text = \"ababababab\",pattern = \"ba\") == 15\n assert candidate(text = \"aaaaabbbbb\",pattern = \"ab\") == 30\n assert candidate(text = \"aaabbbccc\",pattern = \"ac\") == 12\n assert candidate(text = \"abacabacaba\",pattern = \"ac\") == 12\n assert candidate(text = \"abcdefabcdef\",pattern = \"cf\") == 5\n assert candidate(text = \"bbaabb\",pattern = \"ba\") == 8\n assert candidate(text = \"bcbcbcbcbb\",pattern = \"bc\") == 16\n assert candidate(text = \"bbaabaabaabbb\",pattern = \"ab\") == 31\n assert candidate(text = \"bbbbba\",pattern = \"ba\") == 10\n assert candidate(text = \"acbacbacba\",pattern = \"ac\") == 10\n assert candidate(text = \"mnopqr\",pattern = \"pq\") == 2\n assert candidate(text = \"xyxzyxzyxzyx\",pattern = \"yx\") == 15\n assert candidate(text = \"zzyzxzyzxzy\",pattern = \"yz\") == 12\n assert candidate(text = \"xyyxxyyxxyy\",pattern = \"yx\") == 18\n assert candidate(text = \"aabbccdd\",pattern = \"ac\") == 6\n assert candidate(text = \"abcdabcdabcd\",pattern = \"ac\") == 9\n assert candidate(text = \"mississippi\",pattern = \"is\") == 10\n assert candidate(text = \"zzzzzzzzzz\",pattern = \"zz\") == 55\n assert candidate(text = \"ababababab\",pattern = \"ab\") == 20\n assert candidate(text = \"aabbaabbaabbaabbaabbaabbaabbaabb\",pattern = \"bb\") == 136\n assert candidate(text = \"qwertyuiop\",pattern = \"qp\") == 2\n assert candidate(text = \"aaaaaaa\",pattern = \"aa\") == 28\n assert candidate(text = \"abcdabcdabcd\",pattern = \"da\") == 6\n assert candidate(text = \"zzzzz\",pattern = \"zz\") == 15\n assert candidate(text = \"abababababab\",pattern = \"ba\") == 21\n assert candidate(text = \"abababababa\",pattern = \"ab\") == 21\n assert candidate(text = \"abcabcabcabc\",pattern = \"ac\") == 14\n assert candidate(text = \"aabbbcc\",pattern = \"ac\") == 6\n assert candidate(text = \"aabbaabbaabbaabbaabb\",pattern = \"aa\") == 55\n assert candidate(text = \"babcbabcba\",pattern = \"bc\") == 11\n assert candidate(text = \"aabbccddeeff\",pattern = \"bf\") == 6\n assert candidate(text = \"abcabcabc\",pattern = \"ab\") == 9\n assert candidate(text = \"bcbcbcbcbc\",pattern = \"bc\") == 20\n assert candidate(text = \"xyxxyxyxyx\",pattern = \"yx\") == 17\n assert candidate(text = \"abcabcabcabcabcabc\",pattern = \"ca\") == 21\n assert candidate(text = \"xzyxzyxzyz\",pattern = \"zy\") == 10\n assert candidate(text = \"zzzzzz\",pattern = \"zz\") == 21\n assert candidate(text = \"aabbbaaabbbb\",pattern = \"ab\") == 33\n assert candidate(text = \"aaabbb\",pattern = \"ab\") == 12\n assert candidate(text = \"nnaaaannaa\",pattern = \"an\") == 14\n assert candidate(text = \"xyxyxyxyxy\",pattern = \"yx\") == 15\n assert candidate(text = \"cccccc\",pattern = \"cc\") == 21\n assert candidate(text = \"abacabadabacaba\",pattern = \"ba\") == 24\n assert candidate(text = \"bababababababababa\",pattern = \"bb\") == 45\n assert candidate(text = \"dcbabcdabcba\",pattern = \"ab\") == 9\n assert candidate(text = \"xyzzyxzyxzyxzyx\",pattern = \"zy\") == 19\n assert candidate(text = \"aaaaaabbbb\",pattern = \"ab\") == 30\n assert candidate(text = \"cccccccc\",pattern = \"cc\") == 36\n assert candidate(text = \"babcbacbab\",pattern = \"bc\") == 10\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz\",pattern = \"zy\") == 1\n assert candidate(text = \"zzzyyy\",pattern = \"yz\") == 3\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",pattern = \"zz\") == 406\n assert candidate(text = \"mnopqrqpomn\",pattern = \"mn\") == 5\n assert candidate(text = \"aabbaabb\",pattern = \"bb\") == 10\n assert candidate(text = \"aabbccddeeffgg\",pattern = \"ag\") == 6\n assert candidate(text = \"ccbaaa\",pattern = \"ab\") == 3\n assert candidate(text = \"xyzzyxzyzxzyxzyx\",pattern = \"yz\") == 20\n assert candidate(text = \"aaaaaaaaa\",pattern = \"aa\") == 45\n assert candidate(text = \"aabbaabb\",pattern = \"ab\") == 16\n assert candidate(text = \"bababababababa\",pattern = \"ba\") == 35\n assert candidate(text = \"bababababa\",pattern = \"ba\") == 20\n assert candidate(text = \"zyxwvutsrqponmlkjihgfedcba\",pattern = \"yz\") == 1\n assert candidate(text = \"qqqqqqqqqq\",pattern = \"qp\") == 10\n assert candidate(text = \"qwertyuiopasdfghjklzxcvbnm\",pattern = \"mn\") == 1\n assert candidate(text = \"abcabcdabc\",pattern = \"bc\") == 9\n assert candidate(text = \"zzzzyyyy\",pattern = \"zy\") == 20\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",pattern = \"xz\") == 6\n assert candidate(text = \"abacabacab\",pattern = \"ac\") == 11\n assert candidate(text = \"fedcba\",pattern = \"ab\") == 1\n assert candidate(text = \"ccccbbbaaa\",pattern = \"ba\") == 12\n assert candidate(text = \"mmnnnmmnnm\",pattern = \"mn\") == 19\n assert candidate(text = \"abcabcabc\",pattern = \"ba\") == 6\n assert candidate(text = \"xyzxyzxyzxyz\",pattern = \"yx\") == 10\n assert candidate(text = \"qqqqqppppp\",pattern = \"pq\") == 5\n assert candidate(text = \"aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbb\",pattern = \"ba\") == 20\n assert candidate(text = \"abbaba\",pattern = \"ab\") == 7\n assert candidate(text = \"zzzzzzzzzzzzz\",pattern = \"zz\") == 91\n assert candidate(text = \"zzyzxzyzxzyz\",pattern = \"yz\") == 16\n assert candidate(text = \"aabbaabb\",pattern = \"aa\") == 10\n assert candidate(text = \"abcabcabcabcabc\",pattern = \"ab\") == 20\n assert candidate(text = \"babbabababababababa\",pattern = \"ba\") == 63\n assert candidate(text = \"aaabbbcccddd\",pattern = \"ad\") == 12\n assert candidate(text = \"abcdef\",pattern = \"fe\") == 1\n assert candidate(text = \"bbbbbbbbbb\",pattern = \"bb\") == 55\n assert candidate(text = \"bbbbbaaaaa\",pattern = \"ab\") == 5\n assert candidate(text = \"abcde\",pattern = \"ae\") == 2\n assert candidate(text = \"abracadabra\",pattern = \"ra\") == 10\n assert candidate(text = \"abcdefghij\",pattern = \"ae\") == 2\n assert candidate(text = \"aaabbbccc\",pattern = \"ab\") == 12\n assert candidate(text = \"abcdefghij\",pattern = \"aj\") == 2\n assert candidate(text = \"xyzzyxzyxzyxzyxzyxzyxzyx\",pattern = \"zx\") == 43\n assert candidate(text = \"mmnmmnmmn\",pattern = \"mn\") == 18\n assert candidate(text = \"aabbccddeeff\",pattern = \"ef\") == 6\n assert candidate(text = \"zzzzzzzz\",pattern = \"zz\") == 36\n assert candidate(text = \"ccccccc\",pattern = \"cc\") == 28\n assert candidate(text = \"abcabcabc\",pattern = \"bc\") == 9\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",pattern = \"az\") == 6\n assert candidate(text = \"abcdefghij\",pattern = \"af\") == 2\n assert candidate(text = \"bbbbbaaaaa\",pattern = \"ba\") == 30\n assert candidate(text = \"xyzyxzyxzy\",pattern = \"yx\") == 9\n assert candidate(text = \"aabccbaa\",pattern = \"ac\") == 8\n assert candidate(text = \"abacabadabacaba\",pattern = \"ab\") == 24\n assert candidate(text = \"aabccccdddd\",pattern = \"cd\") == 20\n assert candidate(text = \"aaaaaaaaaa\",pattern = \"aa\") == 55\n assert candidate(text = \"aaaabbbb\",pattern = \"ab\") == 20\n assert candidate(text = \"aaaaaaaaaaaabbbbbbbbbbbb\",pattern = \"ab\") == 156\n assert candidate(text = \"abcdefghijklnmopqrstuvwxyz\",pattern = \"az\") == 2\n assert candidate(text = \"abcd\",pattern = \"da\") == 1\n assert candidate(text = \"abcdabcdabcd\",pattern = \"ad\") == 9\n assert candidate(text = \"lkjqwpmr\",pattern = \"qw\") == 2\n assert candidate(text = \"aabbaabbcc\",pattern = \"ab\") == 16\n assert candidate(text = \"abcabcabc\",pattern = \"ac\") == 9\n assert candidate(text = \"baabbaab\",pattern = \"ba\") == 12\n"}, "metadata": {"canonical_parameter_names": ["text", "pattern"], "leetcode_dataset_entry_point": "Solution().maximumSubsequenceCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumSubsequenceCount(String text, String pattern) {", "container": "Solution", "callable": "maximumSubsequenceCount", "parameters": [{"name": "text", "type": "String"}, {"name": "pattern", "type": "String"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2208, "task_id": "minimum-operations-to-halve-array-sum", "difficulty": "Medium", "problem_description": "You are given an array nums of positive integers. In one operation, you can choose any number from nums and reduce it to exactly half the number. (Note that you may choose this reduced number in future operations.)\nReturn the minimum number of operations to reduce the sum of nums by at least half.\n \nExample 1:\n\nInput: nums = [5,19,8,1]\nOutput: 3\nExplanation: The initial sum of nums is equal to 5 + 19 + 8 + 1 = 33.\nThe following is one of the ways to reduce the sum by at least half:\nPick the number 19 and reduce it to 9.5.\nPick the number 9.5 and reduce it to 4.75.\nPick the number 8 and reduce it to 4.\nThe final array is [5, 4.75, 4, 1] with a total sum of 5 + 4.75 + 4 + 1 = 14.75. \nThe sum of nums has been reduced by 33 - 14.75 = 18.25, which is at least half of the initial sum, 18.25 >= 33/2 = 16.5.\nOverall, 3 operations were used so we return 3.\nIt can be shown that we cannot reduce the sum by at least half in less than 3 operations.\n\nExample 2:\n\nInput: nums = [3,8,20]\nOutput: 3\nExplanation: The initial sum of nums is equal to 3 + 8 + 20 = 31.\nThe following is one of the ways to reduce the sum by at least half:\nPick the number 20 and reduce it to 10.\nPick the number 10 and reduce it to 5.\nPick the number 3 and reduce it to 1.5.\nThe final array is [1.5, 8, 5] with a total sum of 1.5 + 8 + 5 = 14.5. \nThe sum of nums has been reduced by 31 - 14.5 = 16.5, which is at least half of the initial sum, 16.5 >= 31/2 = 15.5.\nOverall, 3 operations were used so we return 3.\nIt can be shown that we cannot reduce the sum by at least half in less than 3 operations.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [100, 100, 100, 100]) == 4\n assert candidate(nums = [3, 8, 20]) == 3\n assert candidate(nums = [10000000]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [5, 19, 8, 1]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [10, 10, 10, 10, 10]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 10\n assert candidate(nums = [10, 20, 30, 40]) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 13\n assert candidate(nums = [9999999, 9999998, 9999997, 9999996, 9999995]) == 5\n assert candidate(nums = [5000000, 5000000, 5000000, 5000000, 5000000]) == 5\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 3\n assert candidate(nums = [1000, 500, 250, 125, 62.5, 31.25]) == 3\n assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250]) == 3\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584]) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 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]) == 24\n assert candidate(nums = [1, 1000000, 100000, 10000, 1000]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 3\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 9\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 3\n assert candidate(nums = [50000000, 50000000, 50000000, 50000000, 50000000]) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 3\n assert candidate(nums = [5000000, 3000000, 2000000, 1000000, 500000, 300000, 200000, 100000]) == 4\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]) == 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]) == 30\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 15\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250]) == 3\n assert candidate(nums = [1234567, 2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234, 9012345]) == 8\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 2\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500]) == 16\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 2\n assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531]) == 3\n assert candidate(nums = [9999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000]) == 4\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1]) == 10\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]) == 18\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 3\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 9\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531, 9765, 4882, 2441, 1220, 610, 305, 152, 76, 38]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 2\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 20\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 12\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996]) == 5\n assert candidate(nums = [1234567, 2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234, 9012345, 10123456]) == 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, 5, 5, 5, 5, 5]) == 25\n assert candidate(nums = [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, 100000]) == 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]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 14\n assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062.5, 19531.25]) == 3\n assert candidate(nums = [10000000, 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\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 2\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 20\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 20\n assert candidate(nums = [9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990]) == 10\n assert candidate(nums = [5000000, 5000000, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [9999999, 8888888, 7777777, 6666666, 5555555, 4444444, 3333333, 2222222, 1111111]) == 8\n assert candidate(nums = [9999999, 1, 1, 1]) == 2\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000]) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 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]) == 16\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 12\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 12\n assert candidate(nums = [9999999, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 9\n assert candidate(nums = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000]) == 10\n assert candidate(nums = [5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062.5, 19531.25, 9765.625]) == 3\n assert candidate(nums = [5000000, 3000000, 2000000, 4000000, 1000000]) == 5\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 = [5000000, 4000000, 3000000, 2000000, 1000000, 500000, 250000, 125000, 62500, 31250]) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().halveArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int halveArray(int[] nums) {", "container": "Solution", "callable": "halveArray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2209, "task_id": "minimum-white-tiles-after-covering-with-carpets", "difficulty": "Hard", "problem_description": "You are given a 0-indexed binary string floor, which represents the colors of tiles on a floor:\n\nfloor[i] = '0' denotes that the ith tile of the floor is colored black.\nOn the other hand, floor[i] = '1' denotes that the ith tile of the floor is colored white.\n\nYou are also given numCarpets and carpetLen. You have numCarpets black carpets, each of length carpetLen tiles. Cover the tiles with the given carpets such that the number of white tiles still visible is minimum. Carpets may overlap one another.\nReturn the minimum number of white tiles still visible.\n \nExample 1:\n\n\nInput: floor = \"10110101\", numCarpets = 2, carpetLen = 2\nOutput: 2\nExplanation: \nThe figure above shows one way of covering the tiles with the carpets such that only 2 white tiles are visible.\nNo other way of covering the tiles with the carpets can leave less than 2 white tiles visible.\n\nExample 2:\n\n\nInput: floor = \"11111\", numCarpets = 2, carpetLen = 3\nOutput: 0\nExplanation: \nThe figure above shows one way of covering the tiles with the carpets such that no white tiles are visible.\nNote that the carpets are able to overlap one another.\n\n \nConstraints:\n\n1 <= carpetLen <= floor.length <= 1000\nfloor[i] is either '0' or '1'.\n1 <= numCarpets <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(floor = \"111100001111\",numCarpets = 4,carpetLen = 4) == 0\n assert candidate(floor = \"110011\",numCarpets = 3,carpetLen = 2) == 0\n assert candidate(floor = \"11111\",numCarpets = 2,carpetLen = 3) == 0\n assert candidate(floor = \"1010101010\",numCarpets = 5,carpetLen = 1) == 0\n assert candidate(floor = \"11001100\",numCarpets = 3,carpetLen = 2) == 0\n assert candidate(floor = \"11010110\",numCarpets = 3,carpetLen = 1) == 2\n assert candidate(floor = \"10110101\",numCarpets = 2,carpetLen = 2) == 2\n assert candidate(floor = \"1110111\",numCarpets = 1,carpetLen = 4) == 3\n assert candidate(floor = \"111000111\",numCarpets = 2,carpetLen = 4) == 0\n assert candidate(floor = \"00000\",numCarpets = 1,carpetLen = 1) == 0\n assert candidate(floor = \"00000\",numCarpets = 1,carpetLen = 2) == 0\n assert candidate(floor = \"1111001111001111001111001111001111001111001111001111001111\",numCarpets = 12,carpetLen = 5) == 0\n assert candidate(floor = \"110011001100110011001100110011001100110011001100\",numCarpets = 5,carpetLen = 3) == 14\n assert candidate(floor = \"10101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 5) == 0\n assert candidate(floor = \"110011001100110011001100110011001100110011001100\",numCarpets = 15,carpetLen = 4) == 0\n assert candidate(floor = \"010101010101010101010101010101010101010101010101\",numCarpets = 10,carpetLen = 5) == 0\n assert candidate(floor = \"111101010101010101010101010101010101010101\",numCarpets = 10,carpetLen = 7) == 0\n assert candidate(floor = \"110001001001001001001001001001001001001001001001\",numCarpets = 20,carpetLen = 4) == 0\n assert candidate(floor = \"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 5) == 0\n assert candidate(floor = \"1111000011110000111100001111\",numCarpets = 6,carpetLen = 4) == 0\n assert candidate(floor = \"0000000000000000000000000000\",numCarpets = 10,carpetLen = 10) == 0\n assert candidate(floor = \"11111111111111111111111111111111111111\",numCarpets = 1000,carpetLen = 1) == 0\n assert candidate(floor = \"11111000001111111100\",numCarpets = 4,carpetLen = 4) == 0\n assert candidate(floor = \"11110111101111011110111101\",numCarpets = 10,carpetLen = 2) == 1\n assert candidate(floor = \"010101010101010101010101010101010101010101010101\",numCarpets = 18,carpetLen = 7) == 0\n assert candidate(floor = \"101010101010101010101010101010101010101010101010\",numCarpets = 25,carpetLen = 2) == 0\n assert candidate(floor = \"10000000000000000000000000\",numCarpets = 1,carpetLen = 10) == 0\n assert candidate(floor = \"11100011111000111000\",numCarpets = 5,carpetLen = 4) == 0\n assert candidate(floor = \"111111111111111111111111111111111111111111111111\",numCarpets = 10,carpetLen = 5) == 0\n assert candidate(floor = \"10101010101010101010101010101010101010101010101010\",numCarpets = 15,carpetLen = 4) == 0\n assert candidate(floor = \"10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000\",numCarpets = 25,carpetLen = 8) == 0\n assert candidate(floor = \"00001111000011110000111100001111\",numCarpets = 12,carpetLen = 4) == 0\n assert candidate(floor = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",numCarpets = 50,carpetLen = 10) == 0\n assert candidate(floor = \"0000000000000000000000000000000000000000\",numCarpets = 20,carpetLen = 5) == 0\n assert candidate(floor = \"1010101010101010101010101010101010101010101010101010\",numCarpets = 10,carpetLen = 2) == 16\n assert candidate(floor = \"10010010010010010010010010010010010010\",numCarpets = 10,carpetLen = 3) == 3\n assert candidate(floor = \"01010101010101010101\",numCarpets = 5,carpetLen = 4) == 0\n assert candidate(floor = \"0001111111000111111000111111\",numCarpets = 6,carpetLen = 5) == 0\n assert candidate(floor = \"01010101010101010101010101010101010101\",numCarpets = 8,carpetLen = 2) == 11\n assert candidate(floor = \"11111000011111000011111000011111\",numCarpets = 4,carpetLen = 5) == 0\n assert candidate(floor = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",numCarpets = 100,carpetLen = 10) == 0\n assert candidate(floor = \"0101010101010101010101010101\",numCarpets = 10,carpetLen = 3) == 0\n assert candidate(floor = \"11100011100011100011\",numCarpets = 6,carpetLen = 3) == 0\n assert candidate(floor = \"11111111111111111111\",numCarpets = 3,carpetLen = 5) == 5\n assert candidate(floor = \"111111000011111100001111110000111111\",numCarpets = 8,carpetLen = 5) == 0\n assert candidate(floor = \"1111111111111111111111111111111111111111\",numCarpets = 16,carpetLen = 10) == 0\n assert candidate(floor = \"1010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 6) == 0\n assert candidate(floor = \"11001100110011001100110011001100\",numCarpets = 8,carpetLen = 2) == 0\n assert candidate(floor = \"00100100100100100100100100\",numCarpets = 10,carpetLen = 3) == 0\n assert candidate(floor = \"11111111111111111111111111\",numCarpets = 15,carpetLen = 2) == 0\n assert candidate(floor = \"1111011011111100001101110111\",numCarpets = 5,carpetLen = 6) == 0\n assert candidate(floor = \"111111111111111111111111111111111111111111111111\",numCarpets = 50,carpetLen = 1) == 0\n assert candidate(floor = \"110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100\",numCarpets = 15,carpetLen = 4) == 24\n assert candidate(floor = \"11101110111011101110111011\",numCarpets = 7,carpetLen = 4) == 0\n assert candidate(floor = \"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 15,carpetLen = 4) == 18\n assert candidate(floor = \"100110011001100110011001100110011001\",numCarpets = 8,carpetLen = 4) == 2\n assert candidate(floor = \"10101010101010101010101010101010\",numCarpets = 7,carpetLen = 4) == 2\n assert candidate(floor = \"1111000011110000111100001111000011110000111100001111000011110000111100001111000011110000\",numCarpets = 10,carpetLen = 7) == 4\n assert candidate(floor = \"111100001111000011110000111100001111000011110000\",numCarpets = 5,carpetLen = 4) == 4\n assert candidate(floor = \"11111111111111111111111111\",numCarpets = 10,carpetLen = 6) == 0\n assert candidate(floor = \"10001000100010001000100010001000\",numCarpets = 9,carpetLen = 3) == 0\n assert candidate(floor = \"111000111000111000111000111000111000\",numCarpets = 10,carpetLen = 2) == 2\n assert candidate(floor = \"111111000000111111000000111111000000111111000000111111\",numCarpets = 15,carpetLen = 7) == 0\n assert candidate(floor = \"111111111111111111111111111111111111\",numCarpets = 10,carpetLen = 7) == 0\n assert candidate(floor = \"11111111111111111111111111111111\",numCarpets = 5,carpetLen = 5) == 7\n assert candidate(floor = \"01010101010101010101010101\",numCarpets = 10,carpetLen = 5) == 0\n assert candidate(floor = \"1010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 30,carpetLen = 4) == 0\n assert candidate(floor = \"1010101010101010101010101010\",numCarpets = 10,carpetLen = 5) == 0\n assert candidate(floor = \"01010101010101010101\",numCarpets = 3,carpetLen = 2) == 7\n assert candidate(floor = \"11111111111111111111\",numCarpets = 5,carpetLen = 5) == 0\n assert candidate(floor = \"1111000011110000111100001111000011110000111100001111000011110000111100001111000011110000\",numCarpets = 30,carpetLen = 5) == 0\n assert candidate(floor = \"11110000111100001111\",numCarpets = 4,carpetLen = 5) == 0\n assert candidate(floor = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",numCarpets = 50,carpetLen = 12) == 0\n assert candidate(floor = \"10101010101010101010101010\",numCarpets = 15,carpetLen = 2) == 0\n assert candidate(floor = \"11010101010101010101\",numCarpets = 5,carpetLen = 3) == 1\n assert candidate(floor = \"11101110111011101110111011101110\",numCarpets = 10,carpetLen = 2) == 6\n assert candidate(floor = \"000000000000000000000000000000000000000000000000\",numCarpets = 10,carpetLen = 15) == 0\n assert candidate(floor = \"11111111111111111111111111111111\",numCarpets = 15,carpetLen = 5) == 0\n assert candidate(floor = \"111111111111111111111111111111111111111111111111\",numCarpets = 25,carpetLen = 10) == 0\n assert candidate(floor = \"11111111000000001111111100000000\",numCarpets = 3,carpetLen = 8) == 0\n assert candidate(floor = \"0000000000000000000000000000000000000000000000000000\",numCarpets = 1,carpetLen = 1000) == 0\n assert candidate(floor = \"110110110110110110110110110110110110110110110110\",numCarpets = 12,carpetLen = 6) == 0\n assert candidate(floor = \"1111000011110000111100001111000011110000111100001111\",numCarpets = 10,carpetLen = 8) == 0\n assert candidate(floor = \"01010101010101010101010101010101010101010101\",numCarpets = 4,carpetLen = 7) == 6\n assert candidate(floor = \"1111111111111111111111111111\",numCarpets = 15,carpetLen = 4) == 0\n assert candidate(floor = \"11111111111111111111\",numCarpets = 6,carpetLen = 5) == 0\n assert candidate(floor = \"111111111100000000000000111111111111111111111111\",numCarpets = 5,carpetLen = 10) == 0\n assert candidate(floor = \"100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100\",numCarpets = 20,carpetLen = 6) == 0\n assert candidate(floor = \"1111100000111110000011111\",numCarpets = 3,carpetLen = 6) == 0\n assert candidate(floor = \"01010101010101010101010101010101\",numCarpets = 10,carpetLen = 3) == 0\n assert candidate(floor = \"11110111101111011110\",numCarpets = 5,carpetLen = 3) == 2\n assert candidate(floor = \"00101010101010101010\",numCarpets = 5,carpetLen = 3) == 0\n assert candidate(floor = \"11111111111111111111\",numCarpets = 10,carpetLen = 2) == 0\n assert candidate(floor = \"111000111000111000111000111000111\",numCarpets = 8,carpetLen = 4) == 0\n assert candidate(floor = \"10101010101010101010\",numCarpets = 5,carpetLen = 3) == 0\n assert candidate(floor = \"00000000000000000000000000000000000000\",numCarpets = 1000,carpetLen = 1000) == 0\n assert candidate(floor = \"11110000111100001111000011110000\",numCarpets = 6,carpetLen = 4) == 0\n assert candidate(floor = \"10101010101010101010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 5) == 0\n assert candidate(floor = \"111000111000111000111\",numCarpets = 4,carpetLen = 3) == 0\n assert candidate(floor = \"10101010101010101010\",numCarpets = 3,carpetLen = 4) == 4\n assert candidate(floor = \"000000000000000000000000000000000000000000000000\",numCarpets = 10,carpetLen = 3) == 0\n assert candidate(floor = \"1001001001001001001001001\",numCarpets = 7,carpetLen = 4) == 0\n assert candidate(floor = \"01010101010101010101010101010101010101010101010101010101010\",numCarpets = 25,carpetLen = 3) == 0\n assert candidate(floor = \"11111111111111111111\",numCarpets = 5,carpetLen = 3) == 5\n assert candidate(floor = \"101010101010101010101010101010101010\",numCarpets = 15,carpetLen = 6) == 0\n assert candidate(floor = \"111101110111011101110111011101110111\",numCarpets = 5,carpetLen = 4) == 12\n assert candidate(floor = \"1010101010101010101010101010\",numCarpets = 8,carpetLen = 3) == 0\n assert candidate(floor = \"000101001010100110010010001000101010010101010101\",numCarpets = 15,carpetLen = 3) == 0\n assert candidate(floor = \"11001100110011001100\",numCarpets = 8,carpetLen = 3) == 0\n assert candidate(floor = \"1110111011101110111011101110111011101110111011101110111011101110\",numCarpets = 8,carpetLen = 3) == 24\n"}, "metadata": {"canonical_parameter_names": ["floor", "numCarpets", "carpetLen"], "leetcode_dataset_entry_point": "Solution().minimumWhiteTiles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumWhiteTiles(String floor, int numCarpets, int carpetLen) {", "container": "Solution", "callable": "minimumWhiteTiles", "parameters": [{"name": "floor", "type": "String"}, {"name": "numCarpets", "type": "int"}, {"name": "carpetLen", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2210, "task_id": "count-hills-and-valleys-in-an-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. An index i is part of a hill in nums if the closest non-equal neighbors of i are smaller than nums[i]. Similarly, an index i is part of a valley in nums if the closest non-equal neighbors of i are larger than nums[i]. Adjacent indices i and j are part of the same hill or valley if nums[i] == nums[j].\nNote that for an index to be part of a hill or valley, it must have a non-equal neighbor on both the left and right of the index.\nReturn the number of hills and valleys in nums.\n \nExample 1:\n\nInput: nums = [2,4,1,1,6,5]\nOutput: 3\nExplanation:\nAt index 0: There is no non-equal neighbor of 2 on the left, so index 0 is neither a hill nor a valley.\nAt index 1: The closest non-equal neighbors of 4 are 2 and 1. Since 4 > 2 and 4 > 1, index 1 is a hill. \nAt index 2: The closest non-equal neighbors of 1 are 4 and 6. Since 1 < 4 and 1 < 6, index 2 is a valley.\nAt index 3: The closest non-equal neighbors of 1 are 4 and 6. Since 1 < 4 and 1 < 6, index 3 is a valley, but note that it is part of the same valley as index 2.\nAt index 4: The closest non-equal neighbors of 6 are 1 and 5. Since 6 > 1 and 6 > 5, index 4 is a hill.\nAt index 5: There is no non-equal neighbor of 5 on the right, so index 5 is neither a hill nor a valley. \nThere are 3 hills and valleys so we return 3.\n\nExample 2:\n\nInput: nums = [6,6,5,5,4,1]\nOutput: 0\nExplanation:\nAt index 0: There is no non-equal neighbor of 6 on the left, so index 0 is neither a hill nor a valley.\nAt index 1: There is no non-equal neighbor of 6 on the left, so index 1 is neither a hill nor a valley.\nAt index 2: The closest non-equal neighbors of 5 are 6 and 4. Since 5 < 6 and 5 > 4, index 2 is neither a hill nor a valley.\nAt index 3: The closest non-equal neighbors of 5 are 6 and 4. Since 5 < 6 and 5 > 4, index 3 is neither a hill nor a valley.\nAt index 4: The closest non-equal neighbors of 4 are 5 and 1. Since 4 < 5 and 4 > 1, index 4 is neither a hill nor a valley.\nAt index 5: There is no non-equal neighbor of 1 on the right, so index 5 is neither a hill nor a valley.\nThere are 0 hills and valleys so we return 0.\n\n \nConstraints:\n\n3 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(nums = [100, 99, 100, 98, 99, 100]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 4, 4, 3, 3, 2, 2, 1]) == 0\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1]) == 0\n assert candidate(nums = [1, 3, 2, 3, 1]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5]) == 4\n assert candidate(nums = [3, 1, 2, 1, 3, 2, 1]) == 4\n assert candidate(nums = [2, 4, 1, 1, 6, 5]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 1, 1]) == 1\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 1]) == 3\n assert candidate(nums = [6, 6, 5, 5, 4, 1]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 3, 3, 3, 2, 2, 2, 1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 2, 2, 3]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3]) == 2\n assert candidate(nums = [1, 3, 1, 2, 1, 3, 1]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 2, 2]) == 2\n assert candidate(nums = [50, 50, 49, 51, 49, 51, 50]) == 4\n assert candidate(nums = [9, 8, 9, 8, 9, 8, 9]) == 5\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3]) == 3\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 96, 97, 98, 99, 100]) == 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, 3, 2, 1, 2, 3, 4, 3, 2]) == 9\n assert candidate(nums = [3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3]) == 11\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 4, 3, 2, 1]) == 5\n assert candidate(nums = [3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1]) == 10\n assert candidate(nums = [50, 50, 50, 50, 51, 50, 50, 50, 50, 51, 50, 50, 50, 50]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 4, 3, 2, 1, 1, 1]) == 1\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2]) == 5\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9]) == 12\n assert candidate(nums = [10, 9, 8, 7, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9]) == 3\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 17\n assert candidate(nums = [100, 90, 100, 90, 100, 90, 100, 80, 90, 80]) == 8\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 2, 2, 1, 1]) == 1\n assert candidate(nums = [3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2]) == 3\n assert candidate(nums = [1, 3, 2, 3, 1, 3, 2, 1, 2, 3, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 2, 3, 1, 2, 1]) == 7\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 = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == 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 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 2\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]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3]) == 4\n assert candidate(nums = [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, 10, 9, 8, 7, 6, 5]) == 3\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 8\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 2, 1, 3, 2, 3, 1]) == 9\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 7\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 7\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 1, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [10, 20, 10, 30, 10, 20, 10, 30, 10, 20, 10]) == 9\n assert candidate(nums = [50, 51, 52, 51, 50, 51, 52, 51, 50, 51, 52, 51]) == 5\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 8\n assert candidate(nums = [1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1]) == 9\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 5, 7, 4, 8, 3, 9, 2, 10]) == 18\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2]) == 4\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 9\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9]) == 12\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2]) == 8\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10]) == 4\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 13\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 8\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 0\n assert candidate(nums = [2, 2, 2, 3, 3, 2, 2, 2, 1, 1, 2, 2, 2]) == 2\n assert candidate(nums = [3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 8\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 1, 2, 1, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9]) == 13\n assert candidate(nums = [100, 99, 98, 97, 98, 99, 100, 99, 98, 97, 96, 97, 98, 99, 100, 99]) == 4\n assert candidate(nums = [1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2]) == 8\n assert candidate(nums = [1, 1, 1, 2, 3, 4, 5, 5, 5, 4, 3, 2, 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]) == 0\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 96, 97, 98, 99, 100]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1]) == 3\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 5]) == 8\n assert candidate(nums = [7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 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]) == 19\n assert candidate(nums = [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, 2, 1]) == 14\n assert candidate(nums = [10, 9, 8, 7, 6, 7, 8, 9, 10, 9]) == 2\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2]) == 3\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]) == 9\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1, 2, 3]) == 16\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 6\n assert candidate(nums = [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]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 6]) == 2\n assert candidate(nums = [1, 1, 2, 3, 4, 3, 2, 1, 1, 2, 3, 4, 3, 2, 1, 1, 2, 3, 4]) == 4\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2]) == 7\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8]) == 10\n assert candidate(nums = [50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50]) == 17\n assert candidate(nums = [2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 1, 2, 2]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 1\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 11\n assert candidate(nums = [1, 3, 2, 1, 2, 1, 2, 1, 2, 1, 3, 2, 1, 2, 1]) == 11\n assert candidate(nums = [1, 2, 2, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 8\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 3, 4]) == 8\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 11\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [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, 2]) == 14\n assert candidate(nums = [20, 21, 20, 22, 21, 23, 22, 24, 23, 25, 24, 23, 22, 21, 20, 19, 20, 21, 22, 21]) == 11\n assert candidate(nums = [1, 3, 3, 3, 2, 2, 2, 1, 3, 3, 3, 2, 2, 2]) == 3\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 3\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2]) == 2\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1]) == 9\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 18\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 18\n assert candidate(nums = [10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6]) == 11\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2]) == 1\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1, 1, 2, 2, 3, 3, 3, 2, 2, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 3, 2, 1, 2, 3, 4, 4, 3, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 8\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [9, 8, 7, 8, 7, 8, 9, 10, 9, 10, 9, 8, 7, 8, 7, 6, 5, 4, 5, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8]) == 13\n assert candidate(nums = [3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 3, 3, 2, 2, 1]) == 1\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10]) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countHillValley", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countHillValley(int[] nums) {", "container": "Solution", "callable": "countHillValley", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2211, "task_id": "count-collisions-on-a-road", "difficulty": "Medium", "problem_description": "There are n cars on an infinitely long road. The cars are numbered from 0 to n - 1 from left to right and each car is present at a unique point.\nYou are given a 0-indexed string directions of length n. directions[i] can be either 'L', 'R', or 'S' denoting whether the ith car is moving towards the left, towards the right, or staying at its current point respectively. Each moving car has the same speed.\nThe number of collisions can be calculated as follows:\n\nWhen two cars moving in opposite directions collide with each other, the number of collisions increases by 2.\nWhen a moving car collides with a stationary car, the number of collisions increases by 1.\n\nAfter a collision, the cars involved can no longer move and will stay at the point where they collided. Other than that, cars cannot change their state or direction of motion.\nReturn the total number of collisions that will happen on the road.\n \nExample 1:\n\nInput: directions = \"RLRSLL\"\nOutput: 5\nExplanation:\nThe collisions that will happen on the road are:\n- Cars 0 and 1 will collide with each other. Since they are moving in opposite directions, the number of collisions becomes 0 + 2 = 2.\n- Cars 2 and 3 will collide with each other. Since car 3 is stationary, the number of collisions becomes 2 + 1 = 3.\n- Cars 3 and 4 will collide with each other. Since car 3 is stationary, the number of collisions becomes 3 + 1 = 4.\n- Cars 4 and 5 will collide with each other. After car 4 collides with car 3, it will stay at the point of collision and get hit by car 5. The number of collisions becomes 4 + 1 = 5.\nThus, the total number of collisions that will happen on the road is 5. \n\nExample 2:\n\nInput: directions = \"LLRR\"\nOutput: 0\nExplanation:\nNo cars will collide with each other. Thus, the total number of collisions that will happen on the road is 0.\n \nConstraints:\n\n1 <= directions.length <= 105\ndirections[i] is either 'L', 'R', or 'S'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(directions = \"SSRLSL\") == 3\n assert candidate(directions = \"LRLRLR\") == 4\n assert candidate(directions = \"RRRR\") == 0\n assert candidate(directions = \"LRRSLRLR\") == 5\n assert candidate(directions = \"LSRL\") == 2\n assert candidate(directions = \"SSSS\") == 0\n assert candidate(directions = \"RLSLRL\") == 5\n assert candidate(directions = \"RSLSLSLS\") == 4\n assert candidate(directions = \"SSSRRSLL\") == 4\n assert candidate(directions = \"LRSLSR\") == 2\n assert candidate(directions = \"RLSL\") == 3\n assert candidate(directions = \"RLLLLLL\") == 7\n assert candidate(directions = \"RRRRRRS\") == 6\n assert candidate(directions = \"LLRR\") == 0\n assert candidate(directions = \"RRLR\") == 3\n assert candidate(directions = \"SSLSLS\") == 2\n assert candidate(directions = \"RLRRLL\") == 6\n assert candidate(directions = \"RRRSSSLL\") == 5\n assert candidate(directions = \"SSSSS\") == 0\n assert candidate(directions = \"LLLLL\") == 0\n assert candidate(directions = \"RLRSLL\") == 5\n assert candidate(directions = \"LSLR\") == 1\n assert candidate(directions = \"LLLL\") == 0\n assert candidate(directions = \"RSLRS\") == 3\n assert candidate(directions = \"RSLRLRLS\") == 6\n assert candidate(directions = \"RRSLRR\") == 3\n assert candidate(directions = \"LRLR\") == 2\n assert candidate(directions = \"RRRSSSLLLRRR\") == 6\n assert candidate(directions = \"LSRLSL\") == 3\n assert candidate(directions = \"LRLL\") == 3\n assert candidate(directions = \"SSRLSS\") == 2\n assert candidate(directions = \"RRRRR\") == 0\n assert candidate(directions = \"RSLR\") == 2\n assert candidate(directions = \"SSS\") == 0\n assert candidate(directions = \"LRRLRRLL\") == 7\n assert candidate(directions = \"RSLRSL\") == 4\n assert candidate(directions = \"LSSRLL\") == 3\n assert candidate(directions = \"RSLRLR\") == 4\n assert candidate(directions = \"SSRSLLS\") == 3\n assert candidate(directions = \"RRRRRSSSSSLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLSSSSSSSSSSS\") == 43\n assert candidate(directions = \"LRLRLRLRLRLR\") == 10\n assert candidate(directions = \"RRLRLRLRLRLRLRLRLRLR\") == 19\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"SSRSLRRRLLSLSSS\") == 8\n assert candidate(directions = \"RRRRRSSLLLLLRRRR\") == 10\n assert candidate(directions = \"RLLLLRRRRLLLLRRRRRLLLLRRRR\") == 22\n assert candidate(directions = \"RSSSSRRRRRRRRRRSSSLL\") == 13\n assert candidate(directions = \"RRRRRRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 10\n assert candidate(directions = \"LRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"RLRLRLRLRLRLRLRL\") == 16\n assert candidate(directions = \"RRRSSLLLLRRRSSLLLL\") == 14\n assert candidate(directions = \"RRRLRSSRRRLRRRRRSLRRRRRR\") == 15\n assert candidate(directions = \"RLRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 2\n assert candidate(directions = \"RSLRRSLRRSLR\") == 8\n assert candidate(directions = \"LLLSRSSRRRLRRRRRSLRRRRRR\") == 11\n assert candidate(directions = \"RLRSLLRSLLRSLLRSLLRS\") == 15\n assert candidate(directions = \"LLLLLLLLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RSLRSLRSLRSLRSLRSLRSLRSLRL\") == 18\n assert candidate(directions = \"LLLLSSSSRRRRRRRRRLLLLL\") == 14\n assert candidate(directions = \"RRRRSSSSLLLLRRRRRRSSSSLLLLRRRRRRSSSSLLLL\") == 28\n assert candidate(directions = \"RRRRRRRRRRRR\") == 0\n assert candidate(directions = \"SLRLRLRLRLRSLSLSL\") == 13\n assert candidate(directions = \"LLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSRRRRRR\") == 0\n assert candidate(directions = \"RSSSSRRRLLLLRRRSL\") == 12\n assert candidate(directions = \"RRRRRRRRRRSSSSSSSSSLLLLLLLL\") == 18\n assert candidate(directions = \"LRRRRRLLLLLS\") == 10\n assert candidate(directions = \"SLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 44\n assert candidate(directions = \"LLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"RRRSLSLSSSLLLLRRRS\") == 12\n assert candidate(directions = \"LLLLRRRRRRRR\") == 0\n assert candidate(directions = \"RLRSRLRSRLRSRLRS\") == 12\n assert candidate(directions = \"SSSSSSSSSSSSSSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLLLLLLLLLLLLLLLLLLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 52\n assert candidate(directions = \"RLRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 2\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"SSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RSLRSLSRLRSLSR\") == 8\n assert candidate(directions = \"RRRSLSLRSLRRRRLLL\") == 14\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"SSSSSRRRRRSSSSS\") == 5\n assert candidate(directions = \"RRRRSSSLLLLLRRRR\") == 9\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRR\") == 44\n assert candidate(directions = \"SSRRRRLLLLSSRRRRLLLLSS\") == 16\n assert candidate(directions = \"RSLRSLSRLSRLSRLRSLSR\") == 12\n assert candidate(directions = \"RRRRRRRRLLLLLLLL\") == 16\n assert candidate(directions = \"SLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 46\n assert candidate(directions = \"RRRLLRRRLLLLLSS\") == 13\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRRRRR\") == 43\n assert candidate(directions = \"LLLLLRRRRRLLLLLRRRRRLLLLLRRRRRLLLLLRRRRR\") == 30\n assert candidate(directions = \"LLLLRRRRRRSSSSSLLLL\") == 10\n assert candidate(directions = \"RLRLRLRLRLRL\") == 12\n assert candidate(directions = \"RLRSLRSLRSLRSLRS\") == 11\n assert candidate(directions = \"RRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"SLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 48\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRR\") == 44\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRRRR\") == 44\n assert candidate(directions = \"SSSSSSRRRRRSSSSSSSSS\") == 5\n assert candidate(directions = \"LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR\") == 38\n assert candidate(directions = \"SSSLRRRLLSSL\") == 7\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RRRLRLRLRLRLRLRLRLRLRLRLRLRRRRRRRRRRRR\") == 26\n assert candidate(directions = \"SSSSRRRRLLLLRRRRLLLL\") == 16\n assert candidate(directions = \"RRRRRLSLLSLLLL\") == 12\n assert candidate(directions = \"SSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RRRRRSSSSLLLLLLLL\") == 13\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"RLRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 2\n assert candidate(directions = \"SSRRRRRSSSSLLLSSSL\") == 9\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"RLRRLLRLRRLLRLRR\") == 14\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLSSSS\") == 0\n assert candidate(directions = \"RRRRSSSSSSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRL\") == 38\n assert candidate(directions = \"LSRSSRSLLRSRLS\") == 7\n assert candidate(directions = \"LLLLLLRRRRRRLLLLRRRRRR\") == 10\n assert candidate(directions = \"LLLLSSSSRRRRSSSSLLLL\") == 8\n assert candidate(directions = \"SSSSSSSSSSSRRRRRRSSSSSSLLLLLLLLSSSSSSSSSSS\") == 14\n assert candidate(directions = \"RRRSSLRLRLRSLL\") == 11\n assert candidate(directions = \"RSLSLRLSLSLRLSLR\") == 10\n assert candidate(directions = \"SSSSSRRRRRSSSSSLLLLL\") == 10\n assert candidate(directions = \"SSSSRRRRSSSSSSSSSSSSSSSSSSS\") == 4\n assert candidate(directions = \"SSSSRRRRRRLLLLSSSSSLLLL\") == 14\n assert candidate(directions = \"SSLRRRSSLLSL\") == 7\n assert candidate(directions = \"RRSSSLRSLSSSRRSSSLRSL\") == 10\n assert candidate(directions = \"LSLSLSLSLSLSLSLSLRRRRRR\") == 8\n assert candidate(directions = \"LLLLSSRRRRSSSSRRRR\") == 4\n assert candidate(directions = \"RSLSRSLSRSLSRS\") == 7\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RSLRSSLSRSSL\") == 6\n assert candidate(directions = \"LRLRLRLRLRLRLRLRLRLR\") == 18\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRRRR\") == 43\n assert candidate(directions = \"RRRRRSSSLLLLLLLLRRRR\") == 13\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"LLLLRRRRSSSSLLRRRR\") == 6\n assert candidate(directions = \"LRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"LLLSRLRLRLRLRLL\") == 11\n assert candidate(directions = \"RRRRSSSSLLLL\") == 8\n assert candidate(directions = \"RLRLRLRLRLRLRLRLRLRL\") == 20\n assert candidate(directions = \"LLLLRRRRSSSSLLLL\") == 8\n assert candidate(directions = \"LRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLL\") == 46\n assert candidate(directions = \"RRRRRRRRRSSSSSSSLLLLLLLLSSSSSSSSSSSSSSSSSS\") == 17\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRLLSSSSSSSSSSSSSSSSSL\") == 22\n assert candidate(directions = \"RLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL\") == 40\n assert candidate(directions = \"LRRRSLRRRLSLSLLSLRR\") == 12\n assert candidate(directions = \"LRRRLRRLLRLLRLRRRLLR\") == 18\n assert candidate(directions = \"RRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLL\") == 40\n assert candidate(directions = \"SRLRSRLRSRLRSRLRSRLRSRLRSRLRSRLRSRLRSR\") == 27\n assert candidate(directions = \"RRRRRSSLLLLLLLLLL\") == 15\n assert candidate(directions = \"SSSSRRRRLLLLSSSS\") == 8\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"SSSSRRRRLLLLSSSSRRRR\") == 8\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"SRRRRRLRRRRLLSRRRRLLL\") == 19\n assert candidate(directions = \"RRRLLLLLSSSSRRRLLLLL\") == 16\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"RLLLLLRRRRRR\") == 6\n assert candidate(directions = \"RSLRRSLSLSLSLSLSL\") == 10\n assert candidate(directions = \"RLRSLRSLRSLRSLRSLRSLRSLRSLRSLRSLR\") == 22\n assert candidate(directions = \"RRRRRRRRRRLLLLLLLLLL\") == 20\n assert candidate(directions = \"RRRRSSSLLLLLLLRRRRRR\") == 11\n assert candidate(directions = \"SSSSRRRRLLLLLRRRRLLLLLSSSSRRRRLLLLLRRRRLLLLL\") == 36\n assert candidate(directions = \"LLLLLLLLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSRRRR\") == 0\n assert candidate(directions = \"RRRRRRRRRRRRRRSSSLSSSSSSSSSSSSSSSSSSSSSSSL\") == 16\n assert candidate(directions = \"RRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSLLLLLL\") == 12\n assert candidate(directions = \"RRRRLLLLSSSSRRRLLL\") == 14\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"RLRRRLRLRLRLRLRLRLRLRLRLRLRR\") == 26\n assert candidate(directions = \"RRRRRSSSSSSLLLLSSSSSS\") == 9\n assert candidate(directions = \"SSRRRRRLLLLLSS\") == 10\n assert candidate(directions = \"RRRRRRRRRRRRRLLLLLLLLLLLL\") == 25\n assert candidate(directions = \"RRRRRRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSLLLL\") == 14\n assert candidate(directions = \"RSLSLRSLRRSLRSLRL\") == 12\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RSSSSSSRRRRRRRLLLLLLLLLLLLLRRRRRR\") == 21\n assert candidate(directions = \"RLRSLRLRSLRL\") == 10\n"}, "metadata": {"canonical_parameter_names": ["directions"], "leetcode_dataset_entry_point": "Solution().countCollisions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countCollisions(String directions) {", "container": "Solution", "callable": "countCollisions", "parameters": [{"name": "directions", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2212, "task_id": "maximum-points-in-an-archery-competition", "difficulty": "Medium", "problem_description": "Alice and Bob are opponents in an archery competition. The competition has set the following rules:\n\nAlice first shoots numArrows arrows and then Bob shoots numArrows arrows.\nThe points are then calculated as follows:\n\t\nThe target has integer scoring sections ranging from 0 to 11 inclusive.\nFor each section of the target with score k (in between 0 to 11), say Alice and Bob have shot ak and bk arrows on that section respectively. If ak >= bk, then Alice takes k points. If ak < bk, then Bob takes k points.\nHowever, if ak == bk == 0, then nobody takes k points.\n\n\n\n\n\nFor example, if Alice and Bob both shot 2 arrows on the section with score 11, then Alice takes 11 points. On the other hand, if Alice shot 0 arrows on the section with score 11 and Bob shot 2 arrows on that same section, then Bob takes 11 points.\n\n\nYou are given the integer numArrows and an integer array aliceArrows of size 12, which represents the number of arrows Alice shot on each scoring section from 0 to 11. Now, Bob wants to maximize the total number of points he can obtain.\nReturn the array bobArrows which represents the number of arrows Bob shot on each scoring section from 0 to 11. The sum of the values in bobArrows should equal numArrows.\nIf there are multiple ways for Bob to earn the maximum total points, return any one of them.\n \nExample 1:\n\n\nInput: numArrows = 9, aliceArrows = [1,1,0,1,0,0,2,1,0,1,2,0]\nOutput: [0,0,0,0,1,1,0,0,1,2,3,1]\nExplanation: The table above shows how the competition is scored. \nBob earns a total point of 4 + 5 + 8 + 9 + 10 + 11 = 47.\nIt can be shown that Bob cannot obtain a score higher than 47 points.\n\nExample 2:\n\n\nInput: numArrows = 3, aliceArrows = [0,0,1,0,0,0,0,0,0,0,0,2]\nOutput: [0,0,0,0,0,0,0,0,1,1,1,0]\nExplanation: The table above shows how the competition is scored.\nBob earns a total point of 8 + 9 + 10 = 27.\nIt can be shown that Bob cannot obtain a score higher than 27 points.\n\n \nConstraints:\n\n1 <= numArrows <= 105\naliceArrows.length == bobArrows.length == 12\n0 <= aliceArrows[i], bobArrows[i] <= numArrows\nsum(aliceArrows[i]) == numArrows\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(numArrows = 100000,aliceArrows = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == [9991, 0, 0, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001]\n assert candidate(numArrows = 5,aliceArrows = [0, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2]\n assert candidate(numArrows = 15,aliceArrows = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3]\n assert candidate(numArrows = 12,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2]\n assert candidate(numArrows = 20,aliceArrows = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4]\n assert candidate(numArrows = 3,aliceArrows = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0]\n assert candidate(numArrows = 9,aliceArrows = [1, 1, 0, 1, 0, 0, 2, 1, 0, 1, 2, 0]) == [0, 0, 0, 0, 1, 1, 0, 0, 1, 2, 3, 1]\n assert candidate(numArrows = 5,aliceArrows = [2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n assert candidate(numArrows = 10,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(numArrows = 9,aliceArrows = [2, 3, 2, 2, 2, 3, 2, 2, 2, 3, 2, 2]) == [0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 3]\n assert candidate(numArrows = 20,aliceArrows = [3, 0, 2, 1, 4, 0, 2, 1, 3, 0, 2, 1]) == [1, 1, 0, 2, 0, 1, 3, 2, 4, 1, 3, 2]\n assert candidate(numArrows = 100,aliceArrows = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [1, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(numArrows = 50,aliceArrows = [10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0]) == [0, 0, 11, 11, 11, 11, 1, 1, 1, 1, 1, 1]\n assert candidate(numArrows = 80,aliceArrows = [0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15]) == [11, 0, 1, 0, 1, 16, 1, 16, 1, 16, 1, 16]\n assert candidate(numArrows = 85,aliceArrows = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [19, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(numArrows = 72,aliceArrows = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [0, 0, 0, 0, 0, 9, 10, 11, 0, 13, 14, 15]\n assert candidate(numArrows = 99,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [22, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(numArrows = 90,aliceArrows = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == [2, 0, 0, 0, 0, 0, 0, 0, 19, 21, 23, 25]\n assert candidate(numArrows = 25,aliceArrows = [2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3]) == [0, 0, 0, 0, 0, 3, 4, 4, 3, 3, 4, 4]\n assert candidate(numArrows = 30,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 29]) == [10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]\n assert candidate(numArrows = 30,aliceArrows = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [3, 0, 0, 0, 0, 0, 7, 6, 5, 4, 3, 2]\n assert candidate(numArrows = 77,aliceArrows = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == [41, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1]\n assert candidate(numArrows = 85,aliceArrows = [0, 0, 5, 10, 15, 20, 0, 0, 0, 0, 0, 0]) == [24, 1, 6, 11, 16, 21, 1, 1, 1, 1, 1, 1]\n assert candidate(numArrows = 80,aliceArrows = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == [38, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2]\n assert candidate(numArrows = 60,aliceArrows = [2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == [27, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4]\n assert candidate(numArrows = 25,aliceArrows = [0, 0, 0, 0, 5, 4, 3, 2, 1, 0, 0, 0]) == [0, 0, 1, 1, 6, 5, 4, 3, 2, 1, 1, 1]\n assert candidate(numArrows = 66,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 0, 0, 4, 5, 0, 7, 8, 9, 10, 11, 12]\n assert candidate(numArrows = 20,aliceArrows = [1, 3, 2, 4, 1, 2, 3, 4, 2, 1, 3, 2]) == [0, 0, 0, 0, 0, 3, 0, 5, 3, 2, 4, 3]\n assert candidate(numArrows = 50,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50]) == [40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(numArrows = 90,aliceArrows = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 2]\n assert candidate(numArrows = 40,aliceArrows = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0]) == [6, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 1]\n assert candidate(numArrows = 23,aliceArrows = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [2, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(numArrows = 85,aliceArrows = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == [1, 0, 0, 0, 0, 0, 0, 0, 18, 20, 22, 24]\n assert candidate(numArrows = 20,aliceArrows = [1, 3, 2, 5, 0, 0, 4, 3, 1, 2, 3, 1]) == [0, 0, 3, 0, 1, 1, 0, 4, 2, 3, 4, 2]\n assert candidate(numArrows = 20,aliceArrows = [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 4]) == [2, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 5]\n assert candidate(numArrows = 90,aliceArrows = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [3, 0, 0, 0, 0, 0, 0, 41, 46, 0, 0, 0]\n assert candidate(numArrows = 30,aliceArrows = [0, 3, 0, 0, 5, 0, 0, 0, 3, 0, 0, 0]) == [8, 4, 1, 1, 6, 1, 1, 1, 4, 1, 1, 1]\n assert candidate(numArrows = 30,aliceArrows = [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == [0, 0, 0, 4, 3, 2, 1, 2, 3, 4, 5, 6]\n assert candidate(numArrows = 50,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [0, 0, 0, 0, 0, 0, 8, 9, 10, 11, 12, 0]\n assert candidate(numArrows = 75,aliceArrows = [15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [64, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(numArrows = 100,aliceArrows = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [34, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(numArrows = 75,aliceArrows = [10, 5, 5, 5, 10, 5, 5, 5, 10, 5, 5, 5]) == [5, 0, 6, 6, 11, 6, 6, 6, 11, 6, 6, 6]\n assert candidate(numArrows = 60,aliceArrows = [0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10]) == [0, 1, 1, 1, 1, 1, 0, 11, 11, 11, 11, 11]\n assert candidate(numArrows = 15,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]) == [5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(numArrows = 40,aliceArrows = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0]) == [1, 1, 0, 1, 0, 1, 11, 1, 11, 1, 11, 1]\n assert candidate(numArrows = 25,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 0, 0, 0, 0, 0, 7, 8, 0, 10, 0, 0]\n assert candidate(numArrows = 25,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25]) == [15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(numArrows = 120,aliceArrows = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 100]) == [2, 0, 1, 3, 1, 3, 1, 3, 1, 3, 1, 101]\n assert candidate(numArrows = 85,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85]) == [75, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(numArrows = 120,aliceArrows = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == [43, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(numArrows = 40,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1]) == [0, 0, 0, 0, 0, 0, 8, 9, 10, 11, 0, 2]\n assert candidate(numArrows = 20,aliceArrows = [0, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(numArrows = 100,aliceArrows = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [3, 0, 0, 0, 0, 0, 0, 0, 46, 51, 0, 0]\n assert candidate(numArrows = 60,aliceArrows = [0, 5, 0, 0, 0, 0, 5, 0, 0, 0, 0, 5]) == [34, 6, 1, 1, 1, 1, 6, 1, 1, 1, 1, 6]\n assert candidate(numArrows = 8,aliceArrows = [3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == [3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n assert candidate(numArrows = 40,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 0, 0, 0, 0, 0, 0, 8, 9, 0, 11, 12]\n assert candidate(numArrows = 25,aliceArrows = [4, 3, 5, 3, 4, 5, 6, 3, 4, 5, 6, 2]) == [0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 3]\n assert candidate(numArrows = 12,aliceArrows = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3]\n assert candidate(numArrows = 120,aliceArrows = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [104, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]\n assert candidate(numArrows = 30,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 0]\n assert candidate(numArrows = 99,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0]) == [23, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1]\n assert candidate(numArrows = 60,aliceArrows = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10]) == [0, 0, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11]\n assert candidate(numArrows = 20,aliceArrows = [5, 3, 4, 2, 6, 3, 7, 2, 4, 5, 6, 3]) == [0, 0, 0, 0, 0, 0, 0, 3, 0, 6, 7, 4]\n assert candidate(numArrows = 80,aliceArrows = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == [0, 0, 0, 0, 0, 0, 0, 18, 19, 0, 21, 22]\n assert candidate(numArrows = 150,aliceArrows = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [2, 0, 0, 0, 0, 0, 0, 41, 0, 51, 56, 0]\n assert candidate(numArrows = 50,aliceArrows = [0, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0]) == [19, 1, 1, 1, 11, 1, 1, 1, 11, 1, 1, 1]\n assert candidate(numArrows = 60,aliceArrows = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0]) == [29, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1]\n assert candidate(numArrows = 25,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(numArrows = 42,aliceArrows = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 0, 0]\n assert candidate(numArrows = 60,aliceArrows = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == [1, 0, 0, 0, 0, 0, 0, 0, 28, 31, 0, 0]\n assert candidate(numArrows = 20,aliceArrows = [3, 2, 1, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == [0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 0]\n assert candidate(numArrows = 50,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50]) == [40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(numArrows = 88,aliceArrows = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [22, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(numArrows = 70,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70]) == [60, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(numArrows = 100,aliceArrows = [10, 10, 0, 10, 0, 0, 20, 10, 0, 10, 20, 0]) == [9, 11, 1, 11, 1, 1, 21, 11, 1, 11, 21, 1]\n assert candidate(numArrows = 85,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(numArrows = 120,aliceArrows = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72]) == [4, 0, 0, 0, 0, 0, 0, 0, 55, 61, 0, 0]\n assert candidate(numArrows = 50,aliceArrows = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0]) == [29, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(numArrows = 55,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0]) == [0, 0, 0, 0, 6, 7, 8, 0, 10, 11, 12, 1]\n assert candidate(numArrows = 150,aliceArrows = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0]) == [49, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1]\n assert candidate(numArrows = 20,aliceArrows = [0, 3, 1, 2, 0, 4, 1, 0, 5, 2, 1, 1]) == [0, 0, 0, 3, 1, 0, 2, 1, 6, 3, 2, 2]\n assert candidate(numArrows = 60,aliceArrows = [0, 10, 20, 30, 40, 50, 60, 0, 0, 0, 0, 0]) == [3, 0, 21, 31, 0, 0, 0, 1, 1, 1, 1, 1]\n assert candidate(numArrows = 100,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [12, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(numArrows = 120,aliceArrows = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [43, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(numArrows = 50,aliceArrows = [10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0]) == [10, 0, 11, 11, 11, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(numArrows = 40,aliceArrows = [2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 1, 0]) == [21, 1, 2, 1, 4, 1, 3, 1, 2, 1, 2, 1]\n assert candidate(numArrows = 60,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60]) == [50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(numArrows = 50,aliceArrows = [0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [2, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(numArrows = 90,aliceArrows = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [46, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(numArrows = 75,aliceArrows = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [9, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(numArrows = 75,aliceArrows = [0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20, 20]) == [7, 1, 1, 1, 1, 1, 0, 0, 0, 21, 21, 21]\n assert candidate(numArrows = 100,aliceArrows = [10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0]) == [49, 11, 11, 11, 11, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(numArrows = 18,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1]) == [0, 0, 0, 0, 0, 7, 0, 9, 0, 0, 0, 2]\n assert candidate(numArrows = 30,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == [1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 11]\n assert candidate(numArrows = 75,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(numArrows = 10,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 1]\n assert candidate(numArrows = 100,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [78, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(numArrows = 60,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [38, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(numArrows = 7,aliceArrows = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 2, 2]\n assert candidate(numArrows = 100,aliceArrows = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(numArrows = 30,aliceArrows = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == [0, 0, 0, 0, 0, 0, 14, 16, 0, 0, 0, 0]\n assert candidate(numArrows = 90,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [13, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(numArrows = 30,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(numArrows = 100,aliceArrows = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0]) == [44, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]\n assert candidate(numArrows = 10,aliceArrows = [3, 1, 2, 2, 3, 1, 4, 2, 3, 4, 5, 1]) == [0, 0, 0, 0, 0, 0, 0, 3, 0, 5, 0, 2]\n assert candidate(numArrows = 60,aliceArrows = [3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 2, 3, 4, 0, 6, 7, 8, 9, 10, 11]\n assert candidate(numArrows = 75,aliceArrows = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6]) == [43, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7]\n assert candidate(numArrows = 120,aliceArrows = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [43, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(numArrows = 100,aliceArrows = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == [64, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1]\n"}, "metadata": {"canonical_parameter_names": ["numArrows", "aliceArrows"], "leetcode_dataset_entry_point": "Solution().maximumBobPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] maximumBobPoints(int numArrows, int[] aliceArrows) {", "container": "Solution", "callable": "maximumBobPoints", "parameters": [{"name": "numArrows", "type": "int"}, {"name": "aliceArrows", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2213, "task_id": "longest-substring-of-one-repeating-character", "difficulty": "Hard", "problem_description": "You are given a 0-indexed string s. You are also given a 0-indexed string queryCharacters of length k and a 0-indexed array of integer indices queryIndices of length k, both of which are used to describe k queries.\nThe ith query updates the character in s at index queryIndices[i] to the character queryCharacters[i].\nReturn an array lengths of length k where lengths[i] is the length of the longest substring of s consisting of only one repeating character after the ith query is performed.\n \nExample 1:\n\nInput: s = \"babacc\", queryCharacters = \"bcb\", queryIndices = [1,3,3]\nOutput: [3,3,4]\nExplanation: \n- 1st query updates s = \"bbbacc\". The longest substring consisting of one repeating character is \"bbb\" with length 3.\n- 2nd query updates s = \"bbbccc\". \n The longest substring consisting of one repeating character can be \"bbb\" or \"ccc\" with length 3.\n- 3rd query updates s = \"bbbbcc\". The longest substring consisting of one repeating character is \"bbbb\" with length 4.\nThus, we return [3,3,4].\n\nExample 2:\n\nInput: s = \"abyzz\", queryCharacters = \"aa\", queryIndices = [2,1]\nOutput: [2,3]\nExplanation:\n- 1st query updates s = \"abazz\". The longest substring consisting of one repeating character is \"zz\" with length 2.\n- 2nd query updates s = \"aaazz\". The longest substring consisting of one repeating character is \"aaa\" with length 3.\nThus, we return [2,3].\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of lowercase English letters.\nk == queryCharacters.length == queryIndices.length\n1 <= k <= 105\nqueryCharacters consists of lowercase English letters.\n0 <= queryIndices[i] < s.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcde\",queryCharacters = \"aaaaa\",queryIndices = [0, 1, 2, 3, 4]) == [1, 2, 3, 4, 5]\n assert candidate(s = \"abyzz\",queryCharacters = \"aa\",queryIndices = [2, 1]) == [2, 3]\n assert candidate(s = \"abcde\",queryCharacters = \"ee\",queryIndices = [2, 4]) == [1, 1]\n assert candidate(s = \"zzzzz\",queryCharacters = \"abcd\",queryIndices = [0, 1, 2, 3]) == [4, 3, 2, 1]\n assert candidate(s = \"babacc\",queryCharacters = \"bcb\",queryIndices = [1, 3, 3]) == [3, 3, 4]\n assert candidate(s = \"abcde\",queryCharacters = \"ee\",queryIndices = [0, 4]) == [1, 1]\n assert candidate(s = \"aaaaa\",queryCharacters = \"bb\",queryIndices = [1, 3]) == [3, 1]\n assert candidate(s = \"z\",queryCharacters = \"z\",queryIndices = [0]) == [1]\n assert candidate(s = \"zzzzz\",queryCharacters = \"xy\",queryIndices = [0, 4]) == [4, 3]\n assert candidate(s = \"aaaaa\",queryCharacters = \"b\",queryIndices = [2]) == [2]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",queryCharacters = \"zzzzzzzzzzzzzzzzzzzz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(s = \"ababababab\",queryCharacters = \"aaaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 3, 3, 5, 5, 7, 7, 9, 9, 10]\n assert candidate(s = \"abcdefghij\",queryCharacters = \"jjjjjjjjjj\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 10, 10]\n assert candidate(s = \"abcdefg\",queryCharacters = \"hijklmn\",queryIndices = [0, 1, 2, 3, 4, 5, 6]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(s = \"abacabadabacaba\",queryCharacters = \"aaaaaaaaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15]\n assert candidate(s = \"zzzaaabbbccc\",queryCharacters = \"aaabbbccc\",queryIndices = [2, 3, 4, 5, 6, 7, 8]) == [4, 4, 4, 4, 4, 4, 4]\n assert candidate(s = \"aabbccddeeffgghhiijjkk\",queryCharacters = \"llll\",queryIndices = [2, 4, 6, 8]) == [2, 2, 2, 2]\n assert candidate(s = \"zzzzzzzzzz\",queryCharacters = \"yyyyyyyyyy\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 8, 7, 6, 5, 6, 7, 8, 9, 10]\n assert candidate(s = \"aabbaabb\",queryCharacters = \"cccc\",queryIndices = [1, 3, 5, 7]) == [2, 2, 2, 1]\n assert candidate(s = \"pppqqqrrrsssttt\",queryCharacters = \"uuuuuuuuuuuuuuu\",queryIndices = [2, 5, 8, 11, 14, 2, 5, 8, 11, 14, 2, 5, 8, 11, 14]) == [3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(s = \"abacabadabacabadabacabadabacabad\",queryCharacters = \"abacabadabacabadabacabadabacabad\",queryIndices = [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]) == [1, 1, 1, 1, 1, 1, 1, 1, 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(s = \"xyzzxxxyyy\",queryCharacters = \"zzz\",queryIndices = [1, 3, 5]) == [3, 3, 3]\n assert candidate(s = \"abababababababab\",queryCharacters = \"cccccccc\",queryIndices = [0, 2, 4, 6, 8, 10, 12, 14]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(s = \"mnopqrstu\",queryCharacters = \"aaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(s = \"abcdefghij\",queryCharacters = \"z\",queryIndices = [5]) == [1]\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\",queryCharacters = \"dddddddddddddddddddddddddddd\",queryIndices = [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]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]\n assert candidate(s = \"aaabbbccc\",queryCharacters = \"dddddd\",queryIndices = [0, 3, 6, 1, 4, 7]) == [3, 3, 2, 2, 2, 2]\n assert candidate(s = \"aabaaa\",queryCharacters = \"bbccc\",queryIndices = [1, 1, 3, 3, 4]) == [3, 3, 2, 2, 2]\n assert candidate(s = \"abcabcabc\",queryCharacters = \"aaa\",queryIndices = [0, 3, 6]) == [1, 1, 1]\n assert candidate(s = \"abcabcabc\",queryCharacters = \"ddddddd\",queryIndices = [0, 3, 6, 1, 4, 7, 2]) == [1, 1, 1, 2, 2, 2, 5]\n assert candidate(s = \"aabbaa\",queryCharacters = \"bb\",queryIndices = [0, 4]) == [2, 3]\n assert candidate(s = \"abcdabcdabcdabcd\",queryCharacters = \"zzzz\",queryIndices = [1, 3, 5, 7]) == [1, 1, 1, 1]\n assert candidate(s = \"abcabcabcabc\",queryCharacters = \"dddddddddddd\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(s = \"aaaaabbbbbccccc\",queryCharacters = \"dddddeeee\",queryIndices = [1, 3, 5, 7, 9]) == [5, 5, 5, 5, 5]\n assert candidate(s = \"mississippi\",queryCharacters = \"llll\",queryIndices = [0, 1, 2, 3]) == [2, 2, 3, 4]\n assert candidate(s = \"xyxxyxyxyx\",queryCharacters = \"zzzzzzzzzz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [2, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(s = \"aabbbccccc\",queryCharacters = \"bbb\",queryIndices = [2, 3, 7]) == [5, 5, 3]\n assert candidate(s = \"abccba\",queryCharacters = \"bbccc\",queryIndices = [2, 3, 2, 3, 4]) == [2, 4, 2, 2, 3]\n assert candidate(s = \"xyxyxyxyxyxy\",queryCharacters = \"zzzzzzzzzzzz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(s = \"aaaaaaaaaa\",queryCharacters = \"bbbbbbbbbb\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 8, 7, 6, 5, 6, 7, 8, 9, 10]\n assert candidate(s = \"abcdefg\",queryCharacters = \"zzzzzzz\",queryIndices = [6, 5, 4, 3, 2, 1, 0]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",queryCharacters = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",queryIndices = [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]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 26]\n assert candidate(s = \"mmmmnnnnoooo\",queryCharacters = \"ppppqqqqrrrr\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(s = \"abccba\",queryCharacters = \"cccccc\",queryIndices = [1, 2, 3, 4, 5, 0]) == [3, 3, 3, 4, 5, 6]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",queryCharacters = \"abcdefghijklmnopqrstuvwxyz\",queryIndices = [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]) == [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, 19]\n assert candidate(s = \"abcdefghij\",queryCharacters = \"abcdefghij\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(s = \"abcdeabcdeabcdeabcde\",queryCharacters = \"abcdeabcdeabcdeabcde\",queryIndices = [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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(s = \"aabbccddeeffgg\",queryCharacters = \"hhhhhhhh\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7]) == [2, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(s = \"aabbcc\",queryCharacters = \"ffffff\",queryIndices = [0, 1, 2, 3, 4, 5]) == [2, 2, 3, 4, 5, 6]\n assert candidate(s = \"ppppqqqqrrrrssss\",queryCharacters = \"ttttuuuuvvvv\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(s = \"mmmmmmmmmm\",queryCharacters = \"llllllllll\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 8, 7, 6, 5, 6, 7, 8, 9, 10]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",queryCharacters = \"abcdefghijklmnopqrstuvwxyz\",queryIndices = [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]) == [1, 1, 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(s = \"aaaaaaaabbbbbbbbccccccccdddddddd\",queryCharacters = \"ddddddddccccccccbbbbbbbbaaaaaaaa\",queryIndices = [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]) == [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(s = \"xyxyxyxyxyx\",queryCharacters = \"yyyyy\",queryIndices = [1, 3, 5, 7, 9]) == [1, 1, 1, 1, 1]\n assert candidate(s = \"abcdefghij\",queryCharacters = \"jjjjj\",queryIndices = [8, 7, 6, 5, 4]) == [2, 3, 4, 5, 6]\n assert candidate(s = \"abcdefghij\",queryCharacters = \"aaaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(s = \"abcdefghijabcdefghij\",queryCharacters = \"jjjjjjjjjj\",queryIndices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [2, 3, 4, 5, 6, 7, 8, 9, 11, 11]\n assert candidate(s = \"abababababab\",queryCharacters = \"cccc\",queryIndices = [0, 2, 4, 6]) == [1, 1, 1, 1]\n assert candidate(s = \"aabbccddeeff\",queryCharacters = \"abcdef\",queryIndices = [1, 3, 5, 7, 9, 11]) == [2, 2, 2, 2, 2, 2]\n assert candidate(s = \"abacaba\",queryCharacters = \"aaaaa\",queryIndices = [1, 2, 3, 4, 5]) == [3, 3, 5, 5, 7]\n assert candidate(s = \"aaaabbbbccccdddd\",queryCharacters = \"ddddccccbbbbaaaaff\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [4, 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(s = \"xyzxyzxyzxyz\",queryCharacters = \"zzzz\",queryIndices = [0, 1, 2, 3]) == [1, 3, 3, 4]\n assert candidate(s = \"zzzzzzzzzz\",queryCharacters = \"aaaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 8, 7, 6, 5, 6, 7, 8, 9, 10]\n assert candidate(s = \"abcdabcdabcd\",queryCharacters = \"aaaabbbb\",queryIndices = [0, 1, 8, 9, 4, 5, 10, 11]) == [1, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(s = \"aabbccddeeff\",queryCharacters = \"hhhhhhh\",queryIndices = [1, 3, 5, 7, 9, 11, 1]) == [2, 2, 2, 2, 2, 1, 1]\n assert candidate(s = \"aabbccddeeff\",queryCharacters = \"zzzzzz\",queryIndices = [1, 3, 5, 7, 9, 11]) == [2, 2, 2, 2, 2, 1]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",queryCharacters = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",queryIndices = [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]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 26]\n assert candidate(s = \"aabbaa\",queryCharacters = \"cccccc\",queryIndices = [0, 1, 2, 3, 4, 5]) == [2, 2, 3, 4, 5, 6]\n assert candidate(s = \"zzzzzzyyyyy\",queryCharacters = \"xyyxz\",queryIndices = [0, 5, 6, 7, 10]) == [5, 6, 6, 4, 4]\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbbcccccccccc\",queryCharacters = \"dddddddddd\",queryIndices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [11, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(s = \"abacabadabacaba\",queryCharacters = \"zzzzzzzzzzz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(s = \"abababab\",queryCharacters = \"bbbbbbbb\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7]) == [2, 2, 4, 4, 6, 6, 8, 8]\n assert candidate(s = \"abacabadabacaba\",queryCharacters = \"ccccccc\",queryIndices = [0, 1, 2, 3, 4, 5, 6]) == [1, 2, 4, 4, 5, 6, 7]\n assert candidate(s = \"aabbccddeeff\",queryCharacters = \"gggggg\",queryIndices = [0, 1, 2, 3, 4, 5]) == [2, 2, 3, 4, 5, 6]\n assert candidate(s = \"zzzzzzzzzzzz\",queryCharacters = \"aaaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [11, 10, 9, 8, 7, 6, 7, 8, 9, 10]\n assert candidate(s = \"abccbaabc\",queryCharacters = \"cccc\",queryIndices = [2, 3, 5, 6]) == [2, 2, 2, 2]\n assert candidate(s = \"xyxyxyxyxyx\",queryCharacters = \"aaaaaa\",queryIndices = [0, 2, 4, 6, 8, 10]) == [1, 1, 1, 1, 1, 1]\n assert candidate(s = \"acacacacacacacacacacacaca\",queryCharacters = \"bbbbbbbbbbbbbbbbbbbbbbb\",queryIndices = [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]) == [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 = \"zzzzyyyxxxxwwwwvvvuuutttsssrrrqqqppponnmlkkjjjiii\",queryCharacters = \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\",queryIndices = [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]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 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]\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",queryCharacters = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",queryIndices = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 0, 3, 6, 9, 12, 15, 18, 21, 24, 27]) == [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": ["s", "queryCharacters", "queryIndices"], "leetcode_dataset_entry_point": "Solution().longestRepeating", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] longestRepeating(String s, String queryCharacters, int[] queryIndices) {", "container": "Solution", "callable": "longestRepeating", "parameters": [{"name": "s", "type": "String"}, {"name": "queryCharacters", "type": "String"}, {"name": "queryIndices", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2215, "task_id": "find-the-difference-of-two-arrays", "difficulty": "Easy", "problem_description": "Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where:\n\nanswer[0] is a list of all distinct integers in nums1 which are not present in nums2.\nanswer[1] is a list of all distinct integers in nums2 which are not present in nums1.\n\nNote that the integers in the lists may be returned in any order.\n \nExample 1:\n\nInput: nums1 = [1,2,3], nums2 = [2,4,6]\nOutput: [[1,3],[4,6]]\nExplanation:\nFor nums1, nums1[1] = 2 is present at index 0 of nums2, whereas nums1[0] = 1 and nums1[2] = 3 are not present in nums2. Therefore, answer[0] = [1,3].\nFor nums2, nums2[0] = 2 is present at index 1 of nums1, whereas nums2[1] = 4 and nums2[2] = 6 are not present in nums2. Therefore, answer[1] = [4,6].\nExample 2:\n\nInput: nums1 = [1,2,3,3], nums2 = [1,1,2,2]\nOutput: [[3],[]]\nExplanation:\nFor nums1, nums1[2] and nums1[3] are not present in nums2. Since nums1[2] == nums1[3], their value is only included once and answer[0] = [3].\nEvery integer in nums2 is present in nums1. Therefore, answer[1] = [].\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 1000\n-1000 <= nums1[i], nums2[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [0, -1, -2],nums2 = [1, -1, 2]) == [[0, -2], [1, 2]]\n assert candidate(nums1 = [5, 7, 8],nums2 = [9, 10, 5]) == [[8, 7], [9, 10]]\n assert candidate(nums1 = [1, 2, 3],nums2 = []) == [[1, 2, 3], []]\n assert candidate(nums1 = [10, 20, 30],nums2 = [5, 15, 25, 35]) == [[10, 20, 30], [25, 35, 5, 15]]\n assert candidate(nums1 = [5, 7, 8],nums2 = [9, 10, 11]) == [[8, 5, 7], [9, 10, 11]]\n assert candidate(nums1 = [1000, -1000],nums2 = [-1000, 1000]) == [[], []]\n assert candidate(nums1 = [1000, -1000],nums2 = [-1000, 1000]) == [[], []]\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == [[], []]\n assert candidate(nums1 = [1, 3, 5, 7],nums2 = [2, 4, 6, 8]) == [[1, 3, 5, 7], [8, 2, 4, 6]]\n assert candidate(nums1 = [1, 2, 3, 3],nums2 = [1, 1, 2, 2]) == [[3], []]\n assert candidate(nums1 = [100, 200, 300],nums2 = [100, 200, 300]) == [[], []]\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 2, 2, 2]) == [[1], [2]]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]\n assert candidate(nums1 = [],nums2 = [1, 2, 3]) == [[], [1, 2, 3]]\n assert candidate(nums1 = [-1, -2, -3],nums2 = [-3, -4, -5]) == [[-1, -2], [-5, -4]]\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 40, 50]) == [[10, 20], [40, 50]]\n assert candidate(nums1 = [5, 7, 9],nums2 = [5, 8, 10]) == [[9, 7], [8, 10]]\n assert candidate(nums1 = [-1, -2, -3],nums2 = [-2, -3, -4]) == [[-1], [-4]]\n assert candidate(nums1 = [1],nums2 = [2]) == [[1], [2]]\n assert candidate(nums1 = [-1000, 0, 1000],nums2 = [0]) == [[-1000, 1000], []]\n assert candidate(nums1 = [5, 6, 7],nums2 = [7, 8, 9]) == [[5, 6], [8, 9]]\n assert candidate(nums1 = [1, 2, 3],nums2 = [2, 4, 6]) == [[1, 3], [4, 6]]\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == [[1, 2, 3], [4, 5, 6]]\n assert candidate(nums1 = [-1, 0, 1],nums2 = [0, 1, 2]) == [[-1], [2]]\n assert candidate(nums1 = [0],nums2 = [0]) == [[], []]\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == [[], []]\n assert candidate(nums1 = [10, 20, 30],nums2 = [15, 25, 35]) == [[10, 20, 30], [25, 35, 15]]\n assert candidate(nums1 = [-1, -2, -3, -4, -5, 0, 5, 10],nums2 = [-5, -4, -3, -2, -1, 0, 1, 2]) == [[10, 5], [1, 2]]\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0]) == [[], []]\n assert candidate(nums1 = [6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5]) == [[6, 7, 8, 9, 10], [1, 2, 3, 4, 5]]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [4, 4, 5, 5, 6, 6, 7, 7]) == [[1, 2, 3], [5, 6, 7]]\n assert candidate(nums1 = [-5, -10, -15, -20],nums2 = [-10, -15, -20, -25]) == [[-5], [-25]]\n assert candidate(nums1 = [1000, 999, 998, 997, 996],nums2 = [996, 995, 994, 993, 992]) == [[1000, 997, 998, 999], [992, 993, 994, 995]]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [2, 2, 3, 3, 5, 5, 6, 6]) == [[1, 4], [5, 6]]\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [30, 40, 50, 60]) == [[10, 20], [50, 60]]\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]) == [[1, 2, 3, 4], [11, 12, 13, 14]]\n assert candidate(nums1 = [1000, 999, 998],nums2 = [1000, 1001, 1002, 998]) == [[999], [1001, 1002]]\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]) == [[], []]\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, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], []]\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5]) == [[], []]\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [100, 200, 300, 400, 500]) == [[], []]\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [200, 400, 600, 800, 1000]) == [[100, 500, 300], [800, 1000, 600]]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9]) == [[2, 4, 6, 8, 10], []]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [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(nums1 = [0, 0, 0, 0],nums2 = [1, 1, 1, 1]) == [[0], [1]]\n assert candidate(nums1 = [-1, -2, -3, -4],nums2 = [-3, -4, -5, -6]) == [[-1, -2], [-6, -5]]\n assert candidate(nums1 = [1, 2, 2, 3, 4, 4, 5],nums2 = [2, 4, 6, 7, 8, 8, 9]) == [[1, 3, 5], [8, 9, 6, 7]]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [2, 2, 4, 4, 5, 5]) == [[1, 3], [4, 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]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]\n assert candidate(nums1 = [1, 2, 3],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [[], [4, 5, 6, 7, 8, 9, 10]]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [[], [35, 45, 15, 55, 25]]\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], []]\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [300, 400, 500, 600]) == [[200, 100], [600, 500]]\n assert candidate(nums1 = [-1000, -999, -998],nums2 = [-1000, -999, -997]) == [[-998], [-997]]\n assert candidate(nums1 = [1000, -1000, 0, 500, -500],nums2 = [-1000, 0, 500, -500, 1000]) == [[], []]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14, 16]]\n assert candidate(nums1 = [100, -50, 0, 200, 300],nums2 = [-50, 0, 100, 400, 500]) == [[200, 300], [400, 500]]\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [[], []]\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [100, 300, 500, 600]) == [[200, 400], [600, 500]]\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [-5, -4, -3, -2, -1]) == [[], []]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == [[], []]\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 1, 2, 3, 4, 5]) == [[], [1, 2, 3, 4, 5]]\n assert candidate(nums1 = [-1, 0, 1],nums2 = [0, -1, 2]) == [[1], [2]]\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [[1], [2]]\n assert candidate(nums1 = [-1000, -500, 0, 500, 1000],nums2 = [-1000, -500, 0, 500, 1000]) == [[], []]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [-1000, -900, -800, -700, -600, -500, -400, -300, -200, -100]) == [[800, 900, 100, 1000, 200, 300, 400, 500, 600, 700], [-800, -700, -600, -500, -400, -900, -300, -200, -1000, -100]]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [3, 3, 4, 4, 5, 5]) == [[1, 2], [4, 5]]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [[100, 70, 40, 10, 80, 50, 20, 90, 60, 30], [65, 35, 5, 75, 45, 15, 85, 55, 25, 95]]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 60, 70, 80, 90]) == [[40, 10, 20, 30], [80, 90, 60, 70]]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45, 55]) == [[40, 10, 50, 20, 30], [35, 5, 45, 15, 55, 25]]\n assert candidate(nums1 = [500, 501, 502, 503, 504],nums2 = [502, 503, 504, 505, 506]) == [[500, 501], [505, 506]]\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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [[], []]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == [[40, 10, 50, 20, 30], [35, 5, 45, 15, 25]]\n assert candidate(nums1 = [-1000, 1000, 0],nums2 = [0, -1000, 1000]) == [[], []]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10, 12]) == [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12]]\n assert candidate(nums1 = [100, 200, 300],nums2 = [300, 200, 100, 400, 500]) == [[], [400, 500]]\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, 3, 5, 7, 9], [12, 14, 16, 18, 20]]\n assert candidate(nums1 = [],nums2 = [1, 2, 3, 4, 5]) == [[], [1, 2, 3, 4, 5]]\n assert candidate(nums1 = [500, 501, 502, 503, 504, 505],nums2 = [503, 504, 505, 506, 507, 508]) == [[500, 501, 502], [506, 507, 508]]\n assert candidate(nums1 = [-1, -2, -3],nums2 = [-3, -4, -5]) == [[-1, -2], [-5, -4]]\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10]) == [[], []]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [[], []]\n assert candidate(nums1 = [100, -50, 200, 300, -100],nums2 = [-50, 200, 400, 500, -100]) == [[100, 300], [400, 500]]\n assert candidate(nums1 = [1000, 500, -500, -1000],nums2 = [500, -500, 1000, -1000]) == [[], []]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9]) == [[1, 2, 3, 4], [8, 9, 6, 7]]\n assert candidate(nums1 = [1000, -1000, 500, -500, 0],nums2 = [0, 500, -500, 1000, -1000]) == [[], []]\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == [[], []]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [[], []]\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 40, 50, 10, 20]) == [[], [40, 50]]\n assert candidate(nums1 = [500, 600, 700],nums2 = [800, 900, 1000, 500, 600]) == [[700], [800, 1000, 900]]\n assert candidate(nums1 = [100, -50, 23, 7, 3, 100],nums2 = [-50, 23, 8, 9, 100, 101]) == [[3, 7], [8, 9, 101]]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == [[], []]\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9, 0]) == [[1, 2, 3, 4], [8, 9, 6, 7]]\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [150, 250, 350, 450, 550]) == [[100, 200, 300, 400, 500], [450, 550, 150, 250, 350]]\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 600, 700, 800, 900]) == [[200, 100, 400, 300], [800, 700, 600, 900]]\n assert candidate(nums1 = [-10, -20, -30],nums2 = [-30, -40, -50, -10]) == [[-20], [-40, -50]]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [100, 200, 300, 500]) == [[400], [500]]\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [101, 201, 301, 401, 501]) == [[100, 200, 300, 400, 500], [101, 201, 301, 401, 501]]\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [-5, -6, -7, -8, -9]) == [[-4, -3, -2, -1], [-8, -7, -6, -9]]\n assert candidate(nums1 = [0, -1, -2, -3, -4],nums2 = [-2, -4, -6, -8, -10]) == [[0, -3, -1], [-8, -6, -10]]\n assert candidate(nums1 = [100, 200, 300],nums2 = [100, 200, 300, 400, 500]) == [[], [400, 500]]\n assert candidate(nums1 = [-1, -2, -3, -4],nums2 = [-4, -5, -6, -7]) == [[-3, -1, -2], [-7, -6, -5]]\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [3, 4, 5, 6, 7, 8]) == [[0, 1, 2], [8, 6, 7]]\n assert candidate(nums1 = [-1000, -500, 0, 500, 1000],nums2 = [1000, 500, 0, -500, -1000]) == [[], []]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55]) == [[40, 10, 50, 20, 30], [35, 45, 15, 55, 25]]\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46]) == [[35, 5, 40, 10, 45, 15, 50, 20, 25, 30], [1, 36, 6, 41, 11, 46, 16, 21, 26, 31]]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = []) == [[1, 2, 3, 4, 5], []]\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],nums2 = [3, 3, 4, 4, 5, 5, 6, 6]) == [[1, 2], [5, 6]]\n assert candidate(nums1 = [-1000, -999, -998, -997],nums2 = [-999, -998, -997, -996]) == [[-1000], [-996]]\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().findDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List> findDifference(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "findDifference", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "List>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2216, "task_id": "minimum-deletions-to-make-array-beautiful", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. The array nums is beautiful if:\n\nnums.length is even.\nnums[i] != nums[i + 1] for all i % 2 == 0.\n\nNote that an empty array is considered beautiful.\nYou can delete any number of elements from nums. When you delete an element, all the elements to the right of the deleted element will be shifted one unit to the left to fill the gap created and all the elements to the left of the deleted element will remain unchanged.\nReturn the minimum number of elements to delete from nums to make it beautiful.\n \nExample 1:\n\nInput: nums = [1,1,2,3,5]\nOutput: 1\nExplanation: You can delete either nums[0] or nums[1] to make nums = [1,2,3,5] which is beautiful. It can be proven you need at least 1 deletion to make nums beautiful.\n\nExample 2:\n\nInput: nums = [1,1,2,2,3,3]\nOutput: 2\nExplanation: You can delete nums[0] and nums[5] to make nums = [1,2,2,3] which is beautiful. It can be proven you need at least 2 deletions to make nums beautiful.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 2\n assert candidate(nums = [100000, 100000, 99999, 99999, 99998, 99998]) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2]) == 6\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 1\n assert candidate(nums = []) == 0\n assert candidate(nums = [0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4]) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 2, 3, 5]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 1\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == 5\n assert candidate(nums = [1, 3, 2, 3, 3, 2]) == 0\n assert candidate(nums = [1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5]) == 16\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5]) == 2\n assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 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, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 24\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 10\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]) == 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]) == 20\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 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]) == 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]) == 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, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 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]) == 20\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, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 12\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 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]) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 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, 8, 8, 8, 9, 9, 9]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 13, 14]) == 4\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]) == 0\n assert candidate(nums = [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, 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]) == 12\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, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 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]) == 2\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 0, 1, 1, 2, 2]) == 2\n assert candidate(nums = [1, 2, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 2\n assert candidate(nums = [5, 5, 4, 4, 4, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0]) == 6\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 9]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 1\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 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, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 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]) == 30\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\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 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]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5]) == 8\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\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, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 8\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 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]) == 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]) == 25\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]) == 1\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 1\n assert candidate(nums = [1, 2, 3, 3, 4, 5, 5, 6, 7, 8]) == 2\n assert candidate(nums = [100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 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]) == 0\n assert candidate(nums = [100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996, 99996, 99995, 99995, 99994, 99994, 99993, 99993, 99992, 99992, 99991, 99991, 99990, 99990, 99989, 99989, 99988, 99988]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 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, 10]) == 15\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 82\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 12\n assert candidate(nums = [1, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2]) == 8\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 6\n assert candidate(nums = [1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 13\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, 1, 2]) == 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]) == 2\n assert candidate(nums = [1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [1, 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, 5, 5]) == 12\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, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5]) == 8\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]) == 22\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]) == 0\n assert candidate(nums = [100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997]) == 2\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5]) == 2\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 3\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 6\n assert candidate(nums = [1, 2, 3, 3, 3, 4, 5, 5, 5, 6, 6, 6, 7, 8, 9, 9, 9]) == 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]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10]) == 5\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]) == 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == 3\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11]) == 0\n assert candidate(nums = [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, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 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]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\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]) == 1\n assert candidate(nums = [100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996, 99996]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 1\n assert candidate(nums = [1, 2, 3, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10]) == 5\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 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, 5]) == 31\n assert candidate(nums = [1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10]) == 3\n assert candidate(nums = [1, 2, 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\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minDeletion", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minDeletion(int[] nums) {", "container": "Solution", "callable": "minDeletion", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2217, "task_id": "find-palindrome-with-fixed-length", "difficulty": "Medium", "problem_description": "Given an integer array queries and a positive integer intLength, return an array answer where answer[i] is either the queries[i]th smallest positive palindrome of length intLength or -1 if no such palindrome exists.\nA palindrome is a number that reads the same backwards and forwards. Palindromes cannot have leading zeros.\n \nExample 1:\n\nInput: queries = [1,2,3,4,5,90], intLength = 3\nOutput: [101,111,121,131,141,999]\nExplanation:\nThe first few palindromes of length 3 are:\n101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, ...\nThe 90th palindrome of length 3 is 999.\n\nExample 2:\n\nInput: queries = [2,4,6], intLength = 4\nOutput: [1111,1331,1551]\nExplanation:\nThe first six palindromes of length 4 are:\n1001, 1111, 1221, 1331, 1441, and 1551.\n\n \nConstraints:\n\n1 <= queries.length <= 5 * 104\n1 <= queries[i] <= 109\n1 <= intLength <= 15\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(queries = [10, 20, 30],intLength = 2) == [-1, -1, -1]\n assert candidate(queries = [1, 3, 5, 7, 9],intLength = 5) == [10001, 10201, 10401, 10601, 10801]\n assert candidate(queries = [50000],intLength = 15) == [100499999994001]\n assert candidate(queries = [1, 1000000],intLength = 15) == [100000000000001, 109999999999901]\n assert candidate(queries = [1, 2, 3, 4, 5, 90],intLength = 3) == [101, 111, 121, 131, 141, 999]\n assert candidate(queries = [10, 20, 30],intLength = 6) == [109901, 119911, 129921]\n assert candidate(queries = [2, 4, 6],intLength = 4) == [1111, 1331, 1551]\n assert candidate(queries = [100, 200, 300],intLength = 7) == [1099901, 1199911, 1299921]\n assert candidate(queries = [1, 10, 100, 1000],intLength = 7) == [1000001, 1009001, 1099901, 1999991]\n assert candidate(queries = [10, 20, 30],intLength = 6) == [109901, 119911, 129921]\n assert candidate(queries = [100, 200, 300],intLength = 7) == [1099901, 1199911, 1299921]\n assert candidate(queries = [1, 1, 1, 1],intLength = 1) == [1, 1, 1, 1]\n assert candidate(queries = [1, 100000000],intLength = 1) == [1, -1]\n assert candidate(queries = [5000000],intLength = 1) == [-1]\n assert candidate(queries = [1000000000],intLength = 15) == [-1]\n assert candidate(queries = [1, 10, 100, 1000, 10000],intLength = 5) == [10001, 10901, 19991, -1, -1]\n assert candidate(queries = [100000],intLength = 15) == [100999999999001]\n assert candidate(queries = [1, 2, 3],intLength = 1) == [1, 2, 3]\n assert candidate(queries = [5, 15, 25],intLength = 2) == [55, -1, -1]\n assert candidate(queries = [123456, 654321],intLength = 10) == [-1, -1]\n assert candidate(queries = [50000, 100000, 150000, 200000, 250000, 300000, 350000, 400000],intLength = 13) == [1049999999401, 1099999999901, 1149999999411, 1199999999911, 1249999999421, 1299999999921, 1349999999431, 1399999999931]\n assert candidate(queries = [100, 1000, 10000, 100000, 1000000],intLength = 15) == [100000999000001, 100009999900001, 100099999990001, 100999999999001, 109999999999901]\n assert candidate(queries = [1, 9, 99, 999, 9999, 99999],intLength = 15) == [100000000000001, 100000080000001, 100000989000001, 100009989900001, 100099989990001, 100999989999001]\n assert candidate(queries = [1, 10, 100, 1000, 10000, 100000],intLength = 3) == [101, 191, -1, -1, -1, -1]\n assert candidate(queries = [90000000, 95000000, 99000000],intLength = 15) == [999999999999999, -1, -1]\n assert candidate(queries = [123456789],intLength = 15) == [-1]\n assert candidate(queries = [1, 123456, 987654, 999999],intLength = 5) == [10001, -1, -1, -1]\n assert candidate(queries = [98765, 43210, 54321, 67890],intLength = 5) == [-1, -1, -1, -1]\n assert candidate(queries = [1000000, 2000000, 3000000, 4000000, 5000000],intLength = 11) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],intLength = 5) == [10001, 10101, 10201, 10301, 10401, 10501, 10601, 10701, 10801, 10901]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],intLength = 15) == [100000000000001, 100000010000001, 100000020000001, 100000030000001, 100000040000001, 100000050000001, 100000060000001, 100000070000001, 100000080000001, 100000090000001]\n assert candidate(queries = [123, 456, 789, 101112, 131415],intLength = 11) == [10012221001, 10045554001, 10078887001, 20111111102, 23141414132]\n assert candidate(queries = [1, 10, 100, 1000, 10000],intLength = 9) == [100000001, 100090001, 100999001, 109999901, 199999991]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],intLength = 9) == [100000001, 100010001, 100020001, 100030001, 100040001, 100050001, 100060001, 100070001, 100080001, 100090001]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],intLength = 2) == [11, 22, 33, 44, 55, 66, 77, 88, 99, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(queries = [1, 2, 3, 4, 5, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],intLength = 5) == [10001, 10101, 10201, 10301, 10401, 19991, 29992, 39993, 49994, 59995, 69996, 79997, 89998, 99999, -1]\n assert candidate(queries = [100000000, 200000000, 300000000],intLength = 12) == [-1, -1, -1]\n assert candidate(queries = [100000000, 100000001, 100000002],intLength = 13) == [-1, -1, -1]\n assert candidate(queries = [500000000, 600000000, 700000000],intLength = 9) == [-1, -1, -1]\n assert candidate(queries = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],intLength = 14) == [10000000000001, 10000044000001, 10000099000001, 10000144100001, 10000199100001, 10000244200001, 10000299200001, 10000344300001, 10000399300001, 10000444400001, 10000499400001]\n assert candidate(queries = [100000, 200000, 300000],intLength = 11) == [19999999991, 29999999992, 39999999993]\n assert candidate(queries = [10000, 20000, 30000, 40000, 50000],intLength = 13) == [1009999999001, 1019999999101, 1029999999201, 1039999999301, 1049999999401]\n assert candidate(queries = [500000, 600000, 700000, 800000],intLength = 13) == [1499999999941, 1599999999951, 1699999999961, 1799999999971]\n assert candidate(queries = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],intLength = 6) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(queries = [10000, 10001, 10002, 10003, 10004],intLength = 6) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [5000, 6000, 7000, 8000, 9000, 10000],intLength = 11) == [10499999401, 10599999501, 10699999601, 10799999701, 10899999801, 10999999901]\n assert candidate(queries = [999999999],intLength = 15) == [-1]\n assert candidate(queries = [1000, 2000, 3000, 4000, 5000],intLength = 6) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [1, 5, 10, 15, 20, 25, 30],intLength = 5) == [10001, 10401, 10901, 11411, 11911, 12421, 12921]\n assert candidate(queries = [100000, 100001, 100002],intLength = 11) == [19999999991, 20000000002, 20000100002]\n assert candidate(queries = [1000, 2000, 3000, 4000, 5000],intLength = 5) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [50000, 150000, 250000],intLength = 11) == [14999999941, 24999999942, 34999999943]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],intLength = 2) == [11, 22, 33, 44, 55, 66, 77, 88, 99, -1, -1, -1, -1, -1, -1]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],intLength = 4) == [1001, 1111, 1221, 1331, 1441, 1551, 1661, 1771, 1881, 1991, 2002, 2112, 2222, 2332, 2442, 2552, 2662, 2772, 2882, 2992]\n assert candidate(queries = [1, 50000000, 100000000],intLength = 15) == [100000000000001, 599999999999995, -1]\n assert candidate(queries = [5000000, 6000000, 7000000],intLength = 11) == [-1, -1, -1]\n assert candidate(queries = [10, 20, 30, 40, 50],intLength = 5) == [10901, 11911, 12921, 13931, 14941]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],intLength = 14) == [10000000000001, 10000011000001, 10000022000001, 10000033000001, 10000044000001, 10000055000001, 10000066000001, 10000077000001, 10000088000001, 10000099000001]\n assert candidate(queries = [100000, 99999, 88888],intLength = 15) == [100999999999001, 100999989999001, 100888878888001]\n assert candidate(queries = [999999, 999998, 999997],intLength = 7) == [-1, -1, -1]\n assert candidate(queries = [123456, 654321, 111111],intLength = 9) == [-1, -1, -1]\n assert candidate(queries = [1, 2, 3, 4, 5, 1000000, 2000000, 3000000, 4000000, 5000000],intLength = 7) == [1000001, 1001001, 1002001, 1003001, 1004001, -1, -1, -1, -1, -1]\n assert candidate(queries = [1000000, 2000000, 3000000, 4000000, 5000000],intLength = 15) == [109999999999901, 119999999999911, 129999999999921, 139999999999931, 149999999999941]\n assert candidate(queries = [12345, 67890, 111111, 222222, 333333],intLength = 7) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [1, 100000000, 50000000, 25000000, 75000000, 90000000, 100000000, 85000000, 65000000, 45000000],intLength = 8) == [10000001, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(queries = [100, 200, 300, 400, 500],intLength = 15) == [100000999000001, 100001999100001, 100002999200001, 100003999300001, 100004999400001]\n assert candidate(queries = [10000, 20000, 30000],intLength = 7) == [-1, -1, -1]\n assert candidate(queries = [1, 123456, 987654, 1000000],intLength = 5) == [10001, -1, -1, -1]\n assert candidate(queries = [10000, 20000, 30000, 40000, 50000],intLength = 8) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [1000, 2000, 3000, 4000, 5000],intLength = 11) == [10099999001, 10199999101, 10299999201, 10399999301, 10499999401]\n assert candidate(queries = [1, 10, 100, 1000, 10000, 100000],intLength = 11) == [10000000001, 10000900001, 10009990001, 10099999001, 10999999901, 19999999991]\n assert candidate(queries = [5000, 10000, 15000, 20000],intLength = 10) == [1499999941, 1999999991, 2499999942, 2999999992]\n assert candidate(queries = [999999, 888888, 777777, 666666, 555555],intLength = 10) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [1, 1000000, 9999999, 10000000],intLength = 13) == [1000000000001, 1999999999991, -1, -1]\n assert candidate(queries = [98765, 43210, 11111, 22222, 33333],intLength = 11) == [19876467891, 14320902341, 11111011111, 12222122221, 13333233331]\n assert candidate(queries = [500000, 600000, 700000],intLength = 13) == [1499999999941, 1599999999951, 1699999999961]\n assert candidate(queries = [987654321],intLength = 15) == [-1]\n assert candidate(queries = [123456789],intLength = 9) == [-1]\n assert candidate(queries = [123456789, 987654321, 500000000, 300000000, 200000000],intLength = 15) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [123, 456, 789],intLength = 10) == [1012222101, 1045555401, 1078888701]\n assert candidate(queries = [100000, 200000, 300000],intLength = 9) == [-1, -1, -1]\n assert candidate(queries = [100000000],intLength = 15) == [-1]\n assert candidate(queries = [999999999, 999999998, 999999997, 999999996, 999999995],intLength = 15) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [1, 999999999],intLength = 15) == [100000000000001, -1]\n assert candidate(queries = [100000, 1000000, 10000000, 100000000, 1000000000],intLength = 11) == [19999999991, -1, -1, -1, -1]\n assert candidate(queries = [5000, 10000, 15000, 20000],intLength = 7) == [5999995, -1, -1, -1]\n assert candidate(queries = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],intLength = 9) == [100000001, 100090001, 100999001, 109999901, 199999991, -1, -1, -1, -1, -1]\n assert candidate(queries = [500, 1000, 1500, 2000, 2500, 3000],intLength = 7) == [1499941, 1999991, 2499942, 2999992, 3499943, 3999993]\n assert candidate(queries = [1000000000],intLength = 9) == [-1]\n assert candidate(queries = [10000, 20000, 30000, 40000],intLength = 11) == [10999999901, 11999999911, 12999999921, 13999999931]\n assert candidate(queries = [987654, 987655, 987656, 987657, 987658],intLength = 13) == [1987653567891, 1987654567891, 1987655567891, 1987656567891, 1987657567891]\n assert candidate(queries = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],intLength = 3) == [101, 141, 191, 242, 292, 343, 393, 444, 494, 545, 595, 646, 696, 747, 797, 848, 898, 949, 999, -1]\n assert candidate(queries = [123456789, 987654321, 567891234],intLength = 15) == [-1, -1, -1]\n assert candidate(queries = [1, 123456789, 987654321, 500000000],intLength = 9) == [100000001, -1, -1, -1]\n assert candidate(queries = [1000000, 1000001, 1000002, 1000003, 1000004],intLength = 13) == [1999999999991, 2000000000002, 2000001000002, 2000002000002, 2000003000002]\n assert candidate(queries = [5000, 10000, 15000, 20000],intLength = 9) == [149999941, 199999991, 249999942, 299999992]\n assert candidate(queries = [100000000, 99999999, 88888888, 77777777],intLength = 13) == [-1, -1, -1, -1]\n assert candidate(queries = [123456789],intLength = 10) == [-1]\n assert candidate(queries = [100000000, 99999999, 99999998, 99999997, 99999996],intLength = 2) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [1000000, 1000001, 1000002],intLength = 15) == [109999999999901, 110000000000011, 110000010000011]\n assert candidate(queries = [999999, 999998, 999997, 999996, 999995],intLength = 6) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1],intLength = 11) == [-1, -1, -1, 19999999991, 10999999901, 10099999001, 10009990001, 10000900001, 10000000001]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],intLength = 2) == [11, 22, 33, 44, 55, 66, 77, 88, 99, -1]\n assert candidate(queries = [1, 10, 100, 1000, 10000, 100000],intLength = 14) == [10000000000001, 10000099000001, 10000999900001, 10009999990001, 10099999999001, 10999999999901]\n assert candidate(queries = [987654321, 123456789],intLength = 8) == [-1, -1]\n assert candidate(queries = [10000000, 10000001, 10000002, 10000003, 10000004],intLength = 7) == [-1, -1, -1, -1, -1]\n assert candidate(queries = [500000, 500001, 500002, 500003, 500004],intLength = 13) == [1499999999941, 1500000000051, 1500001000051, 1500002000051, 1500003000051]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, 10000, 100000, 1000000],intLength = 5) == [10001, 10101, 10201, 10301, 10401, 10501, 10601, 10701, 10801, 10901, 19991, -1, -1, -1, -1]\n assert candidate(queries = [99999999, 100000000, 100000001],intLength = 9) == [-1, -1, -1]\n assert candidate(queries = [500000, 500001, 500002, 500003, 500004, 500005],intLength = 13) == [1499999999941, 1500000000051, 1500001000051, 1500002000051, 1500003000051, 1500004000051]\n"}, "metadata": {"canonical_parameter_names": ["queries", "intLength"], "leetcode_dataset_entry_point": "Solution().kthPalindrome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long[] kthPalindrome(int[] queries, int intLength) {", "container": "Solution", "callable": "kthPalindrome", "parameters": [{"name": "queries", "type": "int[]"}, {"name": "intLength", "type": "int"}], "return_type": "long[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2218, "task_id": "maximum-value-of-k-coins-from-piles", "difficulty": "Hard", "problem_description": "There are n piles of coins on a table. Each pile consists of a positive number of coins of assorted denominations.\nIn one move, you can choose any coin on top of any pile, remove it, and add it to your wallet.\nGiven a list piles, where piles[i] is a list of integers denoting the composition of the ith pile from top to bottom, and a positive integer k, return the maximum total value of coins you can have in your wallet if you choose exactly k coins optimally.\n \nExample 1:\n\n\nInput: piles = [[1,100,3],[7,8,9]], k = 2\nOutput: 101\nExplanation:\nThe above diagram shows the different ways we can choose k coins.\nThe maximum total we can obtain is 101.\n\nExample 2:\n\nInput: piles = [[100],[100],[100],[100],[100],[100],[1,1,1,1,1,1,700]], k = 7\nOutput: 706\nExplanation:\nThe maximum total can be obtained if we choose all coins from the last pile.\n\n \nConstraints:\n\nn == piles.length\n1 <= n <= 1000\n1 <= piles[i][j] <= 105\n1 <= k <= sum(piles[i].length) <= 2000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(piles = [[30, 10], [50, 20, 10]],k = 3) == 100\n assert candidate(piles = [[1, 2], [3, 4], [5, 6]],k = 5) == 19\n assert candidate(piles = [[10, 20], [5, 5, 5, 5], [1, 1, 1, 1, 1]],k = 5) == 45\n assert candidate(piles = [[1, 2, 3], [4, 5, 6]],k = 3) == 15\n assert candidate(piles = [[30, 10, 20], [10, 20, 30], [5, 5, 5]],k = 5) == 100\n assert candidate(piles = [[1], [2], [3], [4], [5]],k = 3) == 12\n assert candidate(piles = [[10]],k = 1) == 10\n assert candidate(piles = [[10, 20, 30], [30, 20, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 10) == 124\n assert candidate(piles = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 5) == 33\n assert candidate(piles = [[1, 100, 3], [7, 8, 9]],k = 2) == 101\n assert candidate(piles = [[100], [100], [100], [100], [100], [100], [1, 1, 1, 1, 1, 1, 700]],k = 7) == 706\n assert candidate(piles = [[3, 1, 5], [1, 2, 3], [4, 6]],k = 3) == 13\n assert candidate(piles = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],k = 4) == 16\n assert candidate(piles = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],k = 10) == 55\n assert candidate(piles = [[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]],k = 25) == 55\n assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 10) == 55\n assert candidate(piles = [[1, 3, 5, 7, 9], [2, 4, 6, 8], [10, 20, 30, 40, 50, 60]],k = 12) == 237\n assert candidate(piles = [[10000, 20000, 30000, 40000, 50000], [10000, 20000, 30000, 40000, 50000], [10000, 20000, 30000, 40000, 50000]],k = 10) == 300000\n assert candidate(piles = [[100, 90, 80], [70, 60, 50, 40], [30, 20, 10]],k = 7) == 490\n assert candidate(piles = [[1, 100, 3, 50], [7, 8, 9, 100], [1, 2, 3, 4, 5]],k = 7) == 228\n assert candidate(piles = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]],k = 10) == 550\n assert candidate(piles = [[5, 1, 2, 3], [4, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 8) == 100\n assert candidate(piles = [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200], [1300, 1400, 1500, 1600]],k = 8) == 10000\n assert candidate(piles = [[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]],k = 50) == 400\n assert candidate(piles = [[1000, 900, 800], [700, 600, 500], [400, 300, 200], [100, 90, 80], [70, 60, 50], [40, 30, 20], [10, 9, 8], [7, 6, 5]],k = 20) == 5959\n assert candidate(piles = [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1]],k = 10) == 10\n assert candidate(piles = [[1000, 2000, 3000], [1000, 1000, 1000, 1000], [500, 500, 500, 500, 500, 500], [200, 200, 200]],k = 10) == 11500\n assert candidate(piles = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]],k = 30) == 1105\n assert candidate(piles = [[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]],k = 15) == 40\n assert candidate(piles = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]],k = 20) == 210\n assert candidate(piles = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4]],k = 10) == 35\n assert candidate(piles = [[10, 20], [30, 40, 50, 60], [70, 80, 90], [100]],k = 7) == 460\n assert candidate(piles = [[10, 15, 20], [25, 30, 35], [40, 45, 50], [5, 10, 15], [1, 2, 3]],k = 12) == 300\n assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]],k = 15) == 195\n assert candidate(piles = [[99999, 99998, 99997, 99996, 99995], [99994, 99993, 99992, 99991, 99990], [99989, 99988, 99987, 99986, 99985], [99984, 99983, 99982, 99981, 99980]],k = 15) == 1499880\n assert candidate(piles = [[1, 2], [3, 4, 5], [6, 7, 8, 9], [10, 11, 12, 13, 14]],k = 8) == 81\n assert candidate(piles = [[10, 20, 30], [5, 15, 25], [1, 2, 3], [9, 18, 27]],k = 8) == 134\n assert candidate(piles = [[1000, 500, 250, 125, 62, 31, 15, 7, 3, 1], [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]],k = 20) == 3017\n assert candidate(piles = [[100, 90, 80, 70, 60], [50, 40, 30, 20, 10], [1, 2, 3, 4, 5]],k = 10) == 550\n assert candidate(piles = [[10, 20, 30], [40, 50, 60, 70], [80, 90]],k = 8) == 420\n assert candidate(piles = [[100000], [100000], [100000], [100000], [100000], [100000], [100000]],k = 7) == 700000\n assert candidate(piles = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70]],k = 6) == 270\n assert candidate(piles = [[5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2]],k = 15) == 59\n assert candidate(piles = [[10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10]],k = 15) == 150\n assert candidate(piles = [[100000], [100000], [100000], [100000], [100000], [100000], [100000], [100000], [100000], [100000]],k = 5) == 500000\n assert candidate(piles = [[1, 2, 3, 4, 5], [10, 20, 30, 40, 50], [100, 200, 300, 400, 500], [1000, 2000, 3000, 4000, 5000]],k = 10) == 16500\n assert candidate(piles = [[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]],k = 15) == 105\n assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 10) == 55\n assert candidate(piles = [[1, 10, 30, 50], [10, 20, 30, 40], [5, 15, 25, 35]],k = 10) == 211\n assert candidate(piles = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1000]],k = 10) == 1009\n assert candidate(piles = [[10, 20, 30], [1, 2, 3, 4, 5], [100, 200], [50, 60, 70]],k = 7) == 510\n assert candidate(piles = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6]],k = 15) == 95\n assert candidate(piles = [[1000, 900, 800], [700, 600], [500, 400, 300, 200, 100]],k = 12) == 5500\n assert candidate(piles = [[1], [1, 1, 1], [1, 1, 1, 1, 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) == 20\n assert candidate(piles = [[100, 100, 100], [100, 100, 100], [100, 100, 100], [100, 100, 100]],k = 8) == 800\n assert candidate(piles = [[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]],k = 15) == 140\n assert candidate(piles = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1]],k = 15) == 70\n assert candidate(piles = [[1000, 2000, 3000], [1500, 2500, 3500], [1200, 2200, 3200]],k = 5) == 10900\n assert candidate(piles = [[10, 20, 30, 40], [5, 15, 25], [100], [50, 75]],k = 6) == 285\n assert candidate(piles = [[1, 1000, 2000], [3000, 4000, 5000], [6000, 7000, 8000], [9000, 10000, 11000]],k = 6) == 51000\n assert candidate(piles = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]],k = 25) == 135\n assert candidate(piles = [[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]],k = 20) == 40\n assert candidate(piles = [[10, 20, 30], [15, 25, 35, 45], [5, 10, 15, 20, 25]],k = 10) == 210\n assert candidate(piles = [[1, 100, 3], [7, 8, 9], [4, 5, 6], [10, 20, 30], [1000, 2000, 3000]],k = 12) == 6189\n assert candidate(piles = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]],k = 10) == 155\n assert candidate(piles = [[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) == 320\n assert candidate(piles = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]],k = 20) == 605\n assert candidate(piles = [[10, 20, 30, 40], [50, 60, 70], [80, 90, 100, 110, 120], [130, 140]],k = 10) == 950\n assert candidate(piles = [[100], [200], [300], [400], [500], [600], [700], [800], [900], [1000]],k = 5) == 4000\n assert candidate(piles = [[50], [20], [10], [5]],k = 3) == 80\n assert candidate(piles = [[9, 7, 5, 3, 1], [8, 6, 4, 2], [10, 20, 30], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 15) == 108\n assert candidate(piles = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 6, 8, 10], [10, 8, 6, 4, 2]],k = 15) == 78\n assert candidate(piles = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [2, 12, 22, 32, 42]],k = 10) == 275\n assert candidate(piles = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]],k = 20) == 210\n assert candidate(piles = [[1000, 2000], [100, 200, 300, 400, 500], [50]],k = 8) == 4550\n assert candidate(piles = [[5, 10, 15], [20, 25, 30, 35, 40], [1, 1, 1, 1, 1, 1, 1], [99, 98, 97, 96]],k = 10) == 545\n assert candidate(piles = [[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], [1000]],k = 20) == 1038\n assert candidate(piles = [[10, 20, 30, 40, 50], [5, 10, 15, 20, 25], [1, 2, 3, 4, 5], [100, 200, 300, 400, 500]],k = 10) == 1650\n assert candidate(piles = [[1000, 2000, 3000], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [500, 600, 700, 800, 900], [10, 20, 30, 40, 50]],k = 15) == 9653\n assert candidate(piles = [[1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18]],k = 12) == 147\n assert candidate(piles = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]],k = 10) == 300\n assert candidate(piles = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],k = 14) == 105\n assert candidate(piles = [[5, 4, 3, 2, 1], [10, 9, 8, 7, 6], [15, 14, 13, 12, 11]],k = 15) == 120\n assert candidate(piles = [[100, 200, 300], [400, 500, 600], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],k = 15) == 2145\n assert candidate(piles = [[100, 200, 300], [50, 60, 70, 80], [10, 20, 30, 40, 50]],k = 15) == 1010\n assert candidate(piles = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]],k = 18) == 90\n assert candidate(piles = [[5, 1, 2], [3, 10, 1], [4, 4, 4], [2, 8, 6]],k = 6) == 34\n assert candidate(piles = [[1, 100, 3], [7, 8, 9], [5, 6, 7], [4, 5, 6]],k = 10) == 152\n assert candidate(piles = [[1, 1, 1, 1, 1], [2, 2, 2], [3, 3], [4], [5, 5, 5, 5]],k = 10) == 36\n assert candidate(piles = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13], [6, 8, 10, 12, 14], [7, 9, 11, 13, 15], [8, 10, 12, 14, 16], [9, 11, 13, 15, 17], [10, 12, 14, 16, 18]],k = 25) == 300\n assert candidate(piles = [[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]],k = 15) == 95\n assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],k = 15) == 120\n assert candidate(piles = [[10, 20, 30], [5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 8) == 81\n assert candidate(piles = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],k = 8) == 100\n assert candidate(piles = [[100, 200], [50, 150, 250], [200, 300, 400, 500], [300, 400, 500, 600, 700]],k = 15) == 4650\n assert candidate(piles = [[1, 2], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23]],k = 12) == 201\n"}, "metadata": {"canonical_parameter_names": ["piles", "k"], "leetcode_dataset_entry_point": "Solution().maxValueOfCoins", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxValueOfCoins(List> piles, int k) {", "container": "Solution", "callable": "maxValueOfCoins", "parameters": [{"name": "piles", "type": "List>"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2220, "task_id": "minimum-bit-flips-to-convert-number", "difficulty": "Easy", "problem_description": "A bit flip of a number x is choosing a bit in the binary representation of x and flipping it from either 0 to 1 or 1 to 0.\n\nFor example, for x = 7, the binary representation is 111 and we may choose any bit (including any leading zeros not shown) and flip it. We can flip the first bit from the right to get 110, flip the second bit from the right to get 101, flip the fifth bit from the right (a leading zero) to get 10111, etc.\n\nGiven two integers start and goal, return the minimum number of bit flips to convert start to goal.\n \nExample 1:\n\nInput: start = 10, goal = 7\nOutput: 3\nExplanation: The binary representation of 10 and 7 are 1010 and 0111 respectively. We can convert 10 to 7 in 3 steps:\n- Flip the first bit from the right: 1010 -> 1011.\n- Flip the third bit from the right: 1011 -> 1111.\n- Flip the fourth bit from the right: 1111 -> 0111.\nIt can be shown we cannot convert 10 to 7 in less than 3 steps. Hence, we return 3.\nExample 2:\n\nInput: start = 3, goal = 4\nOutput: 3\nExplanation: The binary representation of 3 and 4 are 011 and 100 respectively. We can convert 3 to 4 in 3 steps:\n- Flip the first bit from the right: 011 -> 010.\n- Flip the second bit from the right: 010 -> 000.\n- Flip the third bit from the right: 000 -> 100.\nIt can be shown we cannot convert 3 to 4 in less than 3 steps. Hence, we return 3.\n\n \nConstraints:\n\n0 <= start, goal <= 109\n\n \nNote: This question is the same as 461: Hamming Distance.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(start = 123456789,goal = 987654321) == 15\n assert candidate(start = 5,goal = 2) == 3\n assert candidate(start = 1000000000,goal = 500000000) == 14\n assert candidate(start = 8,goal = 15) == 3\n assert candidate(start = 15,goal = 8) == 3\n assert candidate(start = 5,goal = 8) == 3\n assert candidate(start = 1000000000,goal = 999999999) == 10\n assert candidate(start = 1023,goal = 0) == 10\n assert candidate(start = 3,goal = 4) == 3\n assert candidate(start = 29,goal = 15) == 2\n assert candidate(start = 10,goal = 7) == 3\n assert candidate(start = 54321,goal = 12345) == 5\n assert candidate(start = 1023,goal = 512) == 9\n assert candidate(start = 512,goal = 256) == 2\n assert candidate(start = 0,goal = 0) == 0\n assert candidate(start = 255,goal = 0) == 8\n assert candidate(start = 15,goal = 0) == 4\n assert candidate(start = 1,goal = 1) == 0\n assert candidate(start = 1,goal = 1023) == 9\n assert candidate(start = 5,goal = 10) == 4\n assert candidate(start = 111111111,goal = 999999999) == 13\n assert candidate(start = 1234567890,goal = 1098765432) == 16\n assert candidate(start = 8589934591,goal = 536870912) == 32\n assert candidate(start = 4294967295,goal = 268435456) == 31\n assert candidate(start = 1,goal = 1073741824) == 2\n assert candidate(start = 101010101,goal = 111111111) == 10\n assert candidate(start = 1001100110,goal = 1110011001) == 20\n assert candidate(start = 987654321,goal = 123456789) == 15\n assert candidate(start = 1000000000,goal = 0) == 13\n assert candidate(start = 888888888,goal = 111111111) == 18\n assert candidate(start = 67890,goal = 54321) == 9\n assert candidate(start = 536870912,goal = 858993459) == 15\n assert candidate(start = 1048575,goal = 2097151) == 1\n assert candidate(start = 1001001001,goal = 1100110011) == 13\n assert candidate(start = 858993459,goal = 1717986918) == 16\n assert candidate(start = 987654321,goal = 876543219) == 11\n assert candidate(start = 123,goal = 321) == 5\n assert candidate(start = 3486784401,goal = 2123366401) == 12\n assert candidate(start = 1000000000,goal = 1) == 14\n assert candidate(start = 1,goal = 2147483647) == 30\n assert candidate(start = 1073741823,goal = 134217728) == 29\n assert candidate(start = 999999999,goal = 111111111) == 13\n assert candidate(start = 1100110011,goal = 1010101010) == 19\n assert candidate(start = 999999999,goal = 999999998) == 1\n assert candidate(start = 293847,goal = 987654) == 11\n assert candidate(start = 111111111,goal = 222222222) == 14\n assert candidate(start = 1001001,goal = 1100110) == 15\n assert candidate(start = 123456789,goal = 123456788) == 1\n assert candidate(start = 500000000,goal = 500000001) == 1\n assert candidate(start = 33554431,goal = 67108864) == 26\n assert candidate(start = 8388607,goal = 8388608) == 24\n assert candidate(start = 13579,goal = 24680) == 8\n assert candidate(start = 134217727,goal = 268435455) == 1\n assert candidate(start = 54321,goal = 100000) == 7\n assert candidate(start = 2147483647,goal = 2147483646) == 1\n assert candidate(start = 16777215,goal = 8388608) == 23\n assert candidate(start = 86420,goal = 13579) == 10\n assert candidate(start = 1111111111,goal = 2222222222) == 16\n assert candidate(start = 1,goal = 1000000000) == 14\n assert candidate(start = 0,goal = 1000000000) == 13\n assert candidate(start = 789012345,goal = 543210987) == 16\n assert candidate(start = 536870911,goal = 2147483648) == 30\n assert candidate(start = 123456789,goal = 987654322) == 17\n assert candidate(start = 134217728,goal = 268435455) == 27\n assert candidate(start = 536870912,goal = 268435456) == 2\n assert candidate(start = 536870911,goal = 1073741823) == 1\n assert candidate(start = 0,goal = 1073741823) == 30\n assert candidate(start = 54321,goal = 65432) == 8\n assert candidate(start = 268435455,goal = 67108863) == 2\n assert candidate(start = 999999999,goal = 888888888) == 17\n assert candidate(start = 135792468,goal = 246813579) == 16\n assert candidate(start = 8675309,goal = 5309867) == 12\n assert candidate(start = 999999999,goal = 1) == 20\n assert candidate(start = 1610612735,goal = 1342177280) == 28\n assert candidate(start = 1048575,goal = 1) == 19\n assert candidate(start = 100000000,goal = 1) == 13\n assert candidate(start = 134217728,goal = 134217729) == 1\n assert candidate(start = 67890,goal = 98765) == 10\n assert candidate(start = 1234,goal = 5678) == 8\n assert candidate(start = 67890,goal = 12345) == 8\n assert candidate(start = 1073741824,goal = 2147483647) == 30\n assert candidate(start = 123456,goal = 654321) == 8\n assert candidate(start = 65535,goal = 32768) == 15\n assert candidate(start = 555555555,goal = 444444444) == 20\n assert candidate(start = 2147483647,goal = 0) == 31\n"}, "metadata": {"canonical_parameter_names": ["start", "goal"], "leetcode_dataset_entry_point": "Solution().minBitFlips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minBitFlips(int start, int goal) {", "container": "Solution", "callable": "minBitFlips", "parameters": [{"name": "start", "type": "int"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2221, "task_id": "find-triangular-sum-of-an-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums, where nums[i] is a digit between 0 and 9 (inclusive).\nThe triangular sum of nums is the value of the only element present in nums after the following process terminates:\n\nLet nums comprise of n elements. If n == 1, end the process. Otherwise, create a new 0-indexed integer array newNums of length n - 1.\nFor each index i, where 0 <= i < n - 1, assign the value of newNums[i] as (nums[i] + nums[i+1]) % 10, where % denotes modulo operator.\nReplace the array nums with newNums.\nRepeat the entire process starting from step 1.\n\nReturn the triangular sum of nums.\n \nExample 1:\n\n\nInput: nums = [1,2,3,4,5]\nOutput: 8\nExplanation:\nThe above diagram depicts the process from which we obtain the triangular sum of the array.\nExample 2:\n\nInput: nums = [5]\nOutput: 5\nExplanation:\nSince there is only one element in nums, the triangular sum is the value of that element itself.\n \nConstraints:\n\n1 <= nums.length <= 1000\n0 <= nums[i] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 6\n assert candidate(nums = [4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == 6\n assert candidate(nums = [5]) == 5\n assert candidate(nums = [1, 0, 1, 0, 1]) == 8\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 6\n assert candidate(nums = [9, 9, 9, 9, 9]) == 4\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [6, 7, 3, 5, 9, 4, 2, 8, 1, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 8\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 4\n assert candidate(nums = [9, 9, 9, 9]) == 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]) == 2\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 6\n assert candidate(nums = [6, 3, 8, 1, 7, 4, 9, 2, 5, 0, 6, 3, 8, 1, 7, 4, 9, 2, 5, 0]) == 6\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9, 1, 2, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == 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]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1]) == 6\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 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]) == 8\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 = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 8\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\n assert candidate(nums = [8, 1, 9, 1, 8, 1, 9, 1, 8, 1, 9, 1, 8, 1, 9, 1, 8, 1, 9, 1]) == 4\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 1\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0]) == 4\n assert candidate(nums = [7, 1, 5, 9, 2, 6, 5, 3, 5, 7]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 4\n assert candidate(nums = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == 2\n assert candidate(nums = [7, 3, 1, 4, 6, 2, 9, 0, 5]) == 2\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 8\n assert candidate(nums = [7, 3, 5, 1, 9, 8, 7, 6, 4, 2, 0]) == 8\n assert candidate(nums = [7, 1, 3, 5, 2, 8, 6, 4, 9, 0, 7, 1, 3, 5, 2, 8, 6, 4, 9, 0]) == 7\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, 6, 9, 2, 5, 8, 1, 4, 7, 0]) == 8\n assert candidate(nums = [6, 2, 8, 4, 0, 1, 3, 5, 7, 9]) == 8\n assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == 4\n assert candidate(nums = [3, 6, 9, 2, 5, 8, 1, 4, 7, 0, 3, 6, 9, 2, 5, 8, 1, 4, 7, 0]) == 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\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 0\n assert candidate(nums = [8, 1, 4, 1, 8, 1, 4, 1, 8, 1, 4]) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 6\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [9, 2, 3, 4, 5, 6, 7, 8, 1, 0, 9, 2, 3, 4, 5, 6, 7, 8, 1, 0]) == 8\n assert candidate(nums = [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, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9]) == 8\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 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]) == 0\n assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2]) == 2\n assert candidate(nums = [6, 2, 9, 5, 4, 8, 7, 1, 3, 6, 2, 9, 5, 4, 8, 7, 1, 3, 6, 2]) == 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]) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == 4\n assert candidate(nums = [5, 3, 8, 9, 1, 4, 6, 7]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == 0\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 4\n assert candidate(nums = [8, 6, 4, 2, 0, 9, 7, 5, 3, 1, 8, 6, 4, 2, 0, 9, 7, 5, 3, 1]) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 6\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9]) == 0\n assert candidate(nums = [7, 3, 5, 2, 8, 6, 4, 9, 1, 0, 7, 3, 5, 2, 8, 6, 4, 9, 1, 0]) == 5\n assert candidate(nums = [7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0]) == 8\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [6, 2, 8, 4, 0, 1, 5, 9, 3, 7]) == 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]) == 0\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2]) == 8\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 6\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 5\n assert candidate(nums = [0, 9, 0, 9, 0, 9, 0, 9, 0, 9]) == 4\n assert candidate(nums = [1, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0]) == 7\n assert candidate(nums = [7, 3, 1, 2, 5, 8, 6, 4, 9, 0]) == 5\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(nums = [7, 1, 9, 3, 7, 1, 9, 3, 7, 1, 9, 3, 7, 1, 9, 3, 7, 1, 9, 3]) == 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]) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 4\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 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\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9]) == 0\n assert candidate(nums = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 4\n assert candidate(nums = [2, 7, 1, 8, 2, 8, 1, 8, 2, 8, 4, 5, 9, 0, 4, 5, 2, 3, 5, 3]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().triangularSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int triangularSum(int[] nums) {", "container": "Solution", "callable": "triangularSum", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2222, "task_id": "number-of-ways-to-select-buildings", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary string s which represents the types of buildings along a street where:\n\ns[i] = '0' denotes that the ith building is an office and\ns[i] = '1' denotes that the ith building is a restaurant.\n\nAs a city official, you would like to select 3 buildings for random inspection. However, to ensure variety, no two consecutive buildings out of the selected buildings can be of the same type.\n\nFor example, given s = \"001101\", we cannot select the 1st, 3rd, and 5th buildings as that would form \"011\" which is not allowed due to having two consecutive buildings of the same type.\n\nReturn the number of valid ways to select 3 buildings.\n \nExample 1:\n\nInput: s = \"001101\"\nOutput: 6\nExplanation: \nThe following sets of indices selected are valid:\n- [0,2,4] from \"001101\" forms \"010\"\n- [0,3,4] from \"001101\" forms \"010\"\n- [1,2,4] from \"001101\" forms \"010\"\n- [1,3,4] from \"001101\" forms \"010\"\n- [2,4,5] from \"001101\" forms \"101\"\n- [3,4,5] from \"001101\" forms \"101\"\nNo other selection is valid. Thus, there are 6 total ways.\n\nExample 2:\n\nInput: s = \"11100\"\nOutput: 0\nExplanation: It can be shown that there are no valid selections.\n\n \nConstraints:\n\n3 <= s.length <= 105\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"100100100\") == 24\n assert candidate(s = \"101010101\") == 30\n assert candidate(s = \"000111000\") == 27\n assert candidate(s = \"111\") == 0\n assert candidate(s = \"0000000001\") == 0\n assert candidate(s = \"01010\") == 5\n assert candidate(s = \"010101010\") == 30\n assert candidate(s = \"1001001\") == 12\n assert candidate(s = \"011001100\") == 28\n assert candidate(s = \"101101101\") == 27\n assert candidate(s = \"10101\") == 5\n assert candidate(s = \"1111111110\") == 0\n assert candidate(s = \"1010101010101010101\") == 285\n assert candidate(s = \"001001001\") == 24\n assert candidate(s = \"001101\") == 6\n assert candidate(s = \"1001001001\") == 36\n assert candidate(s = \"11111\") == 0\n assert candidate(s = \"0011001100\") == 40\n assert candidate(s = \"000\") == 0\n assert candidate(s = \"010101\") == 8\n assert candidate(s = \"1100110011\") == 40\n assert candidate(s = \"101010\") == 8\n assert candidate(s = \"11100\") == 0\n assert candidate(s = \"0101010101\") == 40\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"0110110\") == 12\n assert candidate(s = \"110011001\") == 28\n assert candidate(s = \"010101001010101010\") == 240\n assert candidate(s = \"101010101010101010\") == 240\n assert candidate(s = \"000111000111000111000\") == 378\n assert candidate(s = \"101010101010101\") == 140\n assert candidate(s = \"010101010101010101010101010101010101\") == 1938\n assert candidate(s = \"111111111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"001001001001001001001001001001001001001001001001\") == 4080\n assert candidate(s = \"00000000000000000000000000000000\") == 0\n assert candidate(s = \"100001000010000100001\") == 240\n assert candidate(s = \"10101010101010101010101010\") == 728\n assert candidate(s = \"1010101010101010101010101010101\") == 1240\n assert candidate(s = \"111000111000111\") == 135\n assert candidate(s = \"110011001100110011001\") == 380\n assert candidate(s = \"000111000111000111\") == 216\n assert candidate(s = \"101010101010101010101010\") == 572\n assert candidate(s = \"010010100101001010010100101001\") == 1074\n assert candidate(s = \"101010101010101010101\") == 385\n assert candidate(s = \"1010101010\") == 40\n assert candidate(s = \"111111111100000000111111111\") == 720\n assert candidate(s = \"111111111111111111111\") == 0\n assert candidate(s = \"010101010101010101\") == 240\n assert candidate(s = \"010010010010010010\") == 216\n assert candidate(s = \"101010101010101010101010101\") == 819\n assert candidate(s = \"000000000000000000000000000\") == 0\n assert candidate(s = \"000111000111000111000111\") == 540\n assert candidate(s = \"101010101010101010101010101010\") == 1120\n assert candidate(s = \"110011001100\") == 64\n assert candidate(s = \"110011001100110011\") == 240\n assert candidate(s = \"111100001111000011110000\") == 512\n assert candidate(s = \"10011001100110011001\") == 330\n assert candidate(s = \"01001001001001\") == 100\n assert candidate(s = \"0101010101010101010101010101010\") == 1240\n assert candidate(s = \"100100100100100100\") == 210\n assert candidate(s = \"000000000000000000000\") == 0\n assert candidate(s = \"000111000111\") == 54\n assert candidate(s = \"0101010101010101010101010101010101\") == 1632\n assert candidate(s = \"000000000011111111000000000\") == 720\n assert candidate(s = \"010101010101010101010101010\") == 819\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010\") == 7308\n assert candidate(s = \"111111000000111111\") == 216\n assert candidate(s = \"111111111111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"01010010100101001010\") == 320\n assert candidate(s = \"1111111000000111111000000\") == 468\n assert candidate(s = \"1001001001001001001001001001001001001001001001\") == 3600\n assert candidate(s = \"0100100101010010010100100\") == 614\n assert candidate(s = \"0000011111\") == 0\n assert candidate(s = \"11111111111111111111\") == 0\n assert candidate(s = \"1101010101010101010101010101010101\") == 1632\n assert candidate(s = \"00000001111111100000001111111110000000\") == 2170\n assert candidate(s = \"0011011011100101010101010\") == 633\n assert candidate(s = \"110011001100110\") == 136\n assert candidate(s = \"000001111110000011111\") == 300\n assert candidate(s = \"0110110110110110110110110110110110110110110110\") == 3600\n assert candidate(s = \"111111111111111111\") == 0\n assert candidate(s = \"1010101010101010101010101010101010\") == 1632\n assert candidate(s = \"10101010100000001010101010\") == 630\n assert candidate(s = \"000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"00000000000011111111111\") == 0\n assert candidate(s = \"00000111110000011111\") == 250\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001\") == 56316\n assert candidate(s = \"00110011001100110011001100\") == 728\n assert candidate(s = \"01010111100001110101\") == 320\n assert candidate(s = \"11001100110011001100\") == 320\n assert candidate(s = \"11100011100011100011\") == 324\n assert candidate(s = \"01010101010101010101010101010101\") == 1360\n assert candidate(s = \"1010101010101010101010101010\") == 910\n assert candidate(s = \"01110111011101110111\") == 240\n assert candidate(s = \"111000111000\") == 54\n assert candidate(s = \"10110110110110110110110110110110110\") == 1584\n assert candidate(s = \"111111000111111000\") == 162\n assert candidate(s = \"11111100000011111100000011111100000\") == 1620\n assert candidate(s = \"11110000111100001111000011110000\") == 1280\n assert candidate(s = \"010101010101\") == 70\n assert candidate(s = \"01010101010101010101010101010101010\") == 1785\n assert candidate(s = \"1100110011001100110011001\") == 644\n assert candidate(s = \"11111111111111111111111111111111\") == 0\n assert candidate(s = \"011001100110011001\") == 240\n assert candidate(s = \"1111111111100000000000\") == 0\n assert candidate(s = \"011011011011011011011011011\") == 720\n assert candidate(s = \"000111000111000111000111000111000\") == 1485\n assert candidate(s = \"101010101010010101\") == 240\n assert candidate(s = \"0101010101010101010101010101\") == 910\n assert candidate(s = \"01101001101001101001101001101001\") == 1360\n assert candidate(s = \"0110011001100110011001\") == 440\n assert candidate(s = \"111110000011111000001\") == 325\n assert candidate(s = \"01010101011111110101010101\") == 630\n assert candidate(s = \"000011110000111100001111\") == 512\n assert candidate(s = \"10001000100010001000\") == 240\n assert candidate(s = \"1001001001001001001001001001001001\") == 1452\n assert candidate(s = \"100010001000100010001000100010001000100010001000\") == 3432\n assert candidate(s = \"00001111000011110000111100001111\") == 1280\n assert candidate(s = \"1110001110001110001110001110001110\") == 1620\n assert candidate(s = \"000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"00110011001100110011\") == 320\n assert candidate(s = \"11101110111\") == 39\n assert candidate(s = \"0000010000100001\") == 92\n assert candidate(s = \"1010101010101\") == 91\n assert candidate(s = \"00000000000000000000\") == 0\n assert candidate(s = \"1111100000\") == 0\n assert candidate(s = \"0001100011000110001100011\") == 600\n assert candidate(s = \"1001001001001001001001001\") == 576\n assert candidate(s = \"00011110001111000111\") == 300\n assert candidate(s = \"001010010010100\") == 131\n assert candidate(s = \"000000000000000000\") == 0\n assert candidate(s = \"11010101010101010101\") == 330\n assert candidate(s = \"01010101010101\") == 112\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 4600\n assert candidate(s = \"10100101001010010100101001010010\") == 1302\n assert candidate(s = \"110110110110110110110110110110110110110110110110\") == 4080\n assert candidate(s = \"010101010101010101010\") == 385\n assert candidate(s = \"1010101010101010101010\") == 440\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 2660\n assert candidate(s = \"1111100001111000011110000\") == 560\n assert candidate(s = \"0110110110110110110110110110110110\") == 1452\n assert candidate(s = \"01010101010101010101010101010101010101010101\") == 3542\n assert candidate(s = \"01101101101101101101101101101101101101101101\") == 3150\n assert candidate(s = \"00000011111100000011111100000011111\") == 1620\n assert candidate(s = \"01010101010101010101\") == 330\n assert candidate(s = \"11001100110011\") == 112\n assert candidate(s = \"000001111100000111\") == 200\n assert candidate(s = \"1001001001001001001001001001\") == 810\n assert candidate(s = \"00101010101010101010\") == 330\n assert candidate(s = \"01101101101101101101\") == 294\n assert candidate(s = \"10101010101010101010\") == 330\n assert candidate(s = \"111110000001111100000\") == 300\n assert candidate(s = \"111111111111111111111111111\") == 0\n assert candidate(s = \"1101010101\") == 40\n assert candidate(s = \"111000111000111000111000\") == 540\n assert candidate(s = \"01110111011101110111011101110111011101110111\") == 2640\n assert candidate(s = \"110110110110110110\") == 210\n assert candidate(s = \"0000000000011111111111\") == 0\n assert candidate(s = \"10101000011110101010\") == 322\n assert candidate(s = \"000111000111000\") == 135\n assert candidate(s = \"011110111101111011110\") == 240\n assert candidate(s = \"000111111000111110\") == 192\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numberOfWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long numberOfWays(String s) {", "container": "Solution", "callable": "numberOfWays", "parameters": [{"name": "s", "type": "String"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2223, "task_id": "sum-of-scores-of-built-strings", "difficulty": "Hard", "problem_description": "You are building a string s of length n one character at a time, prepending each new character to the front of the string. The strings are labeled from 1 to n, where the string with length i is labeled si.\n\nFor example, for s = \"abaca\", s1 == \"a\", s2 == \"ca\", s3 == \"aca\", etc.\n\nThe score of si is the length of the longest common prefix between si and sn (Note that s == sn).\nGiven the final string s, return the sum of the score of every si.\n \nExample 1:\n\nInput: s = \"babab\"\nOutput: 9\nExplanation:\nFor s1 == \"b\", the longest common prefix is \"b\" which has a score of 1.\nFor s2 == \"ab\", there is no common prefix so the score is 0.\nFor s3 == \"bab\", the longest common prefix is \"bab\" which has a score of 3.\nFor s4 == \"abab\", there is no common prefix so the score is 0.\nFor s5 == \"babab\", the longest common prefix is \"babab\" which has a score of 5.\nThe sum of the scores is 1 + 0 + 3 + 0 + 5 = 9, so we return 9.\nExample 2:\n\nInput: s = \"azbazbzaz\"\nOutput: 14\nExplanation: \nFor s2 == \"az\", the longest common prefix is \"az\" which has a score of 2.\nFor s6 == \"azbzaz\", the longest common prefix is \"azb\" which has a score of 3.\nFor s9 == \"azbazbzaz\", the longest common prefix is \"azbazbzaz\" which has a score of 9.\nFor all other si, the score is 0.\nThe sum of the scores is 2 + 3 + 9 = 14, so we return 14.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzxyzxyz\") == 18\n assert candidate(s = \"abcabcabc\") == 18\n assert candidate(s = \"aabbcc\") == 7\n assert candidate(s = \"abacabadabacaba\") == 32\n assert candidate(s = \"zzzzz\") == 15\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"abacaba\") == 12\n assert candidate(s = \"babab\") == 9\n assert candidate(s = \"azbazbzaz\") == 14\n assert candidate(s = \"abcde\") == 5\n assert candidate(s = \"zazazaz\") == 16\n assert candidate(s = \"aaaaa\") == 15\n assert candidate(s = \"aabbaabb\") == 14\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"abcdefg\") == 7\n assert candidate(s = \"aabbccddeeff\") == 13\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\") == 65\n assert candidate(s = \"abacabadabacabadabacaba\") == 60\n assert candidate(s = \"abcdefgfedcbabcdefgfedcbabcdefgfedcbabcdefgfedcbabcdefgfedcb\") == 180\n assert candidate(s = \"xyxyxyxyxyxyxyxy\") == 72\n assert candidate(s = \"zxyzyxzyxzyxzyxzyxzyxzyx\") == 31\n assert candidate(s = \"aaaabbbbccccaaaabbbbcccc\") == 48\n assert candidate(s = \"mississippimississippimississippimississippi\") == 110\n assert candidate(s = \"aaaaaaaaaabaaaa\") == 70\n assert candidate(s = \"rotorrotor\") == 17\n assert candidate(s = \"abracadabra\") == 18\n assert candidate(s = \"abcabcabcabc\") == 30\n assert candidate(s = \"abcabcabcabcabcd\") == 46\n assert candidate(s = \"zzzzzzzzzzzzzzz\") == 120\n assert candidate(s = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkiijjhhggffeeddccbbbaaa\") == 55\n assert candidate(s = \"aaaaaaaaaabaaaaaaaaab\") == 111\n assert candidate(s = \"abcabcabcabcabcabca\") == 70\n assert candidate(s = \"abcabcabcabca\") == 35\n assert candidate(s = \"abcdabcdabcd\") == 24\n assert candidate(s = \"abacabadabacabad\") == 34\n assert candidate(s = \"abababababababababababababababab\") == 272\n assert candidate(s = \"aaaaabbbbccccdddd\") == 27\n assert candidate(s = \"aaaaabbbbbccccdddd\") == 28\n assert candidate(s = \"aaaaabbbbb\") == 20\n assert candidate(s = \"aaaaabbbbccccddddeeeee\") == 32\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == 234\n assert candidate(s = \"abcdefedcbafedcbafedcba\") == 26\n assert candidate(s = \"mississippimississippi\") == 33\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == 273\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 630\n assert candidate(s = \"aabbaabbaabbaabb\") == 44\n assert candidate(s = \"bananaananabanana\") == 23\n assert candidate(s = \"abcabcabcabcabcabcab\") == 77\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 84\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 612\n assert candidate(s = \"qwertyuiopqwertyuiop\") == 30\n assert candidate(s = \"aabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == 145\n assert candidate(s = \"abcdefghjihgfedcba\") == 19\n assert candidate(s = \"acabacabacabacabacabacabacabacabacabacab\") == 230\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 165\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 360\n assert candidate(s = \"abcabcabcab\") == 26\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 408\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(s = \"abcdefedcbafedcbafedcbafedcbafedcbafedcbafedcbafedcbafedcbafedcba\") == 75\n assert candidate(s = \"abcdeedcbaabcdeedcba\") == 32\n assert candidate(s = \"ababababababab\") == 56\n assert candidate(s = \"abcdeedcba\") == 11\n assert candidate(s = \"abababababababab\") == 72\n assert candidate(s = \"noon\") == 5\n assert candidate(s = \"abababababab\") == 42\n assert candidate(s = \"ababababababababab\") == 90\n assert candidate(s = \"abcabcabcabcabcabc\") == 63\n assert candidate(s = \"aabbccddeeffgghhii\") == 19\n assert candidate(s = \"abcdabcdabcdabcd\") == 40\n assert candidate(s = \"level\") == 6\n assert candidate(s = \"levellevellevel\") == 33\n assert candidate(s = \"abcdabcdabcdabcdabcd\") == 60\n assert candidate(s = \"abcdefghijk\") == 11\n assert candidate(s = \"aaaaaaaaaaa\") == 66\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiopqwertyuiop\") == 100\n assert candidate(s = \"bananaananab\") == 13\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 210\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 666\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 315\n assert candidate(s = \"banana\") == 6\n assert candidate(s = \"zzyzxzyzxzyzxzyz\") == 24\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == 272\n assert candidate(s = \"zxyzyxzyxzyxzyxzyx\") == 23\n assert candidate(s = \"abracadabraabracadabra\") == 47\n assert candidate(s = \"abcdedcbaabcdedcba\") == 29\n assert candidate(s = \"abcdefghij\") == 10\n assert candidate(s = \"abcdedcbafedcbafedcbafedcbafedcba\") == 38\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 53\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 21\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 38\n assert candidate(s = \"aaaaaabbccddeeffgg\") == 33\n assert candidate(s = \"aaaaabbbbbaaaaa\") == 40\n assert candidate(s = \"racecarracecar\") == 23\n assert candidate(s = \"abacabadabacabadabacabad\") == 63\n assert candidate(s = \"deified\") == 8\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 525\n assert candidate(s = \"aaaaaabbbbbccccc\") == 31\n assert candidate(s = \"aaaaaabbbbccccdddd\") == 33\n assert candidate(s = \"abcbaabcbaabcba\") == 33\n assert candidate(s = \"ababababcabababa\") == 44\n assert candidate(s = \"abcdabcdbabc\") == 19\n assert candidate(s = \"abababababababababababab\") == 156\n assert candidate(s = \"ababababab\") == 30\n assert candidate(s = \"abacabadabacabadabacab\") == 55\n assert candidate(s = \"civic\") == 6\n assert candidate(s = \"rotor\") == 6\n assert candidate(s = \"racecar\") == 8\n assert candidate(s = \"abcabcabcabcabcabcabcabcabc\") == 135\n assert candidate(s = \"abcdefghijabcdefghij\") == 30\n assert candidate(s = \"zazbzcbzazbzcb\") == 25\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 108\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 46\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == 198\n assert candidate(s = \"abcabcabcabcabcab\") == 57\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 2211\n assert candidate(s = \"abcdefabcdeabcdeabc\") == 32\n assert candidate(s = \"mississippi\") == 11\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzz\") == 71\n assert candidate(s = \"hellohellohellohello\") == 50\n assert candidate(s = \"abcabcabcabcabc\") == 45\n assert candidate(s = \"xyzzzyxyzzzyxyzzzyxyzzzy\") == 60\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().sumScores", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long sumScores(String s) {", "container": "Solution", "callable": "sumScores", "parameters": [{"name": "s", "type": "String"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2224, "task_id": "minimum-number-of-operations-to-convert-time", "difficulty": "Easy", "problem_description": "You are given two strings current and correct representing two 24-hour times.\n24-hour times are formatted as \"HH:MM\", where HH is between 00 and 23, and MM is between 00 and 59. The earliest 24-hour time is 00:00, and the latest is 23:59.\nIn one operation you can increase the time current by 1, 5, 15, or 60 minutes. You can perform this operation any number of times.\nReturn the minimum number of operations needed to convert current to correct.\n \nExample 1:\n\nInput: current = \"02:30\", correct = \"04:35\"\nOutput: 3\nExplanation:\nWe can convert current to correct in 3 operations as follows:\n- Add 60 minutes to current. current becomes \"03:30\".\n- Add 60 minutes to current. current becomes \"04:30\".\n- Add 5 minutes to current. current becomes \"04:35\".\nIt can be proven that it is not possible to convert current to correct in fewer than 3 operations.\nExample 2:\n\nInput: current = \"11:00\", correct = \"11:01\"\nOutput: 1\nExplanation: We only have to add one minute to current, so the minimum number of operations needed is 1.\n\n \nConstraints:\n\ncurrent and correct are in the format \"HH:MM\"\ncurrent <= correct\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(current = \"01:59\",correct = \"02:00\") == 1\n assert candidate(current = \"00:01\",correct = \"00:02\") == 1\n assert candidate(current = \"02:30\",correct = \"04:35\") == 3\n assert candidate(current = \"12:00\",correct = \"13:00\") == 1\n assert candidate(current = \"00:00\",correct = \"23:59\") == 32\n assert candidate(current = \"23:45\",correct = \"23:59\") == 6\n assert candidate(current = \"00:01\",correct = \"00:05\") == 4\n assert candidate(current = \"01:15\",correct = \"01:20\") == 1\n assert candidate(current = \"12:45\",correct = \"15:30\") == 5\n assert candidate(current = \"23:00\",correct = \"23:15\") == 1\n assert candidate(current = \"09:15\",correct = \"09:15\") == 0\n assert candidate(current = \"12:34\",correct = \"12:59\") == 3\n assert candidate(current = \"11:00\",correct = \"11:01\") == 1\n assert candidate(current = \"18:00\",correct = \"18:14\") == 6\n assert candidate(current = \"15:30\",correct = \"16:45\") == 2\n assert candidate(current = \"12:45\",correct = \"12:45\") == 0\n assert candidate(current = \"01:00\",correct = \"02:00\") == 1\n assert candidate(current = \"23:40\",correct = \"00:05\") == -21\n assert candidate(current = \"21:45\",correct = \"22:00\") == 1\n assert candidate(current = \"12:00\",correct = \"12:15\") == 1\n assert candidate(current = \"09:40\",correct = \"10:00\") == 2\n assert candidate(current = \"05:30\",correct = \"05:35\") == 1\n assert candidate(current = \"01:59\",correct = \"03:00\") == 2\n assert candidate(current = \"23:59\",correct = \"23:59\") == 0\n assert candidate(current = \"22:45\",correct = \"23:40\") == 5\n assert candidate(current = \"06:40\",correct = \"06:55\") == 1\n assert candidate(current = \"09:50\",correct = \"10:10\") == 2\n assert candidate(current = \"06:10\",correct = \"06:25\") == 1\n assert candidate(current = \"06:30\",correct = \"07:00\") == 2\n assert candidate(current = \"05:47\",correct = \"06:02\") == 1\n assert candidate(current = \"21:30\",correct = \"01:00\") == -19\n assert candidate(current = \"09:47\",correct = \"18:23\") == 12\n assert candidate(current = \"14:20\",correct = \"14:40\") == 2\n assert candidate(current = \"03:33\",correct = \"04:08\") == 3\n assert candidate(current = \"20:15\",correct = \"21:10\") == 5\n assert candidate(current = \"08:30\",correct = \"09:40\") == 3\n assert candidate(current = \"05:40\",correct = \"07:20\") == 5\n assert candidate(current = \"17:45\",correct = \"19:00\") == 2\n assert candidate(current = \"19:55\",correct = \"20:10\") == 1\n assert candidate(current = \"14:50\",correct = \"15:05\") == 1\n assert candidate(current = \"14:59\",correct = \"15:10\") == 3\n assert candidate(current = \"05:55\",correct = \"06:00\") == 1\n assert candidate(current = \"01:01\",correct = \"02:56\") == 6\n assert candidate(current = \"08:20\",correct = \"08:35\") == 1\n assert candidate(current = \"05:00\",correct = \"09:55\") == 9\n assert candidate(current = \"09:30\",correct = \"20:35\") == 12\n assert candidate(current = \"07:30\",correct = \"07:31\") == 1\n assert candidate(current = \"01:23\",correct = \"02:18\") == 5\n assert candidate(current = \"17:55\",correct = \"18:00\") == 1\n assert candidate(current = \"16:50\",correct = \"18:25\") == 4\n assert candidate(current = \"10:05\",correct = \"14:40\") == 7\n assert candidate(current = \"01:05\",correct = \"02:10\") == 2\n assert candidate(current = \"03:15\",correct = \"03:30\") == 1\n assert candidate(current = \"20:30\",correct = \"22:35\") == 3\n assert candidate(current = \"18:10\",correct = \"19:10\") == 1\n assert candidate(current = \"03:00\",correct = \"07:15\") == 5\n assert candidate(current = \"03:14\",correct = \"06:09\") == 7\n assert candidate(current = \"07:45\",correct = \"08:30\") == 3\n assert candidate(current = \"09:14\",correct = \"09:44\") == 2\n assert candidate(current = \"01:01\",correct = \"04:04\") == 6\n assert candidate(current = \"13:59\",correct = \"14:00\") == 1\n assert candidate(current = \"02:22\",correct = \"02:27\") == 1\n assert candidate(current = \"05:30\",correct = \"05:45\") == 1\n assert candidate(current = \"11:20\",correct = \"12:55\") == 4\n assert candidate(current = \"17:30\",correct = \"18:05\") == 3\n assert candidate(current = \"11:59\",correct = \"12:04\") == 1\n assert candidate(current = \"08:37\",correct = \"09:02\") == 3\n assert candidate(current = \"16:00\",correct = \"16:16\") == 2\n assert candidate(current = \"18:34\",correct = \"19:50\") == 3\n assert candidate(current = \"19:10\",correct = \"21:25\") == 3\n assert candidate(current = \"05:05\",correct = \"11:10\") == 7\n assert candidate(current = \"13:20\",correct = \"17:50\") == 6\n assert candidate(current = \"20:59\",correct = \"21:59\") == 1\n assert candidate(current = \"04:30\",correct = \"06:10\") == 5\n assert candidate(current = \"16:25\",correct = \"17:00\") == 3\n assert candidate(current = \"08:59\",correct = \"09:00\") == 1\n assert candidate(current = \"03:23\",correct = \"03:58\") == 3\n assert candidate(current = \"14:45\",correct = \"20:30\") == 8\n assert candidate(current = \"19:47\",correct = \"21:00\") == 6\n assert candidate(current = \"00:01\",correct = \"23:59\") == 31\n assert candidate(current = \"22:25\",correct = \"22:40\") == 1\n assert candidate(current = \"17:30\",correct = \"20:00\") == 4\n assert candidate(current = \"14:10\",correct = \"15:35\") == 4\n assert candidate(current = \"00:01\",correct = \"00:06\") == 1\n assert candidate(current = \"01:15\",correct = \"02:45\") == 3\n assert candidate(current = \"13:47\",correct = \"18:23\") == 8\n assert candidate(current = \"09:00\",correct = \"09:09\") == 5\n assert candidate(current = \"06:55\",correct = \"07:10\") == 1\n assert candidate(current = \"13:45\",correct = \"15:30\") == 4\n assert candidate(current = \"13:45\",correct = \"15:10\") == 4\n assert candidate(current = \"09:55\",correct = \"11:40\") == 4\n assert candidate(current = \"20:15\",correct = \"21:25\") == 3\n assert candidate(current = \"11:59\",correct = \"12:00\") == 1\n assert candidate(current = \"17:31\",correct = \"20:00\") == 9\n assert candidate(current = \"01:01\",correct = \"22:59\") == 29\n assert candidate(current = \"12:25\",correct = \"14:15\") == 5\n assert candidate(current = \"10:30\",correct = \"10:55\") == 3\n assert candidate(current = \"13:25\",correct = \"13:40\") == 1\n assert candidate(current = \"16:10\",correct = \"16:55\") == 3\n assert candidate(current = \"07:40\",correct = \"07:55\") == 1\n assert candidate(current = \"05:20\",correct = \"06:50\") == 3\n assert candidate(current = \"08:30\",correct = \"20:45\") == 13\n assert candidate(current = \"14:15\",correct = \"14:15\") == 0\n assert candidate(current = \"13:45\",correct = \"14:10\") == 3\n assert candidate(current = \"09:05\",correct = \"09:10\") == 1\n assert candidate(current = \"17:00\",correct = \"18:30\") == 3\n assert candidate(current = \"20:50\",correct = \"21:50\") == 1\n assert candidate(current = \"12:45\",correct = \"13:30\") == 3\n assert candidate(current = \"18:44\",correct = \"19:59\") == 2\n assert candidate(current = \"05:20\",correct = \"05:25\") == 1\n assert candidate(current = \"05:45\",correct = \"10:30\") == 7\n assert candidate(current = \"03:00\",correct = \"04:59\") == 10\n assert candidate(current = \"10:10\",correct = \"11:55\") == 4\n assert candidate(current = \"04:59\",correct = \"05:00\") == 1\n assert candidate(current = \"01:45\",correct = \"02:00\") == 1\n assert candidate(current = \"00:59\",correct = \"01:00\") == 1\n assert candidate(current = \"13:12\",correct = \"13:57\") == 3\n assert candidate(current = \"19:50\",correct = \"21:00\") == 3\n assert candidate(current = \"10:10\",correct = \"10:55\") == 3\n assert candidate(current = \"09:01\",correct = \"09:16\") == 1\n assert candidate(current = \"22:15\",correct = \"23:00\") == 3\n assert candidate(current = \"17:00\",correct = \"19:45\") == 5\n assert candidate(current = \"06:30\",correct = \"08:45\") == 3\n assert candidate(current = \"22:00\",correct = \"23:00\") == 1\n assert candidate(current = \"14:45\",correct = \"15:05\") == 2\n assert candidate(current = \"04:55\",correct = \"05:00\") == 1\n assert candidate(current = \"10:05\",correct = \"10:10\") == 1\n assert candidate(current = \"13:47\",correct = \"15:12\") == 4\n assert candidate(current = \"09:45\",correct = \"11:20\") == 4\n assert candidate(current = \"17:40\",correct = \"18:20\") == 4\n assert candidate(current = \"22:15\",correct = \"22:50\") == 3\n assert candidate(current = \"23:40\",correct = \"00:15\") == -21\n assert candidate(current = \"08:00\",correct = \"08:05\") == 1\n assert candidate(current = \"14:05\",correct = \"14:14\") == 5\n assert candidate(current = \"00:05\",correct = \"01:05\") == 1\n assert candidate(current = \"01:23\",correct = \"05:47\") == 10\n assert candidate(current = \"22:15\",correct = \"23:45\") == 3\n assert candidate(current = \"20:30\",correct = \"22:45\") == 3\n"}, "metadata": {"canonical_parameter_names": ["current", "correct"], "leetcode_dataset_entry_point": "Solution().convertTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int convertTime(String current, String correct) {", "container": "Solution", "callable": "convertTime", "parameters": [{"name": "current", "type": "String"}, {"name": "correct", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2225, "task_id": "find-players-with-zero-or-one-losses", "difficulty": "Medium", "problem_description": "You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match.\nReturn a list answer of size 2 where:\n\nanswer[0] is a list of all players that have not lost any matches.\nanswer[1] is a list of all players that have lost exactly one match.\n\nThe values in the two lists should be returned in increasing order.\nNote:\n\nYou should only consider the players that have played at least one match.\nThe testcases will be generated such that no two matches will have the same outcome.\n\n \nExample 1:\n\nInput: matches = [[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]]\nOutput: [[1,2,10],[4,5,7,8]]\nExplanation:\nPlayers 1, 2, and 10 have not lost any matches.\nPlayers 4, 5, 7, and 8 each have lost one match.\nPlayers 3, 6, and 9 each have lost two matches.\nThus, answer[0] = [1,2,10] and answer[1] = [4,5,7,8].\n\nExample 2:\n\nInput: matches = [[2,3],[1,3],[5,4],[6,4]]\nOutput: [[1,2,5,6],[]]\nExplanation:\nPlayers 1, 2, 5, and 6 have not lost any matches.\nPlayers 3 and 4 each have lost two matches.\nThus, answer[0] = [1,2,5,6] and answer[1] = [].\n\n \nConstraints:\n\n1 <= matches.length <= 105\nmatches[i].length == 2\n1 <= winneri, loseri <= 105\nwinneri != loseri\nAll matches[i] are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matches = [[1, 2]]) == [[1], [2]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == [[], [1, 2, 3, 4, 5]]\n assert candidate(matches = [[100, 200], [200, 300], [100, 300], [400, 500]]) == [[100, 400], [200, 500]]\n assert candidate(matches = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5]]) == [[1], [2, 3, 5]]\n assert candidate(matches = [[5, 3], [5, 4], [4, 5], [3, 4]]) == [[], [3, 5]]\n assert candidate(matches = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600]]) == [[100], [200, 300, 400, 500, 600]]\n assert candidate(matches = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]\n assert candidate(matches = [[1, 3], [2, 3], [3, 6], [5, 6], [5, 7], [4, 5], [4, 8], [4, 9], [10, 4], [10, 9]]) == [[1, 2, 10], [4, 5, 7, 8]]\n assert candidate(matches = [[100, 200], [200, 300], [100, 300]]) == [[100], [200]]\n assert candidate(matches = [[100000, 1], [99999, 2], [99998, 3], [99997, 4], [99996, 5]]) == [[99996, 99997, 99998, 99999, 100000], [1, 2, 3, 4, 5]]\n assert candidate(matches = [[2, 3], [1, 3], [5, 4], [6, 4]]) == [[1, 2, 5, 6], []]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [[1], [2, 3, 4, 5]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 3], [3, 5], [5, 7], [7, 9], [2, 4], [4, 6], [6, 8], [8, 10]]) == [[], [1, 2]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5], [4, 1], [5, 2], [6, 7], [7, 8], [8, 9], [9, 6], [7, 9], [8, 6], [9, 7]]) == [[], [8]]\n assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [4, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7]]) == [[1], [2]]\n assert candidate(matches = [[10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 10], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 21]]) == [[], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]\n assert candidate(matches = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [100, 300], [300, 500], [500, 700], [700, 900], [100, 400], [400, 600], [600, 800], [800, 1000], [100, 500], [500, 900], [100, 600], [600, 1000], [100, 700], [100, 800], [100, 900], [100, 1000]]) == [[100], [200]]\n assert candidate(matches = [[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]]) == [[1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11], [11, 10], [12, 13], [13, 12], [14, 15], [15, 14], [16, 17], [17, 16], [18, 19], [19, 18], [20, 21], [21, 20]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]]\n assert candidate(matches = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 2], [10, 1]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(matches = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]\n assert candidate(matches = [[1, 3], [2, 3], [3, 6], [5, 6], [5, 7], [4, 5], [4, 8], [4, 9], [10, 4], [10, 9], [11, 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, 30], [29, 31], [30, 32], [31, 33], [32, 34], [33, 35], [34, 36], [35, 37], [36, 38], [37, 39], [38, 40], [39, 41], [40, 42], [41, 43], [42, 44], [43, 45], [44, 46], [45, 47], [46, 48], [47, 49], [48, 50], [49, 51], [50, 52], [51, 53], [52, 54], [53, 55], [54, 56], [55, 57], [56, 58], [57, 59], [58, 60], [59, 61], [60, 62], [61, 63], [62, 64], [63, 65], [64, 66], [65, 67], [66, 68], [67, 69], [68, 70], [69, 71], [70, 72], [71, 73], [72, 74], [73, 75], [74, 76], [75, 77], [76, 78], [77, 79], [78, 80], [79, 81], [80, 82], [81, 83], [82, 84], [83, 85], [84, 86], [85, 87], [86, 88], [87, 89], [88, 90], [89, 91], [90, 92], [91, 93], [92, 94], [93, 95], [94, 96], [95, 97], [96, 98], [97, 99], [98, 100], [99, 101], [100, 102], [101, 103], [102, 104], [103, 105], [104, 106], [105, 107], [106, 108], [107, 109], [108, 110], [109, 111], [110, 112], [111, 113], [112, 114], [113, 115], [114, 116], [115, 117], [116, 118], [117, 119], [118, 120], [119, 121], [120, 122], [121, 123], [122, 124], [123, 125], [124, 126], [125, 127], [126, 128], [127, 129], [128, 130], [129, 131], [130, 132], [131, 133], [132, 134], [133, 135], [134, 136], [135, 137], [136, 138], [137, 139], [138, 140], [139, 141], [140, 142], [141, 143], [142, 144], [143, 145], [144, 146], [145, 147], [146, 148], [147, 149], [148, 150], [149, 151], [150, 152], [151, 153], [152, 154], [153, 155], [154, 156], [155, 157], [156, 158], [157, 159], [158, 160], [159, 161], [160, 162], [161, 163], [162, 164], [163, 165], [164, 166], [165, 167], [166, 168], [167, 169], [168, 170], [169, 171], [170, 172], [171, 173], [172, 174], [173, 175], [174, 176], [175, 177], [176, 178], [177, 179], [178, 180], [179, 181], [180, 182], [181, 183], [182, 184], [183, 185], [184, 186], [185, 187], [186, 188], [187, 189], [188, 190], [189, 191], [190, 192], [191, 193], [192, 194], [193, 195], [194, 196], [195, 197], [196, 198], [197, 199], [198, 200], [199, 201], [200, 202]]) == [[1, 2, 10, 11], [4, 5, 7, 8, 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, 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, 201, 202]]\n assert candidate(matches = [[1, 10], [2, 10], [3, 11], [4, 11], [5, 12], [6, 12], [7, 13], [8, 13], [9, 14], [10, 15], [11, 15], [12, 16], [13, 16], [14, 17], [15, 18], [16, 18], [17, 19], [18, 20], [19, 20]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [14, 17, 19]]\n assert candidate(matches = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 1], [12, 2], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == [[], [1, 2, 3, 4, 5, 6]]\n assert candidate(matches = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 1], [10, 2]]) == [[], []]\n assert candidate(matches = [[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], [16, 15], [17, 18], [18, 17], [19, 20], [20, 19]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]\n assert candidate(matches = [[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], [19, 21], [20, 1]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [[], [1, 2, 3, 4, 5]]\n assert candidate(matches = [[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, 1], [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, 1]]) == [[], [2]]\n assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == [[1], [2, 5, 6, 7, 8, 9, 10]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 3], [3, 5], [5, 7], [7, 9], [9, 1], [2, 4], [4, 6], [6, 8], [8, 10], [10, 2]]) == [[], []]\n assert candidate(matches = [[1, 10], [2, 10], [3, 11], [4, 11], [5, 12], [6, 12], [7, 13], [8, 13], [9, 14], [1, 15], [2, 15], [3, 16], [4, 16], [5, 17], [6, 17], [7, 18], [8, 18], [9, 19]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [14, 19]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]\n assert candidate(matches = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == [[1], [2]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5], [2, 4], [4, 1], [5, 3]]) == [[], [2]]\n assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 12], [8, 12], [9, 13], [10, 13], [11, 14], [12, 14], [13, 15], [14, 15], [1, 16], [2, 16], [3, 17], [4, 17], [5, 18], [6, 18], [7, 19], [8, 19], [9, 20], [10, 20], [11, 21], [12, 21], [13, 22], [14, 22], [15, 23], [16, 23], [17, 24], [18, 24], [19, 25], [20, 25], [21, 26], [22, 26], [23, 27], [24, 27], [25, 28], [26, 28], [27, 29], [28, 29]]) == [[1], [2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 6], [3, 7], [4, 8], [5, 9]]) == [[], [2, 3, 4, 5, 10]]\n assert candidate(matches = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [2, 3], [3, 2], [2, 4], [4, 2], [2, 5], [5, 2], [2, 6], [6, 2], [2, 7], [7, 2], [2, 8], [8, 2], [2, 9], [9, 2], [2, 10], [10, 2]]) == [[], []]\n assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [4, 1], [4, 2], [4, 3], [5, 6], [6, 7], [7, 5], [7, 8], [8, 6], [8, 9], [9, 7], [9, 10], [10, 8]]) == [[], [1, 5, 9, 10]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 9]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(matches = [[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, 1500], [1500, 1600], [1600, 1700], [1700, 1800], [1800, 1900], [1900, 2000], [2000, 2100]]) == [[100], [200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 9], [2, 8], [3, 7], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 1], [10, 2]]) == [[], [1, 3, 4, 5]]\n assert candidate(matches = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 10], [9, 10]]) == [[1], [2, 3]]\n assert candidate(matches = [[5, 1], [2, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 2], [9, 3], [10, 4]]) == [[], [1, 2, 5, 6, 7, 8, 9, 10]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [1, 10]]) == [[], []]\n assert candidate(matches = [[1, 4], [1, 5], [2, 4], [2, 6], [3, 5], [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]]) == [[1, 2, 3], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]\n assert candidate(matches = [[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], [16, 15], [17, 18], [18, 17], [19, 20], [20, 19], [1, 11], [11, 1], [2, 12], [12, 2], [3, 13], [13, 3], [4, 14], [14, 4], [5, 15], [15, 5], [6, 16], [16, 6], [7, 17], [17, 7], [8, 18], [18, 8], [9, 19], [19, 9], [10, 20], [20, 10]]) == [[], []]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 7]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[1], [2, 5, 6, 7, 8]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 19], [19, 16], [20, 21], [21, 22], [22, 20], [23, 24], [24, 25], [25, 23], [26, 27], [27, 28], [28, 29], [29, 26]]) == [[], [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]]\n assert candidate(matches = [[1, 10], [2, 10], [3, 10], [4, 11], [5, 11], [6, 12], [7, 12], [8, 13], [9, 13], [10, 14], [11, 14], [12, 15], [13, 15], [14, 16], [15, 16]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], []]\n assert candidate(matches = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 1]]) == [[], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]]\n assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [[1], [2, 5, 6, 7, 8, 9, 10]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 10]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]\n assert candidate(matches = [[10, 11], [12, 13], [11, 12], [13, 10], [14, 15], [16, 17], [15, 16], [17, 14], [18, 19], [19, 20]]) == [[18], [10, 11, 12, 13, 14, 15, 16, 17, 19, 20]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 10], [10, 2], [2, 11], [11, 3], [3, 12], [12, 4], [4, 13], [13, 5], [5, 14], [14, 6], [6, 15], [15, 7], [7, 16], [16, 8], [8, 17], [17, 9], [9, 18], [18, 10], [10, 19], [19, 1]]) == [[], [11, 12, 13, 14, 15, 16, 17, 18, 19]]\n assert candidate(matches = [[10, 1], [11, 10], [12, 11], [13, 12], [14, 13], [15, 14], [1, 15]]) == [[], [1, 10, 11, 12, 13, 14, 15]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28]]) == [[], [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(matches = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [1, 3], [3, 2], [2, 4], [4, 5], [5, 1], [1, 4], [4, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [[], []]\n assert candidate(matches = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]\n assert candidate(matches = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [1, 3], [2, 4], [5, 7], [6, 8], [9, 11], [10, 12], [13, 15], [14, 16], [17, 19], [18, 20]]) == [[1, 5, 9, 13, 17], [2, 3, 6, 7, 10, 11, 14, 15, 18, 19]]\n assert candidate(matches = [[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], [19, 21], [20, 22]]) == [[1, 2], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 1], [1, 4], [4, 5], [5, 6], [6, 4], [4, 7], [7, 8], [8, 9], [9, 10], [10, 7]]) == [[], [1, 2, 3, 5, 6, 8, 9, 10]]\n assert candidate(matches = [[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], [16, 15], [17, 18], [18, 17], [19, 20], [20, 19], [21, 22], [22, 21], [23, 24], [24, 23], [25, 26], [26, 25], [27, 28], [28, 27], [29, 30], [30, 29], [31, 32], [32, 31], [33, 34], [34, 33], [35, 36], [36, 35], [37, 38], [38, 37], [39, 40], [40, 39]]) == [[], [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]]\n assert candidate(matches = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20], [12, 21], [13, 22], [14, 23], [15, 24], [16, 25], [17, 26], [18, 27], [19, 28], [20, 29], [21, 30], [22, 31], [23, 32], [24, 33], [25, 34], [26, 35], [27, 36], [28, 37], [29, 38], [30, 39], [31, 40], [32, 1], [33, 2], [34, 3], [35, 4], [36, 5], [37, 6], [38, 7], [39, 8], [40, 9]]) == [[], [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]]\n assert candidate(matches = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [2, 3], [4, 5], [6, 7], [8, 9], [10, 1]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24], [8, 25], [9, 26], [9, 27], [9, 28], [10, 29], [10, 30], [10, 31]]) == [[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"}, "metadata": {"canonical_parameter_names": ["matches"], "leetcode_dataset_entry_point": "Solution().findWinners", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List> findWinners(int[][] matches) {", "container": "Solution", "callable": "findWinners", "parameters": [{"name": "matches", "type": "int[][]"}], "return_type": "List>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2226, "task_id": "maximum-candies-allocated-to-k-children", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array candies. Each element in the array denotes a pile of candies of size candies[i]. You can divide each pile into any number of sub piles, but you cannot merge two piles together.\nYou are also given an integer k. You should allocate piles of candies to k children such that each child gets the same number of candies. Each child can be allocated candies from only one pile of candies and some piles of candies may go unused.\nReturn the maximum number of candies each child can get.\n \nExample 1:\n\nInput: candies = [5,8,6], k = 3\nOutput: 5\nExplanation: We can divide candies[1] into 2 piles of size 5 and 3, and candies[2] into 2 piles of size 5 and 1. We now have five piles of candies of sizes 5, 5, 3, 5, and 1. We can allocate the 3 piles of size 5 to 3 children. It can be proven that each child cannot receive more than 5 candies.\n\nExample 2:\n\nInput: candies = [2,5], k = 11\nOutput: 0\nExplanation: There are 11 children but only 7 candies in total, so it is impossible to ensure each child receives at least one candy. Thus, each child gets no candy and the answer is 0.\n\n \nConstraints:\n\n1 <= candies.length <= 105\n1 <= candies[i] <= 107\n1 <= k <= 1012\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(candies = [10000000, 10000000, 10000000],k = 10000000) == 2\n assert candidate(candies = [7, 14, 10, 7],k = 3) == 7\n assert candidate(candies = [5, 8, 6],k = 3) == 5\n assert candidate(candies = [3, 9, 7],k = 6) == 3\n assert candidate(candies = [10, 20, 30, 40, 50],k = 15) == 10\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(candies = [7, 10, 10, 10],k = 4) == 7\n assert candidate(candies = [10000000],k = 1) == 10000000\n assert candidate(candies = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 5) == 7\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 6\n assert candidate(candies = [10, 20, 30, 40, 50],k = 3) == 30\n assert candidate(candies = [10, 20, 30, 40, 50],k = 30) == 5\n assert candidate(candies = [10000000, 10000000, 10000000],k = 3) == 10000000\n assert candidate(candies = [1000000],k = 1) == 1000000\n assert candidate(candies = [2, 5],k = 11) == 0\n assert candidate(candies = [7, 7, 7, 7, 7],k = 5) == 7\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(candies = [1, 2, 3, 4, 5],k = 15) == 1\n assert candidate(candies = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],k = 300000) == 1\n assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 500000) == 40\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 60\n assert candidate(candies = [10000000, 5000000, 2500000, 1250000, 625000],k = 1000000) == 19\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 1\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 1\n assert candidate(candies = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 5555555555) == 0\n assert candidate(candies = [10000000],k = 10000001) == 0\n assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 1000000000) == 0\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000000000) == 0\n assert candidate(candies = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000],k = 45000000) == 1\n assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000],k = 1000000) == 50\n assert candidate(candies = [1000000, 999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111],k = 1000000) == 5\n assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000],k = 5000000) == 10\n assert candidate(candies = [9999999, 9999999, 9999999, 9999999, 9999999],k = 1) == 9999999\n assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 10) == 1000000\n assert candidate(candies = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 100) == 10\n assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 5000000) == 2\n assert candidate(candies = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000],k = 10) == 5000000\n assert candidate(candies = [1234567, 8901234, 5678901, 2345678, 9012345],k = 10000000) == 2\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000000) == 0\n assert candidate(candies = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000],k = 5) == 5000000\n assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000],k = 1000000000000) == 0\n assert candidate(candies = [9999999, 9999999, 9999999, 9999999, 9999999],k = 49999995) == 1\n assert candidate(candies = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 10) == 9\n assert candidate(candies = [2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000],k = 10000000) == 6\n assert candidate(candies = [5000000, 5000000, 5000000, 5000000, 5000000],k = 10000000) == 2\n assert candidate(candies = [10000000, 10000000, 10000000],k = 1000000) == 29\n assert candidate(candies = [10000000, 10000000, 10000000],k = 3000000) == 10\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 0\n assert candidate(candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50) == 100\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 7\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 100) == 3\n assert candidate(candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 15000) == 1\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 10) == 400\n assert candidate(candies = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 25) == 10\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 3\n assert candidate(candies = [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(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20) == 13\n assert candidate(candies = [10000000, 1000000, 100000, 10000, 1000, 100, 10, 1],k = 10000000) == 1\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 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 = 30) == 1\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 45) == 1\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000000000) == 0\n assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000],k = 4) == 1000000\n assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000],k = 10000000) == 10\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 55) == 10\n assert candidate(candies = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250],k = 1000000) == 19\n assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000],k = 50000000) == 2\n assert candidate(candies = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 100) == 4\n assert candidate(candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 25) == 600\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 55) == 1\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 35) == 1\n assert candidate(candies = [9999999, 9999998, 9999997, 9999996, 9999995],k = 1000000000000) == 0\n assert candidate(candies = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 20) == 5\n assert candidate(candies = [10000, 20000, 30000, 40000, 50000],k = 150000) == 1\n assert candidate(candies = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1024) == 1\n assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 500000000) == 0\n assert candidate(candies = [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(candies = [1000000, 1000000, 1000000, 1000000, 1000000],k = 250000) == 20\n assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000],k = 5) == 10000000\n assert candidate(candies = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000],k = 5000000) == 10\n assert candidate(candies = [10000000, 5000000, 3000000, 2000000, 1000000],k = 1000000) == 20\n"}, "metadata": {"canonical_parameter_names": ["candies", "k"], "leetcode_dataset_entry_point": "Solution().maximumCandies", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumCandies(int[] candies, long k) {", "container": "Solution", "callable": "maximumCandies", "parameters": [{"name": "candies", "type": "int[]"}, {"name": "k", "type": "long"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2231, "task_id": "largest-number-after-digit-swaps-by-parity", "difficulty": "Easy", "problem_description": "You are given a positive integer num. You may swap any two digits of num that have the same parity (i.e. both odd digits or both even digits).\nReturn the largest possible value of num after any number of swaps.\n \nExample 1:\n\nInput: num = 1234\nOutput: 3412\nExplanation: Swap the digit 3 with the digit 1, this results in the number 3214.\nSwap the digit 2 with the digit 4, this results in the number 3412.\nNote that there may be other sequences of swaps but it can be shown that 3412 is the largest possible number.\nAlso note that we may not swap the digit 4 with the digit 1 since they are of different parities.\n\nExample 2:\n\nInput: num = 65875\nOutput: 87655\nExplanation: Swap the digit 8 with the digit 6, this results in the number 85675.\nSwap the first digit 5 with the digit 7, this results in the number 87655.\nNote that there may be other sequences of swaps but it can be shown that 87655 is the largest possible number.\n\n \nConstraints:\n\n1 <= num <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 24680) == 86420\n assert candidate(num = 987654321) == 987654321\n assert candidate(num = 13524687) == 75386421\n assert candidate(num = 1000000) == 1000000\n assert candidate(num = 2222) == 2222\n assert candidate(num = 222222) == 222222\n assert candidate(num = 111111) == 111111\n assert candidate(num = 1111) == 1111\n assert candidate(num = 975318642) == 975318642\n assert candidate(num = 13579) == 97531\n assert candidate(num = 2468) == 8642\n assert candidate(num = 135246) == 531642\n assert candidate(num = 111) == 111\n assert candidate(num = 1234) == 3412\n assert candidate(num = 65875) == 87655\n assert candidate(num = 1919191919) == 9999911111\n assert candidate(num = 9753186420) == 9753186420\n assert candidate(num = 1234567890123456789) == 9898767654543232101\n assert candidate(num = 8642086420) == 8866442200\n assert candidate(num = 5432109876) == 9876543210\n assert candidate(num = 31415926535) == 95655342311\n assert candidate(num = 1111111111) == 1111111111\n assert candidate(num = 13579246801357924680) == 99775886645331142200\n assert candidate(num = 2222222222) == 2222222222\n assert candidate(num = 1928374655) == 9786554231\n assert candidate(num = 111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999) == 999999999988888888887777777777666666666655555555554444444444333333333322222222221111111111\n assert candidate(num = 1010101010) == 1010101010\n assert candidate(num = 198765432) == 978563412\n assert candidate(num = 1357913579) == 9977553311\n assert candidate(num = 10203040506070809) == 98647200500030001\n assert candidate(num = 1000000000) == 1000000000\n assert candidate(num = 123456789) == 987654321\n assert candidate(num = 9876543210) == 9876543210\n assert candidate(num = 111333555777) == 777555333111\n assert candidate(num = 333111555777) == 777555333111\n assert candidate(num = 222444666888) == 888666444222\n assert candidate(num = 973518642) == 975318642\n assert candidate(num = 8282828282) == 8888822222\n assert candidate(num = 1000000001) == 1000000001\n assert candidate(num = 1234567890987654321) == 9898767654543232101\n assert candidate(num = 999888777666555444333222111000) == 999888777666555444333222111000\n assert candidate(num = 8246035791) == 8642097531\n assert candidate(num = 5656565656565656565) == 5656565656565656565\n assert candidate(num = 973159731) == 997753311\n assert candidate(num = 1234567890) == 9876543210\n assert candidate(num = 111333555777999) == 999777555333111\n assert candidate(num = 543210987654321) == 987654543232101\n assert candidate(num = 908070605040302010) == 986472005000300010\n assert candidate(num = 8642097531) == 8642097531\n assert candidate(num = 191928283737) == 997788223311\n assert candidate(num = 1098765432) == 9876543210\n assert candidate(num = 100200400600800) == 186420000000000\n assert candidate(num = 102030405060708090) == 986472005000300010\n assert candidate(num = 2468024680) == 8866442200\n assert candidate(num = 987654321987654321) == 989876765543432121\n assert candidate(num = 59876543210) == 97856543210\n assert candidate(num = 2040608000) == 8642000000\n assert candidate(num = 555444333222111) == 555444333222111\n assert candidate(num = 5555555555) == 5555555555\n assert candidate(num = 99887766554433221100) == 99887766554433221100\n assert candidate(num = 2468135790) == 8642975310\n assert candidate(num = 1133557799) == 9977553311\n assert candidate(num = 111222333444555666777888999) == 999888777666555444333222111\n assert candidate(num = 111222333444) == 333444111222\n assert candidate(num = 7777777777) == 7777777777\n assert candidate(num = 98765432101234567890) == 98987676545432321010\n assert candidate(num = 9999999999) == 9999999999\n assert candidate(num = 9876543211111) == 9876543211111\n assert candidate(num = 1357924680) == 9753186420\n assert candidate(num = 111122223333444455556666777788889999) == 999988887777666655554444333322221111\n assert candidate(num = 1938765420) == 9758361420\n assert candidate(num = 9735186420) == 9753186420\n assert candidate(num = 987654321098765432109876543210) == 989898767676545454323232101010\n assert candidate(num = 9999999999888888888877777777776666666666555555555544444444443333333333222222222211111111110000000000) == 9999999999888888888877777777776666666666555555555544444444443333333333222222222211111111110000000000\n assert candidate(num = 2244668800) == 8866442200\n assert candidate(num = 112233445566778899) == 998877665544332211\n assert candidate(num = 2468013579) == 8642097531\n assert candidate(num = 8080808080) == 8888800000\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().largestInteger", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int largestInteger(int num) {", "container": "Solution", "callable": "largestInteger", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2232, "task_id": "minimize-result-by-adding-parentheses-to-expression", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string expression of the form \"+\" where and represent positive integers.\nAdd a pair of parentheses to expression such that after the addition of parentheses, expression is a valid mathematical expression and evaluates to the smallest possible value. The left parenthesis must be added to the left of '+' and the right parenthesis must be added to the right of '+'.\nReturn expression after adding a pair of parentheses such that expression evaluates to the smallest possible value. If there are multiple answers that yield the same result, return any of them.\nThe input has been generated such that the original value of expression, and the value of expression after adding any pair of parentheses that meets the requirements fits within a signed 32-bit integer.\n \nExample 1:\n\nInput: expression = \"247+38\"\nOutput: \"2(47+38)\"\nExplanation: The expression evaluates to 2 * (47 + 38) = 2 * 85 = 170.\nNote that \"2(4)7+38\" is invalid because the right parenthesis must be to the right of the '+'.\nIt can be shown that 170 is the smallest possible value.\n\nExample 2:\n\nInput: expression = \"12+34\"\nOutput: \"1(2+3)4\"\nExplanation: The expression evaluates to 1 * (2 + 3) * 4 = 1 * 5 * 4 = 20.\n\nExample 3:\n\nInput: expression = \"999+999\"\nOutput: \"(999+999)\"\nExplanation: The expression evaluates to 999 + 999 = 1998.\n\n \nConstraints:\n\n3 <= expression.length <= 10\nexpression consists of digits from '1' to '9' and '+'.\nexpression starts and ends with digits.\nexpression contains exactly one '+'.\nThe original value of expression, and the value of expression after adding any pair of parentheses that meets the requirements fits within a signed 32-bit integer.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(expression = \"56+78\") == \"(56+78)\"\n assert candidate(expression = \"5+6\") == \"(5+6)\"\n assert candidate(expression = \"3+8\") == \"(3+8)\"\n assert candidate(expression = \"111+222\") == \"1(11+22)2\"\n assert candidate(expression = \"3+2\") == \"(3+2)\"\n assert candidate(expression = \"5+678\") == \"(5+67)8\"\n assert candidate(expression = \"247+38\") == \"2(47+38)\"\n assert candidate(expression = \"3+12\") == \"(3+1)2\"\n assert candidate(expression = \"11+11\") == \"1(1+1)1\"\n assert candidate(expression = \"8+9\") == \"(8+9)\"\n assert candidate(expression = \"1+2\") == \"(1+2)\"\n assert candidate(expression = \"123+456\") == \"1(23+45)6\"\n assert candidate(expression = \"9+9\") == \"(9+9)\"\n assert candidate(expression = \"12+34\") == \"1(2+3)4\"\n assert candidate(expression = \"88+11\") == \"8(8+1)1\"\n assert candidate(expression = \"999+999\") == \"(999+999)\"\n assert candidate(expression = \"1+9\") == \"(1+9)\"\n assert candidate(expression = \"333+444\") == \"(333+444)\"\n assert candidate(expression = \"555+666\") == \"(555+666)\"\n assert candidate(expression = \"9+99\") == \"(9+99)\"\n assert candidate(expression = \"9+1\") == \"(9+1)\"\n assert candidate(expression = \"5+9\") == \"(5+9)\"\n assert candidate(expression = \"1+1\") == \"(1+1)\"\n assert candidate(expression = \"10+1\") == \"1(0+1)\"\n assert candidate(expression = \"12+3\") == \"1(2+3)\"\n assert candidate(expression = \"555+555\") == \"(555+555)\"\n assert candidate(expression = \"123+4\") == \"1(23+4)\"\n assert candidate(expression = \"9+876\") == \"(9+87)6\"\n assert candidate(expression = \"12345+6789\") == \"1(2345+6789)\"\n assert candidate(expression = \"56+789\") == \"(56+789)\"\n assert candidate(expression = \"1111+2222\") == \"1(111+222)2\"\n assert candidate(expression = \"123+4567\") == \"1(23+456)7\"\n assert candidate(expression = \"6666+7777\") == \"(6666+7777)\"\n assert candidate(expression = \"9999+1\") == \"9(999+1)\"\n assert candidate(expression = \"12+345\") == \"1(2+34)5\"\n assert candidate(expression = \"567+89\") == \"(567+89)\"\n assert candidate(expression = \"8+7654\") == \"(8+765)4\"\n assert candidate(expression = \"987+654\") == \"(987+654)\"\n assert candidate(expression = \"33+44\") == \"(33+44)\"\n assert candidate(expression = \"1234+56789\") == \"1(234+5678)9\"\n assert candidate(expression = \"7000+8000\") == \"(7000+8)000\"\n assert candidate(expression = \"99+11\") == \"9(9+1)1\"\n assert candidate(expression = \"333+666\") == \"(333+666)\"\n assert candidate(expression = \"345+678\") == \"(345+678)\"\n assert candidate(expression = \"50+50\") == \"(50+5)0\"\n assert candidate(expression = \"123+45\") == \"1(23+45)\"\n assert candidate(expression = \"5+55\") == \"(5+5)5\"\n assert candidate(expression = \"678+9\") == \"6(78+9)\"\n assert candidate(expression = \"12+345678\") == \"1(2+34)5678\"\n assert candidate(expression = \"900000+100000\") == \"(900000+1)00000\"\n assert candidate(expression = \"10+20\") == \"(10+2)0\"\n assert candidate(expression = \"12+3456789\") == \"1(2+34)56789\"\n assert candidate(expression = \"123456+789012\") == \"1(23456+78901)2\"\n assert candidate(expression = \"99+88\") == \"(99+88)\"\n assert candidate(expression = \"56+7890\") == \"(56+789)0\"\n assert candidate(expression = \"9+1234\") == \"(9+123)4\"\n assert candidate(expression = \"55555+66666\") == \"(55555+66666)\"\n assert candidate(expression = \"1234+56\") == \"1(234+56)\"\n assert candidate(expression = \"678+90123\") == \"(678+9012)3\"\n assert candidate(expression = \"44+555\") == \"(44+55)5\"\n assert candidate(expression = \"9+87654321\") == \"(9+8765432)1\"\n assert candidate(expression = \"2222+3333\") == \"2(222+333)3\"\n assert candidate(expression = \"1+999\") == \"(1+99)9\"\n assert candidate(expression = \"9876+5432\") == \"(9876+5432)\"\n assert candidate(expression = \"4321+9\") == \"43(21+9)\"\n assert candidate(expression = \"5678+910\") == \"(5678+91)0\"\n assert candidate(expression = \"987654+321098\") == \"(987654+321098)\"\n assert candidate(expression = \"100000+200000\") == \"(100000+2)00000\"\n assert candidate(expression = \"3000+4000\") == \"(3000+4)000\"\n assert candidate(expression = \"300000+400000\") == \"(300000+4)00000\"\n assert candidate(expression = \"100+100\") == \"(100+1)00\"\n assert candidate(expression = \"10+999\") == \"1(0+9)99\"\n assert candidate(expression = \"500000+600000\") == \"(500000+6)00000\"\n assert candidate(expression = \"5432+1\") == \"543(2+1)\"\n assert candidate(expression = \"1+9999\") == \"(1+999)9\"\n assert candidate(expression = \"3456+789\") == \"3(456+789)\"\n assert candidate(expression = \"5555+666\") == \"5(555+666)\"\n assert candidate(expression = \"123+6\") == \"1(23+6)\"\n assert candidate(expression = \"8888+9999\") == \"(8888+9999)\"\n assert candidate(expression = \"213+456\") == \"(213+456)\"\n assert candidate(expression = \"23+4567\") == \"(23+456)7\"\n assert candidate(expression = \"100+200\") == \"(100+2)00\"\n assert candidate(expression = \"9+8765432\") == \"(9+876543)2\"\n assert candidate(expression = \"111+111\") == \"1(11+11)1\"\n assert candidate(expression = \"77777+88888\") == \"(77777+88888)\"\n assert candidate(expression = \"99+1\") == \"9(9+1)\"\n assert candidate(expression = \"3+9999\") == \"(3+999)9\"\n assert candidate(expression = \"234+567\") == \"(234+567)\"\n assert candidate(expression = \"2+9999\") == \"(2+999)9\"\n assert candidate(expression = \"4321+876\") == \"4(321+876)\"\n assert candidate(expression = \"9000+1000\") == \"(9000+1)000\"\n assert candidate(expression = \"11+111\") == \"1(1+11)1\"\n assert candidate(expression = \"5+6789\") == \"(5+678)9\"\n assert candidate(expression = \"1+23456\") == \"(1+2)3456\"\n assert candidate(expression = \"1098+231\") == \"1(098+23)1\"\n assert candidate(expression = \"999+1\") == \"9(99+1)\"\n assert candidate(expression = \"4444+5555\") == \"(4444+5555)\"\n assert candidate(expression = \"55+55\") == \"(55+55)\"\n assert candidate(expression = \"777+888\") == \"(777+888)\"\n assert candidate(expression = \"98765+4321\") == \"9(8765+432)1\"\n assert candidate(expression = \"654+321\") == \"6(54+32)1\"\n assert candidate(expression = \"77+88\") == \"(77+88)\"\n assert candidate(expression = \"33333+44444\") == \"(33333+44444)\"\n assert candidate(expression = \"222+333\") == \"2(22+33)3\"\n assert candidate(expression = \"2+987654321\") == \"(2+98765432)1\"\n assert candidate(expression = \"123+45678\") == \"1(23+4567)8\"\n assert candidate(expression = \"9+8765\") == \"(9+876)5\"\n assert candidate(expression = \"5678+123\") == \"5(678+123)\"\n assert candidate(expression = \"1234+567\") == \"1(234+567)\"\n assert candidate(expression = \"234+56789\") == \"(234+5678)9\"\n assert candidate(expression = \"987654+321\") == \"987(654+32)1\"\n assert candidate(expression = \"876+54\") == \"(876+54)\"\n assert candidate(expression = \"123456+789\") == \"1(23456+789)\"\n assert candidate(expression = \"2000+1000\") == \"(2000+1)000\"\n assert candidate(expression = \"99999+11111\") == \"9(9999+1111)1\"\n assert candidate(expression = \"9876+543\") == \"(9876+543)\"\n assert candidate(expression = \"5000+6000\") == \"(5000+6)000\"\n assert candidate(expression = \"789+12\") == \"7(89+12)\"\n assert candidate(expression = \"1111+1111\") == \"1(111+111)1\"\n assert candidate(expression = \"700000+800000\") == \"(700000+8)00000\"\n assert candidate(expression = \"55+5\") == \"5(5+5)\"\n assert candidate(expression = \"1+99999\") == \"(1+9999)9\"\n assert candidate(expression = \"11+22\") == \"1(1+2)2\"\n assert candidate(expression = \"321+654\") == \"(321+654)\"\n assert candidate(expression = \"55+66\") == \"(55+66)\"\n assert candidate(expression = \"56789+12\") == \"5(6789+12)\"\n assert candidate(expression = \"1000+2000\") == \"(1000+2)000\"\n assert candidate(expression = \"1234+5678\") == \"1(234+5678)\"\n assert candidate(expression = \"11111+22222\") == \"1(1111+2222)2\"\n assert candidate(expression = \"6+66\") == \"(6+6)6\"\n assert candidate(expression = \"54321+6789\") == \"5(4321+6789)\"\n assert candidate(expression = \"123+456789\") == \"1(23+456)789\"\n assert candidate(expression = \"54+32\") == \"5(4+3)2\"\n assert candidate(expression = \"21+89\") == \"(21+89)\"\n"}, "metadata": {"canonical_parameter_names": ["expression"], "leetcode_dataset_entry_point": "Solution().minimizeResult", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String minimizeResult(String expression) {", "container": "Solution", "callable": "minimizeResult", "parameters": [{"name": "expression", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2233, "task_id": "maximum-product-after-k-increments", "difficulty": "Medium", "problem_description": "You are given an array of non-negative integers nums and an integer k. In one operation, you may choose any element from nums and increment it by 1.\nReturn the maximum product of nums after at most k operations. Since the answer may be very large, return it modulo 109 + 7. Note that you should maximize the product before taking the modulo. \n \nExample 1:\n\nInput: nums = [0,4], k = 5\nOutput: 20\nExplanation: Increment the first number 5 times.\nNow nums = [5, 4], with a product of 5 * 4 = 20.\nIt can be shown that 20 is maximum product possible, so we return 20.\nNote that there may be other ways to increment nums to have the maximum product.\n\nExample 2:\n\nInput: nums = [6,3,3,2], k = 2\nOutput: 216\nExplanation: Increment the second number 1 time and increment the fourth number 1 time.\nNow nums = [6, 4, 3, 3], with a product of 6 * 4 * 3 * 3 = 216.\nIt can be shown that 216 is maximum product possible, so we return 216.\nNote that there may be other ways to increment nums to have the maximum product.\n\n \nConstraints:\n\n1 <= nums.length, k <= 105\n0 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 7776\n assert candidate(nums = [1, 2, 3, 4],k = 3) == 108\n assert candidate(nums = [100000, 100000, 100000],k = 300000) == 944000007\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 94500000\n assert candidate(nums = [0, 4],k = 5) == 20\n assert candidate(nums = [0, 0, 0, 0],k = 10) == 36\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 540\n assert candidate(nums = [5, 5, 5, 5],k = 4) == 1296\n assert candidate(nums = [1, 1, 1, 1, 1],k = 10) == 243\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 508243680\n assert candidate(nums = [9, 9, 9, 9],k = 8) == 14641\n assert candidate(nums = [1000000],k = 1000000) == 2000000\n assert candidate(nums = [10, 10, 10],k = 5) == 1584\n assert candidate(nums = [6, 3, 3, 2],k = 2) == 216\n assert candidate(nums = [0, 0, 0, 0],k = 1) == 0\n assert candidate(nums = [1, 2, 3],k = 6) == 64\n assert candidate(nums = [1000000, 1000000],k = 1000000) == 999984257\n assert candidate(nums = [100000, 100000, 100000],k = 500000) == 830133340\n assert candidate(nums = [10, 20, 30],k = 15) == 15180\n assert candidate(nums = [1, 2, 3],k = 3) == 27\n assert candidate(nums = [1, 1, 1, 1],k = 10) == 144\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],k = 500000) == 800515855\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 10000) == 500226898\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 55) == 937424426\n assert candidate(nums = [100, 100, 100, 100, 100],k = 250) == 937499475\n assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 10) == 18750\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 = 200) == 138022365\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 1000) == 24010000\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 100) == 858490890\n assert candidate(nums = [1, 1000000],k = 999999) == 999993007\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 45) == 1000000000\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) == 836777896\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 100) == 385000049\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 500) == 514152040\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 508243680\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 209024971\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 48999587\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 20) == 248832\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 = 100) == 4900\n assert candidate(nums = [100, 200, 300, 400, 500],k = 1000) == 999781257\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 460935215\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 = 100) == 414469870\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 50) == 60466176\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 20) == 786432\n assert candidate(nums = [999999, 999998, 999997, 999996],k = 10000) == 58871243\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 913512597\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 50) == 904899965\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 200) == 340513509\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) == 322349693\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100000) == 570617225\n assert candidate(nums = [1, 3, 5, 7, 9],k = 20) == 59049\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 30) == 176221081\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 235146240\n assert candidate(nums = [1, 10, 100, 1000, 10000],k = 10000) == 49587669\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995],k = 100000) == 817421264\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 50) == 999999937\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],k = 200) == 73636025\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1024\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 50) == 608131681\n assert candidate(nums = [1, 3, 5, 7, 9],k = 25) == 100000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 937424426\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 50) == 73741817\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 = 100) == 911705284\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 30) == 60466176\n assert candidate(nums = [1, 10, 100, 1000, 10000],k = 100000) == 501184279\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 = 20) == 1048576\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 937424426\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000],k = 1000000) == 369628908\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 235146240\n assert candidate(nums = [1, 1000000],k = 999999) == 999993007\n assert candidate(nums = [1],k = 100000) == 100001\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],k = 1000000) == 679146511\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 = 1000000) == 825247221\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 500000) == 249964681\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 312500000\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 = 50) == 467201634\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100000) == 346266448\n assert candidate(nums = [1, 2, 3, 4, 5],k = 10) == 3125\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],k = 10000) == 607510375\n assert candidate(nums = [1000000, 999999, 999998],k = 1000000) == 448037452\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 50) == 73741817\n assert candidate(nums = [100000, 100000, 100000, 100000],k = 300000) == 765670962\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0],k = 25) == 983040\n assert candidate(nums = [10, 20, 30, 40, 50],k = 30) == 54000000\n assert candidate(nums = [1000000, 1000000, 1000000],k = 3000000) == 392\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],k = 1000) == 461240680\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 105099888\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 30) == 191102976\n assert candidate(nums = [1, 2, 3, 4, 5],k = 20) == 16807\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 550731776\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 100) == 47899023\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996],k = 10000) == 233771963\n assert candidate(nums = [1, 10, 100, 1000, 10000],k = 50000) == 901582326\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 50) == 650386593\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1000) == 889950771\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 312500000\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500],k = 500000) == 180658830\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 = 5000) == 881212280\n assert candidate(nums = [100000, 100000, 100000],k = 300000) == 944000007\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) == 785571733\n assert candidate(nums = [1, 2, 3, 4, 5],k = 15) == 7776\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumProduct(int[] nums, int k) {", "container": "Solution", "callable": "maximumProduct", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2234, "task_id": "maximum-total-beauty-of-the-gardens", "difficulty": "Hard", "problem_description": "Alice is a caretaker of n gardens and she wants to plant flowers to maximize the total beauty of all her gardens.\nYou are given a 0-indexed integer array flowers of size n, where flowers[i] is the number of flowers already planted in the ith garden. Flowers that are already planted cannot be removed. You are then given another integer newFlowers, which is the maximum number of flowers that Alice can additionally plant. You are also given the integers target, full, and partial.\nA garden is considered complete if it has at least target flowers. The total beauty of the gardens is then determined as the sum of the following:\n\nThe number of complete gardens multiplied by full.\nThe minimum number of flowers in any of the incomplete gardens multiplied by partial. If there are no incomplete gardens, then this value will be 0.\n\nReturn the maximum total beauty that Alice can obtain after planting at most newFlowers flowers.\n \nExample 1:\n\nInput: flowers = [1,3,1,1], newFlowers = 7, target = 6, full = 12, partial = 1\nOutput: 14\nExplanation: Alice can plant\n- 2 flowers in the 0th garden\n- 3 flowers in the 1st garden\n- 1 flower in the 2nd garden\n- 1 flower in the 3rd garden\nThe gardens will then be [3,6,2,2]. She planted a total of 2 + 3 + 1 + 1 = 7 flowers.\nThere is 1 garden that is complete.\nThe minimum number of flowers in the incomplete gardens is 2.\nThus, the total beauty is 1 * 12 + 2 * 1 = 12 + 2 = 14.\nNo other way of planting flowers can obtain a total beauty higher than 14.\n\nExample 2:\n\nInput: flowers = [2,4,5,3], newFlowers = 10, target = 5, full = 2, partial = 6\nOutput: 30\nExplanation: Alice can plant\n- 3 flowers in the 0th garden\n- 0 flowers in the 1st garden\n- 0 flowers in the 2nd garden\n- 2 flowers in the 3rd garden\nThe gardens will then be [5,4,5,5]. She planted a total of 3 + 0 + 0 + 2 = 5 flowers.\nThere are 3 gardens that are complete.\nThe minimum number of flowers in the incomplete gardens is 4.\nThus, the total beauty is 3 * 2 + 4 * 6 = 6 + 24 = 30.\nNo other way of planting flowers can obtain a total beauty higher than 30.\nNote that Alice could make all the gardens complete but in this case, she would obtain a lower total beauty.\n\n \nConstraints:\n\n1 <= flowers.length <= 105\n1 <= flowers[i], target <= 105\n1 <= newFlowers <= 1010\n1 <= full, partial <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(flowers = [10, 20, 30, 40, 50],newFlowers = 100,target = 25,full = 5,partial = 2) == 68\n assert candidate(flowers = [1, 1, 1, 1],newFlowers = 15,target = 3,full = 5,partial = 3) == 21\n assert candidate(flowers = [5, 5, 5, 5],newFlowers = 10,target = 5,full = 10,partial = 5) == 40\n assert candidate(flowers = [10, 20, 30],newFlowers = 100,target = 25,full = 50,partial = 10) == 340\n assert candidate(flowers = [10, 1, 2, 3],newFlowers = 15,target = 10,full = 5,partial = 2) == 20\n assert candidate(flowers = [1, 2, 3, 4, 5],newFlowers = 15,target = 5,full = 10,partial = 5) == 60\n assert candidate(flowers = [5, 5, 5, 5],newFlowers = 10,target = 5,full = 10,partial = 1) == 40\n assert candidate(flowers = [2, 4, 5, 3],newFlowers = 10,target = 5,full = 2,partial = 6) == 30\n assert candidate(flowers = [100000, 100000, 100000],newFlowers = 300000,target = 100000,full = 100000,partial = 100000) == 300000\n assert candidate(flowers = [1, 2, 3, 4, 5],newFlowers = 15,target = 4,full = 20,partial = 5) == 100\n assert candidate(flowers = [10, 10, 10],newFlowers = 0,target = 10,full = 100,partial = 50) == 300\n assert candidate(flowers = [1, 2, 3, 4, 5],newFlowers = 15,target = 5,full = 10,partial = 3) == 52\n assert candidate(flowers = [5, 5, 5, 5],newFlowers = 10,target = 5,full = 10,partial = 10) == 40\n assert candidate(flowers = [5, 5, 5, 5],newFlowers = 10,target = 5,full = 2,partial = 6) == 8\n assert candidate(flowers = [1, 1, 1, 1],newFlowers = 20,target = 3,full = 7,partial = 3) == 28\n assert candidate(flowers = [1, 3, 1, 1],newFlowers = 7,target = 6,full = 12,partial = 1) == 14\n assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 100,target = 10,full = 100,partial = 1) == 1000\n assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 100,target = 10,full = 30,partial = 20) == 450\n assert candidate(flowers = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],newFlowers = 1000000,target = 50000,full = 500,partial = 250) == 12504250\n assert candidate(flowers = [50000, 100000, 25000, 75000],newFlowers = 100000,target = 80000,full = 500,partial = 200) == 16001300\n assert candidate(flowers = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],newFlowers = 10000,target = 2000,full = 1000,partial = 500) == 1008500\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 7,full = 15,partial = 3) == 153\n assert candidate(flowers = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],newFlowers = 10000000000,target = 500000000,full = 100000,partial = 50000) == 25000000850000\n assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 500,target = 55,full = 15,partial = 7) == 513\n assert candidate(flowers = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],newFlowers = 1000000,target = 90000,full = 1000,partial = 500) == 10000\n assert candidate(flowers = [1, 10, 100, 1000, 10000, 100000],newFlowers = 100000,target = 50000,full = 1000,partial = 500) == 11112000\n assert candidate(flowers = [1, 5, 9, 13, 17, 21],newFlowers = 25,target = 15,full = 10,partial = 3) == 74\n assert candidate(flowers = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],newFlowers = 1000000,target = 100000,full = 1,partial = 1) == 10\n assert candidate(flowers = [50, 40, 30, 20, 10, 0, 0, 0, 0, 0],newFlowers = 150,target = 35,full = 100,partial = 20) == 940\n assert candidate(flowers = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],newFlowers = 10000000000,target = 100000,full = 1000,partial = 500) == 50008500\n assert candidate(flowers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],newFlowers = 5000,target = 500,full = 100,partial = 50) == 25850\n assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 50,target = 10,full = 15,partial = 5) == 180\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],newFlowers = 50,target = 8,full = 50,partial = 10) == 770\n assert candidate(flowers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],newFlowers = 50,target = 8,full = 20,partial = 5) == 215\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 100,target = 5,full = 20,partial = 15) == 240\n assert candidate(flowers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],newFlowers = 100,target = 4,full = 100,partial = 50) == 1050\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 5,full = 10,partial = 1) == 100\n assert candidate(flowers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],newFlowers = 50,target = 5,full = 100,partial = 50) == 1000\n assert candidate(flowers = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],newFlowers = 150,target = 35,full = 20,partial = 3) == 249\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 10,full = 20,partial = 10) == 270\n assert candidate(flowers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],newFlowers = 1000,target = 5,full = 100,partial = 50) == 1000\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],newFlowers = 100,target = 10,full = 30,partial = 15) == 555\n assert candidate(flowers = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],newFlowers = 1000000,target = 100000,full = 100000,partial = 100000) == 8030300000\n assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],newFlowers = 1000,target = 100,full = 50,partial = 25) == 3175\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 10000000000,target = 1,full = 100,partial = 50) == 1000\n assert candidate(flowers = [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],newFlowers = 500,target = 20,full = 150,partial = 75) == 5775\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],newFlowers = 500,target = 15,full = 25,partial = 10) == 615\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 5,full = 10,partial = 3) == 102\n assert candidate(flowers = [99990, 99991, 99992, 99993, 99994, 99995, 99996, 99997, 99998, 99999],newFlowers = 100000,target = 100000,full = 100000,partial = 100000) == 10000800000\n assert candidate(flowers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],newFlowers = 100,target = 11,full = 50,partial = 25) == 950\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 100,target = 5,full = 50,partial = 20) == 530\n assert candidate(flowers = [90, 90, 90, 90, 90, 90, 90, 90, 90, 90],newFlowers = 100,target = 95,full = 1000,partial = 500) == 56000\n assert candidate(flowers = [90000, 80000, 70000, 60000, 50000],newFlowers = 300000,target = 100000,full = 1000,partial = 500) == 50003500\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1,target = 1,full = 100,partial = 50) == 1000\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],newFlowers = 300,target = 15,full = 100,partial = 50) == 2600\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 10,full = 20,partial = 10) == 270\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 10000000000,target = 2,full = 1,partial = 1) == 10\n assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 1000,target = 60,full = 50,partial = 25) == 1925\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 5,full = 100,partial = 10) == 1000\n assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 1000,target = 55,full = 50,partial = 10) == 990\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 7,full = 20,partial = 5) == 210\n assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 100,target = 10,full = 20,partial = 5) == 225\n assert candidate(flowers = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],newFlowers = 1000000,target = 100000,full = 100000,partial = 50000) == 1000000\n assert candidate(flowers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],newFlowers = 50,target = 10,full = 20,partial = 10) == 270\n assert candidate(flowers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],newFlowers = 500,target = 3,full = 20,partial = 10) == 200\n assert candidate(flowers = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],newFlowers = 500,target = 45,full = 50,partial = 10) == 890\n assert candidate(flowers = [5, 5, 5, 5, 5],newFlowers = 25,target = 7,full = 50,partial = 5) == 250\n assert candidate(flowers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],newFlowers = 3000,target = 500,full = 50,partial = 25) == 12925\n assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 50,target = 10,full = 10,partial = 1) == 100\n assert candidate(flowers = [50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97],newFlowers = 100000,target = 10000,full = 1000,partial = 500) == 5008500\n assert candidate(flowers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],newFlowers = 20,target = 6,full = 20,partial = 10) == 230\n assert candidate(flowers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],newFlowers = 5000,target = 500,full = 1000,partial = 100) == 58900\n assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 1000,target = 60,full = 50,partial = 10) == 1040\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 5,full = 100,partial = 50) == 2100\n assert candidate(flowers = [50, 30, 20, 10, 5],newFlowers = 150,target = 25,full = 10,partial = 5) == 160\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 2,full = 50,partial = 25) == 4250\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 30,target = 6,full = 10,partial = 3) == 105\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 0,target = 5,full = 50,partial = 10) == 310\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 5,full = 100,partial = 50) == 8400\n assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 100,target = 10,full = 20,partial = 10) == 270\n assert candidate(flowers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],newFlowers = 1000,target = 40,full = 50,partial = 20) == 1230\n assert candidate(flowers = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],newFlowers = 200,target = 25,full = 100,partial = 50) == 2100\n assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 500,target = 40,full = 20,partial = 10) == 570\n assert candidate(flowers = [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],newFlowers = 700,target = 20,full = 50,partial = 20) == 1580\n assert candidate(flowers = [100, 200, 300, 400, 500],newFlowers = 1000,target = 350,full = 15,partial = 5) == 1805\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 15,target = 5,full = 100,partial = 10) == 1000\n assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 150,target = 80,full = 150,partial = 75) == 4950\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 30,target = 7,full = 10,partial = 5) == 120\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 1,target = 1,full = 1000,partial = 500) == 10000\n assert candidate(flowers = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],newFlowers = 200,target = 55,full = 100,partial = 50) == 3600\n assert candidate(flowers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],newFlowers = 50,target = 10,full = 100,partial = 50) == 1350\n assert candidate(flowers = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],newFlowers = 1000000,target = 50000,full = 1000,partial = 500) == 25008500\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 250,target = 5,full = 100,partial = 50) == 1100\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],newFlowers = 500,target = 15,full = 75,partial = 35) == 1915\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 8,full = 20,partial = 10) == 250\n assert candidate(flowers = [90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 0],newFlowers = 150000,target = 60000,full = 500,partial = 200) == 10002000\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 100,target = 5,full = 100,partial = 50) == 1100\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 7,full = 100,partial = 50) == 1200\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 100,target = 5,full = 50,partial = 25) == 1050\n assert candidate(flowers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],newFlowers = 45,target = 5,full = 15,partial = 10) == 175\n assert candidate(flowers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],newFlowers = 250,target = 30,full = 200,partial = 100) == 4700\n assert candidate(flowers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],newFlowers = 100,target = 7,full = 20,partial = 5) == 210\n assert candidate(flowers = [1, 2, 3, 4, 5],newFlowers = 1000000,target = 10,full = 100000,partial = 10000) == 500000\n assert candidate(flowers = [2, 4, 6, 8, 10, 12, 14],newFlowers = 30,target = 15,full = 7,partial = 5) == 71\n assert candidate(flowers = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],newFlowers = 10000,target = 995,full = 100,partial = 50) == 50600\n assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 500,target = 75,full = 1000,partial = 100) == 16400\n assert candidate(flowers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],newFlowers = 5000,target = 750,full = 250,partial = 125) == 97125\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],newFlowers = 200,target = 10,full = 50,partial = 25) == 925\n assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 10,full = 10,partial = 1) == 100\n assert candidate(flowers = [100000, 99999, 99998, 99997, 99996, 99995],newFlowers = 150000,target = 100000,full = 100000,partial = 100000) == 10000400000\n assert candidate(flowers = [1, 5, 9, 13, 17, 21],newFlowers = 20,target = 15,full = 10,partial = 3) == 67\n assert candidate(flowers = [50, 40, 30, 20, 10],newFlowers = 100,target = 35,full = 100,partial = 50) == 2100\n assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 100,target = 5,full = 5,partial = 2) == 53\n"}, "metadata": {"canonical_parameter_names": ["flowers", "newFlowers", "target", "full", "partial"], "leetcode_dataset_entry_point": "Solution().maximumBeauty", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumBeauty(int[] flowers, long newFlowers, int target, int full, int partial) {", "container": "Solution", "callable": "maximumBeauty", "parameters": [{"name": "flowers", "type": "int[]"}, {"name": "newFlowers", "type": "long"}, {"name": "target", "type": "int"}, {"name": "full", "type": "int"}, {"name": "partial", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2235, "task_id": "add-two-integers", "difficulty": "Easy", "problem_description": "Given two integers num1 and num2, return the sum of the two integers.\n \nExample 1:\n\nInput: num1 = 12, num2 = 5\nOutput: 17\nExplanation: num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned.\n\nExample 2:\n\nInput: num1 = -10, num2 = 4\nOutput: -6\nExplanation: num1 + num2 = -6, so -6 is returned.\n\n \nConstraints:\n\n-100 <= num1, num2 <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num1 = 100,num2 = -100) == 0\n assert candidate(num1 = -10,num2 = 4) == -6\n assert candidate(num1 = 25,num2 = 25) == 50\n assert candidate(num1 = -50,num2 = 50) == 0\n assert candidate(num1 = 99,num2 = 1) == 100\n assert candidate(num1 = -50,num2 = 25) == -25\n assert candidate(num1 = -30,num2 = -70) == -100\n assert candidate(num1 = 100,num2 = 100) == 200\n assert candidate(num1 = 12,num2 = 5) == 17\n assert candidate(num1 = 0,num2 = 0) == 0\n assert candidate(num1 = -100,num2 = -100) == -200\n assert candidate(num1 = -99,num2 = -1) == -100\n assert candidate(num1 = 50,num2 = -50) == 0\n assert candidate(num1 = -45,num2 = -55) == -100\n assert candidate(num1 = -73,num2 = -27) == -100\n assert candidate(num1 = 80,num2 = -30) == 50\n assert candidate(num1 = 23,num2 = -23) == 0\n assert candidate(num1 = -75,num2 = 20) == -55\n assert candidate(num1 = 100,num2 = 0) == 100\n assert candidate(num1 = 0,num2 = -100) == -100\n assert candidate(num1 = -1,num2 = -99) == -100\n assert candidate(num1 = -45,num2 = 65) == 20\n assert candidate(num1 = 22,num2 = 78) == 100\n assert candidate(num1 = 98,num2 = 2) == 100\n assert candidate(num1 = 45,num2 = -55) == -10\n assert candidate(num1 = -75,num2 = 25) == -50\n assert candidate(num1 = -88,num2 = 12) == -76\n assert candidate(num1 = -75,num2 = -25) == -100\n assert candidate(num1 = 1,num2 = 99) == 100\n assert candidate(num1 = -100,num2 = 0) == -100\n assert candidate(num1 = 42,num2 = -42) == 0\n assert candidate(num1 = -49,num2 = 51) == 2\n assert candidate(num1 = -99,num2 = 1) == -98\n assert candidate(num1 = 0,num2 = 100) == 100\n assert candidate(num1 = 45,num2 = -45) == 0\n assert candidate(num1 = 50,num2 = -60) == -10\n assert candidate(num1 = 88,num2 = 12) == 100\n assert candidate(num1 = -45,num2 = 55) == 10\n assert candidate(num1 = 67,num2 = -33) == 34\n assert candidate(num1 = -33,num2 = -67) == -100\n assert candidate(num1 = -30,num2 = 70) == 40\n assert candidate(num1 = -67,num2 = 33) == -34\n assert candidate(num1 = 99,num2 = -1) == 98\n assert candidate(num1 = 73,num2 = 27) == 100\n assert candidate(num1 = 75,num2 = -25) == 50\n assert candidate(num1 = -45,num2 = 45) == 0\n assert candidate(num1 = -100,num2 = 100) == 0\n assert candidate(num1 = -23,num2 = 23) == 0\n assert candidate(num1 = 67,num2 = 33) == 100\n assert candidate(num1 = 50,num2 = 50) == 100\n assert candidate(num1 = -50,num2 = -50) == -100\n assert candidate(num1 = 28,num2 = -28) == 0\n assert candidate(num1 = 45,num2 = 55) == 100\n assert candidate(num1 = 33,num2 = 67) == 100\n assert candidate(num1 = 75,num2 = 25) == 100\n assert candidate(num1 = 49,num2 = 51) == 100\n assert candidate(num1 = -23,num2 = 77) == 54\n assert candidate(num1 = 37,num2 = 63) == 100\n assert candidate(num1 = 29,num2 = 71) == 100\n"}, "metadata": {"canonical_parameter_names": ["num1", "num2"], "leetcode_dataset_entry_point": "Solution().sum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int sum(int num1, int num2) {", "container": "Solution", "callable": "sum", "parameters": [{"name": "num1", "type": "int"}, {"name": "num2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2236, "task_id": "root-equals-sum-of-children", "difficulty": "Easy", "problem_description": "You are given the root of a binary tree that consists of exactly 3 nodes: the root, its left child, and its right child.\nReturn true if the value of the root is equal to the sum of the values of its two children, or false otherwise.\n \nExample 1:\n\n\nInput: root = [10,4,6]\nOutput: true\nExplanation: The values of the root, its left child, and its right child are 10, 4, and 6, respectively.\n10 is equal to 4 + 6, so we return true.\n\nExample 2:\n\n\nInput: root = [5,3,1]\nOutput: false\nExplanation: The values of the root, its left child, and its right child are 5, 3, and 1, respectively.\n5 is not equal to 3 + 1, so we return false.\n\n \nConstraints:\n\nThe tree consists only of the root, its left child, and its right child.\n-100 <= Node.val <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, -1, 2])) == True\n assert candidate(root = tree_node([-5, -3, -2])) == True\n assert candidate(root = tree_node([5, 3, 1])) == False\n assert candidate(root = tree_node([99, 50, 49])) == True\n assert candidate(root = tree_node([-100, 50, 50])) == False\n assert candidate(root = tree_node([100, -50, 150])) == True\n assert candidate(root = tree_node([1, 0, 1])) == True\n assert candidate(root = tree_node([2, 1, 1])) == True\n assert candidate(root = tree_node([0, 0, 0])) == True\n assert candidate(root = tree_node([10, 4, 6])) == True\n assert candidate(root = tree_node([-1, 1, 0])) == False\n assert candidate(root = tree_node([100, 0, 100])) == True\n assert candidate(root = tree_node([50, -25, 75])) == True\n assert candidate(root = tree_node([99, -50, 149])) == True\n assert candidate(root = tree_node([-100, 0, -100])) == True\n assert candidate(root = tree_node([0, 100, -100])) == True\n assert candidate(root = tree_node([100, -1, 101])) == True\n assert candidate(root = tree_node([2, 1, 1])) == True\n assert candidate(root = tree_node([-100, -99, -1])) == True\n assert candidate(root = tree_node([-100, 100, 0])) == False\n assert candidate(root = tree_node([99, -1, -98])) == False\n assert candidate(root = tree_node([-100, 33, -67])) == False\n assert candidate(root = tree_node([0, -1, 1])) == True\n assert candidate(root = tree_node([-100, 0, 0])) == False\n assert candidate(root = tree_node([0, -1, 1])) == True\n assert candidate(root = tree_node([50, 25, 25])) == True\n assert candidate(root = tree_node([1, 100, -99])) == True\n assert candidate(root = tree_node([-75, -25, -50])) == True\n assert candidate(root = tree_node([-1, -1, 0])) == True\n assert candidate(root = tree_node([5, 5, 0])) == True\n assert candidate(root = tree_node([100, 1, 99])) == True\n assert candidate(root = tree_node([-100, -50, -50])) == True\n assert candidate(root = tree_node([99, 49, 50])) == True\n assert candidate(root = tree_node([-60, -40, -20])) == True\n assert candidate(root = tree_node([100, 50, 50])) == True\n assert candidate(root = tree_node([1, 0, 1])) == True\n assert candidate(root = tree_node([-50, -25, -25])) == True\n assert candidate(root = tree_node([-2, -1, -1])) == True\n assert candidate(root = tree_node([-99, 99, -198])) == True\n assert candidate(root = tree_node([99, 49, 50])) == True\n assert candidate(root = tree_node([33, 16, 17])) == True\n assert candidate(root = tree_node([-99, 50, -51])) == False\n assert candidate(root = tree_node([50, 24, 26])) == True\n assert candidate(root = tree_node([100, -100, 200])) == True\n assert candidate(root = tree_node([-25, -25, 50])) == False\n assert candidate(root = tree_node([1, -1, 2])) == True\n assert candidate(root = tree_node([1, 99, -98])) == True\n assert candidate(root = tree_node([100, 50, 50])) == True\n assert candidate(root = tree_node([100, -50, 50])) == False\n assert candidate(root = tree_node([-1, 99, -98])) == False\n assert candidate(root = tree_node([50, 25, -25])) == False\n assert candidate(root = tree_node([100, 99, 1])) == True\n assert candidate(root = tree_node([99, -99, 198])) == True\n assert candidate(root = tree_node([10, 3, 7])) == True\n assert candidate(root = tree_node([-100, 0, 100])) == False\n assert candidate(root = tree_node([50, 25, 25])) == True\n assert candidate(root = tree_node([1, 1, 0])) == True\n assert candidate(root = tree_node([-99, -49, -50])) == True\n assert candidate(root = tree_node([1, 2, -1])) == True\n assert candidate(root = tree_node([-10, -5, -5])) == True\n assert candidate(root = tree_node([100, -100, 200])) == True\n assert candidate(root = tree_node([-1, -50, 49])) == True\n assert candidate(root = tree_node([-7, -3, -4])) == True\n assert candidate(root = tree_node([-100, 50, -50])) == False\n assert candidate(root = tree_node([10, -10, 20])) == True\n assert candidate(root = tree_node([-100, -100, 0])) == True\n assert candidate(root = tree_node([50, -25, -25])) == False\n assert candidate(root = tree_node([1, -50, 51])) == True\n assert candidate(root = tree_node([7, 3, 4])) == True\n assert candidate(root = tree_node([-50, 25, 25])) == False\n assert candidate(root = tree_node([33, 32, 1])) == True\n assert candidate(root = tree_node([-100, -50, -50])) == True\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().checkTree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2239, "task_id": "find-closest-number-to-zero", "difficulty": "Easy", "problem_description": "Given an integer array nums of size n, return the number with the value closest to 0 in nums. If there are multiple answers, return the number with the largest value.\n \nExample 1:\n\nInput: nums = [-4,-2,1,4,8]\nOutput: 1\nExplanation:\nThe distance from -4 to 0 is |-4| = 4.\nThe distance from -2 to 0 is |-2| = 2.\nThe distance from 1 to 0 is |1| = 1.\nThe distance from 4 to 0 is |4| = 4.\nThe distance from 8 to 0 is |8| = 8.\nThus, the closest number to 0 in the array is 1.\n\nExample 2:\n\nInput: nums = [2,-1,1]\nOutput: 1\nExplanation: 1 and -1 are both the closest numbers to 0, so 1 being larger is returned.\n\n \nConstraints:\n\n1 <= n <= 1000\n-105 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, -3, 2, -2, 1, -1]) == 1\n assert candidate(nums = [100000, -100000, 50000, -50000]) == 50000\n assert candidate(nums = [100000, -100000, 50000, -50000]) == 50000\n assert candidate(nums = [7, -10, 4, 3, -20, 2]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [0, 5, -5]) == 0\n assert candidate(nums = [-5, -3, -1, -4, -2]) == -1\n assert candidate(nums = [0, 1, -1]) == 0\n assert candidate(nums = [-1]) == -1\n assert candidate(nums = [-10, -9, 9, 10]) == 9\n assert candidate(nums = [-5, -5, -5, -5, -5]) == -5\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3]) == 0\n assert candidate(nums = [-100000, 100000]) == 100000\n assert candidate(nums = [-10, -5, 0, 5, 10]) == 0\n assert candidate(nums = [-10, 10, 0]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [-5, -4, -3, -2, -1]) == -1\n assert candidate(nums = [-4, -2, 1, 4, 8]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [100000, -100000, 50000, -50000, 0]) == 0\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1\n assert candidate(nums = [-100000]) == -100000\n assert candidate(nums = [-10, -3, -1, 0, 1, 3, 10]) == 0\n assert candidate(nums = [100000]) == 100000\n assert candidate(nums = [-10, -5, 0, 5, 10]) == 0\n assert candidate(nums = [-5, -4, -3, -2, -1]) == -1\n assert candidate(nums = [5, 3, 1, 4, 2]) == 1\n assert candidate(nums = [2, -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, 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\n assert candidate(nums = [12345, -12345, 11111, -11111, 22222, -22222, 33333, -33333, 44444, -44444, 55555, -55555, 66666, -66666, 77777, -77777, 88888, -88888, 99999, -99999]) == 11111\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, -1, -3, -7, -15, -31, -62, -125, -250, -500, -1000]) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 7\n assert candidate(nums = [5000, -5000, 2500, -2500, 1250, -1250, 625, -625, 312, -312, 156, -156]) == 156\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980, -9980, -9981, -9982, -9983, -9984, -9985, -9986, -9987, -9988, -9989, -9990, -9991, -9992, -9993, -9994, -9995, -9996, -9997, -9998, -9999, -10000]) == 9980\n assert candidate(nums = [-1, -1, -1, -1, 1, 1, 1, 1]) == 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, 0]) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, 0, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [-99999, -50000, -10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000, 50000, 99999]) == 0\n assert candidate(nums = [-50, -25, 0, 25, 50, -12, 12, -7, 7, -3, 3, -1, 1]) == 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\n assert candidate(nums = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [-50000, -49999, 49999, 50000, 0]) == 0\n assert candidate(nums = [-10000, -9999, -9998, -9997, 9997, 9998, 9999, 10000, 0]) == 0\n assert candidate(nums = [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]) == 0\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900]) == 100\n assert candidate(nums = [50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [3, -1, -3, 1, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n assert candidate(nums = [-50000, -25000, -12500, -6250, -3125, -1562, -781, -390, -195, -97, -48, -24, -12, -6, -3, -1, 1, 3, 6, 12, 24, 48, 97, 195, 390, 781, 1562, 3125, 6250, 12500, 25000, 50000]) == 1\n assert candidate(nums = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85, 95, -95]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 0]) == 0\n assert candidate(nums = [0, -1, 1, -100000, 100000]) == 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]) == -1\n assert candidate(nums = [82345, -82345, 67890, -67890, 54321, -54321, 43210, -43210, 32109, -32109, 21098, -21098]) == 21098\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\n assert candidate(nums = [1, -1, 100000, -100000, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n assert candidate(nums = [-7, -14, -21, -28, -35, -42, -49, -56, -63, -70]) == -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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [0, -100000, 100000, -99999, 99999]) == 0\n assert candidate(nums = [-1000, 1000, 0, 500, -500, 250, -250, 125, -125, 62, -62, 31, -31, 15, -15, 7, -7, 3, -3, 1, -1]) == 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, 11, -12, 12, -13, 13, -14, 14, -15, 15]) == 1\n assert candidate(nums = [-100000, -99999, 99999, 100000]) == 99999\n assert candidate(nums = [1000, 1001, 999, 998, 1002, 997, 1003, 996, 1004, 995, 0, -1, -2, -3, -4]) == 0\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, -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]) == 70\n assert candidate(nums = [-50, -25, 0, 25, 50]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 0\n assert candidate(nums = [98765, 43210, 87654, 32109, 76543, 21098, 65432, 10987, 54321, 9876, 4321, 8765, 3210, 7654, 2109, 6543, 1098, 5432, 987, 432, 876, 321, 765, 210, 654, 109, 543, 98, 43, 87, 32, 76, 21, 65, 10, 5, 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, 21, 22, 23, 24, 25]) == 1\n assert candidate(nums = [123, -123, 456, -456, 789, -789, 101112, -101112, 131415, -131415, 0]) == 0\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, -49991, -49992, -49993, -49994, -49995, -49996, -49997, -49998, -49999, -50000]) == 49991\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [99998, -99998, 99999, -99999, 0]) == 0\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 = [-98765, 98765, -87654, 87654, -76543, 76543, -65432, 65432, -54321, 54321, -43210, 43210, -32109, 32109, -21098, 21098, -10987, 10987, -9876, 9876]) == 9876\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 100\n assert candidate(nums = [-33333, 33333, -66666, 66666, -100000, 100000, 0, 1, -1, 2, -2]) == 0\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, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970, -100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990, -99989, -99988, -99987, -99986, -99985, -99984, -99983, -99982, -99981, -99980, -99979, -99978, -99977, -99976, -99975, -99974, -99973, -99972, -99971, -99970]) == 99970\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 = [50000, -50000, 49999, -49999, 49998, -49998, 100000, -100000]) == 49998\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980, 9979, 9978, 9977, 9976, 9975, 9974, 9973, 9972, 9971, 9970, 9969, 9968, 9967, 9966, 9965, 9964, 9963, 9962, 9961, 9960, 9959, 9958, 9957, 9956, 9955, 9954, 9953, 9952, 9951, 9950, 9949, 9948, 9947, 9946, 9945, 9944, 9943, 9942, 9941, 9940, 9939, 9938, 9937, 9936, 9935, 9934, 9933, 9932, 9931, 9930, 9929, 9928, 9927, 9926, 9925, 9924, 9923, 9922, 9921, 9920, 9919, 9918, 9917, 9916, 9915, 9914, 9913, 9912, 9911, 9910, 9909, 9908, 9907, 9906, 9905, 9904, 9903, 9902, 9901, 9900, 9899, 9898, 9897, 9896, 9895, 9894, 9893, 9892, 9891, 9890, 9889, 9888, 9887, 9886, 9885, 9884, 9883, 9882, 9881, 9880, 9879, 9878, 9877, 9876, 9875, 9874, 9873, 9872, 9871, 9870, 9869, 9868, 9867, 9866, 9865, 9864, 9863, 9862, 9861, 9860, 9859, 9858, 9857, 9856, 9855, 9854, 9853, 9852, 9851, 9850, 9849, 9848, 9847, 9846, 9845, 9844, 9843, 9842, 9841, 9840, 9839, 9838, 9837, 9836, 9835, 9834, 9833, 9832, 9831, 9830, 9829, 9828, 9827, 9826, 9825, 9824, 9823, 9822, 9821, 9820, 9819, 9818, 9817, 9816, 9815, 9814, 9813, 9812, 9811, 9810, 9809, 9808, 9807, 9806, 9805, 9804, 9803, 9802, 9801, 9800]) == 9800\n assert candidate(nums = [-1000, -500, -250, -125, -62, -31, -15, -7, -3, -1, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]) == 1\n assert candidate(nums = [-5000, 5000, -1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -6000, 6000, -7000, 7000, -8000, 8000]) == 1000\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, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [100000, -99999, 99999, -100000, 50000, -49999, 49999, -50000]) == 49999\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -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 = [-99999, -99998, -99997, 99997, 99998, 99999]) == 99997\n assert candidate(nums = [-50000, 50000, -49999, 49999, -49998, 49998, 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 = [0, -100000, 100000, -99999, 99999, -99998, 99998, -99997, 99997, -99996, 99996, -99995, 99995, -99994, 99994, -99993, 99993, -99992, 99992, -99991, 99991, -99990, 99990, -99989, 99989, -99988, 99988, -99987, 99987, -99986, 99986, -99985, 99985, -99984, 99984, -99983, 99983, -99982, 99982, -99981, 99981, -99980, 99980, -99979, 99979, -99978, 99978, -99977, 99977, -99976, 99976, -99975, 99975, -99974, 99974, -99973, 99973, -99972, 99972, -99971, 99971, -99970, 99970]) == 0\n assert candidate(nums = [10000, -10000, 5000, -5000, 1000, -1000, 500, -500, 100, -100, 50, -50, 10, -10, 5, -5, 1, -1]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [23, -23, 46, -46, 92, -92, 184, -184, 368, -368, 736, -736, 1472, -1472, 2944, -2944]) == 23\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, -99979, -99978, -99977, -99976, -99975, -99974, -99973, -99972, -99971, -99970]) == -99970\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 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 0\n assert candidate(nums = [100, 200, -150, 150, 0, -50, 50, -200]) == 0\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, -100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 90\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]) == 100\n assert candidate(nums = [99999, -99999, 99998, -99998, 99997, -99997, 99996, -99996, 99995, -99995, 0]) == 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]) == 1\n assert candidate(nums = [98765, -98765, 43210, -43210, 86421, -86421, 12345, -12345, 0]) == 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, -11, 12, -12]) == 1\n assert candidate(nums = [-1000, -999, -998, 998, 999, 1000, 500, -500, 250, -250]) == 250\n assert candidate(nums = [99995, 99996, 99997, 99998, 99999, -99995, -99996, -99997, -99998, -99999]) == 99995\n assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40]) == 5\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -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, -21, -22, -23, -24, -25]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, -99991, -99992, -99993, -99994, -99995, -99996, -99997, -99998, -99999, -100000]) == 99991\n assert candidate(nums = [-10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000]) == 1\n assert candidate(nums = [-54321, 54321, -12345, 12345, -6789, 6789, -3456, 3456, -789, 789]) == 789\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, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 1\n assert candidate(nums = [-99999, 99999, -50000, 50000, -25000, 25000, -12500, 12500, -6250, 6250, -3125, 3125]) == 3125\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 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\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]) == 1\n assert candidate(nums = [3, 5, -3, -5, 7, -7, 2, -2, 0]) == 0\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\n assert candidate(nums = [-50000, -25000, -10000, -5000, -1000, -500, -100, -50, -10, -1, 0, 1, 10, 50, 100, 500, 1000, 5000, 10000, 25000, 50000]) == 0\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, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970]) == 99970\n assert candidate(nums = [-99999, -99998, -99997, -99996, 99996, 99997, 99998, 99999]) == 99996\n assert candidate(nums = [-500, -250, 0, 250, 500, -249, 249]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0]) == 0\n assert candidate(nums = [0, -1, 1, -100000, 100000, -99999, 99999, -10, 10, -5, 5, -2, 2, -3, 3]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findClosestNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findClosestNumber(int[] nums) {", "container": "Solution", "callable": "findClosestNumber", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2240, "task_id": "number-of-ways-to-buy-pens-and-pencils", "difficulty": "Medium", "problem_description": "You are given an integer total indicating the amount of money you have. You are also given two integers cost1 and cost2 indicating the price of a pen and pencil respectively. You can spend part or all of your money to buy multiple quantities (or none) of each kind of writing utensil.\nReturn the number of distinct ways you can buy some number of pens and pencils.\n \nExample 1:\n\nInput: total = 20, cost1 = 10, cost2 = 5\nOutput: 9\nExplanation: The price of a pen is 10 and the price of a pencil is 5.\n- If you buy 0 pens, you can buy 0, 1, 2, 3, or 4 pencils.\n- If you buy 1 pen, you can buy 0, 1, or 2 pencils.\n- If you buy 2 pens, you cannot buy any pencils.\nThe total number of ways to buy pens and pencils is 5 + 3 + 1 = 9.\n\nExample 2:\n\nInput: total = 5, cost1 = 10, cost2 = 10\nOutput: 1\nExplanation: The price of both pens and pencils are 10, which cost more than total, so you cannot buy any writing utensils. Therefore, there is only 1 way: buy 0 pens and 0 pencils.\n\n \nConstraints:\n\n1 <= total, cost1, cost2 <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(total = 20,cost1 = 10,cost2 = 5) == 9\n assert candidate(total = 1000,cost1 = 1,cost2 = 1) == 501501\n assert candidate(total = 5,cost1 = 10,cost2 = 10) == 1\n assert candidate(total = 5,cost1 = 10,cost2 = 10) == 1\n assert candidate(total = 100,cost1 = 1,cost2 = 1) == 5151\n assert candidate(total = 50,cost1 = 7,cost2 = 11) == 23\n assert candidate(total = 100,cost1 = 20,cost2 = 30) == 14\n assert candidate(total = 50,cost1 = 10,cost2 = 20) == 12\n assert candidate(total = 1000000,cost1 = 500000,cost2 = 500000) == 6\n assert candidate(total = 20,cost1 = 10,cost2 = 5) == 9\n assert candidate(total = 1000000,cost1 = 500000,cost2 = 500000) == 6\n assert candidate(total = 1000000,cost1 = 500000,cost2 = 300000) == 7\n assert candidate(total = 10,cost1 = 3,cost2 = 7) == 6\n assert candidate(total = 10,cost1 = 5,cost2 = 2) == 10\n assert candidate(total = 1,cost1 = 1,cost2 = 1) == 3\n assert candidate(total = 50,cost1 = 25,cost2 = 20) == 6\n assert candidate(total = 100,cost1 = 1,cost2 = 1) == 5151\n assert candidate(total = 500,cost1 = 250,cost2 = 250) == 6\n assert candidate(total = 1,cost1 = 2,cost2 = 3) == 1\n assert candidate(total = 500,cost1 = 5,cost2 = 7) == 3665\n assert candidate(total = 150,cost1 = 25,cost2 = 15) == 40\n assert candidate(total = 100,cost1 = 100,cost2 = 100) == 3\n assert candidate(total = 1234,cost1 = 123,cost2 = 456) == 21\n assert candidate(total = 800,cost1 = 120,cost2 = 30) == 105\n assert candidate(total = 100,cost1 = 50,cost2 = 100) == 4\n assert candidate(total = 100,cost1 = 50,cost2 = 50) == 6\n assert candidate(total = 1000,cost1 = 100,cost2 = 200) == 36\n assert candidate(total = 100000,cost1 = 1000,cost2 = 500) == 10201\n assert candidate(total = 999999,cost1 = 99999,cost2 = 1) == 5500055\n assert candidate(total = 80,cost1 = 8,cost2 = 5) == 95\n assert candidate(total = 200,cost1 = 15,cost2 = 4) == 368\n assert candidate(total = 1000,cost1 = 150,cost2 = 100) == 44\n assert candidate(total = 100,cost1 = 7,cost2 = 3) == 265\n assert candidate(total = 1000,cost1 = 150,cost2 = 75) == 56\n assert candidate(total = 1000000,cost1 = 999999,cost2 = 999999) == 3\n assert candidate(total = 123456,cost1 = 11111,cost2 = 22222) == 42\n assert candidate(total = 100000,cost1 = 33333,cost2 = 33333) == 10\n assert candidate(total = 999999,cost1 = 1000,cost2 = 999) == 501501\n assert candidate(total = 10000,cost1 = 100,cost2 = 50) == 10201\n assert candidate(total = 200,cost1 = 50,cost2 = 25) == 25\n assert candidate(total = 500000,cost1 = 999999,cost2 = 1) == 500001\n assert candidate(total = 150,cost1 = 5,cost2 = 3) == 796\n assert candidate(total = 999999,cost1 = 100000,cost2 = 50000) == 110\n assert candidate(total = 123456,cost1 = 12345,cost2 = 6543) == 109\n assert candidate(total = 10000,cost1 = 50,cost2 = 30) == 33634\n assert candidate(total = 500,cost1 = 250,cost2 = 100) == 10\n assert candidate(total = 100000,cost1 = 1,cost2 = 1) == 5000150001\n assert candidate(total = 250,cost1 = 75,cost2 = 25) == 26\n assert candidate(total = 500,cost1 = 150,cost2 = 125) == 11\n assert candidate(total = 1000,cost1 = 10,cost2 = 1) == 50601\n assert candidate(total = 999,cost1 = 1,cost2 = 1) == 500500\n assert candidate(total = 1000,cost1 = 500,cost2 = 250) == 9\n assert candidate(total = 200,cost1 = 10,cost2 = 100) == 33\n assert candidate(total = 120,cost1 = 30,cost2 = 20) == 19\n assert candidate(total = 60,cost1 = 20,cost2 = 30) == 7\n assert candidate(total = 999999,cost1 = 1,cost2 = 2) == 250000500000\n assert candidate(total = 300,cost1 = 150,cost2 = 100) == 7\n assert candidate(total = 150,cost1 = 50,cost2 = 50) == 10\n assert candidate(total = 1000,cost1 = 333,cost2 = 111) == 22\n assert candidate(total = 100,cost1 = 25,cost2 = 30) == 11\n assert candidate(total = 500,cost1 = 150,cost2 = 50) == 26\n assert candidate(total = 999999,cost1 = 99999,cost2 = 99999) == 66\n assert candidate(total = 800,cost1 = 400,cost2 = 200) == 9\n assert candidate(total = 120,cost1 = 40,cost2 = 60) == 7\n assert candidate(total = 600,cost1 = 100,cost2 = 150) == 19\n assert candidate(total = 500,cost1 = 250,cost2 = 200) == 6\n assert candidate(total = 500000,cost1 = 1,cost2 = 2) == 62500500001\n assert candidate(total = 999999,cost1 = 1,cost2 = 1) == 500000500000\n assert candidate(total = 1500000,cost1 = 300000,cost2 = 400000) == 15\n assert candidate(total = 75,cost1 = 15,cost2 = 10) == 27\n assert candidate(total = 200,cost1 = 1,cost2 = 1) == 20301\n assert candidate(total = 1000,cost1 = 500,cost2 = 100) == 18\n assert candidate(total = 100,cost1 = 1,cost2 = 2) == 2601\n assert candidate(total = 70,cost1 = 5,cost2 = 3) == 185\n assert candidate(total = 300,cost1 = 100,cost2 = 150) == 7\n assert candidate(total = 1000,cost1 = 300,cost2 = 500) == 7\n assert candidate(total = 999999,cost1 = 999999,cost2 = 1) == 1000001\n assert candidate(total = 1000000,cost1 = 1,cost2 = 1) == 500001500001\n assert candidate(total = 1000000,cost1 = 1,cost2 = 1000000) == 1000002\n assert candidate(total = 1000,cost1 = 5,cost2 = 3) == 33634\n assert candidate(total = 5000,cost1 = 50,cost2 = 100) == 2601\n assert candidate(total = 100000,cost1 = 20000,cost2 = 30000) == 14\n assert candidate(total = 1000,cost1 = 100,cost2 = 10) == 561\n assert candidate(total = 100,cost1 = 30,cost2 = 70) == 6\n assert candidate(total = 100,cost1 = 30,cost2 = 7) == 34\n assert candidate(total = 123456,cost1 = 123,cost2 = 456) == 136511\n assert candidate(total = 300,cost1 = 50,cost2 = 25) == 49\n assert candidate(total = 100,cost1 = 5,cost2 = 3) == 364\n assert candidate(total = 10000,cost1 = 100,cost2 = 10) == 50601\n assert candidate(total = 200,cost1 = 150,cost2 = 50) == 7\n assert candidate(total = 500,cost1 = 100,cost2 = 50) == 36\n assert candidate(total = 999999,cost1 = 100000,cost2 = 10000) == 550\n assert candidate(total = 500,cost1 = 100,cost2 = 10) == 156\n assert candidate(total = 300,cost1 = 50,cost2 = 75) == 19\n assert candidate(total = 100,cost1 = 99,cost2 = 1) == 103\n assert candidate(total = 100,cost1 = 25,cost2 = 7) == 39\n assert candidate(total = 200,cost1 = 7,cost2 = 11) == 285\n assert candidate(total = 300,cost1 = 150,cost2 = 50) == 12\n assert candidate(total = 100,cost1 = 50,cost2 = 25) == 9\n assert candidate(total = 120,cost1 = 20,cost2 = 15) == 33\n assert candidate(total = 500,cost1 = 200,cost2 = 150) == 8\n assert candidate(total = 1,cost1 = 1,cost2 = 2) == 2\n"}, "metadata": {"canonical_parameter_names": ["total", "cost1", "cost2"], "leetcode_dataset_entry_point": "Solution().waysToBuyPensPencils", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long waysToBuyPensPencils(int total, int cost1, int cost2) {", "container": "Solution", "callable": "waysToBuyPensPencils", "parameters": [{"name": "total", "type": "int"}, {"name": "cost1", "type": "int"}, {"name": "cost2", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2242, "task_id": "maximum-score-of-a-node-sequence", "difficulty": "Hard", "problem_description": "There is an undirected graph with n nodes, numbered from 0 to n - 1.\nYou are given a 0-indexed integer array scores of length n where scores[i] denotes the score of node i. You are also given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai and bi.\nA node sequence is valid if it meets the following conditions:\n\nThere is an edge connecting every pair of adjacent nodes in the sequence.\nNo node appears more than once in the sequence.\n\nThe score of a node sequence is defined as the sum of the scores of the nodes in the sequence.\nReturn the maximum score of a valid node sequence with a length of 4. If no such sequence exists, return -1.\n \nExample 1:\n\n\nInput: scores = [5,2,9,8,4], edges = [[0,1],[1,2],[2,3],[0,2],[1,3],[2,4]]\nOutput: 24\nExplanation: The figure above shows the graph and the chosen node sequence [0,1,2,3].\nThe score of the node sequence is 5 + 2 + 9 + 8 = 24.\nIt can be shown that no other node sequence has a score of more than 24.\nNote that the sequences [3,1,2,0] and [1,0,2,3] are also valid and have a score of 24.\nThe sequence [0,3,2,4] is not valid since no edge connects nodes 0 and 3.\n\nExample 2:\n\n\nInput: scores = [9,20,6,4,11,12], edges = [[0,3],[5,3],[2,4],[1,3]]\nOutput: -1\nExplanation: The figure above shows the graph.\nThere are no valid node sequences of length 4, so we return -1.\n\n \nConstraints:\n\nn == scores.length\n4 <= n <= 5 * 104\n1 <= scores[i] <= 108\n0 <= edges.length <= 5 * 104\nedges[i].length == 2\n0 <= ai, bi <= n - 1\nai != bi\nThere are no duplicate edges.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(scores = [5, 2, 9, 8, 4],edges = [[0, 1], [1, 2], [2, 3], [0, 2], [1, 3], [2, 4]]) == 24\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 4\n assert candidate(scores = [10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 0]]) == 40\n assert candidate(scores = [9, 20, 6, 4, 11, 12],edges = [[0, 3], [5, 3], [2, 4], [1, 3]]) == -1\n assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 40\n assert candidate(scores = [10, 20, 30, 40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 140\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == 20\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 40\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 20\n assert candidate(scores = [1, 2, 3, 4],edges = [[0, 1], [1, 2], [2, 3]]) == 10\n assert candidate(scores = [90, 80, 70, 60, 50, 40, 30, 20, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8], [1, 7], [2, 6], [3, 5]]) == 300\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 5], [6, 7], [8, 9], [0, 4], [1, 3], [2, 5], [4, 6], [5, 7], [0, 8], [1, 9], [4, 7], [6, 8], [7, 9], [0, 5], [1, 6], [2, 4], [3, 7], [0, 7], [1, 8], [2, 9], [3, 6], [4, 8], [5, 9]]) == 340\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],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], [0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == 540\n assert candidate(scores = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 111100000\n assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 3400\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],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, 0], [0, 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, 0], [14, 1]]) == 540\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 2], [1, 3], [4, 6], [5, 7], [0, 4], [1, 5], [2, 6], [3, 7], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [0, 8], [1, 6], [2, 7], [3, 8], [4, 9]]) == 34\n assert candidate(scores = [8, 6, 7, 5, 3, 0, 9],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [1, 4], [2, 5]]) == 30\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0], [0, 5], [5, 10], [10, 15]]) == 4\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],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]]) == 540\n assert candidate(scores = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 340000000\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 4], [5, 9]]) == 34\n assert candidate(scores = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],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, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 0]]) == 200\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 340\n assert candidate(scores = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 0]]) == 48\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [0, 19]]) == 4\n assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == 2200\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],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]]) == 20\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == 180\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]]) == -1\n assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 2], [1, 3], [4, 6], [5, 7]]) == 3400\n assert candidate(scores = [5, 15, 10, 20, 25, 30, 5, 10, 15, 20],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 3], [3, 6], [6, 9], [1, 4], [4, 7]]) == 85\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],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, 0], [0, 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, 0], [19, 1]]) == 74\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 34\n assert candidate(scores = [8, 6, 7, 5, 3, 0, 9],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [2, 4], [4, 6], [1, 3], [3, 5], [5, 0], [0, 4], [4, 2], [2, 6], [6, 1], [1, 5], [5, 3], [3, 0]]) == 30\n assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]]) == 64\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [0, 7], [5, 6], [5, 4], [6, 3], [7, 0]]) == 130\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 9], [0, 1], [1, 9], [1, 2], [2, 9], [2, 3], [3, 9], [3, 4], [4, 9], [4, 5], [5, 9], [5, 6], [6, 9], [6, 7], [7, 9], [7, 8], [8, 9]]) == 34\n assert candidate(scores = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 4], [3, 7], [3, 8]]) == 330000000\n assert candidate(scores = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 4], [5, 9]]) == 340\n assert candidate(scores = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],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]]) == 400\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],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, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 0], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 1], [1, 5], [5, 9], [9, 13], [13, 1]]) == 270\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],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], [39, 0]]) == 20\n assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]]) == 3400\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 4\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 40\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],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, 0], [0, 9], [9, 14], [14, 19], [19, 4], [4, 9], [9, 14], [0, 7], [7, 12], [12, 17]]) == 740\n assert candidate(scores = [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],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]]) == 114\n assert candidate(scores = [9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == 30\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],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], [0, 14]]) == 540\n assert candidate(scores = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [2, 4], [4, 6], [6, 0]]) == 400000000\n assert candidate(scores = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7], [1, 3], [2, 4], [0, 5], [1, 6], [0, 6], [2, 7]]) == 399999994\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],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], [0, 9], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [11, 13], [12, 14], [15, 17], [16, 18]]) == 740\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 2], [1, 3], [4, 6], [5, 7], [2, 4], [3, 5]]) == 20\n assert candidate(scores = [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],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]]) == 154\n assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 0], [8, 1], [9, 2]]) == 3400\n assert candidate(scores = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991, 99999990, 99999989, 99999988, 99999987, 99999986],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]]) == 399999994\n assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],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, 0], [0, 7], [7, 12], [12, 4], [1, 8], [8, 13]]) == 104\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],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]]) == 20\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],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, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 0]]) == 540\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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]]) == 4\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],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]]) == 54\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[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], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == 340\n assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],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]]) == 144\n assert candidate(scores = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 3400000000\n assert candidate(scores = [100, 200, 300, 400, 500],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [0, 2], [1, 3], [2, 0], [3, 1], [4, 2]]) == 1400\n assert candidate(scores = [100000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 4], [5, 9]]) == 100000024\n assert candidate(scores = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 340000000\n assert candidate(scores = [50, 40, 30, 20, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 140\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],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, 0], [0, 7], [7, 12], [12, 4], [1, 8], [8, 13]]) == 54\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 340\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [6, 3], [3, 9], [9, 1], [1, 7], [7, 4], [4, 10], [10, 5], [5, 11], [11, 2], [2, 8], [8, 0]]) == 420\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 340\n assert candidate(scores = [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],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, 0], [0, 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], [19, 21], [20, 22], [21, 23], [22, 24], [23, 0], [24, 1]]) == 200\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 14]]) == 310\n assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],edges = [[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]]) == -1\n assert candidate(scores = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 4], [4, 8], [8, 3], [3, 7], [7, 2], [2, 6], [6, 1], [1, 5]]) == 1900\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]) == 28\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],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], [0, 19]]) == 74\n assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],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], [0, 14]]) == 5400\n"}, "metadata": {"canonical_parameter_names": ["scores", "edges"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumScore(int[] scores, int[][] edges) {", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "scores", "type": "int[]"}, {"name": "edges", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2243, "task_id": "calculate-digit-sum-of-a-string", "difficulty": "Easy", "problem_description": "You are given a string s consisting of digits and an integer k.\nA round can be completed if the length of s is greater than k. In one round, do the following:\n\nDivide s into consecutive groups of size k such that the first k characters are in the first group, the next k characters are in the second group, and so on. Note that the size of the last group can be smaller than k.\nReplace each group of s with a string representing the sum of all its digits. For example, \"346\" is replaced with \"13\" because 3 + 4 + 6 = 13.\nMerge consecutive groups together to form a new string. If the length of the string is greater than k, repeat from step 1.\n\nReturn s after all rounds have been completed.\n \nExample 1:\n\nInput: s = \"11111222223\", k = 3\nOutput: \"135\"\nExplanation: \n- For the first round, we divide s into groups of size 3: \"111\", \"112\", \"222\", and \"23\".\n ​​​​​Then we calculate the digit sum of each group: 1 + 1 + 1 = 3, 1 + 1 + 2 = 4, 2 + 2 + 2 = 6, and 2 + 3 = 5. \n  So, s becomes \"3\" + \"4\" + \"6\" + \"5\" = \"3465\" after the first round.\n- For the second round, we divide s into \"346\" and \"5\".\n  Then we calculate the digit sum of each group: 3 + 4 + 6 = 13, 5 = 5. \n  So, s becomes \"13\" + \"5\" = \"135\" after second round. \nNow, s.length <= k, so we return \"135\" as the answer.\n\nExample 2:\n\nInput: s = \"00000000\", k = 3\nOutput: \"000\"\nExplanation: \nWe divide s into \"000\", \"000\", and \"00\".\nThen we calculate the digit sum of each group: 0 + 0 + 0 = 0, 0 + 0 + 0 = 0, and 0 + 0 = 0. \ns becomes \"0\" + \"0\" + \"0\" = \"000\", whose length is equal to k, so we return \"000\".\n\n \nConstraints:\n\n1 <= s.length <= 100\n2 <= k <= 100\ns consists of digits only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"00000000\",k = 3) == \"000\"\n assert candidate(s = \"111\",k = 5) == \"111\"\n assert candidate(s = \"987654321\",k = 2) == \"36\"\n assert candidate(s = \"11111222223\",k = 3) == \"135\"\n assert candidate(s = \"9876543210\",k = 2) == \"36\"\n assert candidate(s = \"123\",k = 5) == \"123\"\n assert candidate(s = \"9999999999\",k = 5) == \"4545\"\n assert candidate(s = \"1234567890\",k = 2) == \"99\"\n assert candidate(s = \"111\",k = 2) == \"21\"\n assert candidate(s = \"1\",k = 1) == \"1\"\n assert candidate(s = \"56789\",k = 4) == \"269\"\n assert candidate(s = \"999999999999999999\",k = 5) == \"2214\"\n assert candidate(s = \"9876543210\",k = 5) == \"3510\"\n assert candidate(s = \"22222222222222222222222222222222\",k = 10) == \"2020204\"\n assert candidate(s = \"369121518212427303336394245485154576063666972757881848790939699\",k = 12) == \"414756647424\"\n assert candidate(s = \"222222222222222222222222222222222\",k = 7) == \"165\"\n assert candidate(s = \"56565656565656565656\",k = 8) == \"444422\"\n assert candidate(s = \"0123456789012345678901234567890123456789\",k = 10) == \"45454545\"\n assert candidate(s = \"1001001001001001001001001001001\",k = 5) == \"92\"\n assert candidate(s = \"55555555555555555555555555555555555555555555555555\",k = 33) == \"16585\"\n assert candidate(s = \"8888888888888888888888888888888888888888888888888\",k = 18) == \"144144104\"\n assert candidate(s = \"55555555555555555555555555555555555555555555555555\",k = 5) == \"1816\"\n assert candidate(s = \"9999999999999999999999999999999999999999999999999\",k = 25) == \"225216\"\n assert candidate(s = \"111111111111111111111111111111111111111111111111111\",k = 11) == \"111111117\"\n assert candidate(s = \"13579135791357913579\",k = 3) == \"73\"\n assert candidate(s = \"0123456789012345678901234567890123456789012345678901234567890\",k = 11) == \"585\"\n assert candidate(s = \"00000000000000000000\",k = 15) == \"00\"\n assert candidate(s = \"01234567890123456789012345678901234567890123456789\",k = 12) == \"4650545817\"\n assert candidate(s = \"99999999999999999999999999999999\",k = 15) == \"13513518\"\n assert candidate(s = \"246802468024680246802468024680246802468024680246802468024680246\",k = 7) == \"22257\"\n assert candidate(s = \"11111111111111111111\",k = 20) == \"11111111111111111111\"\n assert candidate(s = \"19876543210987654321098765432109876543210987654321\",k = 23) == \"10810810\"\n assert candidate(s = \"3336669991234567890123456789012345678901234567890\",k = 22) == \"1059930\"\n assert candidate(s = \"555555555555555555555555555555555555555555555555\",k = 4) == \"168\"\n assert candidate(s = \"4738691209384762938746293874623987462938746293874623987462938\",k = 6) == \"243\"\n assert candidate(s = \"2222222222222222222222222222222222222222222222\",k = 3) == \"281\"\n assert candidate(s = \"111222333444555666777888999000111222333444555\",k = 9) == \"184572936\"\n assert candidate(s = \"9999999999\",k = 4) == \"189\"\n assert candidate(s = \"432143214321432143214321432143214321432143214321\",k = 6) == \"201612\"\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111\",k = 10) == \"59\"\n assert candidate(s = \"12345678901234567890\",k = 4) == \"9126\"\n assert candidate(s = \"4321098765432109876543210987654321098765432109876\",k = 7) == \"3415\"\n assert candidate(s = \"9999999999999999999999999999999999999999999999999999999999999\",k = 2) == \"99\"\n assert candidate(s = \"5972841563974856321\",k = 4) == \"86\"\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111\",k = 40) == \"4020\"\n assert candidate(s = \"111222333444555666777888999000111\",k = 8) == \"381\"\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\",k = 10) == \"55555\"\n assert candidate(s = \"111111111111111111111111111111111111111111111111111\",k = 25) == \"25251\"\n assert candidate(s = \"55555555555555555555555555555555555555555555555555\",k = 20) == \"10010050\"\n assert candidate(s = \"000000000000000000000000000000000000000000000000000\",k = 25) == \"000\"\n assert candidate(s = \"1234512345123451234512345123451234\",k = 6) == \"2413\"\n assert candidate(s = \"11111222223333344444\",k = 5) == \"122\"\n assert candidate(s = \"012345678901234567890123456789012345678901234567890123456789\",k = 5) == \"1314\"\n assert candidate(s = \"123456789012345678901234567890\",k = 10) == \"454545\"\n assert candidate(s = \"923847239874239874239874239874239874239874239874239874239874\",k = 10) == \"537\"\n assert candidate(s = \"9876543210987654321098765432109876543210\",k = 15) == \"805545\"\n assert candidate(s = \"112233445566778899001122334455667788990011223344\",k = 12) == \"42546638\"\n assert candidate(s = \"55555555555555555555\",k = 10) == \"5050\"\n assert candidate(s = \"24681357911131517191\",k = 7) == \"292324\"\n assert candidate(s = \"123123123123123123123123123123123123123123123123123123123123123123123123123123123123\",k = 22) == \"43444536\"\n assert candidate(s = \"111122223333444455556666777788889999\",k = 8) == \"279\"\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000\",k = 20) == \"000\"\n assert candidate(s = \"1111111111222222222233333333334444444444\",k = 8) == \"262\"\n assert candidate(s = \"11111111111111111111111111111111\",k = 7) == \"77774\"\n assert candidate(s = \"222444666888000222444666888000\",k = 12) == \"603624\"\n assert candidate(s = \"123456789123456789123456789123456789123456789\",k = 11) == \"485256609\"\n assert candidate(s = \"12345678901234567890123456789012345678901234567890\",k = 15) == \"60756030\"\n assert candidate(s = \"123456789012345678901234567890123456789012345678901234567890\",k = 8) == \"3024\"\n assert candidate(s = \"13579135791357913579\",k = 6) == \"217\"\n assert candidate(s = \"43210987654321098765432109876543210987654321098765\",k = 15) == \"55805535\"\n assert candidate(s = \"111222333444555666777888999\",k = 6) == \"2214\"\n assert candidate(s = \"10101010101010101010\",k = 5) == \"3232\"\n assert candidate(s = \"12312312312312312312\",k = 3) == \"21\"\n assert candidate(s = \"55555555555555555555555555555555\",k = 10) == \"50505010\"\n assert candidate(s = \"31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679\",k = 20) == \"979710190869\"\n assert candidate(s = \"98765432109876543210987654321098765432109876543210\",k = 6) == \"262215\"\n assert candidate(s = \"1234567890098765432112345678900987654321\",k = 25) == \"10575\"\n assert candidate(s = \"999999999999999999999999999999999999999999999999999\",k = 10) == \"459\"\n assert candidate(s = \"99999999999999999999\",k = 9) == \"818118\"\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111\",k = 13) == \"1313131310\"\n assert candidate(s = \"55555555555555555555555555555555555555555555555555\",k = 10) == \"5050505050\"\n assert candidate(s = \"87654321098765432109\",k = 6) == \"189\"\n assert candidate(s = \"0987654321098765432109876543210987654321098765432109876543210987654321\",k = 18) == \"87837966\"\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",k = 50) == \"50505034\"\n assert candidate(s = \"111122223333444455556666777788889999\",k = 5) == \"153\"\n assert candidate(s = \"48375926195487326594873265984736259847326598473265984732659\",k = 12) == \"6364726064\"\n assert candidate(s = \"111111111111111111111111111111111111111111111111111\",k = 9) == \"999996\"\n assert candidate(s = \"987654321098765432109876543210\",k = 11) == \"545328\"\n assert candidate(s = \"24680246802468024680\",k = 4) == \"5129\"\n assert candidate(s = \"000111222333444555666777888999\",k = 11) == \"155565\"\n assert candidate(s = \"101010101010101010101010101010101010101010101010101\",k = 8) == \"4444442\"\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\",k = 12) == \"00000\"\n assert candidate(s = \"99999999999999999999999999999999999999999999999999999999999999999999\",k = 20) == \"18018018072\"\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",k = 15) == \"878787878782\"\n assert candidate(s = \"56789012345678901234567890\",k = 6) == \"2015\"\n assert candidate(s = \"111222333444555666777888999000111222333444555666777888999000\",k = 9) == \"4518\"\n assert candidate(s = \"8888888888888888888888888888888888888888\",k = 2) == \"41\"\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",k = 25) == \"25252525252525252521\"\n assert candidate(s = \"99999999999999999999999999999999999999999999999999\",k = 20) == \"18018090\"\n assert candidate(s = \"0000000000000000000000000000000000000000\",k = 100) == \"0000000000000000000000000000000000000000\"\n assert candidate(s = \"102030405060708090\",k = 3) == \"711\"\n assert candidate(s = \"987654321098765432109876543210\",k = 3) == \"99\"\n assert candidate(s = \"9999999999\",k = 2) == \"99\"\n assert candidate(s = \"12345678901234567890\",k = 10) == \"4545\"\n assert candidate(s = \"98765432109876543210987654321098765432109876543210\",k = 18) == \"898551\"\n assert candidate(s = \"12345678901234567890\",k = 7) == \"282735\"\n assert candidate(s = \"111222333444555666777888999000111222333444555666777888999000\",k = 10) == \"4113\"\n assert candidate(s = \"543210543210543210543210543210\",k = 12) == \"303015\"\n assert candidate(s = \"987654321098765432109876543210987654321098765432109876543210\",k = 12) == \"6258545046\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().digitSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String digitSum(String s, int k) {", "container": "Solution", "callable": "digitSum", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2244, "task_id": "minimum-rounds-to-complete-all-tasks", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the same difficulty level.\nReturn the minimum rounds required to complete all the tasks, or -1 if it is not possible to complete all the tasks.\n \nExample 1:\n\nInput: tasks = [2,2,3,3,2,4,4,4,4,4]\nOutput: 4\nExplanation: To complete all the tasks, a possible plan is:\n- In the first round, you complete 3 tasks of difficulty level 2. \n- In the second round, you complete 2 tasks of difficulty level 3. \n- In the third round, you complete 3 tasks of difficulty level 4. \n- In the fourth round, you complete 2 tasks of difficulty level 4. \nIt can be shown that all the tasks cannot be completed in fewer than 4 rounds, so the answer is 4.\n\nExample 2:\n\nInput: tasks = [2,3,3]\nOutput: -1\nExplanation: There is only 1 task of difficulty level 2, but in each round, you can only complete either 2 or 3 tasks of the same difficulty level. Hence, you cannot complete all the tasks, and the answer is -1.\n\n \nConstraints:\n\n1 <= tasks.length <= 105\n1 <= tasks[i] <= 109\n\n \nNote: This question is the same as 2870: Minimum Number of Operations to Make Array Empty.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 5\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 5\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 7\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 5\n assert candidate(tasks = [1]) == -1\n assert candidate(tasks = [2, 3, 3]) == -1\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(tasks = [2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 7\n assert candidate(tasks = [1, 1, 1, 1, 1, 1]) == 2\n assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8\n assert candidate(tasks = [10, 10, 10, 20, 20, 30, 30, 30, 30]) == 4\n assert candidate(tasks = [2, 2, 3, 3, 2, 4, 4, 4, 4, 4]) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5]) == -1\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5]) == 3\n assert candidate(tasks = [5, 5, 5, 5, 5, 5]) == 2\n assert candidate(tasks = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == 6\n assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3]) == -1\n assert candidate(tasks = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 4\n assert candidate(tasks = [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]) == 15\n assert candidate(tasks = [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, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == -1\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(tasks = [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]) == 9\n assert candidate(tasks = [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]) == 11\n assert candidate(tasks = [2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 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]) == 13\n assert candidate(tasks = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300]) == 10\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 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(tasks = [1, 1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 14\n assert candidate(tasks = [1000000000, 1000000000, 1000000000, 1000000000, 2000000000, 2000000000, 3000000000, 3000000000, 3000000000]) == 4\n assert candidate(tasks = [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]) == 16\n assert candidate(tasks = [1, 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, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(tasks = [400, 400, 400, 400, 500, 500, 500, 500, 500, 600, 600, 600, 600, 600, 600, 700, 700, 700, 700, 700, 700, 700]) == 9\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 13\n assert candidate(tasks = [1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 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]) == 17\n assert candidate(tasks = [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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 16\n assert candidate(tasks = [3, 3, 3, 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, 4, 4, 4, 4, 4, 4, 4, 4]) == 14\n assert candidate(tasks = [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]) == -1\n assert candidate(tasks = [100, 100, 100, 101, 101, 101, 101, 101, 102, 102, 102, 103, 103, 103, 103, 103, 103, 104, 104]) == 7\n assert candidate(tasks = [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(tasks = [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, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 16\n assert candidate(tasks = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 13\n assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == -1\n assert candidate(tasks = [7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 11\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == 8\n assert candidate(tasks = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 19\n assert candidate(tasks = [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, 2, 2, 2, 2, 2, 2, 2, 2]) == 15\n assert candidate(tasks = [6, 6, 6, 6, 6, 6, 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, 9]) == 13\n assert candidate(tasks = [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]) == 12\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == -1\n assert candidate(tasks = [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]) == 10\n assert candidate(tasks = [1, 1, 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, 6, 6, 6, 6, 6, 6]) == 14\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(tasks = [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 14\n assert candidate(tasks = [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]) == 9\n"}, "metadata": {"canonical_parameter_names": ["tasks"], "leetcode_dataset_entry_point": "Solution().minimumRounds", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumRounds(int[] tasks) {", "container": "Solution", "callable": "minimumRounds", "parameters": [{"name": "tasks", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2245, "task_id": "maximum-trailing-zeros-in-a-cornered-path", "difficulty": "Medium", "problem_description": "You are given a 2D integer array grid of size m x n, where each cell contains a positive integer.\nA cornered path is defined as a set of adjacent cells with at most one turn. More specifically, the path should exclusively move either horizontally or vertically up to the turn (if there is one), without returning to a previously visited cell. After the turn, the path will then move exclusively in the alternate direction: move vertically if it moved horizontally, and vice versa, also without returning to a previously visited cell.\nThe product of a path is defined as the product of all the values in the path.\nReturn the maximum number of trailing zeros in the product of a cornered path found in grid.\nNote:\n\nHorizontal movement means moving in either the left or right direction.\nVertical movement means moving in either the up or down direction.\n\n \nExample 1:\n\n\nInput: grid = [[23,17,15,3,20],[8,1,20,27,11],[9,4,6,2,21],[40,9,1,10,6],[22,7,4,5,3]]\nOutput: 3\nExplanation: The grid on the left shows a valid cornered path.\nIt has a product of 15 * 20 * 6 * 1 * 10 = 18000 which has 3 trailing zeros.\nIt can be shown that this is the maximum trailing zeros in the product of a cornered path.\n\nThe grid in the middle is not a cornered path as it has more than one turn.\nThe grid on the right is not a cornered path as it requires a return to a previously visited cell.\n\nExample 2:\n\n\nInput: grid = [[4,3,2],[7,6,1],[8,8,8]]\nOutput: 0\nExplanation: The grid is shown in the figure above.\nThere are no cornered paths in the grid that result in a product with a trailing zero.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 105\n1 <= m * n <= 105\n1 <= grid[i][j] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 0\n assert candidate(grid = [[5, 10, 15], [20, 25, 30], [35, 40, 45]]) == 5\n assert candidate(grid = [[2, 4, 6, 8], [10, 20, 30, 40], [50, 60, 70, 80]]) == 6\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 = [[23, 17, 15, 3, 20], [8, 1, 20, 27, 11], [9, 4, 6, 2, 21], [40, 9, 1, 10, 6], [22, 7, 4, 5, 3]]) == 3\n assert candidate(grid = [[10, 5, 2], [6, 3, 8], [4, 7, 1]]) == 2\n assert candidate(grid = [[2, 5], [10, 5]]) == 2\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 1\n assert candidate(grid = [[4, 3, 2], [7, 6, 1], [8, 8, 8]]) == 0\n assert candidate(grid = [[2, 4, 8, 16], [3, 6, 12, 24], [5, 10, 20, 40]]) == 4\n assert candidate(grid = [[8, 8, 8, 8], [5, 5, 5, 5], [10, 10, 10, 10], [20, 20, 20, 20]]) == 6\n assert candidate(grid = [[4, 5, 25, 20], [8, 12, 15, 30], [10, 6, 2, 24], [20, 2, 5, 4]]) == 6\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]]) == 5\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]]) == 6\n assert candidate(grid = [[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]]) == 13\n assert candidate(grid = [[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 24\n assert candidate(grid = [[10, 50, 250, 1250], [20, 100, 500, 2500], [40, 200, 1000, 5000], [80, 400, 2000, 10000]]) == 22\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]]) == 3\n assert candidate(grid = [[25, 50, 75, 100], [5, 10, 15, 20], [1, 2, 3, 4], [125, 250, 375, 500]]) == 9\n assert candidate(grid = [[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]]) == 1\n assert candidate(grid = [[12, 15, 25, 20, 5], [2, 4, 16, 40, 100], [10, 20, 30, 40, 50], [5, 10, 15, 20, 25]]) == 9\n assert candidate(grid = [[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]]) == 11\n assert candidate(grid = [[1, 2, 4, 8, 16, 32], [2, 4, 8, 16, 32, 64], [4, 8, 16, 32, 64, 128], [8, 16, 32, 64, 128, 256], [16, 32, 64, 128, 256, 512], [32, 64, 128, 256, 512, 1024]]) == 0\n assert candidate(grid = [[125, 250, 500], [25, 50, 100], [5, 10, 20]]) == 7\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 6, 10, 14, 18], [4, 12, 20, 28, 36], [8, 24, 40, 56, 72], [16, 48, 80, 112, 144]]) == 5\n assert candidate(grid = [[1, 2, 4, 8, 16], [3, 6, 12, 24, 48], [5, 10, 20, 40, 80], [7, 14, 28, 56, 112], [9, 18, 36, 72, 144]]) == 5\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]]) == 9\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 90]]) == 1\n assert candidate(grid = [[8, 12, 15, 25, 20, 5], [4, 16, 40, 100, 8, 2], [10, 20, 30, 40, 50, 10], [5, 10, 15, 20, 25, 12], [2, 6, 10, 15, 20, 25], [3, 5, 10, 15, 20, 25]]) == 11\n assert candidate(grid = [[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]]) == 1\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]]) == 0\n assert candidate(grid = [[2, 4, 8, 16, 32, 64, 128], [1, 3, 5, 7, 9, 11, 13], [25, 50, 75, 100, 125, 150, 175]]) == 11\n assert candidate(grid = [[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]]) == 0\n assert candidate(grid = [[4, 8, 16, 32, 64], [2, 4, 8, 16, 32], [1, 2, 4, 8, 16], [128, 64, 32, 16, 8], [4, 2, 1, 2, 4]]) == 0\n assert candidate(grid = [[2, 3, 5, 7, 11], [4, 6, 10, 14, 22], [8, 12, 20, 28, 44], [16, 24, 40, 56, 88], [32, 48, 80, 112, 176]]) == 5\n assert candidate(grid = [[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]]) == 10\n assert candidate(grid = [[20, 40, 60, 80, 100], [10, 20, 30, 40, 50], [1, 2, 3, 4, 5], [5, 10, 15, 20, 25], [2, 4, 6, 8, 10]]) == 12\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 25, 125, 625, 3125], [5, 125, 625, 3125, 15625], [5, 625, 3125, 15625, 78125], [5, 3125, 15625, 78125, 390625]]) == 0\n assert candidate(grid = [[2, 3, 5, 7, 11, 13, 17, 19, 23, 29], [30, 31, 37, 41, 43, 47, 53, 59, 61, 67], [71, 73, 79, 83, 89, 97, 101, 103, 107, 109]]) == 2\n assert candidate(grid = [[2, 3, 5, 7], [15, 21, 25, 35], [50, 75, 125, 175], [100, 150, 250, 350]]) == 7\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]]) == 7\n assert candidate(grid = [[8, 6, 2, 10, 5], [2, 5, 1, 9, 4], [3, 6, 5, 1, 7], [8, 4, 3, 9, 6], [5, 2, 1, 8, 4]]) == 3\n assert candidate(grid = [[2, 5, 10, 20, 25], [4, 8, 12, 16, 32], [3, 6, 9, 12, 15], [5, 10, 15, 20, 25], [2, 4, 8, 16, 32]]) == 8\n assert candidate(grid = [[400, 200, 100], [200, 100, 50], [100, 50, 25]]) == 10\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 2\n assert candidate(grid = [[3, 6, 9, 12, 15, 18, 21, 24, 27, 30], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 13\n assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [11, 22, 33, 44, 55]]) == 9\n assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55], [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33]]) == 14\n assert candidate(grid = [[32, 32, 32, 32, 32], [64, 64, 64, 64, 64], [128, 128, 128, 128, 128], [256, 256, 256, 256, 256], [512, 512, 512, 512, 512]]) == 0\n assert candidate(grid = [[12, 18, 15, 30, 25], [16, 20, 24, 10, 5], [21, 14, 7, 35, 40], [8, 12, 16, 40, 25], [15, 25, 35, 20, 40]]) == 9\n assert candidate(grid = [[999, 1000, 500, 250], [10, 5, 2, 1], [15, 3, 6, 12], [7, 14, 28, 56], [21, 42, 84, 168]]) == 9\n assert candidate(grid = [[50, 25, 10, 5, 2], [2, 5, 10, 25, 50], [10, 25, 50, 125, 250], [250, 125, 50, 25, 10], [10, 25, 50, 125, 250]]) == 7\n assert candidate(grid = [[3, 6, 9, 12, 15], [18, 21, 24, 27, 30], [33, 36, 39, 42, 45], [48, 51, 54, 57, 60]]) == 4\n assert candidate(grid = [[2, 5, 2, 5, 2, 5, 2, 5, 2, 5], [5, 2, 5, 2, 5, 2, 5, 2, 5, 2], [2, 5, 2, 5, 2, 5, 2, 5, 2, 5], [5, 2, 5, 2, 5, 2, 5, 2, 5, 2]]) == 6\n assert candidate(grid = [[20, 5, 10], [4, 15, 50], [10, 10, 10]]) == 5\n assert candidate(grid = [[20, 50, 25], [5, 10, 15], [2, 4, 8]]) == 6\n assert candidate(grid = [[2, 5, 10, 20], [1, 10, 100, 1000], [4, 20, 100, 500], [8, 40, 200, 1000]]) == 13\n assert candidate(grid = [[12, 25, 50], [6, 100, 200], [15, 5, 5]]) == 6\n assert candidate(grid = [[2, 4, 8, 16, 32], [3, 6, 12, 24, 48], [5, 10, 20, 40, 80], [15, 30, 60, 120, 240], [45, 90, 180, 360, 720]]) == 7\n assert candidate(grid = [[2, 5, 2, 5, 2, 5, 2, 5, 2, 5], [5, 2, 5, 2, 5, 2, 5, 2, 5, 2], [2, 5, 2, 5, 2, 5, 2, 5, 2, 5], [5, 2, 5, 2, 5, 2, 5, 2, 5, 2], [2, 5, 2, 5, 2, 5, 2, 5, 2, 5], [5, 2, 5, 2, 5, 2, 5, 2, 5, 2]]) == 7\n assert candidate(grid = [[100, 200, 300, 400, 500], [2, 4, 6, 8, 10], [5, 10, 15, 20, 25], [10, 20, 30, 40, 50]]) == 15\n assert candidate(grid = [[2, 2, 2, 2, 2], [5, 5, 5, 5, 5], [2, 5, 10, 15, 20], [25, 50, 100, 200, 400], [500, 1000, 2000, 4000, 8000]]) == 19\n assert candidate(grid = [[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]]) == 1\n assert candidate(grid = [[2, 3, 5, 7, 11, 13, 17, 19, 23, 29], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40], [25, 50, 75, 100, 125, 150, 175, 200, 225, 250], [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]]) == 15\n assert candidate(grid = [[1000, 1000, 1000], [1000, 1000, 1000], [1000, 1000, 1000]]) == 15\n assert candidate(grid = [[12, 15, 20, 25, 30], [24, 30, 35, 40, 45], [50, 55, 60, 65, 70], [75, 80, 85, 90, 95], [100, 105, 110, 115, 120]]) == 11\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]]) == 3\n assert candidate(grid = [[998, 999, 1000], [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 4\n assert candidate(grid = [[2, 4, 8, 16, 32], [3, 6, 12, 24, 48], [5, 10, 20, 40, 80], [7, 14, 28, 56, 112], [11, 22, 44, 88, 176]]) == 5\n assert candidate(grid = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [25, 50, 75, 100, 125, 150, 175, 200, 225, 250], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30], [35, 70, 105, 140, 175, 210, 245, 280, 315, 350], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]]) == 16\n assert candidate(grid = [[6, 2, 3, 10, 15], [2, 4, 5, 20, 25], [3, 6, 9, 30, 45], [4, 8, 12, 40, 60], [5, 10, 15, 50, 75]]) == 9\n assert candidate(grid = [[25, 16, 4, 2], [5, 10, 20, 8], [1, 12, 6, 4], [3, 6, 9, 15]]) == 5\n assert candidate(grid = [[4, 3, 2, 1, 5], [7, 6, 1, 8, 9], [8, 8, 8, 1, 2], [1, 1, 1, 3, 4]]) == 1\n assert candidate(grid = [[8, 16, 32, 64, 128], [4, 8, 16, 32, 64], [2, 4, 8, 16, 32], [1, 2, 4, 8, 16], [1, 1, 1, 1, 2]]) == 0\n assert candidate(grid = [[7, 11, 13, 17, 19, 23, 29, 31, 37, 41], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40], [2, 5, 10, 20, 40, 80, 160, 320, 640, 1280], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]]) == 10\n assert candidate(grid = [[2, 5, 10, 15], [20, 25, 30, 35], [40, 45, 50, 55], [60, 65, 70, 75]]) == 7\n assert candidate(grid = [[5, 10, 15, 20, 25], [1, 2, 3, 4, 5], [6, 12, 18, 24, 30], [7, 14, 21, 28, 35], [8, 16, 24, 32, 40]]) == 7\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], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 3\n assert candidate(grid = [[100, 200, 300, 400, 500], [600, 700, 800, 900, 1000], [1100, 1200, 1300, 1400, 1500], [1600, 1700, 1800, 1900, 2000]]) == 20\n assert candidate(grid = [[1, 2, 4, 8, 16, 32, 64, 128, 256, 512], [512, 256, 128, 64, 32, 16, 8, 4, 2, 1], [1, 5, 10, 15, 20, 25, 30, 35, 40, 45], [45, 40, 35, 30, 25, 20, 15, 10, 5, 1]]) == 11\n assert candidate(grid = [[12, 34, 56, 78, 90], [23, 45, 67, 89, 101], [123, 145, 167, 189, 201], [11, 22, 33, 44, 55], [66, 77, 88, 99, 110]]) == 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], [2, 5, 10, 20, 40, 80, 160, 320, 640, 1280]]) == 9\n assert candidate(grid = [[4, 8, 16, 32, 64, 128, 256], [3, 6, 12, 24, 48, 96, 192], [5, 10, 20, 40, 80, 160, 320], [7, 14, 28, 56, 112, 224, 448]]) == 7\n assert candidate(grid = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 3\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxTrailingZeros", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxTrailingZeros(int[][] grid) {", "container": "Solution", "callable": "maxTrailingZeros", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2246, "task_id": "longest-path-with-different-adjacent-characters", "difficulty": "Hard", "problem_description": "You are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree is represented by a 0-indexed array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1.\nYou are also given a string s of length n, where s[i] is the character assigned to node i.\nReturn the length of the longest path in the tree such that no pair of adjacent nodes on the path have the same character assigned to them.\n \nExample 1:\n\n\nInput: parent = [-1,0,0,1,1,2], s = \"abacbe\"\nOutput: 3\nExplanation: The longest path where each two adjacent nodes have different characters in the tree is the path: 0 -> 1 -> 3. The length of this path is 3, so 3 is returned.\nIt can be proven that there is no longer path that satisfies the conditions. \n\nExample 2:\n\n\nInput: parent = [-1,0,0,0], s = \"aabc\"\nOutput: 3\nExplanation: The longest path where each two adjacent nodes have different characters is the path: 2 -> 0 -> 3. The length of this path is 3, so 3 is returned.\n\n \nConstraints:\n\nn == parent.length == s.length\n1 <= n <= 105\n0 <= parent[i] <= n - 1 for all i >= 1\nparent[0] == -1\nparent represents a valid tree.\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parent = [-1, 0, 0, 2, 2, 2],s = \"abbccc\") == 4\n assert candidate(parent = [-1, 0, 0, 0],s = \"aabc\") == 3\n assert candidate(parent = [-1, 0, 0, 1, 1, 2],s = \"abacbe\") == 3\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5],s = \"abcdefg\") == 7\n assert candidate(parent = [-1, 0, 0, 0, 0, 0, 0],s = \"abcdefg\") == 3\n assert candidate(parent = [-1, 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],s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 5\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],s = \"abcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(parent = [-1, 0, 1, 2, 3, 0, 6, 7, 8, 2, 10, 11, 12, 1, 14, 15, 16, 0, 18, 19, 20, 3, 22, 23, 24, 4, 26, 27, 28, 5, 30, 31, 32, 6, 34, 35, 36, 7, 38, 39, 40, 8, 42, 43, 44, 9, 46, 47, 48, 10, 50, 51, 52, 11, 54, 55, 56, 12, 58, 59, 60],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],s = \"abcdefghijklmnopqrstuvwxyz\") == 21\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],s = \"aabbccddeeffgghhiiiijjjjkkkkllllmmmmnnnnoooppqqrrssttuuvvwwxxyyzz\") == 7\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],s = \"abcdefghijklmno\") == 14\n assert candidate(parent = [-1, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],s = \"abcdefghijklmnopqrstuvwxyz\") == 7\n assert candidate(parent = [-1, 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, 20, 20],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 10\n assert candidate(parent = [-1, 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, 20, 20, 21, 21],s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 10\n assert candidate(parent = [-1, 0, 0, 0, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijk\") == 8\n assert candidate(parent = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],s = \"aabbaaccddcceeddffgeee\") == 5\n assert candidate(parent = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],s = \"abcabcabcabcabcabc\") == 5\n assert candidate(parent = [-1, 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],s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 9\n assert candidate(parent = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 3],s = \"abacabadaba\") == 5\n assert candidate(parent = [-1, 0, 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, 14],s = \"abacabadacadaeafagahaiajakalalamanaoapaqara\") == 7\n assert candidate(parent = [-1, 0, 0, 0, 0, 0, 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],s = \"ababababababababababababababababababababababababababababababababababababababababababa\") == 5\n assert candidate(parent = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 4],s = \"abcdefghij\") == 6\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 4, 5, 6],s = \"aabbccddeee\") == 5\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 21, 22, 23, 24, 25, 26, 27, 28, 29],s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(parent = [-1, 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, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29],s = \"abcdefghijklmnopqrstuvabcdefghijklmnopqrstuvabcdefghijklmnopqrstuvabcdefghijklmnopqrstuv\") == 11\n assert candidate(parent = [-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],s = \"abacabadabacabadabacabadabacabadabacabadabacaba\") == 32\n assert candidate(parent = [-1, 0, 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, 20, 20, 21, 21],s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(parent = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],s = \"abcdefghijklmnopqrstuvwx\") == 7\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],s = \"abcdefghijklmnopqrstuvwxypq\") == 21\n assert candidate(parent = [-1, 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, 37, 38, 39, 40, 41, 42, 43, 44, 45],s = \"abcdefghijklmnopqrstuvwxypqabcdefghijklmnopqrstuvwxypq\") == 13\n assert candidate(parent = [-1, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnop\") == 9\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],s = \"abcdefghijklmnopqrstuvwxyz\") == 16\n assert candidate(parent = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],s = \"aaaaabbbbbcccccddeeeeffffgghhhhiijjjj\") == 3\n assert candidate(parent = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3],s = \"aababbccdd\") == 3\n assert candidate(parent = [-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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 31\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],s = \"abcdefghij\") == 6\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 2, 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, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(parent = [-1, 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],s = \"abacabadacadaeafagahaiajakalalamanaoapaqara\") == 7\n assert candidate(parent = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],s = \"abcdefghijklmnopqrstuvwxyz\") == 5\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],s = \"aaabbbcccdd\") == 5\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],s = \"abacabadabacaba\") == 5\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(parent = [-1, 0, 0, 0, 0, 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, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 0, 49, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 11\n assert candidate(parent = [-1, 0, 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, 14],s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzz\") == 10\n assert candidate(parent = [-1, 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],s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzz\") == 9\n assert candidate(parent = [-1, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 9\n assert candidate(parent = [-1, 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],s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 7\n assert candidate(parent = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2],s = \"abcdeabcdeabcde\") == 5\n assert candidate(parent = [-1, 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, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 13\n"}, "metadata": {"canonical_parameter_names": ["parent", "s"], "leetcode_dataset_entry_point": "Solution().longestPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestPath(int[] parent, String s) {", "container": "Solution", "callable": "longestPath", "parameters": [{"name": "parent", "type": "int[]"}, {"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2248, "task_id": "intersection-of-multiple-arrays", "difficulty": "Easy", "problem_description": "Given a 2D integer array nums where nums[i] is a non-empty array of distinct positive integers, return the list of integers that are present in each array of nums sorted in ascending order.\n \nExample 1:\n\nInput: nums = [[3,1,2,4,5],[1,2,3,4],[3,4,5,6]]\nOutput: [3,4]\nExplanation: \nThe only integers present in each of nums[0] = [3,1,2,4,5], nums[1] = [1,2,3,4], and nums[2] = [3,4,5,6] are 3 and 4, so we return [3,4].\nExample 2:\n\nInput: nums = [[1,2,3],[4,5,6]]\nOutput: []\nExplanation: \nThere does not exist any integer present both in nums[0] and nums[1], so we return an empty list [].\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= sum(nums[i].length) <= 1000\n1 <= nums[i][j] <= 1000\nAll the values of nums[i] are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [[1], [1]]) == [1]\n assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [30, 60, 70]]) == [30]\n assert candidate(nums = [[3, 1, 2, 4, 5], [1, 2, 3, 4], [3, 4, 5, 6]]) == [3, 4]\n assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50]]) == [30]\n assert candidate(nums = [[1], [1], [1], [1]]) == [1]\n assert candidate(nums = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == []\n assert candidate(nums = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7]]) == [3, 4, 5]\n assert candidate(nums = [[5, 10], [10, 15], [15, 20], [20, 25], [5, 25]]) == []\n assert candidate(nums = [[10, 20, 30], [10, 20, 40], [10, 30, 40]]) == [10]\n assert candidate(nums = [[5], [5]]) == [5]\n assert candidate(nums = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]) == [3, 4]\n assert candidate(nums = [[1, 2], [2, 3], [3, 4]]) == []\n assert candidate(nums = [[1, 2, 3, 4, 5], [2, 3, 5, 7], [3, 5, 8, 9]]) == [3, 5]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6]]) == []\n assert candidate(nums = [[10, 20, 30], [10, 20, 40], [10, 30, 50]]) == [10]\n assert candidate(nums = [[2, 4, 6, 8, 10], [2, 4, 6, 8, 10, 12], [2, 4, 6, 8, 10, 12, 14], [2, 4, 6, 8, 10, 12, 14, 16]]) == [2, 4, 6, 8, 10]\n assert candidate(nums = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 1, 2]]) == [1, 2, 3]\n assert candidate(nums = [[1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 7]]) == [1, 2, 3]\n assert candidate(nums = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 1], [1, 3, 5, 7, 9]]) == []\n assert candidate(nums = [[5, 10, 15, 20, 25], [15, 20, 25, 30, 35], [20, 25, 30, 35, 40], [25, 30, 35, 40, 45], [30, 35, 40, 45, 50]]) == []\n assert candidate(nums = [[7, 14, 21, 28, 35], [14, 21, 28, 42, 56], [21, 28, 35, 42, 56, 70]]) == [21, 28]\n assert candidate(nums = [[1, 3, 5, 7, 9], [3, 5, 7, 9, 11], [5, 7, 9, 11, 13], [7, 9, 11, 13, 15]]) == [7, 9]\n assert candidate(nums = [[10, 20, 30], [30, 40, 50], [20, 30, 40], [30, 50, 60]]) == [30]\n assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [30, 50, 60]]) == [30]\n assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70], [60, 70, 80], [70, 80, 90], [80, 90, 100], [90, 100, 110]]) == []\n assert candidate(nums = [[10, 20, 30, 40, 50], [10, 30, 50, 70], [10, 30, 50, 90]]) == [10, 30, 50]\n assert candidate(nums = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 10]]) == []\n assert candidate(nums = [[100, 200, 300], [300, 400, 500], [500, 600, 700], [700, 800, 900], [900, 1000, 100]]) == []\n assert candidate(nums = [[5, 10, 15, 20], [10, 15, 25, 30], [15, 20, 30, 35], [20, 25, 30, 35]]) == []\n assert candidate(nums = [[500, 501, 502, 503, 504, 505], [503, 504, 505, 506, 507, 508], [505, 506, 507, 508, 509, 510], [507, 508, 509, 510, 511, 512], [509, 510, 511, 512, 513, 514]]) == []\n assert candidate(nums = [[7, 11, 13], [11, 13, 15], [11, 13, 17], [11, 13, 19]]) == [11, 13]\n assert candidate(nums = [[5, 10, 15, 20], [5, 20, 25, 30], [5, 10, 20, 35], [5, 10, 15, 20, 40]]) == [5, 20]\n assert candidate(nums = [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]) == [1]\n assert candidate(nums = [[999], [999, 998], [999, 998, 997], [999, 998, 997, 996]]) == [999]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]) == [3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [[5, 10, 15], [10, 15, 20], [15, 20, 25], [20, 25, 30], [25, 30, 35]]) == []\n assert candidate(nums = [[1, 3, 5, 7, 9], [3, 5, 7, 9, 11], [5, 7, 9, 11, 13], [7, 9, 11, 13, 15], [9, 11, 13, 15, 17]]) == [9]\n assert candidate(nums = [[5, 15, 25], [5, 25, 35], [25, 35, 45], [15, 25, 35], [5, 15, 25, 35]]) == [25]\n assert candidate(nums = [[100, 200, 300], [100, 400, 500], [100, 600, 700], [100, 800, 900]]) == [100]\n assert candidate(nums = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [1, 5, 9, 13, 17]]) == [1, 5]\n assert candidate(nums = [[100, 200, 300, 400, 500], [100, 200, 300, 400, 600], [100, 200, 300, 500, 600], [100, 200, 400, 500, 600]]) == [100, 200]\n assert candidate(nums = [[1, 3, 5, 7, 9], [2, 3, 5, 8, 9], [3, 4, 5, 7, 9], [3, 5, 6, 7, 9]]) == [3, 5, 9]\n assert candidate(nums = [[10, 20, 30], [30, 40, 50], [10, 30, 50, 70], [30, 80, 90, 100]]) == [30]\n assert candidate(nums = [[100, 200, 300], [200, 300, 400], [300, 400, 500], [400, 500, 600]]) == []\n assert candidate(nums = [[100, 200, 300], [200, 300, 400], [300, 400, 500], [400, 500, 600], [500, 600, 700]]) == []\n assert candidate(nums = [[10, 20, 30, 40], [20, 30, 40, 50], [30, 40, 50, 60], [40, 50, 60, 70]]) == [40]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]]) == [9, 10]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == []\n assert candidate(nums = [[5, 10, 15, 20, 25], [15, 20, 25, 30, 35], [20, 25, 30, 35, 40], [25, 30, 35, 40, 45]]) == [25]\n assert candidate(nums = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 3, 5, 7, 11, 13, 17, 19, 23, 29], [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]]) == [3, 5, 7, 11, 13, 17, 19]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10], [3, 6, 9, 12], [6, 12, 18]]) == [6]\n assert candidate(nums = [[10, 20, 30], [10, 20, 30, 40], [10, 20, 30, 40, 50], [10, 20, 30, 40, 50, 60]]) == [10, 20, 30]\n assert candidate(nums = [[50, 100, 150, 200], [100, 150, 200, 250], [150, 200, 250, 300], [200, 250, 300, 350], [250, 300, 350, 400]]) == []\n assert candidate(nums = [[100, 200, 300], [101, 201, 301], [102, 202, 302], [103, 203, 303], [104, 204, 304], [105, 205, 305]]) == []\n assert candidate(nums = [[100, 200, 300], [200, 300, 400], [300, 400, 500], [300, 600, 900]]) == [300]\n assert candidate(nums = [[7, 14, 21, 28], [14, 21, 28, 35], [21, 28, 35, 42], [28, 35, 42, 49]]) == [28]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == []\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]]) == [4, 8]\n assert candidate(nums = [[300, 301, 302, 303, 304, 305], [300, 301, 302, 303, 304, 305, 306], [300, 301, 302, 303, 304, 305, 307, 308]]) == [300, 301, 302, 303, 304, 305]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5]]) == []\n assert candidate(nums = [[999, 1000], [1000, 999], [999, 1000, 998], [1000, 999, 998], [998, 999, 1000], [998, 1000, 999]]) == [999, 1000]\n assert candidate(nums = [[1, 1000], [1, 999], [1, 998], [1, 997], [1, 996]]) == [1]\n assert candidate(nums = [[999, 1000], [999], [999, 1000, 998], [998, 999, 997], [999, 998, 997, 1000]]) == [999]\n assert candidate(nums = [[2, 4, 6, 8, 10, 12], [4, 8, 12, 16, 20], [6, 12, 18, 24, 30], [8, 16, 24, 32, 40], [10, 20, 30, 40, 50]]) == []\n assert candidate(nums = [[5, 15, 25, 35, 45], [15, 25, 35, 45, 55], [5, 15, 25, 35, 45, 65], [15, 25, 35, 45, 75]]) == [15, 25, 35, 45]\n assert candidate(nums = [[11, 22, 33, 44, 55], [22, 33, 44, 55, 66], [33, 44, 55, 66, 77], [44, 55, 66, 77, 88], [55, 66, 77, 88, 99]]) == [55]\n assert candidate(nums = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 5, 9], [2, 6, 10]]) == []\n assert candidate(nums = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [20, 30, 40, 50, 60, 70, 80, 90, 100, 110], [30, 40, 50, 60, 70, 80, 90, 100, 110, 120]]) == [30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [[10, 20, 30, 40], [10, 20, 50], [10, 30, 40, 50]]) == [10]\n assert candidate(nums = [[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]]) == [50]\n assert candidate(nums = [[7, 14, 21, 28], [14, 21, 28, 35], [21, 28, 35, 42], [28, 35, 42, 49], [35, 42, 49, 56], [42, 49, 56, 63]]) == []\n assert candidate(nums = [[7, 8, 9], [7, 8, 9], [7, 8, 9], [7, 8, 9], [7, 8, 9]]) == [7, 8, 9]\n assert candidate(nums = [[1], [2], [3], [4], [5]]) == []\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [2, 4, 6, 8, 10, 12, 14], [1, 3, 5, 7, 9, 11, 13, 15]]) == []\n assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60]]) == []\n assert candidate(nums = [[100], [100, 200], [100, 200, 300], [100, 200, 300, 400], [100, 200, 300, 400, 500]]) == [100]\n assert candidate(nums = [[1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5]]) == [1]\n assert candidate(nums = [[1, 3, 5, 7, 9], [2, 3, 5, 8, 9], [3, 5, 9, 11, 13], [3, 9, 15, 18, 21]]) == [3, 9]\n assert candidate(nums = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [10, 15, 20, 25, 30, 35, 40, 45, 50, 55], [15, 20, 25, 30, 35, 40, 45, 50, 55, 60], [20, 25, 30, 35, 40, 45, 50, 55, 60, 65]]) == [20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [[500, 501, 502, 503, 504], [501, 502, 503, 504, 505], [502, 503, 504, 505, 506], [503, 504, 505, 506, 507]]) == [503, 504]\n assert candidate(nums = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 1], [1, 11, 12], [12, 2, 13], [13, 14, 3]]) == []\n assert candidate(nums = [[1, 10, 100, 1000], [10, 100, 1000, 200], [100, 1000, 200, 300], [1000, 200, 300, 400]]) == [1000]\n assert candidate(nums = [[7, 14, 21, 28, 35], [14, 28, 42, 56, 70], [21, 42, 63, 84, 105], [14, 21, 28, 35, 42]]) == []\n assert candidate(nums = [[7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [11, 12, 13]]) == []\n assert candidate(nums = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9]]) == []\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]) == [3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [[5, 10, 15, 20, 25], [10, 15, 20, 25, 30], [15, 20, 25, 30, 35], [20, 25, 30, 35, 40]]) == [20, 25]\n assert candidate(nums = [[100, 200, 300, 400], [400, 500, 600, 700], [300, 400, 500, 600], [400, 600, 800, 900]]) == [400]\n assert candidate(nums = [[500], [500, 501, 502], [500, 502, 503], [500, 501, 503]]) == [500]\n assert candidate(nums = [[10], [10], [10], [10], [10], [10], [10], [10], [10], [10]]) == [10]\n assert candidate(nums = [[101, 202, 303], [202, 303, 404], [303, 404, 505], [404, 505, 606], [505, 606, 707], [606, 707, 808], [707, 808, 909]]) == []\n assert candidate(nums = [[100], [100], [100], [100], [100]]) == [100]\n assert candidate(nums = [[7, 14, 21], [14, 21, 28], [21, 28, 35], [7, 14, 21, 28, 35]]) == [21]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().intersection", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List intersection(int[][] nums) {", "container": "Solution", "callable": "intersection", "parameters": [{"name": "nums", "type": "int[][]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2249, "task_id": "count-lattice-points-inside-a-circle", "difficulty": "Medium", "problem_description": "Given a 2D integer array circles where circles[i] = [xi, yi, ri] represents the center (xi, yi) and radius ri of the ith circle drawn on a grid, return the number of lattice points that are present inside at least one circle.\nNote:\n\nA lattice point is a point with integer coordinates.\nPoints that lie on the circumference of a circle are also considered to be inside it.\n\n \nExample 1:\n\n\nInput: circles = [[2,2,1]]\nOutput: 5\nExplanation:\nThe figure above shows the given circle.\nThe lattice points present inside the circle are (1, 2), (2, 1), (2, 2), (2, 3), and (3, 2) and are shown in green.\nOther points such as (1, 1) and (1, 3), which are shown in red, are not considered inside the circle.\nHence, the number of lattice points present inside at least one circle is 5.\nExample 2:\n\n\nInput: circles = [[2,2,2],[3,4,1]]\nOutput: 16\nExplanation:\nThe figure above shows the given circles.\nThere are exactly 16 lattice points which are present inside at least one circle. \nSome of them are (0, 2), (2, 0), (2, 4), (3, 2), and (4, 4).\n\n \nConstraints:\n\n1 <= circles.length <= 200\ncircles[i].length == 3\n1 <= xi, yi <= 100\n1 <= ri <= min(xi, yi)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 33\n assert candidate(circles = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5]]) == 276\n assert candidate(circles = [[2, 2, 1]]) == 5\n assert candidate(circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5]]) == 243\n assert candidate(circles = [[2, 2, 2], [3, 4, 1]]) == 16\n assert candidate(circles = [[1, 2, 3], [4, 5, 6]]) == 105\n assert candidate(circles = [[100, 100, 1]]) == 5\n assert candidate(circles = [[100, 100, 50]]) == 7845\n assert candidate(circles = [[50, 50, 50]]) == 7845\n assert candidate(circles = [[50, 50, 40], [60, 60, 10]]) == 5025\n assert candidate(circles = [[100, 100, 100]]) == 31417\n assert candidate(circles = [[1, 1, 1]]) == 5\n assert candidate(circles = [[5, 5, 1], [5, 5, 2], [5, 5, 3]]) == 29\n assert candidate(circles = [[10, 10, 5]]) == 81\n assert candidate(circles = [[50, 50, 10], [40, 40, 10], [30, 30, 10]]) == 833\n assert candidate(circles = [[1, 1, 1], [3, 3, 1]]) == 10\n assert candidate(circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1]]) == 11\n assert candidate(circles = [[50, 50, 20], [60, 60, 10]]) == 1314\n assert candidate(circles = [[10, 10, 1], [20, 20, 1], [30, 30, 1]]) == 15\n assert candidate(circles = [[10, 10, 5], [20, 20, 10], [30, 30, 15]]) == 950\n assert candidate(circles = [[50, 50, 50], [50, 50, 30]]) == 7845\n assert candidate(circles = [[50, 50, 10], [50, 60, 10], [50, 70, 10], [50, 80, 10], [50, 90, 10], [50, 100, 10], [50, 40, 10], [50, 30, 10], [50, 20, 10], [50, 10, 10]]) == 2027\n assert candidate(circles = [[100, 100, 10], [90, 90, 15], [80, 80, 20], [70, 70, 25]]) == 2685\n assert candidate(circles = [[1, 99, 10], [99, 1, 10], [50, 50, 40], [25, 25, 25], [75, 75, 25], [10, 10, 15], [90, 90, 15], [40, 40, 30], [60, 60, 30]]) == 7615\n assert candidate(circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5]]) == 729\n assert candidate(circles = [[30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5]]) == 567\n assert candidate(circles = [[50, 50, 20], [50, 50, 15], [50, 50, 10], [50, 50, 5]]) == 1257\n assert candidate(circles = [[10, 10, 30], [20, 20, 30], [30, 30, 30], [40, 40, 30]]) == 3938\n assert candidate(circles = [[10, 10, 10], [10, 20, 10], [10, 30, 10], [10, 40, 10], [10, 50, 10], [10, 60, 10]]) == 1267\n assert candidate(circles = [[1, 1, 1], [99, 1, 1], [1, 99, 1], [99, 99, 1], [50, 50, 5]]) == 101\n assert candidate(circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5], [100, 100, 5]]) == 810\n assert candidate(circles = [[50, 50, 20], [60, 50, 20], [70, 50, 20], [80, 50, 20]]) == 2433\n assert candidate(circles = [[25, 25, 10], [25, 75, 10], [75, 25, 10], [75, 75, 10]]) == 1268\n assert candidate(circles = [[10, 10, 15], [15, 15, 10], [20, 20, 5], [25, 25, 3]]) == 638\n assert candidate(circles = [[50, 50, 1], [50, 50, 2], [50, 50, 3], [50, 50, 4], [50, 50, 5]]) == 81\n assert candidate(circles = [[10, 10, 5], [10, 20, 5], [10, 30, 5], [10, 40, 5], [10, 50, 5], [10, 60, 5]]) == 481\n assert candidate(circles = [[10, 50, 30], [50, 10, 30], [90, 50, 30], [50, 90, 30]]) == 9496\n assert candidate(circles = [[30, 30, 10], [60, 30, 10], [30, 60, 10], [60, 60, 10], [45, 45, 15]]) == 1837\n assert candidate(circles = [[10, 50, 30], [20, 40, 25], [30, 30, 20], [40, 20, 15], [50, 10, 10]]) == 3139\n assert candidate(circles = [[100, 100, 50], [10, 10, 30], [90, 10, 20], [10, 90, 25]]) == 11790\n assert candidate(circles = [[50, 50, 20], [50, 70, 20], [50, 30, 20], [30, 50, 20], [70, 50, 20]]) == 4113\n assert candidate(circles = [[1, 50, 1], [50, 1, 1], [50, 99, 1], [99, 50, 1]]) == 20\n assert candidate(circles = [[10, 10, 10], [20, 10, 10], [30, 10, 10], [40, 10, 10], [50, 10, 10], [60, 10, 10]]) == 1267\n assert candidate(circles = [[10, 10, 5], [15, 15, 10], [20, 20, 15], [25, 25, 20]]) == 1329\n assert candidate(circles = [[25, 25, 15], [50, 25, 15], [75, 25, 15], [25, 50, 15], [50, 50, 15], [75, 50, 15], [25, 75, 15], [50, 75, 15], [75, 75, 15]]) == 5733\n assert candidate(circles = [[25, 25, 10], [25, 75, 10], [75, 25, 10], [75, 75, 10], [50, 50, 20]]) == 2525\n assert candidate(circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) == 56\n assert candidate(circles = [[50, 50, 50], [30, 30, 30], [70, 70, 30], [20, 20, 20], [80, 80, 20]]) == 8687\n assert candidate(circles = [[90, 90, 5], [80, 80, 5], [70, 70, 5], [60, 60, 5]]) == 324\n assert candidate(circles = [[1, 99, 1], [99, 1, 1], [50, 50, 45], [25, 25, 25], [75, 75, 25]]) == 7605\n assert candidate(circles = [[20, 20, 5], [20, 30, 5], [30, 20, 5], [30, 30, 5], [40, 40, 5], [40, 50, 5], [50, 40, 5], [50, 50, 5]]) == 640\n assert candidate(circles = [[10, 10, 50], [30, 30, 30], [50, 50, 20], [70, 70, 10]]) == 4388\n assert candidate(circles = [[10, 10, 1], [20, 20, 1], [30, 30, 1], [40, 40, 1], [50, 50, 1], [60, 60, 1], [70, 70, 1], [80, 80, 1], [90, 90, 1], [10, 90, 1], [90, 10, 1]]) == 55\n assert candidate(circles = [[50, 50, 20], [70, 50, 20], [50, 70, 20], [50, 30, 20]]) == 3447\n assert candidate(circles = [[1, 1, 50], [50, 50, 50], [100, 100, 50], [50, 1, 50], [1, 50, 50]]) == 15772\n assert candidate(circles = [[10, 10, 1], [11, 11, 2], [12, 12, 3], [13, 13, 4], [14, 14, 5], [15, 15, 6], [16, 16, 7], [17, 17, 8], [18, 18, 9], [19, 19, 10]]) == 347\n assert candidate(circles = [[10, 10, 10], [20, 10, 10], [10, 20, 10], [20, 20, 10], [15, 15, 10]]) == 797\n assert candidate(circles = [[1, 99, 10], [99, 1, 10], [50, 50, 30]]) == 3197\n assert candidate(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]]) == 56\n assert candidate(circles = [[90, 90, 10], [80, 80, 15], [70, 70, 5], [60, 60, 20]]) == 2036\n assert candidate(circles = [[50, 50, 50], [60, 60, 20], [70, 70, 10], [80, 80, 5], [90, 90, 2], [100, 100, 1]]) == 7863\n assert candidate(circles = [[10, 10, 20], [20, 10, 20], [30, 10, 20], [40, 10, 20], [50, 10, 20], [60, 10, 20], [70, 10, 20], [80, 10, 20], [90, 10, 20]]) == 3231\n assert candidate(circles = [[30, 30, 15], [60, 60, 15], [90, 90, 15], [10, 10, 20], [80, 80, 20], [50, 50, 30], [25, 25, 10], [75, 75, 10]]) == 5257\n assert candidate(circles = [[50, 50, 1], [50, 51, 1], [51, 50, 1], [51, 51, 1], [1, 1, 1], [99, 99, 1], [1, 99, 1], [99, 1, 1]]) == 32\n assert candidate(circles = [[50, 50, 50], [40, 40, 40], [30, 30, 30], [20, 20, 20], [10, 10, 10], [60, 60, 10], [70, 70, 10], [80, 80, 10], [90, 90, 10]]) == 8613\n assert candidate(circles = [[50, 50, 25], [25, 25, 25], [75, 75, 25]]) == 5171\n assert candidate(circles = [[10, 10, 5], [20, 10, 5], [30, 10, 5], [40, 10, 5], [50, 10, 5], [60, 10, 5]]) == 481\n assert candidate(circles = [[1, 1, 100], [100, 1, 100], [100, 100, 100], [1, 100, 100]]) == 37209\n assert candidate(circles = [[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]]) == 35\n assert candidate(circles = [[1, 1, 10], [10, 1, 10], [19, 1, 10], [28, 1, 10], [37, 1, 10], [46, 1, 10], [55, 1, 10], [64, 1, 10], [73, 1, 10], [82, 1, 10], [91, 1, 10], [100, 1, 10]]) == 1211\n assert candidate(circles = [[10, 10, 15], [20, 20, 15], [15, 25, 10]]) == 1011\n assert candidate(circles = [[99, 1, 10], [1, 99, 10], [1, 1, 10], [99, 99, 10]]) == 804\n assert candidate(circles = [[50, 50, 5], [50, 60, 5], [50, 70, 5], [50, 80, 5], [50, 90, 5]]) == 401\n assert candidate(circles = [[10, 10, 20], [80, 80, 20], [45, 45, 30]]) == 4891\n assert candidate(circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5]]) == 324\n assert candidate(circles = [[20, 20, 30], [40, 40, 30], [60, 60, 30], [80, 80, 30]]) == 7152\n assert candidate(circles = [[100, 100, 10], [90, 90, 20], [80, 80, 15], [70, 70, 25]]) == 2875\n assert candidate(circles = [[1, 50, 49], [99, 50, 49], [50, 1, 49], [50, 99, 49], [50, 50, 40]]) == 17421\n assert candidate(circles = [[25, 25, 15], [75, 75, 15], [25, 75, 15], [75, 25, 15], [50, 50, 10]]) == 3153\n assert candidate(circles = [[10, 10, 5], [20, 20, 15], [30, 30, 10], [40, 40, 20]]) == 1904\n assert candidate(circles = [[25, 25, 5], [25, 30, 5], [25, 35, 5], [25, 40, 5], [25, 45, 5]]) == 269\n assert candidate(circles = [[25, 25, 15], [45, 25, 15], [25, 45, 15], [45, 45, 15]]) == 2213\n assert candidate(circles = [[10, 10, 30], [20, 20, 30], [30, 30, 30], [40, 40, 30], [50, 50, 30]]) == 4782\n assert candidate(circles = [[10, 10, 15], [20, 20, 20], [30, 10, 15]]) == 1538\n assert candidate(circles = [[10, 90, 10], [90, 10, 10], [50, 50, 20], [60, 40, 15]]) == 2133\n assert candidate(circles = [[10, 50, 10], [20, 50, 10], [30, 50, 10], [40, 50, 10], [50, 50, 10], [60, 50, 10]]) == 1267\n assert candidate(circles = [[30, 30, 20], [40, 40, 20], [50, 50, 20], [60, 60, 20]]) == 2925\n assert candidate(circles = [[10, 10, 5], [30, 30, 5], [50, 50, 5], [70, 70, 5], [90, 90, 5]]) == 405\n assert candidate(circles = [[1, 1, 20], [1, 99, 20], [99, 1, 20], [99, 99, 20], [50, 50, 20]]) == 4266\n assert candidate(circles = [[10, 10, 5], [15, 15, 3], [20, 20, 7]]) == 244\n assert candidate(circles = [[50, 50, 20], [60, 60, 20], [70, 70, 20], [80, 80, 20], [90, 90, 20]]) == 3481\n assert candidate(circles = [[50, 50, 50], [60, 60, 50], [70, 70, 50], [80, 80, 50]]) == 12075\n assert candidate(circles = [[1, 50, 20], [99, 50, 20], [50, 1, 20], [50, 99, 20], [50, 50, 10]]) == 4207\n assert candidate(circles = [[10, 10, 5], [15, 15, 10], [20, 20, 15], [25, 25, 20], [30, 30, 25], [35, 35, 30], [40, 40, 35], [45, 45, 40], [50, 50, 45], [55, 55, 50]]) == 8352\n assert candidate(circles = [[10, 10, 20], [20, 20, 20], [30, 30, 20], [40, 40, 20], [50, 50, 20], [60, 60, 20], [70, 70, 20], [80, 80, 20], [90, 90, 20], [10, 90, 20], [90, 10, 20]]) == 7325\n assert candidate(circles = [[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]]) == 32\n assert candidate(circles = [[1, 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]]) == 188\n assert candidate(circles = [[1, 1, 50], [100, 1, 50], [1, 100, 50], [100, 100, 50], [50, 50, 50], [50, 1, 50], [1, 50, 50], [100, 50, 50], [50, 100, 50]]) == 21676\n assert candidate(circles = [[75, 75, 30], [25, 25, 15], [50, 50, 10]]) == 3795\n assert candidate(circles = [[10, 10, 5], [20, 20, 10], [30, 30, 15], [40, 40, 20], [50, 50, 25]]) == 2761\n assert candidate(circles = [[30, 30, 20], [30, 70, 20], [70, 30, 20], [70, 70, 20], [50, 50, 20]]) == 5369\n assert candidate(circles = [[50, 50, 10], [51, 51, 5], [52, 52, 15], [53, 53, 20]]) == 1257\n assert candidate(circles = [[1, 1, 1], [99, 99, 1], [50, 50, 40]]) == 5035\n assert candidate(circles = [[10, 10, 40], [50, 50, 40], [90, 90, 40]]) == 10417\n assert candidate(circles = [[1, 1, 1], [99, 99, 1], [50, 50, 50]]) == 7855\n assert candidate(circles = [[1, 1, 100], [100, 100, 100], [50, 50, 50], [25, 25, 25], [75, 75, 25]]) == 33663\n assert candidate(circles = [[1, 1, 1], [1, 100, 1], [100, 1, 1], [100, 100, 1], [50, 50, 45]]) == 6381\n assert candidate(circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == 90\n assert candidate(circles = [[10, 50, 15], [50, 10, 15], [90, 50, 15], [50, 90, 15]]) == 2702\n assert candidate(circles = [[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]]) == 347\n assert candidate(circles = [[100, 100, 100], [1, 1, 1], [99, 99, 1]]) == 31422\n assert candidate(circles = [[10, 50, 10], [20, 40, 15], [30, 30, 20], [40, 20, 25], [50, 10, 30]]) == 3139\n assert candidate(circles = [[1, 99, 10], [99, 1, 10], [50, 50, 10], [25, 25, 15], [75, 75, 15]]) == 2111\n assert candidate(circles = [[50, 50, 10], [50, 60, 10], [50, 70, 10], [50, 80, 10]]) == 887\n"}, "metadata": {"canonical_parameter_names": ["circles"], "leetcode_dataset_entry_point": "Solution().countLatticePoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countLatticePoints(int[][] circles) {", "container": "Solution", "callable": "countLatticePoints", "parameters": [{"name": "circles", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2250, "task_id": "count-number-of-rectangles-containing-each-point", "difficulty": "Medium", "problem_description": "You are given a 2D integer array rectangles where rectangles[i] = [li, hi] indicates that ith rectangle has a length of li and a height of hi. You are also given a 2D integer array points where points[j] = [xj, yj] is a point with coordinates (xj, yj).\nThe ith rectangle has its bottom-left corner point at the coordinates (0, 0) and its top-right corner point at (li, hi).\nReturn an integer array count of length points.length where count[j] is the number of rectangles that contain the jth point.\nThe ith rectangle contains the jth point if 0 <= xj <= li and 0 <= yj <= hi. Note that points that lie on the edges of a rectangle are also considered to be contained by that rectangle.\n \nExample 1:\n\n\nInput: rectangles = [[1,2],[2,3],[2,5]], points = [[2,1],[1,4]]\nOutput: [2,1]\nExplanation: \nThe first rectangle contains no points.\nThe second rectangle contains only the point (2, 1).\nThe third rectangle contains the points (2, 1) and (1, 4).\nThe number of rectangles that contain the point (2, 1) is 2.\nThe number of rectangles that contain the point (1, 4) is 1.\nTherefore, we return [2, 1].\n\nExample 2:\n\n\nInput: rectangles = [[1,1],[2,2],[3,3]], points = [[1,3],[1,1]]\nOutput: [1,3]\nExplanation:\nThe first rectangle contains only the point (1, 1).\nThe second rectangle contains only the point (1, 1).\nThe third rectangle contains the points (1, 3) and (1, 1).\nThe number of rectangles that contain the point (1, 3) is 1.\nThe number of rectangles that contain the point (1, 1) is 3.\nTherefore, we return [1, 3].\n\n \nConstraints:\n\n1 <= rectangles.length, points.length <= 5 * 104\nrectangles[i].length == points[j].length == 2\n1 <= li, xj <= 109\n1 <= hi, yj <= 100\nAll the rectangles are unique.\nAll the points are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rectangles = [[1, 2], [2, 3], [2, 5]],points = [[2, 1], [1, 4]]) == [2, 1]\n assert candidate(rectangles = [[10, 100], [9, 99], [8, 98], [7, 97]],points = [[10, 100], [9, 99], [8, 98], [7, 97]]) == [1, 2, 3, 4]\n assert candidate(rectangles = [[10, 1], [9, 10], [10, 10], [1, 1]],points = [[5, 5], [6, 6], [7, 7]]) == [2, 2, 2]\n assert candidate(rectangles = [[1000000000, 100], [999999999, 100], [1000000000, 100], [1, 100]],points = [[500000000, 50], [600000000, 60], [700000000, 70]]) == [3, 3, 3]\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3]],points = [[1, 3], [1, 1]]) == [1, 3]\n assert candidate(rectangles = [[5, 100], [10, 99], [15, 98], [20, 97], [25, 96], [30, 95]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [6, 6, 6, 6, 6, 5, 5, 5, 5, 5]\n assert candidate(rectangles = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [9, 7, 5, 3, 1, 0, 0, 0, 0]\n assert candidate(rectangles = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[10, 100], [20, 99], [30, 98], [40, 97], [50, 96], [60, 95], [70, 94], [80, 93], [90, 92], [100, 91]],points = [[5, 95], [15, 90], [25, 85], [35, 80], [45, 75], [55, 70], [65, 65], [75, 60], [85, 55], [95, 50]]) == [6, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[500000000, 100], [600000000, 100], [700000000, 100], [800000000, 100]],points = [[400000000, 50], [550000000, 55], [650000000, 65], [750000000, 75]]) == [4, 3, 2, 1]\n assert candidate(rectangles = [[100, 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], [1400, 100], [1500, 100], [1600, 100], [1700, 100], [1800, 100], [1900, 100], [2000, 100]],points = [[50, 50], [250, 50], [450, 50], [650, 50], [850, 50], [1050, 50], [1250, 50], [1450, 50], [1650, 50], [1850, 50]]) == [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]\n assert candidate(rectangles = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96], [1, 95], [1, 94], [1, 93], [1, 92], [1, 91]],points = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96], [1, 95], [1, 94], [1, 93], [1, 92], [1, 91]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(rectangles = [[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]],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]]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[300000000, 100], [600000000, 90], [900000000, 80], [1200000000, 70], [1500000000, 60]],points = [[150000000, 65], [450000000, 75], [750000000, 85], [1050000000, 95], [1350000000, 100]]) == [4, 2, 0, 0, 0]\n assert candidate(rectangles = [[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], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [1, 56], [1, 57], [1, 58], [1, 59], [1, 60], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 66], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 72], [1, 73], [1, 74], [1, 75], [1, 76], [1, 77], [1, 78], [1, 79], [1, 80], [1, 81], [1, 82], [1, 83], [1, 84], [1, 85], [1, 86], [1, 87], [1, 88], [1, 89], [1, 90], [1, 91], [1, 92], [1, 93], [1, 94], [1, 95], [1, 96], [1, 97], [1, 98], [1, 99], [1, 100]],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], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [1, 56], [1, 57], [1, 58], [1, 59], [1, 60], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 66], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 72], [1, 73], [1, 74], [1, 75], [1, 76], [1, 77], [1, 78], [1, 79], [1, 80], [1, 81], [1, 82], [1, 83], [1, 84], [1, 85], [1, 86], [1, 87], [1, 88], [1, 89], [1, 90], [1, 91], [1, 92], [1, 93], [1, 94], [1, 95], [1, 96], [1, 97], [1, 98], [1, 99], [1, 100]]) == [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]\n assert candidate(rectangles = [[500, 90], [1000, 80], [1500, 70], [2000, 60], [2500, 50]],points = [[250, 55], [750, 75], [1250, 85], [1750, 95], [2250, 100]]) == [4, 1, 0, 0, 0]\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[5, 100], [10, 99], [15, 98], [20, 97], [25, 96], [30, 95], [35, 94], [40, 93], [45, 92], [50, 91]],points = [[1, 95], [6, 90], [11, 85], [16, 80], [21, 75], [26, 70], [31, 65], [36, 60], [41, 55], [46, 50]]) == [6, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],points = [[50, 1], [150, 2], [250, 3], [350, 4], [450, 5]]) == [5, 4, 3, 2, 1]\n assert candidate(rectangles = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]]) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(rectangles = [[1000000000, 100], [999999999, 100], [1000000000, 100], [1, 100]],points = [[500000000, 50], [600000000, 60], [700000000, 70], [1000000000, 100]]) == [3, 3, 3, 2]\n assert candidate(rectangles = [[500000000, 100], [499999999, 99], [500000000, 98], [1, 97]],points = [[250000000, 50], [300000000, 60], [350000000, 70]]) == [3, 3, 3]\n assert candidate(rectangles = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],points = [[50, 10], [150, 20], [250, 30], [350, 40], [450, 50]]) == [0, 0, 0, 0, 0]\n assert candidate(rectangles = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [10, 8, 6, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rectangles = [[100, 100], [99, 100], [98, 100], [97, 100], [96, 100], [95, 100], [94, 100], [93, 100], [92, 100], [91, 100], [90, 100]],points = [[50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == [11, 11, 11, 11, 11]\n assert candidate(rectangles = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(rectangles = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 100]],points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 100]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]],points = [[50, 1], [150, 2], [250, 3], [350, 4], [450, 5], [550, 6], [650, 7], [750, 8], [850, 9], [950, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[1000000000, 100], [500000000, 100], [250000000, 100], [125000000, 100], [62500000, 100]],points = [[500000000, 50], [250000000, 50], [125000000, 50], [62500000, 50], [31250000, 50]]) == [2, 3, 4, 5, 5]\n assert candidate(rectangles = [[1000000000, 100], [999999999, 99], [999999998, 98], [999999997, 97], [999999996, 96], [999999995, 95], [999999994, 94], [999999993, 93], [999999992, 92], [999999991, 91]],points = [[500000000, 50], [500000001, 50], [500000002, 50], [500000003, 50], [500000004, 50], [500000005, 50], [500000006, 50], [500000007, 50], [500000008, 50], [500000009, 50]]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(rectangles = [[500000000, 50], [600000000, 60], [700000000, 70], [800000000, 80], [900000000, 90]],points = [[250000000, 25], [350000000, 35], [450000000, 45], [550000000, 55]]) == [5, 5, 5, 4]\n assert candidate(rectangles = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [5, 5, 5, 5, 5]\n assert candidate(rectangles = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],points = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450]]) == [1, 0, 0, 0, 0]\n assert candidate(rectangles = [[1000000000, 100], [999999999, 99], [1000000000, 98], [1, 97]],points = [[500000000, 50], [600000000, 51], [700000000, 52], [800000000, 53]]) == [3, 3, 3, 3]\n assert candidate(rectangles = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],points = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == [10, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(rectangles = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],points = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],points = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],points = [[1, 90], [2, 89], [3, 88], [4, 87], [5, 86], [6, 85], [7, 84], [8, 83], [9, 82], [10, 81]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96]],points = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96]]) == [1, 2, 3, 4, 5]\n assert candidate(rectangles = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],points = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[5, 100], [10, 99], [15, 98], [20, 97], [25, 96], [30, 95]],points = [[5, 95], [10, 90], [15, 85], [20, 80], [25, 75], [30, 70]]) == [6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [550, 550], [650, 650], [750, 750], [850, 850], [950, 950]]) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(rectangles = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10]],points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[500000000, 100], [500000001, 99], [500000002, 98], [500000003, 97], [500000004, 96]],points = [[500000000, 99], [500000001, 98], [500000002, 97]]) == [2, 2, 2]\n assert candidate(rectangles = [[100, 100], [200, 95], [300, 90], [400, 85], [500, 80], [600, 75], [700, 70], [800, 65], [900, 60], [1000, 55]],points = [[50, 50], [150, 55], [250, 60], [350, 65], [450, 70], [550, 75], [650, 80], [750, 85], [850, 90], [950, 95]]) == [10, 9, 7, 5, 3, 1, 0, 0, 0, 0]\n assert candidate(rectangles = [[500000000, 50], [600000000, 60], [700000000, 70], [800000000, 80]],points = [[100000000, 10], [200000000, 20], [300000000, 30], [400000000, 40], [500000000, 50], [600000000, 60], [700000000, 70], [800000000, 80]]) == [4, 4, 4, 4, 4, 3, 2, 1]\n assert candidate(rectangles = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[1000000000, 100], [1000000000, 99], [1000000000, 98], [1000000000, 97], [1000000000, 96]],points = [[500000000, 50], [500000000, 49], [500000000, 48], [500000000, 47], [500000000, 46]]) == [5, 5, 5, 5, 5]\n assert candidate(rectangles = [[500000000, 100], [500000001, 100], [500000002, 100], [500000003, 100], [500000004, 100]],points = [[499999999, 50], [500000000, 50], [500000001, 50], [500000002, 50], [500000003, 50]]) == [5, 5, 4, 3, 2]\n assert candidate(rectangles = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(rectangles = [[50, 50], [75, 75], [100, 100], [25, 25]],points = [[30, 30], [40, 40], [60, 60], [80, 80], [90, 90]]) == [3, 3, 2, 1, 1]\n assert candidate(rectangles = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],points = [[1, 1], [10, 10], [2, 2], [20, 20], [3, 3], [30, 30], [4, 4], [40, 40], [5, 5], [50, 50]]) == [10, 1, 9, 0, 8, 0, 7, 0, 6, 0]\n assert candidate(rectangles = [[10, 100], [20, 100], [30, 100], [40, 100], [50, 100]],points = [[5, 50], [15, 50], [25, 50], [35, 50], [45, 50]]) == [5, 4, 3, 2, 1]\n assert candidate(rectangles = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1]],points = [[15, 1], [25, 1], [35, 1], [45, 1], [55, 1]]) == [4, 3, 2, 1, 0]\n assert candidate(rectangles = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10], [100, 11], [100, 12], [100, 13], [100, 14], [100, 15], [100, 16], [100, 17], [100, 18], [100, 19], [100, 20], [100, 21], [100, 22], [100, 23], [100, 24], [100, 25], [100, 26], [100, 27], [100, 28], [100, 29], [100, 30], [100, 31], [100, 32], [100, 33], [100, 34], [100, 35], [100, 36], [100, 37], [100, 38], [100, 39], [100, 40], [100, 41], [100, 42], [100, 43], [100, 44], [100, 45], [100, 46], [100, 47], [100, 48], [100, 49], [100, 50], [100, 51], [100, 52], [100, 53], [100, 54], [100, 55], [100, 56], [100, 57], [100, 58], [100, 59], [100, 60], [100, 61], [100, 62], [100, 63], [100, 64], [100, 65], [100, 66], [100, 67], [100, 68], [100, 69], [100, 70], [100, 71], [100, 72], [100, 73], [100, 74], [100, 75], [100, 76], [100, 77], [100, 78], [100, 79], [100, 80], [100, 81], [100, 82], [100, 83], [100, 84], [100, 85], [100, 86], [100, 87], [100, 88], [100, 89], [100, 90], [100, 91], [100, 92], [100, 93], [100, 94], [100, 95], [100, 96], [100, 97], [100, 98], [100, 99]],points = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15], [50, 16], [50, 17], [50, 18], [50, 19], [50, 20], [50, 21], [50, 22], [50, 23], [50, 24], [50, 25], [50, 26], [50, 27], [50, 28], [50, 29], [50, 30], [50, 31], [50, 32], [50, 33], [50, 34], [50, 35], [50, 36], [50, 37], [50, 38], [50, 39], [50, 40], [50, 41], [50, 42], [50, 43], [50, 44], [50, 45], [50, 46], [50, 47], [50, 48], [50, 49], [50, 50], [50, 51], [50, 52], [50, 53], [50, 54], [50, 55], [50, 56], [50, 57], [50, 58], [50, 59], [50, 60], [50, 61], [50, 62], [50, 63], [50, 64], [50, 65], [50, 66], [50, 67], [50, 68], [50, 69], [50, 70], [50, 71], [50, 72], [50, 73], [50, 74], [50, 75], [50, 76], [50, 77], [50, 78], [50, 79], [50, 80], [50, 81], [50, 82], [50, 83], [50, 84], [50, 85], [50, 86], [50, 87], [50, 88], [50, 89], [50, 90], [50, 91], [50, 92], [50, 93], [50, 94], [50, 95], [50, 96], [50, 97], [50, 98], [50, 99]]) == [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]\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],points = [[5, 100], [6, 99], [7, 98], [8, 97], [9, 96], [10, 95], [11, 94], [12, 93], [13, 92], [14, 91]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(rectangles = [[1000000000, 1], [999999999, 2], [999999998, 3], [999999997, 4], [999999996, 5]],points = [[1000000000, 1], [999999999, 2], [999999998, 3], [999999997, 4], [999999996, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(rectangles = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96], [1, 95]],points = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(rectangles = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],points = [[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rectangles = [[1000000000, 50], [999999999, 50], [1000000000, 50], [1, 50]],points = [[500000000, 30], [600000000, 35], [700000000, 40]]) == [3, 3, 3]\n assert candidate(rectangles = [[9, 90], [8, 80], [7, 70], [6, 60], [5, 50], [4, 40], [3, 30], [2, 20], [1, 10]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n"}, "metadata": {"canonical_parameter_names": ["rectangles", "points"], "leetcode_dataset_entry_point": "Solution().countRectangles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] countRectangles(int[][] rectangles, int[][] points) {", "container": "Solution", "callable": "countRectangles", "parameters": [{"name": "rectangles", "type": "int[][]"}, {"name": "points", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2251, "task_id": "number-of-flowers-in-full-bloom", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array flowers, where flowers[i] = [starti, endi] means the ith flower will be in full bloom from starti to endi (inclusive). You are also given a 0-indexed integer array people of size n, where people[i] is the time that the ith person will arrive to see the flowers.\nReturn an integer array answer of size n, where answer[i] is the number of flowers that are in full bloom when the ith person arrives.\n \nExample 1:\n\n\nInput: flowers = [[1,6],[3,7],[9,12],[4,13]], people = [2,3,7,11]\nOutput: [1,2,2,2]\nExplanation: The figure above shows the times when the flowers are in full bloom and when the people arrive.\nFor each person, we return the number of flowers in full bloom during their arrival.\n\nExample 2:\n\n\nInput: flowers = [[1,10],[3,3]], people = [3,3,2]\nOutput: [2,2,1]\nExplanation: The figure above shows the times when the flowers are in full bloom and when the people arrive.\nFor each person, we return the number of flowers in full bloom during their arrival.\n\n \nConstraints:\n\n1 <= flowers.length <= 5 * 104\nflowers[i].length == 2\n1 <= starti <= endi <= 109\n1 <= people.length <= 5 * 104\n1 <= people[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(flowers = [[1, 10], [3, 3]],people = [3, 3, 2]) == [2, 2, 1]\n assert candidate(flowers = [[1, 100]],people = [50, 100, 150]) == [1, 1, 0]\n assert candidate(flowers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 2], [2, 3], [3, 4]],people = [1, 2, 3, 4]) == [1, 2, 2, 1]\n assert candidate(flowers = [[5, 10], [15, 20], [1, 5]],people = [6, 12, 4]) == [1, 0, 1]\n assert candidate(flowers = [[1, 1000000000]],people = [1, 500000000, 1000000000]) == [1, 1, 1]\n assert candidate(flowers = [[5, 10], [15, 20], [25, 30]],people = [10, 20, 30, 40]) == [1, 1, 1, 0]\n assert candidate(flowers = [[1, 6], [3, 7], [9, 12], [4, 13]],people = [2, 3, 7, 11]) == [1, 2, 2, 2]\n assert candidate(flowers = [[1, 1000000000]],people = [1, 1000000000]) == [1, 1]\n assert candidate(flowers = [[5, 11], [8, 8], [8, 9], [10, 10], [9, 11], [5, 7]],people = [6, 10, 7]) == [2, 3, 2]\n assert candidate(flowers = [[1, 1], [2, 2], [3, 3]],people = [1, 2, 3]) == [1, 1, 1]\n assert candidate(flowers = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(flowers = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],people = [3, 6, 8, 10, 15]) == [3, 5, 3, 1, 0]\n assert candidate(flowers = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10]],people = [1, 5, 10]) == [5, 5, 5]\n assert candidate(flowers = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(flowers = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]\n assert candidate(flowers = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],people = [1, 5, 10, 15]) == [1, 2, 2, 0]\n assert candidate(flowers = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],people = [2, 6, 10, 14, 18, 22, 24]) == [1, 1, 1, 1, 1, 1, 0]\n assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],people = [1, 1000000000, 500000000, 250000000, 750000000]) == [1, 1, 5, 5, 5]\n assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997]],people = [1, 2, 3, 4, 999999999, 1000000000]) == [1, 2, 3, 4, 2, 1]\n assert candidate(flowers = [[100000000, 200000000], [300000000, 400000000], [500000000, 600000000]],people = [150000000, 350000000, 550000000]) == [1, 1, 1]\n assert candidate(flowers = [[2, 5], [8, 10], [12, 14], [18, 22], [26, 28], [30, 34]],people = [2, 5, 8, 10, 12, 14, 18, 22, 26, 28, 30, 34]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],people = [5, 6, 7, 8, 9, 10]) == [5, 5, 4, 3, 2, 1]\n assert candidate(flowers = [[1, 6], [3, 7], [9, 12], [4, 13], [14, 17], [18, 21], [22, 25]],people = [2, 3, 7, 11, 15, 19, 23]) == [1, 2, 2, 2, 1, 1, 1]\n assert candidate(flowers = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]],people = [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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]],people = [1, 50, 100, 150, 200, 250, 300]) == [1, 2, 3, 3, 3, 2, 1]\n assert candidate(flowers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[5, 15], [10, 20], [15, 25], [20, 30], [25, 35]],people = [10, 15, 20, 25, 30, 35]) == [2, 3, 3, 3, 2, 1]\n assert candidate(flowers = [[5, 20], [20, 30], [10, 25], [15, 35], [25, 40]],people = [10, 15, 20, 25, 30, 35, 40]) == [2, 3, 4, 4, 3, 2, 1]\n assert candidate(flowers = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],people = [5, 15, 25, 35, 45, 55]) == [1, 1, 1, 1, 1, 0]\n assert candidate(flowers = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [19, 21], [22, 24], [25, 27], [28, 30]],people = [1, 3, 4, 6, 7, 9, 10, 12, 13, 15, 16, 18, 19, 21, 22, 24, 25, 27, 28, 30]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]],people = [2, 6, 10, 14, 18, 22]) == [1, 1, 1, 1, 1, 0]\n assert candidate(flowers = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]],people = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],people = [3, 8, 13, 18, 23]) == [1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 3, 3, 3, 3, 2, 1]\n assert candidate(flowers = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 0, 0, 0, 0, 0]\n assert candidate(flowers = [[1, 6], [3, 7], [9, 12], [4, 13], [10, 15], [16, 20], [21, 25], [26, 30]],people = [2, 5, 6, 7, 10, 15, 20, 25, 30]) == [1, 3, 3, 2, 3, 1, 1, 1, 1]\n assert candidate(flowers = [[10, 15], [15, 20], [20, 25], [25, 30]],people = [12, 17, 22, 27]) == [1, 1, 1, 1]\n assert candidate(flowers = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35]],people = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33]) == [0, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 1000], [500, 1500], [1000, 2000], [1500, 2500], [2000, 3000], [2500, 3500], [3000, 4000], [3500, 4500], [4000, 5000], [4500, 5500]],people = [1, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000]) == [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2]\n assert candidate(flowers = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(flowers = [[1, 5], [2, 3], [4, 6], [7, 8], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 2, 2, 2, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 300000000], [500000000, 1000000000], [700000000, 900000000], [800000000, 1000000000], [900000000, 1100000000]],people = [100000000, 300000000, 500000000, 700000000, 900000000, 1100000000]) == [1, 1, 1, 2, 4, 1]\n assert candidate(flowers = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50]],people = [5, 15, 25, 35, 45]) == [1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 1000000000], [100000001, 2000000000], [2000000001, 3000000000], [3000000001, 4000000000], [4000000001, 5000000000]],people = [500000000, 1500000000, 2500000000, 3500000000, 4500000000, 5500000000]) == [2, 1, 1, 1, 1, 0]\n assert candidate(flowers = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],people = [1, 2, 3, 4, 5]) == [5, 5, 5, 5, 5]\n assert candidate(flowers = [[1, 5], [2, 9], [6, 8], [4, 7], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 2, 3, 3, 3, 3, 2, 2, 1]\n assert candidate(flowers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(flowers = [[2, 11], [4, 12], [8, 15], [9, 16], [10, 17]],people = [5, 10, 15, 20]) == [2, 5, 3, 0]\n assert candidate(flowers = [[1, 1000000000], [2, 500000000], [500000000, 1000000000]],people = [1, 250000000, 500000000, 750000000, 1000000000]) == [1, 2, 3, 2, 2]\n assert candidate(flowers = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],people = [50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 6]\n assert candidate(flowers = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],people = [1, 5, 10]) == [1, 1, 1]\n assert candidate(flowers = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996], [6, 999999995]],people = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 999999995, 999999997, 1000000000]) == [1, 3, 5, 6, 6, 6, 6, 6, 6, 6, 6, 4, 1]\n assert candidate(flowers = [[1, 10], [5, 15], [10, 20], [15, 25], [20, 30]],people = [1, 6, 11, 16, 21]) == [1, 2, 2, 2, 2]\n assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(flowers = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [19, 21]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [9, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(flowers = [[10, 12], [12, 14], [14, 16], [16, 18], [18, 20], [20, 22], [22, 24], [24, 26], [26, 28]],people = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]) == [1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1]\n assert candidate(flowers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]\n assert candidate(flowers = [[1, 5], [2, 8], [3, 9], [10, 15], [12, 18], [16, 20]],people = [1, 3, 5, 7, 10, 12, 15, 18, 20]) == [1, 3, 3, 2, 1, 2, 2, 2, 1]\n assert candidate(flowers = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 500000000], [500000001, 1000000000]],people = [250000000, 750000000, 1000000000]) == [1, 1, 1]\n assert candidate(flowers = [[1, 2000000000], [1, 2000000000], [1, 2000000000], [1, 2000000000], [1, 2000000000], [1, 2000000000], [1, 2000000000], [1, 2000000000], [1, 2000000000], [1, 2000000000]],people = [1, 1000000000, 2000000000]) == [10, 10, 10]\n assert candidate(flowers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000]],people = [1, 500, 1000]) == [10, 10, 10]\n assert candidate(flowers = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(flowers = [[10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [10, 20]],people = [5, 15, 25]) == [0, 10, 0]\n assert candidate(flowers = [[1, 6], [6, 11], [11, 16], [16, 21]],people = [1, 5, 6, 10, 11, 15, 16, 20, 21]) == [1, 1, 2, 1, 2, 1, 2, 1, 1]\n assert candidate(flowers = [[100, 110], [110, 120], [120, 130], [130, 140], [140, 150], [150, 160], [160, 170], [170, 180], [180, 190]],people = [105, 115, 125, 135, 145, 155, 165, 175, 185]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [19, 21]],people = [2, 5, 8, 11, 14, 17, 20]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],people = [1, 2, 3, 4, 5, 1000000000, 999999999, 999999998, 999999997, 999999996]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n assert candidate(flowers = [[1, 10000], [10001, 20000], [20001, 30000], [30001, 40000], [40001, 50000]],people = [5000, 15000, 25000, 35000, 45000]) == [1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],people = [1, 500000000, 1000000000]) == [1, 5, 1]\n assert candidate(flowers = [[1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000]],people = [1, 1000000000, 500000000, 250000000, 750000000]) == [10, 10, 10, 10, 10]\n assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(flowers = [[1, 100], [10, 90], [20, 80], [30, 70], [40, 60], [50, 50]],people = [1, 50, 100, 150]) == [1, 6, 1, 0]\n assert candidate(flowers = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350]],people = [50, 100, 150, 200, 250, 300, 350]) == [2, 3, 3, 3, 3, 2, 1]\n assert candidate(flowers = [[100, 200], [150, 250], [200, 300], [250, 350], [300, 400]],people = [50, 100, 150, 200, 250, 300, 350, 400, 450]) == [0, 1, 2, 3, 3, 3, 2, 1, 0]\n assert candidate(flowers = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],people = [1, 2, 3, 4, 5]) == [10, 10, 10, 10, 10]\n assert candidate(flowers = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1]\n assert candidate(flowers = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]],people = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1]\n assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996], [6, 999999995], [7, 999999994], [8, 999999993], [9, 999999992], [10, 999999991]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(flowers = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],people = [3, 8, 13, 18, 23, 28]) == [1, 1, 1, 1, 1, 0]\n assert candidate(flowers = [[1, 5], [10, 15], [20, 25], [30, 35], [40, 45]],people = [3, 8, 13, 18, 23, 28, 33, 38, 43]) == [1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996], [6, 999999995], [7, 999999994], [8, 999999993], [9, 999999992], [10, 999999991]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 999999991, 999999992, 999999993, 999999994, 999999995, 999999996, 999999997, 999999998, 999999999, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(flowers = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50], [45, 55], [50, 60], [55, 65]],people = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]) == [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1]\n assert candidate(flowers = [[5, 15], [10, 20], [15, 25], [20, 30], [25, 35]],people = [5, 8, 10, 12, 15, 18, 20, 23, 25, 28, 30]) == [1, 1, 2, 2, 3, 2, 3, 2, 3, 2, 2]\n assert candidate(flowers = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],people = [1, 5, 9]) == [1, 2, 2]\n assert candidate(flowers = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 5], [10, 20], [25, 35], [40, 50], [55, 60]],people = [5, 15, 25, 35, 45, 55, 60]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35]],people = [8, 13, 18, 23, 28, 33]) == [1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000]],people = [1, 1000000000]) == [10, 10]\n assert candidate(flowers = [[1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000]],people = [1, 500000000, 1000000000]) == [5, 5, 5]\n assert candidate(flowers = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3]],people = [1, 2, 3, 4, 5]) == [5, 5, 5, 0, 0]\n assert candidate(flowers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],people = [1, 5, 9, 13, 17, 20]) == [1, 1, 1, 1, 1, 1]\n assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],people = [1, 3, 5, 7, 9]) == [1, 2, 2, 2, 2]\n assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(flowers = [[1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000]],people = [1, 1000000000, 500000000, 250000000, 750000000]) == [5, 5, 5, 5, 5]\n assert candidate(flowers = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],people = [5, 15, 25, 35, 45, 55, 1, 11, 21, 31, 41]) == [1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1]\n"}, "metadata": {"canonical_parameter_names": ["flowers", "people"], "leetcode_dataset_entry_point": "Solution().fullBloomFlowers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] fullBloomFlowers(int[][] flowers, int[] people) {", "container": "Solution", "callable": "fullBloomFlowers", "parameters": [{"name": "flowers", "type": "int[][]"}, {"name": "people", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2255, "task_id": "count-prefixes-of-a-given-string", "difficulty": "Easy", "problem_description": "You are given a string array words and a string s, where words[i] and s comprise only of lowercase English letters.\nReturn the number of strings in words that are a prefix of s.\nA prefix of a string is a substring that occurs at the beginning of the string. A substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: words = [\"a\",\"b\",\"c\",\"ab\",\"bc\",\"abc\"], s = \"abc\"\nOutput: 3\nExplanation:\nThe strings in words which are a prefix of s = \"abc\" are:\n\"a\", \"ab\", and \"abc\".\nThus the number of strings in words which are a prefix of s is 3.\nExample 2:\n\nInput: words = [\"a\",\"a\"], s = \"aa\"\nOutput: 2\nExplanation:\nBoth of the strings are a prefix of s. \nNote that the same string can occur multiple times in words, and it should be counted each time.\n \nConstraints:\n\n1 <= words.length <= 1000\n1 <= words[i].length, s.length <= 10\nwords[i] and s consist of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['hello', 'hell', 'he', 'h'],s = \"hello\") == 4\n assert candidate(words = ['short'],s = \"shorter\") == 1\n assert candidate(words = ['same', 'same'],s = \"same\") == 2\n assert candidate(words = ['hello'],s = \"h\") == 0\n assert candidate(words = ['hello'],s = \"hello\") == 1\n assert candidate(words = ['d', 'do', 'dog', 'doge'],s = \"doge\") == 4\n assert candidate(words = ['prefix'],s = \"prefix\") == 1\n assert candidate(words = ['same', 'same', 'same'],s = \"same\") == 3\n assert candidate(words = ['world'],s = \"world\") == 1\n assert candidate(words = ['a', 'b', 'c'],s = \"abcde\") == 1\n assert candidate(words = ['a'],s = \"a\") == 1\n assert candidate(words = ['not', 'a', 'prefix'],s = \"example\") == 0\n assert candidate(words = ['test', 'testing', 't'],s = \"testing\") == 3\n assert candidate(words = ['xyz', 'xy', 'x'],s = \"xyz\") == 3\n assert candidate(words = ['abcd'],s = \"abc\") == 0\n assert candidate(words = ['a', 'b', 'c'],s = \"d\") == 0\n assert candidate(words = ['test', 'testing', 'tested'],s = \"testing\") == 2\n assert candidate(words = ['a', 'a'],s = \"aa\") == 2\n assert candidate(words = ['abc'],s = \"abc\") == 1\n assert candidate(words = ['abc', 'abcd', 'abcde'],s = \"abcdef\") == 3\n assert candidate(words = ['z', 'zz', 'zzz'],s = \"zzzz\") == 3\n assert candidate(words = ['cat', 'bat', 'rat'],s = \"car\") == 0\n assert candidate(words = ['a', 'b', 'c', 'ab', 'bc', 'abc'],s = \"abc\") == 3\n assert candidate(words = ['h'],s = \"hello\") == 1\n assert candidate(words = ['a'],s = \"b\") == 0\n assert candidate(words = ['yes', 'no'],s = \"yesman\") == 1\n assert candidate(words = ['prefix'],s = \"prefixing\") == 1\n assert candidate(words = ['hello', 'he', 'h'],s = \"hello\") == 3\n assert candidate(words = ['test'],s = \"testing\") == 1\n assert candidate(words = ['a', 'ab', 'abc', 'abcd'],s = \"abcd\") == 4\n assert candidate(words = ['subsequence', 'subsequen', 'subsequen', 'subsequ', 'subsequ', 'subseq'],s = \"subsequence\") == 6\n assert candidate(words = ['ab', 'abc', 'abcd'],s = \"abcd\") == 3\n assert candidate(words = ['test', 'testing', 'tested', 'te'],s = \"testing\") == 3\n assert candidate(words = ['unique', 'uniq', 'un'],s = \"unique\") == 3\n assert candidate(words = ['different', 'dif', 'diff', 'differ'],s = \"different\") == 4\n assert candidate(words = ['partial', 'parti', 'part', 'par'],s = \"partialmatch\") == 4\n assert candidate(words = ['prefix', 'pre', 'pred'],s = \"predicate\") == 2\n assert candidate(words = ['example', 'examp', 'exam', 'exa', 'ex', 'e'],s = \"example\") == 6\n assert candidate(words = ['prefix', 'prefi', 'pref', 'pre'],s = \"prefix\") == 4\n assert candidate(words = ['abc', 'abcd', 'ab', 'a'],s = \"abcd\") == 4\n assert candidate(words = ['complex', 'com', 'comp', 'comple', 'complexe'],s = \"complex\") == 4\n assert candidate(words = ['prefix', 'prefi', 'prefixe', 'prefixex'],s = \"prefixextension\") == 4\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa'],s = \"aaaaa\") == 4\n assert candidate(words = ['example', 'ex', 'exa', 'exam', 'examp', 'examp'],s = \"example\") == 6\n assert candidate(words = ['complex', 'comple', 'compl', 'comp'],s = \"complexity\") == 4\n assert candidate(words = ['hello', 'hell', 'he'],s = \"hello\") == 3\n assert candidate(words = ['abcde', 'bcde', 'cde', 'de', 'e'],s = \"abcde\") == 1\n assert candidate(words = ['abc', 'def', 'ghi'],s = \"abcdefghi\") == 1\n assert candidate(words = ['not', 'no', 'n'],s = \"note\") == 3\n assert candidate(words = ['multiple', 'multip', 'multi', 'mult', 'mult'],s = \"multiple\") == 5\n assert candidate(words = ['word', 'words', 'wording'],s = \"word\") == 1\n assert candidate(words = ['prefix', 'pre', 'p'],s = \"prefix\") == 3\n assert candidate(words = ['overlap', 'over', 'ov', 'o'],s = \"overlap\") == 4\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],s = \"aaaaaaaa\") == 5\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],s = \"aaaaa\") == 5\n assert candidate(words = ['short', 'shorter', 'shortest'],s = \"short\") == 1\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg'],s = \"abcdefgh\") == 7\n assert candidate(words = ['short', 'shot', 'sh', 's'],s = \"shortstory\") == 3\n assert candidate(words = ['abcd', 'abc', 'ab', 'a'],s = \"a\") == 1\n assert candidate(words = ['longword', 'long', 'lo', 'l', 'lon', 'longw'],s = \"longword\") == 6\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],s = \"abcde\") == 1\n assert candidate(words = ['prefix', 'pre', 'p'],s = \"prefix\") == 3\n assert candidate(words = ['prefix', 'pre', 'pref', 'prefi', 'prefixe'],s = \"prefix\") == 4\n assert candidate(words = ['aaa', 'aa', 'a'],s = \"aaaaa\") == 3\n assert candidate(words = ['word', 'wording', 'worded', 'wordingword'],s = \"wordingword\") == 3\n assert candidate(words = ['test', 'testing', 'testi', 'testin'],s = \"testingstring\") == 4\n assert candidate(words = ['one', 'two', 'three', 'four'],s = \"one\") == 1\n assert candidate(words = ['different', 'diff', 'diffe', 'differen', 'differen'],s = \"different\") == 5\n assert candidate(words = ['unique', 'uniq', 'un', 'u'],s = \"unique\") == 4\n assert candidate(words = ['aaa', 'aa', 'a', 'aaaa'],s = \"aaa\") == 3\n assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg'],s = \"abcd\") == 1\n assert candidate(words = ['not', 'no', 'n'],s = \"note\") == 3\n assert candidate(words = ['same', 'same', 'same', 'same'],s = \"same\") == 4\n assert candidate(words = ['test', 'testing', 'tea', 'te'],s = \"testing\") == 3\n assert candidate(words = ['longword', 'long', 'lo', 'l'],s = \"longwordexample\") == 4\n assert candidate(words = ['begin', 'beg', 'be', 'b'],s = \"beginning\") == 4\n assert candidate(words = ['overlap', 'over', 'o'],s = \"overlap\") == 3\n assert candidate(words = ['test', 'testing', 'tes', 't'],s = \"testing\") == 4\n assert candidate(words = ['xy', 'xyz', 'xyzz'],s = \"xy\") == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],s = \"fives\") == 1\n assert candidate(words = ['longword', 'long', 'lo', 'l'],s = \"longword\") == 4\n assert candidate(words = ['example', 'ex', 'exa', 'exam', 'examp'],s = \"example\") == 5\n assert candidate(words = ['one', 'two', 'three'],s = \"onetwothree\") == 1\n assert candidate(words = ['abc', 'abcd', 'abcde'],s = \"abcdef\") == 3\n assert candidate(words = ['multiple', 'multi', 'mul', 'mu'],s = \"multiples\") == 4\n assert candidate(words = ['word', 'wor', 'wo', 'w'],s = \"word\") == 4\n assert candidate(words = ['banana', 'ban', 'ba', 'b'],s = \"bananarama\") == 4\n assert candidate(words = ['abcd', 'abc', 'ab', 'a'],s = \"abcd\") == 4\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa'],s = \"aaaa\") == 4\n assert candidate(words = ['prefix', 'pre', 'prefixx', 'prefixxx', 'prefixxxx'],s = \"prefixx\") == 3\n assert candidate(words = ['quick', 'qui', 'quic', 'quicks', 'quickb'],s = \"quickbrownfox\") == 4\n assert candidate(words = ['test', 'testing', 'tested'],s = \"testing\") == 2\n assert candidate(words = ['one', 'onetwo', 'onetwothree'],s = \"onetwothree\") == 3\n assert candidate(words = ['programming', 'prog', 'pro'],s = \"programming\") == 3\n assert candidate(words = ['part', 'partial', 'partially'],s = \"partially\") == 3\n assert candidate(words = ['aaa', 'aa', 'a', 'aaaa'],s = \"aaaa\") == 4\n assert candidate(words = ['one', 'two', 'three', 'four'],s = \"one\") == 1\n assert candidate(words = ['prefix', 'pre', 'prex', 'abc'],s = \"prefix\") == 2\n assert candidate(words = ['abc', 'abcd', 'abcde'],s = \"abcdefg\") == 3\n assert candidate(words = ['repeat', 'repe', 'rep', 're', 'r'],s = \"repeat\") == 5\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde'],s = \"a\") == 1\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],s = \"aaaaaa\") == 5\n assert candidate(words = ['complex', 'comp', 'com', 'co', 'c'],s = \"complexity\") == 5\n assert candidate(words = ['python', 'pyth', 'py'],s = \"python\") == 3\n assert candidate(words = ['xyz', 'xy', 'x'],s = \"xy\") == 2\n assert candidate(words = ['xyz', 'xy', 'x', ''],s = \"xyz\") == 4\n assert candidate(words = ['complex', 'com', 'co', 'c'],s = \"complex\") == 4\n assert candidate(words = ['prefix', 'prefixx', 'prefixxx', 'prefixxxx'],s = \"prefix\") == 1\n assert candidate(words = ['abc', 'abcd', 'abcde'],s = \"abcdefg\") == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'abc'],s = \"abcdefghi\") == 2\n assert candidate(words = ['cat', 'cattle', 'cattleman'],s = \"cattleman\") == 3\n assert candidate(words = ['xyz', 'xy', 'x'],s = \"xyz\") == 3\n assert candidate(words = ['same', 'same', 'same'],s = \"same\") == 3\n assert candidate(words = ['prefix', 'pre', 'pref'],s = \"prefix\") == 3\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef'],s = \"fghijkl\") == 0\n assert candidate(words = ['small', 'smaller', 'smallest', 'smallerest'],s = \"smallerest\") == 3\n assert candidate(words = ['substring', 'subs', 'sub', 'su'],s = \"substringexample\") == 4\n assert candidate(words = ['abc', 'abcd', 'abcde', 'abcdef'],s = \"abcdefg\") == 4\n assert candidate(words = ['test', 'testing', 'testi'],s = \"test\") == 1\n assert candidate(words = ['zz', 'zzz', 'zzzz'],s = \"zzzz\") == 3\n assert candidate(words = ['hello', 'he', 'hell'],s = \"hello\") == 3\n assert candidate(words = ['prefix', 'pre', 'pref', 'prex'],s = \"prefix\") == 3\n assert candidate(words = ['z', 'zz', 'zzz', 'zzzz'],s = \"zzzzzz\") == 4\n assert candidate(words = ['unique', 'uniq', 'uni', 'un', 'u'],s = \"unique\") == 5\n assert candidate(words = ['cat', 'dog', 'car', 'catch', 'cart'],s = \"catch\") == 2\n assert candidate(words = ['consistent', 'consist', 'consi', 'cons'],s = \"consistency\") == 3\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],s = \"abcdefghij\") == 1\n assert candidate(words = ['unique', 'uniq', 'uni', 'un'],s = \"uniques\") == 4\n assert candidate(words = ['hello', 'world', 'hel', 'wo', 'wor'],s = \"helloworld\") == 2\n assert candidate(words = ['overlap', 'over', 'ov', 'overlaplap'],s = \"overlap\") == 3\n assert candidate(words = ['matching', 'match', 'mat', 'ma', 'm'],s = \"matching\") == 5\n assert candidate(words = ['hello', 'hell', 'he', 'h', 'hellohello'],s = \"hellohello\") == 5\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa'],s = \"aaaaaaaaa\") == 4\n assert candidate(words = ['test', 'testing', 'testing123'],s = \"test\") == 1\n assert candidate(words = ['match', 'mat', 'ma', 'm'],s = \"match\") == 4\n assert candidate(words = ['example', 'exa', 'ex', 'e'],s = \"example\") == 4\n assert candidate(words = ['hello', 'hell', 'he', 'h'],s = \"hello\") == 4\n assert candidate(words = ['word', 'wording', 'wordings'],s = \"word\") == 1\n assert candidate(words = ['prefix', 'pre', 'p', 'programming'],s = \"prefix\") == 3\n assert candidate(words = ['a', 'ab', 'abc', 'abcd'],s = \"abcde\") == 4\n assert candidate(words = ['unique', 'uniqueness', 'uni', 'un'],s = \"uniqueness\") == 4\n assert candidate(words = ['one', 'on', 'o', 'ones'],s = \"one\") == 3\n assert candidate(words = ['word', 'wo', 'w'],s = \"word\") == 3\n assert candidate(words = ['prefix', 'pre', 'pr', 'p'],s = \"prefix\") == 4\n assert candidate(words = ['example', 'exam', 'ex', 'e'],s = \"examples\") == 4\n assert candidate(words = ['common', 'commo', 'comm', 'com', 'co', 'c'],s = \"common\") == 6\n"}, "metadata": {"canonical_parameter_names": ["words", "s"], "leetcode_dataset_entry_point": "Solution().countPrefixes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countPrefixes(String[] words, String s) {", "container": "Solution", "callable": "countPrefixes", "parameters": [{"name": "words", "type": "String[]"}, {"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2256, "task_id": "minimum-average-difference", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of length n.\nThe average difference of the index i is the absolute difference between the average of the first i + 1 elements of nums and the average of the last n - i - 1 elements. Both averages should be rounded down to the nearest integer.\nReturn the index with the minimum average difference. If there are multiple such indices, return the smallest one.\nNote:\n\nThe absolute difference of two numbers is the absolute value of their difference.\nThe average of n elements is the sum of the n elements divided (integer division) by n.\nThe average of 0 elements is considered to be 0.\n\n \nExample 1:\n\nInput: nums = [2,5,3,9,5,3]\nOutput: 3\nExplanation:\n- The average difference of index 0 is: |2 / 1 - (5 + 3 + 9 + 5 + 3) / 5| = |2 / 1 - 25 / 5| = |2 - 5| = 3.\n- The average difference of index 1 is: |(2 + 5) / 2 - (3 + 9 + 5 + 3) / 4| = |7 / 2 - 20 / 4| = |3 - 5| = 2.\n- The average difference of index 2 is: |(2 + 5 + 3) / 3 - (9 + 5 + 3) / 3| = |10 / 3 - 17 / 3| = |3 - 5| = 2.\n- The average difference of index 3 is: |(2 + 5 + 3 + 9) / 4 - (5 + 3) / 2| = |19 / 4 - 8 / 2| = |4 - 4| = 0.\n- The average difference of index 4 is: |(2 + 5 + 3 + 9 + 5) / 5 - 3 / 1| = |24 / 5 - 3 / 1| = |4 - 3| = 1.\n- The average difference of index 5 is: |(2 + 5 + 3 + 9 + 5 + 3) / 6 - 0| = |27 / 6 - 0| = |4 - 0| = 4.\nThe average difference of index 3 is the minimum average difference so return 3.\n\nExample 2:\n\nInput: nums = [0]\nOutput: 0\nExplanation:\nThe only index is 0 so return 0.\nThe average difference of index 0 is: |0 / 1 - 0| = |0 - 0| = 0.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 1\n assert candidate(nums = [100000, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [0, 1, 0, 1, 0]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(nums = [1, 0, 0, 0, 0]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [2, 5, 3, 9, 5, 3]) == 3\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 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]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 0\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 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, 1]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 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]) == 0\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16]) == 1\n assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 0\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 0\n assert candidate(nums = [100000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 90000, 9000, 900, 90]) == 5\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 0\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0]) == 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]) == 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]) == 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]) == 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, 0]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 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]) == 0\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14]) == 19\n assert candidate(nums = [100000, 0, 50000, 50000, 25000, 25000, 75000, 25000, 0, 100000]) == 4\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 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, 100000]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 0\n assert candidate(nums = [5, 3, 8, 1, 4, 2, 7, 6, 9, 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, 1]) == 0\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, 0]) == 1\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 0]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 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]) == 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]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 3\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 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]) == 0\n assert candidate(nums = [0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000]) == 1\n assert candidate(nums = [5, 2, 9, 1, 5, 6]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 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]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 0, 4, 5, 0, 6, 3, 7, 2, 8, 1, 9]) == 9\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, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\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]) == 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]) == 0\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 0, 0, 0, 0, 0]) == 9\n assert candidate(nums = [7, 3, 8, 5, 2, 6, 4, 9, 1, 10]) == 1\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(nums = [100000, 0, 100000, 0, 100000, 0]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 14\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumAverageDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumAverageDifference(int[] nums) {", "container": "Solution", "callable": "minimumAverageDifference", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2257, "task_id": "count-unguarded-cells-in-the-grid", "difficulty": "Medium", "problem_description": "You are given two integers m and n representing a 0-indexed m x n grid. You are also given two 2D integer arrays guards and walls where guards[i] = [rowi, coli] and walls[j] = [rowj, colj] represent the positions of the ith guard and jth wall respectively.\nA guard can see every cell in the four cardinal directions (north, east, south, or west) starting from their position unless obstructed by a wall or another guard. A cell is guarded if there is at least one guard that can see it.\nReturn the number of unoccupied cells that are not guarded.\n \nExample 1:\n\n\nInput: m = 4, n = 6, guards = [[0,0],[1,1],[2,3]], walls = [[0,1],[2,2],[1,4]]\nOutput: 7\nExplanation: The guarded and unguarded cells are shown in red and green respectively in the above diagram.\nThere are a total of 7 unguarded cells, so we return 7.\n\nExample 2:\n\n\nInput: m = 3, n = 3, guards = [[1,1]], walls = [[0,1],[1,0],[2,1],[1,2]]\nOutput: 4\nExplanation: The unguarded cells are shown in green in the above diagram.\nThere are a total of 4 unguarded cells, so we return 4.\n\n \nConstraints:\n\n1 <= m, n <= 105\n2 <= m * n <= 105\n1 <= guards.length, walls.length <= 5 * 104\n2 <= guards.length + walls.length <= m * n\nguards[i].length == walls[j].length == 2\n0 <= rowi, rowj < m\n0 <= coli, colj < n\nAll the positions in guards and walls are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 4,n = 6,guards = [[0, 0], [1, 1], [2, 3]],walls = [[0, 1], [2, 2], [1, 4]]) == 7\n assert candidate(m = 3,n = 3,guards = [[1, 1]],walls = [[0, 1], [1, 0], [2, 1], [1, 2]]) == 4\n assert candidate(m = 5,n = 5,guards = [[2, 2]],walls = [[0, 0], [4, 4]]) == 14\n assert candidate(m = 10,n = 10,guards = [[3, 3], [6, 6]],walls = [[1, 1], [8, 8]]) == 62\n assert candidate(m = 6,n = 6,guards = [[1, 1], [4, 4]],walls = [[2, 2], [3, 3]]) == 14\n assert candidate(m = 12,n = 12,guards = [[1, 1], [5, 5], [9, 9]],walls = [[2, 2], [6, 6], [10, 10], [3, 3], [7, 7], [11, 11]]) == 75\n assert candidate(m = 10,n = 10,guards = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1], [2, 2]],walls = [[1, 1]]) == 49\n assert candidate(m = 10,n = 5,guards = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2]],walls = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 4]]) == 1\n assert candidate(m = 20,n = 10,guards = [[5, 2], [10, 7], [15, 3], [18, 8]],walls = [[0, 5], [4, 9], [9, 4], [14, 8], [19, 3], [7, 0]]) == 104\n assert candidate(m = 15,n = 20,guards = [[2, 5], [4, 8], [10, 15]],walls = [[3, 3], [6, 7], [9, 12], [11, 14]]) == 200\n assert candidate(m = 20,n = 20,guards = [[0, 0], [19, 19], [0, 19], [19, 0]],walls = [[5, 5], [15, 15], [10, 10], [14, 14], [9, 9], [11, 11]]) == 318\n assert candidate(m = 10,n = 10,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],walls = [[0, 0], [6, 6], [7, 7], [8, 8], [9, 9]]) == 20\n assert candidate(m = 15,n = 20,guards = [[2, 2], [5, 5], [8, 8]],walls = [[3, 3], [7, 7], [11, 11], [13, 13]]) == 200\n assert candidate(m = 45,n = 45,guards = [[10, 10], [20, 20], [30, 30], [40, 40]],walls = [[12, 12], [18, 18], [22, 22], [28, 28], [32, 32], [38, 38]]) == 1675\n assert candidate(m = 18,n = 18,guards = [[9, 9], [10, 10], [11, 11], [12, 12], [13, 13]],walls = [[0, 0], [17, 17], [1, 1], [16, 16], [8, 8], [9, 9]]) == 164\n assert candidate(m = 20,n = 20,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],walls = [[6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 220\n assert candidate(m = 15,n = 15,guards = [[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]],walls = [[0, 7], [7, 0], [7, 7], [7, 14], [14, 7]]) == 3\n assert candidate(m = 6,n = 9,guards = [[1, 1], [1, 8], [4, 4], [5, 5]],walls = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 6], [5, 7], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [0, 8]]) == 8\n assert candidate(m = 12,n = 12,guards = [[2, 2], [2, 9], [9, 2], [9, 9], [5, 5]],walls = [[3, 3], [3, 8], [8, 3], [8, 8], [6, 6]]) == 76\n assert candidate(m = 12,n = 8,guards = [[2, 1], [5, 3], [8, 5]],walls = [[1, 2], [4, 4], [7, 6], [10, 7]]) == 41\n assert candidate(m = 9,n = 9,guards = [[1, 1], [1, 7], [7, 1], [7, 7]],walls = [[2, 2], [2, 6], [6, 2], [6, 6], [3, 3], [3, 5], [5, 3], [5, 5]]) == 41\n assert candidate(m = 100,n = 100,guards = [[25, 25], [50, 50], [75, 75]],walls = [[10, 10], [20, 20], [30, 30], [40, 40], [55, 55], [60, 60], [65, 65], [70, 70], [80, 80], [90, 90]]) == 9399\n assert candidate(m = 25,n = 25,guards = [[12, 12], [13, 13], [14, 14]],walls = [[0, 0], [24, 24], [5, 5], [20, 20], [10, 10], [15, 15]]) == 478\n assert candidate(m = 11,n = 7,guards = [[3, 1], [6, 4], [8, 6]],walls = [[1, 0], [2, 3], [4, 5], [5, 6], [7, 2]]) == 32\n assert candidate(m = 10,n = 10,guards = [[3, 3], [3, 6], [6, 3], [6, 6]],walls = [[2, 2], [2, 7], [7, 2], [7, 7], [4, 4], [4, 5], [5, 4], [5, 5]]) == 56\n assert candidate(m = 8,n = 12,guards = [[1, 5], [4, 7], [6, 3]],walls = [[0, 3], [3, 5], [5, 8], [7, 10]]) == 45\n assert candidate(m = 8,n = 8,guards = [[2, 2], [3, 3], [4, 4]],walls = [[1, 1], [5, 5], [6, 6], [7, 7], [0, 0], [1, 6], [6, 1], [5, 7], [7, 5]]) == 16\n assert candidate(m = 16,n = 16,guards = [[8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]],walls = [[0, 0], [1, 1], [15, 15], [14, 14], [7, 7], [6, 6]]) == 94\n assert candidate(m = 8,n = 8,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],walls = [[0, 0], [7, 7], [3, 3], [5, 5], [2, 2]]) == 0\n assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[0, 0], [19, 19], [9, 9], [14, 14], [15, 5], [5, 15], [10, 0], [10, 19]]) == 303\n assert candidate(m = 8,n = 8,guards = [[1, 1], [1, 6], [6, 1], [6, 6]],walls = [[2, 3], [2, 5], [5, 2], [5, 5]]) == 32\n assert candidate(m = 7,n = 7,guards = [[1, 1], [1, 5], [5, 1], [5, 5]],walls = [[0, 3], [3, 0], [3, 6], [6, 3]]) == 21\n assert candidate(m = 10,n = 5,guards = [[0, 0], [0, 4], [5, 0], [5, 4]],walls = [[1, 2], [2, 2], [3, 2], [4, 2], [6, 2], [7, 2], [8, 2], [9, 2]]) == 16\n assert candidate(m = 70,n = 70,guards = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60]],walls = [[15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65]]) == 4090\n assert candidate(m = 10,n = 10,guards = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],walls = [[1, 1], [1, 9], [9, 1], [9, 9], [0, 0], [0, 9], [9, 0], [5, 1], [5, 9]]) == 3\n assert candidate(m = 5,n = 10,guards = [[0, 0], [0, 9], [4, 0], [4, 9]],walls = [[2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8]]) == 16\n assert candidate(m = 10,n = 10,guards = [[0, 0], [0, 9], [9, 0], [9, 9]],walls = [[2, 2], [2, 7], [7, 2], [7, 7]]) == 60\n assert candidate(m = 7,n = 7,guards = [[1, 1], [1, 5], [5, 1], [5, 5]],walls = [[2, 2], [2, 5], [5, 2], [5, 5], [3, 3]]) == 23\n assert candidate(m = 8,n = 8,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],walls = [[0, 0], [7, 7], [0, 7], [7, 0]]) == 5\n assert candidate(m = 10,n = 10,guards = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],walls = [[1, 1], [8, 8], [9, 9], [0, 0]]) == 12\n assert candidate(m = 7,n = 7,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],walls = [[0, 0], [1, 2], [2, 4], [3, 5], [4, 6], [5, 0], [6, 1], [6, 6]]) == 11\n assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[2, 2], [7, 7], [12, 12], [17, 17]]) == 285\n assert candidate(m = 100,n = 100,guards = [[10, 10], [40, 50], [70, 80]],walls = [[15, 15], [30, 30], [60, 60], [85, 85]]) == 9405\n assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[0, 0], [19, 19], [5, 10], [10, 15], [15, 5], [5, 15], [10, 5]]) == 331\n assert candidate(m = 15,n = 15,guards = [[2, 2], [7, 7], [12, 12]],walls = [[3, 3], [4, 4], [5, 5], [6, 6], [8, 8], [9, 9], [10, 10], [11, 11], [13, 13], [14, 14]]) == 134\n assert candidate(m = 18,n = 10,guards = [[3, 3], [7, 3], [11, 3], [3, 7], [7, 7], [11, 7]],walls = [[2, 2], [2, 8], [8, 2], [8, 8], [5, 5]]) == 115\n assert candidate(m = 10,n = 5,guards = [[2, 1], [7, 3]],walls = [[1, 1], [1, 3], [3, 1], [3, 3], [5, 1], [5, 3], [8, 1], [8, 3]]) == 31\n assert candidate(m = 15,n = 15,guards = [[2, 2], [5, 5], [8, 8]],walls = [[3, 3], [6, 6], [9, 9], [4, 4], [7, 7], [10, 10]]) == 138\n assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[2, 2], [4, 4], [6, 6], [8, 8], [12, 12], [14, 14], [16, 16], [18, 18]]) == 281\n assert candidate(m = 7,n = 7,guards = [[0, 0], [0, 6], [6, 0], [6, 6], [3, 3]],walls = [[1, 1], [1, 5], [5, 1], [5, 5], [2, 2], [2, 4], [4, 2], [4, 4]]) == 8\n assert candidate(m = 8,n = 8,guards = [[1, 1], [1, 7], [7, 1], [7, 7], [3, 3], [3, 4], [4, 3], [4, 4]],walls = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7]]) == 12\n assert candidate(m = 7,n = 7,guards = [[1, 3], [2, 4], [3, 5], [4, 1], [5, 2], [6, 3]],walls = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [5, 6], [4, 6], [3, 6], [2, 6], [1, 6]]) == 0\n assert candidate(m = 12,n = 10,guards = [[2, 2], [2, 3], [3, 2], [3, 3], [5, 5], [6, 6], [7, 7], [8, 8]],walls = [[1, 1], [1, 2], [1, 3], [1, 4], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 9]]) == 30\n assert candidate(m = 12,n = 12,guards = [[3, 3], [6, 6], [9, 9]],walls = [[2, 2], [4, 4], [5, 5], [7, 7], [8, 8], [10, 10], [11, 11], [0, 0], [1, 1]]) == 72\n assert candidate(m = 14,n = 14,guards = [[2, 2], [2, 11], [11, 2], [11, 11]],walls = [[3, 3], [3, 10], [10, 3], [10, 10], [5, 5], [5, 8], [8, 5], [8, 8]]) == 136\n assert candidate(m = 12,n = 12,guards = [[6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],walls = [[0, 0], [11, 11], [10, 10], [9, 9], [8, 8]]) == 31\n assert candidate(m = 10,n = 10,guards = [[1, 1], [1, 8], [8, 1], [8, 8], [4, 4]],walls = [[0, 0], [0, 9], [9, 0], [9, 9], [2, 2], [2, 7], [7, 2], [7, 7]]) == 41\n assert candidate(m = 9,n = 9,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],walls = [[4, 3], [4, 5], [5, 4], [3, 4]]) == 14\n assert candidate(m = 15,n = 15,guards = [[2, 3], [4, 5], [6, 7]],walls = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 139\n assert candidate(m = 80,n = 80,guards = [[10, 10], [30, 30], [50, 50], [70, 70]],walls = [[15, 15], [35, 35], [55, 55], [75, 75]]) == 5772\n assert candidate(m = 6,n = 6,guards = [[1, 1], [1, 4], [4, 1], [4, 4]],walls = [[0, 0], [0, 5], [5, 0], [5, 5], [2, 2], [3, 3]]) == 10\n assert candidate(m = 8,n = 8,guards = [[1, 1], [2, 2], [3, 3], [4, 4]],walls = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == 30\n assert candidate(m = 25,n = 15,guards = [[3, 4], [8, 9], [13, 14], [18, 1], [23, 6]],walls = [[2, 5], [7, 10], [12, 13], [17, 2], [22, 7]]) == 195\n assert candidate(m = 15,n = 20,guards = [[5, 5], [7, 7], [10, 10]],walls = [[3, 3], [12, 12], [8, 8], [6, 6]]) == 200\n assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[2, 2], [3, 3], [4, 4], [6, 6], [7, 7], [8, 8], [9, 9], [11, 11], [12, 12], [13, 13], [14, 14], [16, 16], [17, 17], [18, 18], [19, 19]]) == 274\n assert candidate(m = 50,n = 50,guards = [[10, 10], [20, 20], [30, 30], [40, 40]],walls = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45]]) == 2111\n assert candidate(m = 8,n = 5,guards = [[1, 1], [1, 3], [3, 1], [3, 3]],walls = [[0, 0], [0, 4], [4, 0], [4, 4], [2, 2]]) == 13\n assert candidate(m = 50,n = 50,guards = [[25, 25], [25, 26], [24, 25]],walls = [[24, 24], [24, 26], [26, 25], [26, 26]]) == 2421\n assert candidate(m = 15,n = 20,guards = [[2, 2], [5, 5], [7, 7], [10, 10]],walls = [[1, 1], [3, 3], [8, 8], [12, 12], [14, 19]]) == 171\n assert candidate(m = 5,n = 10,guards = [[1, 2], [3, 7]],walls = [[1, 1], [1, 3], [2, 1], [2, 3], [3, 1], [3, 3], [4, 1], [4, 3], [1, 8], [1, 9], [2, 8], [2, 9], [3, 8], [3, 9], [4, 8], [4, 9]]) == 21\n assert candidate(m = 7,n = 7,guards = [[1, 1], [5, 5]],walls = [[2, 2], [2, 3], [2, 4], [3, 2], [3, 4], [4, 2], [4, 3], [4, 4]]) == 17\n assert candidate(m = 30,n = 30,guards = [[1, 1], [2, 2], [3, 3], [4, 4]],walls = [[5, 5], [6, 6], [7, 7], [8, 8]]) == 672\n assert candidate(m = 15,n = 15,guards = [[3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13]],walls = [[1, 1], [2, 2], [4, 4], [6, 6], [8, 8], [10, 10], [12, 12], [14, 14]]) == 73\n assert candidate(m = 10,n = 10,guards = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],walls = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 28\n assert candidate(m = 12,n = 12,guards = [[3, 3], [4, 4], [5, 5], [6, 6]],walls = [[1, 1], [2, 2], [7, 7], [8, 8], [9, 9], [10, 10]]) == 58\n assert candidate(m = 6,n = 6,guards = [[0, 0], [5, 5]],walls = [[1, 1], [1, 4], [2, 2], [2, 3], [3, 2], [3, 3], [4, 1], [4, 4]]) == 8\n assert candidate(m = 9,n = 9,guards = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],walls = [[0, 0], [8, 8], [1, 1], [7, 7], [2, 2], [3, 3]]) == 12\n assert candidate(m = 15,n = 15,guards = [[2, 2], [7, 7], [12, 12]],walls = [[0, 0], [5, 5], [10, 10], [14, 14]]) == 140\n assert candidate(m = 15,n = 15,guards = [[2, 2], [5, 5], [8, 8], [11, 11]],walls = [[3, 3], [6, 6], [9, 9], [12, 12], [0, 0], [14, 14]]) == 115\n assert candidate(m = 15,n = 10,guards = [[5, 5], [10, 5], [14, 5]],walls = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [11, 5], [12, 5], [13, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 99\n assert candidate(m = 7,n = 11,guards = [[1, 3], [4, 6], [6, 8]],walls = [[0, 1], [2, 4], [3, 5], [5, 7], [6, 9]]) == 29\n assert candidate(m = 10,n = 10,guards = [[1, 2], [2, 1], [3, 3], [6, 6], [8, 8]],walls = [[0, 0], [4, 4], [5, 5], [9, 9]]) == 21\n assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[3, 3], [4, 4], [6, 6], [7, 7], [9, 9], [11, 11], [13, 13], [14, 14], [16, 16], [17, 17], [19, 19]]) == 278\n"}, "metadata": {"canonical_parameter_names": ["m", "n", "guards", "walls"], "leetcode_dataset_entry_point": "Solution().countUnguarded", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countUnguarded(int m, int n, int[][] guards, int[][] walls) {", "container": "Solution", "callable": "countUnguarded", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "guards", "type": "int[][]"}, {"name": "walls", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2258, "task_id": "escape-the-spreading-fire", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array grid of size m x n which represents a field. Each cell has one of three values:\n\n0 represents grass,\n1 represents fire,\n2 represents a wall that you and fire cannot pass through.\n\nYou are situated in the top-left cell, (0, 0), and you want to travel to the safehouse at the bottom-right cell, (m - 1, n - 1). Every minute, you may move to an adjacent grass cell. After your move, every fire cell will spread to all adjacent cells that are not walls.\nReturn the maximum number of minutes that you can stay in your initial position before moving while still safely reaching the safehouse. If this is impossible, return -1. If you can always reach the safehouse regardless of the minutes stayed, return 109.\nNote that even if the fire spreads to the safehouse immediately after you have reached it, it will be counted as safely reaching the safehouse.\nA cell is adjacent to another cell if the former is directly north, east, south, or west of the latter (i.e., their sides are touching).\n \nExample 1:\n\n\nInput: grid = [[0,2,0,0,0,0,0],[0,0,0,2,2,1,0],[0,2,0,0,1,2,0],[0,0,2,2,2,0,2],[0,0,0,0,0,0,0]]\nOutput: 3\nExplanation: The figure above shows the scenario where you stay in the initial position for 3 minutes.\nYou will still be able to safely reach the safehouse.\nStaying for more than 3 minutes will not allow you to safely reach the safehouse.\nExample 2:\n\n\nInput: grid = [[0,0,0,0],[0,1,2,0],[0,2,0,0]]\nOutput: -1\nExplanation: The figure above shows the scenario where you immediately move towards the safehouse.\nFire will spread to any cell you move towards and it is impossible to safely reach the safehouse.\nThus, -1 is returned.\n\nExample 3:\n\n\nInput: grid = [[0,0,0],[2,2,0],[1,2,0]]\nOutput: 1000000000\nExplanation: The figure above shows the initial grid.\nNotice that the fire is contained by walls and you will always be able to safely reach the safehouse.\nThus, 109 is returned.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n2 <= m, n <= 300\n4 <= m * n <= 2 * 104\ngrid[i][j] is either 0, 1, or 2.\ngrid[0][0] == grid[m - 1][n - 1] == 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 2, 0], [0, 2, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 0, 0, 2, 0], [0, 2, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 2, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 2, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 2, 0, 2, 0], [0, 0, 0, 2, 0], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[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]]) == -1\n assert candidate(grid = [[0, 0, 0, 2, 1, 0], [0, 2, 0, 0, 0, 0], [0, 0, 2, 2, 0, 0], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 1], [0, 2, 2, 0], [0, 2, 2, 0], [0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 1], [0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 1000000000\n assert candidate(grid = [[0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 2, 2, 1, 0], [0, 2, 0, 0, 1, 2, 0], [0, 0, 2, 2, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 2, 2, 1, 0], [0, 2, 0, 0, 0, 2, 0], [0, 0, 2, 2, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 2, 2, 2, 0], [0, 2, 0, 2, 0], [0, 2, 2, 2, 0], [0, 0, 0, 0, 0]]) == 1000000000\n assert candidate(grid = [[0, 0, 0], [2, 2, 0], [1, 2, 0]]) == 1000000000\n assert candidate(grid = [[0, 0, 2, 0, 0, 0, 0], [0, 1, 1, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0], [0, 1, 1, 1, 0, 2, 0], [0, 0, 2, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0], [0, 1, 0, 2, 1, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 2, 0, 0], [0, 0, 0, 1, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 1, 2, 0, 1, 2, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 1, 0, 2, 0, 2, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2, 1, 2, 0, 1, 2, 1, 0, 1, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 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, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\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, 2, 0, 0, 0, 0], [0, 0, 0, 2, 1, 2, 0, 0, 0], [0, 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]]) == 1000000000\n assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 1, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2], [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, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 2], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 0, 1, 2, 1, 2, 0, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 1, 0], [2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 1, 0, 0]]) == -1\n assert candidate(grid = [[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, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 0, 1, 2, 1, 2, 1, 0, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 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, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 2, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 2, 2, 1, 0], [0, 2, 0, 0, 1, 2, 0], [0, 0, 2, 2, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 1, 0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 2, 0, 1, 0, 0], [0, 0, 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, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 2, 0, 2, 1, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 1, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[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]]) == -1\n assert candidate(grid = [[0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 2, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 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]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 2, 0, 2, 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, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0], [0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 2, 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\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 2, 2, 0, 0], [0, 0, 2, 2, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 2, 0, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 1, 2, 0, 0, 2, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[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, 1, 0, 0, 0, 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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 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(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 2, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\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, 2, 2, 2, 0, 0], [0, 0, 0, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 2, 2, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 2], [0, 1, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 2, 0, 1, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 2, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 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]]) == -1\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, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 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, 1, 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(grid = [[0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 1, 2, 0, 2, 1, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 2, 0, 0], [0, 0, 1, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 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]]) == -1\n assert candidate(grid = [[0, 0, 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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 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\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 2, 2, 2, 0, 0, 0], [0, 1, 1, 1, 2, 0, 2, 1, 1, 0], [0, 0, 0, 0, 2, 2, 2, 0, 0, 0], [0, 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, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 1, 2, 2, 2, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 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, 0, 0]]) == 1000000000\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [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, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [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, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [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]]) == -1\n assert candidate(grid = [[0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 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, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 2, 0, 0, 0, 0], [0, 0, 0, 2, 2, 0, 1, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 2, 2, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 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], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 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(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [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, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [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, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 2, 1, 2, 0], [0, 0, 1, 0, 0, 0], [0, 2, 0, 2, 1, 0], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 0, 2, 1, 0], [0, 1, 2, 0, 1, 0, 2, 1, 0], [0, 1, 2, 0, 0, 0, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 1, 0], [0, 0, 0, 0, 2, 2, 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]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 1, 0, 0, 0, 1, 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]]) == -1\n assert candidate(grid = [[0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 2, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 2, 1, 0, 2, 1, 0, 2, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 2, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 2, 1, 0, 2, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\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], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 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\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 0, 2, 0], [0, 0, 0, 0, 1, 0, 0], [0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\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, 2, 0, 2, 0, 2, 0, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 2, 1, 0, 0, 2, 0], [0, 0, 0, 0, 2, 0, 0], [0, 2, 0, 0, 0, 2, 0], [0, 0, 0, 2, 0, 0, 0], [0, 2, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\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, 1, 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]]) == -1\n assert candidate(grid = [[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, 0], [0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == -1\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, 1, 2, 2, 2, 2, 2, 1, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 2, 2, 0, 2, 1, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 1, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 2, 2, 0, 0, 1, 0], [0, 2, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 2, 0, 2, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 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, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 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, 0, 0, 0, 0], [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(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, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 2, 2, 2, 2, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\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, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 2, 2, 2, 2, 2, 2, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 2, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 0, 1, 2, 1, 0, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 2, 0], [0, 2, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 0, 0, 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, 0, 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(grid = [[0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 2, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, 2, 0], [0, 2, 1, 0, 2, 1, 0, 2, 0, 2], [0, 0, 0, 2, 0, 0, 0, 0, 2, 0], [0, 1, 0, 0, 1, 0, 1, 2, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, 2, 0], [0, 2, 1, 0, 2, 1, 0, 2, 0, 2], [0, 0, 0, 2, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\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], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 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\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 0, 1, 2, 0, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 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, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 2, 0, 2, 1, 2], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 1, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [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, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [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]]) == -1\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maximumMinutes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumMinutes(int[][] grid) {", "container": "Solution", "callable": "maximumMinutes", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2259, "task_id": "remove-digit-from-number-to-maximize-result", "difficulty": "Easy", "problem_description": "You are given a string number representing a positive integer and a character digit.\nReturn the resulting string after removing exactly one occurrence of digit from number such that the value of the resulting string in decimal form is maximized. The test cases are generated such that digit occurs at least once in number.\n \nExample 1:\n\nInput: number = \"123\", digit = \"3\"\nOutput: \"12\"\nExplanation: There is only one '3' in \"123\". After removing '3', the result is \"12\".\n\nExample 2:\n\nInput: number = \"1231\", digit = \"1\"\nOutput: \"231\"\nExplanation: We can remove the first '1' to get \"231\" or remove the second '1' to get \"123\".\nSince 231 > 123, we return \"231\".\n\nExample 3:\n\nInput: number = \"551\", digit = \"5\"\nOutput: \"51\"\nExplanation: We can remove either the first or second '5' from \"551\".\nBoth result in the string \"51\".\n\n \nConstraints:\n\n2 <= number.length <= 100\nnumber consists of digits from '1' to '9'.\ndigit is a digit from '1' to '9'.\ndigit occurs at least once in number.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(number = \"222333\",digit = \"2\") == \"22333\"\n assert candidate(number = \"99999\",digit = \"9\") == \"9999\"\n assert candidate(number = \"999\",digit = \"9\") == \"99\"\n assert candidate(number = \"551\",digit = \"5\") == \"51\"\n assert candidate(number = \"10001\",digit = \"0\") == \"1001\"\n assert candidate(number = \"987654321\",digit = \"9\") == \"87654321\"\n assert candidate(number = \"123456789\",digit = \"5\") == \"12346789\"\n assert candidate(number = \"11111\",digit = \"1\") == \"1111\"\n assert candidate(number = \"123456789123456789\",digit = \"4\") == \"12356789123456789\"\n assert candidate(number = \"1000001\",digit = \"0\") == \"100001\"\n assert candidate(number = \"11211\",digit = \"1\") == \"1211\"\n assert candidate(number = \"123\",digit = \"3\") == \"12\"\n assert candidate(number = \"111111111\",digit = \"1\") == \"11111111\"\n assert candidate(number = \"1112\",digit = \"1\") == \"112\"\n assert candidate(number = \"999999999\",digit = \"9\") == \"99999999\"\n assert candidate(number = \"1231\",digit = \"1\") == \"231\"\n assert candidate(number = \"1221\",digit = \"1\") == \"221\"\n assert candidate(number = \"100000001\",digit = \"0\") == \"10000001\"\n assert candidate(number = \"87654321\",digit = \"8\") == \"7654321\"\n assert candidate(number = \"3141592653589793\",digit = \"1\") == \"341592653589793\"\n assert candidate(number = \"123456789\",digit = \"8\") == \"12345679\"\n assert candidate(number = \"987654321\",digit = \"2\") == \"98765431\"\n assert candidate(number = \"1221\",digit = \"2\") == \"121\"\n assert candidate(number = \"2222222\",digit = \"2\") == \"222222\"\n assert candidate(number = \"1111\",digit = \"1\") == \"111\"\n assert candidate(number = \"123456789\",digit = \"9\") == \"12345678\"\n assert candidate(number = \"5656565656\",digit = \"6\") == \"565656565\"\n assert candidate(number = \"987654321123456789\",digit = \"4\") == \"98765432112356789\"\n assert candidate(number = \"123123123123\",digit = \"2\") == \"13123123123\"\n assert candidate(number = \"10101010101010101010101010101010101010101010101010\",digit = \"1\") == \"1010101010101010101010101010101010101010101010100\"\n assert candidate(number = \"9898989898\",digit = \"8\") == \"998989898\"\n assert candidate(number = \"1122334455\",digit = \"1\") == \"122334455\"\n assert candidate(number = \"333333333\",digit = \"3\") == \"33333333\"\n assert candidate(number = \"1000000000\",digit = \"1\") == \"000000000\"\n assert candidate(number = \"9876543210\",digit = \"5\") == \"987643210\"\n assert candidate(number = \"12345654321\",digit = \"3\") == \"1245654321\"\n assert candidate(number = \"112233445566778899\",digit = \"5\") == \"11223344566778899\"\n assert candidate(number = \"100000000\",digit = \"0\") == \"10000000\"\n assert candidate(number = \"987987987\",digit = \"7\") == \"98987987\"\n assert candidate(number = \"101010101010\",digit = \"0\") == \"11010101010\"\n assert candidate(number = \"5959595959\",digit = \"9\") == \"595959595\"\n assert candidate(number = \"11223344556677889900\",digit = \"1\") == \"1223344556677889900\"\n assert candidate(number = \"987654321123456789987654321\",digit = \"3\") == \"98765432112456789987654321\"\n assert candidate(number = \"12345678901234567890\",digit = \"0\") == \"1234567891234567890\"\n assert candidate(number = \"122122122\",digit = \"2\") == \"12212212\"\n assert candidate(number = \"12345678901234567890\",digit = \"4\") == \"1235678901234567890\"\n assert candidate(number = \"123456789101112\",digit = \"1\") == \"23456789101112\"\n assert candidate(number = \"98765432109876543210\",digit = \"5\") == \"9876543210987643210\"\n assert candidate(number = \"11111111111111111111111111111111111111111111111111\",digit = \"1\") == \"1111111111111111111111111111111111111111111111111\"\n assert candidate(number = \"1919191919191919\",digit = \"9\") == \"191919191919191\"\n assert candidate(number = \"1000000001\",digit = \"0\") == \"100000001\"\n assert candidate(number = \"543219876\",digit = \"9\") == \"54321876\"\n assert candidate(number = \"56789101112131415161718192021\",digit = \"1\") == \"5678910112131415161718192021\"\n assert candidate(number = \"987654321987654321987654321987654321\",digit = \"8\") == \"98765432198765432198765432197654321\"\n assert candidate(number = \"123412341234\",digit = \"2\") == \"13412341234\"\n assert candidate(number = \"11223344556677889900\",digit = \"0\") == \"1122334455667788990\"\n assert candidate(number = \"12345678901234567890123456789012345678901234567890\",digit = \"0\") == \"1234567891234567890123456789012345678901234567890\"\n assert candidate(number = \"1919191919\",digit = \"9\") == \"191919191\"\n assert candidate(number = \"1919191919191919191919191919191919191919191919191\",digit = \"9\") == \"191919191919191919191919191919191919191919191911\"\n assert candidate(number = \"9999999999\",digit = \"9\") == \"999999999\"\n assert candidate(number = \"543219876987654321\",digit = \"9\") == \"54321987687654321\"\n assert candidate(number = \"987654321123456789\",digit = \"1\") == \"98765432123456789\"\n assert candidate(number = \"3131313131\",digit = \"1\") == \"331313131\"\n assert candidate(number = \"555555555555555555555\",digit = \"5\") == \"55555555555555555555\"\n assert candidate(number = \"123456789876543210987654321\",digit = \"9\") == \"12345678987654321087654321\"\n assert candidate(number = \"9999999999999999999\",digit = \"9\") == \"999999999999999999\"\n assert candidate(number = \"1212121212\",digit = \"2\") == \"121212121\"\n assert candidate(number = \"12345123451234512345\",digit = \"4\") == \"1235123451234512345\"\n assert candidate(number = \"91827364591827364591\",digit = \"1\") == \"9827364591827364591\"\n assert candidate(number = \"567567567\",digit = \"7\") == \"56756756\"\n assert candidate(number = \"999888777666555444333222111\",digit = \"9\") == \"99888777666555444333222111\"\n assert candidate(number = \"10000000001\",digit = \"0\") == \"1000000001\"\n assert candidate(number = \"876543210\",digit = \"0\") == \"87654321\"\n assert candidate(number = \"5645645645645645645645645645645645645645645645645\",digit = \"5\") == \"645645645645645645645645645645645645645645645645\"\n assert candidate(number = \"1234321\",digit = \"3\") == \"124321\"\n assert candidate(number = \"123456789123456789123456789\",digit = \"8\") == \"12345679123456789123456789\"\n assert candidate(number = \"123123123123123\",digit = \"1\") == \"23123123123123\"\n assert candidate(number = \"5656565656\",digit = \"5\") == \"656565656\"\n assert candidate(number = \"20202020202020202020202020202020202020202020202020\",digit = \"2\") == \"2020202020202020202020202020202020202020202020200\"\n assert candidate(number = \"2345678901234567890\",digit = \"0\") == \"234567891234567890\"\n assert candidate(number = \"918273645\",digit = \"9\") == \"18273645\"\n assert candidate(number = \"12233445566778899\",digit = \"9\") == \"1223344556677889\"\n assert candidate(number = \"5555555555555555555\",digit = \"5\") == \"555555555555555555\"\n assert candidate(number = \"101010101\",digit = \"0\") == \"11010101\"\n assert candidate(number = \"999999999999999999999\",digit = \"9\") == \"99999999999999999999\"\n assert candidate(number = \"8765432109876543210\",digit = \"5\") == \"876543210987643210\"\n assert candidate(number = \"33333333333333333333333333333333333333333333333333\",digit = \"3\") == \"3333333333333333333333333333333333333333333333333\"\n assert candidate(number = \"98765432109876543210\",digit = \"6\") == \"9876543210987543210\"\n assert candidate(number = \"100000000000000000000\",digit = \"0\") == \"10000000000000000000\"\n assert candidate(number = \"12345678901234567890\",digit = \"7\") == \"1234568901234567890\"\n assert candidate(number = \"3232323232323232\",digit = \"3\") == \"323232323232322\"\n assert candidate(number = \"123456789\",digit = \"2\") == \"13456789\"\n assert candidate(number = \"19191919191919191919\",digit = \"9\") == \"1919191919191919191\"\n assert candidate(number = \"123123123\",digit = \"1\") == \"23123123\"\n assert candidate(number = \"5645645645645645645645645645645645645645645645645\",digit = \"6\") == \"564564564564564564564564564564564564564564564545\"\n assert candidate(number = \"123987654321987654321987654321\",digit = \"9\") == \"12398765432198765432187654321\"\n assert candidate(number = \"1212121212121212121\",digit = \"2\") == \"121212121212121211\"\n assert candidate(number = \"123123123123123123123\",digit = \"3\") == \"12312312312312312312\"\n assert candidate(number = \"11111111111111111111\",digit = \"1\") == \"1111111111111111111\"\n assert candidate(number = \"112233445566778899\",digit = \"1\") == \"12233445566778899\"\n assert candidate(number = \"2222222222222222222222222222222\",digit = \"2\") == \"222222222222222222222222222222\"\n assert candidate(number = \"123987654321987654321987654321\",digit = \"1\") == \"23987654321987654321987654321\"\n assert candidate(number = \"987654321987654321\",digit = \"9\") == \"98765432187654321\"\n assert candidate(number = \"11111111111111111111111111111111111111111111\",digit = \"1\") == \"1111111111111111111111111111111111111111111\"\n assert candidate(number = \"9999999999999999999999999999999999999999999999999\",digit = \"9\") == \"999999999999999999999999999999999999999999999999\"\n assert candidate(number = \"111222333444555666777888999\",digit = \"3\") == \"11122233444555666777888999\"\n assert candidate(number = \"23333332\",digit = \"3\") == \"2333332\"\n assert candidate(number = \"22222222222222222222222222222222222222222222\",digit = \"2\") == \"2222222222222222222222222222222222222222222\"\n assert candidate(number = \"99999999991\",digit = \"9\") == \"9999999991\"\n assert candidate(number = \"333333\",digit = \"3\") == \"33333\"\n assert candidate(number = \"123456789123456789123456789\",digit = \"9\") == \"12345678912345678912345678\"\n assert candidate(number = \"123412341234\",digit = \"1\") == \"23412341234\"\n assert candidate(number = \"987654321123456789\",digit = \"9\") == \"98765432112345678\"\n assert candidate(number = \"543212345\",digit = \"2\") == \"54321345\"\n assert candidate(number = \"1111111111\",digit = \"1\") == \"111111111\"\n assert candidate(number = \"432143214321\",digit = \"2\") == \"43214321431\"\n assert candidate(number = \"12233445566778899\",digit = \"1\") == \"2233445566778899\"\n assert candidate(number = \"5555555555555555555555555555555555555555555555555\",digit = \"5\") == \"555555555555555555555555555555555555555555555555\"\n assert candidate(number = \"9876543210123456789\",digit = \"9\") == \"987654321012345678\"\n assert candidate(number = \"11112222\",digit = \"2\") == \"1111222\"\n assert candidate(number = \"31415926535\",digit = \"1\") == \"3415926535\"\n assert candidate(number = \"1234567890987654321\",digit = \"5\") == \"123467890987654321\"\n assert candidate(number = \"98877665544332211\",digit = \"8\") == \"9877665544332211\"\n assert candidate(number = \"1000000000\",digit = \"0\") == \"100000000\"\n assert candidate(number = \"2468135791113151719\",digit = \"1\") == \"246835791113151719\"\n assert candidate(number = \"12345678987654321\",digit = \"7\") == \"1234568987654321\"\n"}, "metadata": {"canonical_parameter_names": ["number", "digit"], "leetcode_dataset_entry_point": "Solution().removeDigit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String removeDigit(String number, char digit) {", "container": "Solution", "callable": "removeDigit", "parameters": [{"name": "number", "type": "String"}, {"name": "digit", "type": "char"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2260, "task_id": "minimum-consecutive-cards-to-pick-up", "difficulty": "Medium", "problem_description": "You are given an integer array cards where cards[i] represents the value of the ith card. A pair of cards are matching if the cards have the same value.\nReturn the minimum number of consecutive cards you have to pick up to have a pair of matching cards among the picked cards. If it is impossible to have matching cards, return -1.\n \nExample 1:\n\nInput: cards = [3,4,2,3,4,7]\nOutput: 4\nExplanation: We can pick up the cards [3,4,2,3] which contain a matching pair of cards with value 3. Note that picking up the cards [4,2,3,4] is also optimal.\n\nExample 2:\n\nInput: cards = [1,0,5,3]\nOutput: -1\nExplanation: There is no way to pick up a set of consecutive cards that contain a pair of matching cards.\n\n \nConstraints:\n\n1 <= cards.length <= 105\n0 <= cards[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cards = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 11\n assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n assert candidate(cards = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 10\n assert candidate(cards = [3, 4, 2, 3, 4, 7]) == 4\n assert candidate(cards = [0, 0]) == 2\n assert candidate(cards = [1, 1]) == 2\n assert candidate(cards = [0, 0, 0, 0, 0]) == 2\n assert candidate(cards = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1]) == -1\n assert candidate(cards = [5]) == -1\n assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(cards = [1000000, 999999, 1000000]) == 3\n assert candidate(cards = [1, 1, 1, 1, 1]) == 2\n assert candidate(cards = [1, 0, 5, 3]) == -1\n assert candidate(cards = [1000000, 0, 1000000]) == 3\n assert candidate(cards = [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, 1]) == 51\n assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1]) == 12\n assert candidate(cards = [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]) == 11\n assert candidate(cards = [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]) == 51\n assert candidate(cards = [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, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(cards = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(cards = [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]) == 2\n assert candidate(cards = [5, 3, 8, 10, 5, 3, 8, 10, 5, 3, 8, 10, 5, 3, 8, 10, 5, 3, 8, 10]) == 5\n assert candidate(cards = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5]) == 7\n assert candidate(cards = [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, 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]) == 31\n assert candidate(cards = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 11\n assert candidate(cards = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(cards = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(cards = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 5, 15, 25, 35, 45, 55, 65, 75, 85]) == 12\n assert candidate(cards = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10]) == 21\n assert candidate(cards = [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]) == 31\n assert candidate(cards = [1000000, 999999, 999998, 999997, 999996, 999995, 1000000]) == 7\n assert candidate(cards = [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]) == 6\n assert candidate(cards = [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]) == 11\n assert candidate(cards = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 6\n assert candidate(cards = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 2\n assert candidate(cards = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(cards = [5, 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(cards = [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, 0]) == 32\n assert candidate(cards = [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, 1]) == 31\n assert candidate(cards = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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(cards = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981, 999980, 999999]) == 21\n assert candidate(cards = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10]) == 11\n assert candidate(cards = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 500, 300]) == 8\n assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 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]) == 2\n assert candidate(cards = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 1000]) == 11\n assert candidate(cards = [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]) == 51\n assert candidate(cards = [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]) == 31\n assert candidate(cards = [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]) == 2\n assert candidate(cards = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 6\n assert candidate(cards = [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]) == 21\n assert candidate(cards = [9, 3, 1, 3, 2, 5, 9, 8, 3, 9]) == 3\n assert candidate(cards = [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]) == 31\n assert candidate(cards = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 1000000]) == 11\n assert candidate(cards = [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, 1]) == 2\n assert candidate(cards = [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]) == 2\n assert candidate(cards = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 11\n assert candidate(cards = [1000000, 999999, 999998, 1000000, 999997, 999996, 999995, 999994, 999993, 1000000]) == 4\n assert candidate(cards = [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]) == 11\n assert candidate(cards = [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, 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]) == 11\n assert candidate(cards = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(cards = [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]) == 21\n assert candidate(cards = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 11\n assert candidate(cards = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 3\n assert candidate(cards = [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]) == 2\n assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(cards = [1000000, 999999, 999998, 999997, 1000000, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981, 999980]) == 5\n assert candidate(cards = [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]) == 26\n assert candidate(cards = [42, 17, 23, 34, 42, 17, 23, 34, 42, 17, 23, 34, 42]) == 5\n assert candidate(cards = [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, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 26\n assert candidate(cards = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11\n assert candidate(cards = [1, 0, 5, 3, 2, 4, 6, 7, 8, 9, 1, 0, 5, 3, 2, 4, 6, 7, 8, 9]) == 11\n assert candidate(cards = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 21\n assert candidate(cards = [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, 1]) == 2\n assert candidate(cards = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n assert candidate(cards = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(cards = [1000000, 999999, 999998, 999997, 999996, 1000000]) == 6\n assert candidate(cards = [1000000, 999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 1000000]) == 11\n assert candidate(cards = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 11\n assert candidate(cards = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 17\n assert candidate(cards = [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]) == 26\n assert candidate(cards = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(cards = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11\n assert candidate(cards = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 11\n assert candidate(cards = [1, 0, 5, 3, 2, 2, 5, 1, 0, 3, 2, 1]) == 2\n assert candidate(cards = [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]) == 2\n assert candidate(cards = [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]) == 11\n assert candidate(cards = [100000, 200000, 300000, 100000, 400000, 500000, 600000, 700000, 800000, 900000, 100000]) == 4\n assert candidate(cards = [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]) == 31\n assert candidate(cards = [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, 1]) == 101\n assert candidate(cards = [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, 1]) == 2\n assert candidate(cards = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 3\n assert candidate(cards = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 1]) == 21\n assert candidate(cards = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 11\n assert candidate(cards = [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]) == 2\n assert candidate(cards = [1, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(cards = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 1000000]) == 11\n assert candidate(cards = [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]) == 2\n assert candidate(cards = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n assert candidate(cards = [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]) == 21\n assert candidate(cards = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == 11\n assert candidate(cards = [1000000, 1000000, 1000000, 1000000, 1000000]) == 2\n assert candidate(cards = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10]) == 11\n assert candidate(cards = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == 11\n assert candidate(cards = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 3\n assert candidate(cards = [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]) == 12\n assert candidate(cards = [100000, 200000, 300000, 400000, 500000, 100000, 200000, 300000, 400000, 500000]) == 6\n"}, "metadata": {"canonical_parameter_names": ["cards"], "leetcode_dataset_entry_point": "Solution().minimumCardPickup", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumCardPickup(int[] cards) {", "container": "Solution", "callable": "minimumCardPickup", "parameters": [{"name": "cards", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2261, "task_id": "k-divisible-elements-subarrays", "difficulty": "Medium", "problem_description": "Given an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p.\nTwo arrays nums1 and nums2 are said to be distinct if:\n\nThey are of different lengths, or\nThere exists at least one index i where nums1[i] != nums2[i].\n\nA subarray is defined as a non-empty contiguous sequence of elements in an array.\n \nExample 1:\n\nInput: nums = [2,3,3,2,2], k = 2, p = 2\nOutput: 11\nExplanation:\nThe elements at indices 0, 3, and 4 are divisible by p = 2.\nThe 11 distinct subarrays which have at most k = 2 elements divisible by 2 are:\n[2], [2,3], [2,3,3], [2,3,3,2], [3], [3,3], [3,3,2], [3,3,2,2], [3,2], [3,2,2], and [2,2].\nNote that the subarrays [2] and [3] occur more than once in nums, but they should each be counted only once.\nThe subarray [2,3,3,2,2] should not be counted because it has 3 elements that are divisible by 2.\n\nExample 2:\n\nInput: nums = [1,2,3,4], k = 4, p = 1\nOutput: 10\nExplanation:\nAll element of nums are divisible by p = 1.\nAlso, every subarray of nums will have at most 4 elements that are divisible by 1.\nSince all subarrays are distinct, the total number of subarrays satisfying all the constraints is 10.\n\n \nConstraints:\n\n1 <= nums.length <= 200\n1 <= nums[i], p <= 200\n1 <= k <= nums.length\n\n \nFollow up:\nCan you solve this problem in O(n2) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 2, 1],k = 1,p = 2) == 5\n assert candidate(nums = [19, 23, 29, 31, 37],k = 3,p = 5) == 15\n assert candidate(nums = [1, 2, 1, 2],k = 1,p = 2) == 5\n assert candidate(nums = [13, 26, 39, 52, 65],k = 2,p = 13) == 9\n assert candidate(nums = [5, 5, 5, 5],k = 2,p = 5) == 2\n assert candidate(nums = [5, 10, 15, 20],k = 2,p = 5) == 7\n assert candidate(nums = [5, 10, 15, 20, 25],k = 3,p = 5) == 12\n assert candidate(nums = [7, 11, 13, 17],k = 1,p = 2) == 10\n assert candidate(nums = [100, 200, 300, 400, 500],k = 2,p = 100) == 9\n assert candidate(nums = [6, 3, 2, 8, 7, 1],k = 3,p = 3) == 21\n assert candidate(nums = [5, 5, 5, 5],k = 1,p = 5) == 1\n assert candidate(nums = [3, 9, 12, 15, 18],k = 2,p = 3) == 9\n assert candidate(nums = [10, 20, 30, 40, 50],k = 0,p = 10) == 0\n assert candidate(nums = [11, 22, 33, 44, 55],k = 3,p = 11) == 12\n assert candidate(nums = [19, 19, 19, 19, 19],k = 3,p = 19) == 3\n assert candidate(nums = [7, 14, 21, 28, 35],k = 2,p = 7) == 9\n assert candidate(nums = [2, 4, 6, 8, 10],k = 1,p = 2) == 5\n assert candidate(nums = [3, 6, 9, 12, 15],k = 1,p = 3) == 5\n assert candidate(nums = [7, 7, 7, 7, 7],k = 0,p = 7) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 3,p = 5) == 15\n assert candidate(nums = [7, 14, 21, 28, 35],k = 1,p = 7) == 5\n assert candidate(nums = [3, 6, 9, 12, 15],k = 2,p = 3) == 9\n assert candidate(nums = [200, 100, 50, 25, 12],k = 1,p = 25) == 6\n assert candidate(nums = [1, 1, 1, 1, 1],k = 2,p = 1) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],k = 2,p = 10) == 9\n assert candidate(nums = [1, 1, 1, 1],k = 1,p = 1) == 1\n assert candidate(nums = [10, 5, 15, 20, 25],k = 3,p = 5) == 12\n assert candidate(nums = [6, 3, 9, 12, 15],k = 2,p = 3) == 9\n assert candidate(nums = [2, 3, 3, 2, 2],k = 2,p = 2) == 11\n assert candidate(nums = [11, 13, 17, 19, 23],k = 5,p = 2) == 15\n assert candidate(nums = [2, 4, 6, 8, 10],k = 0,p = 2) == 0\n assert candidate(nums = [6, 12, 18, 24, 30],k = 3,p = 3) == 12\n assert candidate(nums = [11, 22, 33, 44, 55],k = 5,p = 10) == 15\n assert candidate(nums = [8, 16, 24, 32, 40],k = 2,p = 8) == 9\n assert candidate(nums = [1, 2, 3, 4],k = 4,p = 1) == 10\n assert candidate(nums = [1, 6, 3, 2, 7, 4],k = 3,p = 3) == 21\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 = 15,p = 3) == 195\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260],k = 7,p = 13) == 119\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 = 8,p = 1) == 132\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 5,p = 5) == 50\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220],k = 10,p = 11) == 155\n assert candidate(nums = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200],k = 1,p = 20) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10,p = 1) == 55\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 2,p = 11) == 19\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 15,p = 7) == 231\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 = 25,p = 2) == 325\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,p = 1) == 5\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],k = 4,p = 4) == 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 = 200,p = 2) == 20\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181],k = 15,p = 200) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7,p = 3) == 120\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],k = 2,p = 2) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 5,p = 2) == 65\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209],k = 10,p = 11) == 145\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 200],k = 5,p = 5) == 210\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165],k = 6,p = 11) == 75\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181],k = 15,p = 19) == 210\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10,p = 10) == 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 = 10,p = 3) == 210\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,p = 2) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5,p = 10) == 40\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 7,p = 7) == 77\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200],k = 4,p = 100) == 8\n assert candidate(nums = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400],k = 10,p = 20) == 155\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 3,p = 15) == 27\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 = 10,p = 5) == 209\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],k = 7,p = 5) == 91\n assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126],k = 12,p = 6) == 174\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,p = 2) == 147\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3,p = 4) == 47\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 2,p = 13) == 19\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5,p = 4) == 55\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3,p = 2) == 41\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,p = 3) == 201\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 = 15,p = 2) == 210\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],k = 10,p = 7) == 155\n assert candidate(nums = [15, 18, 21, 24, 27, 30, 33, 36, 39, 42],k = 5,p = 3) == 40\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 = 10,p = 100) == 155\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 = 15,p = 2) == 345\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,p = 5) == 10\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 4,p = 7) == 34\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3,p = 1) == 3\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 3,p = 11) == 27\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2,p = 2) == 55\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181],k = 10,p = 2) == 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 = 5,p = 2) == 160\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300],k = 10,p = 15) == 155\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5,p = 5) == 5\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 10,p = 5) == 155\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,p = 3) == 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],k = 5,p = 2) == 20\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],k = 5,p = 2) == 19\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33],k = 5,p = 3) == 45\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 4,p = 7) == 34\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],k = 5,p = 4) == 40\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],k = 50,p = 1) == 50\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 = 10,p = 3) == 155\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,p = 1) == 90\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],k = 5,p = 3) == 60\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,p = 2) == 10\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 4,p = 3) == 34\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 = 7,p = 3) == 119\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2,p = 10) == 19\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260],k = 5,p = 13) == 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],k = 10,p = 1) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 6,p = 2) == 75\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91],k = 7,p = 7) == 70\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4,p = 10) == 34\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 = 10,p = 2) == 210\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 = 15,p = 5) == 270\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,p = 5) == 155\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0,p = 5) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 6,p = 2) == 75\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,p = 1) == 5\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 = 20,p = 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],k = 3,p = 1) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 10,p = 2) == 105\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 3,p = 7) == 27\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414],k = 4,p = 101) == 50\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266, 285, 304, 323, 342, 361, 380, 399, 418, 437, 456, 475, 494, 513, 532, 551, 570],k = 20,p = 19) == 410\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91],k = 6,p = 7) == 63\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 = 20,p = 2) == 20\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5,p = 2) == 40\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 7,p = 5) == 84\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],k = 3,p = 10) == 30\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,p = 2) == 465\n assert candidate(nums = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10],k = 3,p = 5) == 6\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340, 357, 374, 391, 408, 425],k = 10,p = 17) == 205\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5,p = 10) == 40\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5,p = 2) == 40\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200],k = 4,p = 25) == 26\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 = 20,p = 3) == 210\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111],k = 6,p = 101) == 66\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209],k = 8,p = 11) == 124\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 5,p = 3) == 65\n"}, "metadata": {"canonical_parameter_names": ["nums", "k", "p"], "leetcode_dataset_entry_point": "Solution().countDistinct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countDistinct(int[] nums, int k, int p) {", "container": "Solution", "callable": "countDistinct", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}, {"name": "p", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2262, "task_id": "total-appeal-of-a-string", "difficulty": "Hard", "problem_description": "The appeal of a string is the number of distinct characters found in the string.\n\nFor example, the appeal of \"abbca\" is 3 because it has 3 distinct characters: 'a', 'b', and 'c'.\n\nGiven a string s, return the total appeal of all of its substrings.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"abbca\"\nOutput: 28\nExplanation: The following are the substrings of \"abbca\":\n- Substrings of length 1: \"a\", \"b\", \"b\", \"c\", \"a\" have an appeal of 1, 1, 1, 1, and 1 respectively. The sum is 5.\n- Substrings of length 2: \"ab\", \"bb\", \"bc\", \"ca\" have an appeal of 2, 1, 2, and 2 respectively. The sum is 7.\n- Substrings of length 3: \"abb\", \"bbc\", \"bca\" have an appeal of 2, 2, and 3 respectively. The sum is 7.\n- Substrings of length 4: \"abbc\", \"bbca\" have an appeal of 3 and 3 respectively. The sum is 6.\n- Substrings of length 5: \"abbca\" has an appeal of 3. The sum is 3.\nThe total sum is 5 + 7 + 7 + 6 + 3 = 28.\n\nExample 2:\n\nInput: s = \"code\"\nOutput: 20\nExplanation: The following are the substrings of \"code\":\n- Substrings of length 1: \"c\", \"o\", \"d\", \"e\" have an appeal of 1, 1, 1, and 1 respectively. The sum is 4.\n- Substrings of length 2: \"co\", \"od\", \"de\" have an appeal of 2, 2, and 2 respectively. The sum is 6.\n- Substrings of length 3: \"cod\", \"ode\" have an appeal of 3 and 3 respectively. The sum is 6.\n- Substrings of length 4: \"code\" has an appeal of 4. The sum is 4.\nThe total sum is 4 + 6 + 6 + 4 = 20.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 3276\n assert candidate(s = \"zzzaaa\") == 30\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"abacabadabacaba\") == 357\n assert candidate(s = \"abcabcabc\") == 109\n assert candidate(s = \"abbca\") == 28\n assert candidate(s = \"ababababab\") == 100\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 210\n assert candidate(s = \"aaa\") == 6\n assert candidate(s = \"python\") == 56\n assert candidate(s = \"abcabc\") == 46\n assert candidate(s = \"world\") == 35\n assert candidate(s = \"zzzzzzzzzz\") == 55\n assert candidate(s = \"abcdabcdabcd\") == 244\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 1306\n assert candidate(s = \"abc\") == 10\n assert candidate(s = \"abcd\") == 20\n assert candidate(s = \"aaaa\") == 10\n assert candidate(s = \"hello\") == 29\n assert candidate(s = \"mississippi\") == 148\n assert candidate(s = \"zzzzz\") == 15\n assert candidate(s = \"z\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 13078\n assert candidate(s = \"longstringwithvariouscharacters\") == 3921\n assert candidate(s = \"code\") == 20\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 3276\n assert candidate(s = \"xyzzxyzzxyzz\") == 191\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeefffffffffgggggggggghhhhhhhhhh\") == 11380\n assert candidate(s = \"abcdefg\") == 84\n assert candidate(s = \"aabbccaaabbbccc\") == 274\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 18730\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 6520\n assert candidate(s = \"bbaaccddeeffgg\") == 329\n assert candidate(s = \"aabbaabbaabbccddeeefffggghhhiiijjjkkklllmnnnooopppqqqrrrsssttuuuuuuuuvvwxyz\") == 26940\n assert candidate(s = \"abracadabra\") == 210\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 1306\n assert candidate(s = \"uniquecharacters\") == 677\n assert candidate(s = \"aabbc\") == 25\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzz\") == 23011\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabb\") == 1008\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 865\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 1838\n assert candidate(s = \"ababababababababababababababa\") == 841\n assert candidate(s = \"ninetyninebottlesofbeer\") == 1564\n assert candidate(s = \"abcdabcdbcadbacdbac\") == 646\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 1820\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 46306\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 5345\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 3276\n assert candidate(s = \"abcabcabcabcabcabcabcabcabc\") == 1054\n assert candidate(s = \"abababababababab\") == 256\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 21528\n assert candidate(s = \"xyxzyzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxz\") == 5105\n assert candidate(s = \"hellohellohello\") == 377\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 46120\n assert candidate(s = \"banana\") == 40\n assert candidate(s = \"hellohellobyebye\") == 513\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 8230\n assert candidate(s = \"abacabadaba\") == 177\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1378\n assert candidate(s = \"thisisareallylongteststringwithmanydistinctcharactersandrepeatedones\") == 25027\n assert candidate(s = \"thisisaverylongstringwithmanycopiesofthissubstringthissubstringthissubstring\") == 35609\n assert candidate(s = \"xyxzyxyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyz\") == 2363\n assert candidate(s = \"aaaaabbbbbccccc\") == 220\n assert candidate(s = \"xyzzzyxzyzyzyxzyzyxzyzyzyzyxzyzyzyzyzyzyzyzyzyzyzyzyzyz\") == 4088\n assert candidate(s = \"amazingappeal\") == 374\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1275\n assert candidate(s = \"aabbccaaaabbbccc\") == 309\n assert candidate(s = \"abacabadabacabaabacabadabacaba\") == 1555\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().appealSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long appealSum(String s) {", "container": "Solution", "callable": "appealSum", "parameters": [{"name": "s", "type": "String"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2264, "task_id": "largest-3-same-digit-number-in-string", "difficulty": "Easy", "problem_description": "You are given a string num representing a large integer. An integer is good if it meets the following conditions:\n\nIt is a substring of num with length 3.\nIt consists of only one unique digit.\n\nReturn the maximum good integer as a string or an empty string \"\" if no such integer exists.\nNote:\n\nA substring is a contiguous sequence of characters within a string.\nThere may be leading zeroes in num or a good integer.\n\n \nExample 1:\n\nInput: num = \"6777133339\"\nOutput: \"777\"\nExplanation: There are two distinct good integers: \"777\" and \"333\".\n\"777\" is the largest, so we return \"777\".\n\nExample 2:\n\nInput: num = \"2300019\"\nOutput: \"000\"\nExplanation: \"000\" is the only good integer.\n\nExample 3:\n\nInput: num = \"42352338\"\nOutput: \"\"\nExplanation: No substring of length 3 consists of only one unique digit. Therefore, there are no good integers.\n\n \nConstraints:\n\n3 <= num.length <= 1000\nnum only consists of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"999888777666555444333222111000\") == \"999\"\n assert candidate(num = \"000\") == \"000\"\n assert candidate(num = \"42352338\") == \"\"\n assert candidate(num = \"9876543210\") == \"\"\n assert candidate(num = \"555444555\") == \"555\"\n assert candidate(num = \"112233445566778899\") == \"\"\n assert candidate(num = \"888777666555444333222111000\") == \"888\"\n assert candidate(num = \"2300019\") == \"000\"\n assert candidate(num = \"10000001\") == \"000\"\n assert candidate(num = \"123\") == \"\"\n assert candidate(num = \"6777133339\") == \"777\"\n assert candidate(num = \"1222333444555666777888999000\") == \"999\"\n assert candidate(num = \"888777666555444333222111\") == \"888\"\n assert candidate(num = \"333333333\") == \"333\"\n assert candidate(num = \"999999999\") == \"999\"\n assert candidate(num = \"999999\") == \"999\"\n assert candidate(num = \"11223344556677889900\") == \"\"\n assert candidate(num = \"9999999\") == \"999\"\n assert candidate(num = \"1234567890\") == \"\"\n assert candidate(num = \"000111222333444555666777888999\") == \"999\"\n assert candidate(num = \"111222333\") == \"333\"\n assert candidate(num = \"888888888888888888888\") == \"888\"\n assert candidate(num = \"100100100\") == \"\"\n assert candidate(num = \"000000000\") == \"000\"\n assert candidate(num = \"111111111\") == \"111\"\n assert candidate(num = \"111\") == \"111\"\n assert candidate(num = \"123123123123123123123123123123123123\") == \"\"\n assert candidate(num = \"1234444321111234444321\") == \"444\"\n assert candidate(num = \"12345678987654321000000123456789\") == \"000\"\n assert candidate(num = \"555444333222111000000000000111222333444\") == \"555\"\n assert candidate(num = \"123456789123456789123456789123456789123456789\") == \"\"\n assert candidate(num = \"1233344445555566666777777\") == \"777\"\n assert candidate(num = \"555444333222111000000111222333444555\") == \"555\"\n assert candidate(num = \"1222222222222222222222222222221\") == \"222\"\n assert candidate(num = \"555444333222111000999888777666555\") == \"999\"\n assert candidate(num = \"10000001000000100000010000001000000\") == \"000\"\n assert candidate(num = \"987654321111111111111111111111987654321000000000\") == \"111\"\n assert candidate(num = \"88888888888888888888888888888888888888888888\") == \"888\"\n assert candidate(num = \"1234567890123456789012345678901234567890\") == \"\"\n assert candidate(num = \"12345678987654321012345678987654321\") == \"\"\n assert candidate(num = \"999000111222333444555666777888999\") == \"999\"\n assert candidate(num = \"000123456789\") == \"000\"\n assert candidate(num = \"111111222222333333444444555555666666777777888888999999\") == \"999\"\n assert candidate(num = \"1111111111111111111111111111111111111111111111111\") == \"111\"\n assert candidate(num = \"123123123123123123123123\") == \"\"\n assert candidate(num = \"123123123123123123123123123123\") == \"\"\n assert candidate(num = \"1000000000000000000000000000000000000000000000000\") == \"000\"\n assert candidate(num = \"01234567890123456789012345678901234567890\") == \"\"\n assert candidate(num = \"999999999999999999999999999999\") == \"999\"\n assert candidate(num = \"987654321111111111111111111111987654321\") == \"111\"\n assert candidate(num = \"111222333444555666777888999000111222333444555666777888999\") == \"999\"\n assert candidate(num = \"1221221221221221221221221\") == \"\"\n assert candidate(num = \"000000000000000000000000000\") == \"000\"\n assert candidate(num = \"123123123123123123123123123\") == \"\"\n assert candidate(num = \"55555555555555555555555555555555555555555555555555555555\") == \"555\"\n assert candidate(num = \"123333456789000123456789\") == \"333\"\n assert candidate(num = \"00000000000000000000000000000000000000000000\") == \"000\"\n assert candidate(num = \"99999999999999999999999999999999999999999999\") == \"999\"\n assert candidate(num = \"333333333333333333333333333333\") == \"333\"\n assert candidate(num = \"9990000000000000000000000000000000000000000000000000000000\") == \"999\"\n assert candidate(num = \"1122334455667788990011223344556677889900\") == \"\"\n assert candidate(num = \"33333333333333333333333333333333333333333333\") == \"333\"\n assert candidate(num = \"987654321000000000987654321\") == \"000\"\n assert candidate(num = \"122333444555666777888999\") == \"999\"\n assert candidate(num = \"888999777666555444333222111000\") == \"999\"\n assert candidate(num = \"111222333444555666777888999000\") == \"999\"\n assert candidate(num = \"123332111112222233333\") == \"333\"\n assert candidate(num = \"98765432109876543210987654321\") == \"\"\n assert candidate(num = \"000000000000000000000000000000\") == \"000\"\n assert candidate(num = \"11111111111111111111111111111111111111111111\") == \"111\"\n assert candidate(num = \"98765432111111111111111111111111111111111111\") == \"111\"\n assert candidate(num = \"999111222333444555666777888\") == \"999\"\n assert candidate(num = \"123332111222222111111\") == \"333\"\n assert candidate(num = \"111222333444555666777888999111222333444555\") == \"999\"\n assert candidate(num = \"10101010101010101010101010101010101010101010\") == \"\"\n assert candidate(num = \"12345678987654321111100000000222222333333\") == \"333\"\n assert candidate(num = \"1000000000000000000000000000000\") == \"000\"\n assert candidate(num = \"111222333444555666777888999000111222\") == \"999\"\n assert candidate(num = \"98765432111123456789000000\") == \"111\"\n assert candidate(num = \"999000999000999\") == \"999\"\n assert candidate(num = \"0000000000000000000000000000000000000000000000000\") == \"000\"\n assert candidate(num = \"000000111111222222333333444444555555666666777777888888999999\") == \"999\"\n assert candidate(num = \"111222333444555666777888999111\") == \"999\"\n assert candidate(num = \"987654321098765432109876543210\") == \"\"\n assert candidate(num = \"888999888999888999888999888999\") == \"999\"\n assert candidate(num = \"111000111000111000111000\") == \"111\"\n assert candidate(num = \"1234555554321\") == \"555\"\n assert candidate(num = \"123456789123456789123456789\") == \"\"\n assert candidate(num = \"111000111000111000111000111000\") == \"111\"\n assert candidate(num = \"111000222333444555666777888999\") == \"999\"\n assert candidate(num = \"333222111333222111333222111\") == \"333\"\n assert candidate(num = \"101010101010101010101010101\") == \"\"\n assert candidate(num = \"1111111111111111111111111111111\") == \"111\"\n assert candidate(num = \"12345678999987654321\") == \"999\"\n assert candidate(num = \"111122223333444455556666777788889999\") == \"999\"\n assert candidate(num = \"123456789000000987654321\") == \"000\"\n assert candidate(num = \"999888777666555444333222111\") == \"999\"\n assert candidate(num = \"555555555555555555555555555555555555555555555555\") == \"555\"\n assert candidate(num = \"111222333444555666777888999\") == \"999\"\n assert candidate(num = \"999888777666555444333222111000999888777\") == \"999\"\n assert candidate(num = \"111000111222333\") == \"333\"\n assert candidate(num = \"123456789876543211222333444555666777888999\") == \"999\"\n assert candidate(num = \"123456789876543211111111111111\") == \"111\"\n assert candidate(num = \"9999999999999999999999999999999999999999999999999\") == \"999\"\n assert candidate(num = \"123456789000000000000000000\") == \"000\"\n assert candidate(num = \"987654321000000123456789\") == \"000\"\n assert candidate(num = \"111999888777666555444333222111\") == \"999\"\n assert candidate(num = \"5555555555555555555555555555555\") == \"555\"\n assert candidate(num = \"333222111000999888777666555444333222111000\") == \"999\"\n assert candidate(num = \"1233321111222223333\") == \"333\"\n assert candidate(num = \"0011223344556677889900112233445566\") == \"\"\n assert candidate(num = \"123456789012345678901234567890\") == \"\"\n assert candidate(num = \"000111222333444555666777888999000111222333\") == \"999\"\n assert candidate(num = \"1111122223333444455556666777788889999\") == \"999\"\n assert candidate(num = \"5555555555555555555555555\") == \"555\"\n assert candidate(num = \"111222333444555666777888999000111\") == \"999\"\n assert candidate(num = \"999000999000999000999000999000999000\") == \"999\"\n assert candidate(num = \"1234567890000000000000000000000000000000\") == \"000\"\n assert candidate(num = \"123456789123456789123456789123456789\") == \"\"\n assert candidate(num = \"11111111111111111111111111111100000000000000000\") == \"111\"\n assert candidate(num = \"555555444444333333222222111111\") == \"555\"\n assert candidate(num = \"333222111000777888999\") == \"999\"\n assert candidate(num = \"555555555555555555555555555555\") == \"555\"\n assert candidate(num = \"1222233333444444555555566666667\") == \"666\"\n assert candidate(num = \"123123123123123123123123123123123123123123123123123123123123\") == \"\"\n assert candidate(num = \"123456789999987654321\") == \"999\"\n assert candidate(num = \"990990990990990990\") == \"\"\n assert candidate(num = \"123455567890123456789012345678\") == \"555\"\n assert candidate(num = \"111111111111111111111111111111\") == \"111\"\n assert candidate(num = \"12345556789000987654321000000\") == \"555\"\n assert candidate(num = \"22222222222222222222222222222222222222222222\") == \"222\"\n assert candidate(num = \"10000000000000000000000000000001\") == \"000\"\n assert candidate(num = \"000111000111000111000111000111\") == \"111\"\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().largestGoodInteger", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String largestGoodInteger(String num) {", "container": "Solution", "callable": "largestGoodInteger", "parameters": [{"name": "num", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2265, "task_id": "count-nodes-equal-to-average-of-subtree", "difficulty": "Medium", "problem_description": "Given the root of a binary tree, return the number of nodes where the value of the node is equal to the average of the values in its subtree.\nNote:\n\nThe average of n elements is the sum of the n elements divided by n and rounded down to the nearest integer.\nA subtree of root is a tree consisting of root and all of its descendants.\n\n \nExample 1:\n\n\nInput: root = [4,8,5,0,1,null,6]\nOutput: 5\nExplanation: \nFor the node with value 4: The average of its subtree is (4 + 8 + 5 + 0 + 1 + 6) / 6 = 24 / 6 = 4.\nFor the node with value 5: The average of its subtree is (5 + 6) / 2 = 11 / 2 = 5.\nFor the node with value 0: The average of its subtree is 0 / 1 = 0.\nFor the node with value 1: The average of its subtree is 1 / 1 = 1.\nFor the node with value 6: The average of its subtree is 6 / 1 = 6.\n\nExample 2:\n\n\nInput: root = [1]\nOutput: 1\nExplanation: For the node with value 1: The average of its subtree is 1 / 1 = 1.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 1000].\n0 <= Node.val <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([0, 0, 0, 0, 0, 0, 0])) == 7\n assert candidate(root = tree_node([4, 8, 5, 0, 1, None, 6])) == 5\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 18])) == 4\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7])) == 3\n assert candidate(root = tree_node([1])) == 1\n assert candidate(root = tree_node([5, 3, 7, 2, 4, 6, 8, 1, None, None, None, None, None, None, 9])) == 7\n assert candidate(root = tree_node([6, 10, 20, 5, None, 15, 25, 3, None, None, None, 18, 22])) == 5\n assert candidate(root = tree_node([5, 3, 8, 1, 4, 7, 10, 0, 2, 6, 9, None, None, None, None, None, None, None, None])) == 10\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 13, 17, 23, 27, 33, 37])) == 12\n assert candidate(root = tree_node([9, 6, 15, 3, 8, 12, 20, 1, 5, 7, 9, 11, 13, 17, 22])) == 12\n assert candidate(root = tree_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])) == 13\n assert candidate(root = tree_node([2, 3, 3, 8, 10, 14, 13])) == 4\n assert candidate(root = tree_node([1, 3, 5, 2, 4, 6, 7, None, None, None, None, None, None, None, 8])) == 6\n assert candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 5\n assert candidate(root = tree_node([1, 2, 2, 3, 3, None, None, 4, 4, 4, 4, None, None, 5, 5, 5, 5, 5, 5, 5, 5])) == 13\n assert candidate(root = tree_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 10\n assert candidate(root = tree_node([5, 2, 8, 1, 3, 7, 9, 0, 4, 6, 10])) == 9\n assert candidate(root = tree_node([3, 3, None, 3, None, 3, None, 3, None, 3, None, 3, None, 3])) == 8\n assert candidate(root = tree_node([7, 3, 15, None, None, 9, 20])) == 3\n assert candidate(root = tree_node([6, 2, 8, 0, 4, 7, 9, None, 1, 3, 5, None, None, None, None, None])) == 9\n assert candidate(root = tree_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200])) == 10\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18])) == 4\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 190])) == 11\n assert candidate(root = tree_node([5, 3, 8, 2, 4, 7, 9, 1, None, None, 6])) == 7\n assert candidate(root = tree_node([25, 10, 35, 5, 15, 30, 40, 2, 7, 13, 17, 28, 32, 38, 45])) == 11\n assert candidate(root = tree_node([1, 2, 2, 3, 3, None, None, 4, 4, 4, 4])) == 7\n assert candidate(root = tree_node([7, 10, 15, None, None, 12, 20])) == 4\n assert candidate(root = tree_node([7, 3, 15, None, None, 9, 20, None, None, None, None, 19, 23])) == 3\n assert candidate(root = tree_node([6, 5, 7, 2, 3, 6, 8, 1, 4, 5, 7, 6, 8, 9, 10])) == 11\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, 8, 9, 10, 11, 12, 13, None, None, None, None, 14, 15, None, None, None, None, None, 16])) == 8\n assert candidate(root = tree_node([100, 99, 101, 98, 102, 97, 103])) == 6\n assert candidate(root = tree_node([8, 5, 9, 4, 6, 8, 10, None, None, None, None, 7, 11, None, None])) == 8\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 90, 110, 140, 160, 190])) == 12\n assert candidate(root = tree_node([6, 2, 8, 0, 4, 7, 9, None, None, 3, 5])) == 8\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 2, 8, 12, 18, 22, 28, 32, 40])) == 15\n assert candidate(root = tree_node([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1])) == 4\n assert candidate(root = tree_node([999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999])) == 15\n assert candidate(root = tree_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == 15\n assert candidate(root = tree_node([7, 3, 15, 1, 5, 9, 20, 0, 2, None, None, None, None, 17, 25])) == 8\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 12, 37, 63, 87, 112, 137, 162, 187])) == 9\n assert candidate(root = tree_node([500, 250, 750, 125, 375, 625, 875, 63, 188, 313, 438, 563, 688, 813, 938])) == 15\n assert candidate(root = tree_node([5, 1, 4, None, None, 3, 6])) == 4\n assert candidate(root = tree_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])) == 8\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 9\n assert candidate(root = tree_node([2, 1, 3, 0, 4, 6, 9, 0, 0, 0, 0, 0, 0, 0, 0])) == 9\n assert candidate(root = tree_node([100, 50, 150, 25, 75, None, None, 10, 40, 125, 175])) == 6\n assert candidate(root = tree_node([9, 3, 15, 1, None, 12, 20, None, None, None, 13, 18, 22])) == 6\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6, 8, None, None, 17, 20])) == 7\n assert candidate(root = tree_node([7, 3, 15, None, None, 9, 20, None, None, 10, 19])) == 4\n assert candidate(root = tree_node([7, 10, 15, None, None, None, 20])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 10\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18])) == 7\n assert candidate(root = tree_node([7, 3, 11, 1, 5, 9, 13, None, None, 2, 6, 8, 10, 12, 14])) == 12\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, None, 1, 7])) == 5\n assert candidate(root = tree_node([1, 3, 2, 5, 3, None, 9, 0, 8])) == 5\n assert candidate(root = tree_node([2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 8\n assert candidate(root = tree_node([2, 1, 3, 0, 2, 2, 4, None, None, None, 3, None, None, 2, None])) == 7\n assert candidate(root = tree_node([2, 3, None, 1, None, 3, None, None, 2, None, 2])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 8\n assert candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, 0, 8])) == 8\n assert candidate(root = tree_node([1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4])) == 10\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 90, 110, 140, 160, 190])) == 15\n assert candidate(root = tree_node([1, 3, 2, None, 5, None, 9, 6, None, 7, None, 11, None, 13, None, 17])) == 3\n assert candidate(root = tree_node([1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4])) == 12\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, None, 1])) == 3\n assert candidate(root = tree_node([1000, 500, 1500, 250, 750, 1250, 1750, 125, 375, 625, 875, 1125, 1375, 1625, 1875])) == 15\n assert candidate(root = tree_node([5, 10, 15, 20, 25, None, None, 30, None, None, 35])) == 3\n assert candidate(root = tree_node([2, 3, 5, 8, 13, None, None])) == 3\n assert candidate(root = tree_node([6, 12, 8, 24, 4, None, 2, None, 10])) == 4\n assert candidate(root = tree_node([5, 2, 8, 1, 4, None, 9, None, None, 3, 6])) == 6\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, None, 6])) == 5\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 18, 25])) == 11\n assert candidate(root = tree_node([2, 1, 11, 0, 3, 9, 12, None, None, 2, 4, 8, 10, None, 5, 6, 13])) == 8\n assert candidate(root = tree_node([1, 3, 2, 5, 9, None, 10, None, None, 13, None, None, 7])) == 3\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, None, 6, 8, 11, 14, 18, 22])) == 12\n assert candidate(root = tree_node([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, 5, 1])) == 5\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().averageOfSubtree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2266, "task_id": "count-number-of-texts", "difficulty": "Medium", "problem_description": "Alice is texting Bob using her phone. The mapping of digits to letters is shown in the figure below.\n\nIn order to add a letter, Alice has to press the key of the corresponding digit i times, where i is the position of the letter in the key.\n\nFor example, to add the letter 's', Alice has to press '7' four times. Similarly, to add the letter 'k', Alice has to press '5' twice.\nNote that the digits '0' and '1' do not map to any letters, so Alice does not use them.\n\nHowever, due to an error in transmission, Bob did not receive Alice's text message but received a string of pressed keys instead.\n\nFor example, when Alice sent the message \"bob\", Bob received the string \"2266622\".\n\nGiven a string pressedKeys representing the string received by Bob, return the total number of possible text messages Alice could have sent.\nSince the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: pressedKeys = \"22233\"\nOutput: 8\nExplanation:\nThe possible text messages Alice could have sent are:\n\"aaadd\", \"abdd\", \"badd\", \"cdd\", \"aaae\", \"abe\", \"bae\", and \"ce\".\nSince there are 8 possible messages, we return 8.\n\nExample 2:\n\nInput: pressedKeys = \"222222222222222222222222222222222222\"\nOutput: 82876089\nExplanation:\nThere are 2082876103 possible text messages Alice could have sent.\nSince we need to return the answer modulo 109 + 7, we return 2082876103 % (109 + 7) = 82876089.\n\n \nConstraints:\n\n1 <= pressedKeys.length <= 105\npressedKeys only consists of digits from '2' - '9'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pressedKeys = \"99999999\") == 108\n assert candidate(pressedKeys = \"3333\") == 7\n assert candidate(pressedKeys = \"33\") == 2\n assert candidate(pressedKeys = \"4444\") == 7\n assert candidate(pressedKeys = \"555555\") == 24\n assert candidate(pressedKeys = \"9999999\") == 56\n assert candidate(pressedKeys = \"888888888\") == 149\n assert candidate(pressedKeys = \"888888\") == 24\n assert candidate(pressedKeys = \"7777777\") == 56\n assert candidate(pressedKeys = \"66\") == 2\n assert candidate(pressedKeys = \"55555\") == 13\n assert candidate(pressedKeys = \"888\") == 4\n assert candidate(pressedKeys = \"33344455566677778889999\") == 65536\n assert candidate(pressedKeys = \"2222\") == 7\n assert candidate(pressedKeys = \"7777\") == 8\n assert candidate(pressedKeys = \"77777777\") == 108\n assert candidate(pressedKeys = \"8888\") == 7\n assert candidate(pressedKeys = \"6666666\") == 44\n assert candidate(pressedKeys = \"23456789\") == 1\n assert candidate(pressedKeys = \"666\") == 4\n assert candidate(pressedKeys = \"22233\") == 8\n assert candidate(pressedKeys = \"555\") == 4\n assert candidate(pressedKeys = \"9999999999\") == 401\n assert candidate(pressedKeys = \"44444\") == 13\n assert candidate(pressedKeys = \"333333\") == 24\n assert candidate(pressedKeys = \"99999\") == 15\n assert candidate(pressedKeys = \"88888\") == 13\n assert candidate(pressedKeys = \"222222222222222222222222222222222222\") == 82876089\n assert candidate(pressedKeys = \"9999888777666555444333222111\") == 524288\n assert candidate(pressedKeys = \"777777777777777777777777777777777777\") == 312882411\n assert candidate(pressedKeys = \"2222222222222222222222222222222222227777777777777777777777777777777\") == 168766023\n assert candidate(pressedKeys = \"2223333333333333333333333333333333334444444444444444444444444444444\") == 151530826\n assert candidate(pressedKeys = \"234567898765432345678987654323456789876543234567898765432\") == 1\n assert candidate(pressedKeys = \"7773333322225555555555444446666688888\") == 219119992\n assert candidate(pressedKeys = \"222222222222222222222222222222222222444444444444444444444444444\") == 964547839\n assert candidate(pressedKeys = \"9999999999999999999999999999999999999999999999999999999999999999999\") == 831813694\n assert candidate(pressedKeys = \"55555555555555555555555555555555555577777777777777777777777777777778888888888888888888888888888888\") == 60492310\n assert candidate(pressedKeys = \"333322225555444466668888\") == 117649\n"}, "metadata": {"canonical_parameter_names": ["pressedKeys"], "leetcode_dataset_entry_point": "Solution().countTexts", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countTexts(String pressedKeys) {", "container": "Solution", "callable": "countTexts", "parameters": [{"name": "pressedKeys", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2267, "task_id": "check-if-there-is-a-valid-parentheses-string-path", "difficulty": "Hard", "problem_description": "A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:\n\nIt is ().\nIt can be written as AB (A concatenated with B), where A and B are valid parentheses strings.\nIt can be written as (A), where A is a valid parentheses string.\n\nYou are given an m x n matrix of parentheses grid. A valid parentheses string path in the grid is a path satisfying all of the following conditions:\n\nThe path starts from the upper left cell (0, 0).\nThe path ends at the bottom-right cell (m - 1, n - 1).\nThe path only ever moves down or right.\nThe resulting parentheses string formed by the path is valid.\n\nReturn true if there exists a valid parentheses string path in the grid. Otherwise, return false.\n \nExample 1:\n\n\nInput: grid = [[\"(\",\"(\",\"(\"],[\")\",\"(\",\")\"],[\"(\",\"(\",\")\"],[\"(\",\"(\",\")\"]]\nOutput: true\nExplanation: The above diagram shows two possible paths that form valid parentheses strings.\nThe first path shown results in the valid parentheses string \"()(())\".\nThe second path shown results in the valid parentheses string \"((()))\".\nNote that there may be other valid parentheses string paths.\n\nExample 2:\n\n\nInput: grid = [[\")\",\")\"],[\"(\",\"(\"]]\nOutput: false\nExplanation: The two possible paths form the parentheses strings \"))(\" and \")((\". Since neither of them are valid parentheses strings, we return false.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 100\ngrid[i][j] is either '(' or ')'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [['(', '(', '('], [')', '(', ')'], ['(', '(', ')'], ['(', '(', ')']]) == True\n assert candidate(grid = [[')', ')'], ['(', '(']]) == False\n assert candidate(grid = [[')', '('], ['(', '(']]) == False\n assert candidate(grid = [['(', ')', '(', ')'], [')', '(', ')', '(']]) == False\n assert candidate(grid = [['(', ')', '(', ')'], ['(', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')', '('], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '('], [')', '(', ')', '(', ')'], [')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')', '('], [')', '(', ')', '(', ')'], [')', '(', '(', ')', '('], [')', '(', ')', '(', ')'], [')', '(', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')']]) == True\n assert candidate(grid = [['(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', ')', '(', '(', '(', ')', '(', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', ')', '(', '(', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == True\n assert candidate(grid = [[')', '(', '(', '(', '('], ['(', ')', '(', ')', '('], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '('], [')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', ')', '(', ')'], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '('], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == True\n assert candidate(grid = [['(', '(', '(', '('], [')', '(', '(', ')'], [')', ')', '(', ')'], [')', '(', ')', ')']]) == False\n assert candidate(grid = [['(', '(', '(', '(', '(', '('], [')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', '(', '(', ')'], ['(', ')', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', ')', '(', ')'], [')', '(', '(', ')', '('], [')', '(', ')', '(', ')'], [')', '(', '(', ')', '('], [')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', ')', '(', '(', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '('], [')', '(', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '('], [')', '(', '(', ')', '(', ')']]) == True\n assert candidate(grid = [['(', '(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')'], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', ')', '('], [')', '(', '(', ')'], ['(', ')', ')', '(']]) == False\n assert candidate(grid = [['(', '(', ')', '(', '(', '(', ')'], [')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')']]) == True\n assert candidate(grid = [['(', '(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')']]) == True\n assert candidate(grid = [['(', '(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')']]) == True\n assert candidate(grid = [['(', '(', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '('], ['(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '('], ['(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '('], ['(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', ')', '(', '(', '(', ')'], [')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')', '('], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '('], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '('], ['(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '('], ['(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')'], ['(', '(', ')', ')'], [')', ')', ')', '(']]) == False\n assert candidate(grid = [['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', '(', '('], [')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')'], [')', '(', ')', '(', ')'], [')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')'], ['(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')'], ['(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', ')', '(', '(', '(', ')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', '(', '('], [')', '(', ')', '('], ['(', ')', '(', ')'], [')', '(', ')', '(']]) == False\n assert candidate(grid = [['(', ')', '(', ')', '('], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', ')', '('], [')', '(', ')', '('], ['(', ')', ')', '('], [')', '(', '(', ')']]) == False\n assert candidate(grid = [['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n assert candidate(grid = [['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == True\n assert candidate(grid = [['(', '(', '(', ')', '('], ['(', '(', ')', ')', '(']]) == False\n assert candidate(grid = [['(', '(', ')', '(', ')'], [')', '(', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')']]) == True\n assert candidate(grid = [['(', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')']]) == True\n assert candidate(grid = [['(', '(', ')', '('], [')', '(', ')', '('], ['(', '(', ')', '('], [')', '(', ')', '(']]) == False\n assert candidate(grid = [['(', '(', '(', ')'], [')', '(', ')', '('], ['(', ')', ')', '(']]) == False\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().hasValidPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean hasValidPath(char[][] grid) {", "container": "Solution", "callable": "hasValidPath", "parameters": [{"name": "grid", "type": "char[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2269, "task_id": "find-the-k-beauty-of-a-number", "difficulty": "Easy", "problem_description": "The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions:\n\nIt has a length of k.\nIt is a divisor of num.\n\nGiven integers num and k, return the k-beauty of num.\nNote:\n\nLeading zeros are allowed.\n0 is not a divisor of any value.\n\nA substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: num = 240, k = 2\nOutput: 2\nExplanation: The following are the substrings of num of length k:\n- \"24\" from \"240\": 24 is a divisor of 240.\n- \"40\" from \"240\": 40 is a divisor of 240.\nTherefore, the k-beauty is 2.\n\nExample 2:\n\nInput: num = 430043, k = 2\nOutput: 2\nExplanation: The following are the substrings of num of length k:\n- \"43\" from \"430043\": 43 is a divisor of 430043.\n- \"30\" from \"430043\": 30 is not a divisor of 430043.\n- \"00\" from \"430043\": 0 is not a divisor of 430043.\n- \"04\" from \"430043\": 4 is not a divisor of 430043.\n- \"43\" from \"430043\": 43 is a divisor of 430043.\nTherefore, the k-beauty is 2.\n\n \nConstraints:\n\n1 <= num <= 109\n1 <= k <= num.length (taking num as a string)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 100000,k = 2) == 1\n assert candidate(num = 240,k = 2) == 2\n assert candidate(num = 1111,k = 2) == 3\n assert candidate(num = 430043,k = 2) == 2\n assert candidate(num = 99999,k = 5) == 1\n assert candidate(num = 123456,k = 3) == 0\n assert candidate(num = 987654,k = 1) == 1\n assert candidate(num = 1111,k = 1) == 4\n assert candidate(num = 987654321,k = 4) == 0\n assert candidate(num = 999999999,k = 9) == 1\n assert candidate(num = 111222333,k = 5) == 0\n assert candidate(num = 2345678901234567890,k = 10) == 0\n assert candidate(num = 100100100,k = 4) == 4\n assert candidate(num = 135792468013579246,k = 7) == 0\n assert candidate(num = 10101010101010101010,k = 5) == 8\n assert candidate(num = 123412341234,k = 6) == 0\n assert candidate(num = 111111111,k = 1) == 9\n assert candidate(num = 9876543210,k = 3) == 1\n assert candidate(num = 1234567890123456789,k = 6) == 0\n assert candidate(num = 7777777,k = 7) == 1\n assert candidate(num = 12301230,k = 4) == 3\n assert candidate(num = 123456789101112131415,k = 6) == 0\n assert candidate(num = 1145141919810,k = 5) == 0\n assert candidate(num = 1000000000,k = 9) == 1\n assert candidate(num = 123456789123456789123456789,k = 8) == 0\n assert candidate(num = 7777777777,k = 8) == 0\n assert candidate(num = 1000000001,k = 9) == 1\n assert candidate(num = 112233445566778899,k = 6) == 0\n assert candidate(num = 2222222222,k = 4) == 0\n assert candidate(num = 333333333,k = 4) == 0\n assert candidate(num = 1010101010,k = 2) == 9\n assert candidate(num = 1111111111,k = 3) == 0\n assert candidate(num = 999999999,k = 2) == 0\n assert candidate(num = 567890123,k = 6) == 0\n assert candidate(num = 1100110011001100,k = 8) == 7\n assert candidate(num = 112233445566778899,k = 5) == 0\n assert candidate(num = 555555555,k = 6) == 0\n assert candidate(num = 100100100,k = 3) == 7\n assert candidate(num = 864208642086420,k = 4) == 3\n assert candidate(num = 86420,k = 2) == 1\n assert candidate(num = 10000000001000000000,k = 10) == 11\n assert candidate(num = 1234567890123456789,k = 7) == 0\n assert candidate(num = 1000100010001,k = 6) == 2\n assert candidate(num = 1000000007,k = 7) == 0\n assert candidate(num = 987654321,k = 9) == 1\n assert candidate(num = 5432109876543210,k = 2) == 4\n assert candidate(num = 222222222,k = 2) == 0\n assert candidate(num = 999999999,k = 1) == 9\n assert candidate(num = 1357924680,k = 2) == 4\n assert candidate(num = 33333333333,k = 4) == 0\n assert candidate(num = 5555555555555555555,k = 6) == 0\n assert candidate(num = 864208642,k = 3) == 0\n assert candidate(num = 101010101,k = 3) == 0\n assert candidate(num = 5555555555,k = 2) == 9\n assert candidate(num = 987654321,k = 3) == 0\n assert candidate(num = 112233445566,k = 6) == 0\n assert candidate(num = 789012345678,k = 7) == 0\n assert candidate(num = 314159265358979323,k = 4) == 0\n assert candidate(num = 222222222,k = 3) == 7\n assert candidate(num = 1111111111,k = 5) == 6\n assert candidate(num = 123123123,k = 2) == 0\n assert candidate(num = 1000000,k = 4) == 1\n assert candidate(num = 888888888888888888,k = 11) == 0\n assert candidate(num = 123456789101112131415,k = 7) == 0\n assert candidate(num = 1357924680,k = 5) == 0\n assert candidate(num = 9876543210987654321,k = 9) == 2\n assert candidate(num = 10203040506070809,k = 6) == 0\n assert candidate(num = 777000777,k = 4) == 2\n assert candidate(num = 101010101,k = 5) == 0\n assert candidate(num = 987654321987654321,k = 9) == 2\n assert candidate(num = 123123123,k = 4) == 0\n assert candidate(num = 1000000000,k = 5) == 1\n assert candidate(num = 98765432109876543210987654321,k = 10) == 2\n assert candidate(num = 222222222,k = 1) == 9\n assert candidate(num = 10203040506070809,k = 9) == 0\n assert candidate(num = 101010101,k = 2) == 4\n assert candidate(num = 567890123,k = 3) == 0\n assert candidate(num = 222222222,k = 5) == 0\n assert candidate(num = 12345678987654321,k = 7) == 0\n assert candidate(num = 999999999,k = 7) == 0\n assert candidate(num = 999999999,k = 3) == 7\n assert candidate(num = 864197532,k = 4) == 0\n assert candidate(num = 12301230123,k = 4) == 2\n assert candidate(num = 101010101010101010,k = 6) == 13\n assert candidate(num = 1000000000,k = 4) == 1\n assert candidate(num = 444444444,k = 5) == 0\n assert candidate(num = 222333444555,k = 4) == 0\n assert candidate(num = 1001001001001001001,k = 5) == 0\n assert candidate(num = 555555555,k = 5) == 0\n assert candidate(num = 7777777,k = 2) == 0\n"}, "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().divisorSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int divisorSubstrings(int num, int k) {", "container": "Solution", "callable": "divisorSubstrings", "parameters": [{"name": "num", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2270, "task_id": "number-of-ways-to-split-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of length n.\nnums contains a valid split at index i if the following are true:\n\nThe sum of the first i + 1 elements is greater than or equal to the sum of the last n - i - 1 elements.\nThere is at least one element to the right of i. That is, 0 <= i < n - 1.\n\nReturn the number of valid splits in nums.\n \nExample 1:\n\nInput: nums = [10,4,-8,7]\nOutput: 2\nExplanation: \nThere are three ways of splitting nums into two non-empty parts:\n- Split nums at index 0. Then, the first part is [10], and its sum is 10. The second part is [4,-8,7], and its sum is 3. Since 10 >= 3, i = 0 is a valid split.\n- Split nums at index 1. Then, the first part is [10,4], and its sum is 14. The second part is [-8,7], and its sum is -1. Since 14 >= -1, i = 1 is a valid split.\n- Split nums at index 2. Then, the first part is [10,4,-8], and its sum is 6. The second part is [7], and its sum is 7. Since 6 < 7, i = 2 is not a valid split.\nThus, the number of valid splits in nums is 2.\n\nExample 2:\n\nInput: nums = [2,3,1,0]\nOutput: 2\nExplanation: \nThere are two valid splits in nums:\n- Split nums at index 1. Then, the first part is [2,3], and its sum is 5. The second part is [1,0], and its sum is 1. Since 5 >= 1, i = 1 is a valid split. \n- Split nums at index 2. Then, the first part is [2,3,1], and its sum is 6. The second part is [0], and its sum is 0. Since 6 >= 0, i = 2 is a valid split.\n\n \nConstraints:\n\n2 <= nums.length <= 105\n-105 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-100000, -100000, -100000, -100000, -100000]) == 2\n assert candidate(nums = [1, -1, 1, -1, 1]) == 2\n assert candidate(nums = [100, -50, 50, -25, 25]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 5\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000]) == 2\n assert candidate(nums = [100000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 19\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [-1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [100000, -50000, 50000, -50000, 50000]) == 4\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100000]) == 0\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 2\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 6\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 7\n assert candidate(nums = [10, 4, -8, 7]) == 2\n assert candidate(nums = [2, 3, 1, 0]) == 2\n assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50]) == 19\n assert candidate(nums = [-1, -1, -1, -1, -1, 5, -1, -1, -1, -1, -1]) == 5\n assert candidate(nums = [100000, 0, -50000, 50000, -100000, 0, 50000, -50000, 100000, 0]) == 6\n assert candidate(nums = [10000, 20000, 30000, -10000, -20000, -30000, 40000]) == 4\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100]) == 19\n assert candidate(nums = [100000, -50000, 25000, -12500, 6250, -3125, 1562]) == 6\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 6\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 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]) == 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]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [50, 25, 12, 6, 3, 1, 0, -1, -3, -6, -12, -25, -50, 100, 200]) == 0\n assert candidate(nums = [-100, 200, -300, 400, -500, 600, -700, 800, -900, 1000, -1100, 1200, -1300, 1400, -1500, 1600, -1700, 1800, -1900, 2000]) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, -600, -700, -800, -900, -1000]) == 8\n assert candidate(nums = [10000, 20000, 30000, -60000, 40000, 50000, -100000, 60000, 70000, 80000]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 19\n assert candidate(nums = [-5, -1, -4, -2, -3, -6, -7, -8, -9, -10]) == 6\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50, 60, 70, 80, 90, 100]) == 2\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]) == 20\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 5500]) == 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]) == 15\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 9\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 2\n assert candidate(nums = [5, 2, -3, 1, 4, 6, -2, 8, -5, 3]) == 4\n assert candidate(nums = [-150, -140, -130, -120, -110, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 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]) == 19\n assert candidate(nums = [100000, 0, -100000, 0, 100000, 0, -100000, 0, 100000]) == 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]) == 15\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 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]) == 15\n assert candidate(nums = [5, 2, 3, 7, 4, 1, 6, 8]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -10]) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -550]) == 10\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10]) == 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, 100]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 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]) == 10\n assert candidate(nums = [10, -5, 20, -10, 30, -15, 40, -20, 50, -25, 60, -30]) == 4\n assert candidate(nums = [100, 200, 300, -600, 100, 200, 300]) == 3\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 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, 10, -10]) == 19\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, -10000, -20000, -30000, -40000, -50000]) == 9\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 3\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == 15\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 55]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 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]) == 6\n assert candidate(nums = [100000, 50000, -25000, -25000, 10000, -10000, 1000, -1000, 100, -100, 10, -10, 1, -1]) == 13\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]) == 21\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 7\n assert candidate(nums = [100000, -50000, 50000, -50000, 50000, -50000, 50000, -50000, 50000, -50000]) == 9\n assert candidate(nums = [100000, -50000, -30000, -20000, 10000, 5000, 2500, 1250, 625, 313]) == 8\n assert candidate(nums = [50000, 50000, -100000, 25000, 25000, 25000, 25000]) == 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]) == 19\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 2\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, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 20\n assert candidate(nums = [99999, -99999, 99998, -99998, 99997, -99997, 99996, -99996, 99995, -99995]) == 9\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, -1500000]) == 5\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 9\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]) == 15\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, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, -5, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [-100, -200, -300, -400, -500, 600, 700, 800, 900, 1000]) == 1\n assert candidate(nums = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60]) == 11\n assert candidate(nums = [-5, -2, -3, -7, -4, -1, -6, -8]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 4\n assert candidate(nums = [5, 3, -5, 2, -3, 3, 9, -10, 4]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().waysToSplitArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int waysToSplitArray(int[] nums) {", "container": "Solution", "callable": "waysToSplitArray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2271, "task_id": "maximum-white-tiles-covered-by-a-carpet", "difficulty": "Medium", "problem_description": "You are given a 2D integer array tiles where tiles[i] = [li, ri] represents that every tile j in the range li <= j <= ri is colored white.\nYou are also given an integer carpetLen, the length of a single carpet that can be placed anywhere.\nReturn the maximum number of white tiles that can be covered by the carpet.\n \nExample 1:\n\n\nInput: tiles = [[1,5],[10,11],[12,18],[20,25],[30,32]], carpetLen = 10\nOutput: 9\nExplanation: Place the carpet starting on tile 10. \nIt covers 9 white tiles, so we return 9.\nNote that there may be other places where the carpet covers 9 white tiles.\nIt can be shown that the carpet cannot cover more than 9 white tiles.\n\nExample 2:\n\n\nInput: tiles = [[10,11],[1,1]], carpetLen = 2\nOutput: 2\nExplanation: Place the carpet starting on tile 10. \nIt covers 2 white tiles, so we return 2.\n\n \nConstraints:\n\n1 <= tiles.length <= 5 * 104\ntiles[i].length == 2\n1 <= li <= ri <= 109\n1 <= carpetLen <= 109\nThe tiles are non-overlapping.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tiles = [[1, 1000000000]],carpetLen = 1000000000) == 1000000000\n assert candidate(tiles = [[1, 10], [11, 20], [21, 30]],carpetLen = 15) == 15\n assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11]],carpetLen = 3) == 2\n assert candidate(tiles = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],carpetLen = 3) == 3\n assert candidate(tiles = [[1, 100]],carpetLen = 50) == 50\n assert candidate(tiles = [[1, 3], [5, 7], [9, 11]],carpetLen = 10) == 8\n assert candidate(tiles = [[3, 6], [8, 10], [12, 15], [18, 20]],carpetLen = 8) == 7\n assert candidate(tiles = [[3, 7], [10, 15], [18, 20]],carpetLen = 8) == 6\n assert candidate(tiles = [[1, 10], [20, 30], [40, 50]],carpetLen = 15) == 11\n assert candidate(tiles = [[3, 6], [8, 10], [12, 15]],carpetLen = 5) == 4\n assert candidate(tiles = [[1, 3], [6, 8], [9, 12]],carpetLen = 5) == 5\n assert candidate(tiles = [[1, 3], [6, 10], [12, 14], [16, 18]],carpetLen = 5) == 5\n assert candidate(tiles = [[1, 5], [10, 11], [12, 18], [20, 25], [30, 32]],carpetLen = 10) == 9\n assert candidate(tiles = [[10, 11], [1, 1]],carpetLen = 2) == 2\n assert candidate(tiles = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],carpetLen = 10) == 10\n assert candidate(tiles = [[2, 5], [8, 10], [12, 15], [18, 25], [30, 35], [40, 50]],carpetLen = 12) == 11\n assert candidate(tiles = [[1, 2], [4, 8], [10, 14], [16, 20], [22, 26], [28, 32], [34, 38], [40, 44], [46, 50]],carpetLen = 10) == 9\n assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23], [25, 27], [29, 31]],carpetLen = 4) == 3\n assert candidate(tiles = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70]],carpetLen = 25) == 17\n assert candidate(tiles = [[1, 5], [7, 10], [15, 20], [25, 30], [35, 40]],carpetLen = 12) == 9\n assert candidate(tiles = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30], [32, 34], [36, 38], [40, 42]],carpetLen = 10) == 8\n assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14]],carpetLen = 4) == 3\n assert candidate(tiles = [[1, 5], [10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75]],carpetLen = 12) == 8\n assert candidate(tiles = [[1, 100], [200, 300], [400, 500], [600, 700], [800, 900]],carpetLen = 150) == 101\n assert candidate(tiles = [[1, 1000000000]],carpetLen = 500000000) == 500000000\n assert candidate(tiles = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75], [80, 85], [90, 95]],carpetLen = 30) == 18\n assert candidate(tiles = [[1, 100], [200, 300], [400, 500], [600, 700], [800, 900]],carpetLen = 200) == 101\n assert candidate(tiles = [[1, 5], [10, 14], [20, 24], [30, 34], [40, 44], [50, 54]],carpetLen = 10) == 6\n assert candidate(tiles = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30], [31, 35]],carpetLen = 10) == 10\n assert candidate(tiles = [[1, 3], [6, 8], [11, 13], [16, 18], [21, 23], [26, 28], [31, 33], [36, 38], [41, 43], [46, 48]],carpetLen = 5) == 3\n assert candidate(tiles = [[5, 9], [15, 29], [35, 49], [55, 69], [75, 89], [95, 109]],carpetLen = 20) == 15\n assert candidate(tiles = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],carpetLen = 15) == 11\n assert candidate(tiles = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75], [80, 85]],carpetLen = 20) == 12\n assert candidate(tiles = [[1, 10], [20, 30], [40, 50], [60, 70], [80, 90]],carpetLen = 15) == 11\n assert candidate(tiles = [[1, 20], [25, 40], [45, 60], [65, 80], [85, 100]],carpetLen = 20) == 20\n assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23], [25, 27], [29, 31], [33, 35], [37, 39]],carpetLen = 7) == 6\n assert candidate(tiles = [[1, 10], [21, 30], [41, 50], [61, 70], [81, 90], [101, 110]],carpetLen = 20) == 10\n assert candidate(tiles = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120], [130, 140], [150, 160]],carpetLen = 25) == 16\n assert candidate(tiles = [[1, 200], [400, 600], [800, 1000], [1200, 1400], [1600, 1800]],carpetLen = 350) == 201\n assert candidate(tiles = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30]],carpetLen = 5) == 4\n assert candidate(tiles = [[2, 6], [9, 14], [17, 22], [25, 30], [33, 38], [41, 46]],carpetLen = 20) == 16\n assert candidate(tiles = [[5, 10], [20, 25], [35, 40], [55, 60], [65, 70]],carpetLen = 15) == 11\n assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23], [25, 27]],carpetLen = 5) == 4\n assert candidate(tiles = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],carpetLen = 35) == 22\n assert candidate(tiles = [[1, 5], [8, 12], [15, 20], [25, 30], [35, 40]],carpetLen = 15) == 11\n assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]],carpetLen = 3) == 2\n assert candidate(tiles = [[2, 5], [8, 15], [18, 25], [30, 35], [40, 50], [55, 60]],carpetLen = 15) == 13\n assert candidate(tiles = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30]],carpetLen = 7) == 6\n assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17]],carpetLen = 3) == 2\n assert candidate(tiles = [[1, 5], [10, 14], [20, 24], [30, 34], [40, 44], [50, 54], [60, 64], [70, 74], [80, 84], [90, 94]],carpetLen = 10) == 6\n assert candidate(tiles = [[1, 20], [25, 40], [45, 60], [65, 80], [85, 100]],carpetLen = 30) == 26\n assert candidate(tiles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],carpetLen = 4) == 7\n assert candidate(tiles = [[1, 3], [6, 8], [11, 13], [16, 18], [21, 23], [26, 28]],carpetLen = 5) == 3\n assert candidate(tiles = [[5, 10], [20, 25], [35, 40], [50, 55], [60, 65], [70, 75], [80, 85]],carpetLen = 20) == 12\n assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],carpetLen = 12) == 9\n assert candidate(tiles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],carpetLen = 5) == 9\n assert candidate(tiles = [[1, 5], [7, 15], [20, 30], [35, 45], [50, 60], [65, 75]],carpetLen = 12) == 11\n assert candidate(tiles = [[1, 5], [10, 15], [20, 25], [30, 35], [40, 45]],carpetLen = 12) == 8\n assert candidate(tiles = [[1, 3], [10, 12], [20, 22], [30, 32], [40, 42], [50, 52], [60, 62]],carpetLen = 5) == 3\n assert candidate(tiles = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60]],carpetLen = 15) == 11\n assert candidate(tiles = [[1, 3], [10, 12], [20, 22], [30, 32], [40, 42]],carpetLen = 4) == 3\n assert candidate(tiles = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [19, 21], [22, 24]],carpetLen = 10) == 10\n assert candidate(tiles = [[1, 3], [5, 8], [10, 14], [18, 22], [26, 30], [34, 38]],carpetLen = 6) == 5\n assert candidate(tiles = [[1, 5], [10, 14], [19, 23], [28, 32], [37, 41], [46, 50]],carpetLen = 10) == 6\n assert candidate(tiles = [[1, 500000000], [500000001, 1000000000]],carpetLen = 600000000) == 600000000\n assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]],carpetLen = 4) == 3\n assert candidate(tiles = [[2, 5], [8, 11], [15, 18], [22, 25], [29, 32]],carpetLen = 10) == 8\n assert candidate(tiles = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]],carpetLen = 12) == 12\n assert candidate(tiles = [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30]],carpetLen = 3) == 2\n assert candidate(tiles = [[1, 50], [100, 150], [200, 250], [300, 350], [400, 450], [500, 550]],carpetLen = 75) == 51\n assert candidate(tiles = [[1, 3], [6, 8], [11, 13], [16, 18], [21, 23], [26, 28], [31, 33]],carpetLen = 6) == 4\n assert candidate(tiles = [[2, 4], [8, 12], [16, 20], [24, 28], [32, 36]],carpetLen = 8) == 5\n assert candidate(tiles = [[1, 3], [6, 9], [12, 15], [18, 21], [24, 27], [30, 33]],carpetLen = 10) == 8\n assert candidate(tiles = [[5, 7], [10, 12], [15, 17], [20, 22], [25, 27], [30, 32], [35, 37]],carpetLen = 7) == 5\n assert candidate(tiles = [[1, 5], [7, 11], [13, 17], [19, 23], [25, 29], [31, 35]],carpetLen = 15) == 13\n assert candidate(tiles = [[1, 1000000], [2000000, 3000000], [4000000, 5000000], [6000000, 7000000]],carpetLen = 1500000) == 1000001\n assert candidate(tiles = [[5, 10], [20, 25], [35, 40], [55, 60], [75, 80], [95, 100]],carpetLen = 30) == 12\n assert candidate(tiles = [[1, 10], [20, 30], [40, 50], [60, 70], [80, 90]],carpetLen = 25) == 16\n assert candidate(tiles = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000]],carpetLen = 150) == 101\n assert candidate(tiles = [[1, 50], [100, 150], [200, 250], [300, 350], [400, 450]],carpetLen = 100) == 51\n assert candidate(tiles = [[1, 5], [10, 14], [18, 22], [26, 30]],carpetLen = 7) == 5\n assert candidate(tiles = [[1, 10], [20, 30], [40, 50], [60, 70], [80, 90], [100, 110]],carpetLen = 25) == 16\n assert candidate(tiles = [[1, 3], [6, 8], [11, 13], [16, 18], [21, 23]],carpetLen = 7) == 5\n assert candidate(tiles = [[1, 2], [4, 8], [10, 14], [16, 20], [22, 26], [28, 32]],carpetLen = 8) == 7\n assert candidate(tiles = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30], [32, 34]],carpetLen = 10) == 8\n assert candidate(tiles = [[1, 1000000000]],carpetLen = 999999999) == 999999999\n assert candidate(tiles = [[1, 100], [200, 300], [400, 500], [600, 700], [800, 900]],carpetLen = 100) == 100\n assert candidate(tiles = [[1, 100], [200, 300], [400, 500], [600, 700], [800, 900]],carpetLen = 50) == 50\n assert candidate(tiles = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000]],carpetLen = 500) == 302\n assert candidate(tiles = [[1, 10], [15, 20], [25, 30], [35, 40], [45, 50]],carpetLen = 15) == 11\n assert candidate(tiles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],carpetLen = 5) == 5\n assert candidate(tiles = [[1, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70]],carpetLen = 18) == 14\n assert candidate(tiles = [[1, 10], [15, 20], [25, 30], [35, 40], [45, 50]],carpetLen = 12) == 10\n assert candidate(tiles = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],carpetLen = 15) == 15\n assert candidate(tiles = [[1, 50], [100, 150], [200, 250], [300, 350], [400, 450]],carpetLen = 150) == 101\n assert candidate(tiles = [[1, 20], [40, 60], [80, 100], [120, 140], [160, 180]],carpetLen = 35) == 21\n assert candidate(tiles = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],carpetLen = 5) == 5\n assert candidate(tiles = [[1, 5], [10, 20], [25, 30], [35, 40], [45, 50], [55, 60]],carpetLen = 10) == 10\n assert candidate(tiles = [[100, 150], [200, 250], [300, 350], [400, 450], [500, 550], [600, 650], [700, 750]],carpetLen = 100) == 51\n assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],carpetLen = 5) == 4\n assert candidate(tiles = [[2, 5], [8, 15], [20, 25], [30, 40], [45, 55]],carpetLen = 12) == 11\n assert candidate(tiles = [[5, 9], [15, 19], [25, 29], [35, 39], [45, 49]],carpetLen = 10) == 5\n assert candidate(tiles = [[10, 14], [15, 19], [20, 24], [25, 29], [30, 34], [35, 39]],carpetLen = 15) == 15\n assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19]],carpetLen = 6) == 5\n assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]],carpetLen = 5) == 4\n assert candidate(tiles = [[1, 10], [20, 30], [40, 50], [60, 70], [80, 90], [100, 110]],carpetLen = 15) == 11\n assert candidate(tiles = [[1, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60]],carpetLen = 12) == 10\n assert candidate(tiles = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000]],carpetLen = 250) == 151\n assert candidate(tiles = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120], [130, 140]],carpetLen = 25) == 16\n assert candidate(tiles = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50]],carpetLen = 15) == 11\n assert candidate(tiles = [[1, 2], [10, 11], [20, 21], [30, 31], [40, 41], [50, 51], [60, 61], [70, 71], [80, 81], [90, 91]],carpetLen = 2) == 2\n"}, "metadata": {"canonical_parameter_names": ["tiles", "carpetLen"], "leetcode_dataset_entry_point": "Solution().maximumWhiteTiles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumWhiteTiles(int[][] tiles, int carpetLen) {", "container": "Solution", "callable": "maximumWhiteTiles", "parameters": [{"name": "tiles", "type": "int[][]"}, {"name": "carpetLen", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2272, "task_id": "substring-with-largest-variance", "difficulty": "Hard", "problem_description": "The variance of a string is defined as the largest difference between the number of occurrences of any 2 characters present in the string. Note the two characters may or may not be the same.\nGiven a string s consisting of lowercase English letters only, return the largest variance possible among all substrings of s.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"aababbb\"\nOutput: 3\nExplanation:\nAll possible variances along with their respective substrings are listed below:\n- Variance 0 for substrings \"a\", \"aa\", \"ab\", \"abab\", \"aababb\", \"ba\", \"b\", \"bb\", and \"bbb\".\n- Variance 1 for substrings \"aab\", \"aba\", \"abb\", \"aabab\", \"ababb\", \"aababbb\", and \"bab\".\n- Variance 2 for substrings \"aaba\", \"ababbb\", \"abbb\", and \"babb\".\n- Variance 3 for substring \"babbb\".\nSince the largest possible variance is 3, we return it.\n\nExample 2:\n\nInput: s = \"abcde\"\nOutput: 0\nExplanation:\nNo letter occurs more than once in s, so the variance of every substring is 0.\n\n \nConstraints:\n\n1 <= s.length <= 104\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzy\") == 5\n assert candidate(s = \"zyzzyzyzy\") == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"abbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"abbaabbaabba\") == 2\n assert candidate(s = \"abababab\") == 1\n assert candidate(s = \"aaaaa\") == 0\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"abcabcabc\") == 1\n assert candidate(s = \"zzyzxzyzyzxzyzxzyzxzyzxzyzxzyzxzyz\") == 11\n assert candidate(s = \"abcabcabcabc\") == 1\n assert candidate(s = \"abcde\") == 0\n assert candidate(s = \"leetcode\") == 2\n assert candidate(s = \"xyzxyzxyz\") == 1\n assert candidate(s = \"abccccccc\") == 6\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"zzzzzyyyyxxxxwwwwvvvvuuuuttttssssrrrrqqqqppppllllkkkkjjjjiiiihhhhggggffffffeee ddcccbbbbaaaa\") == 5\n assert candidate(s = \"aabbcc\") == 1\n assert candidate(s = \"mississippi\") == 3\n assert candidate(s = \"abcdefghij\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 1\n assert candidate(s = \"aabbaaabb\") == 3\n assert candidate(s = \"abacaba\") == 3\n assert candidate(s = \"aababbb\") == 3\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().largestVariance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int largestVariance(String s) {", "container": "Solution", "callable": "largestVariance", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2273, "task_id": "find-resultant-array-after-removing-anagrams", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string array words, where words[i] consists of lowercase English letters.\nIn one operation, select any index i such that 0 < i < words.length and words[i - 1] and words[i] are anagrams, and delete words[i] from words. Keep performing this operation as long as you can select an index that satisfies the conditions.\nReturn words after performing all operations. It can be shown that selecting the indices for each operation in any arbitrary order will lead to the same result.\nAn Anagram is a word or phrase formed by rearranging the letters of a different word or phrase using all the original letters exactly once. For example, \"dacb\" is an anagram of \"abdc\".\n \nExample 1:\n\nInput: words = [\"abba\",\"baba\",\"bbaa\",\"cd\",\"cd\"]\nOutput: [\"abba\",\"cd\"]\nExplanation:\nOne of the ways we can obtain the resultant array is by using the following operations:\n- Since words[2] = \"bbaa\" and words[1] = \"baba\" are anagrams, we choose index 2 and delete words[2].\n Now words = [\"abba\",\"baba\",\"cd\",\"cd\"].\n- Since words[1] = \"baba\" and words[0] = \"abba\" are anagrams, we choose index 1 and delete words[1].\n Now words = [\"abba\",\"cd\",\"cd\"].\n- Since words[2] = \"cd\" and words[1] = \"cd\" are anagrams, we choose index 2 and delete words[2].\n Now words = [\"abba\",\"cd\"].\nWe can no longer perform any operations, so [\"abba\",\"cd\"] is the final answer.\nExample 2:\n\nInput: words = [\"a\",\"b\",\"c\",\"d\",\"e\"]\nOutput: [\"a\",\"b\",\"c\",\"d\",\"e\"]\nExplanation:\nNo two adjacent strings in words are anagrams of each other, so no operations are performed.\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 10\nwords[i] consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'cab', 'bca', 'xyz', 'zyx', 'yxz']) == ['abc', 'xyz']\n assert candidate(words = ['abc', 'cba', 'bca', 'xyz', 'zyx']) == ['abc', 'xyz']\n assert candidate(words = ['unique', 'words', 'here', 'now']) == ['unique', 'words', 'here', 'now']\n assert candidate(words = ['test', 'sett', 'tset', 'ttew']) == ['test', 'ttew']\n assert candidate(words = ['same', 'same', 'same', 'same', 'same']) == ['same']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e']) == ['a', 'b', 'c', 'd', 'e']\n assert candidate(words = ['aabbcc', 'abcabc', 'bcaacb', 'bacbac', 'cababc']) == ['aabbcc']\n assert candidate(words = ['test', 'sett', 'tset', 'stet', 'ttes']) == ['test']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']) == ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']\n assert candidate(words = ['hello', 'billion', 'oellh', 'llheo', 'note', 'tone']) == ['hello', 'billion', 'oellh', 'note']\n assert candidate(words = ['abc', 'cab', 'bac', 'bca', 'xyz']) == ['abc', 'xyz']\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd']) == ['abcd']\n assert candidate(words = ['hello', 'olleh', 'world', 'dlrow', 'python', 'nohtyp']) == ['hello', 'world', 'python']\n assert candidate(words = ['abba', 'baba', 'bbaa', 'cd', 'cd']) == ['abba', 'cd']\n assert candidate(words = ['deed', 'deep', 'peed', 'depe', 'dpee']) == ['deed', 'deep']\n assert candidate(words = ['hello', 'world', 'dlrow', 'owrld', 'worlc']) == ['hello', 'world', 'worlc']\n assert candidate(words = ['same', 'same', 'same', 'same']) == ['same']\n assert candidate(words = ['abc', 'cba', 'bac', 'bca', 'cab', 'acb']) == ['abc']\n assert candidate(words = ['aaa', 'aa', 'a', 'aaaa', 'aaa']) == ['aaa', 'aa', 'a', 'aaaa', 'aaa']\n assert candidate(words = ['aabbcc', 'baccab', 'abcabc', 'xyz', 'zyx', 'yxz']) == ['aabbcc', 'xyz']\n assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl']) == ['listen', 'google']\n assert candidate(words = ['abc', 'cab', 'bac', 'bca', 'acb', 'cba']) == ['abc']\n assert candidate(words = ['aaa', 'aa', 'a']) == ['aaa', 'aa', 'a']\n assert candidate(words = ['deed', 'deed', 'deed', 'deed', 'deed']) == ['deed']\n assert candidate(words = ['hello', 'world', 'dlrow', 'owrld', 'werld', 'hello', 'olleh', 'dlrow', 'world', 'rowld', 'dlrow', 'hello', 'hello', 'world', 'world', 'world', 'dlrow', 'dlrow', 'dlrow', 'dlrow']) == ['hello', 'world', 'werld', 'hello', 'dlrow', 'hello', 'world']\n assert candidate(words = ['triangle', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral']) == ['triangle']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e']) == ['a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e']\n assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'cab', 'bac', 'xyz', 'zyx', 'yxz']) == ['listen', 'google', 'abc', 'xyz']\n assert candidate(words = ['rat', 'car', 'tar', 'arc', 'art', 'cat', 'tac', 'act', 'rat', 'car']) == ['rat', 'car', 'tar', 'arc', 'art', 'cat', 'rat', 'car']\n assert candidate(words = ['racecar', 'carrace', 'acecar', 'enlist', 'inlets', 'silent', 'google', 'gooegl', 'abc', 'bac', 'cba', 'xyz', 'zyx', 'yxz', 'zyx', 'xyz', 'listen', 'silent', 'enlist']) == ['racecar', 'acecar', 'enlist', 'google', 'abc', 'xyz', 'listen']\n assert candidate(words = ['aabbcc', 'aabbc', 'aabc', 'abc', 'ab', 'a', 'abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd', 'mnop', 'ponm', 'omnp', 'nmop', 'mpno', 'pmno']) == ['aabbcc', 'aabbc', 'aabc', 'abc', 'ab', 'a', 'abcd', 'mnop']\n assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba']) == ['ab']\n assert candidate(words = ['hello', 'olleh', 'loleh', 'ohell', 'ehlol', 'world', 'dlrow', 'rowld', 'owlrd', 'wrold', 'hello', 'olleh', 'loleh', 'ohell', 'ehlol']) == ['hello', 'world', 'hello']\n assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'cab', 'bac', 'xyz', 'zyx', 'zyxw', 'wxyz']) == ['listen', 'google', 'abc', 'xyz', 'zyxw']\n assert candidate(words = ['abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd', 'abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd', 'mnop', 'ponm', 'omnp', 'nmop', 'mpno', 'pmno']) == ['abcd', 'mnop']\n assert candidate(words = ['aabbcc', 'baccab', 'abcabc', 'xyz', 'zyx', 'yxz', 'test', 'sett', 'tset', 'stet', 'ttes']) == ['aabbcc', 'xyz', 'test']\n assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'cab', 'bac', 'bca', 'acb', 'cba', 'xyz', 'zyx', 'yxz']) == ['listen', 'google', 'abc', 'xyz']\n assert candidate(words = ['rat', 'tar', 'art', 'star', 'rats', 'tars', 'arts', 'tsar', 'chart', 'arch', 'cart', 'ract', 'track', 'krat', 'tract', 'crat', 'carr', 'rack', 'crab', 'back', 'bark', 'park', 'parking', 'arking', 'king', 'gnik', 'pink', 'kimp', 'pink', 'knip', 'kpin']) == ['rat', 'star', 'chart', 'arch', 'cart', 'track', 'krat', 'tract', 'crat', 'carr', 'rack', 'crab', 'back', 'bark', 'park', 'parking', 'arking', 'king', 'pink', 'kimp', 'pink']\n assert candidate(words = ['rat', 'tar', 'art', 'car', 'arc', 'par', 'arp', 'arc', 'rac', 'cat', 'tac', 'act', 'cta', 'atc', 'tca', 'pqr', 'qrp', 'rpq', 'prq', 'rqp', 'qpr', 'aabb', 'bbaa', 'abab', 'abba', 'aaaa', 'bbba', 'baab', 'aabb', 'baba', 'bbaa', 'cd', 'cd', 'efg', 'feg', 'gfe', 'geg', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz']) == ['rat', 'car', 'par', 'arc', 'cat', 'pqr', 'aabb', 'aaaa', 'bbba', 'baab', 'cd', 'efg', 'geg', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz']\n assert candidate(words = ['race', 'care', 'acre', 'racecar', 'carrace', 'racecar', 'carrace', 'abc', 'bca', 'cab', 'xyz', 'zyx', 'yxz', 'zyxzyx', 'xzyzyz', 'yzyzyx']) == ['race', 'racecar', 'abc', 'xyz', 'zyxzyx', 'xzyzyz', 'yzyzyx']\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == ['abcd']\n assert candidate(words = ['aaaa', 'aaab', 'aabb', 'abbb', 'bbbb', 'bbb', 'bb', 'b', 'a', 'abc', 'bac', 'cba', 'bca', 'cab', 'acb', 'xyz', 'zyx', 'yxz']) == ['aaaa', 'aaab', 'aabb', 'abbb', 'bbbb', 'bbb', 'bb', 'b', 'a', 'abc', 'xyz']\n assert candidate(words = ['rat', 'tar', 'art', 'dog', 'god', 'cat', 'act', 'tac', 'tack', 'rack', 'track', 'chart', 'cart']) == ['rat', 'dog', 'cat', 'tack', 'rack', 'track', 'chart', 'cart']\n assert candidate(words = ['abcde', 'edcba', 'decba', 'acdeb', 'badce', 'abcde', 'edcba', 'decba', 'acdeb', 'badce', 'abcde', 'edcba', 'decba', 'acdeb', 'badce', 'abcde', 'edcba', 'decba', 'acdeb', 'badce']) == ['abcde']\n assert candidate(words = ['anagram', 'nagaram', 'margana', 'anagram', 'margana', 'anagram', 'nagaram', 'margana', 'anagram', 'nagaram', 'margana', 'anagram', 'nagaram', 'margana', 'anagram', 'nagaram', 'margana', 'anagram', 'nagaram', 'margana']) == ['anagram']\n assert candidate(words = ['python', 'typhon', 'hypton', 'ypthon', 'phonto', 'opynth', 'ypthon', 'phonto', 'opynth', 'ypthon', 'phonto', 'opynth', 'ypthon', 'phonto', 'opynth']) == ['python', 'phonto', 'opynth', 'phonto', 'opynth', 'phonto', 'opynth', 'phonto', 'opynth']\n assert candidate(words = ['dormitory', 'dirtyroom', 'dirtyroom', 'dormitory', 'dirtyroom', 'dirtyroom', 'dormitory']) == ['dormitory']\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == ['abcd']\n assert candidate(words = ['aaaaa', 'aaabb', 'aabba', 'abbaa', 'baaab', 'baaba', 'bbaaa', 'abcde', 'edcba', 'decba', 'cbade', 'badec']) == ['aaaaa', 'aaabb', 'abcde']\n assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'bca', 'cab', 'xyz', 'zyx', 'yxz']) == ['listen', 'google', 'abc', 'xyz']\n assert candidate(words = ['race', 'care', 'acre', 'barc', 'racecar', 'carrace', 'racecar', 'carecar', 'abcde', 'edcba', 'bcdea', 'deabc', 'acdeb', 'decab']) == ['race', 'barc', 'racecar', 'abcde']\n assert candidate(words = ['triangle', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral']) == ['triangle']\n assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'abccba', 'bacabc', 'aabbcc', 'abcd', 'dcba', 'cdab', 'bcda', 'badc', 'cabd']) == ['aabbcc', 'abcd']\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == ['abcd']\n assert candidate(words = ['rat', 'tar', 'art', 'dog', 'god', 'cat', 'act', 'tac', 'abc', 'bca', 'cab', 'xyz', 'zyx', 'yxz']) == ['rat', 'dog', 'cat', 'abc', 'xyz']\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyzabcdefghijkl', 'defghijklmnopqrstuvwxyzabc', 'jklmnopqrstuvwxyzabcdefghi', 'pqrsutvwxyzabcdefghijklmno', 'nopqrstuvwxyzabcdefghijklm', 'mnopqrstuvwxyzabcdefghijklmno', 'opqrstuvwxyzabcdefghijklmno', 'pqrsutvwxyzabcdefghijklmno', 'nopqrstuvwxyzabcdefghijklm', 'mnopqrstuvwxyzabcdefghijklmno', 'opqrstuvwxyzabcdefghijklmno', 'pqrsutvwxyzabcdefghijklmno', 'nopqrstuvwxyzabcdefghijklm', 'mnopqrstuvwxyzabcdefghijklmno', 'opqrstuvwxyzabcdefghijklmno', 'pqrsutvwxyzabcdefghijklmno', 'nopqrstuvwxyzabcdefghijklm', 'mnopqrstuvwxyzabcdefghijklmno', 'opqrstuvwxyzabcdefghijklmno', 'pqrsutvwxyzabcdefghijklmno']) == ['abcdefghijklmnopqrstuvwxyz', 'mnopqrstuvwxyzabcdefghijklmno', 'opqrstuvwxyzabcdefghijklmno', 'pqrsutvwxyzabcdefghijklmno', 'mnopqrstuvwxyzabcdefghijklmno', 'opqrstuvwxyzabcdefghijklmno', 'pqrsutvwxyzabcdefghijklmno', 'mnopqrstuvwxyzabcdefghijklmno', 'opqrstuvwxyzabcdefghijklmno', 'pqrsutvwxyzabcdefghijklmno', 'mnopqrstuvwxyzabcdefghijklmno', 'opqrstuvwxyzabcdefghijklmno', 'pqrsutvwxyzabcdefghijklmno']\n assert candidate(words = ['hello', 'olleh', 'world', 'dlrow', 'python', 'nothpy', 'java', 'avaj', 'abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd']) == ['hello', 'world', 'python', 'java', 'abcd']\n assert candidate(words = ['anagram', 'nagaram', 'margana', 'ramnaga', 'gnamar', 'gnamar', 'gnamra', 'gnamra', 'gnamra', 'gnamra', 'gnamra', 'gnamra', 'gnamra']) == ['anagram', 'gnamar']\n assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'bca', 'cab', 'xyz', 'zyx', 'zyx', 'xyz']) == ['listen', 'google', 'abc', 'xyz']\n assert candidate(words = ['aabbcc', 'baccab', 'cbaabc', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'xyz', 'zyx', 'yxz', 'zyx', 'xyz']) == ['aabbcc', 'abc', 'xyz']\n assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'cab', 'bac', 'xyz', 'zyx', 'yxz', 'uvw', 'vuw', 'wuv']) == ['listen', 'google', 'abc', 'xyz', 'uvw']\n assert candidate(words = ['abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd', 'abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd']) == ['abcd']\n assert candidate(words = ['python', 'typhon', 'nohtyp', 'ypthon', 'hypnot', 'python', 'typhon', 'nohtyp', 'ypthon', 'hypnot', 'python', 'typhon', 'nohtyp', 'ypthon', 'hypnot', 'python', 'typhon', 'nohtyp', 'ypthon', 'hypnot']) == ['python']\n assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'inlets']) == ['listen', 'google', 'inlets']\n assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'cabcab', 'abacbc', 'bbacac', 'acbbca', 'aabbbc', 'aabbbc', 'aabbbc']) == ['aabbcc', 'aabbbc']\n assert candidate(words = ['abcd', 'dcba', 'cdab', 'bacd', 'cadb', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == ['abcd']\n assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'xyz', 'zyx', 'yxz', 'mnop', 'ponm', 'omnp', 'nmop', 'mpno', 'pmno']) == ['aabbcc', 'xyz', 'mnop']\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba', 'zzzz', 'zzz', 'zz', 'z']) == ['abc', 'abcd', 'zzzz', 'zzz', 'zz', 'z']\n assert candidate(words = ['ab', 'ba', 'aabb', 'bbaa', 'abab', 'baba', 'abba', 'baab', 'ab', 'ba']) == ['ab', 'aabb', 'ab']\n assert candidate(words = ['aabbcc', 'baccab', 'abcabc', 'abc', 'bac', 'cab', 'bac', 'abc', 'bac', 'cab', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc']) == ['aabbcc', 'abc']\n assert candidate(words = ['abcd', 'dcba', 'abdc', 'cbad', 'bcad', 'adbc', 'dabc', 'cdab', 'dacb', 'cadb', 'acbd', 'bdac', 'bdca', 'abcd', 'dcba', 'abdc', 'cbad', 'bcad', 'adbc', 'dabc', 'cdab', 'dacb', 'cadb', 'acbd', 'bdac', 'bdca', 'abcd', 'dcba', 'abdc', 'cbad', 'bcad', 'adbc', 'dabc', 'cdab', 'dacb', 'cadb', 'acbd', 'bdac', 'bdca', 'abcd', 'dcba', 'abdc', 'cbad', 'bcad', 'adbc', 'dabc', 'cdab', 'dacb', 'cadb', 'acbd', 'bdac', 'bdca']) == ['abcd']\n assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'ccabba', 'cabacb', 'abcabc', 'aabbcc', 'xyzxyz', 'zyxzyx', 'yxzyxz', 'zyxzyx']) == ['aabbcc', 'xyzxyz']\n assert candidate(words = ['anagram', 'nagaram', 'margana', 'gnarama', 'granama', 'aaagmnr', 'ab', 'ba', 'abc', 'cba', 'abcd', 'dcba', 'xyz', 'zyx', 'yxz', 'test', 'sett', 'tset', 'stet', 'ttes', 'deed', 'deep', 'peed', 'depe', 'dpee', 'aabbcc', 'baccab', 'abcabc', 'rat', 'tar', 'art', 'dog', 'god', 'cat', 'act', 'tac', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba', 'zzzz', 'zzz', 'zz', 'z']) == ['anagram', 'ab', 'abc', 'abcd', 'xyz', 'test', 'deed', 'deep', 'aabbcc', 'rat', 'dog', 'cat', 'abcd', 'zzzz', 'zzz', 'zz', 'z']\n assert candidate(words = ['word', 'drow', 'dwor', 'owrd', 'abcd', 'dcba', 'cadb', 'bdac', 'abcd', 'dcba', 'cabd', 'bdac']) == ['word', 'abcd']\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'abdc', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd']) == ['abcd']\n assert candidate(words = ['anagram', 'nagaram', 'margana', 'anagram', 'nagaram', 'margana', 'anagram', 'nagaram']) == ['anagram']\n assert candidate(words = ['evil', 'vile', 'live', 'veil', 'liVE', 'EVIL']) == ['evil', 'liVE', 'EVIL']\n assert candidate(words = ['abcd', 'dcba', 'cdab', 'bacd', 'adcb', 'cbad', 'bcda', 'abcd', 'dcba', 'cdab', 'bacd', 'adcb', 'cbad', 'bcda']) == ['abcd']\n assert candidate(words = ['rat', 'tar', 'art', 'car', 'arc', 'arc', 'rca', 'arc', 'cat', 'tac', 'act', 'dog', 'god', 'god', 'ogd']) == ['rat', 'car', 'cat', 'dog']\n assert candidate(words = ['hello', 'billion', 'nillion', 'illonbi', 'onbilin', 'nnoblli', 'olnibin', 'lobinin', 'ollinbi', 'bloninl', 'bnoloni', 'noblinl', 'llinbon', 'lobinln', 'nilonbl', 'nonlibl', 'oblinln', 'nlonbil', 'oninlb', 'nobinll', 'binlonl', 'onlibnl', 'nbinlol', 'inlboon', 'libnoln', 'onilnbl', 'inlobnl', 'lnoibnl', 'nobllin', 'oinlnbl', 'onilb', 'nlibl', 'inlbn', 'lnbol', 'onbil', 'ilnob', 'lnoib', 'nlobi', 'olnib', 'blnio', 'bnlio', 'nliob', 'libon', 'inlob', 'onilb', 'nobil', 'inobl', 'onlbi', 'nobil', 'lobin', 'linbo', 'inolb', 'nolbi', 'libno', 'inlob', 'onilb', 'nobli', 'inobl', 'onlbi', 'nobil', 'lobin', 'linbo', 'inolb', 'nolbi', 'libno']) == ['hello', 'billion', 'nillion', 'illonbi', 'onbilin', 'nnoblli', 'olnibin', 'ollinbi', 'bloninl', 'bnoloni', 'noblinl', 'oninlb', 'nobinll', 'inlboon', 'libnoln', 'onilb', 'nlibl', 'inlbn', 'lnbol', 'onbil']\n assert candidate(words = ['aabb', 'abab', 'bbaa', 'abcd', 'dcba', 'cdab', 'bcda', 'mnop', 'ponm', 'opnm', 'nmop', 'qrst', 'srqt', 'qstr', 'tqrs', 'stqr', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd']) == ['aabb', 'abcd', 'mnop', 'qrst', 'abcd']\n assert candidate(words = ['triangle', 'integral', 'integral', 'integral', 'triangle', 'integral']) == ['triangle']\n assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'cab', 'bac', 'xyz', 'zyx', 'yxz', 'test', 'sett', 'tset', 'stet', 'ttes', 'deed', 'deep', 'peed', 'depe', 'dpee']) == ['listen', 'google', 'abc', 'xyz', 'test', 'deed', 'deep']\n assert candidate(words = ['deed', 'deep', 'peed', 'depe', 'dpee', 'abcd', 'dcba', 'cbad', 'adcb', 'bacd', 'cabd', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == ['deed', 'deep', 'abcd']\n assert candidate(words = ['aabbcc', 'bbaacc', 'abcabc', 'cccccc', 'bbbaaa', 'aabbcc', 'ccbbdd']) == ['aabbcc', 'cccccc', 'bbbaaa', 'aabbcc', 'ccbbdd']\n assert candidate(words = ['anagram', 'nagaram', 'margana', 'gnarham', 'ramnaga', 'gramana', 'amnagar', 'mangara', 'gnarama', 'ramagna', 'amnagra', 'agranam', 'mangnra', 'gnanram', 'rangnam', 'anagram', 'nagaram', 'margana', 'gnarham', 'ramnaga', 'gramana', 'amnagar', 'mangara', 'gnarama', 'ramagna', 'amnagra', 'agranam', 'mangnra', 'gnanram', 'rangnam']) == ['anagram', 'gnarham', 'ramnaga', 'mangnra', 'anagram', 'gnarham', 'ramnaga', 'mangnra']\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().removeAnagrams", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List removeAnagrams(String[] words) {", "container": "Solution", "callable": "removeAnagrams", "parameters": [{"name": "words", "type": "String[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2274, "task_id": "maximum-consecutive-floors-without-special-floors", "difficulty": "Medium", "problem_description": "Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be special floors, used for relaxation only.\nYou are given two integers bottom and top, which denote that Alice has rented all the floors from bottom to top (inclusive). You are also given the integer array special, where special[i] denotes a special floor that Alice has designated for relaxation.\nReturn the maximum number of consecutive floors without a special floor.\n \nExample 1:\n\nInput: bottom = 2, top = 9, special = [4,6]\nOutput: 3\nExplanation: The following are the ranges (inclusive) of consecutive floors without a special floor:\n- (2, 3) with a total amount of 2 floors.\n- (5, 5) with a total amount of 1 floor.\n- (7, 9) with a total amount of 3 floors.\nTherefore, we return the maximum number which is 3 floors.\n\nExample 2:\n\nInput: bottom = 6, top = 8, special = [7,6,8]\nOutput: 0\nExplanation: Every floor rented is a special floor, so we return 0.\n\n \nConstraints:\n\n1 <= special.length <= 105\n1 <= bottom <= special[i] <= top <= 109\nAll the values of special are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bottom = 3,top = 7,special = [3, 4, 5, 6, 7]) == 0\n assert candidate(bottom = 1,top = 1,special = [1]) == 0\n assert candidate(bottom = 1,top = 10,special = [3, 5, 7, 9]) == 2\n assert candidate(bottom = 6,top = 8,special = [7, 6, 8]) == 0\n assert candidate(bottom = 5,top = 15,special = [10]) == 5\n assert candidate(bottom = 3,top = 15,special = [3, 5, 7, 9, 11, 15]) == 3\n assert candidate(bottom = 1,top = 10,special = [2, 5, 8]) == 2\n assert candidate(bottom = 10,top = 20,special = [12, 14, 16, 18]) == 2\n assert candidate(bottom = 6,top = 8,special = [7, 6, 8]) == 0\n assert candidate(bottom = 2,top = 9,special = [4, 6]) == 3\n assert candidate(bottom = 10,top = 20,special = [12, 15, 18]) == 2\n assert candidate(bottom = 1,top = 10,special = [5]) == 5\n assert candidate(bottom = 10,top = 10,special = [10]) == 0\n assert candidate(bottom = 1,top = 1000000000,special = [500000000]) == 500000000\n assert candidate(bottom = 3,top = 7,special = [3, 4, 5, 6, 7]) == 0\n assert candidate(bottom = 1,top = 10,special = [3, 5, 7]) == 3\n assert candidate(bottom = 2,top = 9,special = [4, 6]) == 3\n assert candidate(bottom = 1,top = 100,special = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 9\n assert candidate(bottom = 1,top = 1000000,special = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000]) == 100000\n assert candidate(bottom = 2,top = 100,special = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 10\n assert candidate(bottom = 50,top = 200,special = [60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 10\n assert candidate(bottom = 1,top = 1000,special = [1, 500, 1000]) == 499\n assert candidate(bottom = 10,top = 20,special = [11, 13, 15, 17]) == 3\n assert candidate(bottom = 50,top = 200,special = [100, 150, 125]) == 50\n assert candidate(bottom = 5,top = 50,special = [10, 20, 30, 40]) == 10\n assert candidate(bottom = 1,top = 1000000000,special = [1000000000]) == 999999999\n assert candidate(bottom = 1,top = 1000000000,special = [1, 1000000000]) == 999999998\n assert candidate(bottom = 5,top = 25,special = [7, 13, 19]) == 6\n assert candidate(bottom = 1,top = 500,special = [250]) == 250\n assert candidate(bottom = 5,top = 20,special = [6, 8, 10, 12, 14, 16, 18]) == 2\n assert candidate(bottom = 1,top = 1000,special = [500, 750]) == 499\n assert candidate(bottom = 1,top = 1000,special = [500]) == 500\n assert candidate(bottom = 1,top = 50,special = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]) == 2\n assert candidate(bottom = 5,top = 15,special = [6, 11]) == 4\n assert candidate(bottom = 5,top = 15,special = [7, 10, 13]) == 2\n assert candidate(bottom = 10,top = 50,special = [15, 25, 35, 45]) == 9\n assert candidate(bottom = 10,top = 50,special = [15, 25, 35]) == 15\n assert candidate(bottom = 1,top = 50,special = [50]) == 49\n assert candidate(bottom = 1,top = 100,special = [2, 98]) == 95\n assert candidate(bottom = 5,top = 25,special = [10, 20]) == 9\n assert candidate(bottom = 1,top = 100,special = [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]) == 3\n assert candidate(bottom = 1,top = 100,special = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 81\n assert candidate(bottom = 1,top = 100,special = [50]) == 50\n assert candidate(bottom = 1,top = 1000,special = [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]) == 901\n assert candidate(bottom = 1,top = 100,special = [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, 100]) == 1\n assert candidate(bottom = 10,top = 20,special = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(bottom = 1,top = 1000000000,special = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000]) == 100000000\n assert candidate(bottom = 1,top = 1000,special = [10, 200, 300, 400, 500, 600, 700, 800, 900]) == 189\n assert candidate(bottom = 1,top = 50,special = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47]) == 3\n assert candidate(bottom = 100,top = 200,special = [120, 130, 140, 150, 160, 170, 180, 190]) == 20\n assert candidate(bottom = 1,top = 1000,special = [1, 1000]) == 998\n assert candidate(bottom = 1,top = 1000000000,special = [1, 500000000, 1000000000]) == 499999999\n assert candidate(bottom = 10,top = 20,special = [10, 12, 14, 16, 18, 20]) == 1\n assert candidate(bottom = 1,top = 1000,special = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 100\n assert candidate(bottom = 1,top = 1000000,special = [500000]) == 500000\n assert candidate(bottom = 5,top = 50,special = [15, 25, 35, 45]) == 10\n assert candidate(bottom = 50,top = 150,special = [51, 52, 53, 54, 55, 56, 57, 58, 59, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149]) == 40\n assert candidate(bottom = 1,top = 50,special = [25]) == 25\n assert candidate(bottom = 1,top = 2000000000,special = [1000000000]) == 1000000000\n assert candidate(bottom = 10,top = 100,special = [15, 35, 60, 85]) == 24\n assert candidate(bottom = 1,top = 100,special = [1, 2, 3, 4, 5, 96, 97, 98, 99, 100]) == 90\n assert candidate(bottom = 10,top = 1000,special = [150, 250, 350, 450, 550, 650, 750, 850, 950]) == 140\n assert candidate(bottom = 5,top = 50,special = [10, 15, 20, 25, 30, 35, 40, 45]) == 5\n assert candidate(bottom = 10,top = 20,special = [12, 15, 18]) == 2\n assert candidate(bottom = 1,top = 100,special = [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]) == 1\n assert candidate(bottom = 1,top = 100,special = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 10\n assert candidate(bottom = 10,top = 50,special = [12, 15, 20, 25, 30, 35, 40, 45]) == 5\n assert candidate(bottom = 10,top = 10000,special = [500, 2500, 4500, 6500, 8500]) == 1999\n assert candidate(bottom = 1,top = 100,special = [99]) == 98\n assert candidate(bottom = 1,top = 100,special = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 61\n assert candidate(bottom = 1,top = 100,special = [1, 100]) == 98\n assert candidate(bottom = 10,top = 100,special = [20, 40, 60, 80]) == 20\n assert candidate(bottom = 1,top = 1000000,special = [1, 2, 3, 4, 5, 999995, 999996, 999997, 999998, 999999]) == 999989\n assert candidate(bottom = 1,top = 20,special = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == 2\n assert candidate(bottom = 1,top = 20,special = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(bottom = 1,top = 10,special = [2, 4, 6, 8]) == 2\n assert candidate(bottom = 100,top = 200,special = [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]) == 1\n assert candidate(bottom = 100,top = 500,special = [200, 300, 400]) == 100\n assert candidate(bottom = 1,top = 100,special = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(bottom = 1,top = 20,special = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 1\n assert candidate(bottom = 10,top = 1000,special = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 100\n assert candidate(bottom = 1,top = 100,special = [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]) == 1\n assert candidate(bottom = 1,top = 50,special = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 29\n assert candidate(bottom = 20,top = 200,special = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 10\n assert candidate(bottom = 5,top = 50,special = [15, 25, 35, 45, 5, 40]) == 9\n assert candidate(bottom = 1,top = 100,special = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == 5\n assert candidate(bottom = 10,top = 50,special = [20, 30, 40]) == 10\n assert candidate(bottom = 1,top = 100,special = [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]) == 7\n assert candidate(bottom = 1,top = 10,special = [1, 3, 5, 7, 9]) == 1\n assert candidate(bottom = 1,top = 100,special = [5, 25, 45, 65, 85, 95]) == 19\n assert candidate(bottom = 10,top = 100,special = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 75\n assert candidate(bottom = 1,top = 100,special = [2, 25, 50, 75, 100]) == 24\n assert candidate(bottom = 1,top = 10,special = [2, 4, 6, 8, 10]) == 1\n"}, "metadata": {"canonical_parameter_names": ["bottom", "top", "special"], "leetcode_dataset_entry_point": "Solution().maxConsecutive", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxConsecutive(int bottom, int top, int[] special) {", "container": "Solution", "callable": "maxConsecutive", "parameters": [{"name": "bottom", "type": "int"}, {"name": "top", "type": "int"}, {"name": "special", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2275, "task_id": "largest-combination-with-bitwise-and-greater-than-zero", "difficulty": "Medium", "problem_description": "The bitwise AND of an array nums is the bitwise AND of all integers in nums.\n\nFor example, for nums = [1, 5, 3], the bitwise AND is equal to 1 & 5 & 3 = 1.\nAlso, for nums = [7], the bitwise AND is 7.\n\nYou are given an array of positive integers candidates. Compute the bitwise AND for all possible combinations of elements in the candidates array.\nReturn the size of the largest combination of candidates with a bitwise AND greater than 0.\n \nExample 1:\n\nInput: candidates = [16,17,71,62,12,24,14]\nOutput: 4\nExplanation: The combination [16,17,62,24] has a bitwise AND of 16 & 17 & 62 & 24 = 16 > 0.\nThe size of the combination is 4.\nIt can be shown that no combination with a size greater than 4 has a bitwise AND greater than 0.\nNote that more than one combination may have the largest size.\nFor example, the combination [62,12,24,14] has a bitwise AND of 62 & 12 & 24 & 14 = 8 > 0.\n\nExample 2:\n\nInput: candidates = [8,8]\nOutput: 2\nExplanation: The largest combination [8,8] has a bitwise AND of 8 & 8 = 8 > 0.\nThe size of the combination is 2, so we return 2.\n\n \nConstraints:\n\n1 <= candidates.length <= 105\n1 <= candidates[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(candidates = [16, 17, 71, 62, 12, 24, 14]) == 4\n assert candidate(candidates = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 16\n assert candidate(candidates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(candidates = [1, 10000000, 2, 9999999, 3, 9999998, 4, 9999997, 5, 9999996, 6, 9999995, 7, 9999994, 8, 9999993, 9, 9999992, 10, 9999991]) == 11\n assert candidate(candidates = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31]) == 10\n assert candidate(candidates = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(candidates = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == 10\n assert candidate(candidates = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1\n assert candidate(candidates = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(candidates = [8, 8]) == 2\n assert candidate(candidates = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 10\n assert candidate(candidates = [1048575, 1048574, 1048573, 1048572, 1048571]) == 5\n assert candidate(candidates = [10000000, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 2\n assert candidate(candidates = [31, 31, 31, 31, 31]) == 5\n assert candidate(candidates = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000]) == 10\n assert candidate(candidates = [536870911, 536870910, 536870909, 536870908, 536870907, 536870906, 536870905, 536870904, 536870903, 536870902, 536870901, 536870900, 536870899, 536870898, 536870897]) == 15\n assert candidate(candidates = [1073741823, 1073741822, 1073741821, 1073741820, 1073741819, 1073741818, 1073741817, 1073741816, 1073741815, 1073741814]) == 10\n assert candidate(candidates = [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(candidates = [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\n assert candidate(candidates = [1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 14\n assert candidate(candidates = [9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990, 9999989, 9999988, 9999987, 9999986, 9999985, 9999984, 9999983, 9999982, 9999981, 9999980]) == 20\n assert candidate(candidates = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642, 2147483641, 2147483640, 2147483639, 2147483638]) == 10\n assert candidate(candidates = [1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006, 1000007, 1000008, 1000009, 1000010, 1000011, 1000012, 1000013, 1000014, 1000015, 1000016, 1000017, 1000018, 1000019]) == 20\n assert candidate(candidates = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 1\n assert candidate(candidates = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643]) == 5\n assert candidate(candidates = [131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864]) == 1\n assert candidate(candidates = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912]) == 1\n assert candidate(candidates = [16777215, 16777214, 16777213, 16777212, 16777211, 16777210, 16777209, 16777208, 16777207, 16777206, 16777205, 16777204, 16777203, 16777202, 16777201]) == 15\n assert candidate(candidates = [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, 101, 105, 109, 113, 117]) == 30\n assert candidate(candidates = [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]) == 31\n assert candidate(candidates = [1234567, 7654321, 13579246, 24681357, 35792468, 46813579, 57924681, 68135792, 79246813, 81357924, 92468135]) == 7\n assert candidate(candidates = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == 11\n assert candidate(candidates = [524288, 524290, 524292, 524294, 524296, 524298, 524300, 524302, 524304, 524306, 524308, 524310, 524312, 524314, 524316, 524318, 524320, 524322, 524324, 524326]) == 20\n assert candidate(candidates = [5000000, 5000001, 5000002, 5000003, 5000004, 5000005, 5000006, 5000007, 5000008, 5000009, 5000010, 5000011, 5000012, 5000013, 5000014, 5000015, 5000016, 5000017, 5000018, 5000019, 5000020, 5000021, 5000022, 5000023, 5000024, 5000025, 5000026, 5000027, 5000028, 5000029, 5000030]) == 31\n assert candidate(candidates = [5000000, 4000000, 3000000, 2000000, 1000000, 500000, 400000, 300000, 200000, 100000, 50000, 40000, 30000, 20000, 10000, 5000, 4000, 3000, 2000, 1000, 500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 5]) == 16\n assert candidate(candidates = [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]) == 1\n assert candidate(candidates = [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]) == 29\n assert candidate(candidates = [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(candidates = [8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(candidates = [1048575, 2097150, 3145725, 4194300, 5242875, 6291450, 7340025, 8388500, 9437075, 10485650, 11534225, 12582800, 13631375, 14679950, 15728525, 16777100, 17825675, 18874250, 19922825, 20971400]) == 20\n assert candidate(candidates = [65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647]) == 16\n assert candidate(candidates = [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, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647]) == 31\n assert candidate(candidates = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004]) == 20\n assert candidate(candidates = [983040, 983041, 983042, 983043, 983044, 983045, 983046, 983047, 983048, 983049]) == 10\n assert candidate(candidates = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000, 14000000, 15000000]) == 10\n assert candidate(candidates = [9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990, 9999989, 9999988, 9999987, 9999986, 9999985, 9999984, 9999983, 9999982, 9999981, 9999980]) == 20\n assert candidate(candidates = [5000000, 5000001, 5000002, 5000003, 5000004, 5000005, 5000006, 5000007, 5000008, 5000009]) == 10\n assert candidate(candidates = [8388607, 8388606, 8388605, 8388604, 8388603, 8388602, 8388601, 8388600, 8388599, 8388598, 8388597, 8388596, 8388595, 8388594, 8388593, 8388592, 8388591, 8388590, 8388589, 8388588]) == 20\n assert candidate(candidates = [1073741823, 1073741822, 1073741821, 1073741820, 1073741819, 1073741818, 1073741817, 1073741816, 1073741815, 1073741814, 1073741813, 1073741812, 1073741811, 1073741810, 1073741809]) == 15\n assert candidate(candidates = [16777215, 16777214, 16777213, 16777212, 16777211, 16777210, 16777209, 16777208, 16777207, 16777206]) == 10\n assert candidate(candidates = [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]) == 16\n assert candidate(candidates = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 9\n assert candidate(candidates = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2\n assert candidate(candidates = [15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607]) == 20\n assert candidate(candidates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(candidates = [1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2\n assert candidate(candidates = [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864]) == 1\n assert candidate(candidates = [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151]) == 20\n assert candidate(candidates = [1023, 2047, 4095, 8191, 16383, 32767, 65535]) == 7\n assert candidate(candidates = [262143, 262142, 262141, 262140, 262139, 262138, 262137, 262136, 262135, 262134, 262133, 262132, 262131, 262130, 262129, 262128, 262127, 262126, 262125, 262124, 262123, 262122, 262121, 262120, 262119, 262118, 262117, 262116, 262115, 262114, 262113]) == 31\n assert candidate(candidates = [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]) == 32\n assert candidate(candidates = [2147483647, 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, 1]) == 2\n assert candidate(candidates = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 999999999, 99999999, 9999999, 999999, 99999]) == 9\n assert candidate(candidates = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 10\n assert candidate(candidates = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000]) == 15\n assert candidate(candidates = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 20\n assert candidate(candidates = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 20\n assert candidate(candidates = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647]) == 22\n assert candidate(candidates = [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, 67108863, 134217727, 268435455, 536870911]) == 29\n assert candidate(candidates = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912]) == 1\n assert candidate(candidates = [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]) == 29\n assert candidate(candidates = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(candidates = [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]) == 30\n assert candidate(candidates = [33554431, 67108863, 134217727, 268435455, 536870911, 1073741823]) == 6\n assert candidate(candidates = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531, 9765, 4882, 2441, 1220, 610, 305, 152, 76, 38, 19]) == 8\n assert candidate(candidates = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 62\n assert candidate(candidates = [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\n assert candidate(candidates = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287]) == 10\n assert candidate(candidates = [65535, 65534, 65533, 65532, 65531, 65530, 65529, 65528, 65527, 65526, 65525, 65524, 65523, 65522, 65521, 65520, 65519, 65518, 65517, 65516, 65515, 65514, 65513, 65512, 65511, 65510, 65509, 65508, 65507, 65506, 65505]) == 31\n assert candidate(candidates = [1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576]) == 10\n assert candidate(candidates = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000, 14000000, 15000000, 16000000, 17000000, 18000000, 19000000, 20000000]) == 11\n assert candidate(candidates = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1\n assert candidate(candidates = [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]) == 50\n assert candidate(candidates = [1000001, 2000002, 3000003, 4000004, 5000005, 6000006, 7000007, 8000008, 9000009, 10000010]) == 10\n assert candidate(candidates = [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]) == 16\n assert candidate(candidates = [33554431, 33554430, 33554429, 33554428, 33554427, 33554426, 33554425, 33554424, 33554423, 33554422, 33554421, 33554420, 33554419, 33554418, 33554417, 33554416, 33554415, 33554414, 33554413, 33554412, 33554411, 33554410, 33554409, 33554408, 33554407, 33554406, 33554405, 33554404, 33554403, 33554402, 33554401]) == 31\n assert candidate(candidates = [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\n assert candidate(candidates = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 10\n assert candidate(candidates = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1\n assert candidate(candidates = [15, 27, 51, 85, 129, 173, 217, 261, 305, 349, 393, 437, 481, 525, 569, 613, 657, 701, 745, 789, 833, 877, 921, 965, 1009, 1053, 1097, 1141, 1185, 1229]) == 30\n assert candidate(candidates = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990, 9999989, 9999988, 9999987, 9999986, 9999985, 9999984, 9999983, 9999982, 9999981]) == 20\n assert candidate(candidates = [10000000, 10000001, 10000002, 10000003, 10000004, 10000005, 10000006, 10000007, 10000008, 10000009]) == 10\n"}, "metadata": {"canonical_parameter_names": ["candidates"], "leetcode_dataset_entry_point": "Solution().largestCombination", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int largestCombination(int[] candidates) {", "container": "Solution", "callable": "largestCombination", "parameters": [{"name": "candidates", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2278, "task_id": "percentage-of-letter-in-string", "difficulty": "Easy", "problem_description": "Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent.\n \nExample 1:\n\nInput: s = \"foobar\", letter = \"o\"\nOutput: 33\nExplanation:\nThe percentage of characters in s that equal the letter 'o' is 2 / 6 * 100% = 33% when rounded down, so we return 33.\n\nExample 2:\n\nInput: s = \"jjjj\", letter = \"k\"\nOutput: 0\nExplanation:\nThe percentage of characters in s that equal the letter 'k' is 0%, so we return 0.\n \nConstraints:\n\n1 <= s.length <= 100\ns consists of lowercase English letters.\nletter is a lowercase English letter.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"jjjj\",letter = \"k\") == 0\n assert candidate(s = \"foobar\",letter = \"o\") == 33\n assert candidate(s = \"mississippi\",letter = \"i\") == 36\n assert candidate(s = \"python\",letter = \"y\") == 16\n assert candidate(s = \"abcabcabc\",letter = \"a\") == 33\n assert candidate(s = \"hello\",letter = \"l\") == 40\n assert candidate(s = \"world\",letter = \"d\") == 20\n assert candidate(s = \"zzzz\",letter = \"z\") == 100\n assert candidate(s = \"b\",letter = \"a\") == 0\n assert candidate(s = \"solution\",letter = \"o\") == 25\n assert candidate(s = \"aaaaabbbbb\",letter = \"b\") == 50\n assert candidate(s = \"a\",letter = \"a\") == 100\n assert candidate(s = \"abcdefg\",letter = \"h\") == 0\n assert candidate(s = \"zzzzzz\",letter = \"z\") == 100\n assert candidate(s = \"aabbcc\",letter = \"b\") == 33\n assert candidate(s = \"aabbccddeeff\",letter = \"c\") == 16\n assert candidate(s = \"abcdefg\",letter = \"a\") == 14\n assert candidate(s = \"zzzzzzzzz\",letter = \"z\") == 100\n assert candidate(s = \"abcdefg\",letter = \"x\") == 0\n assert candidate(s = \"characterization\",letter = \"c\") == 12\n assert candidate(s = \"examplewithrepeatedletterzzzz\",letter = \"z\") == 13\n assert candidate(s = \"qwertypoiuytrewqasdfghjklzxcvbnmasdfghjklzxcvbnm\",letter = \"q\") == 4\n assert candidate(s = \"oneletterone\",letter = \"n\") == 16\n assert candidate(s = \"parameter\",letter = \"r\") == 22\n assert candidate(s = \"alphabet\",letter = \"p\") == 12\n assert candidate(s = \"determinethepercentage\",letter = \"e\") == 31\n assert candidate(s = \"programming\",letter = \"m\") == 18\n assert candidate(s = \"supercalifragilisticexpialidocious\",letter = \"i\") == 20\n assert candidate(s = \"abracadabra\",letter = \"a\") == 45\n assert candidate(s = \"development\",letter = \"e\") == 27\n assert candidate(s = \"abcdefghij\",letter = \"a\") == 10\n assert candidate(s = \"abcdefghijk\",letter = \"a\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",letter = \"z\") == 100\n assert candidate(s = \"abcdefghij\",letter = \"j\") == 10\n assert candidate(s = \"visualization\",letter = \"i\") == 23\n assert candidate(s = \"programming\",letter = \"g\") == 18\n assert candidate(s = \"development\",letter = \"d\") == 9\n assert candidate(s = \"charactercounting\",letter = \"c\") == 17\n assert candidate(s = \"percentage\",letter = \"e\") == 30\n assert candidate(s = \"classification\",letter = \"f\") == 7\n assert candidate(s = \"environment\",letter = \"n\") == 27\n assert candidate(s = \"xyz\",letter = \"z\") == 33\n assert candidate(s = \"charactercountexample\",letter = \"e\") == 14\n assert candidate(s = \"testtesttesttest\",letter = \"t\") == 50\n assert candidate(s = \"computation\",letter = \"i\") == 9\n assert candidate(s = \"performance\",letter = \"n\") == 9\n assert candidate(s = \"understanding\",letter = \"d\") == 15\n assert candidate(s = \"consistencyiskey\",letter = \"i\") == 12\n assert candidate(s = \"xyxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyz\",letter = \"y\") == 33\n assert candidate(s = \"algorithm\",letter = \"g\") == 11\n assert candidate(s = \"representation\",letter = \"r\") == 14\n assert candidate(s = \"communication\",letter = \"m\") == 15\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",letter = \"z\") == 3\n assert candidate(s = \"mississippi\",letter = \"s\") == 36\n assert candidate(s = \"thisisaverylongstringwithrandomcharacters\",letter = \"t\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",letter = \"z\") == 100\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",letter = \"z\") == 100\n assert candidate(s = \"variable\",letter = \"b\") == 12\n assert candidate(s = \"pythonprogramming\",letter = \"p\") == 11\n assert candidate(s = \"xyzzxyzz\",letter = \"z\") == 50\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",letter = \"a\") == 3\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",letter = \"m\") == 3\n assert candidate(s = \"xylophone\",letter = \"p\") == 11\n assert candidate(s = \"characterization\",letter = \"t\") == 12\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",letter = \"z\") == 100\n assert candidate(s = \"synchronous\",letter = \"s\") == 18\n assert candidate(s = \"congratulations\",letter = \"t\") == 13\n assert candidate(s = \"mississippi\",letter = \"x\") == 0\n assert candidate(s = \"example\",letter = \"a\") == 14\n assert candidate(s = \"development\",letter = \"l\") == 9\n assert candidate(s = \"averylongstringwithvariouscharacters\",letter = \"a\") == 11\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",letter = \"z\") == 3\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",letter = \"e\") == 8\n assert candidate(s = \"uniquecharacters\",letter = \"u\") == 12\n assert candidate(s = \"hello world\",letter = \"l\") == 27\n assert candidate(s = \"hellotheregeneralkenobi\",letter = \"l\") == 13\n assert candidate(s = \"asynchronous\",letter = \"y\") == 8\n assert candidate(s = \"helloalibabacloud\",letter = \"a\") == 17\n assert candidate(s = \"mathematics\",letter = \"a\") == 18\n assert candidate(s = \"function\",letter = \"u\") == 12\n assert candidate(s = \"expression\",letter = \"s\") == 20\n assert candidate(s = \"thisisaverylongstringthatshouldtestthemaximumlengthoftheinputwhichisonehundredcharacters\",letter = \"s\") == 7\n assert candidate(s = \"lkjashdflkjhaskldjfhlasjdhflkajshdfjklsahjfdlkjahs\",letter = \"l\") == 14\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxy\",letter = \"x\") == 50\n assert candidate(s = \"programminglanguage\",letter = \"g\") == 21\n assert candidate(s = \"abcdefghij\",letter = \"m\") == 0\n assert candidate(s = \"percentageletter\",letter = \"t\") == 18\n assert candidate(s = \"encyclopedia\",letter = \"o\") == 8\n assert candidate(s = \"alphanumericcharacters123\",letter = \"a\") == 16\n assert candidate(s = \"thisisaverylongstringindeedtoseeifitworks\",letter = \"s\") == 12\n assert candidate(s = \"alphabet\",letter = \"z\") == 0\n assert candidate(s = \"programminglanguage\",letter = \"a\") == 15\n assert candidate(s = \"statistics\",letter = \"s\") == 30\n assert candidate(s = \"xylophone\",letter = \"x\") == 11\n assert candidate(s = \"encyclopedia\",letter = \"e\") == 16\n assert candidate(s = \"nolettersmatch\",letter = \"z\") == 0\n assert candidate(s = \"elephant\",letter = \"l\") == 12\n assert candidate(s = \"character\",letter = \"c\") == 22\n assert candidate(s = \"banana\",letter = \"a\") == 50\n assert candidate(s = \"congratulations\",letter = \"o\") == 13\n assert candidate(s = \"longstringwithvariouscharacters\",letter = \"v\") == 3\n assert candidate(s = \"algorithm\",letter = \"l\") == 11\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",letter = \"b\") == 33\n assert candidate(s = \"alabama\",letter = \"b\") == 14\n assert candidate(s = \"zzzzzzzzzz\",letter = \"z\") == 100\n assert candidate(s = \"sequence\",letter = \"q\") == 12\n assert candidate(s = \"banana\",letter = \"n\") == 33\n"}, "metadata": {"canonical_parameter_names": ["s", "letter"], "leetcode_dataset_entry_point": "Solution().percentageLetter", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int percentageLetter(String s, char letter) {", "container": "Solution", "callable": "percentageLetter", "parameters": [{"name": "s", "type": "String"}, {"name": "letter", "type": "char"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2279, "task_id": "maximum-bags-with-full-capacity-of-rocks", "difficulty": "Medium", "problem_description": "You have n bags numbered from 0 to n - 1. You are given two 0-indexed integer arrays capacity and rocks. The ith bag can hold a maximum of capacity[i] rocks and currently contains rocks[i] rocks. You are also given an integer additionalRocks, the number of additional rocks you can place in any of the bags.\nReturn the maximum number of bags that could have full capacity after placing the additional rocks in some bags.\n \nExample 1:\n\nInput: capacity = [2,3,4,5], rocks = [1,2,4,4], additionalRocks = 2\nOutput: 3\nExplanation:\nPlace 1 rock in bag 0 and 1 rock in bag 1.\nThe number of rocks in each bag are now [2,3,4,4].\nBags 0, 1, and 2 have full capacity.\nThere are 3 bags at full capacity, so we return 3.\nIt can be shown that it is not possible to have more than 3 bags at full capacity.\nNote that there may be other ways of placing the rocks that result in an answer of 3.\n\nExample 2:\n\nInput: capacity = [10,2,2], rocks = [2,2,0], additionalRocks = 100\nOutput: 3\nExplanation:\nPlace 8 rocks in bag 0 and 2 rocks in bag 2.\nThe number of rocks in each bag are now [10,2,2].\nBags 0, 1, and 2 have full capacity.\nThere are 3 bags at full capacity, so we return 3.\nIt can be shown that it is not possible to have more than 3 bags at full capacity.\nNote that we did not use all of the additional rocks.\n\n \nConstraints:\n\nn == capacity.length == rocks.length\n1 <= n <= 5 * 104\n1 <= capacity[i] <= 109\n0 <= rocks[i] <= capacity[i]\n1 <= additionalRocks <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(capacity = [2, 3, 4, 5],rocks = [1, 2, 4, 4],additionalRocks = 2) == 3\n assert candidate(capacity = [1, 2, 3],rocks = [0, 0, 0],additionalRocks = 5) == 2\n assert candidate(capacity = [3, 2, 1],rocks = [0, 0, 0],additionalRocks = 5) == 2\n assert candidate(capacity = [1, 1, 1],rocks = [0, 0, 0],additionalRocks = 3) == 3\n assert candidate(capacity = [3, 9, 8],rocks = [0, 2, 5],additionalRocks = 6) == 2\n assert candidate(capacity = [5, 5, 5, 5],rocks = [0, 0, 0, 0],additionalRocks = 10) == 2\n assert candidate(capacity = [1, 1, 1, 1],rocks = [1, 1, 1, 1],additionalRocks = 1) == 4\n assert candidate(capacity = [3, 3, 3],rocks = [3, 0, 0],additionalRocks = 3) == 2\n assert candidate(capacity = [10, 2, 2],rocks = [2, 2, 0],additionalRocks = 100) == 3\n assert candidate(capacity = [5, 5, 5],rocks = [0, 0, 0],additionalRocks = 10) == 2\n assert candidate(capacity = [1, 1, 1, 1],rocks = [1, 1, 1, 1],additionalRocks = 4) == 4\n assert candidate(capacity = [5, 5, 5],rocks = [0, 0, 0],additionalRocks = 15) == 3\n assert candidate(capacity = [3, 3, 3],rocks = [1, 2, 3],additionalRocks = 2) == 2\n assert candidate(capacity = [20, 20, 20, 20, 20, 20],rocks = [0, 5, 10, 15, 20, 25],additionalRocks = 30) == 5\n assert candidate(capacity = [1, 3, 5, 7, 9],rocks = [0, 1, 2, 3, 4],additionalRocks = 10) == 4\n assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [0, 0, 0, 0, 0],additionalRocks = 1500) == 5\n assert candidate(capacity = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 2500) == 9\n assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 5) == 5\n assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 5) == 5\n assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [0, 0, 0, 0, 0],additionalRocks = 45) == 4\n assert candidate(capacity = [5, 8, 10, 15, 20],rocks = [0, 4, 7, 10, 15],additionalRocks = 20) == 4\n assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 55) == 10\n assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [50, 150, 250, 350, 450],additionalRocks = 500) == 5\n assert candidate(capacity = [1, 2, 3, 4, 5, 6],rocks = [0, 0, 0, 0, 0, 0],additionalRocks = 20) == 5\n assert candidate(capacity = [500000000, 500000000, 500000000],rocks = [0, 0, 0],additionalRocks = 1000000000) == 2\n assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [10, 20, 30, 40, 0],additionalRocks = 50) == 5\n assert candidate(capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],rocks = [0, 1, 2, 3, 4, 0, 1, 2, 3, 4],additionalRocks = 15) == 6\n assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [1, 2, 3, 4, 5],additionalRocks = 90) == 4\n assert candidate(capacity = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],rocks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],additionalRocks = 5) == 5\n assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [0, 0, 0, 0, 0],additionalRocks = 30) == 3\n assert candidate(capacity = [5, 5, 5, 5, 5],rocks = [1, 2, 3, 4, 5],additionalRocks = 10) == 5\n assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 5) == 5\n assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [90, 180, 270, 360, 450],additionalRocks = 100) == 4\n assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [5, 5, 5, 5, 5],additionalRocks = 25) == 5\n assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],additionalRocks = 10) == 10\n assert candidate(capacity = [1000000000, 500000000, 250000000],rocks = [0, 0, 0],additionalRocks = 1500000000) == 2\n assert candidate(capacity = [2, 4, 6, 8, 10],rocks = [0, 1, 2, 3, 4],additionalRocks = 10) == 3\n assert candidate(capacity = [1000000000, 1000000000, 1000000000],rocks = [0, 0, 0],additionalRocks = 2000000000) == 2\n assert candidate(capacity = [50, 50, 50, 50, 50],rocks = [0, 0, 0, 0, 0],additionalRocks = 100) == 2\n assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 10) == 10\n assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [0, 0, 0, 0, 0],additionalRocks = 150) == 5\n assert candidate(capacity = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 10) == 4\n assert candidate(capacity = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],rocks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],additionalRocks = 300) == 10\n assert candidate(capacity = [999999999, 1],rocks = [0, 0],additionalRocks = 1000000000) == 2\n assert candidate(capacity = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 550) == 10\n assert candidate(capacity = [100, 100, 100, 100],rocks = [100, 100, 100, 100],additionalRocks = 100) == 4\n assert candidate(capacity = [2, 4, 6, 8, 10],rocks = [1, 1, 1, 1, 1],additionalRocks = 15) == 3\n assert candidate(capacity = [50, 50, 50, 50, 50],rocks = [10, 20, 30, 40, 50],additionalRocks = 100) == 5\n assert candidate(capacity = [9, 8, 7, 6, 5, 4, 3, 2, 1],rocks = [1, 2, 3, 4, 5, 6, 7, 8, 9],additionalRocks = 20) == 9\n assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 10) == 10\n assert candidate(capacity = [5, 15, 25, 35, 45],rocks = [2, 8, 14, 20, 26],additionalRocks = 120) == 5\n assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [0, 100, 200, 300, 400],additionalRocks = 500) == 5\n assert candidate(capacity = [5, 10, 15, 20, 25, 30, 35],rocks = [0, 0, 0, 0, 0, 0, 0],additionalRocks = 105) == 6\n assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],additionalRocks = 45) == 10\n assert candidate(capacity = [1, 3, 5, 7, 9],rocks = [0, 0, 0, 0, 0],additionalRocks = 25) == 5\n assert candidate(capacity = [1, 2, 4, 8, 16, 32, 64, 128],rocks = [0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 255) == 8\n assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [0, 0, 0, 0, 0],additionalRocks = 100) == 4\n assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],additionalRocks = 1) == 10\n assert candidate(capacity = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],rocks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],additionalRocks = 55) == 10\n assert candidate(capacity = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],rocks = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],additionalRocks = 50) == 10\n assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],additionalRocks = 15) == 10\n assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [50, 100, 150, 200, 250],additionalRocks = 500) == 4\n assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [5, 5, 5, 5, 5],additionalRocks = 15) == 3\n assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [50, 100, 150, 200, 250],additionalRocks = 1000) == 5\n assert candidate(capacity = [1000000000, 1000000000],rocks = [0, 1],additionalRocks = 1999999999) == 2\n assert candidate(capacity = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],rocks = [999999999, 999999998, 999999997, 999999996, 999999995],additionalRocks = 10000000000) == 5\n assert candidate(capacity = [1000000000, 1000000000, 1000000000],rocks = [0, 0, 0],additionalRocks = 3000000000) == 3\n assert candidate(capacity = [1, 2, 4, 8, 16, 32],rocks = [0, 1, 3, 7, 15, 31],additionalRocks = 63) == 6\n assert candidate(capacity = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 50) == 5\n assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [9, 8, 7, 6, 5],additionalRocks = 5) == 2\n assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [0, 2, 4, 6, 8],additionalRocks = 15) == 3\n assert candidate(capacity = [1000, 2000, 3000, 4000, 5000],rocks = [500, 1000, 1500, 2000, 2500],additionalRocks = 5000) == 4\n assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [50, 100, 150, 200, 250],additionalRocks = 100) == 1\n assert candidate(capacity = [100, 200, 300],rocks = [50, 100, 150],additionalRocks = 200) == 2\n assert candidate(capacity = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],rocks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],additionalRocks = 100) == 19\n assert candidate(capacity = [3, 6, 9, 12, 15],rocks = [0, 3, 6, 9, 12],additionalRocks = 20) == 5\n assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [1, 2, 3, 4, 5],additionalRocks = 80) == 3\n assert candidate(capacity = [1000000000, 1000000000, 1000000000],rocks = [0, 0, 0],additionalRocks = 2000000000) == 2\n assert candidate(capacity = [10, 15, 20, 25, 30],rocks = [0, 5, 10, 20, 25],additionalRocks = 50) == 5\n assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 2, 4, 6, 8, 10, 0, 0, 0, 0],additionalRocks = 20) == 9\n assert candidate(capacity = [1000000, 2000000, 3000000, 4000000, 5000000],rocks = [100000, 200000, 300000, 400000, 500000],additionalRocks = 5000000) == 2\n assert candidate(capacity = [100, 100, 100, 100],rocks = [99, 98, 97, 96],additionalRocks = 4) == 2\n assert candidate(capacity = [1, 2, 3, 4, 5],rocks = [0, 1, 2, 3, 4],additionalRocks = 10) == 5\n assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [10, 20, 30, 40, 50],additionalRocks = 100) == 5\n assert candidate(capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],rocks = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],additionalRocks = 5) == 5\n assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [90, 190, 290, 390, 490],additionalRocks = 50) == 5\n assert candidate(capacity = [1000000000, 1000000000, 1000000000],rocks = [500000000, 500000000, 500000000],additionalRocks = 1500000000) == 3\n assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [0, 0, 0, 0, 0],additionalRocks = 25) == 2\n assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 5) == 2\n assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 55) == 10\n assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [9, 19, 29, 39, 49],additionalRocks = 5) == 5\n assert candidate(capacity = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],rocks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],additionalRocks = 45) == 10\n assert candidate(capacity = [7, 7, 7, 7, 7, 7, 7],rocks = [1, 2, 3, 4, 5, 6, 0],additionalRocks = 14) == 4\n assert candidate(capacity = [5, 5, 5, 5, 5],rocks = [0, 1, 2, 3, 4],additionalRocks = 10) == 4\n assert candidate(capacity = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 55) == 10\n assert candidate(capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],rocks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],additionalRocks = 5) == 1\n assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [1, 2, 3, 4, 5],additionalRocks = 15) == 2\n assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [10, 20, 30, 40, 50],additionalRocks = 1000) == 4\n assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],additionalRocks = 55) == 10\n assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [0, 5, 10, 15, 20],additionalRocks = 100) == 5\n assert candidate(capacity = [100000000, 100000000, 100000000],rocks = [50000000, 50000000, 50000000],additionalRocks = 100000000) == 2\n assert candidate(capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],rocks = [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4],additionalRocks = 25) == 12\n assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 10) == 10\n"}, "metadata": {"canonical_parameter_names": ["capacity", "rocks", "additionalRocks"], "leetcode_dataset_entry_point": "Solution().maximumBags", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumBags(int[] capacity, int[] rocks, int additionalRocks) {", "container": "Solution", "callable": "maximumBags", "parameters": [{"name": "capacity", "type": "int[]"}, {"name": "rocks", "type": "int[]"}, {"name": "additionalRocks", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2280, "task_id": "minimum-lines-to-represent-a-line-chart", "difficulty": "Medium", "problem_description": "You are given a 2D integer array stockPrices where stockPrices[i] = [dayi, pricei] indicates the price of the stock on day dayi is pricei. A line chart is created from the array by plotting the points on an XY plane with the X-axis representing the day and the Y-axis representing the price and connecting adjacent points. One such example is shown below:\n\nReturn the minimum number of lines needed to represent the line chart.\n \nExample 1:\n\n\nInput: stockPrices = [[1,7],[2,6],[3,5],[4,4],[5,4],[6,3],[7,2],[8,1]]\nOutput: 3\nExplanation:\nThe diagram above represents the input, with the X-axis representing the day and Y-axis representing the price.\nThe following 3 lines can be drawn to represent the line chart:\n- Line 1 (in red) from (1,7) to (4,4) passing through (1,7), (2,6), (3,5), and (4,4).\n- Line 2 (in blue) from (4,4) to (5,4).\n- Line 3 (in green) from (5,4) to (8,1) passing through (5,4), (6,3), (7,2), and (8,1).\nIt can be shown that it is not possible to represent the line chart using less than 3 lines.\n\nExample 2:\n\n\nInput: stockPrices = [[3,4],[1,2],[7,8],[2,3]]\nOutput: 1\nExplanation:\nAs shown in the diagram above, the line chart can be represented with a single line.\n\n \nConstraints:\n\n1 <= stockPrices.length <= 105\nstockPrices[i].length == 2\n1 <= dayi, pricei <= 109\nAll dayi are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stockPrices = [[3, 4], [1, 2], [7, 8], [2, 3]]) == 1\n assert candidate(stockPrices = [[1, 7], [2, 6], [3, 5], [4, 4], [5, 4], [6, 3], [7, 2], [8, 1]]) == 3\n assert candidate(stockPrices = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]]) == 2\n assert candidate(stockPrices = [[1, 1], [2, 10], [3, 3], [4, 14], [5, 5], [6, 18], [7, 7], [8, 22], [9, 9], [10, 26]]) == 9\n assert candidate(stockPrices = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000]]) == 1\n assert candidate(stockPrices = [[1, 2], [2, 4], [3, 6], [5, 8], [10, 14], [20, 22], [30, 30], [40, 40]]) == 5\n assert candidate(stockPrices = [[1, 1], [2, 3], [4, 5], [8, 7], [16, 9], [32, 11], [64, 13], [128, 15]]) == 7\n assert candidate(stockPrices = [[1, 1], [2, 3], [3, 6], [4, 10], [5, 15], [6, 21], [7, 28], [8, 36], [9, 45], [10, 55]]) == 9\n assert candidate(stockPrices = [[1, 2], [2, 3], [4, 5], [5, 7], [6, 11], [7, 13], [8, 17], [9, 19]]) == 6\n assert candidate(stockPrices = [[1, 2], [2, 2], [3, 3], [4, 3], [5, 4], [6, 5], [7, 6], [8, 6], [9, 7]]) == 6\n assert candidate(stockPrices = [[1, 1], [3, 3], [6, 6], [10, 10], [15, 15], [21, 21], [28, 28]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 3], [4, 5], [8, 9], [16, 17], [32, 33], [64, 65], [128, 129]]) == 2\n assert candidate(stockPrices = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 11], [6, 13], [7, 17]]) == 4\n assert candidate(stockPrices = [[1, 1], [3, 5], [6, 10], [10, 17], [15, 26], [21, 37], [28, 50], [36, 65], [45, 82]]) == 8\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [5, 5], [6, 6], [8, 8], [9, 9], [11, 11], [12, 12]]) == 1\n assert candidate(stockPrices = [[1, 5], [2, 5], [3, 5], [4, 6], [5, 6], [6, 6], [7, 7], [8, 7], [9, 7], [10, 8]]) == 6\n assert candidate(stockPrices = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23]]) == 1\n assert candidate(stockPrices = [[1, 10], [2, 20], [3, 30], [4, 25], [5, 20], [6, 15], [7, 10]]) == 2\n assert candidate(stockPrices = [[1, 1], [2, 5], [3, 10], [4, 17], [5, 26], [6, 37], [7, 50], [8, 65], [9, 82], [10, 101]]) == 9\n assert candidate(stockPrices = [[1, 2], [2, 3], [3, 2], [4, 3], [5, 2], [6, 3], [7, 2], [8, 3]]) == 7\n assert candidate(stockPrices = [[1, 5], [2, 7], [3, 9], [4, 11], [5, 13], [6, 15], [7, 17], [8, 19], [9, 21], [10, 23]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64]]) == 7\n assert candidate(stockPrices = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9], [19, 10]]) == 1\n assert candidate(stockPrices = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 2], [7, 3], [8, 4], [9, 5], [10, 6]]) == 2\n assert candidate(stockPrices = [[1, 2], [2, 3], [4, 5], [7, 8], [11, 12], [16, 14], [22, 15], [29, 16], [37, 17]]) == 5\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 5], [5, 8], [6, 12], [7, 17], [8, 23], [9, 30], [10, 38]]) == 8\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 4], [4, 6], [5, 8], [6, 10], [7, 12], [8, 14], [9, 16], [10, 18]]) == 2\n assert candidate(stockPrices = [[1, 1000000000], [2, 2000000000], [3, 3000000000], [4, 4000000000], [5, 5000000000]]) == 1\n assert candidate(stockPrices = [[1, 10], [2, 10], [3, 10], [4, 5], [5, 5], [6, 5], [7, 0], [8, 0], [9, 0]]) == 5\n assert candidate(stockPrices = [[1, 1], [2, 3], [3, 6], [4, 10], [5, 15], [6, 21], [7, 28]]) == 6\n assert candidate(stockPrices = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 10], [3, 20], [4, 30], [5, 40], [6, 50], [7, 60], [8, 70], [9, 80], [10, 90]]) == 2\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 1\n assert candidate(stockPrices = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 2\n assert candidate(stockPrices = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20], [12, 21], [13, 22], [14, 23], [15, 24]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 3], [4, 7], [7, 15], [11, 26], [16, 40], [22, 58], [29, 79]]) == 5\n assert candidate(stockPrices = [[1, 1], [2, 5], [4, 9], [8, 13], [16, 17], [32, 21], [64, 25], [128, 29]]) == 7\n assert candidate(stockPrices = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7]]) == 6\n assert candidate(stockPrices = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 5], [3, 14], [4, 30], [5, 50], [6, 75], [7, 105], [8, 140], [9, 182], [10, 230]]) == 9\n assert candidate(stockPrices = [[1, 10], [2, 8], [3, 6], [4, 4], [5, 2], [6, 0], [7, -2], [8, -4], [9, -6], [10, -8]]) == 1\n assert candidate(stockPrices = [[1, 2], [2, 1], [3, 2], [4, 1], [5, 2], [6, 1], [7, 2], [8, 1], [9, 2], [10, 1]]) == 9\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [5, 5], [8, 8], [13, 13], [21, 21], [34, 34], [55, 55]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81], [10, 100]]) == 9\n assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 2], [5, 3], [6, 4], [7, 4], [8, 4], [9, 5], [10, 6]]) == 4\n assert candidate(stockPrices = [[1, 5], [2, 10], [3, 15], [5, 20], [10, 25], [20, 30], [40, 35], [80, 40]]) == 6\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 2], [4, 3], [5, 3], [6, 4], [7, 4], [8, 5]]) == 7\n assert candidate(stockPrices = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 1\n assert candidate(stockPrices = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15], [8, 17], [9, 19], [10, 21], [11, 23], [12, 25]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11]]) == 9\n assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 2], [7, 3], [8, 2], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == 4\n assert candidate(stockPrices = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [7, 0], [8, 1], [9, 2], [10, 3]]) == 3\n assert candidate(stockPrices = [[1, 1], [2, 4], [4, 9], [7, 16], [11, 25], [16, 36], [22, 49], [29, 64]]) == 7\n assert candidate(stockPrices = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700]]) == 1\n assert candidate(stockPrices = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 1\n assert candidate(stockPrices = [[1, 1], [3, 3], [6, 6], [9, 9], [12, 12], [15, 15], [18, 18], [21, 21]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 1\n assert candidate(stockPrices = [[1, 1], [3, 2], [6, 3], [10, 4], [15, 5], [21, 6], [28, 7], [36, 8], [45, 9]]) == 8\n assert candidate(stockPrices = [[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]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81]]) == 8\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 3], [5, 3], [6, 3], [7, 4], [8, 5], [9, 6], [10, 7]]) == 3\n assert candidate(stockPrices = [[1, 2], [2, 3], [3, 5], [5, 8], [8, 13], [13, 21], [21, 34], [34, 55], [55, 89], [89, 144]]) == 9\n assert candidate(stockPrices = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19], [11, 21], [12, 23], [13, 25]]) == 1\n assert candidate(stockPrices = [[1, 2], [2, 2], [3, 2], [4, 3], [5, 4], [6, 5], [7, 5], [8, 5], [9, 6], [10, 7]]) == 4\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(stockPrices = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]]) == 1\n assert candidate(stockPrices = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 1], [4, 2], [5, 1], [6, 2], [7, 1], [8, 2], [9, 1], [10, 2]]) == 9\n assert candidate(stockPrices = [[1, 1], [3, 5], [6, 10], [10, 15], [15, 20], [21, 25], [28, 30]]) == 6\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 5], [5, 7], [6, 9], [7, 11]]) == 2\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 4], [4, 8], [5, 16], [6, 32], [7, 64], [8, 128], [9, 256], [10, 512]]) == 9\n assert candidate(stockPrices = [[1, 1], [2, 3], [4, 9], [8, 27], [16, 81], [32, 243], [64, 729], [128, 2187]]) == 7\n assert candidate(stockPrices = [[1, 1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3], [7, 4], [8, 4], [9, 5], [10, 5]]) == 9\n assert candidate(stockPrices = [[1, 100], [2, 50], [4, 25], [8, 12], [16, 6], [32, 3], [64, 1], [128, 0]]) == 7\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 5], [5, 7], [6, 10], [7, 15], [8, 21], [9, 28], [10, 36]]) == 7\n assert candidate(stockPrices = [[10, 20], [20, 10], [30, 30], [40, 40], [50, 50], [60, 60]]) == 3\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 4], [5, 8], [9, 16], [17, 32], [33, 64], [65, 128], [129, 256]]) == 2\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0], [9, -1], [10, -2]]) == 2\n assert candidate(stockPrices = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 8], [7, 6], [8, 4], [9, 2]]) == 2\n assert candidate(stockPrices = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3]]) == 1\n assert candidate(stockPrices = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 1\n assert candidate(stockPrices = [[1, 2], [2, 2], [3, 3], [4, 3], [5, 4], [6, 4], [7, 5], [8, 5]]) == 7\n assert candidate(stockPrices = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 3], [6, 4], [7, 5], [8, 6], [9, 7], [10, 8]]) == 2\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 11]]) == 2\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 2], [4, 2], [5, 3], [6, 3], [7, 4], [8, 4], [9, 5]]) == 7\n assert candidate(stockPrices = [[1, 1], [2, 1], [3, 3], [4, 4], [5, 5], [6, 6], [7, 8], [8, 8], [9, 9], [10, 10]]) == 6\n assert candidate(stockPrices = [[1, 1], [2, 2], [4, 4], [5, 5], [7, 7], [8, 8], [10, 10], [11, 11]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 5], [5, 8], [6, 13], [7, 21], [8, 31], [9, 43], [10, 57]]) == 8\n assert candidate(stockPrices = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 2]]) == 2\n assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1]]) == 1\n assert candidate(stockPrices = [[1, 10], [2, 15], [3, 25], [4, 40], [5, 60], [6, 85], [7, 115], [8, 150], [9, 190], [10, 235]]) == 9\n assert candidate(stockPrices = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [6, 6], [7, 6], [8, 6], [9, 7], [10, 7]]) == 5\n assert candidate(stockPrices = [[1, 1], [2, 5], [3, 9], [4, 14], [5, 19], [6, 25], [7, 31], [8, 38], [9, 45], [10, 53]]) == 5\n assert candidate(stockPrices = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 5], [6, 3], [7, 1], [8, 3], [9, 5], [10, 7]]) == 3\n assert candidate(stockPrices = [[1, 1], [3, 4], [6, 7], [8, 10], [9, 11], [11, 13], [13, 15], [14, 16]]) == 4\n assert candidate(stockPrices = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0]]) == 1\n assert candidate(stockPrices = [[5, 3], [10, 6], [15, 9], [20, 12], [25, 15], [30, 18], [35, 21], [40, 24]]) == 1\n assert candidate(stockPrices = [[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], [16, 5], [17, 5], [18, 5], [19, 5], [20, 5]]) == 1\n assert candidate(stockPrices = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996], [6, 999999995], [7, 999999994], [8, 999999993], [9, 999999992], [10, 999999991]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 2], [6, 2], [7, 2], [8, 2], [9, 3], [10, 3]]) == 5\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [5, 5], [6, 6], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(stockPrices = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17]]) == 1\n assert candidate(stockPrices = [[1, 1], [2, 2], [3, 5], [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]]) == 4\n assert candidate(stockPrices = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 40], [7, 30], [8, 20], [9, 10]]) == 2\n"}, "metadata": {"canonical_parameter_names": ["stockPrices"], "leetcode_dataset_entry_point": "Solution().minimumLines", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumLines(int[][] stockPrices) {", "container": "Solution", "callable": "minimumLines", "parameters": [{"name": "stockPrices", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2281, "task_id": "sum-of-total-strength-of-wizards", "difficulty": "Hard", "problem_description": "As the ruler of a kingdom, you have an army of wizards at your command.\nYou are given a 0-indexed integer array strength, where strength[i] denotes the strength of the ith wizard. For a contiguous group of wizards (i.e. the wizards' strengths form a subarray of strength), the total strength is defined as the product of the following two values:\n\nThe strength of the weakest wizard in the group.\nThe total of all the individual strengths of the wizards in the group.\n\nReturn the sum of the total strengths of all contiguous groups of wizards. Since the answer may be very large, return it modulo 109 + 7.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: strength = [1,3,1,2]\nOutput: 44\nExplanation: The following are all the contiguous groups of wizards:\n- [1] from [1,3,1,2] has a total strength of min([1]) * sum([1]) = 1 * 1 = 1\n- [3] from [1,3,1,2] has a total strength of min([3]) * sum([3]) = 3 * 3 = 9\n- [1] from [1,3,1,2] has a total strength of min([1]) * sum([1]) = 1 * 1 = 1\n- [2] from [1,3,1,2] has a total strength of min([2]) * sum([2]) = 2 * 2 = 4\n- [1,3] from [1,3,1,2] has a total strength of min([1,3]) * sum([1,3]) = 1 * 4 = 4\n- [3,1] from [1,3,1,2] has a total strength of min([3,1]) * sum([3,1]) = 1 * 4 = 4\n- [1,2] from [1,3,1,2] has a total strength of min([1,2]) * sum([1,2]) = 1 * 3 = 3\n- [1,3,1] from [1,3,1,2] has a total strength of min([1,3,1]) * sum([1,3,1]) = 1 * 5 = 5\n- [3,1,2] from [1,3,1,2] has a total strength of min([3,1,2]) * sum([3,1,2]) = 1 * 6 = 6\n- [1,3,1,2] from [1,3,1,2] has a total strength of min([1,3,1,2]) * sum([1,3,1,2]) = 1 * 7 = 7\nThe sum of all the total strengths is 1 + 9 + 1 + 4 + 4 + 4 + 3 + 5 + 6 + 7 = 44.\n\nExample 2:\n\nInput: strength = [5,4,6]\nOutput: 213\nExplanation: The following are all the contiguous groups of wizards: \n- [5] from [5,4,6] has a total strength of min([5]) * sum([5]) = 5 * 5 = 25\n- [4] from [5,4,6] has a total strength of min([4]) * sum([4]) = 4 * 4 = 16\n- [6] from [5,4,6] has a total strength of min([6]) * sum([6]) = 6 * 6 = 36\n- [5,4] from [5,4,6] has a total strength of min([5,4]) * sum([5,4]) = 4 * 9 = 36\n- [4,6] from [5,4,6] has a total strength of min([4,6]) * sum([4,6]) = 4 * 10 = 40\n- [5,4,6] from [5,4,6] has a total strength of min([5,4,6]) * sum([5,4,6]) = 4 * 15 = 60\nThe sum of all the total strengths is 25 + 16 + 36 + 36 + 40 + 60 = 213.\n\n \nConstraints:\n\n1 <= strength.length <= 105\n1 <= strength[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(strength = [1]) == 1\n assert candidate(strength = [1, 1, 1, 1, 1]) == 35\n assert candidate(strength = [10, 9, 8, 7, 6]) == 1988\n assert candidate(strength = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4576\n assert candidate(strength = [5]) == 25\n assert candidate(strength = [1000000000, 1000000000, 1000000000]) == 490\n assert candidate(strength = [5, 3, 1, 2, 4]) == 156\n assert candidate(strength = [1, 2, 3, 4, 5]) == 238\n assert candidate(strength = [5, 6, 7, 8, 9, 10]) == 2688\n assert candidate(strength = [5, 4, 6]) == 213\n assert candidate(strength = [1, 10, 1, 10, 1, 10]) == 578\n assert candidate(strength = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 731\n assert candidate(strength = [10, 9, 8, 7, 6, 5]) == 2688\n assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4576\n assert candidate(strength = [1, 3, 1, 2]) == 44\n assert candidate(strength = [1000000000, 1000000000]) == 196\n assert candidate(strength = [1, 3, 5, 7, 9, 7, 5, 3, 1]) == 2577\n assert candidate(strength = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100]) == 2600000\n assert candidate(strength = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 21824\n assert candidate(strength = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2330\n assert candidate(strength = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 4144\n assert candidate(strength = [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]) == 315315\n assert candidate(strength = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 22000\n assert candidate(strength = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 108290\n assert candidate(strength = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 760\n assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1540\n assert candidate(strength = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 4820\n assert candidate(strength = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 8712\n assert candidate(strength = [1, 5, 2, 5, 3, 5, 4, 5, 5, 5]) == 2232\n assert candidate(strength = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 13042\n assert candidate(strength = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 457600\n assert candidate(strength = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 370373883\n assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 109802\n assert candidate(strength = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 98736\n assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2871\n assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2871\n assert candidate(strength = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 1660\n assert candidate(strength = [10, 20, 30, 40, 50]) == 23800\n assert candidate(strength = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38768\n assert candidate(strength = [1000000000, 1000000000, 1000000000, 1000000000]) == 980\n assert candidate(strength = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4576\n assert candidate(strength = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 370373883\n assert candidate(strength = [5, 3, 8, 6, 2, 7, 4, 9, 1]) == 1914\n assert candidate(strength = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 14312\n assert candidate(strength = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 2684\n assert candidate(strength = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 2439\n assert candidate(strength = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == 4200\n assert candidate(strength = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 109802\n assert candidate(strength = [2, 1, 3, 4, 2, 1, 3, 4, 2, 1]) == 638\n assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 165\n assert candidate(strength = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 268328687\n assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 457600\n assert candidate(strength = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 13552\n assert candidate(strength = [2, 1, 3, 4, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4, 1, 2]) == 3672\n assert candidate(strength = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 3193\n assert candidate(strength = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 1590\n assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 2767600\n assert candidate(strength = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == 619372\n assert candidate(strength = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 30778\n assert candidate(strength = [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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1]) == 64317\n assert candidate(strength = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10]) == 3448\n assert candidate(strength = [2, 1, 2, 1, 2, 1, 2, 1, 2]) == 260\n assert candidate(strength = [35, 30, 25, 20, 15, 10, 5, 10, 15, 20, 25, 30, 35]) == 72275\n assert candidate(strength = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 3178\n assert candidate(strength = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 268328687\n assert candidate(strength = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1715\n assert candidate(strength = [1000000000, 1000000000, 1000000000, 1000000000]) == 980\n assert candidate(strength = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1414\n assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 2767600\n assert candidate(strength = [10, 15, 10, 20, 15, 25, 20, 30, 25, 35]) == 61475\n assert candidate(strength = [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]) == 301120400\n assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 457600\n assert candidate(strength = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 1013\n assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1540\n assert candidate(strength = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 3150\n assert candidate(strength = [10, 20, 30, 20, 10, 10, 20, 30, 20, 10]) == 46200\n assert candidate(strength = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2871\n assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4576\n assert candidate(strength = [3, 1, 2, 5, 4]) == 186\n assert candidate(strength = [5, 1, 3, 2, 4, 6, 8, 7, 9]) == 2155\n assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 220\n assert candidate(strength = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10780\n assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2876356\n assert candidate(strength = [1, 1000000000, 1, 1000000000, 1, 1000000000]) == 0\n assert candidate(strength = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3676\n assert candidate(strength = [100, 1, 200, 2, 300, 3, 400, 4, 500]) == 596592\n assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 109802\n assert candidate(strength = [50, 20, 30, 10, 40, 60, 70, 5, 80, 90]) == 115850\n assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 220\n assert candidate(strength = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 30778\n assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 28764\n assert candidate(strength = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 926\n assert candidate(strength = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 28764\n assert candidate(strength = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 826\n assert candidate(strength = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == 369\n assert candidate(strength = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 340\n assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 6, 7, 8, 9, 10]) == 3083588\n assert candidate(strength = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2871\n assert candidate(strength = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5500\n assert candidate(strength = [1, 3, 2, 4, 1, 5, 2, 6, 1, 7, 2, 8, 1, 9, 2, 10]) == 3648\n assert candidate(strength = [3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == 1864\n assert candidate(strength = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 639\n assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 165\n assert candidate(strength = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1980\n"}, "metadata": {"canonical_parameter_names": ["strength"], "leetcode_dataset_entry_point": "Solution().totalStrength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int totalStrength(int[] strength) {", "container": "Solution", "callable": "totalStrength", "parameters": [{"name": "strength", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2283, "task_id": "check-if-number-has-equal-digit-count-and-digit-value", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string num of length n consisting of digits.\nReturn true if for every index i in the range 0 <= i < n, the digit i occurs num[i] times in num, otherwise return false.\n \nExample 1:\n\nInput: num = \"1210\"\nOutput: true\nExplanation:\nnum[0] = '1'. The digit 0 occurs once in num.\nnum[1] = '2'. The digit 1 occurs twice in num.\nnum[2] = '1'. The digit 2 occurs once in num.\nnum[3] = '0'. The digit 3 occurs zero times in num.\nThe condition holds true for every index in \"1210\", so return true.\n\nExample 2:\n\nInput: num = \"030\"\nOutput: false\nExplanation:\nnum[0] = '0'. The digit 0 should occur zero times, but actually occurs twice in num.\nnum[1] = '3'. The digit 1 should occur three times, but actually occurs zero times in num.\nnum[2] = '0'. The digit 2 occurs zero times in num.\nThe indices 0 and 1 both violate the condition, so return false.\n\n \nConstraints:\n\nn == num.length\n1 <= n <= 10\nnum consists of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"1111\") == False\n assert candidate(num = \"00000\") == False\n assert candidate(num = \"10\") == False\n assert candidate(num = \"1111111111\") == False\n assert candidate(num = \"000\") == False\n assert candidate(num = \"6200000000\") == False\n assert candidate(num = \"0100100010\") == False\n assert candidate(num = \"6210001000\") == True\n assert candidate(num = \"030\") == False\n assert candidate(num = \"9876543210\") == False\n assert candidate(num = \"2020202020\") == False\n assert candidate(num = \"0\") == False\n assert candidate(num = \"5000000000\") == False\n assert candidate(num = \"21200\") == True\n assert candidate(num = \"0987654321\") == False\n assert candidate(num = \"2020\") == True\n assert candidate(num = \"11200\") == False\n assert candidate(num = \"1010101010\") == False\n assert candidate(num = \"1210\") == True\n assert candidate(num = \"6543210\") == False\n assert candidate(num = \"50000\") == False\n assert candidate(num = \"5000001000\") == False\n assert candidate(num = \"1234567890\") == False\n assert candidate(num = \"1221111111\") == False\n assert candidate(num = \"1001\") == False\n assert candidate(num = \"0000\") == False\n assert candidate(num = \"2120000000\") == False\n assert candidate(num = \"4000400040\") == False\n assert candidate(num = \"101010101\") == False\n assert candidate(num = \"0000100000\") == False\n assert candidate(num = \"1112212100\") == False\n assert candidate(num = \"0000000000\") == False\n assert candidate(num = \"400000000004\") == False\n assert candidate(num = \"0000000100\") == False\n assert candidate(num = \"0101010101\") == False\n assert candidate(num = \"00100000010\") == False\n assert candidate(num = \"00000000400\") == False\n assert candidate(num = \"9000000000\") == False\n assert candidate(num = \"3110001000\") == False\n assert candidate(num = \"0100101010\") == False\n assert candidate(num = \"100010000\") == False\n assert candidate(num = \"000020000\") == False\n assert candidate(num = \"100201000\") == False\n assert candidate(num = \"30003\") == False\n assert candidate(num = \"1221\") == False\n assert candidate(num = \"12101000\") == False\n assert candidate(num = \"000010001\") == False\n assert candidate(num = \"3000000000\") == False\n assert candidate(num = \"0010000000\") == False\n assert candidate(num = \"0000101000\") == False\n assert candidate(num = \"3100000\") == False\n assert candidate(num = \"3000000010\") == False\n assert candidate(num = \"0100000001\") == False\n assert candidate(num = \"00001001000\") == False\n assert candidate(num = \"121010000\") == False\n assert candidate(num = \"0123400000\") == False\n assert candidate(num = \"2010000000\") == False\n assert candidate(num = \"0010000010\") == False\n assert candidate(num = \"102020100\") == False\n assert candidate(num = \"000300003\") == False\n assert candidate(num = \"500000000\") == False\n assert candidate(num = \"40000000\") == False\n assert candidate(num = \"5000011000\") == False\n assert candidate(num = \"1001001001\") == False\n assert candidate(num = \"1221100000\") == False\n assert candidate(num = \"1212121212\") == False\n assert candidate(num = \"0001000100\") == False\n assert candidate(num = \"0000000010\") == False\n assert candidate(num = \"3000100002\") == False\n assert candidate(num = \"100002000\") == False\n assert candidate(num = \"200000010\") == False\n assert candidate(num = \"0012002001\") == False\n assert candidate(num = \"13010003\") == False\n assert candidate(num = \"42101000\") == True\n assert candidate(num = \"7000000000\") == False\n assert candidate(num = \"6543210000\") == False\n assert candidate(num = \"5000001400\") == False\n assert candidate(num = \"00000000050\") == False\n assert candidate(num = \"210010010\") == False\n assert candidate(num = \"012020200\") == False\n assert candidate(num = \"0000000004\") == False\n assert candidate(num = \"000030000\") == False\n assert candidate(num = \"12101\") == False\n assert candidate(num = \"4000010000\") == False\n assert candidate(num = \"2220000000\") == False\n assert candidate(num = \"1210101010\") == False\n assert candidate(num = \"000000003\") == False\n assert candidate(num = \"0210000110\") == False\n assert candidate(num = \"1000100010\") == False\n assert candidate(num = \"100000002\") == False\n assert candidate(num = \"3000300000\") == False\n assert candidate(num = \"400001000\") == False\n assert candidate(num = \"0123456789\") == False\n assert candidate(num = \"0000001001\") == False\n assert candidate(num = \"00000110000\") == False\n assert candidate(num = \"2100100000\") == False\n assert candidate(num = \"3110000\") == False\n assert candidate(num = \"00000020000\") == False\n assert candidate(num = \"0000000020\") == False\n assert candidate(num = \"200100100\") == False\n assert candidate(num = \"1210100\") == False\n assert candidate(num = \"1020304050\") == False\n assert candidate(num = \"6000000000\") == False\n assert candidate(num = \"001010101\") == False\n assert candidate(num = \"0000000002\") == False\n assert candidate(num = \"000001011\") == False\n assert candidate(num = \"20200\") == False\n assert candidate(num = \"1111111110\") == False\n assert candidate(num = \"1300102000\") == False\n assert candidate(num = \"10000000001\") == False\n assert candidate(num = \"2020200\") == False\n assert candidate(num = \"41210000\") == False\n assert candidate(num = \"0000000009\") == False\n assert candidate(num = \"0020200\") == False\n assert candidate(num = \"200001\") == False\n assert candidate(num = \"100000101\") == False\n assert candidate(num = \"010200200\") == False\n assert candidate(num = \"1000000001\") == False\n assert candidate(num = \"0123210\") == False\n assert candidate(num = \"3000100000\") == False\n assert candidate(num = \"200000000\") == False\n assert candidate(num = \"021001001\") == False\n assert candidate(num = \"30000003\") == False\n assert candidate(num = \"300020000\") == False\n assert candidate(num = \"0000000001\") == False\n assert candidate(num = \"300000000\") == False\n assert candidate(num = \"00000000006\") == False\n assert candidate(num = \"0000000110\") == False\n assert candidate(num = \"5000000005\") == False\n assert candidate(num = \"4000000000\") == False\n assert candidate(num = \"2010011000\") == False\n assert candidate(num = \"201010101\") == False\n assert candidate(num = \"001100110\") == False\n assert candidate(num = \"1000000010\") == False\n assert candidate(num = \"0112233445\") == False\n assert candidate(num = \"5000000100\") == False\n assert candidate(num = \"0110001000\") == False\n assert candidate(num = \"01000000001\") == False\n assert candidate(num = \"3110000000\") == False\n assert candidate(num = \"100010001\") == False\n assert candidate(num = \"0000010010\") == False\n assert candidate(num = \"00010000100\") == False\n assert candidate(num = \"00000003000\") == False\n assert candidate(num = \"8000000000\") == False\n assert candidate(num = \"00001111\") == False\n assert candidate(num = \"600000000000\") == False\n assert candidate(num = \"1200100000\") == False\n assert candidate(num = \"3330000000\") == False\n assert candidate(num = \"011110000\") == False\n assert candidate(num = \"2120001000\") == False\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().digitCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean digitCount(String num) {", "container": "Solution", "callable": "digitCount", "parameters": [{"name": "num", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2284, "task_id": "sender-with-largest-word-count", "difficulty": "Medium", "problem_description": "You have a chat log of n messages. You are given two string arrays messages and senders where messages[i] is a message sent by senders[i].\nA message is list of words that are separated by a single space with no leading or trailing spaces. The word count of a sender is the total number of words sent by the sender. Note that a sender may send more than one message.\nReturn the sender with the largest word count. If there is more than one sender with the largest word count, return the one with the lexicographically largest name.\nNote:\n\nUppercase letters come before lowercase letters in lexicographical order.\n\"Alice\" and \"alice\" are distinct.\n\n \nExample 1:\n\nInput: messages = [\"Hello userTwooo\",\"Hi userThree\",\"Wonderful day Alice\",\"Nice day userThree\"], senders = [\"Alice\",\"userTwo\",\"userThree\",\"Alice\"]\nOutput: \"Alice\"\nExplanation: Alice sends a total of 2 + 3 = 5 words.\nuserTwo sends a total of 2 words.\nuserThree sends a total of 3 words.\nSince Alice has the largest word count, we return \"Alice\".\n\nExample 2:\n\nInput: messages = [\"How is leetcode for everyone\",\"Leetcode is useful for practice\"], senders = [\"Bob\",\"Charlie\"]\nOutput: \"Charlie\"\nExplanation: Bob sends a total of 5 words.\nCharlie sends a total of 5 words.\nSince there is a tie for the largest word count, we return the sender with the lexicographically larger name, Charlie.\n \nConstraints:\n\nn == messages.length == senders.length\n1 <= n <= 104\n1 <= messages[i].length <= 100\n1 <= senders[i].length <= 10\nmessages[i] consists of uppercase and lowercase English letters and ' '.\nAll the words in messages[i] are separated by a single space.\nmessages[i] does not have leading or trailing spaces.\nsenders[i] consists of uppercase and lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(messages = ['This is a test', 'Another test', 'Final test'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Hi'],senders = ['Bob']) == \"Bob\"\n assert candidate(messages = ['Short', 'Longer message indeed'],senders = ['Alice', 'Alice']) == \"Alice\"\n assert candidate(messages = ['How is leetcode for everyone', 'Leetcode is useful for practice'],senders = ['Bob', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Hi', 'Hello', 'Hey'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Hello userTwooo', 'Hi userThree', 'Wonderful day Alice', 'Nice day userThree'],senders = ['Alice', 'userTwo', 'userThree', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Short', 'Longer message indeed'],senders = ['Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['This is a test', 'Another test', 'Final test'],senders = ['Alice', 'Alice', 'Bob']) == \"Alice\"\n assert candidate(messages = ['Short', 'Longer message indeed'],senders = ['Charlie', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Short', 'Longer message here', 'Even longer message here'],senders = ['Zoe', 'Zoe', 'Zoe']) == \"Zoe\"\n assert candidate(messages = ['a', 'b', 'c', 'd'],senders = ['Anna', 'Bob', 'Charlie', 'David']) == \"David\"\n assert candidate(messages = ['Hello', 'Hi'],senders = ['Alice', 'Bob']) == \"Bob\"\n assert candidate(messages = ['Hello World', 'Foo Bar'],senders = ['Alice', 'Bob']) == \"Bob\"\n assert candidate(messages = ['Hi', 'Hello'],senders = ['Alice', 'Bob']) == \"Bob\"\n assert candidate(messages = ['Equal length messages here', 'Equal length messages here', 'Equal length messages here'],senders = ['Alice', 'Bob', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['a a a a a a a a a a', 'b b b b b b b b b', 'c c c c c c c c', 'd d d d d d d'],senders = ['Alice', 'Bob', 'Alice', 'Bob']) == \"Alice\"\n assert candidate(messages = ['Hello Alice', 'Hello Bob', 'Hello Charlie', 'Hello Dave', 'Hello Eve'],senders = ['Alice', 'Bob', 'Charlie', 'Dave', 'Eve']) == \"Eve\"\n assert candidate(messages = ['Short', 'Longer message with multiple words', 'Another long message that is quite lengthy'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['abc def ghi', 'jkl mno pqr', 'stu vwx yz'],senders = ['Alice', 'Alice', 'Bob']) == \"Alice\"\n assert candidate(messages = ['Word', 'Word Word', 'Word Word Word', 'Word Word Word Word', 'Word Word Word Word Word'],senders = ['Yankee', 'yankee', 'YANKEE', 'Yankee', 'yankee']) == \"yankee\"\n assert candidate(messages = ['a', 'b c', 'd e f', 'g h i j'],senders = ['Z', 'Y', 'X', 'W']) == \"W\"\n assert candidate(messages = ['First message', 'Second message', 'Third message', 'Fourth message'],senders = ['Dave', 'Dave', 'Eve', 'Dave']) == \"Dave\"\n assert candidate(messages = ['This is a longer message with multiple words', 'Short message', 'Another long message with several words in it'],senders = ['Charlie', 'Alice', 'Bob']) == \"Charlie\"\n assert candidate(messages = ['a', 'b', 'c', 'd', 'e', 'f'],senders = ['Z', 'Y', 'X', 'W', 'V', 'U']) == \"Z\"\n assert candidate(messages = ['Hi', 'Hello', 'Hey', 'Goodbye', 'See you later'],senders = ['Alice', 'Bob', 'Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Hello world', 'How are you doing', 'I am fine thank you', 'And you'],senders = ['Bob', 'Charlie', 'Alice', 'Bob']) == \"Alice\"\n assert candidate(messages = ['Many many words in this message to test the function', 'Few words'],senders = ['Alice', 'Bob']) == \"Alice\"\n assert candidate(messages = ['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', 'a b c d e f g h i j k l m n o p q r s t u v w x'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Short message', 'Another short one'],senders = ['charlie', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['One two three four five', 'Six seven eight nine ten', 'Eleven twelve'],senders = ['George', 'Hannah', 'George']) == \"George\"\n assert candidate(messages = ['Hello userTwooo', 'Hi userThree', 'Wonderful day Alice', 'Nice day userThree', 'Great to see you Alice'],senders = ['Alice', 'userTwo', 'userThree', 'Alice', 'Alice']) == \"Alice\"\n assert candidate(messages = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],senders = ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A']) == \"A\"\n assert candidate(messages = ['Short msg', 'Medium length message indeed', 'A very long message with lots of words to count accurately'],senders = ['Carol', 'Carol', 'Carol']) == \"Carol\"\n assert candidate(messages = ['Hello world', 'Python programming is fun', 'Hello again', 'Data structures and algorithms'],senders = ['Alice', 'Bob', 'Alice', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Long message to test', 'Another long message to test', 'Short'],senders = ['Charlie', 'Alice', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['One', 'Two', 'Three', 'Four', 'Five'],senders = ['Zebra', 'Zebra', 'Zebra', 'Zebra', 'Zebra']) == \"Zebra\"\n assert candidate(messages = ['One', 'Two words here', 'Three words in this message', 'Four words make a sentence'],senders = ['Anna', 'Anna', 'Anna', 'Anna']) == \"Anna\"\n assert candidate(messages = ['Quick brown fox jumps over lazy dog', 'Hello', 'Goodbye'],senders = ['Alice', 'Alice', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Quick brown fox', 'Lazy dog', 'Uppercase LOWERCASE', 'Mixed CASE Words'],senders = ['Alex', 'Bob', 'Charlie', 'David']) == \"David\"\n assert candidate(messages = ['One', 'Two words here', 'Three words in this one', 'Four words make this message'],senders = ['Eve', 'eve', 'EVE', 'Eve']) == \"Eve\"\n assert candidate(messages = ['This is a longer message', 'Even longer message here', 'Short'],senders = ['Charlie', 'Charlie', 'Alice']) == \"Charlie\"\n assert candidate(messages = ['Short', 'Longer message to test', 'Even longer message to check the word count', 'Short again'],senders = ['Bob', 'Charlie', 'Alice', 'Charlie']) == \"Alice\"\n assert candidate(messages = ['This is a test message', 'Another test', 'Yet another message here'],senders = ['Charlie', 'Alice', 'Bob']) == \"Charlie\"\n assert candidate(messages = ['A quick brown fox jumps over the lazy dog', 'Foo bar baz'],senders = ['Dave', 'Eve']) == \"Dave\"\n assert candidate(messages = ['Equal words here', 'Equal words here'],senders = ['Alice', 'Bob']) == \"Bob\"\n assert candidate(messages = ['Many words in this message to test the word count functionality', 'Another message to ensure the solution works correctly'],senders = ['Anna', 'Anna']) == \"Anna\"\n assert candidate(messages = ['Multiple words', 'Multiple words', 'Multiple words', 'Multiple words'],senders = ['Alice', 'Bob', 'Charlie', 'David']) == \"David\"\n assert candidate(messages = ['Equal words', 'Equal words'],senders = ['Anna', 'Bob']) == \"Bob\"\n assert candidate(messages = ['Equal length message', 'Another equal length message'],senders = ['Dave', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Word', 'Word word', 'Word word word', 'Word word word word', 'Word word word word word'],senders = ['Alex', 'Alex', 'Alex', 'Brian', 'Brian']) == \"Brian\"\n assert candidate(messages = ['One', 'Two words', 'Three words here', 'Four words in this message'],senders = ['Bob', 'Charlie', 'Bob', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Multiple words in this message', 'Single', 'Two words'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Equal length', 'Equal length'],senders = ['Tom', 'Jerry']) == \"Tom\"\n assert candidate(messages = ['Equal words in messages', 'Equal words in messages'],senders = ['Sender1', 'Sender2']) == \"Sender2\"\n assert candidate(messages = ['Message one', 'Message two', 'Message three', 'Message four'],senders = ['Zebra', 'Zebra', 'Zebra', 'Zebra']) == \"Zebra\"\n assert candidate(messages = ['Unique message each time', 'Another unique one'],senders = ['Alice', 'Bob']) == \"Alice\"\n assert candidate(messages = ['Same sender many times', 'Same sender many times', 'Same sender many times'],senders = ['Alice', 'Alice', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Message one', 'Another message', 'Yet another message to test', 'Final message'],senders = ['Zara', 'Alice', 'Bob', 'Charlie']) == \"Bob\"\n assert candidate(messages = ['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'],senders = ['Alice', 'Bob', 'Charlie']) == \"Bob\"\n assert candidate(messages = ['Hello world', 'Foo bar baz', 'This is a test message'],senders = ['alice', 'Bob', 'alice']) == \"alice\"\n assert candidate(messages = ['Message one', 'Message two', 'Message three'],senders = ['Zach', 'Yvonne', 'Xander']) == \"Zach\"\n assert candidate(messages = ['Different sender', 'Different sender', 'Different sender', 'Different sender'],senders = ['Mike', 'Mike', 'Mike', 'Mike']) == \"Mike\"\n assert candidate(messages = ['Short', 'Medium length message', 'A very very very long message that spans several words indeed'],senders = ['Alice', 'Alice', 'Alice']) == \"Alice\"\n assert candidate(messages = ['This is a longer message', 'Short', 'Another long message here'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['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'],senders = ['Alice']) == \"Alice\"\n assert candidate(messages = ['a', 'b', 'c', 'd', 'e'],senders = ['Eve', 'Eve', 'Eve', 'Eve', 'Eve']) == \"Eve\"\n assert candidate(messages = ['Equal words', 'Equal words'],senders = ['Frank', 'frank']) == \"frank\"\n assert candidate(messages = ['This is a test message', 'Another test', 'Short one'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['A quick brown fox jumps over the lazy dog', 'Lorem ipsum dolor sit amet', 'Consectetur adipiscing elit', 'Sed do eiusmod tempor incididunt'],senders = ['Sam', 'Sam', 'Sam', 'Sam']) == \"Sam\"\n assert candidate(messages = ['Equal', 'Equal Equal', 'Equal Equal Equal'],senders = ['Mickey', 'mickey', 'MICKEY']) == \"MICKEY\"\n assert candidate(messages = ['Hi Alice', 'Hello Bob', 'How are you Charlie'],senders = ['Bob', 'Alice', 'Bob']) == \"Bob\"\n assert candidate(messages = ['Hello world', 'Good morning', 'How are you doing'],senders = ['Charlie', 'Bob', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Hello world', 'How are you today', 'Hope you are well'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['abc def ghi', 'jkl mno pqr', 'stu vwx yz', 'abc def', 'ghi jkl'],senders = ['Charlie', 'Bob', 'Alice', 'Charlie', 'Alice']) == \"Charlie\"\n assert candidate(messages = ['Word', 'Word Word', 'Word Word Word', 'Word Word Word Word'],senders = ['Zeta', 'Zeta', 'zeta', 'ZETA']) == \"ZETA\"\n assert candidate(messages = ['This is a very long message to test the word count functionality', 'Short msg'],senders = ['Delta', 'delta']) == \"Delta\"\n assert candidate(messages = ['Hi there', 'Hello there', 'Hi there', 'Hello there'],senders = ['Alice', 'Bob', 'Alice', 'Bob']) == \"Bob\"\n assert candidate(messages = ['A', 'B', 'C', 'D'],senders = ['Anna', 'Bob', 'Charlie', 'David']) == \"David\"\n assert candidate(messages = ['One', 'Two words', 'Three words here', 'Four words message test'],senders = ['David', 'David', 'Eve', 'Eve']) == \"Eve\"\n assert candidate(messages = ['Same length', 'Same length', 'Same length', 'Same length'],senders = ['Alice', 'Bob', 'Charlie', 'David']) == \"David\"\n assert candidate(messages = ['Quick brown fox jumps over the lazy dog', 'Lazy dog sleeps', 'Quick fox runs away'],senders = ['Dog', 'Dog', 'Fox']) == \"Dog\"\n assert candidate(messages = ['Equal words here', 'Equal words here', 'Equal words here'],senders = ['Anna', 'Bob', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Multiple messages here', 'Even more messages', 'And yet another message'],senders = ['Kate', 'Kate', 'Laura']) == \"Kate\"\n assert candidate(messages = ['Multiple words in this message', 'Another message with several words', 'Just a few words'],senders = ['SenderX', 'SenderX', 'SenderY']) == \"SenderX\"\n assert candidate(messages = ['Message from Alice', 'Another message from Alice', 'Yet another message from Alice', 'Final message from Alice'],senders = ['Alice', 'Alice', 'Alice', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Message one', 'Message two', 'Message three', 'Message four', 'Message five'],senders = ['Neil', 'Neil', 'Neil', 'Neil', 'Neil']) == \"Neil\"\n assert candidate(messages = ['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'],senders = ['Alice', 'Bob']) == \"Bob\"\n assert candidate(messages = ['Multiple words in this message', 'Few words', 'One'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Equal length message', 'Equal length message'],senders = ['Alice', 'Bob']) == \"Bob\"\n assert candidate(messages = ['word'],senders = ['Z']) == \"Z\"\n assert candidate(messages = ['Single', 'Double words', 'Triple words here'],senders = ['Eve', 'Eve', 'Frank']) == \"Frank\"\n assert candidate(messages = ['Many words in this message to test the word count', 'Few words'],senders = ['Charlie', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Same sender multiple times', 'Same sender multiple times', 'Same sender multiple times'],senders = ['Zoe', 'Zoe', 'Zoe']) == \"Zoe\"\n assert candidate(messages = ['A B C D E', 'F G H', 'I J K L M N O'],senders = ['Dave', 'Eve', 'Frank']) == \"Frank\"\n assert candidate(messages = ['Long message with multiple words indeed', 'Another long message with multiple words indeed'],senders = ['Anna', 'Anna']) == \"Anna\"\n assert candidate(messages = ['A quick brown fox jumps over the lazy dog', 'Lorem ipsum dolor sit amet', 'Python programming'],senders = ['Alice', 'Bob', 'Charlie']) == \"Alice\"\n assert candidate(messages = ['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'],senders = ['Zachary']) == \"Zachary\"\n assert candidate(messages = ['This is a test message', 'Another message here', 'Short one'],senders = ['Alice', 'Bob', 'Charlie']) == \"Alice\"\n assert candidate(messages = ['A quick brown fox jumps over the lazy dog', 'The quick brown fox jumps over the lazy dog'],senders = ['Grace', 'grace']) == \"grace\"\n assert candidate(messages = ['Single', 'Double double', 'Triple triple triple'],senders = ['Alice', 'Bob', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Short message', 'Longer message here', 'Even longer message to check', 'Short again'],senders = ['Bob', 'Charlie', 'Alice', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Short one', 'Another short one'],senders = ['Alice', 'Bob']) == \"Bob\"\n assert candidate(messages = ['One', 'Two words', 'Three words here'],senders = ['Zara', 'Zara', 'Zara']) == \"Zara\"\n assert candidate(messages = ['Unique words in each message', 'Unique words here too', 'More unique words'],senders = ['Zoe', 'Yasmin', 'Xander']) == \"Zoe\"\n assert candidate(messages = ['One', 'Two words', 'Three words here', 'Four words in a sentence'],senders = ['Charlie', 'Alice', 'Bob', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Hello world', 'This is a longer message', 'Another message'],senders = ['Charlie', 'Bob', 'Charlie']) == \"Bob\"\n assert candidate(messages = ['Test message', 'Test message', 'Test message', 'Test message'],senders = ['Jack', 'Jack', 'Jack', 'Jack']) == \"Jack\"\n assert candidate(messages = ['One more message', 'Yet another message', 'Final message'],senders = ['Charlie', 'Charlie', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['Hello world', 'How are you doing today', 'Fine thank you'],senders = ['Charlie', 'Alice', 'Bob']) == \"Alice\"\n assert candidate(messages = ['Hello world', 'This is a test', 'Python programming'],senders = ['Alice', 'Bob', 'Charlie']) == \"Bob\"\n assert candidate(messages = ['Single', 'Two words', 'Three word phrase', 'Four word sentence structure'],senders = ['Zebra', 'Zebra', 'Zebra', 'Zebra']) == \"Zebra\"\n assert candidate(messages = ['Hello world', 'Hello Alice', 'Hello Bob'],senders = ['Bob', 'Alice', 'Bob']) == \"Bob\"\n assert candidate(messages = ['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'],senders = ['SenderA', 'SenderB', 'SenderC']) == \"SenderC\"\n assert candidate(messages = ['Unique message', 'Unique message', 'Unique message'],senders = ['Ian', 'Ian', 'Ian']) == \"Ian\"\n assert candidate(messages = ['Message one', 'Message two', 'Message three', 'Message four'],senders = ['Anna', 'Bob', 'Charlie', 'Bob']) == \"Bob\"\n assert candidate(messages = ['Long message to increase word count significantly', 'Short'],senders = ['Charlie', 'Charlie']) == \"Charlie\"\n assert candidate(messages = ['A quick brown fox jumps over the lazy dog', 'The quick brown fox jumps over the lazy dog', 'Lazy dog'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n"}, "metadata": {"canonical_parameter_names": ["messages", "senders"], "leetcode_dataset_entry_point": "Solution().largestWordCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String largestWordCount(String[] messages, String[] senders) {", "container": "Solution", "callable": "largestWordCount", "parameters": [{"name": "messages", "type": "String[]"}, {"name": "senders", "type": "String[]"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2285, "task_id": "maximum-total-importance-of-roads", "difficulty": "Medium", "problem_description": "You are given an integer n denoting the number of cities in a country. The cities are numbered from 0 to n - 1.\nYou are also given a 2D integer array roads where roads[i] = [ai, bi] denotes that there exists a bidirectional road connecting cities ai and bi.\nYou need to assign each city with an integer value from 1 to n, where each value can only be used once. The importance of a road is then defined as the sum of the values of the two cities it connects.\nReturn the maximum total importance of all roads possible after assigning the values optimally.\n \nExample 1:\n\n\nInput: n = 5, roads = [[0,1],[1,2],[2,3],[0,2],[1,3],[2,4]]\nOutput: 43\nExplanation: The figure above shows the country and the assigned values of [2,4,5,3,1].\n- The road (0,1) has an importance of 2 + 4 = 6.\n- The road (1,2) has an importance of 4 + 5 = 9.\n- The road (2,3) has an importance of 5 + 3 = 8.\n- The road (0,2) has an importance of 2 + 5 = 7.\n- The road (1,3) has an importance of 4 + 3 = 7.\n- The road (2,4) has an importance of 5 + 1 = 6.\nThe total importance of all roads is 6 + 9 + 8 + 7 + 7 + 6 = 43.\nIt can be shown that we cannot obtain a greater total importance than 43.\n\nExample 2:\n\n\nInput: n = 5, roads = [[0,3],[2,4],[1,3]]\nOutput: 20\nExplanation: The figure above shows the country and the assigned values of [4,3,2,5,1].\n- The road (0,3) has an importance of 4 + 5 = 9.\n- The road (2,4) has an importance of 2 + 1 = 3.\n- The road (1,3) has an importance of 3 + 5 = 8.\nThe total importance of all roads is 9 + 3 + 8 = 20.\nIt can be shown that we cannot obtain a greater total importance than 20.\n\n \nConstraints:\n\n2 <= n <= 5 * 104\n1 <= roads.length <= 5 * 104\nroads[i].length == 2\n0 <= ai, bi <= n - 1\nai != bi\nThere are no duplicate roads.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,roads = [[0, 1], [1, 2], [2, 3], [0, 2], [1, 3], [2, 4]]) == 43\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == 45\n assert candidate(n = 3,roads = [[0, 1], [1, 2]]) == 9\n assert candidate(n = 4,roads = [[0, 1], [0, 3], [1, 2], [2, 3]]) == 20\n assert candidate(n = 4,roads = [[0, 1], [1, 2], [2, 3]]) == 17\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [1, 2], [1, 3], [1, 4], [2, 5]]) == 53\n assert candidate(n = 5,roads = [[0, 3], [2, 4], [1, 3]]) == 20\n assert candidate(n = 20,roads = [[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], [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]]) == 947\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 59\n assert candidate(n = 9,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 0], [6, 1], [7, 2], [8, 3]]) == 180\n assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == 72\n assert candidate(n = 10,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 165\n assert candidate(n = 12,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11]]) == 188\n assert candidate(n = 16,roads = [[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], [0, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15], [0, 4], [1, 5], [2, 6], [3, 7], [8, 12], [9, 13], [10, 14], [11, 15]]) == 541\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == 123\n assert candidate(n = 10,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 8], [1, 7], [2, 6], [3, 5], [4, 0], [5, 1], [6, 2], [7, 3], [8, 4]]) == 218\n assert candidate(n = 14,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 6], [5, 7], [6, 8], [6, 9], [7, 10], [7, 11], [8, 12], [8, 13], [9, 10], [9, 11], [10, 12], [10, 13], [11, 12], [11, 13]]) == 444\n assert candidate(n = 14,roads = [[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, 0], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 1], [9, 2], [10, 3], [11, 4], [12, 5], [13, 6]]) == 433\n assert candidate(n = 9,roads = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4], [3, 4], [3, 5], [4, 6], [5, 6], [5, 7], [6, 8], [7, 8]]) == 129\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 6], [6, 7], [7, 8], [8, 9]]) == 164\n assert candidate(n = 20,roads = [[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], [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, 1]]) == 950\n assert candidate(n = 12,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]]) == 234\n assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 4], [1, 5], [2, 6], [3, 7]]) == 108\n assert candidate(n = 8,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 4], [3, 5], [4, 6], [5, 7]]) == 105\n assert candidate(n = 15,roads = [[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], [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]]) == 525\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == 160\n assert candidate(n = 9,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [4, 5], [6, 7], [7, 8]]) == 120\n assert candidate(n = 15,roads = [[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]]) == 315\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 135\n assert candidate(n = 12,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 10], [6, 11], [7, 11], [8, 11], [9, 11]]) == 218\n assert candidate(n = 10,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 110\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [5, 13], [6, 13], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14]]) == 425\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 4], [3, 5], [4, 6], [5, 6]]) == 83\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 222\n assert candidate(n = 15,roads = [[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, 0], [0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 1], [9, 2], [10, 3], [11, 4], [12, 5], [13, 6], [14, 0]]) == 480\n assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2]]) == 144\n assert candidate(n = 20,roads = [[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]]) == 420\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 105\n assert candidate(n = 12,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 10], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]]) == 237\n assert candidate(n = 15,roads = [[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]]) == 279\n assert candidate(n = 20,roads = [[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], [10, 19]]) == 516\n assert candidate(n = 9,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 7], [7, 8]]) == 107\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == 105\n assert candidate(n = 12,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 11]]) == 156\n assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [2, 4], [4, 6], [6, 0]]) == 124\n assert candidate(n = 20,roads = [[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], [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], [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, 16], [2, 17], [2, 18], [2, 19]]) == 1542\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [3, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == 105\n assert candidate(n = 15,roads = [[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], [0, 14]]) == 240\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 6], [4, 5], [5, 6]]) == 78\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [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]]) == 428\n assert candidate(n = 8,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]]) == 101\n assert candidate(n = 15,roads = [[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], [0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9]]) == 345\n assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1]]) == 144\n assert candidate(n = 9,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8], [1, 7], [2, 5], [3, 6], [4, 0]]) == 134\n assert candidate(n = 13,roads = [[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, 11], [6, 12], [7, 8], [8, 9], [9, 10]]) == 258\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 4], [4, 5], [5, 6]]) == 78\n assert candidate(n = 20,roads = [[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], [0, 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, 0], [19, 1]]) == 840\n assert candidate(n = 8,roads = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7]]) == 69\n assert candidate(n = 15,roads = [[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], [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], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14]]) == 822\n assert candidate(n = 12,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 2], [7, 3], [8, 4], [9, 5], [10, 1], [11, 0]]) == 312\n assert candidate(n = 11,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 197\n assert candidate(n = 12,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 231\n assert candidate(n = 9,roads = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == 159\n assert candidate(n = 50000,roads = [[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]]) == 1999620\n assert candidate(n = 15,roads = [[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], [6, 14]]) == 284\n"}, "metadata": {"canonical_parameter_names": ["n", "roads"], "leetcode_dataset_entry_point": "Solution().maximumImportance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumImportance(int n, int[][] roads) {", "container": "Solution", "callable": "maximumImportance", "parameters": [{"name": "n", "type": "int"}, {"name": "roads", "type": "int[][]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2287, "task_id": "rearrange-characters-to-make-target-string", "difficulty": "Easy", "problem_description": "You are given two 0-indexed strings s and target. You can take some letters from s and rearrange them to form new strings.\nReturn the maximum number of copies of target that can be formed by taking letters from s and rearranging them.\n \nExample 1:\n\nInput: s = \"ilovecodingonleetcode\", target = \"code\"\nOutput: 2\nExplanation:\nFor the first copy of \"code\", take the letters at indices 4, 5, 6, and 7.\nFor the second copy of \"code\", take the letters at indices 17, 18, 19, and 20.\nThe strings that are formed are \"ecod\" and \"code\" which can both be rearranged into \"code\".\nWe can make at most two copies of \"code\", so we return 2.\n\nExample 2:\n\nInput: s = \"abcba\", target = \"abc\"\nOutput: 1\nExplanation:\nWe can make one copy of \"abc\" by taking the letters at indices 0, 1, and 2.\nWe can make at most one copy of \"abc\", so we return 1.\nNote that while there is an extra 'a' and 'b' at indices 3 and 4, we cannot reuse the letter 'c' at index 2, so we cannot make a second copy of \"abc\".\n\nExample 3:\n\nInput: s = \"abbaccaddaeea\", target = \"aaaaa\"\nOutput: 1\nExplanation:\nWe can make one copy of \"aaaaa\" by taking the letters at indices 0, 3, 6, 9, and 12.\nWe can make at most one copy of \"aaaaa\", so we return 1.\n\n \nConstraints:\n\n1 <= s.length <= 100\n1 <= target.length <= 10\ns and target consist of lowercase English letters.\n\n \nNote: This question is the same as 1189: Maximum Number of Balloons.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbc\",target = \"abc\") == 1\n assert candidate(s = \"aabbbccc\",target = \"abc\") == 2\n assert candidate(s = \"zzzz\",target = \"zz\") == 2\n assert candidate(s = \"abcabcabc\",target = \"abc\") == 3\n assert candidate(s = \"abcd\",target = \"abce\") == 0\n assert candidate(s = \"abbaccaddaeea\",target = \"aaaaa\") == 1\n assert candidate(s = \"aabbbcc\",target = \"abc\") == 2\n assert candidate(s = \"ilovecodingonleetcode\",target = \"code\") == 2\n assert candidate(s = \"aabbccddeeffgghh\",target = \"abcdefgh\") == 2\n assert candidate(s = \"aabbcc\",target = \"abc\") == 2\n assert candidate(s = \"zzzz\",target = \"zzz\") == 1\n assert candidate(s = \"\",target = \"a\") == 0\n assert candidate(s = \"a\",target = \"a\") == 1\n assert candidate(s = \"abcccccc\",target = \"cat\") == 0\n assert candidate(s = \"aaabbbccc\",target = \"abc\") == 3\n assert candidate(s = \"abcd\",target = \"e\") == 0\n assert candidate(s = \"abcd\",target = \"abcd\") == 1\n assert candidate(s = \"aaaaa\",target = \"a\") == 5\n assert candidate(s = \"abababab\",target = \"abab\") == 2\n assert candidate(s = \"aaa\",target = \"a\") == 3\n assert candidate(s = \"aaaaaaaaaa\",target = \"aa\") == 5\n assert candidate(s = \"pqr\",target = \"ppp\") == 0\n assert candidate(s = \"aaaabbbbcccc\",target = \"abc\") == 4\n assert candidate(s = \"leetcode\",target = \"leet\") == 1\n assert candidate(s = \"abcba\",target = \"abc\") == 1\n assert candidate(s = \"xyz\",target = \"xyzy\") == 0\n assert candidate(s = \"xyz\",target = \"zyx\") == 1\n assert candidate(s = \"programming\",target = \"gram\") == 1\n assert candidate(s = \"ababababababababababab\",target = \"baba\") == 5\n assert candidate(s = \"bbbaaaccdddeefff\",target = \"abcde\") == 2\n assert candidate(s = \"qqwweerrttyyuuiooppaassddffgg\",target = \"qwertyuiopasdfgh\") == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",target = \"zzzz\") == 10\n assert candidate(s = \"elevenletters\",target = \"eleven\") == 1\n assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeff\",target = \"abcdeffedcba\") == 3\n assert candidate(s = \"ppppppppppppppp\",target = \"pppp\") == 3\n assert candidate(s = \"programmingproblems\",target = \"problem\") == 1\n assert candidate(s = \"characterscharacters\",target = \"characters\") == 2\n assert candidate(s = \"hellokitty\",target = \"hello\") == 1\n assert candidate(s = \"repeatedcharacters\",target = \"repeat\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcd\",target = \"abcdabcd\") == 2\n assert candidate(s = \"ppppqqqqrrrsssss\",target = \"pqrs\") == 3\n assert candidate(s = \"xyzxyzxyz\",target = \"xyz\") == 3\n assert candidate(s = \"thisisjustaword\",target = \"word\") == 1\n assert candidate(s = \"bananaananan\",target = \"ana\") == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",target = \"zzzz\") == 8\n assert candidate(s = \"xxxxxyyyyyzzzzzwwwwwvvvvv\",target = \"xyzzwv\") == 2\n assert candidate(s = \"ppqpqqppqppqqqqqqq\",target = \"ppqq\") == 3\n assert candidate(s = \"aabcccccaaa\",target = \"abc\") == 1\n assert candidate(s = \"xyzzyxzyzyzxzyxzy\",target = \"zyx\") == 4\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppp\",target = \"p\") == 52\n assert candidate(s = \"abcdefghij\",target = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\",target = \"abcdefghijkmnopqrstuvwxyz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",target = \"abcdefghijklmnopqrstuvwxyz\") == 2\n assert candidate(s = \"quickbrownfox\",target = \"quick\") == 1\n assert candidate(s = \"abracadabra\",target = \"abrac\") == 1\n assert candidate(s = \"aabbbcccddddeeeeeffffffggggghhhhhhiiiiiiijjjjjjjjkkkkkkkkkllllllllllmmmmmmmmmmmnnnnnnnnnnnoooooo\",target = \"abcdefghijklmno\") == 2\n assert candidate(s = \"aaabbbcccddd\",target = \"abcd\") == 3\n assert candidate(s = \"jumpoverthelazydog\",target = \"dogjump\") == 1\n assert candidate(s = \"xyxxyxyxyxyx\",target = \"xyx\") == 3\n assert candidate(s = \"bananana\",target = \"banana\") == 1\n assert candidate(s = \"supercalifragilisticexpialidocious\",target = \"super\") == 2\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",target = \"xyz\") == 1\n assert candidate(s = \"programmingisfun\",target = \"fun\") == 1\n assert candidate(s = \"rearrangerearrangerearrange\",target = \"range\") == 3\n assert candidate(s = \"aaabbbccc\",target = \"abcabc\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",target = \"a\") == 91\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccdddddddd\",target = \"abcdabcdabcd\") == 2\n assert candidate(s = \"aabbbcccdddeeefff\",target = \"abcdef\") == 2\n assert candidate(s = \"abacabadabacaba\",target = \"abc\") == 2\n assert candidate(s = \"mississippi\",target = \"issi\") == 2\n assert candidate(s = \"babbbababbaba\",target = \"bab\") == 4\n assert candidate(s = \"abacabadabacaba\",target = \"abac\") == 2\n assert candidate(s = \"aabbaabbaabb\",target = \"aabb\") == 3\n assert candidate(s = \"nfaivnfainfainfainfainfafinainfnainfaianfaianfaianfaianfaianfaianfaianfaianfaianfaianfai\",target = \"nfa\") == 19\n assert candidate(s = \"abcdefgabcdefgabcdefg\",target = \"abcdefg\") == 3\n assert candidate(s = \"qpwoeirutyalskdjfhgmznxbcv\",target = \"qwerty\") == 1\n assert candidate(s = \"everygoodboydoesfine\",target = \"every\") == 1\n assert candidate(s = \"aabbcc\",target = \"abcabc\") == 1\n assert candidate(s = \"aabbbccddeeefff\",target = \"abcdef\") == 2\n assert candidate(s = \"xyxxyxyxyx\",target = \"xyx\") == 3\n assert candidate(s = \"aabbcc\",target = \"aab\") == 1\n assert candidate(s = \"xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy\",target = \"zyx\") == 23\n assert candidate(s = \"aabbcdeffgghhiijk\",target = \"abcdefghij\") == 1\n assert candidate(s = \"wassupwassupwassup\",target = \"wassup\") == 3\n assert candidate(s = \"abracadabra\",target = \"abra\") == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"xyzxyzxyzxyzxyz\",target = \"xyzxyz\") == 2\n assert candidate(s = \"testtesttesttest\",target = \"test\") == 4\n assert candidate(s = \"rearrangerearrange\",target = \"rearrange\") == 2\n assert candidate(s = \"optimization\",target = \"on\") == 1\n assert candidate(s = \"aaaaaaaaaaa\",target = \"aaaaa\") == 2\n assert candidate(s = \"qqwweerrttyyuuiiooppllaa\",target = \"typewriter\") == 1\n assert candidate(s = \"balloonballoonballoon\",target = \"balloon\") == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",target = \"mnopqrstuvwxyz\") == 2\n assert candidate(s = \"nnnoooiii\",target = \"noon\") == 1\n assert candidate(s = \"abracadabra\",target = \"cab\") == 1\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\",target = \"xyz\") == 6\n assert candidate(s = \"xylophonephonexylo\",target = \"xylo\") == 2\n assert candidate(s = \"abcabcabcabcabc\",target = \"abcabc\") == 2\n assert candidate(s = \"babababababababab\",target = \"abba\") == 4\n assert candidate(s = \"abcabcabcabcabc\",target = \"ab\") == 5\n assert candidate(s = \"aaaabbbbccccdddd\",target = \"abcd\") == 4\n assert candidate(s = \"rearrangecharacters\",target = \"char\") == 1\n assert candidate(s = \"elephantelephant\",target = \"elephant\") == 2\n assert candidate(s = \"fifteenlettersfifteenletters\",target = \"fifteen\") == 2\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",target = \"thequickbrownfoxjumpsoverthelazydog\") == 1\n assert candidate(s = \"thisthisthisthisthisthisisthisthisthisthisthis\",target = \"this\") == 11\n assert candidate(s = \"supercalifragilisticexpialidocious\",target = \"supercali\") == 2\n assert candidate(s = \"mississippi\",target = \"issip\") == 2\n assert candidate(s = \"aabbccddeeff\",target = \"abcdef\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",target = \"zyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"babababa\",target = \"ba\") == 4\n assert candidate(s = \"abcdabcdabcdabcdabcd\",target = \"abcd\") == 5\n assert candidate(s = \"xylophone\",target = \"xyl\") == 1\n assert candidate(s = \"abcdabcdabcd\",target = \"abcd\") == 3\n assert candidate(s = \"thisisaverylongstringwithmanylettersinittomakeitmorechallengingtotest\",target = \"thisis\") == 2\n assert candidate(s = \"balloonballoon\",target = \"balloon\") == 2\n assert candidate(s = \"packmyboxwithfivedozenliquorjugs\",target = \"boxwith\") == 1\n assert candidate(s = \"bananaapple\",target = \"ana\") == 2\n assert candidate(s = \"qwerqwerqwerqwer\",target = \"qwerqwer\") == 2\n assert candidate(s = \"thefiveboxingwizardsjumpquickly\",target = \"jump\") == 1\n assert candidate(s = \"algorithmsarecool\",target = \"cool\") == 1\n assert candidate(s = \"exampleexampleexampleexampleexampleexample\",target = \"example\") == 6\n assert candidate(s = \"xylophone\",target = \"phonex\") == 1\n assert candidate(s = \"thisisaverylongstringthatyoumightfindchallengingtorearrange\",target = \"string\") == 3\n assert candidate(s = \"bananaananabanananana\",target = \"nana\") == 4\n assert candidate(s = \"hellohellohellohello\",target = \"hello\") == 4\n assert candidate(s = \"abracadabra\",target = \"abraca\") == 1\n assert candidate(s = \"hellohellohello\",target = \"hello\") == 3\n"}, "metadata": {"canonical_parameter_names": ["s", "target"], "leetcode_dataset_entry_point": "Solution().rearrangeCharacters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int rearrangeCharacters(String s, String target) {", "container": "Solution", "callable": "rearrangeCharacters", "parameters": [{"name": "s", "type": "String"}, {"name": "target", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2288, "task_id": "apply-discount-to-prices", "difficulty": "Medium", "problem_description": "A sentence is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign '$'. A word represents a price if it is a sequence of digits preceded by a dollar sign.\n\nFor example, \"$100\", \"$23\", and \"$6\" represent prices while \"100\", \"$\", and \"$1e5\" do not.\n\nYou are given a string sentence representing a sentence and an integer discount. For each word representing a price, apply a discount of discount% on the price and update the word in the sentence. All updated prices should be represented with exactly two decimal places.\nReturn a string representing the modified sentence.\nNote that all prices will contain at most 10 digits.\n \nExample 1:\n\nInput: sentence = \"there are $1 $2 and 5$ candies in the shop\", discount = 50\nOutput: \"there are $0.50 $1.00 and 5$ candies in the shop\"\nExplanation: \nThe words which represent prices are \"$1\" and \"$2\". \n- A 50% discount on \"$1\" yields \"$0.50\", so \"$1\" is replaced by \"$0.50\".\n- A 50% discount on \"$2\" yields \"$1\". Since we need to have exactly 2 decimal places after a price, we replace \"$2\" with \"$1.00\".\n\nExample 2:\n\nInput: sentence = \"1 2 $3 4 $5 $6 7 8$ $9 $10$\", discount = 100\nOutput: \"1 2 $0.00 4 $0.00 $0.00 7 8$ $0.00 $10$\"\nExplanation: \nApplying a 100% discount on any price will result in 0.\nThe words representing prices are \"$3\", \"$5\", \"$6\", and \"$9\".\nEach of them is replaced by \"$0.00\".\n\n \nConstraints:\n\n1 <= sentence.length <= 105\nsentence consists of lowercase English letters, digits, ' ', and '$'.\nsentence does not have leading or trailing spaces.\nAll words in sentence are separated by a single space.\nAll prices will be positive numbers without leading zeros.\nAll prices will have at most 10 digits.\n0 <= discount <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"$10 $20 $30 $40 $50\",discount = 0) == \"$10.00 $20.00 $30.00 $40.00 $50.00\"\n assert candidate(sentence = \"$100 $200 $300\",discount = 25) == \"$75.00 $150.00 $225.00\"\n assert candidate(sentence = \"no prices here\",discount = 20) == \"no prices here\"\n assert candidate(sentence = \"1 2 $3 4 $5 $6 7 8$ $9 $10$\",discount = 100) == \"1 2 $0.00 4 $0.00 $0.00 7 8$ $0.00 $10$\"\n assert candidate(sentence = \"there are $1 $2 and 5$ candies in the shop\",discount = 50) == \"there are $0.50 $1.00 and 5$ candies in the shop\"\n assert candidate(sentence = \"no prices here\",discount = 10) == \"no prices here\"\n assert candidate(sentence = \"$9999999999 $1\",discount = 99) == \"$99999999.99 $0.01\"\n assert candidate(sentence = \"$9999999999 $10000000000 $11111111111\",discount = 10) == \"$8999999999.10 $9000000000.00 $9999999999.90\"\n assert candidate(sentence = \"$999 $888 $777 $666 $555 $444 $333 $222 $111 $000\",discount = 90) == \"$99.90 $88.80 $77.70 $66.60 $55.50 $44.40 $33.30 $22.20 $11.10 $0.00\"\n assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000\",discount = 15) == \"$85.00 $170.00 $255.00 $340.00 $425.00 $510.00 $595.00 $680.00 $765.00 $850.00\"\n assert candidate(sentence = \"$0 $00 $000 $0000 $00000\",discount = 100) == \"$0.00 $0.00 $0.00 $0.00 $0.00\"\n assert candidate(sentence = \"$123.45 $678.90 $456.78 $901.23\",discount = 15) == \"$123.45 $678.90 $456.78 $901.23\"\n assert candidate(sentence = \"$1000000000 $999999999 $1111111111 $2222222222 $3333333333\",discount = 75) == \"$250000000.00 $249999999.75 $277777777.75 $555555555.50 $833333333.25\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $0\",discount = 75) == \"$0.25 $0.50 $0.75 $1.00 $1.25 $1.50 $1.75 $2.00 $2.25 $0.00\"\n assert candidate(sentence = \"$123456 $654321 $111111 $222222\",discount = 75) == \"$30864.00 $163580.25 $27777.75 $55555.50\"\n assert candidate(sentence = \"$1.50 $2.50 $3.50 $4.50 $5.50\",discount = 50) == \"$1.50 $2.50 $3.50 $4.50 $5.50\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10\",discount = 20) == \"$0.80 $1.60 $2.40 $3.20 $4.00 $4.80 $5.60 $6.40 $7.20 $8.00\"\n assert candidate(sentence = \"$0 $1 $2 $3 $4 $5 $6 $7 $8 $9\",discount = 10) == \"$0.00 $0.90 $1.80 $2.70 $3.60 $4.50 $5.40 $6.30 $7.20 $8.10\"\n assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000 $1100 $1200 $1300 $1400 $1500\",discount = 10) == \"$90.00 $180.00 $270.00 $360.00 $450.00 $540.00 $630.00 $720.00 $810.00 $900.00 $990.00 $1080.00 $1170.00 $1260.00 $1350.00\"\n assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100\",discount = 100) == \"$0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00\"\n assert candidate(sentence = \"$1.23 $4.56 $7.89 $10.11 $12.13\",discount = 50) == \"$1.23 $4.56 $7.89 $10.11 $12.13\"\n assert candidate(sentence = \"$100.00 $200.00 $300.00\",discount = 50) == \"$100.00 $200.00 $300.00\"\n assert candidate(sentence = \"$999999999 $111111111 $222222222 $333333333 $444444444\",discount = 90) == \"$99999999.90 $11111111.10 $22222222.20 $33333333.30 $44444444.40\"\n assert candidate(sentence = \"$1000000000 $999999999 $888888888 $777777777 $666666666 $555555555 $444444444 $333333333 $222222222 $111111111\",discount = 1) == \"$990000000.00 $989999999.01 $879999999.12 $769999999.23 $659999999.34 $549999999.45 $439999999.56 $329999999.67 $219999999.78 $109999999.89\"\n assert candidate(sentence = \"$12345678901234567890 $98765432109876543210 $10000000001000000000\",discount = 50) == \"$6172839450617283584.00 $49382716054938271744.00 $5000000000499999744.00\"\n assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000\",discount = 99) == \"$1.00 $2.00 $3.00 $4.00 $5.00 $6.00 $7.00 $8.00 $9.00 $10.00\"\n assert candidate(sentence = \"$9999999999 this is a very long sentence with many $100 prices $500 and $1000\",discount = 20) == \"$7999999999.20 this is a very long sentence with many $80.00 prices $400.00 and $800.00\"\n assert candidate(sentence = \"$1million $1billion $1trillion\",discount = 50) == \"$1million $1billion $1trillion\"\n assert candidate(sentence = \"$1000000 $2000000 $3000000 $4000000\",discount = 30) == \"$700000.00 $1400000.00 $2100000.00 $2800000.00\"\n assert candidate(sentence = \"$500 $1000 $1500 $2000\",discount = 20) == \"$400.00 $800.00 $1200.00 $1600.00\"\n assert candidate(sentence = \"$1.5 $2.5 $3.5 $4.5 $5.5\",discount = 10) == \"$1.5 $2.5 $3.5 $4.5 $5.5\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 10) == \"$0.90 $1.80 $2.70 $3.60 $4.50 $5.40 $6.30 $7.20 $8.10 $9.00 $9.90 $10.80 $11.70 $12.60 $13.50 $14.40 $15.30 $16.20 $17.10 $18.00\"\n assert candidate(sentence = \"$9999999999 $1000000000 $123456789\",discount = 5) == \"$9499999999.05 $950000000.00 $117283949.55\"\n assert candidate(sentence = \"$999999999 $888888888 $777777777 $666666666 $555555555\",discount = 20) == \"$799999999.20 $711111110.40 $622222221.60 $533333332.80 $444444444.00\"\n assert candidate(sentence = \"$1234567890 $123456789 $12345678 $1234567 $123456 $12345 $1234 $123 $12 $1\",discount = 10) == \"$1111111101.00 $111111110.10 $11111110.20 $1111110.30 $111110.40 $11110.50 $1110.60 $110.70 $10.80 $0.90\"\n assert candidate(sentence = \"$1 $10 $100 $1000 $10000 $100000 $1000000 $10000000 $100000000 $1000000000\",discount = 99) == \"$0.01 $0.10 $1.00 $10.00 $100.00 $1000.00 $10000.00 $100000.00 $1000000.00 $10000000.00\"\n assert candidate(sentence = \"$12345 $67890 $54321 $98760 $13579 $24680\",discount = 30) == \"$8641.50 $47523.00 $38024.70 $69132.00 $9505.30 $17276.00\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 95) == \"$0.05 $0.10 $0.15 $0.20 $0.25 $0.30 $0.35 $0.40 $0.45 $0.50 $0.55 $0.60 $0.65 $0.70 $0.75 $0.80 $0.85 $0.90 $0.95 $1.00\"\n assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100\",discount = 5) == \"$9.50 $19.00 $28.50 $38.00 $47.50 $57.00 $66.50 $76.00 $85.50 $95.00\"\n assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100\",discount = 20) == \"$8.00 $16.00 $24.00 $32.00 $40.00 $48.00 $56.00 $64.00 $72.00 $80.00\"\n assert candidate(sentence = \"$9999999999\",discount = 1) == \"$9899999999.01\"\n assert candidate(sentence = \"$100abc $abc100 $100$ $100 $200\",discount = 10) == \"$100abc $abc100 $100$ $90.00 $180.00\"\n assert candidate(sentence = \"$9999999999 is the max price and $1 is the min price in this sentence\",discount = 5) == \"$9499999999.05 is the max price and $0.95 is the min price in this sentence\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $0\",discount = 50) == \"$0.50 $1.00 $1.50 $2.00 $2.50 $3.00 $3.50 $4.00 $4.50 $0.00 $0.50 $1.00 $1.50 $2.00 $2.50 $3.00 $3.50 $4.00 $4.50 $0.00\"\n assert candidate(sentence = \"$10000000000 $20000000000 $30000000000\",discount = 50) == \"$5000000000.00 $10000000000.00 $15000000000.00\"\n assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000 $1100 $1200 $1300 $1400 $1500 $1600 $1700 $1800 $1900 $2000\",discount = 75) == \"$25.00 $50.00 $75.00 $100.00 $125.00 $150.00 $175.00 $200.00 $225.00 $250.00 $275.00 $300.00 $325.00 $350.00 $375.00 $400.00 $425.00 $450.00 $475.00 $500.00\"\n assert candidate(sentence = \"$12345 $67890 $54321 $98765 $13579 $24680\",discount = 30) == \"$8641.50 $47523.00 $38024.70 $69135.50 $9505.30 $17276.00\"\n assert candidate(sentence = \"$0\",discount = 100) == \"$0.00\"\n assert candidate(sentence = \"$1234567890 $987654321 $1000000000\",discount = 10) == \"$1111111101.00 $888888888.90 $900000000.00\"\n assert candidate(sentence = \"$9 $99 $999 $9999 $99999 $999999 $9999999 $99999999 $999999999 $9999999999\",discount = 90) == \"$0.90 $9.90 $99.90 $999.90 $9999.90 $99999.90 $999999.90 $9999999.90 $99999999.90 $999999999.90\"\n assert candidate(sentence = \"$1234567890 $9876543210 $1111111111 $2222222222 $3333333333 $4444444444 $5555555555 $6666666666 $7777777777 $8888888888\",discount = 10) == \"$1111111101.00 $8888888889.00 $999999999.90 $1999999999.80 $2999999999.70 $3999999999.60 $4999999999.50 $5999999999.40 $6999999999.30 $7999999999.20\"\n assert candidate(sentence = \"$9999999999 $1000000000 $123456789\",discount = 10) == \"$8999999999.10 $900000000.00 $111111110.10\"\n assert candidate(sentence = \"$1000000 $2000000 $3000000 $4000000 $5000000\",discount = 0) == \"$1000000.00 $2000000.00 $3000000.00 $4000000.00 $5000000.00\"\n assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100\",discount = 0) == \"$10.00 $20.00 $30.00 $40.00 $50.00 $60.00 $70.00 $80.00 $90.00 $100.00\"\n assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100 $110 $120 $130 $140 $150\",discount = 30) == \"$7.00 $14.00 $21.00 $28.00 $35.00 $42.00 $49.00 $56.00 $63.00 $70.00 $77.00 $84.00 $91.00 $98.00 $105.00\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 99) == \"$0.01 $0.02 $0.03 $0.04 $0.05 $0.06 $0.07 $0.08 $0.09 $0.10 $0.11 $0.12 $0.13 $0.14 $0.15 $0.16 $0.17 $0.18 $0.19 $0.20\"\n assert candidate(sentence = \"$1000 $2000 $3000\",discount = 95) == \"$50.00 $100.00 $150.00\"\n assert candidate(sentence = \"$9999999999 $8888888888 $7777777777 $6666666666 $5555555555\",discount = 0) == \"$9999999999.00 $8888888888.00 $7777777777.00 $6666666666.00 $5555555555.00\"\n assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000\",discount = 0) == \"$100.00 $200.00 $300.00 $400.00 $500.00 $600.00 $700.00 $800.00 $900.00 $1000.00\"\n assert candidate(sentence = \"$1000000000 $999999999 $888888888 $777777777 $666666666 $555555555 $444444444 $333333333 $222222222 $111111111\",discount = 15) == \"$850000000.00 $849999999.15 $755555554.80 $661111110.45 $566666666.10 $472222221.75 $377777777.40 $283333333.05 $188888888.70 $94444444.35\"\n assert candidate(sentence = \"$100000 $200000 $300000 $400000 $500000\",discount = 20) == \"$80000.00 $160000.00 $240000.00 $320000.00 $400000.00\"\n assert candidate(sentence = \"$123abc $456def $789ghi $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 15) == \"$123abc $456def $789ghi $0.00 $0.85 $1.70 $2.55 $3.40 $4.25 $5.10 $5.95 $6.80 $7.65 $8.50 $9.35 $10.20 $11.05 $11.90 $12.75 $13.60 $14.45 $15.30 $16.15 $17.00\"\n assert candidate(sentence = \"$9999999999 $1000000000 $100000000 $10000000 $1000000 $100000 $10000 $1000 $100 $10 $1\",discount = 5) == \"$9499999999.05 $950000000.00 $95000000.00 $9500000.00 $950000.00 $95000.00 $9500.00 $950.00 $95.00 $9.50 $0.95\"\n assert candidate(sentence = \"$123.45 $67.89 $10.11 $0.01 $1000000000.99\",discount = 10) == \"$123.45 $67.89 $10.11 $0.01 $1000000000.99\"\n assert candidate(sentence = \"$123 $456 $789 $012 $345 $678 $901 $234 $567 $890 $123456789 $987654321 $111111111 $222222222 $333333333 $444444444 $555555555 $666666666 $777777777 $888888888 $999999999 $1000000000 $2000000000 $3000000000\",discount = 30) == \"$86.10 $319.20 $552.30 $8.40 $241.50 $474.60 $630.70 $163.80 $396.90 $623.00 $86419752.30 $691358024.70 $77777777.70 $155555555.40 $233333333.10 $311111110.80 $388888888.50 $466666666.20 $544444443.90 $622222221.60 $699999999.30 $700000000.00 $1400000000.00 $2100000000.00\"\n assert candidate(sentence = \"$5 $15 $25 $35 $45 $55 $65 $75 $85 $95\",discount = 75) == \"$1.25 $3.75 $6.25 $8.75 $11.25 $13.75 $16.25 $18.75 $21.25 $23.75\"\n assert candidate(sentence = \"$50 apples $20 oranges $30 bananas $10 grapes\",discount = 30) == \"$35.00 apples $14.00 oranges $21.00 bananas $7.00 grapes\"\n assert candidate(sentence = \"$9999999999 $123456789 $9876543210 $1000000000 $500000000\",discount = 15) == \"$8499999999.15 $104938270.65 $8395061728.50 $850000000.00 $425000000.00\"\n assert candidate(sentence = \"$0 $00 $000 $0000 $00000\",discount = 20) == \"$0.00 $0.00 $0.00 $0.00 $0.00\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15\",discount = 0) == \"$1.00 $2.00 $3.00 $4.00 $5.00 $6.00 $7.00 $8.00 $9.00 $10.00 $11.00 $12.00 $13.00 $14.00 $15.00\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10\",discount = 5) == \"$0.95 $1.90 $2.85 $3.80 $4.75 $5.70 $6.65 $7.60 $8.55 $9.50\"\n assert candidate(sentence = \"$1234567890 $9876543210 $1000000000\",discount = 5) == \"$1172839495.50 $9382716049.50 $950000000.00\"\n assert candidate(sentence = \"$1000000000 $999999999 $888888888 $777777777\",discount = 50) == \"$500000000.00 $499999999.50 $444444444.00 $388888888.50\"\n assert candidate(sentence = \"$1234567890 $9876543210 $1000000000\",discount = 15) == \"$1049382706.50 $8395061728.50 $850000000.00\"\n assert candidate(sentence = \"$9999999999 $8888888888 $7777777777 $6666666666 $5555555555 $4444444444 $3333333333 $2222222222 $1111111111 $1\",discount = 99) == \"$99999999.99 $88888888.88 $77777777.77 $66666666.66 $55555555.55 $44444444.44 $33333333.33 $22222222.22 $11111111.11 $0.01\"\n assert candidate(sentence = \"$123 $456 $789 $101112 $131415 $161718 $192021 $222324 $252627 $282930\",discount = 25) == \"$92.25 $342.00 $591.75 $75834.00 $98561.25 $121288.50 $144015.75 $166743.00 $189470.25 $212197.50\"\n assert candidate(sentence = \"$1000 $2000 $3000 $4000 $5000 $6000 $7000 $8000 $9000 $10000\",discount = 75) == \"$250.00 $500.00 $750.00 $1000.00 $1250.00 $1500.00 $1750.00 $2000.00 $2250.00 $2500.00\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 50) == \"$0.50 $1.00 $1.50 $2.00 $2.50 $3.00 $3.50 $4.00 $4.50 $5.00 $5.50 $6.00 $6.50 $7.00 $7.50 $8.00 $8.50 $9.00 $9.50 $10.00\"\n assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000\",discount = 20) == \"$80.00 $160.00 $240.00 $320.00 $400.00 $480.00 $560.00 $640.00 $720.00 $800.00\"\n assert candidate(sentence = \"$999999999 $888888888 $777777777 $666666666 $555555555\",discount = 30) == \"$699999999.30 $622222221.60 $544444443.90 $466666666.20 $388888888.50\"\n assert candidate(sentence = \"$9999999999 $8888888888 $7777777777\",discount = 5) == \"$9499999999.05 $8444444443.60 $7388888888.15\"\n assert candidate(sentence = \"$1000000000 $100000000 $10000000 $1000000 $100000 $10000 $1000 $100 $10 $1\",discount = 5) == \"$950000000.00 $95000000.00 $9500000.00 $950000.00 $95000.00 $9500.00 $950.00 $95.00 $9.50 $0.95\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 15) == \"$0.85 $1.70 $2.55 $3.40 $4.25 $5.10 $5.95 $6.80 $7.65 $8.50 $9.35 $10.20 $11.05 $11.90 $12.75 $13.60 $14.45 $15.30 $16.15 $17.00\"\n assert candidate(sentence = \"$9999999999 $8888888888 $7777777777 $6666666666 $5555555555 $4444444444 $3333333333 $2222222222 $1111111111 $1000000000 $999999999 $888888888 $777777777 $666666666 $555555555 $444444444 $333333333 $222222222 $111111111 $100000000 $99999999 $88888888 $77777777 $66666666 $55555555 $44444444 $33333333 $22222222 $11111111 $10000000 $9999999 $8888888 $7777777 $6666666 $5555555 $4444444 $3333333 $2222222 $1111111 $1000000 $999999 $888888 $777777 $666666 $555555 $444444 $333333 $222222 $111111 $100000 $99999 $88888 $77777 $66666 $55555 $44444 $33333 $22222 $11111 $10000 $9999 $8888 $7777 $6666 $5555 $4444 $3333 $2222 $1111 $1000 $999 $888 $777 $666 $555 $444 $333 $222 $111 $100 $99 $88 $77 $66 $55 $44 $33 $22 $11 $1\",discount = 10) == \"$8999999999.10 $7999999999.20 $6999999999.30 $5999999999.40 $4999999999.50 $3999999999.60 $2999999999.70 $1999999999.80 $999999999.90 $900000000.00 $899999999.10 $799999999.20 $699999999.30 $599999999.40 $499999999.50 $399999999.60 $299999999.70 $199999999.80 $99999999.90 $90000000.00 $89999999.10 $79999999.20 $69999999.30 $59999999.40 $49999999.50 $39999999.60 $29999999.70 $19999999.80 $9999999.90 $9000000.00 $8999999.10 $7999999.20 $6999999.30 $5999999.40 $4999999.50 $3999999.60 $2999999.70 $1999999.80 $999999.90 $900000.00 $899999.10 $799999.20 $699999.30 $599999.40 $499999.50 $399999.60 $299999.70 $199999.80 $99999.90 $90000.00 $89999.10 $79999.20 $69999.30 $59999.40 $49999.50 $39999.60 $29999.70 $19999.80 $9999.90 $9000.00 $8999.10 $7999.20 $6999.30 $5999.40 $4999.50 $3999.60 $2999.70 $1999.80 $999.90 $900.00 $899.10 $799.20 $699.30 $599.40 $499.50 $399.60 $299.70 $199.80 $99.90 $90.00 $89.10 $79.20 $69.30 $59.40 $49.50 $39.60 $29.70 $19.80 $9.90 $0.90\"\n assert candidate(sentence = \"$100 abc $200 def $300 ghi $400 jkl $500 mno\",discount = 75) == \"$25.00 abc $50.00 def $75.00 ghi $100.00 jkl $125.00 mno\"\n assert candidate(sentence = \"$1234 $5678 $91011 $121314 $151617 $181920 $212223 $242526 $272829 $303132\",discount = 20) == \"$987.20 $4542.40 $72808.80 $97051.20 $121293.60 $145536.00 $169778.40 $194020.80 $218263.20 $242505.60\"\n assert candidate(sentence = \"$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\",discount = 100) == \"$0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00\"\n assert candidate(sentence = \"$1234567890 $987654321 $1000000000 $500000000 $250000000 $125000000 $62500000 $31250000 $15625000 $7812500 $3906250 $1953125 $976562 $488281 $244140 $122070 $61035 $30517 $15258 $7629 $3814 $1907 $953 $476 $238 $119 $59 $29 $14 $7 $3 $1\",discount = 10) == \"$1111111101.00 $888888888.90 $900000000.00 $450000000.00 $225000000.00 $112500000.00 $56250000.00 $28125000.00 $14062500.00 $7031250.00 $3515625.00 $1757812.50 $878905.80 $439452.90 $219726.00 $109863.00 $54931.50 $27465.30 $13732.20 $6866.10 $3432.60 $1716.30 $857.70 $428.40 $214.20 $107.10 $53.10 $26.10 $12.60 $6.30 $2.70 $0.90\"\n assert candidate(sentence = \"$123.45 $678.90 $100.00\",discount = 15) == \"$123.45 $678.90 $100.00\"\n assert candidate(sentence = \"$123 $456 $789 $1011 $1213 $1415 $1617 $1819 $2021 $2223 $2425 $2627 $2829 $3031 $3233\",discount = 25) == \"$92.25 $342.00 $591.75 $758.25 $909.75 $1061.25 $1212.75 $1364.25 $1515.75 $1667.25 $1818.75 $1970.25 $2121.75 $2273.25 $2424.75\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10\",discount = 90) == \"$0.10 $0.20 $0.30 $0.40 $0.50 $0.60 $0.70 $0.80 $0.90 $1.00\"\n assert candidate(sentence = \"$10.50 $20.25 $30.75\",discount = 50) == \"$10.50 $20.25 $30.75\"\n assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15\",discount = 5) == \"$0.95 $1.90 $2.85 $3.80 $4.75 $5.70 $6.65 $7.60 $8.55 $9.50 $10.45 $11.40 $12.35 $13.30 $14.25\"\n assert candidate(sentence = \"$9 $8 $7 $6 $5 $4 $3 $2 $1 $0\",discount = 100) == \"$0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00\"\n assert candidate(sentence = \"$123 $456 $789 $101112 $131415 $161718\",discount = 75) == \"$30.75 $114.00 $197.25 $25278.00 $32853.75 $40429.50\"\n assert candidate(sentence = \"$1 $10 $100 $1000 $10000 $100000 $1000000 $10000000 $100000000 $1000000000\",discount = 50) == \"$0.50 $5.00 $50.00 $500.00 $5000.00 $50000.00 $500000.00 $5000000.00 $50000000.00 $500000000.00\"\n assert candidate(sentence = \"$1234.56 $789.01 $456.78 $123.45 $678.90 $901.23 $234.56 $567.89 $890.12 $123.45\",discount = 20) == \"$1234.56 $789.01 $456.78 $123.45 $678.90 $901.23 $234.56 $567.89 $890.12 $123.45\"\n assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100 $110 $120 $130 $140 $150\",discount = 75) == \"$2.50 $5.00 $7.50 $10.00 $12.50 $15.00 $17.50 $20.00 $22.50 $25.00 $27.50 $30.00 $32.50 $35.00 $37.50\"\n assert candidate(sentence = \"$1000000000 this is a test with one big $9999999999 price and a small $1\",discount = 1) == \"$990000000.00 this is a test with one big $9899999999.01 price and a small $0.99\"\n assert candidate(sentence = \"$0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10\",discount = 50) == \"$0.00 $0.50 $1.00 $1.50 $2.00 $2.50 $3.00 $3.50 $4.00 $4.50 $5.00\"\n assert candidate(sentence = \"$9999999999 $8888888888 $7777777777 $6666666666 $5555555555\",discount = 1) == \"$9899999999.01 $8799999999.12 $7699999999.23 $6599999999.34 $5499999999.45\"\n assert candidate(sentence = \"$1 $10 $100 $1000 $10000 $100000 $1000000 $10000000 $100000000 $1000000000 $10000000000\",discount = 5) == \"$0.95 $9.50 $95.00 $950.00 $9500.00 $95000.00 $950000.00 $9500000.00 $95000000.00 $950000000.00 $9500000000.00\"\n assert candidate(sentence = \"$9999999999 $8888888888 $7777777777 $6666666666 $5555555555 $4444444444 $3333333333 $2222222222 $1111111111 $1000000000\",discount = 50) == \"$4999999999.50 $4444444444.00 $3888888888.50 $3333333333.00 $2777777777.50 $2222222222.00 $1666666666.50 $1111111111.00 $555555555.50 $500000000.00\"\n assert candidate(sentence = \"$50 apples and $30 bananas, $20 oranges\",discount = 20) == \"$40.00 apples and $24.00 bananas, $16.00 oranges\"\n assert candidate(sentence = \"$9999999999 $999999999 $99999999 $9999999 $999999 $99999 $9999 $999 $99 $9\",discount = 0) == \"$9999999999.00 $999999999.00 $99999999.00 $9999999.00 $999999.00 $99999.00 $9999.00 $999.00 $99.00 $9.00\"\n assert candidate(sentence = \"$999999999 $888888888 $777777777 $666666666 $555555555 $444444444 $333333333 $222222222 $111111111 $1\",discount = 50) == \"$499999999.50 $444444444.00 $388888888.50 $333333333.00 $277777777.50 $222222222.00 $166666666.50 $111111111.00 $55555555.50 $0.50\"\n assert candidate(sentence = \"$0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 10) == \"$0.00 $0.90 $1.80 $2.70 $3.60 $4.50 $5.40 $6.30 $7.20 $8.10 $9.00 $9.90 $10.80 $11.70 $12.60 $13.50 $14.40 $15.30 $16.20 $17.10 $18.00\"\n assert candidate(sentence = \"$999 $888 $777 $666 $555 $444 $333 $222 $111 $10\",discount = 99) == \"$9.99 $8.88 $7.77 $6.66 $5.55 $4.44 $3.33 $2.22 $1.11 $0.10\"\n"}, "metadata": {"canonical_parameter_names": ["sentence", "discount"], "leetcode_dataset_entry_point": "Solution().discountPrices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String discountPrices(String sentence, int discount) {", "container": "Solution", "callable": "discountPrices", "parameters": [{"name": "sentence", "type": "String"}, {"name": "discount", "type": "int"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2289, "task_id": "steps-to-make-array-non-decreasing", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i - 1] > nums[i] for all 0 < i < nums.length.\nReturn the number of steps performed until nums becomes a non-decreasing array.\n \nExample 1:\n\nInput: nums = [5,3,4,4,7,3,6,11,8,5,11]\nOutput: 3\nExplanation: The following are the steps performed:\n- Step 1: [5,3,4,4,7,3,6,11,8,5,11] becomes [5,4,4,7,6,11,11]\n- Step 2: [5,4,4,7,6,11,11] becomes [5,4,7,11,11]\n- Step 3: [5,4,7,11,11] becomes [5,7,11,11]\n[5,7,11,11] is a non-decreasing array. Therefore, we return 3.\n\nExample 2:\n\nInput: nums = [4,5,7,7,13]\nOutput: 0\nExplanation: nums is already a non-decreasing array. Therefore, we return 0.\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, 3, 5, 4, 6, 5, 7]) == 1\n assert candidate(nums = [3, 2, 1, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 1\n assert candidate(nums = [2, 1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 5, 4, 6]) == 1\n assert candidate(nums = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 2\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9]) == 4\n assert candidate(nums = [4, 5, 7, 7, 13]) == 0\n assert candidate(nums = [1, 3, 2]) == 1\n assert candidate(nums = [5, 3, 4, 4, 7, 3, 6, 11, 8, 5, 11]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [7, 14, 4, 14, 13, 2, 6, 13, 10, 16]) == 3\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 0\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 0\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [2, 1, 3, 2, 1, 4, 3, 2, 1, 5]) == 1\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 1\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 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]) == 1\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 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3]) == 6\n assert candidate(nums = [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]) == 1\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [5, 8, 6, 7, 3, 4, 9, 2, 10, 1, 11, 12, 0, 13]) == 2\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 1\n assert candidate(nums = [100, 10, 90, 20, 80, 30, 70, 40, 60, 50, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [10, 20, 30, 25, 40, 50, 45, 60, 70, 55, 80, 90, 85, 100, 95, 110, 120, 115]) == 1\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 45, 10, 50]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 9\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 = [10, 20, 30, 25, 20, 15, 10, 5, 15, 25, 35, 45, 55, 50, 45, 40, 35, 30, 25, 20]) == 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]) == 1\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 9\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 5, 9, 6, 10, 5, 11, 5, 12]) == 1\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21]) == 1\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 1\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110]) == 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\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 2\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 38, 45, 50, 48]) == 1\n assert candidate(nums = [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 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == 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, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 5\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 3\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 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]) == 1\n assert candidate(nums = [5, 3, 4, 4, 7, 3, 6, 11, 8, 5, 11, 20, 15, 25, 22, 30, 27, 35, 32, 40, 37, 45, 42, 50]) == 3\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 1\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 5, 9, 6]) == 1\n assert candidate(nums = [3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [100, 200, 150, 250, 200, 300, 250, 350, 300, 400]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 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, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [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 = [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, 3, 2, 1, 0]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\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\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 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]) == 0\n assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10]) == 1\n assert candidate(nums = [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 = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 4\n assert candidate(nums = [3, 2, 1, 4, 6, 5, 7, 9, 8, 10]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [3, 2, 1, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 1\n assert candidate(nums = [5, 3, 8, 6, 7, 2, 4, 9, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(nums = [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]) == 1\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]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 2\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 = [5, 3, 4, 4, 7, 3, 6, 11, 8, 5, 11, 10, 9, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 2\n assert candidate(nums = [100, 200, 100, 300, 200, 400, 300, 500, 400, 600]) == 1\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 2\n assert candidate(nums = [5, 3, 4, 4, 7, 3, 6, 11, 8, 5, 11, 3, 2, 1, 9, 8, 7, 6, 5, 4]) == 3\n assert candidate(nums = [8, 3, 2, 1, 4, 5, 6, 7, 9, 10]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 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]) == 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]) == 0\n assert candidate(nums = [3, 2, 1, 6, 5, 4, 9, 8, 7, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 10\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 20]) == 1\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, 10, 2, 9, 3, 8, 4, 7, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [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]) == 1\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 7\n assert candidate(nums = [10, 9, 8, 10, 9, 8, 10, 9, 8, 10, 9, 8, 10, 9, 8]) == 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]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 1\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 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, 1, 2, 3, 4, 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, 2, 3, 4, 5]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().totalSteps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int totalSteps(int[] nums) {", "container": "Solution", "callable": "totalSteps", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2290, "task_id": "minimum-obstacle-removal-to-reach-corner", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array grid of size m x n. Each cell has one of two values:\n\n0 represents an empty cell,\n1 represents an obstacle that may be removed.\n\nYou can move up, down, left, or right from and to an empty cell.\nReturn the minimum number of obstacles to remove so you can move from the upper left corner (0, 0) to the lower right corner (m - 1, n - 1).\n \nExample 1:\n\n\nInput: grid = [[0,1,1],[1,1,0],[1,1,0]]\nOutput: 2\nExplanation: We can remove the obstacles at (0, 1) and (0, 2) to create a path from (0, 0) to (2, 2).\nIt can be shown that we need to remove at least 2 obstacles, so we return 2.\nNote that there may be other ways to remove 2 obstacles to create a path.\n\nExample 2:\n\n\nInput: grid = [[0,1,0,0,0],[0,1,0,1,0],[0,0,0,1,0]]\nOutput: 0\nExplanation: We can move from (0, 0) to (2, 4) without removing any obstacles, so we return 0.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 105\n2 <= m * n <= 105\ngrid[i][j] is either 0 or 1.\ngrid[0][0] == grid[m - 1][n - 1] == 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 1], [1, 0]]) == 1\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 0]]) == 4\n assert candidate(grid = [[0, 1, 1, 0], [1, 1, 1, 0], [1, 1, 1, 0], [0, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 1, 1], [1, 1, 0], [1, 1, 0]]) == 2\n assert candidate(grid = [[0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 1, 0]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 1, 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]]) == 3\n assert candidate(grid = [[0, 1, 1, 0, 1, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 0, 0, 1, 0], [1, 1, 0, 1, 1, 1, 1, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 1, 0, 1, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 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]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 0], [0, 0, 0, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]) == 2\n assert candidate(grid = [[0, 1, 0, 1, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 0, 1, 0, 1]]) == 6\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0], [1, 0, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 1, 0, 1], [0, 1, 1, 1, 1, 0, 0]]) == 2\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], [0, 1, 0, 1, 0, 0]]) == 4\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], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0]]) == 6\n assert candidate(grid = [[0, 1, 1, 1, 1, 0], [1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1], [0, 1, 1, 1, 0, 0]]) == 3\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]]) == 6\n assert candidate(grid = [[0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [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], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0]]) == 2\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[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, 1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0, 1, 0], [1, 1, 1, 1, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 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\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 0, 1, 1, 1], [1, 0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 1, 1], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0]]) == 4\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], [0, 0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 1, 1, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 0, 1, 0, 1], [1, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 0, 1, 1, 0]]) == 3\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 0]]) == 2\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0], [1, 1, 0, 1, 0, 1, 1], [0, 0, 0, 1, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0, 1, 0], [1, 1, 1, 1, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 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\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 0, 0, 1, 0]]) == 1\n assert candidate(grid = [[0, 1, 1, 0, 1, 0, 0, 1], [1, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0], [1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\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]]) == 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, 1, 0, 1, 0, 1, 0]]) == 7\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 0], [1, 1, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 1, 1, 0]]) == 3\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 0, 1], [0, 1, 1, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 1, 1, 1, 1, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1, 0]]) == 3\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 1], [0, 1, 1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0]]) == 4\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0]]) == 2\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 1\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 0, 1, 1], [1, 1, 1, 0, 1], [0, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0], [1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1, 1], [0, 1, 1, 1, 1, 1, 0]]) == 4\n assert candidate(grid = [[0, 1, 1, 1, 0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1, 1, 1, 0, 1], [1, 1, 0, 1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 1, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[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, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 1, 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]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 1, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 0, 1, 0, 0, 0], [1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 1], [1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minimumObstacles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumObstacles(int[][] grid) {", "container": "Solution", "callable": "minimumObstacles", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2293, "task_id": "min-max-game", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums whose length is a power of 2.\nApply the following algorithm on nums:\n\nLet n be the length of nums. If n == 1, end the process. Otherwise, create a new 0-indexed integer array newNums of length n / 2.\nFor every even index i where 0 <= i < n / 2, assign the value of newNums[i] as min(nums[2 * i], nums[2 * i + 1]).\nFor every odd index i where 0 <= i < n / 2, assign the value of newNums[i] as max(nums[2 * i], nums[2 * i + 1]).\nReplace the array nums with newNums.\nRepeat the entire process starting from step 1.\n\nReturn the last number that remains in nums after applying the algorithm.\n \nExample 1:\n\n\nInput: nums = [1,3,5,2,4,8,2,2]\nOutput: 1\nExplanation: The following arrays are the results of applying the algorithm repeatedly.\nFirst: nums = [1,5,4,2]\nSecond: nums = [1,4]\nThird: nums = [1]\n1 is the last remaining number, so we return 1.\n\nExample 2:\n\nInput: nums = [3]\nOutput: 3\nExplanation: 3 is already the last remaining number, so we return 3.\n\n \nConstraints:\n\n1 <= nums.length <= 1024\n1 <= nums[i] <= 109\nnums.length is a power of 2.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 2, 4, 8, 2, 2]) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n assert candidate(nums = [5, 1, 4, 2, 7, 6, 3, 8]) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993]) == 999999995\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 1\n assert candidate(nums = [2, 7, 4, 1, 8, 1, 5, 6]) == 2\n assert candidate(nums = [7, 5, 3, 1, 9, 11, 13, 15]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [9, 11, 8, 7, 6, 5, 4, 3]) == 5\n assert candidate(nums = [3]) == 3\n assert candidate(nums = [7, 3, 2, 4, 9, 8, 5, 1]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80]) == 10\n assert candidate(nums = [9, 8, 7, 6, 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, 31, 32]) == 1\n assert candidate(nums = [1024]) == 1024\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995, 7, 999999994, 8, 999999993]) == 1\n assert candidate(nums = [23, 45, 12, 67, 34, 89, 10, 20, 33, 56, 78, 90, 11, 22, 35, 46]) == 23\n assert candidate(nums = [128, 256, 512, 1024, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 8\n assert candidate(nums = [16, 8, 4, 2, 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]) == 4\n assert candidate(nums = [5, 3, 8, 1, 6, 7, 2, 4, 9, 11, 10, 13, 15, 12, 14, 16]) == 3\n assert candidate(nums = [9, 1, 7, 5, 3, 6, 4, 8, 2, 10, 11, 13, 12, 14, 15, 16]) == 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, 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]) == 1\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55]) == 50\n assert candidate(nums = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 3, 5, 7, 9, 11]) == 11\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672]) == 42\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 3, 5, 7, 9, 11]) == 11\n assert candidate(nums = [13, 21, 7, 15, 2, 18, 10, 20, 23, 5, 3, 9, 22, 4, 8, 16, 19, 1, 17, 14, 12, 6, 11, 24, 111]) == 13\n assert candidate(nums = [9, 3, 5, 7, 2, 8, 6, 4, 1, 10, 11, 12, 13, 14, 15, 16]) == 3\n assert candidate(nums = [1000000000, 1, 1000000000, 2, 1000000000, 3, 1000000000, 4]) == 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, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64]) == 2\n assert candidate(nums = [100, 200, 150, 50, 250, 125, 300, 75, 275, 62, 175, 87, 325, 43, 187, 91]) == 100\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\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 = [5, 15, 10, 20, 25, 35, 30, 40, 45, 55, 50, 60, 65, 75, 70, 80]) == 5\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 11\n assert candidate(nums = [987654321, 123456789, 198765432, 212345678, 398765432, 312345678, 498765432, 412345678]) == 123456789\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9, 2, 4, 7, 6, 5, 3, 2, 8, 1]) == 6\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 10, 15, 20, 25, 30, 35, 40]) == 1\n assert candidate(nums = [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]) == 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, 31, 32]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 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, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131]) == 2\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8]) == 2\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 5\n assert candidate(nums = [1000000000, 999999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 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, 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]) == 10\n assert candidate(nums = [8, 3, 9, 2, 10, 7, 6, 5, 12, 11, 14, 13, 16, 15, 18, 17]) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 2\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431]) == 1023\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\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, 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]) == 1\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, 310, 320]) == 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, 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, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 17, 18, 19, 20, 21]) == 21\n assert candidate(nums = [9, 7, 5, 11, 13, 2, 8, 6, 4, 10, 12, 3, 1, 14, 15, 16]) == 7\n assert candidate(nums = [33, 11, 44, 22, 55, 33, 66, 44, 77, 55, 88, 66, 99, 77, 110, 88]) == 11\n assert candidate(nums = [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]) == 11\n assert candidate(nums = [2, 1, 3, 4, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == 1\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, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 2\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985]) == 999999990\n assert candidate(nums = [23, 45, 12, 67, 34, 89, 21, 56, 78, 90, 34, 23, 67, 89, 45, 12]) == 23\n assert candidate(nums = [5, 8, 3, 9, 1, 7, 4, 2, 6, 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]) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16]) == 4\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 90\n assert candidate(nums = [1, 3, 2, 4, 7, 5, 9, 6, 11, 8, 10, 12, 15, 13, 14, 16, 19, 17, 18, 20, 23, 21, 22, 24, 27, 25, 26, 28, 31, 29, 30, 32]) == 1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985]) == 990\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 1\n assert candidate(nums = [100, 200, 150, 50, 300, 250, 400, 10, 600, 550, 700, 20, 800, 750, 900, 30]) == 100\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == 5\n assert candidate(nums = [17, 23, 15, 29, 11, 31, 13, 37, 19, 41, 21, 43, 25, 47, 27, 49]) == 17\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\n assert candidate(nums = [5, 2, 9, 1, 7, 3, 8, 4, 6, 10, 12, 11, 14, 13, 16, 15]) == 2\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 8, 7, 9, 10, 12, 11, 14, 13, 15, 16]) == 1\n assert candidate(nums = [100, 50, 25, 75, 60, 30, 90, 40, 80, 10, 110, 120, 130, 140, 150, 160]) == 50\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930, 313233, 343536, 373839, 404142, 434445, 464748]) == 123\n assert candidate(nums = [9, 7, 5, 3, 2, 8, 6, 4, 1, 10, 12, 14, 16, 18, 20, 19]) == 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, 1, 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 = [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]) == 21\n assert candidate(nums = [17, 13, 21, 7, 11, 19, 23, 5, 15, 9, 25, 3, 27, 1, 29, 12]) == 13\n assert candidate(nums = [100, 200, 150, 300, 50, 250, 20, 400, 10, 15, 30, 25, 60, 70, 80, 90]) == 90\n assert candidate(nums = [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]) == 43\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 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, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 17, 18, 19, 20, 21, 22, 23]) == 4\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minMaxGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minMaxGame(int[] nums) {", "container": "Solution", "callable": "minMaxGame", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2294, "task_id": "partition-array-such-that-maximum-difference-is-k", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k. You may partition nums into one or more subsequences such that each element in nums appears in exactly one of the subsequences.\nReturn the minimum number of subsequences needed such that the difference between the maximum and minimum values in each subsequence is at most k.\nA subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\n \nExample 1:\n\nInput: nums = [3,6,1,2,5], k = 2\nOutput: 2\nExplanation:\nWe can partition nums into the two subsequences [3,1,2] and [6,5].\nThe difference between the maximum and minimum value in the first subsequence is 3 - 1 = 2.\nThe difference between the maximum and minimum value in the second subsequence is 6 - 5 = 1.\nSince two subsequences were created, we return 2. It can be shown that 2 is the minimum number of subsequences needed.\n\nExample 2:\n\nInput: nums = [1,2,3], k = 1\nOutput: 2\nExplanation:\nWe can partition nums into the two subsequences [1,2] and [3].\nThe difference between the maximum and minimum value in the first subsequence is 2 - 1 = 1.\nThe difference between the maximum and minimum value in the second subsequence is 3 - 3 = 0.\nSince two subsequences were created, we return 2. Note that another optimal solution is to partition nums into the two subsequences [1] and [2,3].\n\nExample 3:\n\nInput: nums = [2,2,4,5], k = 0\nOutput: 3\nExplanation:\nWe can partition nums into the three subsequences [2,2], [4], and [5].\nThe difference between the maximum and minimum value in the first subsequences is 2 - 2 = 0.\nThe difference between the maximum and minimum value in the second subsequences is 4 - 4 = 0.\nThe difference between the maximum and minimum value in the third subsequences is 5 - 5 = 0.\nSince three subsequences were created, we return 3. It can be shown that 3 is the minimum number of subsequences needed.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 105\n0 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 100000],k = 99999) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 4\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 4\n assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 1\n assert candidate(nums = [1, 2, 3],k = 1) == 2\n assert candidate(nums = [1, 3, 5, 7, 9],k = 1) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 5\n assert candidate(nums = [3, 6, 1, 2, 5],k = 2) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1) == 1\n assert candidate(nums = [2, 2, 4, 5],k = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],k = 4) == 1\n assert candidate(nums = [5, 4, 3, 2, 1],k = 3) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 5\n assert candidate(nums = [1, 100, 101, 200, 201, 300, 301],k = 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],k = 2) == 9\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61],k = 4) == 8\n assert candidate(nums = [5, 5, 5, 10, 10, 10, 15, 15, 15, 20, 20, 20, 25, 25, 25, 30, 30, 30, 35, 35, 35, 40, 40, 40, 45, 45, 45],k = 5) == 5\n assert candidate(nums = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901],k = 100) == 5\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 20) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 150) == 6\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 11\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) == 7\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009],k = 1) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 99) == 10\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6],k = 1) == 5\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 15) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1000) == 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],k = 2) == 9\n assert candidate(nums = [3, 1, 2, 6, 5, 4, 9, 7, 8, 12, 10, 11, 15, 13, 14, 18, 16, 17, 21, 19, 20],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, 10, 10],k = 1) == 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 = 1) == 20\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998],k = 99998) == 2\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 6\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) == 5\n assert candidate(nums = [8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84],k = 4) == 10\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 1) == 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, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 1) == 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 = 2) == 10\n assert candidate(nums = [100, 105, 110, 115, 120, 125, 130, 135, 140, 145],k = 10) == 4\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 20) == 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],k = 24) == 1\n assert candidate(nums = [5, 8, 12, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6],k = 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],k = 1) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 200) == 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],k = 4) == 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],k = 0) == 1\n assert candidate(nums = [1, 3, 6, 8, 10, 15, 18, 20, 22, 25],k = 4) == 5\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164],k = 11) == 8\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 1) == 5\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],k = 3) == 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],k = 0) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 4) == 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 = 2) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 2) == 8\n assert candidate(nums = [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, 101],k = 4) == 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) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 1) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 11, 12, 13, 14, 15, 21, 22, 23, 24, 25],k = 10) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 150) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 2) == 6\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 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],k = 1) == 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],k = 0) == 25\n assert candidate(nums = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30],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, 10, 10],k = 1) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 2) == 8\n assert candidate(nums = [1, 5, 9, 14, 18, 22, 26, 30],k = 4) == 5\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 10) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == 1\n assert candidate(nums = [1, 3, 6, 8, 10, 15, 18, 20, 25, 28],k = 3) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 25) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50) == 10\n assert candidate(nums = [5, 8, 3, 9, 1, 4, 7, 6, 2, 10],k = 3) == 3\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 = 5) == 4\n assert candidate(nums = [5, 1, 9, 3, 7, 11, 6, 4, 8, 2, 10, 12],k = 3) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 5\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],k = 4) == 10\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) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 15) == 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],k = 2) == 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],k = 3) == 7\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994],k = 3) == 2\n assert candidate(nums = [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, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177, 181, 185, 189, 193, 197],k = 4) == 25\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],k = 2) == 13\n assert candidate(nums = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 3) == 8\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 10000) == 5\n assert candidate(nums = [4, 8, 15, 16, 23, 42, 50, 55, 60, 65],k = 10) == 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 = 3) == 10\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 11\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 10, 10, 10, 10],k = 1) == 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, 42, 44, 46, 48, 50],k = 5) == 9\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6],k = 1) == 3\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 7) == 5\n assert candidate(nums = [5, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48],k = 5) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 0) == 10\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) == 10\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120],k = 15) == 6\n assert candidate(nums = [30, 40, 20, 50, 60, 10, 70, 80, 90, 100],k = 10) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 5\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50],k = 20) == 5\n assert candidate(nums = [5, 2, 9, 1, 5, 6],k = 4) == 2\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) == 7\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100],k = 9) == 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, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 1) == 20\n assert candidate(nums = [15, 8, 20, 12, 18, 25, 5, 10, 30, 22],k = 5) == 4\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 = 4) == 7\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == 8\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().partitionArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int partitionArray(int[] nums, int k) {", "container": "Solution", "callable": "partitionArray", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2295, "task_id": "replace-elements-in-an-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums that consists of n distinct positive integers. Apply m operations to this array, where in the ith operation you replace the number operations[i][0] with operations[i][1].\nIt is guaranteed that in the ith operation:\n\noperations[i][0] exists in nums.\noperations[i][1] does not exist in nums.\n\nReturn the array obtained after applying all the operations.\n \nExample 1:\n\nInput: nums = [1,2,4,6], operations = [[1,3],[4,7],[6,1]]\nOutput: [3,2,7,1]\nExplanation: We perform the following operations on nums:\n- Replace the number 1 with 3. nums becomes [3,2,4,6].\n- Replace the number 4 with 7. nums becomes [3,2,7,6].\n- Replace the number 6 with 1. nums becomes [3,2,7,1].\nWe return the final array [3,2,7,1].\n\nExample 2:\n\nInput: nums = [1,2], operations = [[1,3],[2,1],[3,2]]\nOutput: [2,1]\nExplanation: We perform the following operations to nums:\n- Replace the number 1 with 3. nums becomes [3,2].\n- Replace the number 2 with 1. nums becomes [3,1].\n- Replace the number 3 with 2. nums becomes [2,1].\nWe return the array [2,1].\n\n \nConstraints:\n\nn == nums.length\nm == operations.length\n1 <= n, m <= 105\nAll the values of nums are distinct.\noperations[i].length == 2\n1 <= nums[i], operations[i][0], operations[i][1] <= 106\noperations[i][0] will exist in nums when applying the ith operation.\noperations[i][1] will not exist in nums when applying the ith operation.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2],operations = [[1, 3], [2, 1], [3, 2]]) == [2, 1]\n assert candidate(nums = [5, 3, 7, 8],operations = [[5, 10], [3, 15], [7, 20], [8, 25]]) == [10, 15, 20, 25]\n assert candidate(nums = [1, 2, 3, 4, 5],operations = [[1, 5], [2, 4], [3, 3]]) == [5, 4, 3, 4, 5]\n assert candidate(nums = [1, 2, 4, 6],operations = [[1, 3], [4, 7], [6, 1]]) == [3, 2, 7, 1]\n assert candidate(nums = [100, 200, 300],operations = [[100, 150], [200, 250], [300, 350]]) == [150, 250, 350]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65],operations = [[5, 1], [15, 2], [25, 3], [35, 4], [45, 5], [55, 6], [65, 7]]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],operations = [[10, 110], [20, 220], [30, 330], [40, 440], [50, 550], [60, 660], [70, 770], [80, 880], [90, 990], [100, 1010]]) == [110, 220, 330, 440, 550, 660, 770, 880, 990, 1010]\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],operations = [[8, 1], [16, 2], [24, 3], [32, 4], [40, 5], [48, 6], [56, 7], [64, 8], [72, 9], [80, 10], [88, 11], [96, 12], [104, 13], [112, 14], [120, 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, 11, 12, 13, 14, 15],operations = [[1, 15], [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65],operations = [[5, 1], [15, 2], [25, 3], [35, 4], [45, 5], [55, 6], [65, 7]]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],operations = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45], [60, 55], [70, 65], [80, 75], [90, 85], [100, 95]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]\n assert candidate(nums = [1, 3, 5, 7, 9],operations = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [2, 4, 6, 8, 10]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],operations = [[7, 1], [14, 2], [21, 3], [28, 4], [35, 5], [42, 6], [49, 7], [56, 8], [63, 9], [70, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],operations = [[1000, 500], [2000, 1500], [3000, 2500], [4000, 3500], [5000, 4500]]) == [500, 1500, 2500, 3500, 4500]\n assert candidate(nums = [1234, 5678, 91011, 121314, 151617],operations = [[1234, 1], [5678, 2], [91011, 3], [121314, 4], [151617, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],operations = [[7, 1], [14, 2], [21, 3], [28, 4], [35, 5], [42, 6], [49, 7], [56, 8], [63, 9], [70, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 14, 21, 28, 35, 42],operations = [[7, 1], [14, 2], [21, 3], [28, 4], [35, 5], [42, 6]]) == [1, 2, 3, 4, 5, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],operations = [[1, 16], [2, 17], [3, 18], [4, 19], [5, 20], [6, 21], [7, 22], [8, 23], [9, 24], [10, 25], [11, 26], [12, 27], [13, 28], [14, 29], [15, 30]]) == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],operations = [[100000, 1], [50000, 2], [25000, 3], [12500, 4], [6250, 5], [3125, 6], [1562, 7], [781, 8], [390, 9], [195, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],operations = [[1000000, 1], [999999, 2], [999998, 3], [999997, 4], [999996, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],operations = [[1000, 1001], [2000, 2002], [3000, 3003], [4000, 4004], [5000, 5005]]) == [1001, 2002, 3003, 4004, 5005]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],operations = [[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]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n assert candidate(nums = [999, 998, 997, 996, 995],operations = [[999, 994], [998, 993], [997, 992], [996, 991], [995, 990]]) == [994, 993, 992, 991, 990]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],operations = [[1, 21], [2, 22], [3, 23], [4, 24], [5, 25], [6, 26], [7, 27], [8, 28], [9, 29], [10, 30], [11, 31], [12, 32], [13, 33], [14, 34], [15, 35], [16, 36], [17, 37], [18, 38], [19, 39], [20, 40]]) == [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(nums = [5, 10, 15, 20, 25],operations = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000],operations = [[1000, 1001], [2000, 2001], [3000, 3001], [4000, 4001], [5000, 5001], [6000, 6001]]) == [1001, 2001, 3001, 4001, 5001, 6001]\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],operations = [[1000000, 999999], [500000, 499999], [250000, 249999], [125000, 124999], [62500, 62499], [31250, 31249], [15625, 15624], [7812, 7811], [3906, 3905], [1953, 1952]]) == [999999, 499999, 249999, 124999, 62499, 31249, 15624, 7811, 3905, 1952]\n assert candidate(nums = [1, 3, 5, 7, 9],operations = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [2, 4, 6, 8, 10]\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],operations = [[1000000, 1000001], [999999, 1000002], [999998, 1000003], [999997, 1000004], [999996, 1000005]]) == [1000001, 1000002, 1000003, 1000004, 1000005]\n assert candidate(nums = [5, 3, 8, 9, 10],operations = [[5, 6], [3, 4], [8, 5], [9, 8], [10, 9]]) == [6, 4, 5, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],operations = [[10, 11], [20, 21], [30, 31], [40, 41], [50, 51], [60, 61], [70, 71], [80, 81], [90, 91], [100, 101]]) == [11, 21, 31, 41, 51, 61, 71, 81, 91, 101]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],operations = [[1, 21], [2, 22], [3, 23], [4, 24], [5, 25], [6, 26], [7, 27], [8, 28], [9, 29], [10, 30], [11, 31], [12, 32], [13, 33], [14, 34], [15, 35], [16, 36], [17, 37], [18, 38], [19, 39], [20, 40]]) == [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],operations = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 11]\n assert candidate(nums = [9999, 8888, 7777, 6666, 5555],operations = [[9999, 10000], [8888, 11111], [7777, 12222], [6666, 13333], [5555, 14444]]) == [10000, 11111, 12222, 13333, 14444]\n assert candidate(nums = [500000, 1, 500001, 2, 500002],operations = [[500000, 3], [1, 4], [500001, 5], [2, 6], [500002, 7]]) == [3, 4, 5, 6, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60],operations = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65]]) == [15, 25, 35, 45, 55, 65]\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121],operations = [[11, 12], [22, 14], [33, 16], [44, 18], [55, 20], [66, 22], [77, 24], [88, 26], [99, 28], [110, 30], [121, 32]]) == [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]\n assert candidate(nums = [7, 14, 21, 28, 35, 42],operations = [[7, 1], [14, 2], [21, 3], [28, 4], [35, 5], [42, 6]]) == [1, 2, 3, 4, 5, 6]\n assert candidate(nums = [12, 34, 56, 78, 90, 123, 456],operations = [[12, 11], [34, 33], [56, 55], [78, 77], [90, 89], [123, 122], [456, 455]]) == [11, 33, 55, 77, 89, 122, 455]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56],operations = [[7, 15], [14, 7], [21, 14], [28, 21], [35, 28], [42, 35], [49, 42], [56, 49]]) == [15, 7, 14, 21, 28, 35, 42, 49]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],operations = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45], [60, 55], [70, 65], [80, 75], [90, 85], [100, 95]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],operations = [[9, 18], [8, 16], [7, 14], [6, 12], [5, 10], [4, 8], [3, 6], [2, 4], [1, 2]]) == [18, 16, 14, 12, 10, 8, 6, 4, 2]\n assert candidate(nums = [5, 3, 8, 9, 2],operations = [[5, 15], [3, 10], [8, 18], [9, 19], [2, 12]]) == [15, 10, 18, 19, 12]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],operations = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(nums = [5, 3, 8, 9, 2, 6],operations = [[5, 10], [3, 5], [8, 3], [9, 8], [2, 9], [6, 2]]) == [10, 5, 3, 8, 9, 2]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],operations = [[100, 110], [200, 120], [300, 130], [400, 140], [500, 150], [600, 160], [700, 170], [800, 180], [900, 190], [1000, 200], [1100, 210], [1200, 220], [1300, 230], [1400, 240], [1500, 250]]) == [110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]\n assert candidate(nums = [1, 100000],operations = [[1, 50000], [100000, 99999]]) == [50000, 99999]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],operations = [[1000, 1100], [2000, 2200], [3000, 3300], [4000, 4400], [5000, 5500]]) == [1100, 2200, 3300, 4400, 5500]\n assert candidate(nums = [5, 15, 25, 35, 45, 55],operations = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60]]) == [10, 20, 30, 40, 50, 60]\n assert candidate(nums = [10, 20, 30, 40, 50],operations = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45]]) == [5, 15, 25, 35, 45]\n assert candidate(nums = [1, 1000000],operations = [[1, 2], [1000000, 1]]) == [2, 1]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],operations = [[100000, 200000], [50000, 100000], [25000, 50000], [12500, 25000], [6250, 12500], [3125, 6250], [1562, 3125], [781, 1562], [390, 781], [195, 390]]) == [200000, 100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],operations = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [5, 10, 15, 20, 25, 30],operations = [[5, 4], [10, 9], [15, 8], [20, 7], [25, 6], [30, 5]]) == [4, 9, 8, 7, 6, 5]\n assert candidate(nums = [7, 11, 13, 17, 19],operations = [[7, 10], [11, 12], [13, 14], [17, 15], [19, 16]]) == [10, 12, 14, 15, 16]\n assert candidate(nums = [10, 20, 30, 40, 50],operations = [[10, 15], [30, 35], [50, 55], [20, 25], [40, 45]]) == [15, 25, 35, 45, 55]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],operations = [[1, 20], [3, 21], [5, 22], [7, 23], [9, 24], [11, 25], [13, 26], [15, 27], [17, 28], [19, 29]]) == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],operations = [[1000000, 1], [999999, 2], [999998, 3], [999997, 4], [999996, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 30, 40, 50],operations = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55]]) == [15, 25, 35, 45, 55]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],operations = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(nums = [5, 3, 9, 11, 13],operations = [[3, 4], [9, 10], [11, 12], [13, 14], [5, 6]]) == [6, 4, 10, 12, 14]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],operations = [[99, 100], [98, 101], [97, 102], [96, 103], [95, 104], [94, 105], [93, 106], [92, 107], [91, 108], [90, 109]]) == [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 111, 222, 333, 444, 555, 666, 777, 888, 999],operations = [[11, 1], [22, 2], [33, 3], [44, 4], [55, 5], [66, 6], [77, 7], [88, 8], [99, 9], [111, 10], [222, 11], [333, 12], [444, 13], [555, 14], [666, 15], [777, 16], [888, 17], [999, 18]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n assert candidate(nums = [7, 17, 27, 37, 47, 57],operations = [[7, 8], [17, 18], [27, 28], [37, 38], [47, 48], [57, 58]]) == [8, 18, 28, 38, 48, 58]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000],operations = [[1000, 1001], [2000, 2002], [3000, 3003], [4000, 4004], [5000, 5005], [6000, 6006]]) == [1001, 2002, 3003, 4004, 5005, 6006]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],operations = [[1000, 500], [2000, 1000], [3000, 1500], [4000, 2000], [5000, 2500], [6000, 3000], [7000, 3500], [8000, 4000], [9000, 4500]]) == [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],operations = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21]]) == [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n assert candidate(nums = [29, 13, 11, 14, 23, 25, 9, 22, 19, 30, 28, 21, 17, 26, 18, 24, 27, 16, 12, 31, 10, 15, 8, 20, 7, 6, 5, 4, 3, 2, 1],operations = [[29, 32], [13, 33], [11, 34], [14, 35], [23, 36], [25, 37], [9, 38], [22, 39], [19, 40], [30, 41], [28, 42], [21, 43], [17, 44], [26, 45], [18, 46], [24, 47], [27, 48], [16, 49], [12, 50], [31, 51], [10, 52], [15, 53], [8, 54], [20, 55], [7, 56], [6, 57], [5, 58], [4, 59], [3, 60], [2, 61], [1, 62]]) == [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]\n assert candidate(nums = [99, 199, 299, 399, 499, 599],operations = [[99, 100], [199, 200], [299, 300], [399, 400], [499, 500], [599, 600]]) == [100, 200, 300, 400, 500, 600]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],operations = [[5, 10], [3, 11], [8, 12], [6, 13], [2, 14], [7, 15], [4, 16], [1, 17]]) == [10, 11, 12, 13, 14, 15, 16, 17]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],operations = [[1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500],operations = [[1000000, 999999], [500000, 1000000], [250000, 500000], [125000, 250000], [62500, 125000]]) == [999999, 1000000, 500000, 250000, 125000]\n assert candidate(nums = [9, 7, 5, 3, 1],operations = [[9, 10], [7, 8], [5, 6], [3, 4], [1, 2]]) == [10, 8, 6, 4, 2]\n assert candidate(nums = [10, 20, 30, 40, 50, 60],operations = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65]]) == [15, 25, 35, 45, 55, 65]\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],operations = [[999999, 999989], [999998, 999988], [999997, 999987], [999996, 999986], [999995, 999985], [999994, 999984], [999993, 999983], [999992, 999982], [999991, 999981], [999990, 999980]]) == [999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981, 999980]\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],operations = [[10000, 5000], [20000, 10000], [30000, 15000], [40000, 20000], [50000, 25000], [60000, 30000], [70000, 35000], [80000, 40000], [90000, 45000], [100000, 50000]]) == [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000]\n"}, "metadata": {"canonical_parameter_names": ["nums", "operations"], "leetcode_dataset_entry_point": "Solution().arrayChange", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] arrayChange(int[] nums, int[][] operations) {", "container": "Solution", "callable": "arrayChange", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "operations", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2299, "task_id": "strong-password-checker-ii", "difficulty": "Easy", "problem_description": "A password is said to be strong if it satisfies all the following criteria:\n\nIt has at least 8 characters.\nIt contains at least one lowercase letter.\nIt contains at least one uppercase letter.\nIt contains at least one digit.\nIt contains at least one special character. The special characters are the characters in the following string: \"!@#$%^&*()-+\".\nIt does not contain 2 of the same character in adjacent positions (i.e., \"aab\" violates this condition, but \"aba\" does not).\n\nGiven a string password, return true if it is a strong password. Otherwise, return false.\n \nExample 1:\n\nInput: password = \"IloveLe3tcode!\"\nOutput: true\nExplanation: The password meets all the requirements. Therefore, we return true.\n\nExample 2:\n\nInput: password = \"Me+You--IsMyDream\"\nOutput: false\nExplanation: The password does not contain a digit and also contains 2 of the same character in adjacent positions. Therefore, we return false.\n\nExample 3:\n\nInput: password = \"1aB!\"\nOutput: false\nExplanation: The password does not meet the length requirement. Therefore, we return false.\n \nConstraints:\n\n1 <= password.length <= 100\npassword consists of letters, digits, and special characters: \"!@#$%^&*()-+\".\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(password = \"IloveLe3tcode!\") == True\n assert candidate(password = \"Me+You--IsMyDream\") == False\n assert candidate(password = \"1aB!\") == False\n"}, "metadata": {"canonical_parameter_names": ["password"], "leetcode_dataset_entry_point": "Solution().strongPasswordCheckerII", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean strongPasswordCheckerII(String password) {", "container": "Solution", "callable": "strongPasswordCheckerII", "parameters": [{"name": "password", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2300, "task_id": "successful-pairs-of-spells-and-potions", "difficulty": "Medium", "problem_description": "You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the ith spell and potions[j] represents the strength of the jth potion.\nYou are also given an integer success. A spell and potion pair is considered successful if the product of their strengths is at least success.\nReturn an integer array pairs of length n where pairs[i] is the number of potions that will form a successful pair with the ith spell.\n \nExample 1:\n\nInput: spells = [5,1,3], potions = [1,2,3,4,5], success = 7\nOutput: [4,0,3]\nExplanation:\n- 0th spell: 5 * [1,2,3,4,5] = [5,10,15,20,25]. 4 pairs are successful.\n- 1st spell: 1 * [1,2,3,4,5] = [1,2,3,4,5]. 0 pairs are successful.\n- 2nd spell: 3 * [1,2,3,4,5] = [3,6,9,12,15]. 3 pairs are successful.\nThus, [4,0,3] is returned.\n\nExample 2:\n\nInput: spells = [3,1,2], potions = [8,5,8], success = 16\nOutput: [2,0,2]\nExplanation:\n- 0th spell: 3 * [8,5,8] = [24,15,24]. 2 pairs are successful.\n- 1st spell: 1 * [8,5,8] = [8,5,8]. 0 pairs are successful. \n- 2nd spell: 2 * [8,5,8] = [16,10,16]. 2 pairs are successful. \nThus, [2,0,2] is returned.\n\n \nConstraints:\n\nn == spells.length\nm == potions.length\n1 <= n, m <= 105\n1 <= spells[i], potions[i] <= 105\n1 <= success <= 1010\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(spells = [3, 1, 2],potions = [8, 5, 8],success = 16) == [2, 0, 2]\n assert candidate(spells = [1, 1, 1],potions = [1, 1, 1],success = 2) == [0, 0, 0]\n assert candidate(spells = [5, 1, 3],potions = [1, 2, 3, 4, 5],success = 7) == [4, 0, 3]\n assert candidate(spells = [1, 2, 3, 4, 5],potions = [5, 4, 3, 2, 1],success = 10) == [0, 1, 2, 3, 4]\n assert candidate(spells = [10, 20, 30],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 50) == [6, 8, 9]\n assert candidate(spells = [100000, 100000, 100000],potions = [100000, 100000, 100000],success = 10000000000) == [3, 3, 3]\n assert candidate(spells = [10, 20, 30],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 100) == [1, 6, 7]\n assert candidate(spells = [1, 1, 1],potions = [1, 1, 1, 1],success = 1) == [4, 4, 4]\n assert candidate(spells = [10, 10, 10],potions = [1, 1, 1, 1, 1],success = 100) == [0, 0, 0]\n assert candidate(spells = [1, 1, 1, 1],potions = [1, 1, 1, 1],success = 1) == [4, 4, 4, 4]\n assert candidate(spells = [1, 2, 3, 4, 5],potions = [5, 4, 3, 2, 1],success = 6) == [0, 3, 4, 4, 4]\n assert candidate(spells = [10, 20, 30],potions = [5, 10, 15, 20],success = 100) == [3, 4, 4]\n assert candidate(spells = [100000],potions = [100000],success = 10000000000) == [1]\n assert candidate(spells = [100, 200, 300, 400, 500],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],success = 500) == [11, 13, 14, 14, 15]\n assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991],success = 4999750005) == [2, 2, 1, 1, 0]\n assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],success = 100000) == [1, 6, 7, 8, 9, 9, 9, 9, 9, 10]\n assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 10000000000) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [100000, 99999, 99998, 99997, 99996, 99995],success = 9999900000) == [1, 0, 0, 0, 0]\n assert candidate(spells = [1, 1, 1, 1, 1],potions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],success = 2) == [0, 0, 0, 0, 0]\n assert candidate(spells = [1, 1, 1, 1, 1],potions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],success = 1) == [10, 10, 10, 10, 10]\n assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],success = 50) == [6, 8, 9, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(spells = [1, 10, 100, 1000, 10000],potions = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000],success = 10000) == [0, 1, 4, 7, 10]\n assert candidate(spells = [1, 3, 5, 7, 9],potions = [11, 13, 15, 17, 19, 21, 23, 25, 27, 29],success = 50) == [0, 7, 10, 10, 10]\n assert candidate(spells = [50000, 60000, 70000, 80000, 90000, 100000],potions = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],success = 5000000000) == [5, 5, 5, 5, 5, 5]\n assert candidate(spells = [2, 4, 6, 8, 10],potions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],success = 100) == [1, 6, 7, 8, 9]\n assert candidate(spells = [100, 200, 300, 400, 500],potions = [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],success = 5000) == [10, 16, 19, 20, 21]\n assert candidate(spells = [5, 10, 15, 20, 25],potions = [20, 25, 30, 35, 40, 45, 50, 55, 60],success = 500) == [0, 3, 6, 8, 9]\n assert candidate(spells = [1000, 2000, 3000, 4000, 5000],potions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],success = 10000) == [9, 10, 10, 10, 10]\n assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [99999, 99998, 99997, 99996, 99995],success = 99990000025) == [0, 0, 0, 0, 0]\n assert candidate(spells = [5, 10, 15, 20, 25],potions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],success = 50) == [5, 8, 8, 9, 9]\n assert candidate(spells = [1, 2, 3, 4, 5],potions = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],success = 100000) == [0, 10, 10, 10, 10]\n assert candidate(spells = [9, 8, 7, 6, 5],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9],success = 20) == [7, 7, 7, 6, 6]\n assert candidate(spells = [33333, 66666, 99999],potions = [33333, 66666, 99999, 133332, 166665, 199998],success = 10000000000) == [0, 2, 3]\n assert candidate(spells = [100, 200, 300, 400, 500],potions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],success = 100) == [10, 10, 10, 10, 10]\n assert candidate(spells = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],potions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],success = 250) == [1, 6, 7, 8, 9, 9, 9, 9, 9, 10]\n assert candidate(spells = [50000, 50000, 50000, 50000],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 100000) == [10, 10, 10, 10]\n assert candidate(spells = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],potions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],success = 2500) == [0, 0, 2, 4, 6, 6, 7, 7, 8, 8]\n assert candidate(spells = [50000, 25000, 12500],potions = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],success = 625000000) == [9, 8, 6]\n assert candidate(spells = [100000, 50000, 25000, 12500, 6250],potions = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],success = 10000000000) == [4, 3, 2, 1, 0]\n assert candidate(spells = [1, 2, 3, 4, 5],potions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],success = 25) == [6, 8, 9, 9, 10]\n assert candidate(spells = [1, 2, 3, 4, 5],potions = [100000, 200000, 300000, 400000, 500000],success = 1000000) == [0, 1, 2, 3, 4]\n assert candidate(spells = [100000, 90000, 80000],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 500000) == [6, 5, 4]\n assert candidate(spells = [1, 1, 1, 1, 1],potions = [100000, 100000, 100000, 100000, 100000],success = 100000) == [5, 5, 5, 5, 5]\n assert candidate(spells = [10000, 20000, 30000, 40000, 50000],potions = [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000],success = 200000000) == [7, 9, 9, 10, 10]\n assert candidate(spells = [50000, 50000, 50000, 50000, 50000],potions = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],success = 5000000000) == [4, 4, 4, 4, 4]\n assert candidate(spells = [10000, 5000, 2500],potions = [5000, 10000, 15000, 20000, 25000],success = 100000000) == [4, 2, 0]\n assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],success = 1000000) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(spells = [5, 15, 25, 35, 45],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 100) == [1, 7, 9, 9, 9]\n assert candidate(spells = [100000, 100000, 100000, 100000],potions = [100000, 100000, 100000, 100000, 100000],success = 10000000000) == [5, 5, 5, 5]\n assert candidate(spells = [5, 5, 5, 5, 5],potions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],success = 6) == [0, 0, 0, 0, 0]\n assert candidate(spells = [1, 3, 5, 7, 9],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 18) == [2, 8, 9, 9, 10]\n assert candidate(spells = [1, 1, 1, 1, 1],potions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],success = 1) == [21, 21, 21, 21, 21]\n assert candidate(spells = [3, 3, 3, 3, 3],potions = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],success = 10) == [0, 0, 0, 0, 0]\n assert candidate(spells = [1, 3, 5, 7, 9],potions = [9, 7, 5, 3, 1],success = 15) == [0, 3, 4, 4, 4]\n assert candidate(spells = [9, 7, 5, 3, 1],potions = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],success = 50) == [8, 7, 6, 2, 0]\n assert candidate(spells = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 20) == [1, 7, 9, 9, 9, 10, 10, 10, 10, 10]\n assert candidate(spells = [10000, 20000, 30000, 40000],potions = [25000, 50000, 75000, 100000, 125000, 150000, 175000, 200000],success = 2000000000) == [1, 5, 6, 7]\n assert candidate(spells = [100000, 50000, 25000, 12500, 6250],potions = [200000, 100000, 50000, 25000, 12500, 6250],success = 10000000000) == [2, 1, 0, 0, 0]\n assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],success = 9999500000) == [0, 0, 0, 0, 0]\n assert candidate(spells = [50, 25, 10, 2],potions = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],success = 5000) == [4, 3, 2, 0]\n assert candidate(spells = [100000, 50000, 25000, 12500, 6250],potions = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],success = 5000000000) == [5, 4, 3, 2, 1]\n assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],success = 10) == [1, 6, 7, 8, 9, 9, 9, 9, 9, 10]\n assert candidate(spells = [1000, 2000, 3000, 4000, 5000],potions = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],success = 5000000) == [0, 0, 0, 0, 10]\n assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],success = 9999500000) == [0, 0, 0, 0, 0]\n assert candidate(spells = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],potions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],success = 100000) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(spells = [5, 5, 5, 5, 5],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 25) == [6, 6, 6, 6, 6]\n assert candidate(spells = [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],potions = [100, 200, 300, 400, 500],success = 5000) == [0, 0, 0, 0, 1, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(spells = [100, 200, 300, 400, 500],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],success = 1000) == [11, 16, 17, 18, 19]\n assert candidate(spells = [100000, 90000, 80000],potions = [100000, 90000, 80000, 70000, 60000],success = 8100000000) == [2, 2, 0]\n assert candidate(spells = [1, 1, 1, 1, 1],potions = [100000, 100000, 100000, 100000, 100000],success = 50000) == [5, 5, 5, 5, 5]\n assert candidate(spells = [1, 3, 5, 7, 9],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 15) == [3, 8, 9, 9, 10]\n assert candidate(spells = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],potions = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],success = 1000000) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(spells = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],success = 1000) == [1, 11, 14, 16, 17, 17, 18, 18, 18, 19]\n assert candidate(spells = [100000, 1, 50000, 10000],potions = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],success = 10000000000) == [1, 0, 0, 0]\n assert candidate(spells = [1, 1, 1, 1, 1],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 10) == [1, 1, 1, 1, 1]\n assert candidate(spells = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],potions = [100000, 50000, 25000, 12500, 6250],success = 10000000000) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4]\n assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [1, 10, 100, 1000, 10000, 100000],success = 9999500000) == [1, 1, 1, 1, 1]\n assert candidate(spells = [9, 8, 7, 6, 5, 4, 3, 2, 1],potions = [9, 8, 7, 6, 5, 4, 3, 2, 1],success = 36) == [6, 5, 4, 4, 2, 1, 0, 0, 0]\n assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],success = 9999800001) == [1, 0, 0, 0, 0]\n assert candidate(spells = [50, 25, 100, 1],potions = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],success = 1000) == [6, 5, 7, 1]\n assert candidate(spells = [10, 20, 30, 40, 50],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 150) == [3, 7, 8, 9, 9]\n assert candidate(spells = [100000, 90000, 80000, 70000, 60000],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 54000000) == [0, 0, 0, 0, 0]\n assert candidate(spells = [100000, 1, 99999],potions = [1, 100000, 99999, 50000, 25000],success = 9999999999) == [1, 0, 0]\n assert candidate(spells = [100000, 100000, 100000],potions = [100000, 100000, 100000, 100000, 100000],success = 10000000000) == [5, 5, 5]\n assert candidate(spells = [5, 10, 15, 20, 25],potions = [20, 25, 30, 35, 40, 45, 50, 55, 60, 65],success = 800) == [0, 0, 3, 6, 7]\n assert candidate(spells = [50, 40, 30, 20, 10],potions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],success = 200) == [10, 10, 9, 9, 7]\n assert candidate(spells = [1, 2, 3, 4, 5],potions = [100000, 200000, 300000, 400000, 500000],success = 500000) == [1, 3, 4, 4, 5]\n assert candidate(spells = [100000, 50000, 25000],potions = [1, 10, 100, 1000, 10000, 100000],success = 10000000000) == [1, 0, 0]\n assert candidate(spells = [100, 200, 300, 400, 500],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 1500) == [3, 7, 8, 9, 9]\n assert candidate(spells = [50, 50, 50, 50, 50],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],success = 250) == [16, 16, 16, 16, 16]\n assert candidate(spells = [99999, 99998, 99997],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 9999800000) == [0, 0, 0]\n assert candidate(spells = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],potions = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],success = 1024) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(spells = [100000, 50000, 25000, 12500],potions = [1, 10, 100, 1000, 10000, 100000],success = 10000000000) == [1, 0, 0, 0]\n assert candidate(spells = [100000, 50000, 25000],potions = [50000, 75000, 100000, 125000],success = 5000000000) == [4, 2, 0]\n assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 50) == [0, 0, 0, 0, 1, 2, 3, 4, 5, 6]\n assert candidate(spells = [10, 20, 30, 40, 50],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 50) == [6, 8, 9, 9, 10]\n"}, "metadata": {"canonical_parameter_names": ["spells", "potions", "success"], "leetcode_dataset_entry_point": "Solution().successfulPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] successfulPairs(int[] spells, int[] potions, long success) {", "container": "Solution", "callable": "successfulPairs", "parameters": [{"name": "spells", "type": "int[]"}, {"name": "potions", "type": "int[]"}, {"name": "success", "type": "long"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2301, "task_id": "match-substring-after-replacement", "difficulty": "Hard", "problem_description": "You are given two strings s and sub. You are also given a 2D character array mappings where mappings[i] = [oldi, newi] indicates that you may perform the following operation any number of times:\n\nReplace a character oldi of sub with newi.\n\nEach character in sub cannot be replaced more than once.\nReturn true if it is possible to make sub a substring of s by replacing zero or more characters according to mappings. Otherwise, return false.\nA substring is a contiguous non-empty sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"fool3e7bar\", sub = \"leet\", mappings = [[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"]]\nOutput: true\nExplanation: Replace the first 'e' in sub with '3' and 't' in sub with '7'.\nNow sub = \"l3e7\" is a substring of s, so we return true.\nExample 2:\n\nInput: s = \"fooleetbar\", sub = \"f00l\", mappings = [[\"o\",\"0\"]]\nOutput: false\nExplanation: The string \"f00l\" is not a substring of s and no replacements can be made.\nNote that we cannot replace '0' with 'o'.\n\nExample 3:\n\nInput: s = \"Fool33tbaR\", sub = \"leetd\", mappings = [[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"],[\"d\",\"b\"],[\"p\",\"b\"]]\nOutput: true\nExplanation: Replace the first and second 'e' in sub with '3' and 'd' in sub with 'b'.\nNow sub = \"l33tb\" is a substring of s, so we return true.\n\n\n \nConstraints:\n\n1 <= sub.length <= s.length <= 5000\n0 <= mappings.length <= 1000\nmappings[i].length == 2\noldi != newi\ns and sub consist of uppercase and lowercase English letters and digits.\noldi and newi are either uppercase or lowercase English letters or digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"fooleetbar\",sub = \"f00l\",mappings = [['o', '0']]) == False\n assert candidate(s = \"fool3e7bar\",sub = \"leet\",mappings = [['e', '3'], ['t', '7'], ['t', '8']]) == True\n assert candidate(s = \"Fool33tbaR\",sub = \"leetd\",mappings = [['e', '3'], ['t', '7'], ['t', '8'], ['d', 'b'], ['p', 'b']]) == True\n assert candidate(s = \"1234567890\",sub = \"120\",mappings = [['3', '4'], ['5', '6'], ['7', '8'], ['9', '0']]) == False\n assert candidate(s = \"thisisaverylongstringwithmanycharacters\",sub = \"thisisaverylongstringwithmanychar1\",mappings = [['a', '1']]) == False\n assert candidate(s = \"abcABC123\",sub = \"aBc12\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['1', '2'], ['2', '3']]) == True\n assert candidate(s = \"A1B2C3D4E5F6G7H8I9J0\",sub = \"abcdefghij\",mappings = [['1', 'a'], ['2', 'b'], ['3', 'c'], ['4', 'd'], ['5', 'e'], ['6', 'f'], ['7', 'g'], ['8', 'h'], ['9', 'i'], ['0', 'j']]) == False\n assert candidate(s = \"abcde\",sub = \"edcba\",mappings = [['a', 'e'], ['b', 'd'], ['c', 'c'], ['d', 'b'], ['e', 'a']]) == True\n assert candidate(s = \"AaBbCc\",sub = \"abc\",mappings = [['A', 'a'], ['B', 'b'], ['C', 'c']]) == False\n assert candidate(s = \"UPPERlower\",sub = \"lower\",mappings = [['U', 'l'], ['P', 'o'], ['E', 'w'], ['R', 'r']]) == True\n assert candidate(s = \"12345678901234567890\",sub = \"13579\",mappings = [['1', '2'], ['3', '4'], ['5', '6'], ['7', '8'], ['9', '0']]) == False\n assert candidate(s = \"xyzuvw\",sub = \"xyzz\",mappings = [['z', 'w'], ['z', 'u']]) == True\n assert candidate(s = \"aaaaaaa\",sub = \"aaab\",mappings = [['a', 'b']]) == False\n assert candidate(s = \"aaaaabbbbcccc\",sub = \"abc\",mappings = [['a', 'b'], ['b', 'c'], ['c', 'a']]) == True\n assert candidate(s = \"1234567890qwertyuiopasdfghjklzxcvbnm\",sub = \"QWERTYUIOPASDFGHJKLZXCVBNM\",mappings = [['q', 'Q'], ['w', 'W'], ['e', 'E'], ['r', 'R'], ['t', 'T'], ['y', 'Y'], ['u', 'U'], ['i', 'I'], ['o', 'O'], ['p', 'P'], ['a', 'A'], ['s', 'S'], ['d', 'D'], ['f', 'F'], ['g', 'G'], ['h', 'H'], ['j', 'J'], ['k', 'K'], ['l', 'L'], ['z', 'Z'], ['x', 'X'], ['c', 'C'], ['v', 'V'], ['b', 'B'], ['n', 'N'], ['m', 'M']]) == False\n assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz\",sub = \"123abc\",mappings = [['1', 'a'], ['2', 'b'], ['3', 'c'], ['a', '1'], ['b', '2'], ['c', '3']]) == False\n assert candidate(s = \"mississippi\",sub = \"misp\",mappings = [['i', 's'], ['s', 'i']]) == False\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789\",sub = \"abcdef\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['d', 'D'], ['e', 'E'], ['f', 'F'], ['0', 'a'], ['1', 'b']]) == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",sub = \"zzzzzzzzzzzzzzzz\",mappings = []) == True\n assert candidate(s = \"PythonProgrammingIsFun\",sub = \"PythnPrgrammngIsFn\",mappings = [['o', '0'], ['r', '4'], ['g', '9'], ['m', 'n'], ['n', 'm'], ['u', '1']]) == False\n assert candidate(s = \"abcXYZabcXYZabc\",sub = \"XYZ\",mappings = [['X', 'a'], ['Y', 'b'], ['Z', 'c']]) == True\n assert candidate(s = \"abcXYZ123defGHI456\",sub = \"xyz\",mappings = [['x', 'X'], ['y', 'Y'], ['z', 'Z']]) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",sub = \"mnoPQR\",mappings = [['m', 'M'], ['n', 'N'], ['o', 'O'], ['p', 'P'], ['q', 'Q'], ['r', 'R'], ['s', 'S'], ['t', 'T']]) == False\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\",sub = \"qwertyuiopasdfghjklzxcvbnm\",mappings = [['Q', 'q'], ['W', 'w'], ['E', 'e'], ['R', 'r'], ['T', 't'], ['Y', 'y'], ['U', 'u'], ['I', 'i'], ['O', 'o'], ['P', 'p'], ['A', 'a'], ['S', 's'], ['D', 'd'], ['F', 'f'], ['G', 'g'], ['H', 'h'], ['J', 'j'], ['K', 'k'], ['L', 'l'], ['Z', 'z'], ['X', 'x'], ['C', 'c'], ['V', 'v'], ['B', 'b'], ['N', 'n'], ['M', 'm']]) == False\n assert candidate(s = \"xyzabcxyz\",sub = \"zyx\",mappings = [['x', 'y'], ['y', 'z'], ['z', 'x']]) == False\n assert candidate(s = \"Python3.8\",sub = \"Python3.8\",mappings = []) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz0123456789\",sub = \"zyxwvutsrqp\",mappings = [['z', '9'], ['y', '8'], ['x', '7'], ['w', '6'], ['v', '5'], ['u', '4'], ['t', '3'], ['s', '2'], ['r', '1'], ['q', '0']]) == False\n assert candidate(s = \"aabbccddeeff\",sub = \"abc\",mappings = [['a', 'b'], ['b', 'c'], ['c', 'd']]) == True\n assert candidate(s = \"9876543210\",sub = \"123\",mappings = [['1', '9'], ['2', '8'], ['3', '7']]) == True\n assert candidate(s = \"mississippi\",sub = \"miss\",mappings = [['m', 'i'], ['i', 's'], ['s', 'p']]) == True\n assert candidate(s = \"mississippi\",sub = \"MISS\",mappings = [['m', 'M'], ['i', 'I'], ['s', 'S']]) == False\n assert candidate(s = \"ababababababab\",sub = \"AB\",mappings = [['a', 'A'], ['b', 'B']]) == False\n assert candidate(s = \"nestedparentheses\",sub = \"nest1dpar3ntheses\",mappings = [['e', '1'], ['o', '3']]) == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",sub = \"aaaaaaaaaa\",mappings = [['z', 'a']]) == False\n assert candidate(s = \"abcabcabcabcabcabc\",sub = \"abababa\",mappings = [['a', 'b'], ['b', 'a']]) == False\n assert candidate(s = \"MULTIPLEMAPPINGS\",sub = \"MAPPING\",mappings = [['M', 'N'], ['A', 'B'], ['P', 'Q'], ['I', 'J'], ['G', 'H']]) == True\n assert candidate(s = \"12345678901234567890\",sub = \"111111\",mappings = [['1', '2'], ['2', '3'], ['3', '4'], ['4', '5'], ['5', '6'], ['6', '7']]) == False\n assert candidate(s = \"abracadabra123\",sub = \"acad\",mappings = [['a', '1'], ['d', '3'], ['a', 'b']]) == True\n assert candidate(s = \"TheQuickBrownFox\",sub = \"TheQucikBrwnFks\",mappings = [['u', 'i'], ['i', 'k'], ['B', 'r'], ['r', 'n'], ['F', 'k'], ['o', 'u']]) == False\n assert candidate(s = \"MAPPINGmappings\",sub = \"mapping\",mappings = [['M', 'm'], ['A', 'a'], ['P', 'p'], ['P', 'p'], ['I', 'i'], ['N', 'n'], ['G', 'g']]) == True\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",sub = \"fedcba\",mappings = [['f', 'Z'], ['e', 'Y'], ['d', 'X'], ['c', 'W'], ['b', 'V'], ['a', 'U']]) == False\n assert candidate(s = \"mississippi\",sub = \"missi5\",mappings = [['i', '5']]) == False\n assert candidate(s = \"ababababab\",sub = \"abab\",mappings = [['a', 'b'], ['b', 'a']]) == True\n assert candidate(s = \"xyz123xyz123xyz123\",sub = \"abc\",mappings = [['a', 'x'], ['b', 'y'], ['c', 'z'], ['1', 'a'], ['2', 'b'], ['3', 'c']]) == True\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",sub = \"ABCD123\",mappings = [['E', '1'], ['F', '2'], ['G', '3']]) == False\n assert candidate(s = \"00000000000000000000\",sub = \"1111111111\",mappings = [['0', '1']]) == False\n assert candidate(s = \"abcabcabcabcabcabc\",sub = \"aBc\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C']]) == False\n assert candidate(s = \"HELLOworld\",sub = \"H3LL0\",mappings = [['E', '3'], ['O', '0']]) == False\n assert candidate(s = \"1234567890\",sub = \"123\",mappings = [['1', '9'], ['2', '8'], ['3', '7']]) == True\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0\",sub = \"abcdefghij\",mappings = [['a', '1'], ['b', '2'], ['c', '3'], ['d', '4'], ['e', '5'], ['f', '6'], ['g', '7'], ['h', '8'], ['i', '9'], ['j', '0']]) == False\n assert candidate(s = \"abcXYZdefUVW\",sub = \"xyzuvw\",mappings = [['a', 'x'], ['b', 'y'], ['c', 'z'], ['d', 'u'], ['e', 'v'], ['f', 'w']]) == False\n assert candidate(s = \"xyxyxyxyxy\",sub = \"xyz\",mappings = [['x', 'y'], ['y', 'x']]) == False\n assert candidate(s = \"thisisaverylongstringwithmanymappings\",sub = \"short\",mappings = [['s', 't'], ['h', 'i'], ['o', 's'], ['r', 'r'], ['t', 'o']]) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",sub = \"xyz\",mappings = [['x', 'v'], ['y', 'w'], ['z', 'x']]) == True\n assert candidate(s = \"A1B2C3D4E5F6G7H8I9J0\",sub = \"abcd\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['d', 'D']]) == False\n assert candidate(s = \"1234567890\",sub = \"abcdefghij\",mappings = [['1', 'a'], ['2', 'b'], ['3', 'c'], ['4', 'd'], ['5', 'e'], ['6', 'f'], ['7', 'g'], ['8', 'h'], ['9', 'i']]) == False\n assert candidate(s = \"abcdefabcdefabcdef\",sub = \"xyz\",mappings = [['a', 'x'], ['b', 'y'], ['c', 'z']]) == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",sub = \"zzzz\",mappings = [['z', 'Z'], ['Z', 'z']]) == True\n assert candidate(s = \"aaaaaa\",sub = \"bbbbb\",mappings = [['a', 'b']]) == False\n assert candidate(s = \"abcabcabcabc\",sub = \"abca\",mappings = [['a', 'b'], ['b', 'c'], ['c', 'a']]) == True\n assert candidate(s = \"111222333444555666777888999\",sub = \"123456789\",mappings = [['1', '2'], ['2', '3'], ['3', '4'], ['4', '5'], ['5', '6'], ['6', '7'], ['7', '8'], ['8', '9']]) == False\n assert candidate(s = \"1234567890\",sub = \"123abc\",mappings = [['4', 'a'], ['5', 'b'], ['6', 'c']]) == False\n assert candidate(s = \"abcabcabcabcabc\",sub = \"abdc\",mappings = [['a', 'd'], ['b', 'c']]) == False\n assert candidate(s = \"AAABBBCCCDDD\",sub = \"abc\",mappings = [['A', 'a'], ['B', 'b'], ['C', 'c']]) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",sub = \"zyxwvutsrqponmlkjihgfedcba\",mappings = [['a', 'z'], ['b', 'y'], ['c', 'x'], ['d', 'w'], ['e', 'v'], ['f', 'u'], ['g', 't'], ['h', 's'], ['i', 'r'], ['j', 'q'], ['k', 'p'], ['l', 'o'], ['m', 'n']]) == False\n assert candidate(s = \"Python3.8\",sub = \"Python3.8\",mappings = [['3', '2']]) == True\n assert candidate(s = \"abcdefghij\",sub = \"abcd12\",mappings = [['e', '1'], ['f', '2'], ['g', '3']]) == False\n assert candidate(s = \"HelloWorld123\",sub = \"hello123\",mappings = [['H', 'h'], ['W', 'w'], ['o', '0'], ['r', '4'], ['l', '1']]) == False\n assert candidate(s = \"aabbccddeeffgg\",sub = \"abc\",mappings = [['a', 'b'], ['b', 'c'], ['c', 'd']]) == True\n assert candidate(s = \"abcdeABCDEabcdeABCDE\",sub = \"abcde\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['d', 'D'], ['e', 'E']]) == True\n assert candidate(s = \"patternmatching\",sub = \"patt3rn\",mappings = [['a', '3']]) == False\n assert candidate(s = \"abcdefgABCDEFG\",sub = \"aBcDeFg\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['d', 'D'], ['e', 'E'], ['f', 'F'], ['g', 'G']]) == True\n assert candidate(s = \"abcdefghijk\",sub = \"abc123\",mappings = [['d', '1'], ['e', '2'], ['f', '3']]) == False\n assert candidate(s = \"zzzzzzzzzz\",sub = \"aaa\",mappings = [['z', 'a']]) == False\n assert candidate(s = \"hello123world456\",sub = \"hell12\",mappings = [['l', '1'], ['o', '2']]) == False\n assert candidate(s = \"helloWorld123\",sub = \"he1oW3ld\",mappings = [['l', '1'], ['o', '0'], ['W', '3'], ['r', '2']]) == False\n assert candidate(s = \"hellohellohello\",sub = \"world\",mappings = [['w', 'h'], ['o', 'e'], ['r', 'l'], ['l', 'l'], ['d', 'o']]) == True\n assert candidate(s = \"Python38\",sub = \"pyth0n39\",mappings = [['P', 'p'], ['Y', 'y'], ['t', '0'], ['h', 'h'], ['o', '3'], ['n', '9']]) == False\n assert candidate(s = \"12345678901234567890\",sub = \"12345\",mappings = [['1', '2'], ['2', '3'], ['3', '4'], ['4', '5'], ['5', '6']]) == True\n"}, "metadata": {"canonical_parameter_names": ["s", "sub", "mappings"], "leetcode_dataset_entry_point": "Solution().matchReplacement", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean matchReplacement(String s, String sub, char[][] mappings) {", "container": "Solution", "callable": "matchReplacement", "parameters": [{"name": "s", "type": "String"}, {"name": "sub", "type": "String"}, {"name": "mappings", "type": "char[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2302, "task_id": "count-subarrays-with-score-less-than-k", "difficulty": "Hard", "problem_description": "The score of an array is defined as the product of its sum and its length.\n\nFor example, the score of [1, 2, 3, 4, 5] is (1 + 2 + 3 + 4 + 5) * 5 = 75.\n\nGiven a positive integer array nums and an integer k, return the number of non-empty subarrays of nums whose score is strictly less than k.\nA subarray is a contiguous sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [2,1,4,3,5], k = 10\nOutput: 6\nExplanation:\nThe 6 subarrays having scores less than 10 are:\n- [2] with score 2 * 1 = 2.\n- [1] with score 1 * 1 = 1.\n- [4] with score 4 * 1 = 4.\n- [3] with score 3 * 1 = 3. \n- [5] with score 5 * 1 = 5.\n- [2,1] with score (2 + 1) * 2 = 6.\nNote that subarrays such as [1,4] and [4,3,5] are not considered because their scores are 10 and 36 respectively, while we need scores strictly less than 10.\nExample 2:\n\nInput: nums = [1,1,1], k = 5\nOutput: 5\nExplanation:\nEvery subarray except [1,1,1] has a score less than 5.\n[1,1,1] has a score (1 + 1 + 1) * 3 = 9, which is greater than 5.\nThus, there are 5 subarrays having scores less than 5.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 105\n1 <= k <= 1015\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 100) == 15\n assert candidate(nums = [10, 10, 10],k = 100) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 24\n assert candidate(nums = [1, 1, 1],k = 5) == 5\n assert candidate(nums = [1],k = 2) == 1\n assert candidate(nums = [5, 5, 5, 5],k = 20) == 4\n assert candidate(nums = [10, 20, 30],k = 100) == 4\n assert candidate(nums = [5, 5, 5, 5],k = 25) == 7\n assert candidate(nums = [2, 1, 4, 3, 5],k = 10) == 6\n assert candidate(nums = [10, 5, 2, 6],k = 100) == 10\n assert candidate(nums = [5, 5, 5, 5, 5],k = 25) == 9\n assert candidate(nums = [1, 2, 3, 4, 5],k = 75) == 14\n assert candidate(nums = [10, 20, 30, 40, 50],k = 200) == 10\n assert candidate(nums = [5, 5, 5, 5],k = 15) == 4\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 19\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000) == 32\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 50) == 19\n assert candidate(nums = [3, 5, 2, 8, 6, 1],k = 25) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 30) == 24\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 30) == 19\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 = 50) == 74\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 = 20) == 74\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],k = 20) == 23\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 100) == 26\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 100) == 34\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 10000) == 54\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 200) == 32\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 100) == 29\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 34\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 30) == 18\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 100) == 23\n assert candidate(nums = [100, 200, 300, 400, 500],k = 100000) == 15\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 500000000000) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 24\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500000) == 55\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 400) == 37\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995],k = 100000000000) == 21\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9],k = 50) == 13\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 = 200) == 101\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 500) == 37\n assert candidate(nums = [3, 5, 7, 2, 8, 10],k = 100) == 17\n assert candidate(nums = [100, 200, 300, 400, 500],k = 10000) == 15\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100000) == 55\n assert candidate(nums = [5, 1, 3, 2, 5, 1, 2],k = 20) == 14\n assert candidate(nums = [9, 7, 5, 3, 1, 9, 7, 5, 3, 1],k = 100) == 34\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 300) == 32\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10000) == 55\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 = 30) == 57\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 999990000000) == 55\n assert candidate(nums = [7, 3, 2, 8, 1, 2, 4],k = 20) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 20) == 20\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 81) == 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],k = 10) == 57\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 25) == 22\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 50) == 54\n assert candidate(nums = [3, 2, 1, 4, 5],k = 20) == 10\n assert candidate(nums = [5, 4, 3, 2, 1],k = 15) == 8\n assert candidate(nums = [10, 1, 2, 3, 10, 2, 3, 10, 2, 3],k = 50) == 27\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 150) == 30\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50000) == 54\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 150) == 38\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 100) == 27\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 11) == 27\n assert candidate(nums = [50, 40, 30, 20, 10],k = 1000) == 15\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 50) == 22\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],k = 10000000) == 28\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],k = 100) == 203\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 150) == 29\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 50) == 34\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5000) == 55\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 27\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 500) == 40\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 150) == 53\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) == 54\n assert candidate(nums = [10, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 150) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100) == 32\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5000) == 54\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 200) == 61\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 100) == 44\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countSubarrays(int[] nums, long k) {", "container": "Solution", "callable": "countSubarrays", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "long"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2303, "task_id": "calculate-amount-paid-in-taxes", "difficulty": "Easy", "problem_description": "You are given a 0-indexed 2D integer array brackets where brackets[i] = [upperi, percenti] means that the ith tax bracket has an upper bound of upperi and is taxed at a rate of percenti. The brackets are sorted by upper bound (i.e. upperi-1 < upperi for 0 < i < brackets.length).\nTax is calculated as follows:\n\nThe first upper0 dollars earned are taxed at a rate of percent0.\nThe next upper1 - upper0 dollars earned are taxed at a rate of percent1.\nThe next upper2 - upper1 dollars earned are taxed at a rate of percent2.\nAnd so on.\n\nYou are given an integer income representing the amount of money you earned. Return the amount of money that you have to pay in taxes. Answers within 10-5 of the actual answer will be accepted.\n \nExample 1:\n\nInput: brackets = [[3,50],[7,10],[12,25]], income = 10\nOutput: 2.65000\nExplanation:\nBased on your income, you have 3 dollars in the 1st tax bracket, 4 dollars in the 2nd tax bracket, and 3 dollars in the 3rd tax bracket.\nThe tax rate for the three tax brackets is 50%, 10%, and 25%, respectively.\nIn total, you pay $3 * 50% + $4 * 10% + $3 * 25% = $2.65 in taxes.\n\nExample 2:\n\nInput: brackets = [[1,0],[4,25],[5,50]], income = 2\nOutput: 0.25000\nExplanation:\nBased on your income, you have 1 dollar in the 1st tax bracket and 1 dollar in the 2nd tax bracket.\nThe tax rate for the two tax brackets is 0% and 25%, respectively.\nIn total, you pay $1 * 0% + $1 * 25% = $0.25 in taxes.\n\nExample 3:\n\nInput: brackets = [[2,50]], income = 0\nOutput: 0.00000\nExplanation:\nYou have no income to tax, so you have to pay a total of $0 in taxes.\n\n \nConstraints:\n\n1 <= brackets.length <= 100\n1 <= upperi <= 1000\n0 <= percenti <= 100\n0 <= income <= 1000\nupperi is sorted in ascending order.\nAll the values of upperi are unique.\nThe upper bound of the last tax bracket is greater than or equal to income.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(brackets = [[3, 50], [7, 10], [12, 25]],income = 10) == 2.65\n assert candidate(brackets = [[5, 10], [10, 20], [15, 30], [20, 40]],income = 25) == 5.0\n assert candidate(brackets = [[100, 20]],income = 50) == 10.0\n assert candidate(brackets = [[50, 0], [100, 20], [150, 25]],income = 175) == 22.5\n assert candidate(brackets = [[1, 100], [2, 50]],income = 1) == 1.0\n assert candidate(brackets = [[5, 5], [10, 15], [15, 25]],income = 15) == 2.25\n assert candidate(brackets = [[1, 100]],income = 1) == 1.0\n assert candidate(brackets = [[2, 50]],income = 0) == 0.0\n assert candidate(brackets = [[1, 100], [2, 0], [3, 50]],income = 1) == 1.0\n assert candidate(brackets = [[1, 0], [4, 25], [5, 50]],income = 2) == 0.25\n assert candidate(brackets = [[10, 10], [20, 20], [30, 30], [40, 40]],income = 35) == 8.0\n assert candidate(brackets = [[1, 1], [2, 2], [3, 3]],income = 3) == 0.06\n assert candidate(brackets = [[1, 100], [2, 50], [3, 25]],income = 1) == 1.0\n assert candidate(brackets = [[10, 20], [20, 30], [30, 40]],income = 15) == 3.5\n assert candidate(brackets = [[5, 50], [10, 30], [15, 20]],income = 12) == 4.4\n assert candidate(brackets = [[500, 10], [1000, 20]],income = 750) == 100.0\n assert candidate(brackets = [[10, 50]],income = 10) == 5.0\n assert candidate(brackets = [[50, 10], [100, 20], [150, 30]],income = 75) == 10.0\n assert candidate(brackets = [[10, 20], [20, 30], [30, 25]],income = 25) == 6.25\n assert candidate(brackets = [[100, 5]],income = 100) == 5.0\n assert candidate(brackets = [[100, 10]],income = 100) == 10.0\n assert candidate(brackets = [[10, 10], [20, 20], [30, 30]],income = 15) == 2.0\n assert candidate(brackets = [[1, 1], [2, 2], [3, 3], [4, 4]],income = 4) == 0.1\n assert candidate(brackets = [[100, 10]],income = 50) == 5.0\n assert candidate(brackets = [[500, 10], [750, 20], [1000, 30]],income = 1000) == 175.0\n assert candidate(brackets = [[5, 100]],income = 5) == 5.0\n assert candidate(brackets = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],income = 5) == 0.15\n assert candidate(brackets = [[10, 10], [20, 20], [30, 30]],income = 25) == 4.5\n assert candidate(brackets = [[3, 0], [6, 10], [9, 20]],income = 9) == 0.9\n assert candidate(brackets = [[1, 100], [2, 100], [3, 100]],income = 3) == 3.0\n assert candidate(brackets = [[50, 10], [100, 20], [200, 30], [500, 40]],income = 400) == 125.0\n assert candidate(brackets = [[100, 10], [200, 20], [300, 30], [400, 40]],income = 350) == 80.0\n assert candidate(brackets = [[10, 0], [20, 10], [30, 20], [40, 30], [50, 40], [60, 50]],income = 60) == 15.0\n assert candidate(brackets = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],income = 45) == 12.5\n assert candidate(brackets = [[500, 25], [1000, 30]],income = 800) == 215.0\n assert candidate(brackets = [[5, 0], [10, 5], [15, 10], [20, 15], [25, 20]],income = 18) == 1.2\n assert candidate(brackets = [[10, 5], [20, 10], [30, 15], [40, 20]],income = 25) == 2.25\n assert candidate(brackets = [[500, 0], [1000, 20], [1500, 40]],income = 2000) == 300.0\n assert candidate(brackets = [[50, 1], [100, 2], [150, 3], [200, 4], [250, 5]],income = 100) == 1.5\n assert candidate(brackets = [[5, 25], [15, 50], [25, 75], [35, 100]],income = 35) == 23.75\n assert candidate(brackets = [[2, 50], [4, 75], [6, 100], [8, 125], [10, 150]],income = 10) == 10.0\n assert candidate(brackets = [[100, 25], [200, 30], [300, 35]],income = 250) == 72.5\n assert candidate(brackets = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],income = 10) == 5.5\n assert candidate(brackets = [[10, 0], [20, 5], [30, 10], [40, 15], [50, 20], [60, 25]],income = 55) == 6.25\n assert candidate(brackets = [[100, 5], [200, 10], [300, 15], [400, 20], [500, 25]],income = 500) == 75.0\n assert candidate(brackets = [[10, 10], [20, 20], [30, 30], [40, 40]],income = 25) == 4.5\n assert candidate(brackets = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60], [700, 70], [800, 80], [900, 90], [1000, 100]],income = 1000) == 550.0\n assert candidate(brackets = [[150, 5], [250, 10], [350, 15], [450, 20], [550, 25]],income = 600) == 77.5\n assert candidate(brackets = [[500, 10], [1000, 15], [1500, 20], [2000, 25], [2500, 30]],income = 2200) == 410.0\n assert candidate(brackets = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],income = 45) == 1.25\n assert candidate(brackets = [[100, 5], [150, 10], [200, 15], [250, 20], [300, 25], [350, 30], [400, 35], [450, 40], [500, 45]],income = 499) == 114.55\n assert candidate(brackets = [[100, 15], [200, 25], [300, 35], [400, 45]],income = 350) == 97.5\n assert candidate(brackets = [[500, 1], [1000, 2]],income = 750) == 10.0\n assert candidate(brackets = [[50, 5], [150, 15], [300, 25]],income = 200) == 30.0\n assert candidate(brackets = [[50, 15], [100, 20], [150, 25], [200, 30]],income = 175) == 37.5\n assert candidate(brackets = [[10, 50], [20, 75], [30, 100]],income = 10) == 5.0\n assert candidate(brackets = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35]],income = 65) == 12.25\n assert candidate(brackets = [[1, 100]],income = 1000) == 1.0\n assert candidate(brackets = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]],income = 100) == 54.5\n assert candidate(brackets = [[200, 10], [400, 20], [600, 30], [800, 40], [1000, 50]],income = 750) == 180.0\n assert candidate(brackets = [[100, 0], [200, 5], [300, 10], [400, 15], [500, 20]],income = 0) == 0.0\n assert candidate(brackets = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]],income = 30) == 3.0\n assert candidate(brackets = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50]],income = 450) == 125.0\n assert candidate(brackets = [[100, 5], [200, 10], [300, 15], [400, 20], [500, 25], [600, 30], [700, 35], [800, 40], [900, 45], [1000, 50]],income = 800) == 180.0\n assert candidate(brackets = [[10, 25], [20, 25], [30, 25], [40, 25], [50, 25]],income = 40) == 10.0\n assert candidate(brackets = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],income = 25) == 0.45\n assert candidate(brackets = [[10, 100], [20, 100], [30, 100], [40, 100], [50, 100]],income = 45) == 45.0\n assert candidate(brackets = [[50, 0], [100, 10], [150, 20], [200, 30], [250, 40]],income = 250) == 50.0\n assert candidate(brackets = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]],income = 5) == 0.3\n assert candidate(brackets = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],income = 400) == 10.0\n assert candidate(brackets = [[10, 10], [50, 20], [100, 30], [200, 40], [500, 50]],income = 600) == 214.0\n assert candidate(brackets = [[50, 1], [100, 2], [150, 3], [200, 4], [250, 5], [300, 6]],income = 175) == 4.0\n assert candidate(brackets = [[15, 0], [30, 10], [45, 20], [60, 30], [75, 40]],income = 70) == 13.0\n assert candidate(brackets = [[10, 50], [20, 40], [30, 30], [40, 20], [50, 10]],income = 50) == 15.0\n assert candidate(brackets = [[10, 50], [20, 40], [30, 30], [40, 20], [50, 10]],income = 45) == 14.5\n assert candidate(brackets = [[50, 0], [100, 5], [150, 10], [200, 15], [250, 20], [300, 25]],income = 120) == 4.5\n assert candidate(brackets = [[10, 25], [20, 25], [30, 25], [40, 25], [50, 25], [60, 25], [70, 25], [80, 25], [90, 25], [100, 25]],income = 95) == 23.75\n assert candidate(brackets = [[10, 50], [20, 50], [30, 50], [40, 50], [50, 50], [60, 50], [70, 50], [80, 50], [90, 50], [100, 50]],income = 55) == 27.5\n assert candidate(brackets = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],income = 100) == 5.5\n assert candidate(brackets = [[1000, 100]],income = 1000) == 1000.0\n assert candidate(brackets = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]],income = 85) == 20.25\n assert candidate(brackets = [[10, 0], [20, 0], [30, 0], [40, 0], [50, 0]],income = 50) == 0.0\n assert candidate(brackets = [[5, 10], [15, 15], [25, 20], [35, 25], [45, 30]],income = 30) == 5.25\n assert candidate(brackets = [[10, 5], [20, 10], [30, 15]],income = 5) == 0.25\n assert candidate(brackets = [[50, 10], [100, 20], [150, 30], [200, 40], [250, 50]],income = 300) == 75.0\n assert candidate(brackets = [[50, 10], [100, 20], [150, 30], [200, 40], [250, 50]],income = 220) == 60.0\n assert candidate(brackets = [[2, 5], [5, 10], [10, 20], [20, 30], [50, 40]],income = 30) == 8.4\n assert candidate(brackets = [[10, 0], [20, 10], [30, 20], [40, 30], [50, 40], [60, 50], [70, 60], [80, 70], [90, 80], [100, 90]],income = 95) == 40.5\n assert candidate(brackets = [[300, 5], [600, 10], [900, 15]],income = 900) == 90.0\n assert candidate(brackets = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60]],income = 650) == 210.0\n assert candidate(brackets = [[5, 0], [10, 10], [15, 20], [20, 30], [25, 40]],income = 25) == 5.0\n assert candidate(brackets = [[100, 15], [200, 25], [300, 35], [400, 45], [500, 55]],income = 600) == 175.0\n assert candidate(brackets = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60]],income = 15) == 14.5\n assert candidate(brackets = [[200, 15], [400, 25], [600, 30]],income = 550) == 125.0\n assert candidate(brackets = [[10, 25], [20, 35], [30, 45], [40, 55], [50, 65]],income = 35) == 13.25\n assert candidate(brackets = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55]],income = 50) == 17.5\n assert candidate(brackets = [[500, 1], [1000, 2], [1500, 3], [2000, 4], [2500, 5]],income = 2400) == 70.0\n assert candidate(brackets = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60]],income = 5) == 4.0\n assert candidate(brackets = [[10, 0], [20, 5], [30, 10], [40, 15], [50, 20], [60, 25], [70, 30], [80, 35], [90, 40], [100, 45]],income = 50) == 5.0\n assert candidate(brackets = [[30, 5], [60, 10], [90, 15], [120, 20], [150, 25]],income = 150) == 22.5\n assert candidate(brackets = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],income = 100) == 55.0\n assert candidate(brackets = [[10, 0], [20, 5], [30, 10], [40, 15], [50, 20]],income = 40) == 3.0\n assert candidate(brackets = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],income = 10) == 0.55\n assert candidate(brackets = [[100, 0], [200, 50], [300, 100], [400, 150]],income = 400) == 300.0\n assert candidate(brackets = [[50, 5], [150, 10], [250, 15], [350, 20], [450, 25], [550, 30]],income = 300) == 37.5\n assert candidate(brackets = [[10, 100], [20, 0], [30, 100], [40, 0]],income = 35) == 20.0\n assert candidate(brackets = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60]],income = 55) == 20.5\n assert candidate(brackets = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50]],income = 500) == 150.0\n assert candidate(brackets = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]],income = 100) == 27.5\n assert candidate(brackets = [[50, 5], [150, 15], [250, 25], [350, 35], [450, 45]],income = 450) == 122.5\n assert candidate(brackets = [[200, 10], [500, 20], [800, 30], [1000, 40]],income = 750) == 155.0\n assert candidate(brackets = [[100, 0], [200, 0], [300, 0], [400, 0], [500, 0]],income = 500) == 0.0\n assert candidate(brackets = [[100, 5], [200, 10], [300, 15], [400, 20], [500, 25], [600, 30]],income = 600) == 105.0\n assert candidate(brackets = [[100, 0], [200, 5], [300, 10], [400, 15], [500, 20], [600, 25]],income = 150) == 2.5\n assert candidate(brackets = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60]],income = 6) == 2.1\n assert candidate(brackets = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25]],income = 45) == 6.25\n assert candidate(brackets = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],income = 35) == 8.0\n assert candidate(brackets = [[1, 100], [10, 90], [100, 80], [1000, 70]],income = 500) == 361.1\n assert candidate(brackets = [[100, 5], [200, 10], [300, 15], [400, 20], [500, 25], [600, 30], [700, 35], [800, 40], [900, 45], [1000, 50]],income = 950) == 250.0\n assert candidate(brackets = [[50, 5], [100, 15], [200, 25], [300, 35]],income = 250) == 52.5\n assert candidate(brackets = [[100, 5], [200, 10], [300, 15], [400, 20], [500, 25], [600, 30], [700, 35], [800, 40], [900, 45], [1000, 50]],income = 999) == 274.5\n assert candidate(brackets = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50]],income = 18) == 4.2\n"}, "metadata": {"canonical_parameter_names": ["brackets", "income"], "leetcode_dataset_entry_point": "Solution().calculateTax", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public double calculateTax(int[][] brackets, int income) {", "container": "Solution", "callable": "calculateTax", "parameters": [{"name": "brackets", "type": "int[][]"}, {"name": "income", "type": "int"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2304, "task_id": "minimum-path-cost-in-a-grid", "difficulty": "Medium", "problem_description": "You are given a 0-indexed m x n integer matrix grid consisting of distinct integers from 0 to m * n - 1. You can move in this matrix from a cell to any other cell in the next row. That is, if you are in cell (x, y) such that x < m - 1, you can move to any of the cells (x + 1, 0), (x + 1, 1), ..., (x + 1, n - 1). Note that it is not possible to move from cells in the last row.\nEach possible move has a cost given by a 0-indexed 2D array moveCost of size (m * n) x n, where moveCost[i][j] is the cost of moving from a cell with value i to a cell in column j of the next row. The cost of moving from cells in the last row of grid can be ignored.\nThe cost of a path in grid is the sum of all values of cells visited plus the sum of costs of all the moves made. Return the minimum cost of a path that starts from any cell in the first row and ends at any cell in the last row.\n \nExample 1:\n\n\nInput: grid = [[5,3],[4,0],[2,1]], moveCost = [[9,8],[1,5],[10,12],[18,6],[2,4],[14,3]]\nOutput: 17\nExplanation: The path with the minimum possible cost is the path 5 -> 0 -> 1.\n- The sum of the values of cells visited is 5 + 0 + 1 = 6.\n- The cost of moving from 5 to 0 is 3.\n- The cost of moving from 0 to 1 is 8.\nSo the total cost of the path is 6 + 3 + 8 = 17.\n\nExample 2:\n\nInput: grid = [[5,1,2],[4,0,3]], moveCost = [[12,10,15],[20,23,8],[21,7,1],[8,1,13],[9,10,25],[5,3,2]]\nOutput: 6\nExplanation: The path with the minimum possible cost is the path 2 -> 3.\n- The sum of the values of cells visited is 2 + 3 = 5.\n- The cost of moving from 2 to 3 is 1.\nSo the total cost of this path is 5 + 1 = 6.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n2 <= m, n <= 50\ngrid consists of distinct integers from 0 to m * n - 1.\nmoveCost.length == m * n\nmoveCost[i].length == n\n1 <= moveCost[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],moveCost = [[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]]) == 29\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]],moveCost = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) == 9\n assert candidate(grid = [[0, 1], [2, 3]],moveCost = [[9, 8], [1, 5], [10, 12], [18, 6]]) == 4\n assert candidate(grid = [[5, 3], [4, 0], [2, 1]],moveCost = [[9, 8], [1, 5], [10, 12], [18, 6], [2, 4], [14, 3]]) == 17\n assert candidate(grid = [[5, 1, 2], [4, 0, 3]],moveCost = [[12, 10, 15], [20, 23, 8], [21, 7, 1], [8, 1, 13], [9, 10, 25], [5, 3, 2]]) == 6\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],moveCost = [[2, 3], [1, 2], [3, 4], [2, 3], [4, 5], [3, 4], [5, 6], [4, 5], [6, 7], [5, 6], [7, 8], [6, 7], [8, 9], [7, 8], [9, 10], [8, 9]]) == 35\n assert candidate(grid = [[2, 3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16]],moveCost = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 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(grid = [[1, 3, 5], [2, 8, 4], [6, 7, 9], [10, 12, 11]],moveCost = [[2, 3, 4], [1, 6, 5], [8, 9, 7], [3, 2, 1], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27]]) == 38\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],moveCost = [[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]]) == 55\n assert candidate(grid = [[5, 3, 7, 9], [4, 0, 8, 6], [2, 1, 5, 4], [10, 12, 15, 11]],moveCost = [[9, 8, 11, 13], [1, 5, 12, 6], [10, 12, 14, 7], [18, 6, 9, 3], [2, 4, 1, 8], [14, 3, 5, 2], [7, 10, 15, 16], [3, 8, 2, 4], [9, 1, 13, 5], [5, 3, 2, 10], [11, 6, 9, 12], [4, 7, 14, 18]]) == 28\n assert candidate(grid = [[9, 3, 12, 6], [2, 11, 8, 4], [15, 14, 10, 13], [7, 5, 1, 0]],moveCost = [[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]]) == 83\n assert candidate(grid = [[7, 5, 3, 1], [8, 6, 4, 2], [9, 7, 5, 3]],moveCost = [[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]]) == 26\n assert candidate(grid = [[9, 2, 11], [14, 13, 7], [4, 15, 6], [8, 3, 5], [10, 12, 1]],moveCost = [[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]]) == 74\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],moveCost = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 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(grid = [[5, 8, 6], [3, 7, 4], [9, 2, 1], [6, 5, 3]],moveCost = [[5, 7, 8], [3, 4, 2], [1, 2, 3], [6, 9, 4], [10, 6, 5], [7, 8, 9], [2, 4, 3], [8, 5, 6], [3, 7, 8], [1, 2, 5]]) == 21\n assert candidate(grid = [[1, 10, 3, 4], [2, 5, 6, 7], [8, 9, 2, 11], [12, 13, 14, 15]],moveCost = [[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]]) == 42\n assert candidate(grid = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]],moveCost = [[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]]) == 43\n assert candidate(grid = [[3, 1, 4, 1, 5], [9, 2, 6, 5, 3], [5, 8, 9, 7, 9], [3, 2, 3, 8, 4]],moveCost = [[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]]) == 55\n assert candidate(grid = [[7, 5, 9], [2, 6, 8], [3, 4, 1], [10, 11, 12]],moveCost = [[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]]) == 47\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 0], [0, 9, 8, 7, 6]],moveCost = [[1, 2, 3, 4, 5], [6, 5, 4, 3, 2], [7, 8, 9, 0, 1], [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], [1, 2, 3, 4, 5], [6, 5, 4, 3, 2], [7, 8, 9, 0, 1], [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]]) == 6\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],moveCost = [[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]]) == 61\n assert candidate(grid = [[1, 3, 1, 4], [1, 5, 1, 4], [4, 2, 1, 3]],moveCost = [[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]]) == 15\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],moveCost = [[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]]) == 61\n assert candidate(grid = [[5, 3, 8], [4, 0, 12], [2, 1, 7], [9, 6, 10]],moveCost = [[9, 8, 5], [1, 5, 2], [10, 12, 15], [18, 6, 3], [2, 4, 8], [14, 3, 6], [7, 11, 9], [13, 16, 14], [17, 19, 20], [1, 21, 22], [23, 24, 25], [26, 27, 28], [29, 30, 31], [32, 33, 34], [35, 36, 37]]) == 27\n assert candidate(grid = [[1, 3, 2, 4], [2, 4, 3, 1], [3, 1, 4, 2], [4, 2, 1, 3]],moveCost = [[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]]) == 25\n assert candidate(grid = [[8, 3, 7, 2], [6, 4, 5, 1], [9, 11, 10, 13]],moveCost = [[2, 5, 1, 3], [6, 4, 8, 7], [9, 12, 11, 13], [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]]) == 23\n assert candidate(grid = [[1, 3, 5], [2, 4, 6], [7, 8, 9]],moveCost = [[3, 5, 2], [1, 3, 4], [6, 2, 5], [4, 1, 3], [2, 5, 1], [7, 2, 4], [3, 6, 2], [5, 1, 4], [2, 3, 1]]) == 14\n assert candidate(grid = [[2, 3, 4, 5], [1, 6, 7, 8], [9, 10, 11, 12]],moveCost = [[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]]) == 26\n"}, "metadata": {"canonical_parameter_names": ["grid", "moveCost"], "leetcode_dataset_entry_point": "Solution().minPathCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minPathCost(int[][] grid, int[][] moveCost) {", "container": "Solution", "callable": "minPathCost", "parameters": [{"name": "grid", "type": "int[][]"}, {"name": "moveCost", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2305, "task_id": "fair-distribution-of-cookies", "difficulty": "Medium", "problem_description": "You are given an integer array cookies, where cookies[i] denotes the number of cookies in the ith bag. You are also given an integer k that denotes the number of children to distribute all the bags of cookies to. All the cookies in the same bag must go to the same child and cannot be split up.\nThe unfairness of a distribution is defined as the maximum total cookies obtained by a single child in the distribution.\nReturn the minimum unfairness of all distributions.\n \nExample 1:\n\nInput: cookies = [8,15,10,20,8], k = 2\nOutput: 31\nExplanation: One optimal distribution is [8,15,8] and [10,20]\n- The 1st child receives [8,15,8] which has a total of 8 + 15 + 8 = 31 cookies.\n- The 2nd child receives [10,20] which has a total of 10 + 20 = 30 cookies.\nThe unfairness of the distribution is max(31,30) = 31.\nIt can be shown that there is no distribution with an unfairness less than 31.\n\nExample 2:\n\nInput: cookies = [6,1,3,2,2,4,1,2], k = 3\nOutput: 7\nExplanation: One optimal distribution is [6,1], [3,2,2], and [4,1,2]\n- The 1st child receives [6,1] which has a total of 6 + 1 = 7 cookies.\n- The 2nd child receives [3,2,2] which has a total of 3 + 2 + 2 = 7 cookies.\n- The 3rd child receives [4,1,2] which has a total of 4 + 1 + 2 = 7 cookies.\nThe unfairness of the distribution is max(7,7,7) = 7.\nIt can be shown that there is no distribution with an unfairness less than 7.\n\n \nConstraints:\n\n2 <= cookies.length <= 8\n1 <= cookies[i] <= 105\n2 <= k <= cookies.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 100000],k = 7) == 100000\n assert candidate(cookies = [8, 15, 10, 20, 8],k = 2) == 31\n assert candidate(cookies = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 8) == 100000\n assert candidate(cookies = [1, 100000, 1, 1, 1, 1, 1, 1],k = 3) == 100000\n assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 2) == 180\n assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 8) == 80\n assert candidate(cookies = [1, 3, 2, 4, 5, 6, 7, 8],k = 2) == 18\n assert candidate(cookies = [100000, 1, 1, 1, 1, 1, 1, 1],k = 2) == 100000\n assert candidate(cookies = [5, 5, 5, 5, 5, 5, 5, 5],k = 8) == 5\n assert candidate(cookies = [2, 2, 2, 2, 2, 2, 2, 2],k = 2) == 8\n assert candidate(cookies = [6, 1, 3, 2, 2, 4, 1, 2],k = 3) == 7\n assert candidate(cookies = [8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 9\n assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 4) == 9\n assert candidate(cookies = [100000, 1, 1, 1, 1, 1, 1, 1],k = 7) == 100000\n assert candidate(cookies = [5, 5, 5, 5, 5, 5, 5, 5],k = 2) == 20\n assert candidate(cookies = [8, 6, 7, 5, 3, 0, 9, 1],k = 5) == 9\n assert candidate(cookies = [8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 18\n assert candidate(cookies = [15, 20, 25, 30, 35, 40, 45, 50],k = 7) == 50\n assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 7) == 8\n assert candidate(cookies = [9, 8, 7, 6, 5, 4, 3, 2],k = 5) == 9\n assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 5) == 800\n assert candidate(cookies = [1, 1, 2, 2, 3, 3, 4, 4],k = 5) == 4\n assert candidate(cookies = [7, 14, 21, 28, 35, 42, 49, 56],k = 2) == 126\n assert candidate(cookies = [80, 70, 60, 50, 40, 30, 20, 10],k = 4) == 90\n assert candidate(cookies = [1, 1, 2, 2, 3, 3, 4, 4],k = 2) == 10\n assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 4) == 90\n assert candidate(cookies = [12, 11, 10, 9, 8, 7, 6, 5],k = 3) == 23\n assert candidate(cookies = [100, 200, 300, 150, 50, 25, 25, 50],k = 4) == 300\n assert candidate(cookies = [30, 20, 10, 40, 60, 50, 70, 80],k = 5) == 80\n assert candidate(cookies = [30, 20, 10, 20, 30, 20, 10, 20],k = 5) == 40\n assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 5) == 80\n assert candidate(cookies = [100000, 1, 2, 3, 4, 5, 6, 7],k = 2) == 100000\n assert candidate(cookies = [1, 10, 100, 1000, 10000, 100000, 5, 50],k = 5) == 100000\n assert candidate(cookies = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000],k = 4) == 10000000\n assert candidate(cookies = [9, 6, 12, 4, 7, 11, 5, 3],k = 4) == 15\n assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 2\n assert candidate(cookies = [9, 9, 9, 9, 9, 9, 9, 9],k = 4) == 18\n assert candidate(cookies = [1, 2, 4, 8, 16, 32, 64, 128],k = 5) == 128\n assert candidate(cookies = [10, 10, 10, 10, 10, 10, 10, 10],k = 7) == 20\n assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 4\n assert candidate(cookies = [18, 23, 45, 12, 34, 56, 78, 90],k = 3) == 123\n assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 6) == 800\n assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 4) == 900\n assert candidate(cookies = [8, 1, 5, 7, 3, 6, 4, 2],k = 3) == 12\n assert candidate(cookies = [9, 8, 7, 6, 5, 4, 3, 2],k = 6) == 9\n assert candidate(cookies = [16, 14, 12, 10, 8, 6, 4, 2],k = 4) == 18\n assert candidate(cookies = [5, 10, 15, 20, 25, 30, 35, 40],k = 5) == 40\n assert candidate(cookies = [5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 15\n assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 7) == 8\n assert candidate(cookies = [9, 18, 27, 36, 45, 54, 63, 72],k = 4) == 81\n assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1],k = 8) == 1\n assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 11\n assert candidate(cookies = [15, 14, 13, 12, 11, 10, 9, 8],k = 4) == 23\n assert candidate(cookies = [15, 25, 35, 45, 55, 65, 75, 85],k = 5) == 85\n assert candidate(cookies = [12, 11, 10, 9, 8, 7, 6, 5],k = 2) == 34\n assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1],k = 3) == 3\n assert candidate(cookies = [30, 20, 10, 10, 20, 30, 40, 50],k = 5) == 50\n assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 3) == 120\n assert candidate(cookies = [15, 15, 15, 15, 15, 15, 15, 15],k = 7) == 30\n assert candidate(cookies = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000],k = 8) == 8000\n assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1],k = 8) == 1\n assert candidate(cookies = [8, 16, 32, 64, 128, 256, 512, 1024],k = 2) == 1024\n assert candidate(cookies = [30, 20, 10, 60, 50, 40, 70, 80],k = 5) == 80\n assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 3) == 150\n assert candidate(cookies = [5, 10, 15, 20, 25, 30, 35, 40],k = 6) == 40\n assert candidate(cookies = [9, 3, 10, 12, 8, 15, 5, 7],k = 3) == 24\n assert candidate(cookies = [3, 1, 2, 4, 5, 6, 7, 8],k = 4) == 9\n assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 4) == 9\n assert candidate(cookies = [12, 17, 22, 14, 29, 18, 15, 20],k = 4) == 41\n assert candidate(cookies = [1, 2, 4, 8, 16, 32, 64, 128],k = 3) == 128\n assert candidate(cookies = [100, 100, 100, 100, 100, 100, 100, 100],k = 5) == 200\n assert candidate(cookies = [12, 23, 34, 45, 56, 67, 78, 89],k = 3) == 135\n assert candidate(cookies = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 4) == 200000\n assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 6) == 80\n assert candidate(cookies = [7, 8, 9, 10, 11, 12, 13, 14],k = 6) == 17\n assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 3) == 1200\n assert candidate(cookies = [8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 8\n assert candidate(cookies = [8, 15, 10, 20, 8, 5, 3, 7],k = 3) == 26\n assert candidate(cookies = [5, 15, 25, 35, 45, 55, 65, 75],k = 3) == 110\n assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 8) == 8\n assert candidate(cookies = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 8) == 10\n assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 4) == 900\n assert candidate(cookies = [15, 15, 15, 15, 15, 15, 15, 15],k = 6) == 30\n assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 5) == 800\n assert candidate(cookies = [2, 4, 6, 8, 10, 12, 14, 16],k = 3) == 24\n assert candidate(cookies = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000],k = 2) == 18000\n assert candidate(cookies = [50, 40, 30, 20, 10, 5, 3, 1],k = 4) == 50\n assert candidate(cookies = [5, 5, 15, 15, 25, 25, 35, 35],k = 4) == 40\n assert candidate(cookies = [15, 15, 15, 15, 15, 15, 15, 15],k = 2) == 60\n assert candidate(cookies = [2, 2, 2, 2, 2, 2, 2, 2],k = 7) == 4\n assert candidate(cookies = [25, 25, 25, 25, 25, 25, 25, 25],k = 8) == 25\n assert candidate(cookies = [8, 15, 10, 20, 8, 12, 15, 10],k = 3) == 33\n assert candidate(cookies = [8, 1, 2, 3, 4, 5, 6, 7],k = 2) == 18\n assert candidate(cookies = [10, 20, 10, 20, 10, 20, 10, 20],k = 4) == 30\n assert candidate(cookies = [50, 40, 30, 20, 10, 1, 2, 3],k = 3) == 53\n assert candidate(cookies = [1, 1, 2, 2, 3, 3, 4, 4],k = 4) == 5\n assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 8) == 8\n assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 4) == 34\n assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 4\n assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 3) == 12\n assert candidate(cookies = [10, 10, 20, 20, 30, 30, 40, 40],k = 4) == 50\n assert candidate(cookies = [9, 18, 27, 36, 45, 54, 63, 72],k = 4) == 81\n assert candidate(cookies = [8, 1, 2, 3, 4, 5, 6, 7],k = 8) == 8\n assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 7) == 800\n"}, "metadata": {"canonical_parameter_names": ["cookies", "k"], "leetcode_dataset_entry_point": "Solution().distributeCookies", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int distributeCookies(int[] cookies, int k) {", "container": "Solution", "callable": "distributeCookies", "parameters": [{"name": "cookies", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2306, "task_id": "naming-a-company", "difficulty": "Hard", "problem_description": "You are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company is as follows:\n\nChoose 2 distinct names from ideas, call them ideaA and ideaB.\nSwap the first letters of ideaA and ideaB with each other.\nIf both of the new names are not found in the original ideas, then the name ideaA ideaB (the concatenation of ideaA and ideaB, separated by a space) is a valid company name.\nOtherwise, it is not a valid name.\n\nReturn the number of distinct valid names for the company.\n \nExample 1:\n\nInput: ideas = [\"coffee\",\"donuts\",\"time\",\"toffee\"]\nOutput: 6\nExplanation: The following selections are valid:\n- (\"coffee\", \"donuts\"): The company name created is \"doffee conuts\".\n- (\"donuts\", \"coffee\"): The company name created is \"conuts doffee\".\n- (\"donuts\", \"time\"): The company name created is \"tonuts dime\".\n- (\"donuts\", \"toffee\"): The company name created is \"tonuts doffee\".\n- (\"time\", \"donuts\"): The company name created is \"dime tonuts\".\n- (\"toffee\", \"donuts\"): The company name created is \"doffee tonuts\".\nTherefore, there are a total of 6 distinct company names.\n\nThe following are some examples of invalid selections:\n- (\"coffee\", \"time\"): The name \"toffee\" formed after swapping already exists in the original array.\n- (\"time\", \"toffee\"): Both names are still the same after swapping and exist in the original array.\n- (\"coffee\", \"toffee\"): Both names formed after swapping already exist in the original array.\n\nExample 2:\n\nInput: ideas = [\"lack\",\"back\"]\nOutput: 0\nExplanation: There are no valid selections. Therefore, 0 is returned.\n\n \nConstraints:\n\n2 <= ideas.length <= 5 * 104\n1 <= ideas[i].length <= 10\nideas[i] consists of lowercase English letters.\nAll the strings in ideas are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(ideas = ['coffee', 'donuts', 'time', 'toffee']) == 6\n assert candidate(ideas = ['aaa', 'bbb', 'ccc']) == 6\n assert candidate(ideas = ['aaa', 'bbb', 'ccc', 'aab', 'abb', 'acc', 'baa', 'bab', 'bac', 'bba', 'bbb', 'bbc', 'caa', 'cab', 'cac', 'cba', 'cbb', 'cbc']) == 6\n assert candidate(ideas = ['abc', 'bcd', 'cde', 'dec']) == 12\n assert candidate(ideas = ['abcd', 'dcba', 'ddda', 'dccd']) == 6\n assert candidate(ideas = ['aaa', 'aab', 'aac', 'aba', 'abb', 'abc', 'aca', 'acb', 'acc', 'baa', 'bab', 'bac', 'bba', 'bbb', 'bbc', 'bca', 'bcb', 'bcc', 'caa', 'cab', 'cac', 'cba', 'cbb', 'cbc', 'cca', 'ccb', 'ccc']) == 0\n assert candidate(ideas = ['aaa', 'bbb', 'ccc', 'ddd']) == 12\n assert candidate(ideas = ['lack', 'back']) == 0\n assert candidate(ideas = ['aaa', 'bbb', 'ccc', 'aab', 'abb', 'abc']) == 10\n assert candidate(ideas = ['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']) == 0\n assert candidate(ideas = ['ana', 'anna', 'nana', 'ann', 'nan']) == 12\n assert candidate(ideas = ['aaa', 'baa', 'caa']) == 0\n assert candidate(ideas = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 0\n assert candidate(ideas = ['aaa', 'aab', 'aac', 'aba', 'abb', 'abc', 'aca', 'acb', 'acc']) == 0\n assert candidate(ideas = ['aa', 'bb', 'cc', 'ac', 'ba', 'ab', 'ad', 'da', 'bd', 'db']) == 10\n assert candidate(ideas = ['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', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', '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']) == 5552\n assert candidate(ideas = ['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', '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', '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', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 10002\n assert candidate(ideas = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf']) == 1548\n assert candidate(ideas = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'zxy', 'yxw', 'vuts', 'rqpm', 'nmlk', 'jihg', 'fedc', 'bac', 'xyz', 'wxyz', 'vwxy', 'uwxy', 'twxy', 'stxy', 'srxy', 'sqxy', 'spxy', 'soxy', 'snxy', 'smxy', 'slxy', 'skxy', 'sjxy', 'sixy', 'shxy', 'sgxy', 'sfxy', 'sexy', 'sdxy', 'scxy', 'sbxy', 'saxy', 'rzxy', 'ryxy', 'rxxy', 'rwxy', 'rvxy', 'ruxy', 'ruxy', 'ruxy', 'rsxy', 'rqxy', 'rpxy', 'roxy', 'rnx', 'rmxy', 'rlxy', 'rkxy', 'rjxy', 'rixy', 'rhxy', 'rgxy', 'rfxy', 'rex', 'rdxy', 'rcxy', 'rbxy', 'rax', 'qzxy', 'qxy', 'qxw', 'qvx', 'qux', 'qtx', 'qsx', 'qqx', 'qpx', 'qox', 'qnx', 'qmx', 'qlx', 'qkx', 'qjx', 'qix', 'qhx', 'qgx', 'qfx', 'qex', 'qdx', 'qcx', 'qbx', 'qax', 'pzxy', 'pyxy', 'pxy', 'pxw', 'pxv', 'pxu', 'pxt', 'pxs', 'pxq', 'pxp', 'pxo', 'pxn', 'pxm', 'pxl', 'pxk', 'pxj', 'pxi', 'pxh', 'pxg', 'pxf', 'pxe', 'pxd', 'pxc', 'pxb', 'pax', 'ozxy', 'oyxy', 'oxy', 'oxw', 'oxv', 'oxu', 'uxt', 'uxs', 'uxq', 'uxp', 'uxo', 'uxn', 'uxm', 'uxl', 'uxk', 'uxj', 'uxi', 'uxh', 'uxg', 'uxf', 'uxe', 'uxd', 'uxc', 'uxb', 'uxa', 'nzz', 'nzy', 'nxz', 'nxy', 'nxw', 'nxv', 'nxu', 'nxt', 'nxs', 'nxq', 'nxp', 'nxo', 'nxn', 'nxm', 'nxl', 'nxk', 'nxj', 'nxi', 'nxh', 'nxg', 'nxf', 'nxe', 'nxd', 'nxc', 'nxb', 'nxa']) == 17252\n assert candidate(ideas = ['xylophone', 'yoyo', 'xylography', 'xenon', 'xerox', 'yacht', 'yellow', 'yak', 'yeti', 'xenophobe', 'xerophyte', 'yodel', 'yxor', 'xyrrhuria', 'yxir', 'xylem', 'yxymphyta', 'xylophone', 'yxonic', 'xyranthus', 'yxist', 'yxiraphyllum', 'yxirion', 'yxirus', 'yxistophora', 'yxistophoric', 'yxistophorous', 'yxistotonic', 'yxistos', 'yxistus', 'yxistoscopy', 'yxistoscopy', 'yxistoscopy', 'yxistoscopy', 'yxistoscopy', 'yxistoscopy', 'yxistoscopy', 'yxistoscopy', 'yxistoscopy', 'yxistoscopy']) == 600\n assert candidate(ideas = ['cat', 'dog', 'cow', 'pig', 'hen', 'sheep', 'goat', 'duck', 'llama', 'alpaca', 'camel', 'horse', 'donkey', 'zebra', 'elephant', 'tiger', 'lion', 'leopard', 'cheetah', 'bear', 'panda', 'koala', 'kangaroo', 'wombat', 'raccoon', 'squirrel', 'chipmunk', 'beaver', 'porcupine', 'hedgehog', 'meerkat', 'baboon', 'gorilla', 'chimpanzee', 'orangutan', 'chinchilla', 'armadillo', 'quokka', 'tamandua', 'aardvark', 'anteater', 'koala', 'emu', 'kiwi', 'lyrebird', 'cassowary', 'kangaroo', 'numbat', 'platypus', 'kangaroo', 'kangaroo', 'kangaroo']) == 2478\n assert candidate(ideas = ['apple', 'apricot', 'banana', 'blackberry', 'blueberry', 'cherry', 'cranberry', 'cantaloupe', 'date', 'dragonfruit', 'elderberry', 'fig', 'grape', 'grapefruit', 'honeydew', 'kiwi', 'lemon', 'lime', 'mango', 'melon', 'nectarine', 'orange', 'papaya', 'peach', 'pear', 'plum', 'pomegranate', 'quince', 'raspberry', 'strawberry', 'tangerine', 'ugli', 'vanilla', 'watermelon', 'xigua', 'yellowberry', 'zucchini']) == 1290\n assert candidate(ideas = ['apple', 'apricot', 'banana', 'blueberry', 'blackberry', 'cherry', 'citrus', 'coconut', 'cranberry', 'grape', 'grapefruit', 'guava', 'kiwi', 'lemon', 'lime', 'mango', 'mangosteen', 'melon', 'nectarine', 'orange', 'papaya', 'peach', 'pear', 'pineapple', 'plum', 'pomegranate', 'raspberry', 'strawberry', 'tangerine', 'watermelon', 'zucchini']) == 866\n assert candidate(ideas = ['axx', 'bxx', 'cxx', 'dxx', 'exx', 'fxx', 'gxx', 'hxx', 'ixx', 'jxx', 'kxx', 'lxx', 'mxx', 'nxx', 'oxx', 'pxx', 'qxx', 'rxx', 'sxx', 'txx', 'uxx', 'vxx', 'wxx', 'xxx', 'yxx', 'zxx']) == 0\n assert candidate(ideas = ['abcd', 'abcf', 'abce', 'abdg', 'abcg', 'abde', 'abfh', 'abih', 'abif', 'abjg', 'abjh', 'abjf', 'abkh', 'abkf', 'abki', 'abkj', 'acde', 'acdf', 'aceg', 'acfh', 'acij', 'ackj', 'acdg', 'acdf', 'aceg', 'acfj', 'acih', 'acki', 'ackj', 'adef', 'adeg', 'adfg', 'adhj', 'adfi', 'adfk', 'adkj', 'acgh', 'adgh', 'adhj', 'adgk', 'adfk', 'adkj', 'afgh', 'afgj', 'afkj', 'aghi', 'aghj', 'agfk', 'agkj', 'agih', 'aghj', 'agfk', 'agkj', 'ahij', 'ahik', 'ahjk', 'aijk', 'bcdf', 'bcde', 'bcfg', 'bdgh', 'bdfi', 'bdfk', 'bdkj', 'bcgh', 'bdgh', 'bdgj', 'bdjk', 'bcfh', 'bcfg', 'bcij', 'bcjk', 'bdef', 'bdeg', 'bdfg', 'bdjk', 'bdfi', 'bdfk', 'bdkj', 'bgfh', 'bgfj', 'bgkj', 'bghi', 'bhij', 'bhik', 'bhjk', 'bijk', 'cdfg', 'cdef', 'cdgh', 'cdij', 'cgfh', 'cgfj', 'cgkj', 'cghi', 'chij', 'chik', 'chjk', 'cijk', 'defg', 'dfgh', 'dfij', 'dgjk', 'dfkj', 'dghj', 'dijk', 'egfh', 'egfj', 'egkj', 'eghi', 'ehij', 'ehik', 'ehjk', 'eijk', 'fghj', 'fgik', 'fgjk', 'fhij', 'fhik', 'fhjk', 'fijk', 'ghij', 'ghik', 'ghjk', 'gijk', 'hijk']) == 2454\n assert candidate(ideas = ['aardvarkaardvark', 'albatrossalbatross', 'alligatoralligator', 'anacondaanaconda', 'antant', 'antelopeantelope', 'anteateranteater', 'antlerantler', 'apricotapricot', 'armadilloarmadillo', 'baboonbaboon', 'badgerbadger', 'baldbald', 'bandicootbandicoot', 'barnaclebarnacle', 'batbat', 'bearbear', 'beaverbeaver', 'beebee', 'beetlebeetle', 'bisonbison', 'bluebirdbluebird', 'boaboa', 'bobcatbobcat', 'bobolinkbobolink', 'boobybooby', 'buffalobuffalo', 'bullbull', 'burroburr', 'buzzardbuzzard', 'camelcamel', 'canarycanary', 'capybaracapybara', 'cariboucaribou', 'catcat', 'caterpillarcaterpillar', 'cheetahcheetah', 'chickenchicken', 'chimpanzeechimpanzee', 'chinchillachinchilla', 'chipmunkchipmunk', 'civetcivet', 'coaticoati', 'cockatoocockatoo', 'codcod', 'condorcondor', 'congerconger', 'conycony', 'cootcoot', 'coralcoral', 'cougarcougar', 'cowcow', 'coyotecooyote', 'crabcrab', 'cranecrane', 'cricketcricket', 'crocodilecrocodile', 'crowcrow', 'curlewcurlew', 'deerdeer', 'dolphindolphin', 'donkeydonkey', 'dovedove', 'dragonflydragonfly', 'drakedrake', 'duckduck', 'dugongdugong', 'eagleeagle', 'earthwormearthworm', 'eeleeel', 'egretegret', 'elandeland', 'elephantelephant', 'elkelk', 'emuumu', 'falconfalcon', 'ferretferret', 'finchfinch', 'fishfish', 'flamingoflamingo', 'flyfly', 'flycatcherflycatcher', 'frogfrog', 'fossafossa', 'foxfox', 'frigatebirdfrigatebird', 'frogfrog', 'gazelligazelle', 'gatorgator', 'gaurgaur', 'gazelligazelle', 'geckogecko', 'gibbongibbon', 'gilagila', 'glideglide', 'gnomegnome', 'goatgoat', 'goldfinchgoldfinch', 'goosegoose', 'gorillagorilla', 'goshawkgoshawk', 'grasshoppergrasshopper', 'grousegrouse', 'guanguan', 'guineafowlguineafowl', 'gullgull', 'guppyguppy', 'haddockhaddock', 'halibuthalibut', 'hamsterhamster', 'harehare', 'harrierharrier', 'hawkhawk', 'hedgehoghedgehog', 'heronheron', 'herringherring', 'hippopotamushippopotamus', 'hornbillhornbill', 'horsehorse', 'houndhound', 'hyenahyena', 'ibisibis', 'iguanaiguana', 'impalaimpala', 'jackaljackal', 'jackrabbitjackrabbit', 'jaguajar', 'jayjay', 'jellyfishjellyfish', 'jerkbirdjerkbird', 'junglefowljunglefowl', 'kangarakangaroo', 'kangarakangaroo', 'katydidkatydid', 'kinkajoukinkajou', 'kipunjikipunji', 'koalakoala', 'komodokomodo', 'korimakokorimako', 'kookaburrakookaburra', 'koupreykouprey', 'krillkrill', 'kudukudu', 'labradorlabrador', 'lamlam', 'lampreylamprey', 'larvalarva', 'leechleech', 'lemurlemur', 'leopardleopard', 'lorikeetlorikeet', 'louselouse', 'louselouse', 'lynxlynx', 'macawmacaw', 'macaquemacaque', 'mackerelmackerel', 'maggotmaggot', 'magpimagpie', 'mandrillmandrill', 'manateemanatee', 'mantismantis', 'marlinmarlin', 'marmotmarmot', 'martenmarten', 'mastodonmastodon', 'mayflymayfly', 'meerkatmeerkat', 'minkmink', 'mockingbirdmockingbird', 'molomole', 'mongoosemongoose', 'moorhenmoorhen', 'moosemoose', 'mouflonmouflon', 'mulemule', 'muskratmuskrat', 'narwhalnarwhal', 'nighthawknighthawk', 'numbatnumbat', 'nyalanyla', 'octopusoctopus', 'okapiokapi', 'ollieollie', 'opossumopossum', 'orangutanorangutan', 'orioleoriole', 'oryxoryx', 'ospreyosprey', 'otterotter', 'owlowl', 'oxox', 'oysteroyster', 'oystercatcheroystercatcher', 'pademelonpademelon', 'pandapanda', 'pangolinpangolin', 'pantherpanther', 'parakeetparakeet', 'parrotparrot', 'partridgepartridge', 'peafowlpeafowl', 'pelicanpelican', 'penguinpenguin', 'pheasantpheasant', 'pigpig', 'pigeonpigeon', 'pikapika', 'pikepike', 'pinkpink', 'pit viperpit viper', 'platypusplatypus', 'polecatpolecat', 'polliwogpolliwog', 'ponypony', 'porcupineporcupine', 'porpoiseporpoise', 'prawnprawn', 'quaggaquagga', 'quailquail', 'quokkaquokka', 'quollquoll', 'rabbitrabbit', 'raccoonraccoon', 'racerracer', 'racketeerracketeer', 'raccoonraccoon', 'ramram', 'ratrat', 'ravenraven', 'rayray', 'reindeerreindeer', 'rhinocerosrhinoceros', 'roachroach', 'rodentrodent', 'rookrook', 'roosterrooster', 'rotiferrotifer', 'rouserouse', 'salmonsalmon', 'salamandersalamander', 'sallysally', 'sangriasangria', 'sand dollarsand dollar', 'sandpipersandpiper', 'sawsharksawshark', 'sawyersawyer', 'scallopscallop', 'scarab beetlescarab beetle', 'servalserval', 'seahorseseahorse', 'sealseal', 'sealionsealion', 'servalserval', 'sheepsheep', 'shrewhrew', 'shrikeshrike', 'shoebillshoebill', 'skimmerskimmer', 'skinkskink', 'skunkskunk', 'slothsloth', 'snailsnail', 'snakesnake', 'snipesnipe', 'spiderspider', 'spider monkeyspider monkey', 'squidsquid', 'squishsquish', 'squishsquish', 'squirrelsquirrel', 'starfishstarfish', 'stagstag', 'stingraystingray', 'storkstork', 'swallowswan', 'swanswan', 'swimmerswimmer', 'swordfishswordfish', 'tamarintamarin', 'tangtang', 'tarantulatarantula', 'tarsiertarsier', 'terntern', 'thripsthrips', 'thrushthrush', 'ticktick', 'tigertiger', 'timberwolftimberwolf', 'tinamoutinamou', 'toadtoad', 'toucantoucan', 'trapdoorspidertrapdoor spider', 'trogdotrogdor', 'trouttrout', 'tsetsetsetse', 'tunatuna', 'turkeyturkey', 'turtleturtle', 'tusktusk', 'tusktusk', 'vampire batvampire bat', 'vulturevulture', 'wallabywallaby', 'walruswalrus', 'warthogwarthog', 'waspwasp', 'water buffalowater buffalo', 'waterbuckwaterbuck', 'waterhenwaterhen', 'watershedwatershed', 'waterstriderwaterstrider', 'weaselweasel', 'wedge-tailed eaglewedge-tailed eagle', 'weevilweevil', 'wombatwombat', 'woodchuckwoodchuck', 'woodpeckerwoodpecker', 'wolverinewolverine', 'wombatwombat', 'wonderbirdwonderbird', 'wombatwombat', 'wormworm', 'wrenwren', 'xenonxenon', 'xerophytexerophyte', 'xylophonexylophone', 'yakyak', 'yarrowyarrow', 'yellowtailyellowtail', 'yolkyolk', 'youngsteryoungster', 'zebrazebra', 'zebuzebu', 'zorillazorilla']) == 105526\n assert candidate(ideas = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'axa', 'bxb', 'cxc', 'dxd', 'eye', 'fzf', 'gag', 'hah', 'ibi', 'jij', 'kjk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz']) == 2390\n assert candidate(ideas = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff', 'ggggg', 'hhhhh', 'iiiii', 'jjjjj', 'kkkkk', 'lllll', 'mmmmm', 'nnnnn', 'ooooo', 'ppppp', 'qqqqq', 'rrrrr', 'sssss', 'ttttt', 'uuuuu', 'vvvvv', 'wwwww', 'xxxxx', 'yyyyy', 'zzzzz', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd', 'efghi', 'jklmn', 'opqrs', 'tuvwx', 'yzabc', 'defgh', 'ijklm', 'nopqr', 'stuvw', 'xyzab', 'cdefg', 'ghijk', 'lmnop', 'qrstu', 'vwxyz', 'yzabc', 'defgh', 'ijklm', 'nopqr', 'stuvw', 'xyzab', 'cdefg', 'ghijk', 'lmnop', 'qrstu', 'vwxyz']) == 3220\n assert candidate(ideas = ['apple', 'apricot', 'banana', 'blueberry', 'blackberry', 'cherry', 'cranberry', 'cantaloupe', 'grape', 'grapefruit', 'kiwi', 'kiwano', 'lemon', 'lime', 'mango', 'mangosteen', 'nectarine', 'orange', 'papaya', 'peach', 'pear', 'plum', 'pluot', 'pomegranate', 'quince', 'raspberry', 'strawberry', 'tangerine', 'ugli', 'watermelon', 'xigua', 'yam', 'zucchini']) == 1004\n assert candidate(ideas = ['apple', 'apricot', 'banana', 'blueberry', 'cherry', 'cranberry', 'date', 'dragonfruit', 'elderberry', 'fig', 'grape', 'grapefruit', 'honeydew', 'kiwi', 'lemon', 'lime', 'mango', 'melon', 'nectarine', 'orange', 'papaya', 'peach', 'pear', 'pineapple', 'plum', 'pomegranate', 'raspberry', 'strawberry', 'tangerine', 'tangerine', 'ugli', 'vanilla', 'watermelon', 'xigua', 'yellowberry', 'zucchini']) == 1214\n assert candidate(ideas = ['aabb', 'abbb', 'acbb', 'adbb', 'aebb', 'afbb', 'agbb', 'ahbb', 'aibb', 'ajbb', 'akbb', 'albb', 'ambb', 'anbb', 'aobb', 'apbb', 'aqbb', 'arbb', 'asbb', 'atbb', 'aubb', 'avbb', 'awbb', 'axbb', 'aybb', 'azbb', 'baab', 'bbab', 'bcab', 'bdab', 'beab', 'bfab', 'bgab', 'bhab', 'biab', 'bjab', 'bkab', 'blab', 'bmba', 'bnab', 'boab', 'bpab', 'bqab', 'brab', 'bsab', 'btab', 'buab', 'bvab', 'bwab', 'bxab', 'byab', 'bzab', 'caab', 'cbab', 'ccab', 'cdba', 'ceab', 'cfab', 'cgab', 'chab', 'ciab', 'cjab', 'ckab', 'clab', 'cmba', 'cnab', 'coab', 'cpab', 'cqab', 'crab', 'csab', 'ctab', 'cuab', 'cvab', 'cwab', 'cxab', 'cyab', 'czab', 'daab', 'dbab', 'dcab', 'ddab', 'deab', 'dfab', 'dgab', 'dhab', 'diab', 'djab', 'dkab', 'dlab', 'dmab', 'dnab', 'doab', 'dpab', 'dqab', 'drab', 'dsab', 'dtab', 'duab', 'dvab', 'dwab', 'dxab', 'dyab', 'dzab', 'eaab', 'ebab', 'ecab', 'edab', 'eeab', 'efab', 'egab', 'ehab', 'eiab', 'ejab', 'ekab', 'elab', 'emab', 'enab', 'eoab', 'epab', 'eqab', 'erab', 'esab', 'etab', 'euab', 'evab', 'ewab', 'exab', 'eyab', 'ezab', 'faab', 'fbab', 'fcab', 'fdab', 'feab', 'ffab', 'fgab', 'fhab', 'fiab', 'fjab', 'fkab', 'flab', 'fmab', 'fnab', 'foab', 'fpab', 'fqab', 'frab', 'fsab', 'ftab', 'fuab', 'fvab', 'fwab', 'fxab', 'fyab', 'fzab']) == 6792\n assert candidate(ideas = ['aabb', 'abba', 'bbaa', 'baab', 'abab', 'baba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba', 'aaaa', 'bbbb', 'cccc', 'dddd', 'aabbcc', 'bbccaa', 'ccaabb', 'aabbaa', 'bbccbb', 'ccaaca']) == 1182\n assert candidate(ideas = ['aardvark', 'albatross', 'alligator', 'anaconda', 'ant', 'antelope', 'anteater', 'antler', 'apricot', 'armadillo', 'baboon', 'badger', 'bald', 'bandicoot', 'barnacle', 'bat', 'bear', 'beaver', 'bee', 'beetle', 'bison', 'bluebird', 'boa', 'bobcat', 'bobolink', 'booby', 'buffalo', 'bull', 'burro', 'buzzard', 'camel', 'canary', 'capybara', 'caribou', 'cat', 'caterpillar', 'cheetah', 'chicken', 'chimpanzee', 'chinchilla', 'chipmunk', 'civet', 'coati', 'cockatoo', 'cod', 'condor', 'conger', 'cony', 'coot', 'coral', 'cougar', 'cow', 'coyote', 'crab', 'crane', 'cricket', 'crocodile', 'crow', 'curlew', 'deer', 'dolphin', 'donkey', 'dove', 'dragonfly', 'drake', 'duck', 'dugong', 'eagle', 'earthworm', 'eel', 'egret', 'eland', 'elephant', 'elk', 'emu', 'falcon', 'ferret', 'finch', 'fish', 'flamingo', 'fly', 'flycatcher', 'frog', 'fossa', 'fox', 'frigatebird', 'frog', 'gazelle', 'gator', 'gaur', 'gazelle', 'gecko', 'gibbon', 'gila', 'glide', 'gnome', 'goat', 'goldfinch', 'goose', 'gorilla', 'goshawk', 'grasshopper', 'grouse', 'guan', 'guineafowl', 'gull', 'guppy', 'haddock', 'halibut', 'hamster', 'hare', 'harrier', 'hawk', 'hedgehog', 'heron', 'herring', 'hippopotamus', 'hornbill', 'horse', 'hound', 'hyena', 'ibis', 'iguana', 'impala', 'jackal', 'jackrabbit', 'jaguar', 'jay', 'jellyfish', 'jerkbird', 'junglefowl', 'kangaroo', 'kangaroo', 'katydid', 'kinkajou', 'kipunji', 'koala', 'komodo', 'korimako', 'kookaburra', 'kouprey', 'krill', 'kudu', 'labrador', 'lamb', 'lamprey', 'larva', 'leech', 'lemur', 'leopard', 'lorikeet', 'louse', 'louse', 'lynx', 'macaw', 'macaque', 'mackerel', 'maggot', 'magpie', 'mandrill', 'manatee', 'mantis', 'marlin', 'marmot', 'marten', 'mastodon', 'mayfly', 'meerkat', 'mink', 'mockingbird', 'mole', 'mongoose', 'moorhen', 'moose', 'mouflon', 'mule', 'muskrat', 'narwhal', 'nighthawk', 'numbat', 'nyala', 'octopus', 'okapi', 'ollie', 'opossum', 'orangutan', 'oriole', 'oryx', 'osprey', 'otter', 'owl', 'ox', 'oyster', 'oystercatcher', 'pademelon', 'panda', 'pangolin', 'panther', 'parakeet', 'parrot', 'partridge', 'peafowl', 'pelican', 'penguin', 'pheasant', 'pig', 'pigeon', 'pika', 'pike', 'pika', 'pink', 'pit viper', 'platypus', 'polecat', 'polliwog', 'pony', 'porcupine', 'porpoise', 'prawn', 'quagga', 'quail', 'quokka', 'quoll', 'rabbit', 'raccoon', 'racer', 'racketeer', 'raccoon', 'ram', 'rat', 'raven', 'ray', 'reindeer', 'rhinoceros', 'roach', 'rodent', 'rook', 'rooster', 'rotifer', 'rouse', 'salmon', 'salamander', 'sally', 'sangria', 'sand dollar', 'sandpiper', 'sawshark', 'sawyer', 'scallop', 'scarab beetle', 'serval', 'seahorse', 'seagull', 'seal', 'sealion', 'serval', 'sheep', 'shrew', 'shrike', 'shoebill', 'skimmer', 'skink', 'skunk', 'sloth', 'snail', 'snake', 'snipe', 'spider', 'spider monkey', 'squid', 'squish', 'squish', 'squirrel', 'starfish', 'stag', 'stingray', 'stork', 'swallow', 'swan', 'swimmer', 'swordfish', 'tamarin', 'tang', 'tarantula', 'tarsier', 'tern', 'thrips', 'thrush', 'tick', 'tiger', 'timberwolf', 'tinamou', 'toad', 'toucan', 'trapdoor spider', 'trogdor', 'trout', 'tsetse', 'tuna', 'turkey', 'turtle', 'tusk', 'tusk', 'vampire bat', 'vulture', 'wallaby', 'walrus', 'warthog', 'wasp', 'water buffalo', 'waterbuck', 'waterhen', 'watershed', 'waterstrider', 'weasel', 'wedge-tailed eagle', 'weevil', 'wombat', 'woodchuck', 'woodpecker', 'wolverine', 'wombat', 'wonderbird', 'wombat', 'worm', 'wren', 'xenon', 'xerophyte', 'xylophone', 'yak', 'yarrow', 'yellowtail', 'yolk', 'youngster', 'zebra', 'zebu', 'zorilla']) == 105944\n assert candidate(ideas = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn', 'klmno', 'lmnop', 'mnopq', 'nopqr', 'opqrs', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvw', 'vwxy', 'wxyz', 'xyz', 'yz', 'z', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba']) == 804\n assert candidate(ideas = ['a1', 'a2', 'a3', 'b1', 'b2', 'b3', 'c1', 'c2', 'c3', 'd1', 'd2', 'd3', 'e1', 'e2', 'e3', 'f1', 'f2', 'f3', 'g1', 'g2', 'g3', 'h1', 'h2', 'h3', 'i1', 'i2', 'i3', 'j1', 'j2', 'j3', 'k1', 'k2', 'k3', 'l1', 'l2', 'l3', 'm1', 'm2', 'm3', 'n1', 'n2', 'n3', 'o1', 'o2', 'o3', 'p1', 'p2', 'p3', 'q1', 'q2', 'q3', 'r1', 'r2', 'r3', 's1', 's2', 's3', 't1', 't2', 't3', 'u1', 'u2', 'u3', 'v1', 'v2', 'v3', 'w1', 'w2', 'w3', 'x1', 'x2', 'x3', 'y1', 'y2', 'y3', 'z1', 'z2', 'z3']) == 0\n assert candidate(ideas = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd', 'efghi', 'jklmn', 'opqrs', 'tuvwx', 'yzabc', 'defgh', 'ijklm', 'nopqr', 'stuvw', 'xyzab', 'cdefg', 'hijkl', 'mnopq', 'rstuv', 'wxyza', 'yzabc', 'ghijk', 'lmnop', 'qrstu', 'vwxyz', 'zabca', 'bcdef', 'ghjkl', 'mnopr', 'stuvw', 'xyza', 'yzabc', 'hijkl', 'lmnop', 'qrstv', 'wxyz', 'yzabc', 'ijklm', 'nopqr', 'rstuw', 'xyz', 'yzabc', 'jklmn', 'opqrs', 'tuvwx', 'yz', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd']) == 2678\n assert candidate(ideas = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zyxwv', 'tsrqp', 'onmlk', 'jihgf', 'edcba', 'vwxyz', 'utsrq', 'ponml', 'lkjih', 'gfedc', 'dcbae', 'yxwvz', 'srqpo', 'nmlkj', 'ihgfe', 'badce', 'fgihj', 'lkmon', 'pqors', 'twuvx', 'zyxwv', 'tsrqp', 'onmlk', 'jihgf', 'edcba', 'vwxyz', 'utsrq', 'ponml', 'lkjih', 'gfedc', 'dcbae', 'yxwvz', 'srqpo', 'nmlkj', 'ihgfe', 'bacde', 'fgihj', 'lkmon', 'pqors', 'twuvx']) == 1900\n assert candidate(ideas = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff', 'ggggg', 'hhhhh', 'iiiii', 'jjjjj', 'kkkkk', 'lllll', 'mmmmm', 'nnnnn', 'ooooo', 'ppppp', 'qqqqq', 'rrrrr', 'sssss', 'ttttt', 'uuuuu', 'vvvvv', 'wwwww', 'xxxxx', 'yyyyy', 'zzzzz', 'aabcd', 'abccd', 'abccf', 'abcce', 'abccg', 'abcch', 'abcci', 'abccj', 'abckk', 'abcll', 'abcmn', 'abcdm', 'abcdn', 'abcdo', 'abcdp', 'abcdq', 'abcds', 'abcdt', 'abcdv', 'abcdw', 'abcdx', 'abcdy', 'abcdz', 'abcea', 'abceb', 'abcec', 'abced', 'abcee', 'abcef', 'abceg', 'abceh', 'abcei', 'abcej', 'abcek', 'abcel', 'abcem', 'abcen', 'abceo', 'abcep', 'abceq', 'abces', 'abceu', 'abcev', 'abcew', 'abcex', 'abcey', 'abcez', 'abcfb', 'abcfb', 'abcfb', 'abcfc', 'abcfb', 'abcfb', 'abcfd', 'abcfe', 'abcfh', 'abcfi', 'abcfj', 'abcfk', 'abclf', 'abcfm', 'abcfn', 'abcfo', 'abcfp', 'abcfq', 'abcfz', 'abcga', 'abcgb', 'abcgc', 'abcgd', 'abcge', 'abcgf', 'abcgg', 'abcgh', 'abcgi', 'abcgj', 'abcgk', 'abcgl', 'abcgm', 'abcgn', 'abcgo', 'abcgp', 'abcgq', 'abcgr', 'abcgs', 'abcgt', 'abcgu', 'abcgv', 'abcgw', 'abcgx', 'abcgy', 'abcgz', 'abcra', 'abcrb', 'abcrc', 'abcrd', 'abcre', 'abcrf', 'abcrg', 'abcrh', 'abcri', 'abcrj', 'abcrk', 'abctrl', 'abcrm', 'abcrn', 'abcro', 'abcrp', 'abcrq', 'abcrs', 'abqrt', 'abcrv', 'abcrw', 'abcrx', 'abcry', 'abcraz', 'abcsea', 'abcseb', 'abcsec', 'abcdse', 'abcsef', 'abcseg', 'abcseh', 'abcsei', 'abcsej', 'abcsek', 'abcseb', 'abcsem', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb', 'abcseb']) == 8450\n assert candidate(ideas = ['aaa', 'aab', 'aac', 'aba', 'abb', 'abc', 'aca', 'acb', 'acc', 'baa', 'bab', 'bac', 'bba', 'bbb', 'bbc', 'bca', 'bcb', 'bcc', 'caa', 'cab', 'cac', 'cba', 'cbb', 'cbc', 'cca', 'ccb', 'ccc', 'ddd', 'dee', 'def', 'deg', 'dih', 'dii', 'dij', 'dka', 'dkb', 'dkc', 'dla', 'dlb', 'dlc', 'dma', 'dmb', 'dmc', 'dna', 'dnb', 'dnc', 'doa', 'dob', 'doc', 'doea', 'doeb', 'doec', 'dofa', 'dobf', 'docf']) == 1512\n assert candidate(ideas = ['aabc', 'abac', 'abbc', 'acbc', 'adbc', 'aebc', 'afbc', 'agbc', 'ahbc', 'aibc', 'ajbc', 'akbc', 'albc', 'ambc', 'anbc', 'aobc', 'apbc', 'aqbc', 'arbc', 'asbc', 'atbc', 'aubc', 'avbc', 'awbc', 'axbc', 'aybc', 'azbc', 'baaa', 'baab', 'baac', 'baad', 'baae', 'baaf', 'baag', 'baah', 'baai', 'baaj', 'baak', 'baal', 'baam', 'baan', 'baao', 'baap', 'baaq', 'baar', 'baas', 'baat', 'baau', 'baav', 'baaw', 'baax', 'baay', 'baaz']) == 1404\n assert candidate(ideas = ['apple', 'apricot', 'banana', 'blueberry', 'cherry', 'cranberry', 'grape', 'guava', 'kiwi', 'lemon', 'lime', 'mango', 'melon', 'orange', 'papaya', 'peach', 'pear', 'plum', 'raspberry', 'strawberry', 'tangerine', 'watermelon']) == 438\n assert candidate(ideas = ['apple', 'apricot', 'banana', 'cherry', 'citrus', 'date', 'elderberry', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'lime', 'mango', 'nectarine', 'orange', 'papaya', 'peach', 'pear', 'persimmon', 'plum', 'pomegranate', 'quince', 'raspberry', 'strawberry', 'tangerine', 'ugli', 'vanilla', 'watermelon', 'xigua', 'yam', 'zucchini']) == 956\n assert candidate(ideas = ['aardvark', 'alligator', 'anteater', 'antelope', 'baboon', 'badger', 'bat', 'bear', 'beaver', 'bison', 'boar', 'buffalo', 'camel', 'canary', 'capybara', 'caribou', 'cat', 'cheetah', 'chimpanzee', 'chinchilla', 'chipmunk', 'clam', 'cobra', 'condor', 'coyote', 'crane', 'crocodile', 'crow', 'deer', 'dingo', 'dolphin', 'donkey', 'dove', 'dragonfly', 'duck', 'eagle', 'eel', 'elephant', 'elk', 'emu', 'falcon', 'ferret', 'finch', 'fish', 'flamingo', 'fly', 'fox', 'frog', 'gazelle', 'gecko', 'giraffe', 'goat', 'goose', 'gorilla', 'grizzly', 'groundhog', 'guinea', 'gull', 'hamster', 'hare', 'hawk', 'hedgehog', 'heron', 'hippopotamus', 'hornbill', 'horse', 'hyena', 'ibis', 'iguana', 'impala', 'jackal', 'jaguar', 'jay', 'jellyfish', 'kangaroo', 'kangaroo', 'koala', 'kookaburra', 'kouprey', 'kudu', 'leopard', 'lemur', 'leopard', 'lion', 'lizard', 'llama', 'lobster', 'locust', 'lory', 'lynx', 'macaw', 'meerkat', 'megalodon', 'mink', 'mole', 'mongoose', 'monkey', 'moose', 'mouse', 'mule', 'muskrat', 'narwhal', 'newt', 'orangutan', 'ostrich', 'otter', 'owl', 'ox', 'oyster', 'panda', 'panther', 'parrot', 'peacock', 'pelican', 'penguin', 'pheasant', 'pig', 'platypus', 'polarbear', 'porcupine', 'porpoise', 'prairie', 'puffin', 'puma', 'quagga', 'quail', 'quelea', 'quetzal', 'quokka', 'quoll', 'rabbit', 'raccoon', 'ram', 'raven', 'reindeer', 'rhinoceros', 'roadrunner', 'robin', 'rooster', 'salamander', 'sardine', 'scorpion', 'seagull', 'seahorse', 'seal', 'shark', 'sheep', 'shrew', 'skunk', 'sloth', 'snail', 'snake', 'sparrow', 'spider', 'squid', 'squirrel', 'starfish', 'stingray', 'stork', 'swan', 'swimmer', 'toucan', 'turtle', 'vulture', 'wallaby', 'walrus', 'wasp', 'weasel', 'weaver', 'whale', 'wolf', 'wolverine', 'wombat', 'woodpecker', 'wolverine', 'xerus', 'xiphias', 'yak', 'yeasty', 'zebra']) == 30306\n assert candidate(ideas = ['aabbcc', 'bbccdd', 'ccddeeff', 'ddeeffgg', 'eeffgghh', 'ffgghhii', 'gghhiijj', 'hhiijjkk', 'iijjkkll', 'jjkkllmm', 'kkllmmnn', 'llmmnnoo', 'mmnnooppee', 'nnooppeeff', 'ooppffgg', 'ppffgghh', 'ffgghhii', 'gghhiijj', 'hhiijjkk', 'iijjkkll', 'jjkkllmm', 'kkllmmnn', 'llmmnnoo', 'mmnnooppee', 'nnooppeeff', 'ooppffgg', 'ppffgghh', 'abcdefgh', 'ijklmnop', 'qrstuvwxyz', 'zyxwvutsrq', 'ponmlkjihg', 'fedcbazyxw', 'vutsrqponm', 'lkjihgfedc', 'bacazyxwvu', 'tsrqponmlk', 'jihgfedcba']) == 1360\n assert candidate(ideas = ['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', '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', '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', 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff', 'ggggg', 'hhhhh', 'iiiii', 'jjjjj', 'kkkkk', 'lllll', 'mmmmm', 'nnnnn', 'ooooo', 'ppppp', 'qqqqq', 'rrrrr', 'sssss', 'ttttt', 'uuuuu', 'vvvvv', 'wwwww', 'xxxxx', 'yyyyy', 'zzzzz']) == 10400\n"}, "metadata": {"canonical_parameter_names": ["ideas"], "leetcode_dataset_entry_point": "Solution().distinctNames", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long distinctNames(String[] ideas) {", "container": "Solution", "callable": "distinctNames", "parameters": [{"name": "ideas", "type": "String[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2309, "task_id": "greatest-english-letter-in-upper-and-lower-case", "difficulty": "Easy", "problem_description": "Given a string of English letters s, return the greatest English letter which occurs as both a lowercase and uppercase letter in s. The returned letter should be in uppercase. If no such letter exists, return an empty string.\nAn English letter b is greater than another letter a if b appears after a in the English alphabet.\n \nExample 1:\n\nInput: s = \"lEeTcOdE\"\nOutput: \"E\"\nExplanation:\nThe letter 'E' is the only letter to appear in both lower and upper case.\n\nExample 2:\n\nInput: s = \"arRAzFif\"\nOutput: \"R\"\nExplanation:\nThe letter 'R' is the greatest letter to appear in both lower and upper case.\nNote that 'A' and 'F' also appear in both lower and upper case, but 'R' is greater than 'F' or 'A'.\n\nExample 3:\n\nInput: s = \"AbCdEfGhIjK\"\nOutput: \"\"\nExplanation:\nThere is no letter that appears in both lower and upper case.\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns consists of lowercase and uppercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n assert candidate(s = \"mMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n assert candidate(s = \"zZyYxXwWeE\") == \"Z\"\n assert candidate(s = \"zZyYxXwWvVuUtTrRsSqQpPoOnNmMlLkKiIjJhHgGfFeEdDcCbBaA\") == \"Z\"\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\") == \"Y\"\n assert candidate(s = \"alluppercase\") == \"\"\n assert candidate(s = \"ALLLOWERCASE\") == \"\"\n assert candidate(s = \"aBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n assert candidate(s = \"AbCdEfGhIjK\") == \"\"\n assert candidate(s = \"a\") == \"\"\n assert candidate(s = \"NoUpperCaseHere\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"Z\"\n assert candidate(s = \"bA\") == \"\"\n assert candidate(s = \"AbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n assert candidate(s = \"NnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n assert candidate(s = \"lEeTcOdE\") == \"E\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"\") == \"\"\n assert candidate(s = \"arRAzFif\") == \"R\"\n assert candidate(s = \"abcdefgHIJKLMnoPQRSTuVwxyz\") == \"\"\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == \"\"\n assert candidate(s = \"aA\") == \"A\"\n assert candidate(s = \"A\") == \"\"\n assert candidate(s = \"AaBbCc\") == \"C\"\n assert candidate(s = \"zZ\") == \"Z\"\n assert candidate(s = \"MmQqEe\") == \"Q\"\n assert candidate(s = \"aB\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n assert candidate(s = \"qUICkBrOwNBROWNfOX\") == \"W\"\n assert candidate(s = \"pUrPLe\") == \"P\"\n assert candidate(s = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa\") == \"Z\"\n assert candidate(s = \"aBcD\") == \"\"\n assert candidate(s = \"bLuE\") == \"\"\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"\"\n assert candidate(s = \"xYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwW\") == \"Z\"\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n assert candidate(s = \"bAcBdCeCdFdEgFhG\") == \"G\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"Z\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaAaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n assert candidate(s = \"hYsS\") == \"S\"\n assert candidate(s = \"thisIsAtEsTString\") == \"T\"\n assert candidate(s = \"xyzXYZuvwUVWtTqsSRpqPRonmNMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"Z\"\n assert candidate(s = \"AaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == \"A\"\n assert candidate(s = \"aAaaAAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"A\"\n assert candidate(s = \"noUpperLower\") == \"\"\n assert candidate(s = \"UnIqUe\") == \"\"\n assert candidate(s = \"mAgEnTa\") == \"A\"\n assert candidate(s = \"aAaAaAaAaAaA\") == \"A\"\n assert candidate(s = \"AaaaBBbbbCCCCDDDdeeeFFGHHHIIIJJJ\") == \"D\"\n assert candidate(s = \"xyzABCxyzABC\") == \"\"\n assert candidate(s = \"aNdSoMeSpEcIaLChArAcTeRs\") == \"S\"\n assert candidate(s = \"withSomeDuPpLicaTeS\") == \"T\"\n assert candidate(s = \"bBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBb\") == \"B\"\n assert candidate(s = \"mNnOoPpQqRrSsTtUuVvWwXxYyZzLlKkJjIiHhGgFfEeDdCcBbAa\") == \"Z\"\n assert candidate(s = \"abcdefghiJklmnopqrStuvWxyzZ\") == \"Z\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n assert candidate(s = \"abcdefGHIJKLmnopQRStuvWXYZ\") == \"\"\n assert candidate(s = \"mMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlL\") == \"Z\"\n assert candidate(s = \"aBcDdEfGgHiJjKlMmNoPpQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n assert candidate(s = \"gRaY\") == \"\"\n assert candidate(s = \"butNoVaLiDgReaTtEsT\") == \"T\"\n assert candidate(s = \"mIXeDuPpLeTeXt\") == \"T\"\n assert candidate(s = \"nNoOlLkKiIjJhHgGfFeEdDcCbBaA\") == \"O\"\n assert candidate(s = \"cYaN\") == \"\"\n assert candidate(s = \"sUpErCoMpLeXtExT\") == \"X\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzZ\") == \"Z\"\n assert candidate(s = \"mIxEdCaSeStRiNg\") == \"I\"\n assert candidate(s = \"MmLlKkJjIiHhGgFfEeDdCcBbAa\") == \"M\"\n assert candidate(s = \"abcdefgHIJKLmnopqRSTUVWxyz\") == \"\"\n assert candidate(s = \"mM\") == \"M\"\n assert candidate(s = \"AbcDefGhIjKlMnopQRStuvWXYZ\") == \"\"\n assert candidate(s = \"ZZZaaaBBBcccDDDeeeFFFgggHHHiiiJJJkkkLLLmmmNNNoooPPPqqqRRRsssTTTuuuVVVwwwXXXyyyzzz\") == \"Z\"\n assert candidate(s = \"tEsTiNgUpPeRaNdLoWeRcAsE\") == \"T\"\n assert candidate(s = \"sUnShInESoNnY\") == \"S\"\n assert candidate(s = \"xYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxY\") == \"\"\n assert candidate(s = \"mNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"Z\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789\") == \"Z\"\n assert candidate(s = \"zZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\") == \"Z\"\n assert candidate(s = \"aNkLmNpQrStUvWxYzZ\") == \"Z\"\n assert candidate(s = \"sTrInGtEsTcAsE\") == \"T\"\n assert candidate(s = \"aAaAaAbBbBcCcCdDdDeEeEfFfFgGgGhHhHiIiIjJjJkKkKlLlLmMmMnNnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"Z\"\n assert candidate(s = \"gReEn\") == \"E\"\n assert candidate(s = \"mnopQRstUVwXYZ\") == \"\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n assert candidate(s = \"mnopqrStuvWxyzZ\") == \"Z\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"Z\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"A\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaA\") == \"A\"\n assert candidate(s = \"abcdefghijkLmnopqrstUvwxyz\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n assert candidate(s = \"aNnBmMlLkKiIjJhHgGfFeEdDcCbBaA\") == \"N\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmooppqqrrssttuuvvwwxxyyzz\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"\"\n assert candidate(s = \"aBcDxyzXYZaBcD\") == \"Z\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n assert candidate(s = \"fUnNyCaSe\") == \"N\"\n assert candidate(s = \"oRaNgE\") == \"\"\n assert candidate(s = \"aBcDfEgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"xyZzXyZzXyZzXyZzXyZzXyZzXyZzXyZzXyZz\") == \"Z\"\n assert candidate(s = \"bAcAdAeAfAgAhAiAjAkAlAmAnAoApAqArAsAtAuAvAwAxAyAz\") == \"\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"A\"\n assert candidate(s = \"qQwWeErRtTyYuUiIoOpPlLkKjJhHgGfFdDsSaAzZ\") == \"Z\"\n assert candidate(s = \"xyzXYZabcABCdefDEFghiGHIjklJKLmnopMNOpqrQRstSTuvwUVWxyzXYZ\") == \"Z\"\n assert candidate(s = \"MiXeDcAsEnOnCaSeTeStStRiNg\") == \"T\"\n assert candidate(s = \"jUmBlEdTeXt\") == \"T\"\n assert candidate(s = \"aBcDefGHiJkLmNoPqRsTuVwXyZZzz\") == \"Z\"\n assert candidate(s = \"aAeEiIoOuUaAeEiIoOuUaAeEiIoOuU\") == \"U\"\n assert candidate(s = \"abCDxyzXYZ\") == \"Z\"\n assert candidate(s = \"oNeTwOThReEfOuRfIvEsIxTEnElEvEnTiGoNeVeNtWeNtYtHrEe\") == \"W\"\n assert candidate(s = \"mAgIc\") == \"\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"Z\"\n assert candidate(s = \"ABCDEFGhijklmNopqrStuvWxyz\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().greatestLetter", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String greatestLetter(String s) {", "container": "Solution", "callable": "greatestLetter", "parameters": [{"name": "s", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2310, "task_id": "sum-of-numbers-with-units-digit-k", "difficulty": "Medium", "problem_description": "Given two integers num and k, consider a set of positive integers with the following properties:\n\nThe units digit of each integer is k.\nThe sum of the integers is num.\n\nReturn the minimum possible size of such a set, or -1 if no such set exists.\nNote:\n\nThe set can contain multiple instances of the same integer, and the sum of an empty set is considered 0.\nThe units digit of a number is the rightmost digit of the number.\n\n \nExample 1:\n\nInput: num = 58, k = 9\nOutput: 2\nExplanation:\nOne valid set is [9,49], as the sum is 58 and each integer has a units digit of 9.\nAnother valid set is [19,39].\nIt can be shown that 2 is the minimum possible size of a valid set.\n\nExample 2:\n\nInput: num = 37, k = 2\nOutput: -1\nExplanation: It is not possible to obtain a sum of 37 using only integers that have a units digit of 2.\n\nExample 3:\n\nInput: num = 0, k = 7\nOutput: 0\nExplanation: The sum of an empty set is considered 0.\n\n \nConstraints:\n\n0 <= num <= 3000\n0 <= k <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 25,k = 5) == 1\n assert candidate(num = 2023,k = 3) == 1\n assert candidate(num = 37,k = 2) == -1\n assert candidate(num = 100,k = 0) == 1\n assert candidate(num = 58,k = 9) == 2\n assert candidate(num = 99,k = 9) == 1\n assert candidate(num = 15,k = 3) == 5\n assert candidate(num = 27,k = 9) == 3\n assert candidate(num = 888,k = 8) == 1\n assert candidate(num = 0,k = 7) == 0\n assert candidate(num = 100,k = 1) == 10\n assert candidate(num = 88,k = 8) == 1\n assert candidate(num = 20,k = 5) == 2\n assert candidate(num = 45,k = 5) == 1\n assert candidate(num = 1,k = 1) == 1\n assert candidate(num = 999,k = 9) == 1\n assert candidate(num = 100,k = 3) == 10\n assert candidate(num = 9,k = 9) == 1\n assert candidate(num = 10,k = 0) == 1\n assert candidate(num = 100,k = 9) == 10\n assert candidate(num = 666,k = 6) == 1\n assert candidate(num = 345,k = 4) == -1\n assert candidate(num = 1000,k = 5) == 2\n assert candidate(num = 123,k = 3) == 1\n assert candidate(num = 2997,k = 7) == 1\n assert candidate(num = 2999,k = 9) == 1\n assert candidate(num = 275,k = 5) == 1\n assert candidate(num = 3000,k = 1) == 10\n assert candidate(num = 222,k = 2) == 1\n assert candidate(num = 210,k = 1) == 10\n assert candidate(num = 256,k = 7) == 8\n assert candidate(num = 1995,k = 5) == 1\n assert candidate(num = 900,k = 0) == 1\n assert candidate(num = 456,k = 4) == 4\n assert candidate(num = 256,k = 8) == 2\n assert candidate(num = 789,k = 9) == 1\n assert candidate(num = 21,k = 1) == 1\n assert candidate(num = 202,k = 2) == 1\n assert candidate(num = 333,k = 3) == 1\n assert candidate(num = 150,k = 5) == 2\n assert candidate(num = 123,k = 8) == -1\n assert candidate(num = 2500,k = 5) == 2\n assert candidate(num = 400,k = 6) == 5\n assert candidate(num = 7531,k = 3) == 7\n assert candidate(num = 1234,k = 8) == 3\n assert candidate(num = 777,k = 1) == 7\n assert candidate(num = 234,k = 5) == -1\n assert candidate(num = 3000,k = 9) == 10\n assert candidate(num = 2345,k = 4) == -1\n assert candidate(num = 678,k = 8) == 1\n assert candidate(num = 999,k = 3) == 3\n assert candidate(num = 145,k = 6) == -1\n assert candidate(num = 56,k = 0) == -1\n assert candidate(num = 777,k = 7) == 1\n assert candidate(num = 2999,k = 3) == 3\n assert candidate(num = 1200,k = 0) == 1\n assert candidate(num = 567,k = 2) == -1\n assert candidate(num = 444,k = 4) == 1\n assert candidate(num = 54321,k = 1) == 1\n assert candidate(num = 50,k = 5) == 2\n assert candidate(num = 8642,k = 2) == 1\n assert candidate(num = 999,k = 1) == 9\n assert candidate(num = 256,k = 6) == 1\n assert candidate(num = 189,k = 9) == 1\n assert candidate(num = 555,k = 5) == 1\n assert candidate(num = 111,k = 1) == 1\n assert candidate(num = 450,k = 5) == 2\n assert candidate(num = 13579,k = 9) == 1\n assert candidate(num = 0,k = 0) == 0\n assert candidate(num = 299,k = 9) == 1\n assert candidate(num = 250,k = 7) == 10\n assert candidate(num = 768,k = 4) == 2\n assert candidate(num = 1985,k = 5) == 1\n assert candidate(num = 1500,k = 0) == 1\n assert candidate(num = 3000,k = 5) == 2\n assert candidate(num = 2875,k = 7) == 5\n assert candidate(num = 158,k = 8) == 1\n assert candidate(num = 99,k = 2) == -1\n assert candidate(num = 1234,k = 4) == 1\n assert candidate(num = 234,k = 4) == 1\n assert candidate(num = 111,k = 2) == -1\n assert candidate(num = 101,k = 1) == 1\n assert candidate(num = 3000,k = 0) == 1\n assert candidate(num = 143,k = 3) == 1\n assert candidate(num = 800,k = 2) == 5\n assert candidate(num = 1024,k = 3) == 8\n assert candidate(num = 303,k = 3) == 1\n assert candidate(num = 888,k = 2) == 4\n assert candidate(num = 500,k = 5) == 2\n assert candidate(num = 123,k = 4) == -1\n assert candidate(num = 1234,k = 7) == 2\n assert candidate(num = 1000,k = 1) == 10\n assert candidate(num = 75,k = 5) == 1\n assert candidate(num = 1999,k = 9) == 1\n assert candidate(num = 243,k = 7) == 9\n assert candidate(num = 1998,k = 8) == 1\n assert candidate(num = 246,k = 7) == 8\n assert candidate(num = 135,k = 5) == 1\n assert candidate(num = 676,k = 6) == 1\n assert candidate(num = 123,k = 1) == 3\n assert candidate(num = 9999,k = 9) == 1\n assert candidate(num = 150,k = 1) == 10\n assert candidate(num = 2500,k = 0) == 1\n assert candidate(num = 2345,k = 9) == 5\n assert candidate(num = 5,k = 0) == -1\n assert candidate(num = 999,k = 5) == -1\n assert candidate(num = 250,k = 5) == 2\n assert candidate(num = 147,k = 6) == -1\n assert candidate(num = 199,k = 9) == 1\n assert candidate(num = 1000,k = 0) == 1\n assert candidate(num = 2468,k = 8) == 1\n assert candidate(num = 2024,k = 4) == 1\n assert candidate(num = 234,k = 3) == 8\n assert candidate(num = 1111,k = 1) == 1\n"}, "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().minimumNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumNumbers(int num, int k) {", "container": "Solution", "callable": "minimumNumbers", "parameters": [{"name": "num", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2311, "task_id": "longest-binary-subsequence-less-than-or-equal-to-k", "difficulty": "Medium", "problem_description": "You are given a binary string s and a positive integer k.\nReturn the length of the longest subsequence of s that makes up a binary number less than or equal to k.\nNote:\n\nThe subsequence can contain leading zeroes.\nThe empty string is considered to be equal to 0.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n\n \nExample 1:\n\nInput: s = \"1001010\", k = 5\nOutput: 5\nExplanation: The longest subsequence of s that makes up a binary number less than or equal to 5 is \"00010\", as this number is equal to 2 in decimal.\nNote that \"00100\" and \"00101\" are also possible, which are equal to 4 and 5 in decimal, respectively.\nThe length of this subsequence is 5, so 5 is returned.\n\nExample 2:\n\nInput: s = \"00101001\", k = 1\nOutput: 6\nExplanation: \"000001\" is the longest subsequence of s that makes up a binary number less than or equal to 1, as this number is equal to 1 in decimal.\nThe length of this subsequence is 6, so 6 is returned.\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns[i] is either '0' or '1'.\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"0000000\",k = 0) == 7\n assert candidate(s = \"111000111\",k = 127) == 7\n assert candidate(s = \"1111111\",k = 127) == 7\n assert candidate(s = \"1111000011\",k = 255) == 8\n assert candidate(s = \"1100110011\",k = 10) == 6\n assert candidate(s = \"1010101010\",k = 512) == 9\n assert candidate(s = \"10101010\",k = 10) == 6\n assert candidate(s = \"111000111\",k = 50) == 6\n assert candidate(s = \"1101001\",k = 4) == 4\n assert candidate(s = \"11111111\",k = 15) == 4\n assert candidate(s = \"0101010101\",k = 512) == 10\n assert candidate(s = \"1101101\",k = 7) == 4\n assert candidate(s = \"1100110011\",k = 500) == 9\n assert candidate(s = \"0000000\",k = 10) == 7\n assert candidate(s = \"1001010\",k = 5) == 5\n assert candidate(s = \"00000\",k = 1000) == 5\n assert candidate(s = \"0101010101\",k = 255) == 9\n assert candidate(s = \"1\",k = 1) == 1\n assert candidate(s = \"11111111\",k = 255) == 8\n assert candidate(s = \"0000111100\",k = 31) == 9\n assert candidate(s = \"101010\",k = 3) == 4\n assert candidate(s = \"0\",k = 0) == 1\n assert candidate(s = \"1111000011110000\",k = 100000) == 16\n assert candidate(s = \"1100110011\",k = 100) == 8\n assert candidate(s = \"1010101010\",k = 10) == 7\n assert candidate(s = \"100110011001100110\",k = 1000) == 14\n assert candidate(s = \"00000000\",k = 0) == 8\n assert candidate(s = \"11001100\",k = 20) == 6\n assert candidate(s = \"00000000\",k = 8) == 8\n assert candidate(s = \"00101001\",k = 1) == 6\n assert candidate(s = \"010101010101010101\",k = 10000) == 16\n assert candidate(s = \"100101010010101010101010\",k = 1024) == 18\n assert candidate(s = \"1010101010101010101010101\",k = 1048575) == 22\n assert candidate(s = \"11001100110011001100110011001100110011001100110011001100\",k = 1000000) == 38\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010\",k = 10) == 36\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010\",k = 1023) == 33\n assert candidate(s = \"110011001100110011001100110011001100110011001100\",k = 65535) == 32\n assert candidate(s = \"001100110011001100110011001100110011001100110011001100110011\",k = 4096) == 36\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",k = 0) == 87\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111\",k = 1073741823) == 30\n assert candidate(s = \"1101101101101101101101101\",k = 1000) == 15\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111\",k = 2047) == 11\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000\",k = 1000) == 56\n assert candidate(s = \"0101010101010101010101010101010101010101\",k = 1023) == 25\n assert candidate(s = \"00001111000011110000111100001111000011110000111100001111\",k = 32767) == 36\n assert candidate(s = \"1001001001001001001001001001001001001001\",k = 10000) == 31\n assert candidate(s = \"11010110101101011010110101101011010110101101011010110101\",k = 1048575) == 34\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001\",k = 5000) == 43\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100110011001100110011001100\",k = 128) == 47\n assert candidate(s = \"10010101010101010101\",k = 30000) == 18\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000111000111000\",k = 50000) == 43\n assert candidate(s = \"11010101010101010101\",k = 16383) == 16\n assert candidate(s = \"1101001101001101001101001101001\",k = 1024) == 20\n assert candidate(s = \"1111111111111111111111111111111111111111\",k = 1024) == 10\n assert candidate(s = \"0101010101010101010101010101010101010101\",k = 10) == 22\n assert candidate(s = \"1001100110011001100110011001100110011001\",k = 2000) == 25\n assert candidate(s = \"1100110011001100\",k = 1000) == 12\n assert candidate(s = \"10101010101010101010101010101010101010101010\",k = 1000000) == 32\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010101\",k = 1000) == 39\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010\",k = 2147483647) == 49\n assert candidate(s = \"11111111111111111111111111111111111111111111\",k = 1048575) == 20\n assert candidate(s = \"1111111111111111111111111\",k = 1048575) == 20\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 500) == 48\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",k = 1000000000) == 29\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000\",k = 1) == 65\n assert candidate(s = \"0011001100110011001100110011001100110011\",k = 5000) == 27\n assert candidate(s = \"0000000000000000000000000000000000000000\",k = 0) == 40\n assert candidate(s = \"111111111100000000111111111000000011111111100000001111111110000000111111111000000011111111\",k = 10000000) == 52\n assert candidate(s = \"1101101101101101101101101101101101101101\",k = 500) == 19\n assert candidate(s = \"100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000\",k = 500000000) == 115\n assert candidate(s = \"11110000111100001111000011110000111100001111000011110000\",k = 65535) == 36\n assert candidate(s = \"100000000000000000000000000000000000000000000000\",k = 1000000000) == 47\n assert candidate(s = \"11001100110011001100110011001100\",k = 2048) == 21\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101\",k = 2048) == 34\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 100) == 48\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000111000111\",k = 500) == 39\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\",k = 511) == 33\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000000000000000\",k = 0) == 64\n assert candidate(s = \"01110111011101110111011101110111011101110111011101110111\",k = 524287) == 29\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 1048575) == 53\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010\",k = 65535) == 44\n assert candidate(s = \"1111000011110000111100001111000011110000\",k = 10000) == 25\n assert candidate(s = \"0000000000000000000000000\",k = 1) == 25\n assert candidate(s = \"000111000111000111000111000111000111000111000111000111000111000111000111\",k = 25000) == 44\n assert candidate(s = \"1110000011100000111000001110000011100000111000001110000011100000111000001110000011100000\",k = 255) == 58\n assert candidate(s = \"111111111111111111111111111111111111111111111111\",k = 2147483647) == 30\n assert candidate(s = \"010101010101010101010101010101010101010101010101\",k = 524287) == 34\n assert candidate(s = \"1110001110001110001110001\",k = 2048) == 17\n assert candidate(s = \"1111000011110000111100001111000011110000111100001111000011110000\",k = 10000) == 37\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111\",k = 1000000000) == 29\n assert candidate(s = \"000100010001000100010001000100010001000100010001000100010001000100010\",k = 1023) == 55\n assert candidate(s = \"0000111111111111111111111\",k = 1048575) == 24\n assert candidate(s = \"0011001100110011001100110011001100110011001100110011001100110011001100110011001100110011\",k = 50) == 47\n assert candidate(s = \"10000000000000000000000000000000000000000000000000000000000000000000\",k = 1) == 67\n assert candidate(s = \"1010101010101010101010101010101010101010\",k = 1023) == 25\n assert candidate(s = \"110010011001001100100110010011001001100100110011001001\",k = 1023) == 34\n assert candidate(s = \"00000000000000000000\",k = 1000) == 20\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111\",k = 2047) == 11\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111\",k = 1000000000) == 29\n assert candidate(s = \"001010101010101010101010101010101010101010101010\",k = 1024) == 30\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",k = 999999999) == 94\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().longestSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestSubsequence(String s, int k) {", "container": "Solution", "callable": "longestSubsequence", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2312, "task_id": "selling-pieces-of-wood", "difficulty": "Hard", "problem_description": "You are given two integers m and n that represent the height and width of a rectangular piece of wood. You are also given a 2D integer array prices, where prices[i] = [hi, wi, pricei] indicates you can sell a rectangular piece of wood of height hi and width wi for pricei dollars.\nTo cut a piece of wood, you must make a vertical or horizontal cut across the entire height or width of the piece to split it into two smaller pieces. After cutting a piece of wood into some number of smaller pieces, you can sell pieces according to prices. You may sell multiple pieces of the same shape, and you do not have to sell all the shapes. The grain of the wood makes a difference, so you cannot rotate a piece to swap its height and width.\nReturn the maximum money you can earn after cutting an m x n piece of wood.\nNote that you can cut the piece of wood as many times as you want.\n \nExample 1:\n\n\nInput: m = 3, n = 5, prices = [[1,4,2],[2,2,7],[2,1,3]]\nOutput: 19\nExplanation: The diagram above shows a possible scenario. It consists of:\n- 2 pieces of wood shaped 2 x 2, selling for a price of 2 * 7 = 14.\n- 1 piece of wood shaped 2 x 1, selling for a price of 1 * 3 = 3.\n- 1 piece of wood shaped 1 x 4, selling for a price of 1 * 2 = 2.\nThis obtains a total of 14 + 3 + 2 = 19 money earned.\nIt can be shown that 19 is the maximum amount of money that can be earned.\n\nExample 2:\n\n\nInput: m = 4, n = 6, prices = [[3,2,10],[1,4,2],[4,1,3]]\nOutput: 32\nExplanation: The diagram above shows a possible scenario. It consists of:\n- 3 pieces of wood shaped 3 x 2, selling for a price of 3 * 10 = 30.\n- 1 piece of wood shaped 1 x 4, selling for a price of 1 * 2 = 2.\nThis obtains a total of 30 + 2 = 32 money earned.\nIt can be shown that 32 is the maximum amount of money that can be earned.\nNotice that we cannot rotate the 1 x 4 piece of wood to obtain a 4 x 1 piece of wood.\n \nConstraints:\n\n1 <= m, n <= 200\n1 <= prices.length <= 2 * 104\nprices[i].length == 3\n1 <= hi <= m\n1 <= wi <= n\n1 <= pricei <= 106\nAll the shapes of wood (hi, wi) are pairwise distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 4,n = 6,prices = [[3, 2, 10], [1, 4, 2], [4, 1, 3]]) == 32\n assert candidate(m = 2,n = 2,prices = [[1, 1, 1], [2, 2, 5]]) == 5\n assert candidate(m = 3,n = 5,prices = [[1, 4, 2], [2, 2, 7], [2, 1, 3]]) == 19\n assert candidate(m = 200,n = 200,prices = [[1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 40000\n assert candidate(m = 2,n = 2,prices = [[2, 2, 5]]) == 5\n assert candidate(m = 1,n = 1,prices = [[1, 1, 100]]) == 100\n assert candidate(m = 5,n = 5,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20]]) == 29\n assert candidate(m = 5,n = 5,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 20], [5, 5, 50]]) == 50\n assert candidate(m = 10,n = 10,prices = [[1, 1, 1], [1, 2, 3], [2, 1, 3], [2, 2, 5], [3, 3, 10], [5, 5, 20]]) == 150\n assert candidate(m = 15,n = 15,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [6, 6, 36], [7, 7, 49], [8, 8, 64], [9, 9, 81], [10, 10, 100], [11, 11, 121], [12, 12, 144], [13, 13, 169], [14, 14, 196], [15, 15, 225]]) == 225\n assert candidate(m = 90,n = 60,prices = [[5, 5, 25], [10, 10, 100], [15, 15, 225], [20, 20, 400], [25, 25, 625]]) == 5400\n assert candidate(m = 10,n = 5,prices = [[1, 1, 2], [1, 2, 4], [1, 3, 6], [1, 4, 8], [1, 5, 10], [2, 1, 4], [2, 2, 8], [2, 3, 12], [2, 4, 16], [2, 5, 20], [3, 1, 6], [3, 2, 12], [3, 3, 18], [3, 4, 24], [3, 5, 30], [4, 1, 8], [4, 2, 16], [4, 3, 24], [4, 4, 32], [4, 5, 40], [5, 1, 10], [5, 2, 20], [5, 3, 30], [5, 4, 40], [5, 5, 50]]) == 100\n assert candidate(m = 100,n = 100,prices = [[50, 50, 2500], [25, 25, 625], [75, 75, 4500], [10, 10, 25], [1, 1, 1]]) == 10000\n assert candidate(m = 50,n = 50,prices = [[5, 5, 25], [10, 10, 100], [25, 25, 625], [45, 45, 2025], [1, 1, 1]]) == 2500\n assert candidate(m = 150,n = 100,prices = [[10, 20, 100], [15, 10, 200], [20, 15, 250], [50, 50, 1500], [75, 75, 5000]]) == 20000\n assert candidate(m = 5,n = 5,prices = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50]]) == 250\n assert candidate(m = 150,n = 100,prices = [[1, 1, 1], [5, 5, 10], [10, 10, 20], [15, 15, 30], [25, 25, 40], [50, 50, 100]]) == 15000\n assert candidate(m = 180,n = 90,prices = [[1, 1, 2], [2, 2, 8], [3, 3, 18], [4, 4, 32], [5, 5, 50], [6, 6, 72], [7, 7, 98], [8, 8, 128], [9, 9, 162], [10, 10, 200], [15, 15, 750], [30, 30, 3000], [45, 45, 6750], [90, 90, 20250]]) == 54000\n assert candidate(m = 50,n = 50,prices = [[1, 1, 2], [2, 2, 6], [3, 3, 18], [4, 4, 40], [5, 5, 75], [10, 10, 300], [15, 15, 800], [25, 25, 1200]]) == 8625\n assert candidate(m = 160,n = 140,prices = [[1, 2, 1], [2, 1, 2], [3, 4, 3], [4, 3, 4], [5, 6, 5], [6, 5, 6], [7, 8, 7], [8, 7, 8], [9, 10, 9], [10, 9, 10]]) == 22400\n assert candidate(m = 150,n = 120,prices = [[50, 40, 2000], [75, 60, 3600], [25, 30, 600], [10, 15, 150], [1, 1, 1]]) == 18000\n assert candidate(m = 100,n = 100,prices = [[10, 10, 50], [20, 20, 100], [30, 30, 150], [50, 50, 300]]) == 5000\n assert candidate(m = 20,n = 30,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [10, 10, 100], [15, 15, 225]]) == 600\n assert candidate(m = 190,n = 190,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 20], [5, 5, 50], [10, 10, 100], [20, 20, 500], [30, 30, 1000], [40, 40, 2000], [50, 50, 5000], [60, 60, 10000], [70, 70, 20000], [80, 80, 50000], [90, 90, 100000], [100, 100, 200000], [110, 110, 300000], [120, 120, 400000], [130, 130, 500000], [140, 140, 600000], [150, 150, 700000], [160, 160, 800000], [170, 170, 900000], [180, 180, 1000000], [190, 190, 1100000]]) == 1100000\n assert candidate(m = 120,n = 80,prices = [[20, 10, 200], [10, 20, 150], [30, 30, 900], [60, 40, 2400], [40, 60, 3000]]) == 11400\n assert candidate(m = 80,n = 60,prices = [[20, 15, 300], [10, 10, 100], [40, 30, 1200], [60, 40, 2400], [50, 50, 3000], [1, 1, 1]]) == 5300\n assert candidate(m = 110,n = 90,prices = [[30, 20, 600], [60, 40, 2400], [15, 10, 150], [50, 30, 1500], [1, 1, 1]]) == 9900\n assert candidate(m = 100,n = 100,prices = [[10, 10, 50], [20, 20, 200], [30, 30, 500], [40, 40, 1000], [50, 50, 2000]]) == 8000\n assert candidate(m = 180,n = 160,prices = [[10, 10, 50], [20, 20, 200], [30, 30, 500], [40, 40, 1000], [50, 50, 2000], [60, 60, 3000]]) == 22650\n assert candidate(m = 50,n = 50,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [5, 5, 50], [10, 10, 100], [25, 25, 5000], [50, 50, 100000]]) == 100000\n assert candidate(m = 200,n = 100,prices = [[1, 1, 1], [1, 2, 2], [2, 1, 3], [2, 2, 5], [10, 10, 100], [20, 20, 500], [30, 30, 1200], [50, 50, 2500], [100, 100, 10000]]) == 30000\n assert candidate(m = 80,n = 120,prices = [[1, 2, 2], [2, 1, 3], [2, 3, 5], [3, 2, 6], [4, 6, 12], [6, 4, 15], [8, 12, 24], [12, 8, 30]]) == 14400\n assert candidate(m = 180,n = 120,prices = [[30, 40, 300], [40, 30, 400], [60, 60, 600], [90, 90, 1200], [120, 120, 2000], [150, 150, 3000]]) == 6600\n assert candidate(m = 150,n = 100,prices = [[10, 10, 100], [20, 20, 500], [30, 30, 1200], [15, 15, 300]]) == 19500\n assert candidate(m = 200,n = 100,prices = [[1, 1, 1], [2, 2, 2], [4, 4, 4], [8, 8, 8], [16, 16, 16], [32, 32, 32]]) == 20000\n assert candidate(m = 10,n = 20,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [6, 6, 36], [7, 7, 49], [8, 8, 64], [9, 9, 81], [10, 10, 100]]) == 200\n assert candidate(m = 200,n = 200,prices = [[10, 20, 100], [20, 30, 250], [30, 40, 500], [40, 50, 750], [50, 60, 1000]]) == 20000\n assert candidate(m = 190,n = 190,prices = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [2, 1, 2], [2, 2, 5], [2, 3, 6], [3, 1, 3], [3, 2, 6], [3, 3, 10]]) == 45125\n assert candidate(m = 100,n = 100,prices = [[10, 10, 100], [20, 20, 300], [30, 30, 600], [40, 40, 1000], [50, 50, 1500]]) == 10000\n assert candidate(m = 120,n = 80,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55], [10, 10, 65], [11, 11, 75], [12, 12, 85], [13, 13, 95], [14, 14, 105], [15, 15, 115], [16, 16, 125], [17, 17, 135], [18, 18, 145], [19, 19, 155], [20, 20, 165], [21, 21, 175], [22, 22, 185], [23, 23, 195], [24, 24, 205], [25, 25, 215], [26, 26, 225], [27, 27, 235], [28, 28, 245], [29, 29, 255], [30, 30, 265], [31, 31, 275], [32, 32, 285], [33, 33, 295], [34, 34, 305], [35, 35, 315], [36, 36, 325], [37, 37, 335], [38, 38, 345], [39, 39, 355], [40, 40, 365], [41, 41, 375], [42, 42, 385], [43, 43, 395], [44, 44, 405], [45, 45, 415], [46, 46, 425], [47, 47, 435], [48, 48, 445], [49, 49, 455], [50, 50, 465], [51, 51, 475], [52, 52, 485], [53, 53, 495], [54, 54, 505], [55, 55, 515], [56, 56, 525], [57, 57, 535], [58, 58, 545], [59, 59, 555], [60, 60, 565], [61, 61, 575], [62, 62, 585], [63, 63, 595], [64, 64, 605], [65, 65, 615], [66, 66, 625], [67, 67, 635], [68, 68, 645], [69, 69, 655], [70, 70, 665], [71, 71, 675], [72, 72, 685], [73, 73, 695], [74, 74, 705], [75, 75, 715], [76, 76, 725], [77, 77, 735], [78, 78, 745], [79, 79, 755], [80, 80, 765]]) == 12000\n assert candidate(m = 110,n = 90,prices = [[10, 10, 100], [20, 20, 400], [30, 30, 900], [40, 40, 1600], [50, 50, 2500], [60, 60, 3600], [70, 70, 4900], [80, 80, 6400], [90, 90, 8100], [100, 100, 10000]]) == 9900\n assert candidate(m = 80,n = 60,prices = [[10, 20, 500], [20, 30, 1500], [30, 40, 2700], [40, 50, 4000]]) == 12000\n assert candidate(m = 120,n = 80,prices = [[1, 1, 1], [2, 2, 5], [4, 4, 20], [8, 8, 100], [16, 16, 500], [32, 32, 2000], [64, 64, 5000], [120, 80, 10000]]) == 18500\n assert candidate(m = 200,n = 200,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55], [10, 10, 65], [11, 11, 75], [12, 12, 85], [13, 13, 95], [14, 14, 105], [15, 15, 115], [16, 16, 125], [17, 17, 135], [18, 18, 145], [19, 19, 155], [20, 20, 165], [21, 21, 175], [22, 22, 185], [23, 23, 195], [24, 24, 205], [25, 25, 215], [26, 26, 225], [27, 27, 235], [28, 28, 245], [29, 29, 255], [30, 30, 265]]) == 50000\n assert candidate(m = 200,n = 100,prices = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [5, 5, 5], [10, 10, 10], [20, 20, 20], [50, 50, 50], [100, 100, 100]]) == 20000\n assert candidate(m = 15,n = 12,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25]]) == 222\n assert candidate(m = 200,n = 150,prices = [[50, 50, 1000], [75, 75, 3000], [100, 100, 5000], [150, 150, 8000]]) == 15000\n assert candidate(m = 180,n = 180,prices = [[1, 1, 3], [2, 2, 6], [3, 3, 9], [4, 4, 12], [5, 5, 15], [6, 6, 18], [7, 7, 21], [8, 8, 24], [9, 9, 27]]) == 97200\n assert candidate(m = 175,n = 110,prices = [[10, 5, 50], [5, 10, 75], [20, 10, 150], [10, 20, 200], [15, 15, 300], [25, 25, 500], [50, 50, 1000]]) == 28875\n assert candidate(m = 120,n = 80,prices = [[1, 1, 1], [2, 2, 5], [4, 4, 15], [8, 8, 30], [16, 16, 60], [32, 32, 120], [64, 64, 240]]) == 12000\n assert candidate(m = 180,n = 120,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 20], [5, 5, 50], [6, 6, 100], [10, 10, 500], [20, 20, 2000], [30, 30, 5000], [40, 40, 10000], [50, 50, 20000], [60, 60, 50000], [120, 120, 100000], [180, 120, 150000]]) == 300000\n assert candidate(m = 120,n = 120,prices = [[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]]) == 14400\n assert candidate(m = 6,n = 4,prices = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [2, 1, 2], [2, 2, 5], [2, 3, 6], [2, 4, 8], [3, 1, 3], [3, 2, 6], [3, 3, 9], [3, 4, 12], [4, 1, 4], [4, 2, 8], [4, 3, 12], [4, 4, 16], [5, 1, 5], [5, 2, 10], [5, 3, 15], [5, 4, 20], [6, 1, 6], [6, 2, 12], [6, 3, 18], [6, 4, 24]]) == 30\n assert candidate(m = 190,n = 190,prices = [[1, 1, 1], [10, 10, 50], [20, 20, 200], [30, 30, 500], [40, 40, 1000], [50, 50, 2000], [60, 60, 3000], [70, 70, 4000], [80, 80, 5000], [90, 90, 6000], [100, 100, 7000], [110, 110, 8000], [120, 120, 9000], [130, 130, 10000], [140, 140, 11000], [150, 150, 12000], [160, 160, 13000], [170, 170, 14000], [180, 180, 15000], [190, 190, 16000]]) == 36100\n assert candidate(m = 80,n = 60,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 20], [5, 5, 50], [10, 10, 100], [20, 20, 500], [30, 30, 1500], [40, 40, 5000], [50, 50, 10000], [60, 60, 20000], [80, 60, 30000]]) == 30000\n assert candidate(m = 150,n = 150,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [150, 150, 100000], [75, 75, 25000]]) == 100000\n assert candidate(m = 150,n = 150,prices = [[1, 1, 5], [2, 2, 10], [3, 3, 15], [5, 5, 25], [10, 10, 50], [15, 15, 75]]) == 112500\n assert candidate(m = 100,n = 100,prices = [[1, 1, 10], [10, 10, 500], [50, 50, 20000], [25, 25, 5000], [100, 100, 50000]]) == 100000\n assert candidate(m = 120,n = 150,prices = [[1, 1, 5], [2, 2, 15], [3, 3, 45], [4, 4, 100], [5, 5, 175], [6, 6, 270], [7, 7, 392], [8, 8, 540], [9, 9, 717], [10, 10, 920], [11, 11, 1155], [12, 12, 1420], [13, 13, 1725], [14, 14, 2070], [15, 15, 2450], [16, 16, 2870], [17, 17, 3332], [18, 18, 3837], [19, 19, 4385], [20, 20, 4980]]) == 220200\n assert candidate(m = 7,n = 3,prices = [[1, 1, 3], [1, 2, 5], [1, 3, 7], [2, 1, 6], [2, 2, 12], [2, 3, 15], [3, 1, 9], [3, 2, 18], [3, 3, 20]]) == 63\n assert candidate(m = 100,n = 150,prices = [[5, 5, 25], [10, 10, 100], [15, 15, 250], [20, 20, 500], [25, 25, 750]]) == 18500\n assert candidate(m = 12,n = 8,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 15], [4, 4, 30], [5, 5, 50], [6, 6, 75], [7, 7, 105], [8, 8, 140], [9, 9, 180], [10, 10, 225], [11, 11, 275], [12, 12, 330]]) == 200\n assert candidate(m = 100,n = 200,prices = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [5, 5, 5], [10, 10, 10], [20, 20, 20], [50, 50, 50], [100, 100, 100]]) == 20000\n assert candidate(m = 100,n = 50,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55], [10, 10, 65], [11, 11, 75], [12, 12, 85], [13, 13, 95], [14, 14, 105], [15, 15, 115], [16, 16, 125], [17, 17, 135], [18, 18, 145], [19, 19, 155], [20, 20, 165], [21, 21, 175], [22, 22, 185], [23, 23, 195], [24, 24, 205], [25, 25, 215], [26, 26, 225], [27, 27, 235], [28, 28, 245], [29, 29, 255], [30, 30, 265], [31, 31, 275], [32, 32, 285], [33, 33, 295], [34, 34, 305], [35, 35, 315], [36, 36, 325], [37, 37, 335], [38, 38, 345], [39, 39, 355], [40, 40, 365], [41, 41, 375], [42, 42, 385], [43, 43, 395], [44, 44, 405], [45, 45, 415], [46, 46, 425], [47, 47, 435], [48, 48, 445], [49, 49, 455], [50, 50, 465]]) == 6250\n assert candidate(m = 100,n = 100,prices = [[1, 1, 10], [5, 5, 100], [10, 10, 500], [20, 20, 2000], [50, 50, 10000]]) == 100000\n assert candidate(m = 120,n = 120,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [6, 6, 36], [7, 7, 49], [8, 8, 64], [9, 9, 81], [10, 10, 100], [11, 11, 121], [12, 12, 144], [13, 13, 169], [14, 14, 196], [15, 15, 225]]) == 14400\n assert candidate(m = 120,n = 80,prices = [[1, 1, 1], [2, 2, 5], [4, 4, 20], [8, 8, 100], [16, 16, 500]]) == 18500\n assert candidate(m = 180,n = 120,prices = [[1, 2, 1], [2, 3, 4], [3, 4, 7], [4, 5, 11], [5, 6, 16]]) == 14400\n assert candidate(m = 180,n = 160,prices = [[90, 80, 14400], [60, 70, 8400], [30, 40, 1200], [20, 30, 600], [10, 20, 200], [1, 1, 1]]) == 57600\n assert candidate(m = 75,n = 75,prices = [[1, 1, 2], [3, 3, 10], [5, 5, 30], [7, 7, 60], [10, 10, 120], [15, 15, 300], [20, 20, 500], [25, 25, 800], [30, 30, 1200], [35, 35, 1600], [40, 40, 2000], [45, 45, 2400], [50, 50, 2800], [55, 55, 3200], [60, 60, 3600], [65, 65, 4000], [70, 70, 4400], [75, 75, 4800]]) == 11250\n assert candidate(m = 160,n = 100,prices = [[10, 10, 100], [20, 20, 400], [30, 30, 900], [40, 40, 1600], [50, 50, 2500]]) == 16000\n assert candidate(m = 120,n = 80,prices = [[10, 5, 10], [5, 10, 20], [15, 5, 30], [5, 15, 40], [20, 10, 50], [10, 20, 60], [25, 5, 70], [5, 25, 80], [30, 10, 90], [10, 30, 100]]) == 6070\n assert candidate(m = 160,n = 160,prices = [[1, 1, 1], [2, 2, 5], [4, 4, 15], [8, 8, 30], [16, 16, 60], [32, 32, 120], [64, 64, 240], [128, 128, 480]]) == 32000\n assert candidate(m = 8,n = 6,prices = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [2, 1, 2], [2, 2, 5], [2, 3, 6], [2, 4, 8], [2, 5, 10], [2, 6, 12], [3, 1, 3], [3, 2, 6], [3, 3, 9], [3, 4, 12], [3, 5, 15], [3, 6, 18], [4, 1, 4], [4, 2, 8], [4, 3, 12], [4, 4, 16], [4, 5, 20], [4, 6, 24], [5, 1, 5], [5, 2, 10], [5, 3, 15], [5, 4, 20], [5, 5, 25], [5, 6, 30], [6, 1, 6], [6, 2, 12], [6, 3, 18], [6, 4, 24], [6, 5, 30], [6, 6, 36], [7, 1, 7], [7, 2, 14], [7, 3, 21], [7, 4, 28], [7, 5, 35], [7, 6, 42], [8, 1, 8], [8, 2, 16], [8, 3, 24], [8, 4, 32], [8, 5, 40], [8, 6, 48]]) == 60\n assert candidate(m = 190,n = 140,prices = [[10, 10, 100], [20, 20, 400], [30, 30, 900], [40, 40, 1600], [50, 50, 2500]]) == 26600\n assert candidate(m = 150,n = 100,prices = [[1, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55], [10, 10, 65], [11, 11, 75], [12, 12, 85], [13, 13, 95], [14, 14, 105], [15, 15, 115], [16, 16, 125], [17, 17, 135], [18, 18, 145], [19, 19, 155], [20, 20, 165], [21, 21, 175], [22, 22, 185], [23, 23, 195], [24, 24, 205], [25, 25, 215], [26, 26, 225], [27, 27, 235], [28, 28, 245], [29, 29, 255], [30, 30, 265], [31, 31, 275], [32, 32, 285], [33, 33, 295], [34, 34, 305], [35, 35, 315], [36, 36, 325], [37, 37, 335], [38, 38, 345], [39, 39, 355], [40, 40, 365], [41, 41, 375], [42, 42, 385], [43, 43, 395], [44, 44, 405], [45, 45, 415], [46, 46, 425], [47, 47, 435], [48, 48, 445], [49, 49, 455], [50, 50, 465], [51, 51, 475], [52, 52, 485], [53, 53, 495], [54, 54, 505], [55, 55, 515], [56, 56, 525], [57, 57, 535], [58, 58, 545], [59, 59, 555], [60, 60, 565], [61, 61, 575], [62, 62, 585], [63, 63, 595], [64, 64, 605], [65, 65, 615], [66, 66, 625], [67, 67, 635], [68, 68, 645], [69, 69, 655], [70, 70, 665], [71, 71, 675], [72, 72, 685], [73, 73, 695], [74, 74, 705], [75, 75, 715]]) == 18750\n assert candidate(m = 100,n = 100,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [6, 6, 36], [7, 7, 49], [8, 8, 64], [9, 9, 81], [10, 10, 100], [20, 20, 400], [30, 30, 900], [40, 40, 1600], [50, 50, 2500], [60, 60, 3600], [70, 70, 4900], [80, 80, 6400], [90, 90, 8100], [100, 100, 10000]]) == 10000\n assert candidate(m = 180,n = 120,prices = [[10, 20, 50], [20, 10, 40], [30, 40, 120], [40, 30, 100], [60, 60, 200]]) == 5400\n assert candidate(m = 200,n = 100,prices = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [2, 2, 5], [2, 3, 6], [2, 4, 7], [2, 5, 8], [3, 3, 9], [3, 4, 10], [3, 5, 11], [4, 4, 13], [4, 5, 14], [5, 5, 16]]) == 25000\n assert candidate(m = 18,n = 18,prices = [[1, 1, 1], [1, 2, 3], [2, 1, 3], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55], [10, 10, 65], [11, 11, 75], [12, 12, 85], [13, 13, 95], [14, 14, 105], [15, 15, 115], [16, 16, 125], [17, 17, 135], [18, 18, 145]]) == 486\n assert candidate(m = 150,n = 100,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 20], [5, 5, 50], [6, 6, 100], [7, 7, 200], [8, 8, 500]]) == 110350\n assert candidate(m = 150,n = 100,prices = [[10, 10, 100], [20, 20, 500], [30, 30, 1200], [5, 5, 20], [15, 15, 300]]) == 19500\n assert candidate(m = 190,n = 130,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [10, 10, 100], [15, 15, 225], [20, 20, 400], [25, 25, 625]]) == 24700\n assert candidate(m = 10,n = 10,prices = [[1, 1, 5], [2, 2, 10], [3, 3, 15], [4, 4, 20], [5, 5, 25], [6, 6, 30], [7, 7, 35], [8, 8, 40], [9, 9, 45], [10, 10, 50]]) == 500\n assert candidate(m = 50,n = 50,prices = [[5, 5, 100], [10, 10, 500], [15, 15, 1200], [20, 20, 2000], [25, 25, 3000], [30, 30, 4000], [35, 35, 5000], [40, 40, 6000], [45, 45, 7000], [50, 50, 8000]]) == 12800\n assert candidate(m = 100,n = 100,prices = [[50, 50, 10000], [25, 25, 2500], [75, 75, 15000], [10, 10, 100], [1, 1, 1]]) == 40000\n assert candidate(m = 10,n = 10,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 30], [8, 8, 35], [9, 9, 40], [10, 10, 50]]) == 125\n assert candidate(m = 150,n = 100,prices = [[1, 1, 1], [2, 2, 5], [5, 5, 10], [10, 10, 20], [15, 15, 30]]) == 18750\n"}, "metadata": {"canonical_parameter_names": ["m", "n", "prices"], "leetcode_dataset_entry_point": "Solution().sellingWood", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long sellingWood(int m, int n, int[][] prices) {", "container": "Solution", "callable": "sellingWood", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "prices", "type": "int[][]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2315, "task_id": "count-asterisks", "difficulty": "Easy", "problem_description": "You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair. In other words, the 1st and 2nd '|' make a pair, the 3rd and 4th '|' make a pair, and so forth.\nReturn the number of '*' in s, excluding the '*' between each pair of '|'.\nNote that each '|' will belong to exactly one pair.\n \nExample 1:\n\nInput: s = \"l|*e*et|c**o|*de|\"\nOutput: 2\nExplanation: The considered characters are underlined: \"l|*e*et|c**o|*de|\".\nThe characters between the first and second '|' are excluded from the answer.\nAlso, the characters between the third and fourth '|' are excluded from the answer.\nThere are 2 asterisks considered. Therefore, we return 2.\nExample 2:\n\nInput: s = \"iamprogrammer\"\nOutput: 0\nExplanation: In this example, there are no asterisks in s. Therefore, we return 0.\n\nExample 3:\n\nInput: s = \"yo|uar|e**|b|e***au|tifu|l\"\nOutput: 5\nExplanation: The considered characters are underlined: \"yo|uar|e**|b|e***au|tifu|l\". There are 5 asterisks considered. Therefore, we return 5.\n \nConstraints:\n\n1 <= s.length <= 1000\ns consists of lowercase English letters, vertical bars '|', and asterisks '*'.\ns contains an even number of vertical bars '|'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"iamprogrammer\") == 0\n assert candidate(s = \"|*|*|*|*|\") == 2\n assert candidate(s = \"||||||||||\") == 0\n assert candidate(s = \"yo|uar|e**|b|e***au|tifu|l\") == 5\n assert candidate(s = \"l|*e*et|c**o|*de|\") == 2\n assert candidate(s = \"abc|def|ghi|jkl|\") == 0\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|\") == 11\n assert candidate(s = \"*|*|*|*|*|*|\") == 3\n assert candidate(s = \"no|asterisks|here|\") == 0\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|\") == 5\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*|\") == 2\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*|\") == 13\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|\") == 13\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*|*\") == 19\n assert candidate(s = \"this|is|a|test|string|with|multiple|pipes|and|asterisks|*|*|*|*|*|*|*|*|*|*|*|\") == 6\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*|\") == 31\n assert candidate(s = \"multiple|pairs|of|bars|and*no*asterisks*between|them|\") == 3\n assert candidate(s = \"*a*|b*c|d*e*f|g*h*i*j|\") == 4\n assert candidate(s = \"abc*def|ghi*jkl|*mnop|qrstu|vwxyz*\") == 3\n assert candidate(s = \"|*a*|b|c*|d*e*|f*g*h|*i*j*k*|l*m*n*o*|\") == 6\n assert candidate(s = \"this|is|a|test|string|with|multiple|pipes|and|asterisks|*|*|*|\") == 2\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|\") == 26\n assert candidate(s = \"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\") == 0\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*|\") == 0\n assert candidate(s = \"interleaved*characters|with|pipes*and*asterisks|and|more|pipes*and*asterisks*at|the*end*of*the|string*\") == 6\n assert candidate(s = \"|*||||*||||*||||*||||*|\") == 0\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|\") == 0\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*|\") == 1\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*|\") == 27\n assert candidate(s = \"nested||pipes|should|not|affect|the|count|of|*|in|between|pipes|\") == 0\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*|\") == 13\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*|\") == 26\n assert candidate(s = \"long|*sequence*|of|*characters*|to|test|the|*algorithm*|efficiency|\") == 0\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*|*\") == 2\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*|\") == 13\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*|\") == 13\n assert candidate(s = \"nested|*pipes*|and|*asterisks*|inside|*and*|outside|*pipes*|\") == 0\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|\") == 9\n assert candidate(s = \"multiple*asterisks*here|and*here*too|and*here|\") == 3\n assert candidate(s = \"this|is*a*test|to*see*if*the*function*works*correctly*with*many*bars|and*asterisks*in*various*places*|\") == 9\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*|\") == 12\n assert candidate(s = \"1234567890|*1*2*3*4*5*6*7*8*9*0|abcdefg|hijklmn|opqrstuv|wxyz|\") == 0\n assert candidate(s = \"*at|the|start*|and|at|the|end*|pipes|should|not|affect|the|count*|\") == 4\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*|\") == 0\n assert candidate(s = \"|pipes|without|*asterisks*|in|between|pipes|should|return|zero|\") == 0\n assert candidate(s = \"*only*|*pipes*|*and*|*asterisks*|*in*|*the*|*string*|\") == 8\n assert candidate(s = \"no*bars*in*string\") == 3\n assert candidate(s = \"no|pipes|here|just|plain|text|and|some|asterisks*at*the*end\") == 3\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*|\") == 6\n assert candidate(s = \"nested*bars*are|not|possible|but|this|is*a*test*case*with*many*bars|and*some*stars*in*the*end*|\") == 8\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 20\n assert candidate(s = \"*at*the*start*and*no*pipes*in*the*middle*or*end\") == 11\n assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 19\n assert candidate(s = \"noasterisks|here|but|many|pipes|to|confuse|you|\") == 0\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*\") == 1\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|*\") == 1\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*|\") == 14\n assert candidate(s = \"hello*world|this|is*a*test|string|with*many*asterisks|\") == 5\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|*|\") == 14\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|\") == 17\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*|\") == 3\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 18\n assert candidate(s = \"||||||||**||||||||\") == 2\n assert candidate(s = \"*single*|*pair*|of|*pipes*|with|*multiple*|asterisks*|inside*|\") == 3\n assert candidate(s = \"no|pipes|here|just|asterisks|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 11\n assert candidate(s = \"a*|b*c|d*e*f|g*h|i*j*k|l*m*n|\") == 5\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|\") == 18\n assert candidate(s = \"mixed|*case*|UPPER|*lower*|numbers|*1234567890*|special|*!@#$%^&*()_+*|\") == 0\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 8\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\") == 25\n assert candidate(s = \"this|is*a*test|with*many*asterisks|and*no*exclusions*at*the*end*\") == 2\n assert candidate(s = \"multiple||pipes||in||a||row||with||asterisks*in||between\") == 1\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*|\") == 24\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*|\") == 13\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*|\") == 5\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|*\") == 18\n assert candidate(s = \"hello|world|*python*|programming|*|code*|\") == 3\n assert candidate(s = \"hello|world*is*great|but*this*is*not|\") == 3\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 20\n assert candidate(s = \"*|**|***|****|*****|******|*******|********|*********|**********|\") == 25\n assert candidate(s = \"no|*pipes|or|*asterisks*|here|\") == 0\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|\") == 25\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|\") == 13\n assert candidate(s = \"*middle*|pipes|*middle*|pipes|*middle*|pipes|*middle*|pipes|*middle*|pipes|\") == 10\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*|\") == 18\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*|\") == 1\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|*\") == 1\n assert candidate(s = \"nested|pipes|are|not|possible||but|this|is|how|it|could|look|if|they|were|*|*|*|*|*|*|\") == 3\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*|\") == 13\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*|*|\") == 27\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\") == 25\n assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 21\n assert candidate(s = \"longer|string|with|many|characters|and|some|pipes|and|asterisks*in*various*places|and*more|pipes|and|asterisks*at*the*end*\") == 1\n assert candidate(s = \"complex|test*case*with*mixed*characters*and*bars*and*asterisks|throughout*the*string|\") == 2\n assert candidate(s = \"single*asterisk*outside*pipes|double**asterisks*inside*pipes|triple***asterisks*outside*pipes\") == 8\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|\") == 8\n assert candidate(s = \"multiple|*pipes*|in|*one*|segment|*of*|the|*string*|should|be|handled|correctly|\") == 0\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|\") == 6\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||\") == 0\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|\") == 12\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|*|*|*|*|\") == 2\n assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 16\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|\") == 0\n assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 20\n assert candidate(s = \"||||||||||||||||||||||||||||||||||||||||||||||||||||\") == 0\n assert candidate(s = \"nested|*p*|ai|*n*|e*d|*|t*e*s*t|case|\") == 4\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countAsterisks", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countAsterisks(String s) {", "container": "Solution", "callable": "countAsterisks", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2316, "task_id": "count-unreachable-pairs-of-nodes-in-an-undirected-graph", "difficulty": "Medium", "problem_description": "You are given an integer n. There is an undirected graph with n nodes, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai and bi.\nReturn the number of pairs of different nodes that are unreachable from each other.\n \nExample 1:\n\n\nInput: n = 3, edges = [[0,1],[0,2],[1,2]]\nOutput: 0\nExplanation: There are no pairs of nodes that are unreachable from each other. Therefore, we return 0.\n\nExample 2:\n\n\nInput: n = 7, edges = [[0,2],[0,5],[2,4],[1,6],[5,4]]\nOutput: 14\nExplanation: There are 14 pairs of nodes that are unreachable from each other:\n[[0,1],[0,3],[0,6],[1,2],[1,3],[1,4],[1,5],[2,3],[2,6],[3,4],[3,5],[3,6],[4,6],[5,6]].\nTherefore, we return 14.\n\n \nConstraints:\n\n1 <= n <= 105\n0 <= edges.length <= 2 * 105\nedges[i].length == 2\n0 <= ai, bi < n\nai != bi\nThere are no repeated edges.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [3, 4]]) == 11\n assert candidate(n = 6,edges = []) == 15\n assert candidate(n = 3,edges = [[0, 1], [0, 2], [1, 2]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [2, 3]]) == 8\n assert candidate(n = 10,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 40\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [3, 4]]) == 6\n assert candidate(n = 4,edges = []) == 6\n assert candidate(n = 1,edges = []) == 0\n assert candidate(n = 10,edges = []) == 45\n assert candidate(n = 7,edges = [[0, 2], [0, 5], [2, 4], [1, 6], [5, 4]]) == 14\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9]]) == 25\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 6], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15]]) == 129\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [6, 7], [7, 8], [8, 9]]) == 33\n assert candidate(n = 16,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, 0]]) == 0\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]) == 96\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [3, 4], [4, 5], [6, 7], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24]]) == 283\n assert candidate(n = 10,edges = [[0, 1], [2, 3], [3, 4], [4, 5], [6, 7], [7, 8], [8, 9]]) == 32\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12]]) == 83\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9], [10, 11], [11, 12], [12, 13], [13, 14]]) == 75\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [8, 9], [9, 10], [11, 12], [13, 14]]) == 93\n assert candidate(n = 20,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]]) == 180\n assert candidate(n = 15,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 0]]) == 96\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15], [20, 21], [21, 22], [22, 23], [23, 24], [24, 20]]) == 250\n assert candidate(n = 15,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]]) == 0\n assert candidate(n = 50,edges = [[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]]) == 1200\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [8, 9], [9, 10], [11, 12], [13, 14]]) == 87\n assert candidate(n = 100,edges = []) == 4950\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [8, 9]]) == 31\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [4, 5], [5, 6], [7, 4]]) == 16\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 100\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 12], [12, 9], [13, 14], [14, 15], [15, 16], [16, 13], [17, 18], [18, 19], [19, 20], [20, 17], [21, 22], [22, 23], [23, 24], [24, 21]]) == 260\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [3, 6], [7, 8], [7, 9]]) == 33\n assert candidate(n = 20,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]]) == 0\n assert candidate(n = 30,edges = [[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]]) == 420\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 2], [3, 4]]) == 6\n assert candidate(n = 50,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]]) == 1035\n assert candidate(n = 100,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], [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]]) == 0\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9], [9, 10], [11, 12], [12, 13], [13, 14], [14, 7]]) == 68\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [4, 5], [6, 7], [6, 8], [6, 9]]) == 32\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [3, 4], [4, 5], [6, 7], [8, 9]]) == 37\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [11, 12], [12, 13], [13, 14]]) == 74\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 15], [18, 19], [19, 20], [20, 18], [21, 22], [22, 23], [23, 21], [24, 24]]) == 276\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [7, 8], [8, 9], [9, 10], [10, 11], [11, 7]]) == 35\n assert candidate(n = 25,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]]) == 0\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 12], [12, 9], [13, 14], [14, 15], [15, 16], [16, 13], [17, 18], [18, 19], [19, 17]]) == 159\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 36\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [4, 5], [5, 6], [7, 8]]) == 35\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9], [10, 11], [12, 13], [13, 14]]) == 89\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [5, 6], [5, 7], [6, 8], [7, 9], [10, 11], [11, 12], [12, 13], [13, 14], [15, 16], [16, 17], [17, 18], [18, 19]]) == 150\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 0\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [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]]) == 150\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [4, 5], [5, 6], [7, 8], [8, 9]]) == 33\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [7, 8], [8, 9]]) == 31\n assert candidate(n = 50,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 15], [18, 19], [19, 20], [20, 18], [21, 22], [22, 23], [23, 21], [24, 24], [25, 26], [26, 27], [27, 28], [28, 25], [29, 30], [30, 31], [31, 29], [32, 33], [33, 34], [34, 32], [35, 36], [36, 37], [37, 35], [38, 39], [39, 40], [40, 38], [41, 42], [42, 43], [43, 41], [44, 45], [45, 46], [46, 44], [47, 48], [48, 49], [49, 47]]) == 1167\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countPairs(int n, int[][] edges) {", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2317, "task_id": "maximum-xor-after-operations", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. In one operation, select any non-negative integer x and an index i, then update nums[i] to be equal to nums[i] AND (nums[i] XOR x).\nNote that AND is the bitwise AND operation and XOR is the bitwise XOR operation.\nReturn the maximum possible bitwise XOR of all elements of nums after applying the operation any number of times.\n \nExample 1:\n\nInput: nums = [3,2,4,6]\nOutput: 7\nExplanation: Apply the operation with x = 4 and i = 3, num[3] = 6 AND (6 XOR 4) = 6 AND 2 = 2.\nNow, nums = [3, 2, 4, 2] and the bitwise XOR of all the elements = 3 XOR 2 XOR 4 XOR 2 = 7.\nIt can be shown that 7 is the maximum possible bitwise XOR.\nNote that other operations may be used to achieve a bitwise XOR of 7.\nExample 2:\n\nInput: nums = [1,2,3,9,2]\nOutput: 11\nExplanation: Apply the operation zero times.\nThe bitwise XOR of all the elements = 1 XOR 2 XOR 3 XOR 9 XOR 2 = 11.\nIt can be shown that 11 is the maximum possible bitwise XOR.\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [8, 1, 4, 2, 15]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 15\n assert candidate(nums = [1, 0, 3, 2]) == 3\n assert candidate(nums = [1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1]) == 1\n assert candidate(nums = [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, 1]) == 2147483647\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 8184\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1]) == 255\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [3, 2, 4, 6]) == 7\n assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000]) == 134217712\n assert candidate(nums = [1, 2, 3, 9, 2]) == 11\n assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312, 97656, 48828, 24414, 12207, 6103, 3051, 1525, 762, 381, 190, 95, 47, 23, 11, 5, 2, 1]) == 134217727\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 31\n assert candidate(nums = [7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024]) == 2040\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == 15\n assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312, 97656, 48828, 24414, 12207, 6103, 3051, 1525, 762, 381, 190, 95, 47, 23, 11, 5, 2, 1]) == 134217727\n assert candidate(nums = [2, 4, 8, 16, 32]) == 62\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [1073741824]) == 1073741824\n assert candidate(nums = [5, 10, 15, 20, 25]) == 31\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2047\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1]) == 255\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(nums = [10, 20, 30, 40]) == 62\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]) == 2047\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 127\n assert candidate(nums = [1919810, 909405, 454702, 227351, 113675, 56837, 28418, 14209, 7104, 3552, 1776, 888, 444, 222, 111, 55, 27, 13, 6, 3, 1]) == 2097151\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]) == 2097151\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1020\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1048575\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]) == 2097151\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 255, 127, 63, 31, 15, 7, 3]) == 255\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 1048575\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303]) == 2147483647\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, 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]) == 63\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\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 1073741823\n assert candidate(nums = [2147483647, 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, 1]) == 2147483647\n assert candidate(nums = [123456789, 987654321, 135792468, 864201357, 246813579, 789123456, 369258147, 456789123, 654321987]) == 1073741823\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]) == 63\n assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312, 97656, 48828, 24414, 12207, 6103, 3051, 1525, 762, 381, 190, 95]) == 134217727\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048575]) == 1048575\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 31, 31, 37, 37, 41, 41, 43, 43]) == 63\n assert candidate(nums = [23456789, 87654321, 12345678, 45678901, 56789012, 67890123, 78901234, 34567890, 43210987, 76543210, 98765432, 21098765, 32109876, 65432109, 54321098, 43210987, 32109876, 21098765, 10987654, 98765432, 87654321, 76543210, 65432109, 54321098, 43210987, 32109876, 21098765, 10987654, 9876543, 8765432]) == 134217727\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84]) == 127\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 2047\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 65535\n assert candidate(nums = [123456789, 987654321, 456789123, 321987654, 789123456, 654321987, 1234567890, 9876543210, 4567891230, 3219876540, 7891234560, 6543219870, 12345678900, 98765432100, 45678912300, 32198765400, 78912345600, 65432198700, 123456789000, 987654321000, 456789123000, 321987654000, 789123456000, 654321987000, 1234567890000, 9876543210000, 4567891230000, 3219876540000, 7891234560000, 6543219870000]) == 17592186044415\n assert candidate(nums = [131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 262143\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 2044\n assert candidate(nums = [987654321, 123456789, 987654322, 123456790, 987654323, 123456791]) == 1071639991\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 65535\n assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240]) == 255\n assert candidate(nums = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 31\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\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 15\n assert candidate(nums = [16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767]) == 16777215\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 100661247\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1048575\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 1023\n assert candidate(nums = [134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144]) == 268173312\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, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647]) == 2147483647\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579]) == 1073741823\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888]) == 1073741823\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1023\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]) == 63\n assert candidate(nums = [18446744073709551615, 18446744073709551614, 18446744073709551613, 18446744073709551612]) == 18446744073709551615\n assert candidate(nums = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991]) == 100000255\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\n assert candidate(nums = [1048575, 1048574, 1048573, 1048572, 1048571, 1048570]) == 1048575\n assert candidate(nums = [99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111, 100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000, 5000000, 1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 50, 10]) == 134217727\n assert candidate(nums = [987654321, 246813579, 864209753, 135792468, 975318642]) == 1073676287\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543, 98765432, 87654321, 76543210, 65432109, 54321098, 43210987, 32109876, 21098765, 10987654, 9876543, 8765432, 7654321, 6543210, 5432109, 4321098, 3210987, 2109876, 1098765, 987654, 876543]) == 1073741823\n assert candidate(nums = [987654321, 2147483647, 1073741824, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608]) == 2147483647\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000, 1100000000, 1200000000, 1300000000, 1400000000, 1500000000, 1600000000, 1700000000, 1800000000, 1900000000, 2000000000, 2100000000, 2200000000, 2300000000, 2400000000, 2500000000, 2600000000, 2700000000, 2800000000, 2900000000, 3000000000]) == 4294967040\n assert candidate(nums = [123456789, 987654321, 456789123, 321654987, 654321987, 789123456, 876543219, 213456789, 345678912, 123987654, 543219876, 678912345, 432156789, 987123456, 765432189, 321987654, 891234567, 567891234, 234567891, 678912345]) == 1073741823\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312]) == 134217727\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]) == 13\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 31\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1023\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 8\n assert candidate(nums = [100000000, 90000000, 80000000, 70000000, 60000000]) == 134217600\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543]) == 1073741823\n assert candidate(nums = [123456789, 987654321, 112233445, 556677889, 998877665, 443322110, 332211009, 887766554, 223344556, 665544337]) == 1073741823\n assert candidate(nums = [234567890, 234567891, 234567892, 234567893, 234567894, 234567895]) == 234567895\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\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535]) == 2147483647\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, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2097151\n assert candidate(nums = [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 = [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]) == 2147483647\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1023\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255]) == 255\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543, 98765432, 87654321, 76543210, 65432109, 54321098, 43210987, 32109876]) == 1073741823\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]) == 1048575\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, 0, 0, 0, 0, 0, 0, 0]) == 8388607\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]) == 65535\n assert candidate(nums = [100000000, 99999999, 99999998, 99999997, 99999996]) == 100000255\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2047\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985, 999999984, 999999983, 999999982, 999999981, 999999980, 999999979, 999999978, 999999977, 999999976, 999999975, 999999974, 999999973, 999999972, 999999971]) == 1000000511\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 9000, 8000]) == 1048575\n assert candidate(nums = [8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == 16777215\n assert candidate(nums = [1073741823, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152]) == 1073741823\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\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095]) == 2147483647\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]) == 2147483647\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607]) == 2147483647\n assert candidate(nums = [23, 45, 67, 89, 111, 133, 155, 177]) == 255\n assert candidate(nums = [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, 1]) == 268435455\n assert candidate(nums = [123456789, 987654321, 1122334455, 5544332211, 678901234, 432109876, 890123456, 654321987]) == 6442450935\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]) == 1048575\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 15\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000]) == 1073737472\n assert candidate(nums = [134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256]) == 268435200\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumXOR", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumXOR(int[] nums) {", "container": "Solution", "callable": "maximumXOR", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2318, "task_id": "number-of-distinct-roll-sequences", "difficulty": "Hard", "problem_description": "You are given an integer n. You roll a fair 6-sided dice n times. Determine the total number of distinct sequences of rolls possible such that the following conditions are satisfied:\n\nThe greatest common divisor of any adjacent values in the sequence is equal to 1.\nThere is at least a gap of 2 rolls between equal valued rolls. More formally, if the value of the ith roll is equal to the value of the jth roll, then abs(i - j) > 2.\n\nReturn the total number of distinct sequences possible. Since the answer may be very large, return it modulo 109 + 7.\nTwo sequences are considered distinct if at least one element is different.\n \nExample 1:\n\nInput: n = 4\nOutput: 184\nExplanation: Some of the possible sequences are (1, 2, 3, 4), (6, 1, 2, 3), (1, 2, 3, 1), etc.\nSome invalid sequences are (1, 2, 1, 3), (1, 2, 3, 6).\n(1, 2, 1, 3) is invalid since the first and third roll have an equal value and abs(1 - 3) = 2 (i and j are 1-indexed).\n(1, 2, 3, 6) is invalid since the greatest common divisor of 3 and 6 = 3.\nThere are a total of 184 distinct sequences possible, so we return 184.\nExample 2:\n\nInput: n = 2\nOutput: 22\nExplanation: Some of the possible sequences are (1, 2), (2, 1), (3, 2).\nSome invalid sequences are (3, 6), (2, 4) since the greatest common divisor is not equal to 1.\nThere are a total of 22 distinct sequences possible, so we return 22.\n\n \nConstraints:\n\n1 <= n <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 66\n assert candidate(n = 100) == 534856607\n assert candidate(n = 4) == 184\n assert candidate(n = 10000) == 874574246\n assert candidate(n = 2) == 22\n assert candidate(n = 1) == 6\n assert candidate(n = 1000) == 497171723\n assert candidate(n = 10) == 93120\n assert candidate(n = 2000) == 784558903\n assert candidate(n = 104) == 920649565\n assert candidate(n = 5) == 516\n assert candidate(n = 20000) == 846205927\n assert candidate(n = 8000) == 366597434\n assert candidate(n = 5000) == 798977852\n assert candidate(n = 9999) == 455330915\n assert candidate(n = 20) == 996985946\n assert candidate(n = 15) == 16706688\n assert candidate(n = 6) == 1472\n assert candidate(n = 750) == 498714087\n assert candidate(n = 500) == 353640467\n assert candidate(n = 7) == 4136\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().distinctSequences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int distinctSequences(int n) {", "container": "Solution", "callable": "distinctSequences", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2319, "task_id": "check-if-matrix-is-x-matrix", "difficulty": "Easy", "problem_description": "A square matrix is said to be an X-Matrix if both of the following conditions hold:\n\nAll the elements in the diagonals of the matrix are non-zero.\nAll other elements are 0.\n\nGiven a 2D integer array grid of size n x n representing a square matrix, return true if grid is an X-Matrix. Otherwise, return false.\n \nExample 1:\n\n\nInput: grid = [[2,0,0,1],[0,3,1,0],[0,5,2,0],[4,0,0,2]]\nOutput: true\nExplanation: Refer to the diagram above. \nAn X-Matrix should have the green elements (diagonals) be non-zero and the red elements be 0.\nThus, grid is an X-Matrix.\n\nExample 2:\n\n\nInput: grid = [[5,7,0],[0,3,1],[0,5,0]]\nOutput: false\nExplanation: Refer to the diagram above.\nAn X-Matrix should have the green elements (diagonals) be non-zero and the red elements be 0.\nThus, grid is not an X-Matrix.\n\n \nConstraints:\n\nn == grid.length == grid[i].length\n3 <= n <= 100\n0 <= grid[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 0, 0], [0, 0, 0, 3], [0, 0, 4, 0], [0, 5, 0, 0]]) == False\n assert candidate(grid = [[1, 2, 0, 0], [0, 3, 1, 0], [0, 5, 2, 0], [0, 0, 0, 4]]) == False\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 5]]) == False\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 1]]) == False\n assert candidate(grid = [[5, 7, 0], [0, 3, 1], [0, 5, 0]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 2, 0, 2, 0], [0, 0, 3, 0, 0], [0, 2, 0, 2, 0], [1, 0, 0, 0, 1]]) == True\n assert candidate(grid = [[2, 0, 0, 1], [0, 3, 1, 0], [0, 5, 2, 0], [4, 0, 0, 2]]) == True\n assert candidate(grid = [[6, 0, 0, 0, 6], [0, 7, 0, 7, 0], [0, 0, 8, 0, 0], [0, 7, 0, 7, 0], [6, 0, 0, 0, 6]]) == True\n assert candidate(grid = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]) == False\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == False\n assert candidate(grid = [[0, 1, 0], [1, 2, 1], [0, 1, 0]]) == False\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == False\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == True\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]]) == True\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 2, 0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 3, 0, 0, 0, 0, 3, 0, 0], [0, 0, 0, 4, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 5, 0, 0, 0, 0], [0, 0, 0, 0, 5, 5, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 4, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 3, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 2, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 2], [0, 3, 0, 0, 0, 0, 5, 0], [0, 0, 6, 0, 0, 8, 0, 0], [0, 0, 0, 9, 10, 0, 0, 0], [0, 0, 0, 11, 12, 0, 0, 0], [0, 0, 13, 0, 0, 14, 0, 0], [0, 15, 0, 0, 0, 0, 16, 0], [17, 0, 0, 0, 0, 0, 0, 18]]) == True\n assert candidate(grid = [[5, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 5]]) == False\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 3, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 5, 0, 0, 0, 0], [0, 6, 0, 0, 0, 0, 0], [7, 0, 0, 0, 0, 0, 0]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 1, 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], [0, 0, 0, 0, 0, 6]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5], [0, 6, 0, 7, 0], [0, 0, 8, 0, 0], [0, 9, 0, 10, 0], [11, 0, 0, 0, 12]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [0, 8, 0, 0, 0, 9, 0], [0, 0, 10, 0, 11, 0, 0], [0, 0, 0, 12, 0, 0, 0], [0, 0, 13, 0, 14, 0, 0], [0, 15, 0, 0, 0, 16, 0], [17, 0, 0, 0, 0, 0, 18]]) == False\n assert candidate(grid = [[2, 0, 0, 0, 3], [0, 5, 0, 6, 0], [0, 0, 7, 0, 0], [0, 8, 0, 9, 0], [4, 0, 0, 0, 1]]) == True\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]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 3], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [6, 0, 0, 0, 0, 2]]) == False\n assert candidate(grid = [[7, 0, 0, 0, 0, 1], [0, 4, 0, 0, 4, 0], [0, 0, 9, 0, 0, 0], [0, 0, 0, 6, 0, 0], [0, 8, 0, 0, 7, 0], [2, 0, 0, 0, 0, 9]]) == False\n assert candidate(grid = [[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]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 2, 0, 0, 0, 2, 0], [0, 0, 3, 0, 3, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 5, 0, 5, 0, 0], [0, 6, 0, 0, 0, 6, 0], [7, 0, 0, 0, 0, 0, 7]]) == True\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 1], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [1, 0, 0, 0, 0, 1]]) == False\n assert candidate(grid = [[7, 0, 0, 0, 0, 0], [0, 6, 0, 0, 0, 0], [0, 0, 5, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 3, 0], [0, 0, 0, 0, 0, 2]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 2, 0, 0, 0, 0, 0, 2, 0], [0, 0, 3, 0, 0, 0, 3, 0, 0], [0, 0, 0, 4, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 4, 0, 4, 0, 0, 0], [0, 0, 3, 0, 0, 0, 3, 0, 0], [0, 2, 0, 0, 0, 0, 0, 2, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 1], [0, 1, 0, 1, 0]]) == False\n assert candidate(grid = [[6, 0, 0, 0, 0], [0, 7, 0, 0, 0], [0, 0, 8, 0, 0], [0, 0, 0, 9, 0], [0, 0, 0, 0, 10]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 7], [0, 2, 0, 0, 0, 8, 0], [0, 0, 3, 0, 9, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 10, 0, 5, 0, 0], [0, 11, 0, 0, 0, 6, 0], [12, 0, 0, 0, 0, 0, 13]]) == True\n assert candidate(grid = [[6, 0, 0, 0, 1], [0, 7, 0, 3, 0], [0, 0, 8, 0, 0], [0, 9, 0, 5, 0], [2, 0, 0, 0, 4]]) == True\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, 4, 0, 0], [0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 1]]) == False\n assert candidate(grid = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]]) == False\n assert candidate(grid = [[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], [0, 0, 0, 0, 0, 6]]) == False\n assert candidate(grid = [[9, 0, 0, 0, 0, 0, 0, 0], [0, 8, 0, 0, 0, 0, 0, 0], [0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 0, 0, 3, 0], [0, 0, 0, 0, 0, 0, 0, 2]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]) == False\n assert candidate(grid = [[1, 2, 0, 0, 4], [3, 0, 5, 0, 6], [0, 7, 0, 8, 0], [9, 0, 10, 0, 11], [12, 0, 0, 13, 14]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 2], [0, 3, 0, 5, 0], [0, 0, 4, 0, 0], [0, 6, 0, 7, 0], [8, 0, 0, 0, 9]]) == True\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 0, 0, 0], [0, 9, 0, 0, 0, 0, 0, 0, 0], [0, 0, 8, 0, 0, 0, 0, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 0, 0, 0, 3, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2]]) == False\n assert candidate(grid = [[5, 0, 0, 0, 0, 0], [0, 4, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 9]]) == False\n assert candidate(grid = [[5, 0, 0, 0, 0], [0, 6, 0, 0, 0], [0, 0, 7, 0, 0], [0, 0, 0, 8, 0], [0, 0, 0, 0, 9]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 2, 0, 0, 1], [0, 0, 3, 0, 0], [0, 0, 0, 2, 0], [1, 0, 0, 0, 1]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 9, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 3, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 2], [0, 2, 0, 3, 0], [0, 0, 4, 0, 0], [0, 5, 0, 6, 0], [7, 0, 0, 0, 8]]) == True\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 14], [0, 2, 0, 0, 0, 0, 15, 0], [0, 0, 3, 0, 0, 16, 0, 0], [0, 0, 0, 4, 17, 0, 0, 0], [0, 0, 0, 18, 5, 0, 0, 0], [0, 0, 19, 0, 0, 6, 0, 0], [0, 20, 0, 0, 0, 0, 7, 0], [21, 0, 0, 0, 0, 0, 0, 8]]) == True\n assert candidate(grid = [[1, 0, 0, 0, 0, 5], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [6, 0, 0, 0, 0, 7]]) == False\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]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 2], [0, 2, 0, 0, 0, 0, 3, 0], [0, 0, 3, 0, 0, 4, 0, 0], [0, 0, 0, 4, 5, 0, 0, 0], [0, 0, 0, 5, 4, 0, 0, 0], [0, 0, 4, 0, 0, 3, 0, 0], [0, 3, 0, 0, 0, 0, 2, 0], [2, 0, 0, 0, 0, 0, 0, 1]]) == True\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, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 1], [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], [1, 0, 0, 0, 0, 0, 1]]) == False\n assert candidate(grid = [[12, 0, 0, 0, 0, 0], [0, 13, 0, 0, 0, 0], [0, 0, 14, 0, 0, 0], [0, 0, 0, 15, 0, 0], [0, 0, 0, 0, 16, 0], [0, 0, 0, 0, 0, 17]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 9], [0, 2, 0, 0, 0, 0, 8, 0], [0, 0, 3, 0, 0, 7, 0, 0], [0, 0, 0, 4, 6, 0, 0, 0], [0, 0, 0, 6, 4, 0, 0, 0], [0, 0, 7, 0, 0, 3, 0, 0], [0, 8, 0, 0, 0, 0, 2, 0], [9, 0, 0, 0, 0, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]) == False\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]]) == False\n assert candidate(grid = [[5, 0, 0, 0, 0, 0, 7], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [9, 0, 0, 0, 0, 0, 10]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 2, 0, 0, 1], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 1, 0, 0, 5]]) == False\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [1, 0, 2, 0, 0, 0, 0], [0, 2, 0, 3, 0, 0, 0], [0, 0, 3, 0, 4, 0, 0], [0, 0, 0, 4, 0, 5, 0], [0, 0, 0, 0, 5, 0, 6], [0, 0, 0, 0, 0, 6, 0]]) == False\n assert candidate(grid = [[5, 0, 0, 0, 0, 0, 0, 0, 0, 2], [0, 4, 0, 0, 0, 0, 0, 0, 3, 0], [0, 0, 3, 0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 2, 0, 0, 5, 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, 5, 0, 0, 2, 0, 0, 0], [0, 0, 4, 0, 0, 0, 0, 3, 0, 0], [0, 3, 0, 0, 0, 0, 0, 0, 4, 0], [2, 0, 0, 0, 0, 0, 0, 0, 0, 5]]) == False\n assert candidate(grid = [[7, 0, 0, 0, 0], [0, 8, 0, 0, 0], [0, 0, 9, 0, 0], [0, 0, 0, 10, 0], [0, 0, 0, 0, 11]]) == False\n assert candidate(grid = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 2, 0], [0, 0, 0, 3, 0, 0], [0, 0, 4, 0, 0, 0], [0, 5, 0, 0, 0, 0], [6, 0, 0, 0, 0, 0]]) == False\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]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 1, 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]]) == False\n assert candidate(grid = [[0, 0, 0, 0, 1], [0, 0, 0, 2, 0], [0, 0, 3, 0, 0], [0, 4, 0, 0, 0], [5, 0, 0, 0, 0]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 0, 0, 0, 5], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [6, 0, 0, 0, 1]]) == False\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]]) == False\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().checkXMatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean checkXMatrix(int[][] grid) {", "container": "Solution", "callable": "checkXMatrix", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2320, "task_id": "count-number-of-ways-to-place-houses", "difficulty": "Medium", "problem_description": "There is a street with n * 2 plots, where there are n plots on each side of the street. The plots on each side are numbered from 1 to n. On each plot, a house can be placed.\nReturn the number of ways houses can be placed such that no two houses are adjacent to each other on the same side of the street. Since the answer may be very large, return it modulo 109 + 7.\nNote that if a house is placed on the ith plot on one side of the street, a house can also be placed on the ith plot on the other side of the street.\n \nExample 1:\n\nInput: n = 1\nOutput: 4\nExplanation: \nPossible arrangements:\n1. All plots are empty.\n2. A house is placed on one side of the street.\n3. A house is placed on the other side of the street.\n4. Two houses are placed, one on each side of the street.\n\nExample 2:\n\n\nInput: n = 2\nOutput: 9\nExplanation: The 9 possible arrangements are shown in the diagram above.\n\n \nConstraints:\n\n1 <= n <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 25\n assert candidate(n = 100) == 20522904\n assert candidate(n = 10000) == 402613600\n assert candidate(n = 2) == 9\n assert candidate(n = 1) == 4\n assert candidate(n = 1000) == 500478595\n assert candidate(n = 10) == 20736\n assert candidate(n = 4000) == 984988507\n assert candidate(n = 7000) == 750848153\n assert candidate(n = 2000) == 329423452\n assert candidate(n = 7500) == 39764836\n assert candidate(n = 50) == 245481867\n assert candidate(n = 5) == 169\n assert candidate(n = 3000) == 511358621\n assert candidate(n = 30) == 30066266\n assert candidate(n = 4) == 64\n assert candidate(n = 1001) == 307206160\n assert candidate(n = 8) == 3025\n assert candidate(n = 250) == 172820552\n assert candidate(n = 8000) == 823868594\n assert candidate(n = 5000) == 851109891\n assert candidate(n = 9999) == 459963766\n assert candidate(n = 20) == 313679521\n assert candidate(n = 15) == 2550409\n assert candidate(n = 2500) == 968650195\n assert candidate(n = 9000) == 641644802\n assert candidate(n = 200) == 450435314\n assert candidate(n = 9) == 7921\n assert candidate(n = 6) == 441\n assert candidate(n = 6000) == 337759600\n assert candidate(n = 500) == 164765197\n assert candidate(n = 7) == 1156\n assert candidate(n = 25) == 580030458\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countHousePlacements", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countHousePlacements(int n) {", "container": "Solution", "callable": "countHousePlacements", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2321, "task_id": "maximum-score-of-spliced-array", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2, both of length n.\nYou can choose two integers left and right where 0 <= left <= right < n and swap the subarray nums1[left...right] with the subarray nums2[left...right].\n\nFor example, if nums1 = [1,2,3,4,5] and nums2 = [11,12,13,14,15] and you choose left = 1 and right = 2, nums1 becomes [1,12,13,4,5] and nums2 becomes [11,2,3,14,15].\n\nYou may choose to apply the mentioned operation once or not do anything.\nThe score of the arrays is the maximum of sum(nums1) and sum(nums2), where sum(arr) is the sum of all the elements in the array arr.\nReturn the maximum possible score.\nA subarray is a contiguous sequence of elements within an array. arr[left...right] denotes the subarray that contains the elements of nums between indices left and right (inclusive).\n \nExample 1:\n\nInput: nums1 = [60,60,60], nums2 = [10,90,10]\nOutput: 210\nExplanation: Choosing left = 1 and right = 1, we have nums1 = [60,90,60] and nums2 = [10,60,10].\nThe score is max(sum(nums1), sum(nums2)) = max(210, 80) = 210.\nExample 2:\n\nInput: nums1 = [20,40,20,70,30], nums2 = [50,20,50,40,20]\nOutput: 220\nExplanation: Choosing left = 3, right = 4, we have nums1 = [20,40,20,40,20] and nums2 = [50,20,50,70,30].\nThe score is max(sum(nums1), sum(nums2)) = max(140, 220) = 220.\n\nExample 3:\n\nInput: nums1 = [7,11,13], nums2 = [1,1,1]\nOutput: 31\nExplanation: We choose not to swap any subarray.\nThe score is max(sum(nums1), sum(nums2)) = max(31, 3) = 31.\n\n \nConstraints:\n\nn == nums1.length == nums2.length\n1 <= n <= 105\n1 <= nums1[i], nums2[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [20, 40, 20, 70, 30],nums2 = [50, 20, 50, 40, 20]) == 220\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 150\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10000, 10000, 10000, 10000, 10000]) == 50000\n assert candidate(nums1 = [100, 200, 300],nums2 = [300, 200, 100]) == 800\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 15\n assert candidate(nums1 = [5000, 5000, 5000],nums2 = [5000, 5000, 5000]) == 15000\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == 8\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 30\n assert candidate(nums1 = [5000, 5000, 5000, 5000, 5000],nums2 = [6000, 6000, 6000, 6000, 6000]) == 30000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 21\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5]) == 25\n assert candidate(nums1 = [10000, 10000, 10000],nums2 = [1, 1, 1]) == 30000\n assert candidate(nums1 = [60, 60, 60],nums2 = [10, 90, 10]) == 210\n assert candidate(nums1 = [1, 1, 1],nums2 = [10000, 10000, 10000]) == 30000\n assert candidate(nums1 = [7, 11, 13],nums2 = [1, 1, 1]) == 31\n assert candidate(nums1 = [9, 8, 7],nums2 = [1, 2, 3]) == 24\n assert candidate(nums1 = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 120\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5]) == 25\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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 310\n assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000],nums2 = [5000, 5000, 5000, 5000, 5000]) == 50000\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 2, 30, 4, 50, 6, 70, 8, 90, 10]) == 280\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]) == 5500\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 800\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 55000\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums1 = [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]) == 30\n assert candidate(nums1 = [10000, 1, 10000, 1, 10000],nums2 = [1, 10000, 1, 10000, 1]) == 40001\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 = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 200000\n assert candidate(nums1 = [5, 1, 3, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 104\n assert candidate(nums1 = [5000, 3000, 1000, 500, 250],nums2 = [250, 500, 1000, 3000, 5000]) == 17000\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 176\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [1, 6, 11, 16, 21]) == 75\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 42\n assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000],nums2 = [9999, 9999, 9999, 9999, 9999]) == 50000\n assert candidate(nums1 = [9999, 9999, 9999, 9999, 9999],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50005\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 45\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],nums2 = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 3100\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999]) == 99990\n assert candidate(nums1 = [5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5]) == 41\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 150000\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 58\n assert candidate(nums1 = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],nums2 = [1, 10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000]) == 60004\n assert candidate(nums1 = [10000, 9000, 8000, 7000, 6000],nums2 = [100, 200, 300, 400, 500]) == 40000\n assert candidate(nums1 = [5000, 2000, 3000, 4000, 1000],nums2 = [1000, 4000, 3000, 2000, 5000]) == 19000\n assert candidate(nums1 = [9999, 9998, 9997, 9996, 9995],nums2 = [1, 2, 3, 4, 5]) == 49985\n assert candidate(nums1 = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 36\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]) == 80\n assert candidate(nums1 = [5000, 5000, 5000, 5000, 5000],nums2 = [10000, 10000, 10000, 10000, 10000]) == 50000\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],nums2 = [9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000]) == 100000\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 400\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 100000\n assert candidate(nums1 = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50000\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]) == 550\n assert candidate(nums1 = [100, 100, 100, 100, 100],nums2 = [200, 200, 200, 200, 200]) == 1000\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [5000, 4000, 3000, 2000, 1000]) == 21000\n assert candidate(nums1 = [5000, 5000, 5000, 5000, 5000],nums2 = [5000, 5000, 5000, 5000, 5000]) == 25000\n assert candidate(nums1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000\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 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 40\n assert candidate(nums1 = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],nums2 = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 604\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 100\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 26\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(nums1 = [1, 2, 3, 4, 5, 100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100, 5, 4, 3, 2, 1]) == 3000\n assert candidate(nums1 = [1, 10, 100, 1000, 10000],nums2 = [10000, 1000, 100, 10, 1]) == 22100\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5500\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n assert candidate(nums1 = [100, 50, 30, 20, 10],nums2 = [10, 20, 30, 50, 100]) == 330\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [100, 90, 80, 70, 60]) == 400\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]) == 55\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]) == 210\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 8000\n assert candidate(nums1 = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],nums2 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 80000\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [10, 8, 6, 4, 2]) == 40\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 60\n assert candidate(nums1 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5]) == 120\n assert candidate(nums1 = [10000, 1, 1, 1, 10000],nums2 = [1, 10000, 10000, 1, 1]) == 40001\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == 2100\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],nums2 = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1760\n assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000],nums2 = [1, 1, 1, 1, 1]) == 50000\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [1, 2, 3, 4, 5]) == 15000\n assert candidate(nums1 = [1, 1, 1, 1, 1, 10000],nums2 = [10000, 1, 1, 1, 1, 1]) == 20004\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maximumsSplicedArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumsSplicedArray(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "maximumsSplicedArray", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2322, "task_id": "minimum-score-after-removals-on-a-tree", "difficulty": "Hard", "problem_description": "There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.\nYou are given a 0-indexed integer array nums of length n where nums[i] represents the value of the ith node. You are also 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.\nRemove two distinct edges of the tree to form three connected components. For a pair of removed edges, the following steps are defined:\n\nGet the XOR of all the values of the nodes for each of the three components respectively.\nThe difference between the largest XOR value and the smallest XOR value is the score of the pair.\n\n\nFor example, say the three components have the node values: [4,5,7], [1,9], and [3,3,3]. The three XOR values are 4 ^ 5 ^ 7 = 6, 1 ^ 9 = 8, and 3 ^ 3 ^ 3 = 3. The largest XOR value is 8 and the smallest XOR value is 3. The score is then 8 - 3 = 5.\n\nReturn the minimum score of any possible pair of edge removals on the given tree.\n \nExample 1:\n\n\nInput: nums = [1,5,5,4,11], edges = [[0,1],[1,2],[1,3],[3,4]]\nOutput: 9\nExplanation: The diagram above shows a way to make a pair of removals.\n- The 1st component has nodes [1,3,4] with values [5,4,11]. Its XOR value is 5 ^ 4 ^ 11 = 10.\n- The 2nd component has node [0] with value [1]. Its XOR value is 1 = 1.\n- The 3rd component has node [2] with value [5]. Its XOR value is 5 = 5.\nThe score is the difference between the largest and smallest XOR value which is 10 - 1 = 9.\nIt can be shown that no other pair of removals will obtain a smaller score than 9.\n\nExample 2:\n\n\nInput: nums = [5,5,2,4,4,2], edges = [[0,1],[1,2],[5,2],[4,3],[1,3]]\nOutput: 0\nExplanation: The diagram above shows a way to make a pair of removals.\n- The 1st component has nodes [3,4] with values [4,4]. Its XOR value is 4 ^ 4 = 0.\n- The 2nd component has nodes [1,0] with values [5,5]. Its XOR value is 5 ^ 5 = 0.\n- The 3rd component has nodes [2,5] with values [2,2]. Its XOR value is 2 ^ 2 = 0.\nThe score is the difference between the largest and smallest XOR value which is 0 - 0 = 0.\nWe cannot obtain a smaller score than 0.\n\n \nConstraints:\n\nn == nums.length\n3 <= n <= 1000\n1 <= nums[i] <= 108\nedges.length == n - 1\nedges[i].length == 2\n0 <= ai, bi < n\nai != bi\nedges represents a valid tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 5, 5, 4, 11],edges = [[0, 1], [1, 2], [1, 3], [3, 4]]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50],edges = [[0, 1], [0, 2], [0, 3], [3, 4]]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(nums = [5, 5, 2, 4, 4, 2],edges = [[0, 1], [1, 2], [5, 2], [4, 3], [1, 3]]) == 0\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [3, 6]]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300],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]]) == 336\n assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312, 97656, 48828, 24414, 12207],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]]) == 67079550\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 36\n assert candidate(nums = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10]]) == 3\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],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]]) == 2\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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]]) == 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],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]]) == 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],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]]) == 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],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]]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],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]]) == 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],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]]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9]]) == 1\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 36\n assert candidate(nums = [9, 3, 5, 2, 7, 1, 8, 6, 4],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8]]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8]]) == 16\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135],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]]) == 75\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],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]]) == 0\n assert candidate(nums = [1, 3, 2, 5, 4, 6, 7, 9, 8, 10, 12, 11, 13, 15, 14, 17, 16, 19, 18, 20],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [2, 6], [6, 7], [4, 8], [8, 9], [8, 10], [5, 11], [11, 12], [11, 13], [10, 14], [14, 15], [14, 16], [7, 17], [17, 18], [18, 19]]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],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]]) == 20\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],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]]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 36\n assert candidate(nums = [100000000, 99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 9915534\n assert candidate(nums = [1, 5, 3, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],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]]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\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],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]]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10]]) == 552\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums", "edges"], "leetcode_dataset_entry_point": "Solution().minimumScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumScore(int[] nums, int[][] edges) {", "container": "Solution", "callable": "minimumScore", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "edges", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2325, "task_id": "decode-the-message", "difficulty": "Easy", "problem_description": "You are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows:\n\nUse the first appearance of all 26 lowercase English letters in key as the order of the substitution table.\nAlign the substitution table with the regular English alphabet.\nEach letter in message is then substituted using the table.\nSpaces ' ' are transformed to themselves.\n\n\nFor example, given key = \"happy boy\" (actual key would have at least one instance of each letter in the alphabet), we have the partial substitution table of ('h' -> 'a', 'a' -> 'b', 'p' -> 'c', 'y' -> 'd', 'b' -> 'e', 'o' -> 'f').\n\nReturn the decoded message.\n \nExample 1:\n\n\nInput: key = \"the quick brown fox jumps over the lazy dog\", message = \"vkbs bs t suepuv\"\nOutput: \"this is a secret\"\nExplanation: The diagram above shows the substitution table.\nIt is obtained by taking the first appearance of each letter in \"the quick brown fox jumps over the lazy dog\".\n\nExample 2:\n\n\nInput: key = \"eljuxhpwnyrdgtqkviszcfmabo\", message = \"zwx hnfx lqantp mnoeius ycgk vcnjrdb\"\nOutput: \"the five boxing wizards jump quickly\"\nExplanation: The diagram above shows the substitution table.\nIt is obtained by taking the first appearance of each letter in \"eljuxhpwnyrdgtqkviszcfmabo\".\n\n \nConstraints:\n\n26 <= key.length <= 2000\nkey consists of lowercase English letters and ' '.\nkey contains every letter in the English alphabet ('a' to 'z') at least once.\n1 <= message.length <= 2000\nmessage consists of lowercase English letters and ' '.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"cba zyx\") == \"xyz abc\"\n assert candidate(key = \"a quick movement of the enemy will jeopardize five gunboats\",message = \"yfcj myj pyjl ufcj myj pyjl ufcj myj pyjl\") == \"omer gor sorq cmer gor sorq cmer gor sorq\"\n assert candidate(key = \"the five boxing wizards jump quickly on this yellow pig\",message = \"jhxuh lqdj efxgh lpuaz fxdyjzjw\") == \"rbisb yvpr cdikb yusnm dipzrmrl\"\n assert candidate(key = \"dvhfujngcpqxlwokzriebastmy\",message = \"mwtiaz azr\") == \"ynxsvq vqr\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"xyz abc\") == \"xyz abc\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"vkbs bs t suepuv\") == \"this is a secret\"\n assert candidate(key = \"byvzkgxfnqmpalwodjtrshceui\",message = \"xsm wv zmz\") == \"guk oc dkd\"\n assert candidate(key = \"wmtresuavhigdcbfykjqploxzn\",message = \"lfnlccyvmdg\") == \"vpzvnnqibml\"\n assert candidate(key = \"zabcdefghijklmnopqrstuvwxy\",message = \"sl rfc zdf\") == \"tm sgd aeg\"\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"mlkjhgfedcbazyxwvutsrqpon\") == \"nopqstuvwxyzabcdefghijklm\"\n assert candidate(key = \"eljuxhpwnyrdgtqkviszcfmabo\",message = \"zwx hnfx lqantp mnoeius ycgk vcnjrdb\") == \"the five boxing wizards jump quickly\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"z x c v\") == \"z x c v\"\n assert candidate(key = \"gysrnhxvaofcedwmltukipjbqz\",message = \"gigv symykgl igxvxjxg\") == \"auah cbpbtaq uaghgwga\"\n assert candidate(key = \"phinxajsgkrzcwvltqbdemoufy\",message = \"xvo wv pmj\") == \"eow no avg\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"zaoymnbxcqrljtheifkgdvspwu\") == \"zaoymnbxcqrljtheifkgdvspwu\"\n assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"gsv jfrxp yildm ulc\") == \"olw qnduj fhsmz gsv\"\n assert candidate(key = \"the five boxing wizards jump quickly on this june day\",message = \"ymj lvfx sflhzymhs vxlw wjymjlvfx sflhzymhs\") == \"ztr yfdi qdybmztbq fiyl lrztryfdi qdybmztbq\"\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt\") == \"thequ ickbr ownfo xjump sover thela zydog\"\n assert candidate(key = \"dfghjklwcvxziomnpqrustyabe\",message = \"kckd ykky\") == \"fifa wffw\"\n assert candidate(key = \"mnychdpbxofl wgviakjuzterqs\",message = \"irhvmvccsjb\") == \"pxeoaoddzsh\"\n assert candidate(key = \"pack my box with five dozen liquor jugs\",message = \"xujf qv zgy jxpx qne nfgqj sraju\") == \"ivxn uo ryf xiai usp snyux zwbxv\"\n assert candidate(key = \"mwp dhxjzvcqrkbyanflstguoei\",message = \"di vccvmr wv czebwqha wv iv lvyrj\") == \"dz ijjial bi jhynbkep bi zi siolg\"\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"a b c d\") == \"z y x w\"\n assert candidate(key = \"the five boxing wizards jump quickly\",message = \"fmwp vifd ttp xosmead\") == \"dtlu fedp aau ihqtcnp\"\n assert candidate(key = \"vuqangfkswjpryxtdmzobhcile\",message = \"wfn yv yfcv\") == \"jge na ngwa\"\n assert candidate(key = \"abcdefghijk lmnopqrstuvwxyz\",message = \"eiqhw fjq hwdq\") == \"eiqhw fjq hwdq\"\n assert candidate(key = \"a quick movement of the enemy will jeopardize five gunboats\",message = \"zruog glhvg frp fvdw zl glcgv\") == \"vtchw wqniw mts miup vq wqewi\"\n assert candidate(key = \"thejumpsquickbrownfoxoverlazydog\",message = \"svhjyjsiqphsjudprvcbgijz\") == \"htbdxdhjigbhdeygntkmzjdw\"\n assert candidate(key = \"ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az\",message = \"qz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz\") == \"qz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz\"\n assert candidate(key = \"swzybfrxlnaoumdgtqivhjkpce\",message = \"flgxswdliefyirukyoaqmpjc\") == \"fiphaboiszfdsgmwdlkrnxvy\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"qruqz efn nhr htyq\") == \"djedw cnm mbj baxd\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"xibohu uvp xibohu\") == \"ofikbe etr ofikbe\"\n assert candidate(key = \"abcd efgh ijkl mnop qrst uvwx yz\",message = \"vuwx yz abcd ef\") == \"vuwx yz abcd ef\"\n assert candidate(key = \"gymnopqrstuvwxzabcdefhiljk\",message = \"xqmgq zm zmjy\") == \"ngcag oc ocyb\"\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"yxe xe xe\") == \"bcv cv cv\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",message = \"abc def abc\") == \"abc def abc\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"vxp qpy o\") == \"vxp qpy o\"\n assert candidate(key = \"jumps over the lazy dog quick brown fox\",message = \"pvuzr cgviy ojizv bxz cfiwz nqzsx vgrb\") == \"dgbni tqgso fasng vzn tyswn xrnez gqiv\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"xqf\") == \"odn\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"gfn\") == \"znm\"\n assert candidate(key = \"pzucfelxwyabqomtjirdnsvhgk\",message = \"kwj kwi kwv wkv\") == \"ziq zir ziw izw\"\n assert candidate(key = \"fmwtkujhpnobxigcsqrzydalve\",message = \"fyh fyt fyv yfj\") == \"auh aud auy uag\"\n assert candidate(key = \"abcdefghij klmnopqrstuvwxyz\",message = \"qzcfj nx ud qzcfj\") == \"qzcfj nx ud qzcfj\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx x\") == \"xpo o\"\n assert candidate(key = \"jumps over lazy dogs quick brown fox the this\",message = \"yjiwxtw vqzj spwq ovbxc yoz qjxv\") == \"maquxyu gpla edup fgtxr mfl paxg\"\n assert candidate(key = \"jklmnopqrstuvwxyzabcdefghi\",message = \"frg fmh gfn\") == \"wix wdy xwe\"\n assert candidate(key = \"zabcdefghijklmnopqrstuvwxy\",message = \"qxy xyx yxq\") == \"ryz yzy zyr\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dog and the quick brown fox jumps over the lazy dog\",message = \"vkbs bs t suepuv\") == \"this is a secret\"\n assert candidate(key = \"ekmflgdqvzntowyhxuspaibrcj\",message = \"jbs xut hig\") == \"zws qrl pvf\"\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"iyh uhy l\") == \"rbs fsb o\"\n assert candidate(key = \"vwxymnbcdfghjklqropstuzaike\",message = \"vcp o cv vcp\") == \"ahs r ha ahs\"\n assert candidate(key = \"ajfzldkgotmhrvwsypnqicxebu\",message = \"oxt oxi oxd xot\") == \"iwj iwu iwf wij\"\n assert candidate(key = \"jklmnopqrstuvwxyzabcdefghi\",message = \"wfn yv yfcv\") == \"nwe pm pwtm\"\n assert candidate(key = \"tevosjhbnyxrgqkfaumzilwpcd\",message = \"npu gpm gpy lgg\") == \"ixr mxs mxj vmm\"\n assert candidate(key = \"mnbvcxzlkjhgfdsapoiuytrewq\",message = \"hfu q jhu\") == \"kmt z jkt\"\n assert candidate(key = \"asdfghjklqwertyuiopzxcvbnm\",message = \"yqz dpy o\") == \"ojt cso r\"\n assert candidate(key = \"qbnvgjlftscxkouwamdphzreiy\",message = \"umr urv urm pyz\") == \"orw owd owr tzv\"\n assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"zqj dpy o\") == \"taq mjf i\"\n assert candidate(key = \"five boxing wizards jump quickly on this lazy dog\",message = \"qzyc yvzctv yxqjvzq yjiwxtw on qjxv yoj\") == \"tkxu xckuyc xgtpckt xpbjgyj fh tpgc xfp\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"c e\") == \"g c\"\n assert candidate(key = \"abcdefghizjklmnopqrstuvwxy\",message = \"lii eil eil\") == \"mii eim eim\"\n assert candidate(key = \"vxznpqjwoefkytlimrdhaguscb\",message = \"tyf iy tf\") == \"nmk pm nk\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"sw uqz\") == \"sl edw\"\n assert candidate(key = \"jxwtrklivnpmhudsfgcayzbeoq\",message = \"kcfizgv zr ocfv\") == \"fsqhvri ve ysqi\"\n assert candidate(key = \"lazy dogs quick brown fox jumps over the this\",message = \"vqzj spwq ovbxc yjiwxtw vqzj qjxv\") == \"wict hvpi fwnsl dtkpsyp wict itsw\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx z\") == \"xpo w\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"mlml qmf lml gmgg\") == \"mlml qmf lml gmgg\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"vz\") == \"tw\"\n assert candidate(key = \"dbrujxfgzvcotwiympnslakqhe\",message = \"kmqs ks u kqsebs\") == \"wqxt wt d wxtzbt\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"wqiv xi sqin sqin\") == \"ldft of sdfm sdfm\"\n assert candidate(key = \"dtjgsvyzxpkbfqwulcmohraeni\",message = \"obr obn oti atn\") == \"tlv tly tbz wby\"\n assert candidate(key = \"abcdefghijk lmnopqrstuvwxyz\",message = \"svil km ybgu bg ujr krkhi yjr cvvux\") == \"svil km ybgu bg ujr krkhi yjr cvvux\"\n assert candidate(key = \"the quick brown fox jumps over lazy dogs\",message = \"mht zrs xqf ovkqvoq ngyu kgxqj bpxc\") == \"qba wjs odn kthdtkd mzxe hzodp irog\"\n assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"jyq zq o\") == \"qfa ta i\"\n assert candidate(key = \"gibrfqotdhewakjyzlxmvncpus\",message = \"yxh lo loxhy\") == \"psj rg rgsjp\"\n assert candidate(key = \"mnopqrstuvwxyzabcdefghijkl\",message = \"aov eovm eovm\") == \"ocj scja scja\"\n assert candidate(key = \"zxvtrqponmlkjihgfedcbazyw\",message = \"ajc eajc eajc\") == \"vmt rvmt rvmt\"\n assert candidate(key = \"gfedcbauioplkjhzyxwvtsrqmn\",message = \"ixv yxv oxv\") == \"irt qrt jrt\"\n assert candidate(key = \"xyzabcdefghijklmnopqrstuvw\",message = \"wvf v fv\") == \"zyi y iy\"\n assert candidate(key = \"abc def ghijk lmnop qrst uvwxyz\",message = \"nvmjy nbsytw\") == \"nvmjy nbsytw\"\n assert candidate(key = \"eljuxhpwnyrdgtqkviszcfmabo\",message = \"ihd hsih xihw gh hsi\") == \"rfl fsrf erfh mf fsr\"\n assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"zqv qv q\") == \"mdi di d\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"qytz nwt zwt\") == \"dxaw mla wla\"\n assert candidate(key = \"quick brown fox jumps over the lazy dog and the quick brown fox jumps\",message = \"vxw aov g pufa ohq\") == \"qli vhq z obkv hta\"\n assert candidate(key = \"vbnmxczasdfghjklpoiuytrewq\",message = \"vkbs bs t suepuv\") == \"aobi bi v itxqta\"\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"yvc zc yz\") == \"bex ax ba\"\n assert candidate(key = \"azbycxdwevfugthrskjqplomni\",message = \"tqppf ptd je\") == \"ntuuk ung si\"\n assert candidate(key = \"xylophone qwertyuiop asdfghjklz cvbnm\",message = \"cvmu cvxqv\") == \"wxzm wxaix\"\n assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"lqtfw xtg twkxq\") == \"saenb ueo ebrua\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx v\") == \"xpo t\"\n assert candidate(key = \"nmqpviwedklxzfgrctuhyjasob\",message = \"ohc oha ohu voh\") == \"ytq ytw yts eyt\"\n assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"izk zkh bva jnfrdq\") == \"vmx mxu oin waseqd\"\n assert candidate(key = \"quick brown fox jumps over the lazy dog\",message = \"rwjsi exmti gsrhri zv wimtix egzewy\") == \"gimpc rlnsc zpgtgc wq icnscl rzwrix\"\n assert candidate(key = \"lazy dogs jumps over the quick brown fox the\",message = \"vqzj yjiwxtw spwq yoj spwq ovbxc yoz\") == \"mrci diswzpw hlwr dfi hlwr fmvzt dfc\"\n assert candidate(key = \"mnopqrstuvwxyzabcdefghijkl\",message = \"mud gct gct\") == \"air uqh uqh\"\n assert candidate(key = \"lazy dogs jumps quickly over the brown fox and\",message = \"vqzj yjiwxtw spwq yoj ovbxc yoz\") == \"qmci dinwztw hlwm dfi fqvzo dfc\"\n assert candidate(key = \"vzhofucmlnjqbdspartexwiykg\",message = \"dpy ld o yv\") == \"npx in d xa\"\n assert candidate(key = \"mnbvcxzlkjhgfdsapoiuytrewq\",message = \"cv lpcv\") == \"ed hqed\"\n assert candidate(key = \"the lazy dog jumps over the quick brown fox\",message = \"qjxv yoj vqzj spwq yjiwxtw ovbxc yvoqzgkxq\") == \"rkzp gik prfk onwr gkswzaw ipvzt gpirfjuzr\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx yjx\") == \"xpo xpo\"\n assert candidate(key = \"cvzkgbxquihmpnytjrsdawolef\",message = \"cfr cfd cfl mfl\") == \"azr azt azx lzx\"\n assert candidate(key = \"lazy dogs jumps quickly over the brown fox the\",message = \"vqzj yjiwxtw spwq yoj ovbxc yoj\") == \"qmci dinwztw hlwm dfi fqvzo dfi\"\n assert candidate(key = \"thezyxwvutsrqponmlkjihgfedcba\",message = \"zqv eovm ztqkofv ztqkofv\") == \"dlh cnhp dalrnvh dalrnvh\"\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"evh vhe yhe\") == \"ves esv bsv\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"zqf ykq fqu fqo ykt nqtk\") == \"wdn xhd nde ndk xha mdah\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"hqv v yhqf\") == \"hqv v yhqf\"\n assert candidate(key = \"ponmlkjihgfedcbazyxwvutsrq\",message = \"jxqy xtgy efn nhr\") == \"gszr swjr lkc ciy\"\n assert candidate(key = \"gymbztfkwjxehalnqosrudvpci\",message = \"nqzv nq p azdvmn\") == \"pqew pq x nevwcp\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"zcf bvg jnfrdq\") == \"zcf bvg jnfrdq\"\n assert candidate(key = \"brown fox the quick jumps over lazy dogs and\",message = \"ovbxc yoz spwq yvoqzgkxq vqzj qjxv ovgx\") == \"ctagn xcw srdk xtckwzogk tkwp kpgt ctzg\"\n assert candidate(key = \"qpwoeirutyalskdjfhgczxmvbn\",message = \"vcp o cv ocv\") == \"xtb d tx dtx\"\n assert candidate(key = \"ijklmnopqrstuvwxyzabcdefgh\",message = \"wqv qv q\") == \"oin in i\"\n assert candidate(key = \"cijqxfyvolnmtzgdwsaehrkpbu\",message = \"fnw uvf uft nwg\") == \"fkq zhf zfm kqo\"\n assert candidate(key = \"lazy dogs jump quickly over the brown fox\",message = \"jxqy xtgy efn nhr\") == \"izmd ztgd ryx xus\"\n assert candidate(key = \"phinxqbcdgjkamlstvrewyzouf\",message = \"thx thg lv xkqhs\") == \"qbe qbj or elfbp\"\n assert candidate(key = \"jklmnopqrstuvwxyzabcdefghi\",message = \"dru gct gct\") == \"uil xtk xtk\"\n assert candidate(key = \"jxqtvknpsmuhbdrgzlcewfoaiy\",message = \"dgy gch dgy\") == \"npz psl npz\"\n assert candidate(key = \"abcdefghijklnmopqrstuvwxyz\",message = \"opq qpo qpo\") == \"opq qpo qpo\"\n assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"gsv htk gdv jgd\") == \"olw per omw qom\"\n assert candidate(key = \"jzkgwvqdhnmltisrfoxcabepy\",message = \"jwpwp yv owp\") == \"aexex yf rex\"\n assert candidate(key = \"wsgczxfltkbqpndohjuaevrmiy\",message = \"vmx gpm mvg maq\") == \"vxf cmx xvc xtl\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"xol mlu w yjx\") == \"xol mlu w yjx\"\n assert candidate(key = \"dogs quick brown fox jumps over lazy the this\",message = \"vqzj spwq ovbxc yjiwxtw vqzj qjxv\") == \"sewp drle bsjoh xpgloyl sewp epos\"\n assert candidate(key = \"abcdefgijklmnopqrstuvwxyz\",message = \"qcp zc y\") == \"pco yc x\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx y\") == \"xpo x\"\n assert candidate(key = \"lmnopqrstuvwxyzabcdefghijk\",message = \"vqj qjv z\") == \"kfy fyk o\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"qiy oiq z\") == \"qiy oiq z\"\n assert candidate(key = \"and the quick brown fox jumps over lazy dogs\",message = \"ovgx yoj spwq yvoqzgkxq ovbxc yjiwxtw vqzj\") == \"nvzq ynr utog yvngxzkqg nvlqj yrioqdo vgxr\"\n assert candidate(key = \"qwertyuioplkjhgfdsazxcvbnm\",message = \"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt\") == \"orwmp dujfh kqzgk vapyl nkcwh orwit sxbke\"\n assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"zqv qv z\") == \"mdi di m\"\n assert candidate(key = \"quick brown fox jumps over lazy dogs the this\",message = \"yvoqzgkxq ovbxc yjiwxtw vqzj qjxv spwq qjxv\") == \"vqhauxela hqfld vmcilyi qaum amlq poia amlq\"\n assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"oxj o j\") == \"iuq i q\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"sw yjx\") == \"sl xpo\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"v zifw ilxqfs\") == \"t wfnl fuodns\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"qzcf bfgs jgcd yqcf\") == \"qzcf bfgs jgcd yqcf\"\n assert candidate(key = \"abcdefghizjklmnopqrstuvwxy\",message = \"ulc cul cul\") == \"vmc cvm cvm\"\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"tsr rst rst\") == \"ghi ihg ihg\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"qz cf\") == \"dw gn\"\n assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"mfir kkfr ifxk\") == \"znhd rrnd hnur\"\n assert candidate(key = \"fnex wpviqkdmtlugybhcarzsoj\",message = \"hcv uxl\") == \"stg odn\"\n assert candidate(key = \"zebra quick brown fox jumps over the lazy dog\",message = \"gqjty efn nhr htyq\") == \"zfpux bnm mvd vuxf\"\n assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"vqz zqv z\") == \"idm mdi m\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"vgj ov sa jhygjmt oh rjw\") == \"tzp kt sv pbxzpqa kb jpl\"\n assert candidate(key = \"bcadefghijklmnopqrstuvwxzy\",message = \"bdc bva jnfrdq\") == \"adb avc jnfrdq\"\n assert candidate(key = \"asdfghjklqwertyuiopzxcvbnm\",message = \"wqv qv q\") == \"kjw jw j\"\n assert candidate(key = \"zebra tiger quick brown fox jumps over the lazy dog\",message = \"uybvf ojizv cfiwz nqzsx vgrb cgviy ojizv bxz\") == \"jycvp mrgav kpgna oiauq vhdc khvgy mrgav cqa\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"dkv v yvk\") == \"yht t xth\"\n assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"zqv qv zc\") == \"mdi di mp\"\n assert candidate(key = \"the brown fox jumps quickly over a lazy dog\",message = \"pjoj qvw xqt jqtqi yjiwxtw spwq jx gsvk yoj\") == \"nkfk pvg jpa kpapq ukqgjag ongp kj zovs ufk\"\n assert candidate(key = \"this quick brown fox jumps over lazy dogs\",message = \"qjxv yvoqzgkxq ovbxc yjiwxtw spwq yoj vqzj\") == \"epos xskewzhoe ksiog xpcloal drle xkp sewp\"\n assert candidate(key = \"jklmnopqrstuvwxyzabcdefghi\",message = \"sgtw xjxw xjxw\") == \"jxkn oaon oaon\"\n assert candidate(key = \"a bc df egh ijkl mno pq rs tuvwxyz\",message = \"v lqyq w lwv yjx\") == \"v lqyq w lwv yjx\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"qzcfb qmgox ypgmt gsv fiu\") == \"qzcfb qmgox ypgmt gsv fiu\"\n assert candidate(key = \"pqrkxlcdemosvahzwfygtnujib\",message = \"izv zfc yfcv\") == \"ypm prg srgm\"\n assert candidate(key = \"lazy dogs jump over quick brown fox the\",message = \"bxz bpxc wxqgc ebcjg fcivw zqzsx ojizv\") == \"txc tlxr uxpgr ntrig wrqmu cpchx fiqcm\"\n assert candidate(key = \"okyftdazhsxngijwumrcvqlpeb\",message = \"kqv mhg a lv vjx\") == \"bvu rim g wu uok\"\n assert candidate(key = \"the brown fox jumps quickly over a lazy dog\",message = \"mht zrs xqf ovkqvoq ngyu a qzfe nax\") == \"mba xeo jpi fvspvfp hzul w pxic hwj\"\n assert candidate(key = \"over lazy dogs quick brown fox jumps the this\",message = \"spwq vqzj spwq ovbxc yjiwxtw qjxv qjxv\") == \"kxrl blgv kxrl abquo hvnruyr lvub lvub\"\n assert candidate(key = \"the brown quick fox jumps over lazy dogs\",message = \"zqft gqf vxt xec ohq oizd\") == \"wina zin toa ocl fbi fkwy\"\n assert candidate(key = \"jumped over the lazy brown fox quick\",message = \"ujxqyc efn nhr htyq\") == \"batuow esr rki kjou\"\n assert candidate(key = \"fghijklmnopqrstuvwxyzabcde\",message = \"vrc vja vrc vja\") == \"qmx qev qmx qev\"\n assert candidate(key = \"the quick brown fox jumps over lazy dogs and\",message = \"spwq yvoqzgkxq ovbxc yjiwxtw vqzj ovgx\") == \"srld xtkdwzhod ktiog xpfloal tdwp ktzo\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"qjvux xfgf q px\") == \"dpteo onzn d ro\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"dkv v ydv\") == \"yht t xyt\"\n assert candidate(key = \"xlsnmveizhptfjugobcdkqrway\",message = \"wcr vcv wcv xwv\") == \"xsw fsf xsf axf\"\n assert candidate(key = \"quick brown fox jumps over lazy dog the\",message = \"fxfsr jxqfk wtf pvuzr bcgy jxqfk dvo\") == \"klkpg mlake iyk oqbug fdxv mlake wqh\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx w\") == \"xpo l\"\n assert candidate(key = \"bdfhjlnprtvxzcgikmoqsuwyae\",message = \"hc vjg cji cgy\") == \"dn keo nep nox\"\n assert candidate(key = \"onmlkjihgfedcbazyxwvutsrqp\",message = \"ixkz znxoz kx yq\") == \"grep pbrap er qy\"\n assert candidate(key = \"phqgiumeaylnofdxjkrcvstzwb\",message = \"ixw ikg ikg ikg\") == \"epy erd erd erd\"\n assert candidate(key = \"five boxing wizards jump quickly on this lazy dog\",message = \"wfkq xqfnk uveogvj pvuzr cfiwz rjgt jxqfk bxz\") == \"javt gtahv qcdficp scqkm uabjk mpiy pgtav egk\"\n assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"vqj qjv cv\") == \"waq aqw vw\"\n assert candidate(key = \"abcdefghjklmnopqrstuvwxyzti\",message = \"ghw gct gct\") == \"ghv gcs gcs\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"fnbv wvxm\") == \"nmit ltoq\"\n assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx\") == \"xpo\"\n assert candidate(key = \"mnbvcxzlkjhgfdsapoiuytrewq\",message = \"qnb wql fhw fql\") == \"zbc yzh mky mzh\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz\",message = \"anxanq azoz anu\") == \"anxanq azoz anu\"\n assert candidate(key = \"thequickbrownfoxjumpsoverthelazydogs\",message = \"qjvux xfgf q px\") == \"dpteo onzn d ro\"\n assert candidate(key = \"abcdefghjklmnopqrstuvwxyzti\",message = \"jkq xjxw xjxw\") == \"ijp wiwv wiwv\"\n assert candidate(key = \"bujgtfayrxohqzplmwdinckevs\",message = \"yzq d pyq o\") == \"hnm s ohm k\"\n assert candidate(key = \"rjkylmfdqogavwunhixpctzesb\",message = \"tzm tmz tmh tmi\") == \"vwf vfw vfq vfr\"\n assert candidate(key = \"the quick brown fox jumps over lazy dogs this\",message = \"spwq yvoqzgkxq ovbxc yjiwxtw vqzj qjxv\") == \"srld xtkdwzhod ktiog xpfloal tdwp dpot\"\n assert candidate(key = \"brown fox jumps over lazy dogs the quick this\",message = \"ovbxc yjiwxtw vqzj qjxv spwq yvoqzgkxq\") == \"cmagy rhxdgud mwqh whgm lkdw rmcwqtzgw\"\n assert candidate(key = \"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\",message = \"z k u o c g t w\") == \"z k u o c g t w\"\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"gtgt nvo gtg mpgg\") == \"tgtg mel tgt nktt\"\n assert candidate(key = \"ijklmnopqrstuvwxyzabcdefgh\",message = \"wqv qv qv\") == \"oin in in\"\n assert candidate(key = \"mjw qzlnf hw uo kcf jehrv dpo osxgt cyqak\",message = \"jnjfdh frl df\") == \"bgbhqi hof qh\"\n assert candidate(key = \"abcdefghizjklmnopqrstuvwxy\",message = \"vuvw xw yx za\") == \"wvwx yx zy ja\"\n assert candidate(key = \"abcdefghijklnmopqrstuvwxyz\",message = \"ehu zcv i\") == \"ehu zcv i\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"ehu zcv i\") == \"ehu zcv i\"\n assert candidate(key = \"wvutsrqponmlkjihgfedcba zyx\",message = \"zyxwvutsrqpnmolkjihgfedcba\") == \"xyzabcdefghjkilmnopqrstuvw\"\n assert candidate(key = \"mnbvcxzlkjhgfdsapoiuytrewq\",message = \"vcp o cv v\") == \"deq r ed d\"\n assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"jyq zq j\") == \"qfa ta q\"\n assert candidate(key = \"the brown fox jumps over the lazy dog quickly\",message = \"tqpp d dswcp gygij\") == \"awnn u uogyn vtvxk\"\n assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"ixq kivk eiqb\") == \"rcj prep vrjy\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"wklv lv dq xvh hqw phvvdjh\") == \"wklv lv dq xvh hqw phvvdjh\"\n assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"zcf jopcnboe wj jop\") == \"mps wbcpaobr jw wbc\"\n assert candidate(key = \"xyzabcdefghijklmnopqrstuvw\",message = \"xpu xh z\") == \"asx ak c\"\n assert candidate(key = \"quick brown fox jumps over the lazy dog\",message = \"kxvzn hqomj jxq zpsvx wbvs hq tkgx\") == \"elqwj tahnm mla wopql ifqp ta sezl\"\n assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"ehu zcv z\") == \"ehu zcv z\"\n assert candidate(key = \"this quick brown fox jumps over lazy dogs and\",message = \"qjxv spwq yvoqzgkxq ovbxc yjiwxtw vqzj ovgx\") == \"epos drle xskewzhoe ksiog xpcloal sewp kszo\"\n assert candidate(key = \"abcdef ghijklmnopqrstuvwxyz\",message = \"zcf bvg jnfrdq\") == \"zcf bvg jnfrdq\"\n assert candidate(key = \"abcdefghijklnmopqrstuvwxyz\",message = \"qzdv lqaf qv yzxq\") == \"qzdv lqaf qv yzxq\"\n assert candidate(key = \"abcdefghikjlmnopqrstuvwxyz\",message = \"hij iji iij\") == \"hik iki iik\"\n"}, "metadata": {"canonical_parameter_names": ["key", "message"], "leetcode_dataset_entry_point": "Solution().decodeMessage", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String decodeMessage(String key, String message) {", "container": "Solution", "callable": "decodeMessage", "parameters": [{"name": "key", "type": "String"}, {"name": "message", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2326, "task_id": "spiral-matrix-iv", "difficulty": "Medium", "problem_description": "You are given two integers m and n, which represent the dimensions of a matrix.\nYou are also given the head of a linked list of integers.\nGenerate an m x n matrix that contains the integers in the linked list presented in spiral order (clockwise), starting from the top-left of the matrix. If there are remaining empty spaces, fill them with -1.\nReturn the generated matrix.\n \nExample 1:\n\n\nInput: m = 3, n = 5, head = [3,0,2,6,8,1,7,9,4,2,5,5,0]\nOutput: [[3,0,2,6,8],[5,0,-1,-1,1],[5,2,4,9,7]]\nExplanation: The diagram above shows how the values are printed in the matrix.\nNote that the remaining spaces in the matrix are filled with -1.\n\nExample 2:\n\n\nInput: m = 1, n = 4, head = [0,1,2]\nOutput: [[0,1,2,-1]]\nExplanation: The diagram above shows how the values are printed from left to right in the matrix.\nThe last space in the matrix is set to -1.\n \nConstraints:\n\n1 <= m, n <= 105\n1 <= m * n <= 105\nThe number of nodes in the list is in the range [1, m * n].\n0 <= Node.val <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 2,n = 2,head = list_node([1, 2])) == [[1, 2], [-1, -1]]\n assert candidate(m = 4,n = 4,head = list_node([1])) == [[1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]\n assert candidate(m = 2,n = 2,head = list_node([1, 2, 3])) == [[1, 2], [-1, 3]]\n assert candidate(m = 4,n = 4,head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])) == [[1, 2, 3, 4], [12, 13, 14, 5], [11, 16, 15, 6], [10, 9, 8, 7]]\n assert candidate(m = 5,n = 3,head = list_node([1, 2, 3, 4, 5, 6, 7])) == [[1, 2, 3], [-1, -1, 4], [-1, -1, 5], [-1, -1, 6], [-1, -1, 7]]\n assert candidate(m = 5,n = 3,head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150])) == [[10, 20, 30], [120, 130, 40], [110, 140, 50], [100, 150, 60], [90, 80, 70]]\n assert candidate(m = 1,n = 4,head = list_node([0, 1, 2])) == [[0, 1, 2, -1]]\n assert candidate(m = 4,n = 3,head = list_node([1, 2, 3, 4, 5, 6])) == [[1, 2, 3], [-1, -1, 4], [-1, -1, 5], [-1, -1, 6]]\n assert candidate(m = 3,n = 5,head = list_node([3, 0, 2, 6, 8, 1, 7, 9, 4, 2, 5, 5, 0])) == [[3, 0, 2, 6, 8], [5, 0, -1, -1, 1], [5, 2, 4, 9, 7]]\n assert candidate(m = 5,n = 1,head = list_node([1, 2, 3, 4, 5])) == [[1], [2], [3], [4], [5]]\n assert candidate(m = 5,n = 1,head = list_node([1, 3, 5, 7, 9])) == [[1], [3], [5], [7], [9]]\n assert candidate(m = 5,n = 3,head = list_node([1, 2, 3, 4, 5])) == [[1, 2, 3], [-1, -1, 4], [-1, -1, 5], [-1, -1, -1], [-1, -1, -1]]\n assert candidate(m = 8,n = 8,head = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000])) == [[100, 200, 300, 400, 500, 600, 700, 800], [-1, -1, -1, -1, -1, -1, -1, 900], [-1, -1, -1, -1, -1, -1, -1, 1000], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-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(m = 6,n = 7,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])) == [[1, 2, 3, 4, 5, 6, 7], [22, 23, 24, 25, 26, 27, 8], [21, 36, 37, 38, 39, 28, 9], [20, 35, 42, 41, 40, 29, 10], [19, 34, 33, 32, 31, 30, 11], [18, 17, 16, 15, 14, 13, 12]]\n assert candidate(m = 8,n = 4,head = 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])) == [[2, 4, 6, 8], [40, 42, 44, 10], [38, -1, 46, 12], [36, -1, 48, 14], [34, -1, -1, 16], [32, -1, -1, 18], [30, -1, -1, 20], [28, 26, 24, 22]]\n assert candidate(m = 7,n = 6,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])) == [[1, 2, 3, 4, 5, 6], [22, 23, 24, 25, 26, 7], [21, -1, -1, -1, 27, 8], [20, -1, -1, -1, 28, 9], [19, -1, -1, -1, 29, 10], [18, -1, -1, 31, 30, 11], [17, 16, 15, 14, 13, 12]]\n assert candidate(m = 6,n = 7,head = list_node([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])) == [[10, 20, 30, 40, 50, 60, 70], [220, 230, 240, 250, 260, 270, 80], [210, -1, -1, -1, -1, -1, 90], [200, -1, -1, -1, -1, -1, 100], [190, -1, -1, -1, -1, -1, 110], [180, 170, 160, 150, 140, 130, 120]]\n assert candidate(m = 10,n = 10,head = list_node([1])) == [[1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -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(m = 1,n = 1,head = list_node([999])) == [[999]]\n assert candidate(m = 10,n = 10,head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1])) == [[9, 8, 7, 6, 5, 4, 3, 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, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -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(m = 7,n = 3,head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120])) == [[10, 20, 30], [-1, -1, 40], [-1, -1, 50], [-1, -1, 60], [-1, -1, 70], [120, -1, 80], [110, 100, 90]]\n assert candidate(m = 9,n = 5,head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1])) == [[9, 8, 7, 6, 5], [-1, -1, -1, -1, 4], [-1, -1, -1, -1, 3], [-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, -1]]\n assert candidate(m = 4,n = 5,head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(m = 8,n = 8,head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1])) == [[9, 8, 7, 6, 5, 4, 3, 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, -1, -1, -1, -1, -1], [-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(m = 6,n = 6,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])) == [[1, 2, 3, 4, 5, 6], [20, 21, 22, 23, 24, 7], [19, 32, 33, 34, 25, 8], [18, 31, 36, 35, 26, 9], [17, 30, 29, 28, 27, 10], [16, 15, 14, 13, 12, 11]]\n assert candidate(m = 10,n = 5,head = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900])) == [[100, 200, 300, 400, 500], [-1, -1, -1, -1, 600], [-1, -1, -1, -1, 700], [-1, -1, -1, -1, 800], [-1, -1, -1, -1, 900], [-1, -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(m = 6,n = 7,head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210])) == [[10, 20, 30, 40, 50, 60, 70], [-1, -1, -1, -1, -1, -1, 80], [210, -1, -1, -1, -1, -1, 90], [200, -1, -1, -1, -1, -1, 100], [190, -1, -1, -1, -1, -1, 110], [180, 170, 160, 150, 140, 130, 120]]\n assert candidate(m = 7,n = 4,head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140])) == [[10, 20, 30, 40], [-1, -1, -1, 50], [-1, -1, -1, 60], [-1, -1, -1, 70], [-1, -1, -1, 80], [140, -1, -1, 90], [130, 120, 110, 100]]\n assert candidate(m = 3,n = 6,head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17])) == [[1, 3, 5, 7, 9, 11], [-1, -1, -1, -1, -1, 13], [-1, -1, -1, -1, 17, 15]]\n assert candidate(m = 5,n = 5,head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9])) == [[1, 2, 3, 4, 5], [-1, -1, -1, -1, 6], [-1, -1, -1, -1, 7], [-1, -1, -1, -1, 8], [-1, -1, -1, -1, 9]]\n assert candidate(m = 20,n = 1,head = list_node([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], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]]\n assert candidate(m = 3,n = 3,head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1])) == [[9, 8, 7], [2, 1, 6], [3, 4, 5]]\n assert candidate(m = 5,n = 9,head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9])) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -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(m = 10,n = 1,head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]\n assert candidate(m = 7,n = 4,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])) == [[1, 2, 3, 4], [18, 19, 20, 5], [17, 28, 21, 6], [16, 27, 22, 7], [15, 26, 23, 8], [14, 25, 24, 9], [13, 12, 11, 10]]\n assert candidate(m = 4,n = 9,head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 36])) == [[1, 3, 5, 7, 9, 11, 13, 15, 17], [-1, -1, -1, -1, -1, -1, -1, -1, 19], [-1, -1, -1, -1, -1, -1, -1, -1, 21], [-1, 36, 35, 33, 31, 29, 27, 25, 23]]\n assert candidate(m = 12,n = 3,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])) == [[1, 2, 3], [26, 27, 4], [25, 28, 5], [24, 29, 6], [23, 30, 7], [22, 31, 8], [21, 32, 9], [20, 33, 10], [19, 34, 11], [18, 35, 12], [17, 36, 13], [16, 15, 14]]\n assert candidate(m = 5,n = 2,head = list_node([100, 200, 300, 400, 500])) == [[100, 200], [-1, 300], [-1, 400], [-1, 500], [-1, -1]]\n assert candidate(m = 3,n = 7,head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105])) == [[5, 10, 15, 20, 25, 30, 35], [80, 85, 90, 95, 100, 105, 40], [75, 70, 65, 60, 55, 50, 45]]\n assert candidate(m = 12,n = 12,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])) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [44, 45, 46, 47, 48, 49, 50, -1, -1, -1, -1, 13], [43, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14], [42, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15], [41, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16], [40, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17], [39, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18], [38, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19], [37, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20], [36, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21], [35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22], [34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23]]\n assert candidate(m = 10,n = 5,head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100])) == [[5, 10, 15, 20, 25], [-1, -1, -1, -1, 30], [-1, -1, -1, -1, 35], [-1, -1, -1, -1, 40], [-1, -1, -1, -1, 45], [-1, -1, -1, -1, 50], [-1, -1, -1, -1, 55], [100, -1, -1, -1, 60], [95, -1, -1, -1, 65], [90, 85, 80, 75, 70]]\n assert candidate(m = 15,n = 1,head = list_node([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(m = 8,n = 8,head = list_node([1])) == [[1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-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(m = 10,n = 10,head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])) == [[9, 8, 7, 6, 5, 4, 3, 2, 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, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -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(m = 1,n = 100,head = list_node([1])) == [[1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -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(m = 5,n = 5,head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == [[1, 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(m = 3,n = 6,head = list_node([5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145])) == [[5, 15, 25, 35, 45, 55], [135, 145, -1, -1, -1, 65], [125, 115, 105, 95, 85, 75]]\n assert candidate(m = 6,n = 8,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])) == [[1, 2, 3, 4, 5, 6, 7, 8], [24, 25, 26, -1, -1, -1, -1, 9], [23, -1, -1, -1, -1, -1, -1, 10], [22, -1, -1, -1, -1, -1, -1, 11], [21, -1, -1, -1, -1, -1, -1, 12], [20, 19, 18, 17, 16, 15, 14, 13]]\n assert candidate(m = 15,n = 15,head = list_node([1])) == [[1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -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(m = 10,n = 10,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])) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [36, 37, 38, 39, 40, 41, 42, 43, 44, 11], [35, 64, 65, 66, 67, 68, 69, 70, 45, 12], [34, 63, 84, 85, 86, 87, 88, 71, 46, 13], [33, 62, 83, 96, 97, 98, 89, 72, 47, 14], [32, 61, 82, 95, 100, 99, 90, 73, 48, 15], [31, 60, 81, 94, 93, 92, 91, 74, 49, 16], [30, 59, 80, 79, 78, 77, 76, 75, 50, 17], [29, 58, 57, 56, 55, 54, 53, 52, 51, 18], [28, 27, 26, 25, 24, 23, 22, 21, 20, 19]]\n assert candidate(m = 2,n = 8,head = list_node([5, 10, 15, 20, 25, 30, 35])) == [[5, 10, 15, 20, 25, 30, 35, -1], [-1, -1, -1, -1, -1, -1, -1, -1]]\n assert candidate(m = 2,n = 10,head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29])) == [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [-1, -1, -1, -1, -1, 29, 27, 25, 23, 21]]\n assert candidate(m = 4,n = 9,head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9])) == [[9, 8, 7, 6, 5, 4, 3, 2, 1], [-1, -1, -1, -1, -1, -1, -1, -1, 0], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -9, -8, -7, -6, -5, -4, -3, -2]]\n assert candidate(m = 6,n = 7,head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140])) == [[10, 20, 30, 40, 50, 60, 70], [-1, -1, -1, -1, -1, -1, 80], [-1, -1, -1, -1, -1, -1, 90], [-1, -1, -1, -1, -1, -1, 100], [-1, -1, -1, -1, -1, -1, 110], [-1, -1, -1, -1, 140, 130, 120]]\n assert candidate(m = 10,n = 1,head = list_node([99, 98, 97, 96, 95, 94, 93, 92, 91, 90])) == [[99], [98], [97], [96], [95], [94], [93], [92], [91], [90]]\n assert candidate(m = 1,n = 10,head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9])) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, -1]]\n assert candidate(m = 7,n = 6,head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170])) == [[10, 20, 30, 40, 50, 60], [-1, -1, -1, -1, -1, 70], [-1, -1, -1, -1, -1, 80], [-1, -1, -1, -1, -1, 90], [-1, -1, -1, -1, -1, 100], [-1, -1, -1, -1, -1, 110], [170, 160, 150, 140, 130, 120]]\n assert candidate(m = 6,n = 6,head = list_node([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])) == [[1, 3, 5, 7, 9, 11], [39, 41, 43, 45, 47, 13], [37, -1, -1, -1, 49, 15], [35, -1, -1, -1, 51, 17], [33, -1, -1, -1, -1, 19], [31, 29, 27, 25, 23, 21]]\n assert candidate(m = 7,n = 5,head = list_node([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])) == [[1, 3, 5, 7, 9], [39, 41, 43, 45, 11], [37, -1, -1, 47, 13], [35, -1, -1, 49, 15], [33, -1, -1, 51, 17], [31, -1, -1, -1, 19], [29, 27, 25, 23, 21]]\n assert candidate(m = 8,n = 8,head = 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, 52, 54, 56, 58, 60, 62, 64])) == [[2, 4, 6, 8, 10, 12, 14, 16], [56, 58, 60, 62, 64, -1, -1, 18], [54, -1, -1, -1, -1, -1, -1, 20], [52, -1, -1, -1, -1, -1, -1, 22], [50, -1, -1, -1, -1, -1, -1, 24], [48, -1, -1, -1, -1, -1, -1, 26], [46, -1, -1, -1, -1, -1, -1, 28], [44, 42, 40, 38, 36, 34, 32, 30]]\n assert candidate(m = 12,n = 4,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])) == [[1, 2, 3, 4], [28, 29, 30, 5], [27, 48, 31, 6], [26, 47, 32, 7], [25, 46, 33, 8], [24, 45, 34, 9], [23, 44, 35, 10], [22, 43, 36, 11], [21, 42, 37, 12], [20, 41, 38, 13], [19, 40, 39, 14], [18, 17, 16, 15]]\n assert candidate(m = 8,n = 3,head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9])) == [[1, 2, 3], [-1, -1, 4], [-1, -1, 5], [-1, -1, 6], [-1, -1, 7], [-1, -1, 8], [-1, -1, 9], [-1, -1, -1]]\n assert candidate(m = 3,n = 7,head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26])) == [[2, 4, 6, 8, 10, 12, 14], [-1, -1, -1, -1, -1, -1, 16], [-1, -1, 26, 24, 22, 20, 18]]\n assert candidate(m = 7,n = 7,head = list_node([999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975])) == [[999, 998, 997, 996, 995, 994, 993], [976, 975, -1, -1, -1, -1, 992], [977, -1, -1, -1, -1, -1, 991], [978, -1, -1, -1, -1, -1, 990], [979, -1, -1, -1, -1, -1, 989], [980, -1, -1, -1, -1, -1, 988], [981, 982, 983, 984, 985, 986, 987]]\n assert candidate(m = 100,n = 1,head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [[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], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-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(m = 3,n = 7,head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130])) == [[10, 20, 30, 40, 50, 60, 70], [-1, -1, -1, -1, -1, -1, 80], [-1, -1, 130, 120, 110, 100, 90]]\n assert candidate(m = 7,n = 6,head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35])) == [[1, 3, 5, 7, 9, 11], [-1, -1, -1, -1, -1, 13], [-1, -1, -1, -1, -1, 15], [-1, -1, -1, -1, -1, 17], [-1, -1, -1, -1, -1, 19], [35, -1, -1, -1, -1, 21], [33, 31, 29, 27, 25, 23]]\n assert candidate(m = 6,n = 6,head = list_node([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, 9, 11], [39, 41, 43, 45, 47, 13], [37, -1, -1, -1, 49, 15], [35, -1, -1, -1, -1, 17], [33, -1, -1, -1, -1, 19], [31, 29, 27, 25, 23, 21]]\n assert candidate(m = 3,n = 8,head = list_node([5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105])) == [[5, 15, 25, 35, 45, 55, 65, 75], [-1, -1, -1, -1, -1, -1, -1, 85], [-1, -1, -1, -1, -1, -1, 105, 95]]\n assert candidate(m = 8,n = 5,head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105])) == [[5, 10, 15, 20, 25], [-1, -1, -1, -1, 30], [105, -1, -1, -1, 35], [100, -1, -1, -1, 40], [95, -1, -1, -1, 45], [90, -1, -1, -1, 50], [85, -1, -1, -1, 55], [80, 75, 70, 65, 60]]\n assert candidate(m = 1,n = 10,head = list_node([1, 2, 3, 4, 5])) == [[1, 2, 3, 4, 5, -1, -1, -1, -1, -1]]\n assert candidate(m = 2,n = 8,head = list_node([1, 2, 3, 4, 5])) == [[1, 2, 3, 4, 5, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1]]\n assert candidate(m = 8,n = 5,head = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100])) == [[100, 200, 300, 400, 500], [-1, -1, -1, -1, 600], [2100, -1, -1, -1, 700], [2000, -1, -1, -1, 800], [1900, -1, -1, -1, 900], [1800, -1, -1, -1, 1000], [1700, -1, -1, -1, 1100], [1600, 1500, 1400, 1300, 1200]]\n assert candidate(m = 10,n = 10,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])) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [36, 37, 38, 39, 40, 41, 42, 43, 44, 11], [35, 64, 65, 66, 67, 68, 69, 70, 45, 12], [34, 63, 84, 85, 86, 87, 88, 71, 46, 13], [33, 62, 83, -1, -1, -1, 89, 72, 47, 14], [32, 61, 82, -1, -1, -1, 90, 73, 48, 15], [31, 60, 81, -1, -1, -1, -1, 74, 49, 16], [30, 59, 80, 79, 78, 77, 76, 75, 50, 17], [29, 58, 57, 56, 55, 54, 53, 52, 51, 18], [28, 27, 26, 25, 24, 23, 22, 21, 20, 19]]\n assert candidate(m = 7,n = 7,head = list_node([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])) == [[10, 20, 30, 40, 50, 60, 70], [240, 250, 260, 270, 280, 290, 80], [230, 400, 410, 420, 430, 300, 90], [220, 390, 480, 490, 440, 310, 100], [210, 380, 470, 460, 450, 320, 110], [200, 370, 360, 350, 340, 330, 120], [190, 180, 170, 160, 150, 140, 130]]\n assert candidate(m = 20,n = 1,head = list_node([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], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]]\n assert candidate(m = 7,n = 6,head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220])) == [[10, 20, 30, 40, 50, 60], [220, -1, -1, -1, -1, 70], [210, -1, -1, -1, -1, 80], [200, -1, -1, -1, -1, 90], [190, -1, -1, -1, -1, 100], [180, -1, -1, -1, -1, 110], [170, 160, 150, 140, 130, 120]]\n assert candidate(m = 9,n = 4,head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, -1, 1, 1], [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(m = 12,n = 3,head = list_node([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])) == [[99, 98, 97], [-1, -1, 96], [75, -1, 95], [76, -1, 94], [77, -1, 93], [78, -1, 92], [79, -1, 91], [80, -1, 90], [81, -1, 89], [82, -1, 88], [83, -1, 87], [84, 85, 86]]\n assert candidate(m = 8,n = 8,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])) == [[1, 2, 3, 4, 5, 6, 7, 8], [28, 29, 30, 31, 32, 33, 34, 9], [27, 48, 49, 50, 51, 52, 35, 10], [26, 47, 60, 61, 62, 53, 36, 11], [25, 46, 59, 64, 63, 54, 37, 12], [24, 45, 58, 57, 56, 55, 38, 13], [23, 44, 43, 42, 41, 40, 39, 14], [22, 21, 20, 19, 18, 17, 16, 15]]\n assert candidate(m = 5,n = 5,head = list_node([1])) == [[1, -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(m = 10,n = 10,head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, -1, -1, -1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, -1, -1, -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(m = 7,n = 2,head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25])) == [[1, 3], [-1, 5], [25, 7], [23, 9], [21, 11], [19, 13], [17, 15]]\n assert candidate(m = 7,n = 3,head = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900])) == [[100, 200, 300], [-1, -1, 400], [-1, -1, 500], [-1, -1, 600], [-1, -1, 700], [-1, -1, 800], [-1, -1, 900]]\n assert candidate(m = 10,n = 10,head = list_node([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])) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [35, 36, 37, 38, 39, 40, 41, 42, 43, 10], [34, 63, 64, 65, 66, 67, 68, 69, 44, 11], [33, 62, 83, 84, 85, 86, 87, 70, 45, 12], [32, 61, 82, 95, 96, 97, 88, 71, 46, 13], [31, 60, 81, 94, 99, 98, 89, 72, 47, 14], [30, 59, 80, 93, 92, 91, 90, 73, 48, 15], [29, 58, 79, 78, 77, 76, 75, 74, 49, 16], [28, 57, 56, 55, 54, 53, 52, 51, 50, 17], [27, 26, 25, 24, 23, 22, 21, 20, 19, 18]]\n assert candidate(m = 3,n = 9,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])) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 25, 26, 27, 10], [19, 18, 17, 16, 15, 14, 13, 12, 11]]\n assert candidate(m = 4,n = 5,head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])) == [[1, 2, 3, 4, 5], [14, -1, -1, -1, 6], [13, -1, -1, -1, 7], [12, 11, 10, 9, 8]]\n assert candidate(m = 9,n = 2,head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80])) == [[5, 10], [-1, 15], [-1, 20], [80, 25], [75, 30], [70, 35], [65, 40], [60, 45], [55, 50]]\n assert candidate(m = 6,n = 5,head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == [[1, 1, 1, 1, 1], [1, 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(m = 10,n = 2,head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1])) == [[9, 8], [-1, 7], [-1, 6], [-1, 5], [-1, 4], [-1, 3], [-1, 2], [-1, 1], [-1, -1], [-1, -1]]\n assert candidate(m = 2,n = 2,head = list_node([1])) == [[1, -1], [-1, -1]]\n assert candidate(m = 3,n = 7,head = list_node([5, 15, 25, 35, 45, 55])) == [[5, 15, 25, 35, 45, 55, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1]]\n assert candidate(m = 9,n = 9,head = 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, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98])) == [[2, 4, 6, 8, 10, 12, 14, 16, 18], [64, 66, 68, 70, 72, 74, 76, 78, 20], [62, -1, -1, -1, -1, -1, -1, 80, 22], [60, -1, -1, -1, -1, -1, -1, 82, 24], [58, -1, -1, -1, -1, -1, -1, 84, 26], [56, -1, -1, -1, -1, -1, -1, 86, 28], [54, -1, -1, -1, -1, -1, -1, 88, 30], [52, -1, -1, 98, 96, 94, 92, 90, 32], [50, 48, 46, 44, 42, 40, 38, 36, 34]]\n assert candidate(m = 15,n = 15,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, 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, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225])) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 16], [55, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 70, 17], [54, 103, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 116, 71, 18], [53, 102, 143, 176, 177, 178, 179, 180, 181, 182, 183, 154, 117, 72, 19], [52, 101, 142, 175, 200, 201, 202, 203, 204, 205, 184, 155, 118, 73, 20], [51, 100, 141, 174, 199, 216, 217, 218, 219, 206, 185, 156, 119, 74, 21], [50, 99, 140, 173, 198, 215, 224, 225, 220, 207, 186, 157, 120, 75, 22], [49, 98, 139, 172, 197, 214, 223, 222, 221, 208, 187, 158, 121, 76, 23], [48, 97, 138, 171, 196, 213, 212, 211, 210, 209, 188, 159, 122, 77, 24], [47, 96, 137, 170, 195, 194, 193, 192, 191, 190, 189, 160, 123, 78, 25], [46, 95, 136, 169, 168, 167, 166, 165, 164, 163, 162, 161, 124, 79, 26], [45, 94, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 80, 27], [44, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 28], [43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29]]\n assert candidate(m = 5,n = 5,head = list_node([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, 24, 23, 22, 21], [10, 9, 8, 7, 20], [11, 2, 1, 6, 19], [12, 3, 4, 5, 18], [13, 14, 15, 16, 17]]\n assert candidate(m = 5,n = 5,head = list_node([1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986])) == [[1000, 999, 998, 997, 996], [-1, -1, -1, -1, 995], [986, -1, -1, -1, 994], [987, -1, -1, -1, 993], [988, 989, 990, 991, 992]]\n assert candidate(m = 6,n = 10,head = list_node([5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155])) == [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [-1, -1, -1, -1, -1, -1, -1, -1, -1, 105], [-1, -1, -1, -1, -1, -1, -1, -1, -1, 115], [-1, -1, -1, -1, -1, -1, -1, -1, -1, 125], [-1, -1, -1, -1, -1, -1, -1, -1, -1, 135], [-1, -1, -1, -1, -1, -1, -1, -1, 155, 145]]\n assert candidate(m = 1,n = 15,head = list_node([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(m = 2,n = 9,head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32])) == [[2, 4, 6, 8, 10, 12, 14, 16, 18], [-1, -1, 32, 30, 28, 26, 24, 22, 20]]\n assert candidate(m = 9,n = 5,head = list_node([5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145])) == [[5, 15, 25, 35, 45], [-1, -1, -1, -1, 55], [-1, -1, -1, -1, 65], [-1, -1, -1, -1, 75], [-1, -1, -1, -1, 85], [-1, -1, -1, -1, 95], [-1, -1, -1, -1, 105], [-1, -1, -1, -1, 115], [-1, -1, 145, 135, 125]]\n"}, "metadata": {"canonical_parameter_names": ["m", "n", "head"], "leetcode_dataset_entry_point": "Solution().spiralMatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {", "container": "Solution", "callable": "ListNode", "parameters": [], "return_type": "class ListNode {\n * int val;\n * ListNode next;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2327, "task_id": "number-of-people-aware-of-a-secret", "difficulty": "Medium", "problem_description": "On day 1, one person discovers a secret.\nYou are given an integer delay, which means that each person will share the secret with a new person every day, starting from delay days after discovering the secret. You are also given an integer forget, which means that each person will forget the secret forget days after discovering it. A person cannot share the secret on the same day they forgot it, or on any day afterwards.\nGiven an integer n, return the number of people who know the secret at the end of day n. Since the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: n = 6, delay = 2, forget = 4\nOutput: 5\nExplanation:\nDay 1: Suppose the first person is named A. (1 person)\nDay 2: A is the only person who knows the secret. (1 person)\nDay 3: A shares the secret with a new person, B. (2 people)\nDay 4: A shares the secret with a new person, C. (3 people)\nDay 5: A forgets the secret, and B shares the secret with a new person, D. (3 people)\nDay 6: B shares the secret with E, and C shares the secret with F. (5 people)\n\nExample 2:\n\nInput: n = 4, delay = 1, forget = 3\nOutput: 6\nExplanation:\nDay 1: The first person is named A. (1 person)\nDay 2: A shares the secret with B. (2 people)\nDay 3: A and B share the secret with 2 new people, C and D. (4 people)\nDay 4: A forgets the secret. B, C, and D share the secret with 3 new people. (6 people)\n\n \nConstraints:\n\n2 <= n <= 1000\n1 <= delay < forget <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8,delay = 3,forget = 6) == 6\n assert candidate(n = 500,delay = 100,forget = 400) == 5820125\n assert candidate(n = 4,delay = 1,forget = 3) == 6\n assert candidate(n = 1000,delay = 5,forget = 10) == 743819361\n assert candidate(n = 1000,delay = 1,forget = 999) == 344211603\n assert candidate(n = 10,delay = 2,forget = 5) == 30\n assert candidate(n = 10,delay = 3,forget = 5) == 5\n assert candidate(n = 15,delay = 4,forget = 7) == 19\n assert candidate(n = 6,delay = 2,forget = 4) == 5\n assert candidate(n = 5,delay = 1,forget = 4) == 14\n assert candidate(n = 7,delay = 2,forget = 3) == 2\n assert candidate(n = 100,delay = 10,forget = 50) == 22517820\n assert candidate(n = 200,delay = 50,forget = 150) == 27250\n assert candidate(n = 900,delay = 300,forget = 650) == 45500\n assert candidate(n = 550,delay = 150,forget = 450) == 203375\n assert candidate(n = 950,delay = 400,forget = 700) == 11625\n assert candidate(n = 800,delay = 150,forget = 600) == 79177860\n assert candidate(n = 900,delay = 150,forget = 300) == 935294905\n assert candidate(n = 1000,delay = 1,forget = 10) == 694661098\n assert candidate(n = 700,delay = 110,forget = 550) == 887595495\n assert candidate(n = 600,delay = 250,forget = 550) == 5350\n assert candidate(n = 500,delay = 100,forget = 200) == 5264525\n assert candidate(n = 200,delay = 2,forget = 199) == 349361643\n assert candidate(n = 1000,delay = 1,forget = 500) == 28219034\n assert candidate(n = 1000,delay = 1,forget = 2) == 2\n assert candidate(n = 750,delay = 250,forget = 500) == 31625\n assert candidate(n = 999,delay = 50,forget = 400) == 112339611\n assert candidate(n = 950,delay = 300,forget = 600) == 81225\n assert candidate(n = 750,delay = 200,forget = 600) == 635625\n assert candidate(n = 900,delay = 200,forget = 500) == 9051525\n assert candidate(n = 600,delay = 125,forget = 500) == 6406900\n assert candidate(n = 800,delay = 200,forget = 300) == 843250\n assert candidate(n = 550,delay = 110,forget = 440) == 8292625\n assert candidate(n = 700,delay = 150,forget = 450) == 7127075\n assert candidate(n = 500,delay = 5,forget = 100) == 121345145\n assert candidate(n = 750,delay = 120,forget = 450) == 913950185\n assert candidate(n = 300,delay = 60,forget = 280) == 907415\n assert candidate(n = 500,delay = 150,forget = 400) == 42450\n assert candidate(n = 600,delay = 50,forget = 550) == 979826832\n assert candidate(n = 750,delay = 125,forget = 550) == 450909175\n assert candidate(n = 550,delay = 70,forget = 400) == 326052608\n assert candidate(n = 800,delay = 400,forget = 750) == 350\n assert candidate(n = 120,delay = 20,forget = 100) == 207054\n assert candidate(n = 400,delay = 30,forget = 150) == 689207212\n assert candidate(n = 800,delay = 100,forget = 600) == 153808266\n assert candidate(n = 600,delay = 200,forget = 300) == 10000\n assert candidate(n = 900,delay = 300,forget = 600) == 45450\n assert candidate(n = 950,delay = 150,forget = 850) == 488545869\n assert candidate(n = 600,delay = 250,forget = 400) == 5200\n assert candidate(n = 650,delay = 130,forget = 520) == 15497300\n assert candidate(n = 700,delay = 350,forget = 560) == 210\n assert candidate(n = 950,delay = 140,forget = 650) == 285835661\n assert candidate(n = 850,delay = 300,forget = 500) == 28975\n assert candidate(n = 650,delay = 90,forget = 500) == 926898505\n assert candidate(n = 550,delay = 250,forget = 450) == 1475\n assert candidate(n = 800,delay = 200,forget = 500) == 1423700\n assert candidate(n = 750,delay = 250,forget = 550) == 31675\n assert candidate(n = 550,delay = 80,forget = 450) == 2109288\n assert candidate(n = 500,delay = 200,forget = 400) == 5250\n assert candidate(n = 1000,delay = 50,forget = 900) == 770071855\n assert candidate(n = 750,delay = 120,forget = 500) == 914080410\n assert candidate(n = 600,delay = 150,forget = 450) == 619250\n assert candidate(n = 999,delay = 300,forget = 750) == 246900\n assert candidate(n = 1000,delay = 50,forget = 950) == 770074505\n assert candidate(n = 950,delay = 190,forget = 760) == 65412725\n assert candidate(n = 1000,delay = 10,forget = 500) == 104566774\n assert candidate(n = 600,delay = 120,forget = 480) == 11476850\n assert candidate(n = 1000,delay = 400,forget = 700) == 20400\n assert candidate(n = 900,delay = 100,forget = 800) == 892948851\n assert candidate(n = 500,delay = 50,forget = 450) == 344465040\n assert candidate(n = 200,delay = 40,forget = 150) == 219220\n assert candidate(n = 300,delay = 50,forget = 250) == 8177885\n assert candidate(n = 1000,delay = 500,forget = 900) == 400\n assert candidate(n = 600,delay = 100,forget = 500) == 165273270\n assert candidate(n = 750,delay = 200,forget = 500) == 632925\n assert candidate(n = 850,delay = 130,forget = 550) == 523316449\n assert candidate(n = 450,delay = 90,forget = 360) == 3944850\n assert candidate(n = 1000,delay = 150,forget = 700) == 188312873\n assert candidate(n = 1000,delay = 999,forget = 1000) == 2\n assert candidate(n = 400,delay = 10,forget = 350) == 610381426\n assert candidate(n = 800,delay = 150,forget = 350) == 77362035\n assert candidate(n = 700,delay = 190,forget = 560) == 426390\n assert candidate(n = 550,delay = 220,forget = 330) == 6215\n assert candidate(n = 900,delay = 250,forget = 600) == 651750\n assert candidate(n = 700,delay = 70,forget = 630) == 66046770\n assert candidate(n = 950,delay = 400,forget = 850) == 11775\n assert candidate(n = 750,delay = 150,forget = 600) == 26594875\n assert candidate(n = 400,delay = 100,forget = 350) == 192050\n assert candidate(n = 300,delay = 10,forget = 299) == 236977941\n assert candidate(n = 800,delay = 200,forget = 600) == 1434000\n assert candidate(n = 900,delay = 200,forget = 700) == 9092125\n assert candidate(n = 700,delay = 100,forget = 500) == 766847687\n assert candidate(n = 650,delay = 175,forget = 525) == 378875\n assert candidate(n = 600,delay = 80,forget = 400) == 816019201\n assert candidate(n = 1000,delay = 500,forget = 999) == 499\n assert candidate(n = 300,delay = 100,forget = 200) == 5150\n"}, "metadata": {"canonical_parameter_names": ["n", "delay", "forget"], "leetcode_dataset_entry_point": "Solution().peopleAwareOfSecret", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int peopleAwareOfSecret(int n, int delay, int forget) {", "container": "Solution", "callable": "peopleAwareOfSecret", "parameters": [{"name": "n", "type": "int"}, {"name": "delay", "type": "int"}, {"name": "forget", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2328, "task_id": "number-of-increasing-paths-in-a-grid", "difficulty": "Hard", "problem_description": "You are given an m x n integer matrix grid, where you can move from a cell to any adjacent cell in all 4 directions.\nReturn the number of strictly increasing paths in the grid such that you can start from any cell and end at any cell. Since the answer may be very large, return it modulo 109 + 7.\nTwo paths are considered different if they do not have exactly the same sequence of visited cells.\n \nExample 1:\n\n\nInput: grid = [[1,1],[3,4]]\nOutput: 8\nExplanation: The strictly increasing paths are:\n- Paths with length 1: [1], [1], [3], [4].\n- Paths with length 2: [1 -> 3], [1 -> 4], [3 -> 4].\n- Paths with length 3: [1 -> 3 -> 4].\nThe total number of paths is 4 + 3 + 1 = 8.\n\nExample 2:\n\nInput: grid = [[1],[2]]\nOutput: 3\nExplanation: The strictly increasing paths are:\n- Paths with length 1: [1], [2].\n- Paths with length 2: [1 -> 2].\nThe total number of paths is 2 + 1 = 3.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 1000\n1 <= m * n <= 105\n1 <= grid[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 4], [2, 1, 4, 3], [1, 4, 3, 2]]) == 64\n assert candidate(grid = [[4, 3, 2, 1], [5, 6, 7, 8]]) == 50\n assert candidate(grid = [[1]]) == 1\n assert candidate(grid = [[1], [2]]) == 3\n assert candidate(grid = [[9, 9, 4], [6, 6, 8], [2, 1, 1]]) == 23\n assert candidate(grid = [[9, 9, 9], [9, 9, 9], [9, 9, 9]]) == 9\n assert candidate(grid = [[10]]) == 1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 53\n assert candidate(grid = [[10, 20, 30], [15, 25, 35], [12, 22, 32]]) == 38\n assert candidate(grid = [[1, 1], [3, 4]]) == 8\n assert candidate(grid = [[3, 1, 4, 2], [1, 6, 5, 3], [2, 7, 4, 8]]) == 49\n assert candidate(grid = [[10, 10, 10, 10], [10, 1, 2, 10], [10, 3, 4, 10], [10, 10, 10, 10]]) == 42\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 185\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]]) == 4312\n assert candidate(grid = [[1, 3, 1], [1, 5, 1], [4, 2, 4]]) == 21\n assert candidate(grid = [[1, 1, 1], [1, 2, 1], [1, 1, 1]]) == 13\n assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]) == 77\n assert candidate(grid = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 192\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 363\n assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [10, 11, 12]]) == 172\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 2, 2, 2, 2, 2, 2, 2, 2, 3], [3, 2, 1, 1, 1, 1, 1, 1, 2, 3], [3, 2, 1, 0, 0, 0, 0, 1, 2, 3], [3, 2, 1, 0, 9, 9, 0, 1, 2, 3], [3, 2, 1, 0, 9, 9, 0, 1, 2, 3], [3, 2, 1, 0, 0, 0, 0, 1, 2, 3], [3, 2, 1, 1, 1, 1, 1, 1, 2, 3], [3, 2, 2, 2, 2, 2, 2, 2, 2, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 236\n assert candidate(grid = [[3, 1, 4, 1, 5], [9, 2, 6, 5, 3], [5, 8, 9, 7, 9], [3, 2, 3, 8, 6], [3, 7, 4, 9, 8]]) == 117\n assert candidate(grid = [[7, 2, 5, 6, 1, 4, 8, 3, 9, 0], [5, 1, 6, 7, 2, 8, 3, 9, 4, 0], [9, 8, 3, 4, 6, 5, 1, 0, 7, 2], [2, 0, 7, 1, 8, 9, 4, 3, 6, 5]]) == 186\n assert candidate(grid = [[10, 9, 8, 7, 6], [9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2]]) == 887\n assert candidate(grid = [[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5], [9, 7, 9, 3, 7, 8, 4, 6, 5, 4, 3], [2, 7, 1, 8, 2, 8, 1, 8, 2, 8, 4], [8, 5, 9, 0, 4, 5, 2, 3, 5, 3, 8], [4, 9, 5, 1, 8, 5, 2, 0, 9, 7, 4]]) == 224\n assert candidate(grid = [[10, 9, 8, 7, 6], [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]]) == 1673\n assert candidate(grid = [[1, 10, 9, 14, 13], [2, 3, 8, 12, 15], [5, 6, 7, 11, 16], [17, 18, 19, 20, 21]]) == 328\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 65\n assert candidate(grid = [[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]]) == 25\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 431\n assert candidate(grid = [[10, 9, 8, 7, 6], [11, 10, 9, 8, 7], [12, 11, 10, 9, 8], [13, 12, 11, 10, 9], [14, 13, 12, 11, 10]]) == 887\n assert candidate(grid = [[10, 1, 10, 1, 10], [1, 10, 1, 10, 1], [10, 1, 10, 1, 10], [1, 10, 1, 10, 1], [10, 1, 10, 1, 10]]) == 65\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 12309\n assert candidate(grid = [[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], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 880\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]]) == 215\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 105\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, 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], [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], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 1540\n assert candidate(grid = [[1, 2, 3, 2, 1], [2, 3, 4, 3, 2], [3, 4, 5, 4, 3], [2, 3, 4, 3, 2], [1, 2, 3, 2, 1]]) == 189\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, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 550\n assert candidate(grid = [[1, 10, 100], [10, 100, 1000], [100, 1000, 10000]]) == 53\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]]) == 45\n assert candidate(grid = [[5, 3, 2], [1, 4, 6], [7, 8, 9]]) == 41\n assert candidate(grid = [[3, 1, 4, 1, 5], [9, 2, 6, 5, 3], [5, 8, 9, 7, 9], [3, 2, 3, 8, 4], [2, 7, 1, 8, 2]]) == 112\n assert candidate(grid = [[1, 10, 1], [2, 11, 2], [3, 12, 3], [4, 13, 4], [5, 14, 5], [6, 15, 6], [7, 16, 7], [8, 17, 8], [9, 18, 9]]) == 465\n assert candidate(grid = [[10, 10, 10, 10], [10, 1, 1, 10], [10, 1, 1, 10], [10, 10, 10, 10]]) == 24\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 1, 2, 1, 5], [5, 3, 4, 3, 5], [5, 5, 5, 5, 5]]) == 54\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 55\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]]) == 887\n assert candidate(grid = [[1, 3, 2, 1], [1, 3, 2, 1], [1, 3, 2, 1]]) == 24\n assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [12, 11, 10], [13, 14, 15]]) == 476\n assert candidate(grid = [[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]]) == 887\n assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16]]) == 1276\n assert candidate(grid = [[5, 5, 5, 5], [5, 1, 2, 5], [5, 4, 3, 5], [5, 5, 5, 5]]) == 45\n assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [4, 5, 6]]) == 93\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]]) == 887\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == 226\n assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 330\n assert candidate(grid = [[1, 10, 100, 1000], [10, 100, 1000, 10000], [100, 1000, 10000, 100000], [1000, 10000, 100000, 1000000]]) == 226\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]]) == 25\n assert candidate(grid = [[1, 2], [4, 3], [2, 1], [3, 4]]) == 26\n assert candidate(grid = [[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]]) == 65\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 5], [3, 2, 1, 5, 4], [2, 1, 5, 4, 3], [1, 5, 4, 3, 2]]) == 149\n assert candidate(grid = [[10, 9, 8, 7], [9, 8, 7, 6], [8, 7, 6, 5], [7, 6, 5, 4]]) == 226\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20], [5, 10, 15, 20, 25]]) == 887\n assert candidate(grid = [[9, 8, 7, 6], [8, 7, 6, 5], [7, 6, 5, 4], [6, 5, 4, 3], [5, 4, 3, 2], [4, 3, 2, 1]]) == 756\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, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 385\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [2, 4, 6, 8, 10]]) == 133\n assert candidate(grid = [[1, 10, 100, 1000, 10000], [1, 10, 100, 1000, 10000], [1, 10, 100, 1000, 10000], [1, 10, 100, 1000, 10000]]) == 60\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]]) == 887\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, 5], [2, 1, 0, 5, 4], [1, 0, 5, 4, 3]]) == 229\n assert candidate(grid = [[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], [4, 1, 9, 7, 1, 6, 9, 3, 9], [9, 3, 7, 5, 1, 0, 5, 8, 2]]) == 285\n assert candidate(grid = [[1, 1000, 1, 1000, 1], [1000, 1, 1000, 1, 1000], [1, 1000, 1, 1000, 1], [1000, 1, 1000, 1, 1000], [1, 1000, 1, 1000, 1]]) == 65\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, 5]]) == 50\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]]) == 12309\n assert candidate(grid = [[10, 11, 16, 15, 4, 1, 5], [7, 6, 3, 16, 15, 10, 11], [14, 13, 12, 5, 18, 19, 20], [1, 2, 3, 4, 21, 22, 23], [24, 25, 26, 27, 28, 29, 30]]) == 508\n assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [5, 6, 7, 8], [8, 7, 6, 5]]) == 139\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]]) == 24\n assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41]]) == 481\n assert candidate(grid = [[5, 1, 4], [1, 5, 5], [4, 5, 5]]) == 19\n assert candidate(grid = [[1, 3, 1], [1, 5, 1], [1, 3, 1]]) == 21\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], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 135\n assert candidate(grid = [[10], [9], [8], [7], [6], [5], [4], [3], [2], [1]]) == 55\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [1, 2, 3, 4, 5]]) == 133\n assert candidate(grid = [[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]]) == 283\n assert candidate(grid = [[3, 2, 1], [6, 5, 4], [9, 8, 7]]) == 53\n assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == 4560\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 495\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countPaths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countPaths(int[][] grid) {", "container": "Solution", "callable": "countPaths", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2331, "task_id": "evaluate-boolean-binary-tree", "difficulty": "Easy", "problem_description": "You are given the root of a full binary tree with the following properties:\n\nLeaf nodes have either the value 0 or 1, where 0 represents False and 1 represents True.\nNon-leaf nodes have either the value 2 or 3, where 2 represents the boolean OR and 3 represents the boolean AND.\n\nThe evaluation of a node is as follows:\n\nIf the node is a leaf node, the evaluation is the value of the node, i.e. True or False.\nOtherwise, evaluate the node's two children and apply the boolean operation of its value with the children's evaluations.\n\nReturn the boolean result of evaluating the root node.\nA full binary tree is a binary tree where each node has either 0 or 2 children.\nA leaf node is a node that has zero children.\n \nExample 1:\n\n\nInput: root = [2,1,3,null,null,0,1]\nOutput: true\nExplanation: The above diagram illustrates the evaluation process.\nThe AND node evaluates to False AND True = False.\nThe OR node evaluates to True OR False = True.\nThe root node evaluates to True, so we return true.\nExample 2:\n\nInput: root = [0]\nOutput: false\nExplanation: The root node is a leaf node and it evaluates to false, so we return false.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 1000].\n0 <= Node.val <= 3\nEvery node has either 0 or 2 children.\nLeaf nodes have a value of 0 or 1.\nNon-leaf nodes have a value of 2 or 3.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([3, 1, 1, None, None, 0, 0])) == False\n assert candidate(root = tree_node([2, 3, 1, None, None, 0, 1])) == True\n assert candidate(root = tree_node([2, 3, 2, None, None, 1, 1, None, None, None, None])) == True\n assert candidate(root = tree_node([2, 1, 1])) == True\n assert candidate(root = tree_node([2, 3, 3, 1, 1, 0, 0])) == True\n assert candidate(root = tree_node([3, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1])) == True\n assert candidate(root = tree_node([3, 2, 2, None, None, 0, 0, None, None, 1, 0, None, None, 1, 1])) == True\n assert candidate(root = tree_node([3, 0, 0, None, None, None, None])) == False\n assert candidate(root = tree_node([3, 0, 1, None, None, None, None])) == False\n assert candidate(root = tree_node([3, 0, 0])) == False\n assert candidate(root = tree_node([2, 3, 3, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0])) == False\n assert candidate(root = tree_node([3, 0, 1])) == False\n assert candidate(root = tree_node([2, 2, 3, 0, 1, 0, 1])) == True\n assert candidate(root = tree_node([2, 3, 2, None, None, 0, 1, None, None, 0, 1])) == True\n assert candidate(root = tree_node([0])) == False\n assert candidate(root = tree_node([2, 3, 3, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([3, 2, 2, 0, 0, 1, 1])) == False\n assert candidate(root = tree_node([3, 3, 2, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([2, 1, 3, None, None, 0, 1])) == True\n assert candidate(root = tree_node([2, 2, 2, 1, 0, 0, 1])) == True\n assert candidate(root = tree_node([2, 3, 2, 0, 1, 1, 0])) == True\n assert candidate(root = tree_node([2, 1, 1, None, None, None, None])) == True\n assert candidate(root = tree_node([3, 2, 3, 3, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0])) == False\n assert candidate(root = tree_node([2, 2, 3, 2, 2, 2, 3, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([2, 2, 3, 1, 0, 3, 1, 0, 1, 0, 1, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([2, 3, 2, 3, 3, 2, 2, 3, 3, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1])) == True\n assert candidate(root = tree_node([3, 2, 2, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([3, 2, 3, 2, 1, 0, 1, None, None, None, None, 1, 0])) == False\n assert candidate(root = tree_node([2, 2, 3, 1, 3, 0, 1, 0, 1, 3, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([3, 2, 3, 2, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0])) == False\n assert candidate(root = tree_node([2, 2, 3, 1, 3, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0])) == False\n assert candidate(root = tree_node([2, 3, 2, 3, 2, 3, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([2, 3, 2, 2, 3, 2, 3, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([2, 3, 2, 3, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 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, 0, 0, 0, 0, 1, 1, 1, 1])) == True\n assert candidate(root = tree_node([2, 3, 2, 0, 1, 3, 1, 0, 0, 1, 1, 0, 1, 1, 0])) == False\n assert candidate(root = tree_node([2, 3, 2, 3, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([2, 3, 2, 3, 2, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([2, 3, 3, 2, 0, 0, 1, 3, 1, 0, 1, 3, 0, 1, 0])) == False\n assert candidate(root = tree_node([3, 3, 3, 3, 3, 3, 3, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([3, 2, 2, 0, 1, 1, 0, 3, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([2, 3, 2, 2, 1, 0, 1, 2, 1, 0, 0, 1, 1, 0, 0])) == True\n assert candidate(root = tree_node([2, 2, 2, 1, 2, 1, 3, 0, 0, 0, 1, 1, 0, 1, 0])) == True\n assert candidate(root = tree_node([3, 3, 3, 2, 2, 2, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([3, 3, 3, 2, 1, 1, 0, 2, 0, 1, 1, 0, 2, 0, 1])) == False\n assert candidate(root = tree_node([3, 2, 2, 3, 3, 3, 3, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([3, 2, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3, 2, 3, 2, 3, 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, 0, 0, 0, 0, 1, 1, 1, 1])) == False\n assert candidate(root = tree_node([2, 3, 2, 3, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([3, 2, 2, 1, 0, 0, 1, 3, 1, 0, 1, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([2, 2, 2, 2, 2, 2, 2, 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])) == False\n assert candidate(root = tree_node([3, 2, 3, 1, 1, 1, 1, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0])) == False\n assert candidate(root = tree_node([3, 3, 2, 3, 2, 3, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([3, 2, 3, 0, 1, 2, 1, 3, 0, 1, 0, 1, 3, 0, 1])) == False\n assert candidate(root = tree_node([2, 3, 2, 1, 0, 3, 1, 1, 0, 0, 1, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([3, 2, 2, 1, 0, 1, 0, 3, 1, 0, 1, 0, 3, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([3, 2, 2, 2, 2, 2, 2, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([3, 2, 2, 2, 0, 0, 1, 3, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([2, 2, 3, 2, 3, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1])) == False\n assert candidate(root = tree_node([2, 3, 3, 2, 3, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([2, 3, 3, 2, 2, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0])) == True\n assert candidate(root = tree_node([3, 2, 2, 3, 3, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([2, 2, 2, 3, 3, 1, 1, 3, 1, 0, 3, 0, 1, 3, 0])) == True\n assert candidate(root = tree_node([2, 3, 3, 3, 1, 0, 1, 2, 0, 1, 0, 1, 0, 1, 1])) == False\n assert candidate(root = tree_node([2, 1, 2, 3, 0, 3, 1, 1, 0, 3, 0, 1, 1, 0, 1, 0, 3, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([3, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0])) == False\n assert candidate(root = tree_node([3, 2, 2, 2, 1, 3, 0, 1, 0, 0, 1, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([2, 2, 3, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1])) == True\n assert candidate(root = tree_node([2, 2, 3, 2, 3, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1])) == True\n assert candidate(root = tree_node([3, 3, 3, 2, 2, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1])) == False\n assert candidate(root = tree_node([2, 3, 2, 3, 2, 3, 2, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1])) == True\n assert candidate(root = tree_node([3, 3, 3, 3, 3, 2, 2, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1])) == False\n assert candidate(root = tree_node([2, 2, 2, 3, 3, 3, 3, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([2, 1, 2, 3, 0, 1, 1, None, None, None, None, 0, 0])) == True\n assert candidate(root = tree_node([2, 3, 3, 3, 2, 2, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([3, 2, 2, 3, 3, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])) == False\n assert candidate(root = tree_node([2, 3, 2, 2, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0])) == False\n assert candidate(root = tree_node([3, 2, 3, 3, 1, 1, 0, 2, 1, 0, 1, 2, 1, 0, 0])) == False\n assert candidate(root = tree_node([3, 2, 2, 3, 1, 0, 1, 2, 0, 1, 0, 2, 1, 0, 0])) == False\n assert candidate(root = tree_node([3, 3, 2, 3, 1, 2, 0, 1, 0, 0, 1, 0, 1, 1, 0])) == False\n assert candidate(root = tree_node([3, 2, 2, 3, 1, 3, 3, 1, 0, 1, 0, 1, 0, 0, 1])) == False\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().evaluateTree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2332, "task_id": "the-latest-time-to-catch-a-bus", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array buses of length n, where buses[i] represents the departure time of the ith bus. You are also given a 0-indexed integer array passengers of length m, where passengers[j] represents the arrival time of the jth passenger. All bus departure times are unique. All passenger arrival times are unique.\nYou are given an integer capacity, which represents the maximum number of passengers that can get on each bus.\nWhen a passenger arrives, they will wait in line for the next available bus. You can get on a bus that departs at x minutes if you arrive at y minutes where y <= x, and the bus is not full. Passengers with the earliest arrival times get on the bus first.\nMore formally when a bus arrives, either:\n\nIf capacity or fewer passengers are waiting for a bus, they will all get on the bus, or\nThe capacity passengers with the earliest arrival times will get on the bus.\n\nReturn the latest time you may arrive at the bus station to catch a bus. You cannot arrive at the same time as another passenger.\nNote: The arrays buses and passengers are not necessarily sorted.\n \nExample 1:\n\nInput: buses = [10,20], passengers = [2,17,18,19], capacity = 2\nOutput: 16\nExplanation: Suppose you arrive at time 16.\nAt time 10, the first bus departs with the 0th passenger. \nAt time 20, the second bus departs with you and the 1st passenger.\nNote that you may not arrive at the same time as another passenger, which is why you must arrive before the 1st passenger to catch the bus.\nExample 2:\n\nInput: buses = [20,30,10], passengers = [19,13,26,4,25,11,21], capacity = 2\nOutput: 20\nExplanation: Suppose you arrive at time 20.\nAt time 10, the first bus departs with the 3rd passenger. \nAt time 20, the second bus departs with the 5th and 1st passengers.\nAt time 30, the third bus departs with the 0th passenger and you.\nNotice if you had arrived any later, then the 6th passenger would have taken your seat on the third bus.\n \nConstraints:\n\nn == buses.length\nm == passengers.length\n1 <= n, m, capacity <= 105\n2 <= buses[i], passengers[i] <= 109\nEach element in buses is unique.\nEach element in passengers is unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(buses = [50, 60, 70],passengers = [5, 10, 20, 30, 40],capacity = 5) == 70\n assert candidate(buses = [3, 5, 7],passengers = [2, 4, 6, 8],capacity = 1) == 5\n assert candidate(buses = [2, 4, 6, 8, 10],passengers = [1, 3, 5, 7, 9],capacity = 1) == 8\n assert candidate(buses = [3, 8, 15, 25],passengers = [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],capacity = 5) == 0\n assert candidate(buses = [10, 20],passengers = [2, 17, 18, 19],capacity = 2) == 16\n assert candidate(buses = [10, 20, 30],passengers = [1, 2, 3, 4, 5, 6, 7, 8, 9],capacity = 3) == 0\n assert candidate(buses = [10, 20, 30, 40],passengers = [5, 10, 15, 20, 25, 30, 35, 40],capacity = 1) == 19\n assert candidate(buses = [100, 200],passengers = [99, 101, 102, 103],capacity = 2) == 100\n assert candidate(buses = [100],passengers = [99],capacity = 1) == 98\n assert candidate(buses = [5, 10, 20],passengers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],capacity = 3) == 0\n assert candidate(buses = [30],passengers = [19, 13, 26, 4, 25, 11, 21],capacity = 3) == 12\n assert candidate(buses = [100],passengers = [10],capacity = 1) == 9\n assert candidate(buses = [20, 30, 10],passengers = [19, 13, 26, 4, 25, 11, 21],capacity = 2) == 20\n assert candidate(buses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],passengers = [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],capacity = 2) == 38\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [10, 20, 30, 40, 50],capacity = 1) == 49\n assert candidate(buses = [100, 200, 300, 400, 500],passengers = [50, 150, 250, 350, 450, 50, 150, 250, 350, 450, 50, 150, 250, 350, 450, 50, 150, 250, 350, 450, 50, 150, 250, 350, 450, 50, 150, 250, 350, 450, 50, 150, 250, 350, 450],capacity = 5) == 349\n assert candidate(buses = [5, 15, 25, 35, 45],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44],capacity = 4) == 35\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],capacity = 2) == 50\n assert candidate(buses = [15, 25, 35, 45, 55],passengers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],capacity = 5) == 55\n assert candidate(buses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],passengers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],capacity = 1) == 18\n assert candidate(buses = [5, 12, 19, 26, 33],passengers = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],capacity = 2) == 26\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [9, 19, 29, 39, 49],capacity = 1) == 48\n assert candidate(buses = [100, 200, 300, 400, 500],passengers = [50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500],capacity = 3) == 399\n assert candidate(buses = [15, 30, 45, 60, 75],passengers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],capacity = 3) == 75\n assert candidate(buses = [5, 10, 20, 30, 40],passengers = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],capacity = 2) == 26\n assert candidate(buses = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],passengers = [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],capacity = 1) == 19\n assert candidate(buses = [5, 15, 25, 35, 45],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44],capacity = 5) == 43\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [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],capacity = 5) == 48\n assert candidate(buses = [100, 200, 300],passengers = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],capacity = 5) == 189\n assert candidate(buses = [100, 200, 300],passengers = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],capacity = 2) == 299\n assert candidate(buses = [12, 24, 36, 48, 60],passengers = [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],capacity = 5) == 49\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [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],capacity = 5) == 0\n assert candidate(buses = [30, 60, 90, 120, 150],passengers = [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],capacity = 4) == 99\n assert candidate(buses = [100, 200, 300, 400, 500],passengers = [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],capacity = 10) == 500\n assert candidate(buses = [20, 30, 40, 50, 60],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],capacity = 2) == 49\n assert candidate(buses = [15, 30, 45, 60, 75],passengers = [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],capacity = 5) == 74\n assert candidate(buses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],passengers = [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],capacity = 1) == 18\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],capacity = 2) == 44\n assert candidate(buses = [50, 60, 70, 80, 90],passengers = [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],capacity = 10) == 0\n assert candidate(buses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],passengers = [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],capacity = 1) == 49\n assert candidate(buses = [5, 15, 25, 35, 45, 55],passengers = [4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54],capacity = 1) == 28\n assert candidate(buses = [100, 200, 300],passengers = [50, 99, 101, 149, 151, 299, 301],capacity = 2) == 298\n assert candidate(buses = [20, 50, 70, 100],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],capacity = 5) == 94\n assert candidate(buses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],passengers = [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],capacity = 3) == 63\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],capacity = 2) == 49\n assert candidate(buses = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],passengers = [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],capacity = 10) == 500\n assert candidate(buses = [10, 15, 20, 25, 30],passengers = [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],capacity = 5) == 0\n assert candidate(buses = [100, 200, 300, 400, 500],passengers = [1, 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],capacity = 10) == 489\n assert candidate(buses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],passengers = [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],capacity = 1) == 0\n assert candidate(buses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],passengers = [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],capacity = 4) == 0\n assert candidate(buses = [15, 25, 35, 45, 55],passengers = [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],capacity = 5) == 0\n assert candidate(buses = [15, 25, 35, 45, 55],passengers = [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],capacity = 3) == 28\n assert candidate(buses = [20, 40, 60, 80, 100],passengers = [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],capacity = 2) == 18\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [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],capacity = 2) == 18\n assert candidate(buses = [5, 15, 25, 35, 45],passengers = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44],capacity = 4) == 35\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],capacity = 3) == 0\n assert candidate(buses = [20, 40, 60, 80, 100],passengers = [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],capacity = 2) == 18\n assert candidate(buses = [10, 25, 50, 75, 100],passengers = [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],capacity = 1) == 0\n assert candidate(buses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],passengers = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99],capacity = 1) == 98\n assert candidate(buses = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],passengers = [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],capacity = 3) == 134\n assert candidate(buses = [100, 200, 300, 400, 500],passengers = [50, 150, 250, 350, 450],capacity = 1) == 449\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacity = 1) == 39\n assert candidate(buses = [100, 200, 300, 400, 500],passengers = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310],capacity = 10) == 500\n assert candidate(buses = [100, 120, 140, 160, 180],passengers = [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],capacity = 10) == 179\n assert candidate(buses = [100, 200, 300, 400, 500],passengers = [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],capacity = 15) == 0\n assert candidate(buses = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],passengers = [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],capacity = 3) == 99\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [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],capacity = 4) == 0\n assert candidate(buses = [5, 10, 20, 25],passengers = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacity = 3) == 1\n assert candidate(buses = [100, 200, 300],passengers = [50, 150, 250, 350],capacity = 3) == 300\n assert candidate(buses = [5, 15, 25, 35, 45],passengers = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60],capacity = 2) == 35\n assert candidate(buses = [10, 25, 40, 55],passengers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 27, 29, 31, 33, 35, 37, 39, 41, 43, 47, 49, 51, 53, 57, 59],capacity = 6) == 48\n assert candidate(buses = [20, 30, 40, 50, 60],passengers = [5, 15, 25, 35, 45, 55, 65],capacity = 2) == 60\n assert candidate(buses = [5, 15, 25, 35, 45, 55],passengers = [1, 3, 5, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 49],capacity = 3) == 40\n assert candidate(buses = [5, 15, 25, 35, 45, 55],passengers = [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],capacity = 3) == 0\n assert candidate(buses = [15, 30, 45, 60],passengers = [3, 4, 6, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 47, 49, 51, 53, 57, 59],capacity = 5) == 38\n assert candidate(buses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],capacity = 2) == 99\n assert candidate(buses = [5, 15, 25, 35, 45],passengers = [2, 5, 7, 10, 15, 18, 20, 22, 25, 30, 32, 35, 40, 42, 45],capacity = 3) == 41\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],capacity = 4) == 50\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [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],capacity = 3) == 29\n assert candidate(buses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],passengers = [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],capacity = 5) == 0\n assert candidate(buses = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],passengers = [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],capacity = 5) == 0\n assert candidate(buses = [100, 200, 300, 400],passengers = [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],capacity = 3) == 0\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [5, 15, 25, 35, 45, 55],capacity = 1) == 44\n assert candidate(buses = [10, 20, 30],passengers = [1, 2, 3, 4, 5, 6, 7, 8, 9],capacity = 4) == 30\n assert candidate(buses = [100, 200, 300, 400, 500],passengers = [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, 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],capacity = 50) == 500\n assert candidate(buses = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacity = 1) == 21\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],capacity = 1) == 44\n assert candidate(buses = [3, 8, 15, 25, 30, 40, 50],passengers = [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],capacity = 5) == 0\n assert candidate(buses = [1000, 2000, 3000],passengers = [500, 1500, 2500, 3500, 4500],capacity = 2) == 3000\n assert candidate(buses = [10, 15, 20, 25, 30],passengers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],capacity = 3) == 30\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacity = 2) == 49\n assert candidate(buses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],passengers = [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],capacity = 2) == 38\n assert candidate(buses = [10, 20, 30, 40, 50],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacity = 1) == 24\n"}, "metadata": {"canonical_parameter_names": ["buses", "passengers", "capacity"], "leetcode_dataset_entry_point": "Solution().latestTimeCatchTheBus", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int latestTimeCatchTheBus(int[] buses, int[] passengers, int capacity) {", "container": "Solution", "callable": "latestTimeCatchTheBus", "parameters": [{"name": "buses", "type": "int[]"}, {"name": "passengers", "type": "int[]"}, {"name": "capacity", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2333, "task_id": "minimum-sum-of-squared-difference", "difficulty": "Medium", "problem_description": "You are given two positive 0-indexed integer arrays nums1 and nums2, both of length n.\nThe sum of squared difference of arrays nums1 and nums2 is defined as the sum of (nums1[i] - nums2[i])2 for each 0 <= i < n.\nYou are also given two positive integers k1 and k2. You can modify any of the elements of nums1 by +1 or -1 at most k1 times. Similarly, you can modify any of the elements of nums2 by +1 or -1 at most k2 times.\nReturn the minimum sum of squared difference after modifying array nums1 at most k1 times and modifying array nums2 at most k2 times.\nNote: You are allowed to modify the array elements to become negative integers.\n \nExample 1:\n\nInput: nums1 = [1,2,3,4], nums2 = [2,10,20,19], k1 = 0, k2 = 0\nOutput: 579\nExplanation: The elements in nums1 and nums2 cannot be modified because k1 = 0 and k2 = 0. \nThe sum of square difference will be: (1 - 2)2 + (2 - 10)2 + (3 - 20)2 + (4 - 19)2 = 579.\n\nExample 2:\n\nInput: nums1 = [1,4,10,12], nums2 = [5,8,6,9], k1 = 1, k2 = 1\nOutput: 43\nExplanation: One way to obtain the minimum sum of square difference is: \n- Increase nums1[0] once.\n- Increase nums2[2] once.\nThe minimum of the sum of square difference will be: \n(2 - 5)2 + (4 - 8)2 + (10 - 7)2 + (12 - 9)2 = 43.\nNote that, there are other ways to obtain the minimum of the sum of square difference, but there is no way to obtain a sum smaller than 43.\n \nConstraints:\n\nn == nums1.length == nums2.length\n1 <= n <= 105\n0 <= nums1[i], nums2[i] <= 105\n0 <= k1, k2 <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [5, 5, 5, 5],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],k1 = 50,k2 = 50) == 0\n assert candidate(nums1 = [100000, 100000],nums2 = [0, 0],k1 = 100000,k2 = 100000) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k1 = 1,k2 = 1) == 3\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1],k1 = 3,k2 = 3) == 0\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [100, 100, 100, 100],k1 = 200,k2 = 200) == 0\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1],k1 = 10,k2 = 10) == 0\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [2, 10, 20, 19],k1 = 0,k2 = 0) == 579\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1],k1 = 2,k2 = 2) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1],k1 = 4,k2 = 4) == 16\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [5, 5, 5, 5, 5],k1 = 5,k2 = 5) == 20\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0],k1 = 5,k2 = 5) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],k1 = 5,k2 = 5) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k1 = 50,k2 = 50) == 0\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [10, 10, 10, 10],k1 = 20,k2 = 20) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],k1 = 3,k2 = 3) == 10\n assert candidate(nums1 = [0, 0, 0],nums2 = [100, 100, 100],k1 = 150,k2 = 150) == 0\n assert candidate(nums1 = [10, 20, 30],nums2 = [1, 2, 3],k1 = 25,k2 = 25) == 6\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],k1 = 5,k2 = 5) == 0\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 1, 1, 1],k1 = 2,k2 = 2) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [10, 10, 10, 10],k1 = 10,k2 = 10) == 64\n assert candidate(nums1 = [3, 5, 7, 9],nums2 = [4, 6, 8, 10],k1 = 3,k2 = 3) == 0\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [0, 0, 0],k1 = 300000,k2 = 300000) == 0\n assert candidate(nums1 = [1, 4, 10, 12],nums2 = [5, 8, 6, 9],k1 = 1,k2 = 1) == 43\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [0, 0, 0],k1 = 100000,k2 = 100000) == 3333333334\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1],k1 = 10,k2 = 10) == 0\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [0, 0, 0],k1 = 100000,k2 = 100000) == 3333333334\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [5000, 4000, 3000, 2000, 1000],k1 = 2000,k2 = 2000) == 16000000\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [100000, 90000, 80000, 70000],nums2 = [60000, 50000, 40000, 30000],k1 = 500000,k2 = 500000) == 0\n assert candidate(nums1 = [100000, 50000, 25000, 10000],nums2 = [90000, 60000, 35000, 15000],k1 = 50000,k2 = 50000) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],k1 = 1000000,k2 = 1000000) == 0\n assert candidate(nums1 = [100000, 50000, 25000],nums2 = [0, 0, 0],k1 = 500000,k2 = 500000) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],k1 = 50,k2 = 50) == 245\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k1 = 1000,k2 = 1000) == 1298535\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [100, 100, 100, 100, 100],k1 = 300,k2 = 300) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k1 = 1000000000,k2 = 1000000000) == 0\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9],k1 = 10,k2 = 10) == 52\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 50,k2 = 50) == 0\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],k1 = 0,k2 = 0) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [50000, 50000, 50000],nums2 = [0, 0, 0],k1 = 150000,k2 = 150000) == 0\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [500, 1000, 1500, 2000, 2500],k1 = 1000,k2 = 1000) == 6583334\n assert candidate(nums1 = [100, 200, 300],nums2 = [300, 200, 100],k1 = 150,k2 = 150) == 5000\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [500, 1500, 2500, 3500, 4500],k1 = 100000,k2 = 100000) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k1 = 150,k2 = 150) == 4252\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [3, 6, 9, 12, 15, 18],k1 = 20,k2 = 25) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],k1 = 10,k2 = 10) == 5\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [150, 250, 350, 450],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],k1 = 10,k2 = 10) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k1 = 50,k2 = 50) == 0\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [105, 205, 305, 405],k1 = 10,k2 = 10) == 0\n assert candidate(nums1 = [50, 50, 50, 50, 50],nums2 = [1, 2, 3, 4, 5],k1 = 200,k2 = 200) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 5,k2 = 5) == 810\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],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [100000, 0, 50000],nums2 = [0, 100000, 50000],k1 = 100000,k2 = 100000) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k1 = 100,k2 = 100) == 12728\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5],k1 = 20,k2 = 20) == 0\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],k1 = 0,k2 = 0) == 0\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],k1 = 0,k2 = 0) == 330\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k1 = 500,k2 = 500) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],k1 = 10,k2 = 10) == 0\n assert candidate(nums1 = [50, 50, 50, 50, 50],nums2 = [0, 0, 0, 0, 0],k1 = 50,k2 = 50) == 4500\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],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 20,k2 = 20) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 100,k2 = 100) == 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],k1 = 1000,k2 = 1000) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [100, 100, 100, 100, 100],k1 = 100,k2 = 100) == 175000\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [50000, 40000, 30000, 20000, 10000],k1 = 1000000,k2 = 1000000) == 0\n assert candidate(nums1 = [100, 100, 100, 100, 100, 100],nums2 = [1, 1, 1, 1, 1, 1],k1 = 300,k2 = 300) == 0\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [500, 1500, 2500, 3500, 4500],k1 = 2000,k2 = 2000) == 0\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10],k1 = 20,k2 = 20) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 50,k2 = 50) == 0\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],k1 = 50,k2 = 50) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 1, 1, 1, 1],k1 = 10,k2 = 10) == 0\n assert candidate(nums1 = [50000, 40000, 30000, 20000, 10000],nums2 = [50000, 40000, 30000, 20000, 10000],k1 = 0,k2 = 0) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3, 4, 5],k1 = 1000,k2 = 1000) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [100000, 100000, 100000, 100000, 100000],k1 = 50000,k2 = 50000) == 31999200005\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55],k1 = 15,k2 = 20) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [10, 20, 30, 40, 50],k1 = 10000,k2 = 10000) == 0\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],k1 = 10,k2 = 10) == 0\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],k1 = 0,k2 = 0) == 330\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k1 = 500,k2 = 500) == 0\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],k1 = 20,k2 = 20) == 10\n assert candidate(nums1 = [50, 50, 50, 50, 50],nums2 = [100, 100, 100, 100, 100],k1 = 150,k2 = 150) == 0\n assert candidate(nums1 = [100000, 90000, 80000, 70000],nums2 = [60000, 50000, 40000, 30000],k1 = 1000000,k2 = 1000000) == 0\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],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k1 = 1000,k2 = 1000) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 5,k2 = 5) == 160\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [90, 190, 290, 390, 490],k1 = 5,k2 = 5) == 320\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k1 = 500,k2 = 500) == 0\n assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000],nums2 = [1, 2, 3, 4, 5],k1 = 1000000,k2 = 1000000) == 0\n assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000],nums2 = [50000, 40000, 30000, 20000, 10000],k1 = 1000000,k2 = 1000000) == 0\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],k1 = 20,k2 = 20) == 10\n assert candidate(nums1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k1 = 100,k2 = 100) == 0\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],k1 = 50,k2 = 50) == 0\n assert candidate(nums1 = [100, 200, 300],nums2 = [1, 1, 1],k1 = 500,k2 = 500) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [50, 150, 250, 350, 450],k1 = 1000,k2 = 1000) == 0\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [0, 0, 0],k1 = 150000,k2 = 150000) == 0\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],k1 = 50,k2 = 50) == 0\n assert candidate(nums1 = [100000, 100000, 100000, 100000, 100000],nums2 = [0, 0, 0, 0, 0],k1 = 1000000,k2 = 1000000) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],k1 = 25,k2 = 25) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [100, 90, 80, 70, 60],k1 = 500,k2 = 500) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k1 = 500,k2 = 500) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5],k1 = 100,k2 = 100) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [3, 8, 13, 18, 23],k1 = 25,k2 = 25) == 0\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [1, 2, 3, 4, 5],k1 = 1000000,k2 = 1000000) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100],k1 = 1000,k2 = 1000) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3, 4, 5],k1 = 1000,k2 = 1000) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k1 = 1500000,k2 = 1500000) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50],k1 = 250,k2 = 250) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k1 = 1000,k2 = 1000) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "k1", "k2"], "leetcode_dataset_entry_point": "Solution().minSumSquareDiff", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minSumSquareDiff(int[] nums1, int[] nums2, int k1, int k2) {", "container": "Solution", "callable": "minSumSquareDiff", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}, {"name": "k1", "type": "int"}, {"name": "k2", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2334, "task_id": "subarray-with-elements-greater-than-varying-threshold", "difficulty": "Hard", "problem_description": "You are given an integer array nums and an integer threshold.\nFind any subarray of nums of length k such that every element in the subarray is greater than threshold / k.\nReturn the size of any such subarray. If there is no such subarray, return -1.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,3,4,3,1], threshold = 6\nOutput: 3\nExplanation: The subarray [3,4,3] has a size of 3, and every element is greater than 6 / 3 = 2.\nNote that this is the only valid subarray.\n\nExample 2:\n\nInput: nums = [6,5,6,5,8], threshold = 7\nOutput: 1\nExplanation: The subarray [8] has a size of 1, and 8 > 7 / 1 = 7. So 1 is returned.\nNote that the subarray [6,5] has a size of 2, and every element is greater than 7 / 2 = 3.5. \nSimilarly, the subarrays [6,5,6], [6,5,6,5], [6,5,6,5,8] also satisfy the given conditions.\nTherefore, 2, 3, 4, or 5 may also be returned.\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i], threshold <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],threshold = 15) == 1\n assert candidate(nums = [10, 10, 10, 10, 10],threshold = 1) == 1\n assert candidate(nums = [5, 5, 5, 5, 5],threshold = 25) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 55) == -1\n assert candidate(nums = [10, 20, 30, 40, 50],threshold = 100) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 5) == 2\n assert candidate(nums = [2, 2, 2, 2, 2],threshold = 10) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],threshold = 15) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 45) == -1\n assert candidate(nums = [5, 4, 3, 2, 1],threshold = 10) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 50) == -1\n assert candidate(nums = [6, 5, 6, 5, 8],threshold = 7) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 30) == -1\n assert candidate(nums = [1, 3, 4, 3, 1],threshold = 6) == 3\n assert candidate(nums = [100, 200, 300, 400, 500],threshold = 1000) == -1\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],threshold = 20) == 21\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],threshold = 10) == 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],threshold = 10) == 11\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],threshold = 500) == -1\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],threshold = 50) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 5) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],threshold = 225) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],threshold = 45) == 1\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9],threshold = 8) == 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],threshold = 50) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10],threshold = 45) == -1\n assert candidate(nums = [5, 10, 15, 20, 25],threshold = 100) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],threshold = 1000) == -1\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],threshold = 1285) == -1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],threshold = 100) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 95) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],threshold = 1000) == -1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],threshold = 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],threshold = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 1) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 20) == 3\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],threshold = 1000000000) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 100) == -1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],threshold = 15) == 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],threshold = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 55) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 50) == -1\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],threshold = 20) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 20) == 5\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],threshold = 10000000000) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],threshold = 120) == -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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = 1000) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],threshold = 450) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 25) == -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],threshold = 190) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 25) == 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],threshold = 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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) == 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],threshold = 1950) == -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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = 1000000000) == -1\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 200) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],threshold = 100) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 45) == -1\n assert candidate(nums = [1, 1000000000, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 1000000000) == -1\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1],threshold = 400) == -1\n assert candidate(nums = [100, 200, 300, 400, 500],threshold = 1000) == -1\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],threshold = 18) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],threshold = 20) == 5\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100],threshold = 250) == 4\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],threshold = 1000000000) == 2\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],threshold = 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],threshold = 10) == 4\n assert candidate(nums = [5, 8, 7, 3, 9, 10, 2, 1, 6],threshold = 20) == -1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],threshold = 500000000) == 1\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],threshold = 50) == -1\n assert candidate(nums = [5, 1, 4, 3, 9, 8, 10],threshold = 30) == -1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 100) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 20) == 3\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 20) == 3\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],threshold = 450) == -1\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],threshold = 25) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 45) == -1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],threshold = 50) == -1\n assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],threshold = 100) == -1\n assert candidate(nums = [1, 3, 2, 6, 5, 4, 7, 9, 8, 10],threshold = 15) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 25) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],threshold = 100) == -1\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],threshold = 10) == -1\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],threshold = 210) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],threshold = 20) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],threshold = 900) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],threshold = 5000) == -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],threshold = 90) == 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],threshold = 100) == -1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],threshold = 500) == 6\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],threshold = 10) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 20) == 3\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],threshold = 5000000000) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],threshold = 495) == -1\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 2, 1, 3, 4],threshold = 10) == 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],threshold = 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],threshold = 200) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],threshold = 100) == -1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],threshold = 50) == 4\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],threshold = 49) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],threshold = 1285) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],threshold = 550) == -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],threshold = 240) == -1\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],threshold = 900) == -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],threshold = 5) == 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],threshold = 90) == 7\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],threshold = 9) == 1\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],threshold = 45) == -1\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],threshold = 15) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],threshold = 100) == -1\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],threshold = 550) == -1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],threshold = 1000000000) == 2\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],threshold = 275) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 25) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 45) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums", "threshold"], "leetcode_dataset_entry_point": "Solution().validSubarraySize", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int validSubarraySize(int[] nums, int threshold) {", "container": "Solution", "callable": "validSubarraySize", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "threshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2335, "task_id": "minimum-amount-of-time-to-fill-cups", "difficulty": "Easy", "problem_description": "You have a water dispenser that can dispense cold, warm, and hot water. Every second, you can either fill up 2 cups with different types of water, or 1 cup of any type of water.\nYou are given a 0-indexed integer array amount of length 3 where amount[0], amount[1], and amount[2] denote the number of cold, warm, and hot water cups you need to fill respectively. Return the minimum number of seconds needed to fill up all the cups.\n \nExample 1:\n\nInput: amount = [1,4,2]\nOutput: 4\nExplanation: One way to fill up the cups is:\nSecond 1: Fill up a cold cup and a warm cup.\nSecond 2: Fill up a warm cup and a hot cup.\nSecond 3: Fill up a warm cup and a hot cup.\nSecond 4: Fill up a warm cup.\nIt can be proven that 4 is the minimum number of seconds needed.\n\nExample 2:\n\nInput: amount = [5,4,4]\nOutput: 7\nExplanation: One way to fill up the cups is:\nSecond 1: Fill up a cold cup, and a hot cup.\nSecond 2: Fill up a cold cup, and a warm cup.\nSecond 3: Fill up a cold cup, and a warm cup.\nSecond 4: Fill up a warm cup, and a hot cup.\nSecond 5: Fill up a cold cup, and a hot cup.\nSecond 6: Fill up a cold cup, and a warm cup.\nSecond 7: Fill up a hot cup.\n\nExample 3:\n\nInput: amount = [5,0,0]\nOutput: 5\nExplanation: Every second, we fill up a cold cup.\n\n \nConstraints:\n\namount.length == 3\n0 <= amount[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(amount = [33, 33, 34]) == 50\n assert candidate(amount = [0, 0, 0]) == 0\n assert candidate(amount = [99, 1, 1]) == 99\n assert candidate(amount = [7, 7, 7]) == 11\n assert candidate(amount = [10, 10, 10]) == 15\n assert candidate(amount = [1, 2, 3]) == 3\n assert candidate(amount = [100, 0, 0]) == 100\n assert candidate(amount = [100, 100, 100]) == 150\n assert candidate(amount = [0, 1, 2]) == 2\n assert candidate(amount = [1, 4, 2]) == 4\n assert candidate(amount = [5, 0, 0]) == 5\n assert candidate(amount = [99, 99, 1]) == 100\n assert candidate(amount = [0, 50, 50]) == 50\n assert candidate(amount = [5, 4, 4]) == 7\n assert candidate(amount = [98, 1, 1]) == 98\n assert candidate(amount = [25, 0, 75]) == 75\n assert candidate(amount = [42, 42, 41]) == 63\n assert candidate(amount = [60, 20, 20]) == 60\n assert candidate(amount = [10, 50, 25]) == 50\n assert candidate(amount = [49, 49, 49]) == 74\n assert candidate(amount = [1, 1, 0]) == 1\n assert candidate(amount = [80, 10, 10]) == 80\n assert candidate(amount = [1, 10, 10]) == 11\n assert candidate(amount = [1, 1, 100]) == 100\n assert candidate(amount = [10, 90, 0]) == 90\n assert candidate(amount = [10, 80, 10]) == 80\n assert candidate(amount = [0, 0, 100]) == 100\n assert candidate(amount = [80, 10, 10]) == 80\n assert candidate(amount = [33, 33, 34]) == 50\n assert candidate(amount = [70, 70, 60]) == 100\n assert candidate(amount = [50, 25, 25]) == 50\n assert candidate(amount = [29, 29, 42]) == 50\n assert candidate(amount = [50, 50, 49]) == 75\n assert candidate(amount = [99, 2, 99]) == 100\n assert candidate(amount = [50, 49, 51]) == 75\n assert candidate(amount = [100, 1, 1]) == 100\n assert candidate(amount = [80, 70, 60]) == 105\n assert candidate(amount = [100, 50, 25]) == 100\n assert candidate(amount = [1, 0, 1]) == 1\n assert candidate(amount = [40, 30, 20]) == 45\n assert candidate(amount = [1, 2, 97]) == 97\n assert candidate(amount = [1, 1, 1]) == 2\n assert candidate(amount = [49, 50, 1]) == 50\n assert candidate(amount = [30, 20, 10]) == 30\n assert candidate(amount = [100, 10, 10]) == 100\n assert candidate(amount = [2, 99, 99]) == 100\n assert candidate(amount = [1, 98, 1]) == 98\n assert candidate(amount = [1, 0, 99]) == 99\n assert candidate(amount = [80, 15, 5]) == 80\n assert candidate(amount = [45, 55, 0]) == 55\n assert candidate(amount = [100, 1, 1]) == 100\n assert candidate(amount = [50, 50, 1]) == 51\n assert candidate(amount = [25, 25, 25]) == 38\n assert candidate(amount = [42, 29, 29]) == 50\n assert candidate(amount = [100, 50, 1]) == 100\n assert candidate(amount = [1, 90, 10]) == 90\n assert candidate(amount = [1, 1, 1]) == 2\n assert candidate(amount = [0, 75, 25]) == 75\n assert candidate(amount = [55, 45, 5]) == 55\n assert candidate(amount = [10, 1, 90]) == 90\n assert candidate(amount = [100, 10, 0]) == 100\n assert candidate(amount = [80, 10, 1]) == 80\n assert candidate(amount = [48, 48, 48]) == 72\n assert candidate(amount = [80, 50, 30]) == 80\n assert candidate(amount = [90, 90, 1]) == 91\n assert candidate(amount = [1, 50, 50]) == 51\n assert candidate(amount = [55, 0, 45]) == 55\n assert candidate(amount = [49, 2, 49]) == 50\n assert candidate(amount = [45, 67, 23]) == 68\n assert candidate(amount = [20, 20, 60]) == 60\n assert candidate(amount = [100, 100, 99]) == 150\n assert candidate(amount = [10, 10, 100]) == 100\n assert candidate(amount = [50, 100, 50]) == 100\n assert candidate(amount = [10, 15, 20]) == 23\n assert candidate(amount = [0, 100, 100]) == 100\n assert candidate(amount = [60, 40, 20]) == 60\n assert candidate(amount = [0, 100, 0]) == 100\n assert candidate(amount = [50, 51, 50]) == 76\n assert candidate(amount = [33, 33, 33]) == 50\n assert candidate(amount = [23, 47, 29]) == 50\n assert candidate(amount = [51, 51, 51]) == 77\n assert candidate(amount = [50, 1, 50]) == 51\n assert candidate(amount = [25, 10, 50]) == 50\n assert candidate(amount = [55, 55, 45]) == 78\n assert candidate(amount = [0, 100, 10]) == 100\n assert candidate(amount = [90, 10, 1]) == 90\n assert candidate(amount = [33, 66, 0]) == 66\n assert candidate(amount = [99, 1, 0]) == 99\n assert candidate(amount = [50, 25, 10]) == 50\n assert candidate(amount = [49, 50, 51]) == 75\n assert candidate(amount = [60, 60, 61]) == 91\n assert candidate(amount = [29, 42, 29]) == 50\n assert candidate(amount = [50, 50, 50]) == 75\n assert candidate(amount = [25, 25, 26]) == 38\n assert candidate(amount = [34, 33, 34]) == 51\n assert candidate(amount = [2, 49, 49]) == 50\n assert candidate(amount = [25, 25, 25]) == 38\n assert candidate(amount = [1, 1, 2]) == 2\n assert candidate(amount = [1, 1, 99]) == 99\n assert candidate(amount = [60, 40, 20]) == 60\n assert candidate(amount = [60, 60, 60]) == 90\n assert candidate(amount = [33, 33, 67]) == 67\n assert candidate(amount = [10, 100, 10]) == 100\n assert candidate(amount = [5, 0, 5]) == 5\n assert candidate(amount = [1, 100, 1]) == 100\n assert candidate(amount = [80, 15, 5]) == 80\n assert candidate(amount = [99, 99, 99]) == 149\n assert candidate(amount = [66, 33, 0]) == 66\n assert candidate(amount = [2, 3, 4]) == 5\n assert candidate(amount = [5, 15, 80]) == 80\n assert candidate(amount = [30, 0, 20]) == 30\n assert candidate(amount = [50, 25, 25]) == 50\n assert candidate(amount = [47, 23, 29]) == 50\n assert candidate(amount = [100, 99, 98]) == 149\n assert candidate(amount = [90, 85, 80]) == 128\n assert candidate(amount = [67, 33, 33]) == 67\n assert candidate(amount = [98, 99, 1]) == 99\n assert candidate(amount = [15, 80, 5]) == 80\n assert candidate(amount = [10, 10, 80]) == 80\n assert candidate(amount = [3, 2, 1]) == 3\n assert candidate(amount = [23, 45, 67]) == 68\n assert candidate(amount = [50, 50, 100]) == 100\n assert candidate(amount = [90, 10, 90]) == 95\n assert candidate(amount = [99, 98, 97]) == 147\n assert candidate(amount = [1, 99, 1]) == 99\n assert candidate(amount = [45, 55, 55]) == 78\n assert candidate(amount = [75, 25, 0]) == 75\n assert candidate(amount = [0, 0, 100]) == 100\n assert candidate(amount = [1, 100, 1]) == 100\n assert candidate(amount = [1, 2, 1]) == 2\n assert candidate(amount = [70, 20, 10]) == 70\n assert candidate(amount = [2, 2, 1]) == 3\n assert candidate(amount = [95, 3, 2]) == 95\n assert candidate(amount = [1, 2, 3]) == 3\n assert candidate(amount = [0, 99, 0]) == 99\n assert candidate(amount = [60, 40, 0]) == 60\n assert candidate(amount = [10, 10, 10]) == 15\n assert candidate(amount = [33, 34, 33]) == 50\n assert candidate(amount = [50, 50, 5]) == 53\n assert candidate(amount = [2, 1, 1]) == 2\n assert candidate(amount = [2, 1, 2]) == 3\n assert candidate(amount = [10, 90, 0]) == 90\n assert candidate(amount = [66, 33, 3]) == 66\n assert candidate(amount = [49, 49, 2]) == 50\n assert candidate(amount = [67, 23, 45]) == 68\n assert candidate(amount = [50, 49, 48]) == 74\n assert candidate(amount = [55, 45, 55]) == 78\n assert candidate(amount = [0, 55, 45]) == 55\n assert candidate(amount = [100, 0, 0]) == 100\n assert candidate(amount = [0, 1, 1]) == 1\n assert candidate(amount = [1, 1, 100]) == 100\n assert candidate(amount = [1, 2, 2]) == 3\n assert candidate(amount = [50, 50, 0]) == 50\n assert candidate(amount = [34, 33, 33]) == 50\n assert candidate(amount = [0, 100, 0]) == 100\n assert candidate(amount = [42, 41, 42]) == 63\n assert candidate(amount = [100, 50, 50]) == 100\n assert candidate(amount = [99, 100, 101]) == 150\n assert candidate(amount = [100, 50, 50]) == 100\n assert candidate(amount = [10, 0, 100]) == 100\n assert candidate(amount = [0, 99, 1]) == 99\n assert candidate(amount = [99, 99, 2]) == 100\n assert candidate(amount = [50, 0, 50]) == 50\n assert candidate(amount = [41, 42, 42]) == 63\n assert candidate(amount = [0, 5, 5]) == 5\n assert candidate(amount = [1, 99, 98]) == 99\n assert candidate(amount = [2, 2, 98]) == 98\n assert candidate(amount = [1, 1, 98]) == 98\n assert candidate(amount = [10, 10, 1]) == 11\n assert candidate(amount = [1, 99, 99]) == 100\n assert candidate(amount = [29, 47, 23]) == 50\n assert candidate(amount = [33, 67, 33]) == 67\n assert candidate(amount = [99, 98, 97]) == 147\n assert candidate(amount = [10, 20, 30]) == 30\n assert candidate(amount = [0, 50, 50]) == 50\n assert candidate(amount = [99, 1, 0]) == 99\n assert candidate(amount = [99, 1, 99]) == 100\n assert candidate(amount = [10, 90, 10]) == 90\n"}, "metadata": {"canonical_parameter_names": ["amount"], "leetcode_dataset_entry_point": "Solution().fillCups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int fillCups(int[] amount) {", "container": "Solution", "callable": "fillCups", "parameters": [{"name": "amount", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2337, "task_id": "move-pieces-to-obtain-a-string", "difficulty": "Medium", "problem_description": "You are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where:\n\nThe characters 'L' and 'R' represent pieces, where a piece 'L' can move to the left only if there is a blank space directly to its left, and a piece 'R' can move to the right only if there is a blank space directly to its right.\nThe character '_' represents a blank space that can be occupied by any of the 'L' or 'R' pieces.\n\nReturn true if it is possible to obtain the string target by moving the pieces of the string start any number of times. Otherwise, return false.\n \nExample 1:\n\nInput: start = \"_L__R__R_\", target = \"L______RR\"\nOutput: true\nExplanation: We can obtain the string target from start by doing the following moves:\n- Move the first piece one step to the left, start becomes equal to \"L___R__R_\".\n- Move the last piece one step to the right, start becomes equal to \"L___R___R\".\n- Move the second piece three steps to the right, start becomes equal to \"L______RR\".\nSince it is possible to get the string target from start, we return true.\n\nExample 2:\n\nInput: start = \"R_L_\", target = \"__LR\"\nOutput: false\nExplanation: The 'R' piece in the string start can move one step to the right to obtain \"_RL_\".\nAfter that, no pieces can move anymore, so it is impossible to obtain the string target from start.\n\nExample 3:\n\nInput: start = \"_R\", target = \"R_\"\nOutput: false\nExplanation: The piece in the string start can move only to the right, so it is impossible to obtain the string target from start.\n \nConstraints:\n\nn == start.length == target.length\n1 <= n <= 105\nstart and target consist of the characters 'L', 'R', and '_'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(start = \"_R\",target = \"R_\") == False\n assert candidate(start = \"___\",target = \"___\") == True\n assert candidate(start = \"LR\",target = \"LR\") == True\n assert candidate(start = \"_LL_R\",target = \"LL__R\") == True\n assert candidate(start = \"____\",target = \"____\") == True\n assert candidate(start = \"L_R\",target = \"_LR\") == False\n assert candidate(start = \"R__L\",target = \"L__R\") == False\n assert candidate(start = \"L_L_R\",target = \"LL_R_\") == False\n assert candidate(start = \"R_R\",target = \"_RR\") == True\n assert candidate(start = \"_L__R__R_\",target = \"L______RR\") == True\n assert candidate(start = \"L___R\",target = \"_L__R\") == False\n assert candidate(start = \"LL_R\",target = \"R_L_\") == False\n assert candidate(start = \"__L___\",target = \"L_____\") == True\n assert candidate(start = \"LRRL\",target = \"LRRL\") == True\n assert candidate(start = \"RL\",target = \"LR\") == False\n assert candidate(start = \"R__L\",target = \"__LR\") == False\n assert candidate(start = \"LRLR\",target = \"LRLR\") == True\n assert candidate(start = \"LL_RR\",target = \"L_RLR\") == False\n assert candidate(start = \"L_L\",target = \"LL_\") == True\n assert candidate(start = \"RLRL\",target = \"LRLR\") == False\n assert candidate(start = \"L___R\",target = \"L___R\") == True\n assert candidate(start = \"R___L\",target = \"L___R\") == False\n assert candidate(start = \"R_L_\",target = \"__LR\") == False\n assert candidate(start = \"R_LRL\",target = \"RLR_L\") == False\n assert candidate(start = \"RRLL____\",target = \"____RRLL\") == False\n assert candidate(start = \"R__L__R\",target = \"__LR___\") == False\n assert candidate(start = \"L_R___L___L___R___R\",target = \"_______LL___RR\") == False\n assert candidate(start = \"LR___LR___LR____\",target = \"_L__L___R___R___\") == False\n assert candidate(start = \"L___R_L__\",target = \"L______LR\") == False\n assert candidate(start = \"____L___R___\",target = \"L___________R\") == True\n assert candidate(start = \"R_____L_______\",target = \"_________LR____\") == False\n assert candidate(start = \"R_R_R_R_R\",target = \"RRRRR_____\") == False\n assert candidate(start = \"R____L_____\",target = \"_____R____L\") == False\n assert candidate(start = \"R______L\",target = \"_____LR_\") == False\n assert candidate(start = \"R___L__R_L\",target = \"_____LR__L\") == False\n assert candidate(start = \"L______R______L\",target = \"_______LR______\") == False\n assert candidate(start = \"R_L_L___R_R\",target = \"__LR___LR\") == False\n assert candidate(start = \"R__L___L_\",target = \"___LR___L\") == False\n assert candidate(start = \"L____R____L___\",target = \"________LR____\") == False\n assert candidate(start = \"L_R____R\",target = \"_LR_____\") == False\n assert candidate(start = \"R__L_____R\",target = \"_______LR___\") == False\n assert candidate(start = \"R_R_R_R_\",target = \"____RRRR\") == True\n assert candidate(start = \"R_L_R_L_R\",target = \"_L__L__RR\") == False\n assert candidate(start = \"R__LR_R__\",target = \"__LR___R_\") == False\n assert candidate(start = \"___L_R___L___R___\",target = \"L_____L____R____\") == False\n assert candidate(start = \"LR_L_R_L_R\",target = \"L_R_L_R_L_\") == False\n assert candidate(start = \"L_R_L_R\",target = \"_L__L_R\") == False\n assert candidate(start = \"R__L___R_L\",target = \"____LR__RL\") == False\n assert candidate(start = \"RRR_______LLL\",target = \"________RRRLLL\") == False\n assert candidate(start = \"__LR__R\",target = \"____LRR\") == False\n assert candidate(start = \"L___R___L\",target = \"____L__LR\") == False\n assert candidate(start = \"L_R__L_R__L\",target = \"_______L___LR\") == False\n assert candidate(start = \"R__L___L_R\",target = \"___LL______R\") == False\n assert candidate(start = \"_L_R__L_R\",target = \"L______LR\") == False\n assert candidate(start = \"L_L_L_L_L\",target = \"_____LLLL\") == False\n assert candidate(start = \"____L_R_L____\",target = \"_________LR\") == False\n assert candidate(start = \"_L_R__L__R\",target = \"__LR____R\") == False\n assert candidate(start = \"R_L_R_L_R_L\",target = \"_LR_L_L_R_L\") == False\n assert candidate(start = \"_L_R_L_R\",target = \"L___L___R\") == False\n assert candidate(start = \"R_L_R_L___\",target = \"__LR____L\") == False\n assert candidate(start = \"R_L_R_L_R\",target = \"___R_L_RL\") == False\n assert candidate(start = \"R_L_R_L_R\",target = \"_LR_L__RR\") == False\n assert candidate(start = \"R___L___R___L\",target = \"_____R___L___\") == False\n assert candidate(start = \"R___L___R___L___\",target = \"_____R____L____\") == False\n assert candidate(start = \"LR_LRL__\",target = \"LRL_L___\") == False\n assert candidate(start = \"L___R____L\",target = \"______LR_L\") == False\n assert candidate(start = \"R___R___R___L___L___\",target = \"_______RRR____\") == False\n assert candidate(start = \"_R____L____R\",target = \"____L___R_R\") == False\n assert candidate(start = \"L_____R__L\",target = \"L_________RL\") == False\n assert candidate(start = \"L___R___L___R___L___\",target = \"__________LRLRL\") == False\n assert candidate(start = \"____R_L_R___\",target = \"R_L_____R_\") == False\n assert candidate(start = \"___L__R___\",target = \"L_______R__\") == True\n assert candidate(start = \"R____L____R\",target = \"____R___L\") == False\n assert candidate(start = \"LR__LR__LR___\",target = \"L___R___L___RRR\") == False\n assert candidate(start = \"L____R____\",target = \"____LR____\") == False\n assert candidate(start = \"RRR___LLL\",target = \"___LLLRRR\") == False\n assert candidate(start = \"L_R_L___R\",target = \"L___L_R__\") == False\n assert candidate(start = \"L_R___R___R___R___L\",target = \"___L_____RRR___\") == False\n assert candidate(start = \"L_R_L_R_L_R\",target = \"LL______RRR\") == False\n assert candidate(start = \"_L__R_L_R\",target = \"L_____RLR\") == False\n assert candidate(start = \"R_L_R__L\",target = \"_R___L_RL\") == False\n assert candidate(start = \"R___R___L___R___L\",target = \"_____RR____L___\") == False\n assert candidate(start = \"R_L_R_L_R_L_R___\",target = \"_L_R_L_R_L_R____\") == False\n assert candidate(start = \"R___L___R\",target = \"__LR___R_\") == False\n assert candidate(start = \"______L_R\",target = \"L______R_\") == False\n assert candidate(start = \"R__L_L___R\",target = \"___LR____R\") == False\n assert candidate(start = \"R___L___R___R___L___\",target = \"_____R____R____L___\") == False\n assert candidate(start = \"_L_L_L_L\",target = \"LLLL____\") == True\n assert candidate(start = \"_L_R_L_R_\",target = \"L_____R_R\") == False\n assert candidate(start = \"L_R_L_R_L_R\",target = \"_LR_L_R_L_R\") == False\n assert candidate(start = \"L_R_L_R_L_R\",target = \"_L_L_L_RLR_\") == False\n assert candidate(start = \"L___R___R___L\",target = \"_____L___RR\") == False\n assert candidate(start = \"R_______L\",target = \"________LR\") == False\n assert candidate(start = \"L_____R_L____\",target = \"________L_R__\") == False\n assert candidate(start = \"R_L_R___L_R___\",target = \"_L_R_L___R____\") == False\n assert candidate(start = \"_L_R__L__R\",target = \"____L___LR\") == False\n assert candidate(start = \"_L_R__L___R\",target = \"L_____R____R\") == False\n assert candidate(start = \"R_L_R___L\",target = \"_LR______\") == False\n assert candidate(start = \"L_R_L___R\",target = \"L___LR___\") == False\n assert candidate(start = \"R_L_R_L_R\",target = \"_LR_L_R_L\") == False\n assert candidate(start = \"LRLR_LRL\",target = \"LRLR_LRL\") == True\n assert candidate(start = \"R_____L__\",target = \"_____LR__\") == False\n assert candidate(start = \"R_L_R_L\",target = \"__LR__L\") == False\n assert candidate(start = \"R_L_R_L_R_L\",target = \"LR_L_R_L_R_\") == False\n assert candidate(start = \"L_____R___L\",target = \"________LRL\") == False\n assert candidate(start = \"_L____R_____\",target = \"L_____R_____\") == True\n assert candidate(start = \"R__R__L\",target = \"_____RR_L\") == False\n assert candidate(start = \"___LR___R\",target = \"L_____RR_\") == False\n assert candidate(start = \"_L___R_L_R\",target = \"L_____RR__\") == False\n assert candidate(start = \"L___R__L_R\",target = \"LL______RR\") == False\n assert candidate(start = \"______\",target = \"______\") == True\n assert candidate(start = \"R_L_R___L_R\",target = \"_L_R_L___RR\") == False\n assert candidate(start = \"L_L_L__L___\",target = \"_L_L___L___L_\") == False\n assert candidate(start = \"R________L\",target = \"________LR\") == False\n assert candidate(start = \"R_L___L_R\",target = \"__LR__L_R\") == False\n assert candidate(start = \"R___________L\",target = \"____________LR\") == False\n assert candidate(start = \"L___R___L\",target = \"__L___R_L\") == False\n assert candidate(start = \"L_R___R__L\",target = \"____L___R\") == False\n assert candidate(start = \"_______L_L_R_R\",target = \"L______L___R_R\") == True\n assert candidate(start = \"RRRLLL___\",target = \"___RRRLLL\") == False\n assert candidate(start = \"L__R__L___R____\",target = \"L___L__R__R____\") == False\n assert candidate(start = \"L_R___R___R___L\",target = \"___L_____RR___\") == False\n assert candidate(start = \"L___R__L___\",target = \"_L_____RL__\") == False\n assert candidate(start = \"L___R___L___R\",target = \"L___L___R___R\") == False\n assert candidate(start = \"____L___R__\",target = \"L_____R____\") == False\n assert candidate(start = \"L_R__L_R\",target = \"_LR__LR_\") == False\n assert candidate(start = \"R_L___LR__L____\",target = \"__LR__LR__L____\") == False\n assert candidate(start = \"L___R___R\",target = \"___L____R\") == False\n assert candidate(start = \"L___R___L_R\",target = \"L_____RL___\") == False\n assert candidate(start = \"__L_R__R_L\",target = \"L_____R__L\") == False\n assert candidate(start = \"_L___R__L\",target = \"L_____R__\") == False\n assert candidate(start = \"L_R___R___L___\",target = \"___L_____R___\") == False\n assert candidate(start = \"_L_R_L_R_R\",target = \"L______RRR\") == False\n assert candidate(start = \"_L___R_L_R\",target = \"L______LR\") == False\n assert candidate(start = \"_R_L_R_L____\",target = \"____LR____LR\") == False\n assert candidate(start = \"R_L__R\",target = \"__LR__\") == False\n"}, "metadata": {"canonical_parameter_names": ["start", "target"], "leetcode_dataset_entry_point": "Solution().canChange", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean canChange(String start, String target) {", "container": "Solution", "callable": "canChange", "parameters": [{"name": "start", "type": "String"}, {"name": "target", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2338, "task_id": "count-the-number-of-ideal-arrays", "difficulty": "Hard", "problem_description": "You are given two integers n and maxValue, which are used to describe an ideal array.\nA 0-indexed integer array arr of length n is considered ideal if the following conditions hold:\n\nEvery arr[i] is a value from 1 to maxValue, for 0 <= i < n.\nEvery arr[i] is divisible by arr[i - 1], for 0 < i < n.\n\nReturn the number of distinct ideal arrays of length n. Since the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: n = 2, maxValue = 5\nOutput: 10\nExplanation: The following are the possible ideal arrays:\n- Arrays starting with the value 1 (5 arrays): [1,1], [1,2], [1,3], [1,4], [1,5]\n- Arrays starting with the value 2 (2 arrays): [2,2], [2,4]\n- Arrays starting with the value 3 (1 array): [3,3]\n- Arrays starting with the value 4 (1 array): [4,4]\n- Arrays starting with the value 5 (1 array): [5,5]\nThere are a total of 5 + 2 + 1 + 1 + 1 = 10 distinct ideal arrays.\n\nExample 2:\n\nInput: n = 5, maxValue = 3\nOutput: 11\nExplanation: The following are the possible ideal arrays:\n- Arrays starting with the value 1 (9 arrays): \n - With no other distinct values (1 array): [1,1,1,1,1] \n - With 2nd distinct value 2 (4 arrays): [1,1,1,1,2], [1,1,1,2,2], [1,1,2,2,2], [1,2,2,2,2]\n - With 2nd distinct value 3 (4 arrays): [1,1,1,1,3], [1,1,1,3,3], [1,1,3,3,3], [1,3,3,3,3]\n- Arrays starting with the value 2 (1 array): [2,2,2,2,2]\n- Arrays starting with the value 3 (1 array): [3,3,3,3,3]\nThere are a total of 9 + 1 + 1 = 11 distinct ideal arrays.\n\n \nConstraints:\n\n2 <= n <= 104\n1 <= maxValue <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,maxValue = 7) == 106\n assert candidate(n = 2,maxValue = 5) == 10\n assert candidate(n = 3,maxValue = 7) == 28\n assert candidate(n = 3,maxValue = 6) == 25\n assert candidate(n = 6,maxValue = 12) == 327\n assert candidate(n = 10,maxValue = 5) == 86\n assert candidate(n = 4,maxValue = 4) == 19\n assert candidate(n = 10,maxValue = 10) == 571\n assert candidate(n = 4,maxValue = 7) == 43\n assert candidate(n = 3,maxValue = 2) == 4\n assert candidate(n = 10000,maxValue = 10000) == 22940607\n assert candidate(n = 4,maxValue = 10) == 89\n assert candidate(n = 5,maxValue = 3) == 11\n assert candidate(n = 2000,maxValue = 10) == 347343994\n assert candidate(n = 15,maxValue = 10) == 1431\n assert candidate(n = 7,maxValue = 20) == 1191\n assert candidate(n = 8000,maxValue = 8000) == 106406983\n assert candidate(n = 8,maxValue = 16) == 1115\n assert candidate(n = 6000,maxValue = 6000) == 883250062\n assert candidate(n = 2000,maxValue = 5000) == 716352377\n assert candidate(n = 10000,maxValue = 1) == 1\n assert candidate(n = 100,maxValue = 50) == 604383896\n assert candidate(n = 1000,maxValue = 4) == 502501\n assert candidate(n = 9,maxValue = 5) == 73\n assert candidate(n = 7,maxValue = 15) == 575\n assert candidate(n = 10,maxValue = 20) == 3176\n assert candidate(n = 2000,maxValue = 1000) == 534638579\n assert candidate(n = 10,maxValue = 15) == 1341\n assert candidate(n = 50,maxValue = 20) == 519126\n assert candidate(n = 8,maxValue = 3) == 17\n assert candidate(n = 20,maxValue = 2) == 21\n assert candidate(n = 6,maxValue = 3) == 13\n assert candidate(n = 100,maxValue = 3) == 201\n assert candidate(n = 10000,maxValue = 5000) == 22892639\n assert candidate(n = 9999,maxValue = 10000) == 667133522\n assert candidate(n = 6000,maxValue = 3000) == 80648523\n assert candidate(n = 3000,maxValue = 3000) == 806624302\n assert candidate(n = 2000,maxValue = 2000) == 585712681\n assert candidate(n = 3,maxValue = 1) == 1\n assert candidate(n = 5000,maxValue = 5) == 12517501\n assert candidate(n = 5000,maxValue = 2000) == 802769368\n assert candidate(n = 1000,maxValue = 2000) == 228299266\n assert candidate(n = 8,maxValue = 20) == 1707\n assert candidate(n = 50,maxValue = 25) == 1630451\n assert candidate(n = 100,maxValue = 2) == 101\n assert candidate(n = 5,maxValue = 1) == 1\n assert candidate(n = 6,maxValue = 8) == 138\n assert candidate(n = 5,maxValue = 9999) == 6309016\n assert candidate(n = 100,maxValue = 5) == 5351\n assert candidate(n = 500,maxValue = 3) == 1001\n assert candidate(n = 2000,maxValue = 50) == 74895101\n assert candidate(n = 100,maxValue = 100) == 959337187\n assert candidate(n = 5,maxValue = 100) == 7537\n assert candidate(n = 100,maxValue = 10) == 202201\n assert candidate(n = 9,maxValue = 9) == 373\n assert candidate(n = 5000,maxValue = 20) == 436322284\n assert candidate(n = 2000,maxValue = 10000) == 239341549\n assert candidate(n = 20,maxValue = 50) == 388980\n assert candidate(n = 10000,maxValue = 500) == 397370814\n assert candidate(n = 1000,maxValue = 1000) == 91997497\n assert candidate(n = 7500,maxValue = 7500) == 143340271\n assert candidate(n = 25,maxValue = 30) == 153176\n assert candidate(n = 500,maxValue = 500) == 652553975\n assert candidate(n = 5000,maxValue = 100) == 853200627\n assert candidate(n = 5000,maxValue = 5000) == 144035088\n assert candidate(n = 1000,maxValue = 100) == 607180637\n assert candidate(n = 50,maxValue = 100) == 268368886\n assert candidate(n = 10000,maxValue = 100) == 200548806\n assert candidate(n = 10,maxValue = 100) == 105568\n assert candidate(n = 2,maxValue = 10000) == 93668\n assert candidate(n = 10,maxValue = 10000) == 466423769\n assert candidate(n = 1000,maxValue = 10000) == 888200964\n assert candidate(n = 15,maxValue = 15) == 3711\n assert candidate(n = 3000,maxValue = 6000) == 321990518\n assert candidate(n = 8,maxValue = 2) == 9\n assert candidate(n = 30,maxValue = 30) == 290436\n assert candidate(n = 1000,maxValue = 10) == 170172001\n assert candidate(n = 7500,maxValue = 10000) == 430119293\n assert candidate(n = 8000,maxValue = 9000) == 358648747\n assert candidate(n = 7500,maxValue = 5000) == 777616479\n"}, "metadata": {"canonical_parameter_names": ["n", "maxValue"], "leetcode_dataset_entry_point": "Solution().idealArrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int idealArrays(int n, int maxValue) {", "container": "Solution", "callable": "idealArrays", "parameters": [{"name": "n", "type": "int"}, {"name": "maxValue", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2341, "task_id": "maximum-number-of-pairs-in-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. In one operation, you may do the following:\n\nChoose two integers in nums that are equal.\nRemove both integers from nums, forming a pair.\n\nThe operation is done on nums as many times as possible.\nReturn a 0-indexed integer array answer of size 2 where answer[0] is the number of pairs that are formed and answer[1] is the number of leftover integers in nums after doing the operation as many times as possible.\n \nExample 1:\n\nInput: nums = [1,3,2,1,3,2,2]\nOutput: [3,1]\nExplanation:\nForm a pair with nums[0] and nums[3] and remove them from nums. Now, nums = [3,2,3,2,2].\nForm a pair with nums[0] and nums[2] and remove them from nums. Now, nums = [2,2,2].\nForm a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [2].\nNo more pairs can be formed. A total of 3 pairs have been formed, and there is 1 number leftover in nums.\n\nExample 2:\n\nInput: nums = [1,1]\nOutput: [1,0]\nExplanation: Form a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [].\nNo more pairs can be formed. A total of 1 pair has been formed, and there are 0 numbers leftover in nums.\n\nExample 3:\n\nInput: nums = [0]\nOutput: [0,1]\nExplanation: No pairs can be formed, and there is 1 number leftover in nums.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n0 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [5, 0]\n assert candidate(nums = [100, 0, 50, 50, 0, 100]) == [3, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 10]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [5, 1]\n assert candidate(nums = [42]) == [0, 1]\n assert candidate(nums = [1]) == [0, 1]\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 2]) == [3, 1]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1]) == [4, 1]\n assert candidate(nums = [6, 6, 6, 7, 7, 7, 8, 8, 8, 8]) == [4, 2]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [5, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [5, 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]) == [10, 0]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [6, 0]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [0, 5]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == [3, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [5, 0]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [5, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [5, 0]\n assert candidate(nums = [0]) == [0, 1]\n assert candidate(nums = [100, 100, 100, 99, 99, 98]) == [2, 2]\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == [3, 0]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [4, 2]\n assert candidate(nums = [100, 100, 99, 99, 98, 98, 97, 97, 96, 96]) == [5, 0]\n assert candidate(nums = [1, 1]) == [1, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 0]\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2]) == [3, 1]\n assert candidate(nums = [100, 100, 100]) == [1, 1]\n assert candidate(nums = [30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34]) == [8, 3]\n assert candidate(nums = [1, 2, 1, 2, 3, 4, 3, 4, 5, 5, 5, 6, 6, 6, 6]) == [7, 1]\n assert candidate(nums = [10, 10, 10, 10, 10, 20, 20, 20, 20, 30, 30, 30, 40, 40, 40, 40, 40]) == [7, 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]) == [14, 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]) == [15, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == [10, 0]\n assert candidate(nums = [65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 67, 68, 68, 68, 68]) == [11, 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]) == [18, 0]\n assert candidate(nums = [34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38]) == [13, 2]\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]) == [11, 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]) == [8, 4]\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]) == [12, 1]\n assert candidate(nums = [7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12]) == [9, 3]\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, 8]) == [16, 5]\n assert candidate(nums = [30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33]) == [12, 3]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [10, 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]) == [15, 0]\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == [13, 1]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5]) == [14, 2]\n assert candidate(nums = [1, 1, 1, 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]) == [3, 23]\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, 0]\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]) == [10, 5]\n assert candidate(nums = [35, 35, 35, 35, 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38]) == [10, 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]) == [0, 30]\n assert candidate(nums = [10, 20, 10, 20, 30, 30, 30, 40, 40, 40, 40]) == [5, 1]\n assert candidate(nums = [21, 22, 22, 21, 23, 24, 24, 23, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29]) == [9, 0]\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]) == [12, 3]\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6]) == [15, 0]\n assert candidate(nums = [6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == [8, 1]\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == [11, 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]) == [9, 2]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [6, 2]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40]) == [6, 1]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4]) == [7, 1]\n assert candidate(nums = [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]) == [12, 1]\n assert candidate(nums = [21, 21, 21, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25]) == [9, 2]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [13, 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]) == [15, 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]) == [10, 0]\n assert candidate(nums = [45, 45, 45, 45, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49, 49, 49]) == [14, 2]\n assert candidate(nums = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [8, 4]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == [7, 1]\n assert candidate(nums = [16, 17, 18, 19, 20, 16, 17, 18, 19, 20, 16, 17, 18, 19, 20, 16, 17, 18, 19, 20, 16, 17, 18, 19, 20]) == [10, 5]\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 40, 40, 40, 50, 50, 50, 50]) == [6, 2]\n assert candidate(nums = [10, 20, 10, 30, 20, 30, 40, 40, 40, 50, 50, 50, 50, 60, 60, 60, 60, 60]) == [8, 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, 2, 2, 2, 2, 2, 2]) == [18, 1]\n assert candidate(nums = [10, 20, 10, 30, 20, 30, 40, 50, 60, 40, 50, 60, 70, 80, 90, 100, 70, 80, 90, 100]) == [10, 0]\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]) == [20, 0]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == [10, 0]\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]) == [10, 1]\n assert candidate(nums = [39, 39, 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, 42, 42, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44]) == [12, 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, 20]\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 2, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == [11, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == [8, 4]\n assert candidate(nums = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90]) == [10, 0]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [6, 3]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 10, 10]) == [14, 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, 11, 11, 12, 12, 13, 13, 14, 14]) == [14, 0]\n assert candidate(nums = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]) == [10, 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]) == [15, 0]\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 5]\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10]) == [9, 2]\n assert candidate(nums = [10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40]) == [6, 2]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == [0, 20]\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]) == [0, 25]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [15, 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, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == [20, 0]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10]) == [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]) == [0, 20]\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == [13, 1]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [6, 2]\n assert candidate(nums = [11, 12, 11, 12, 13, 14, 15, 14, 13, 15, 15, 14, 13, 12, 11]) == [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, 1, 2, 3, 4, 5]) == [5, 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]) == [10, 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]) == [26, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [10, 2]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51]) == [16, 0]\n assert candidate(nums = [16, 16, 17, 17, 17, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20]) == [7, 2]\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == [15, 2]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10]) == [16, 0]\n assert candidate(nums = [52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52]) == [19, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10]) == [10, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == [12, 2]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [4, 2]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == [15, 1]\n assert candidate(nums = [60, 60, 61, 61, 61, 62, 62, 62, 62, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64]) == [9, 2]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 6, 7, 8, 9, 10]) == [6, 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, 11, 11, 11, 12, 12, 12]) == [12, 12]\n assert candidate(nums = [26, 26, 26, 26, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29]) == [11, 2]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [12, 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]) == [14, 1]\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]) == [12, 2]\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9]) == [8, 1]\n assert candidate(nums = [0, 1, 1, 0, 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]) == [12, 5]\n assert candidate(nums = [2, 3, 3, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6]) == [7, 4]\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]) == [11, 3]\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == [7, 1]\n assert candidate(nums = [39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == [0, 21]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numberOfPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] numberOfPairs(int[] nums) {", "container": "Solution", "callable": "numberOfPairs", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2342, "task_id": "max-sum-of-a-pair-with-equal-sum-of-digits", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums consisting of positive integers. You can choose two indices i and j, such that i != j, and the sum of digits of the number nums[i] is equal to that of nums[j].\nReturn the maximum value of nums[i] + nums[j] that you can obtain over all possible indices i and j that satisfy the conditions. If no such pair of indices exists, return -1.\n \nExample 1:\n\nInput: nums = [18,43,36,13,7]\nOutput: 54\nExplanation: The pairs (i, j) that satisfy the conditions are:\n- (0, 2), both numbers have a sum of digits equal to 9, and their sum is 18 + 36 = 54.\n- (1, 4), both numbers have a sum of digits equal to 7, and their sum is 43 + 7 = 50.\nSo the maximum sum that we can obtain is 54.\n\nExample 2:\n\nInput: nums = [10,12,19,14]\nOutput: -1\nExplanation: There are no two numbers that satisfy the conditions, so 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 = [99, 18, 81, 27]) == 108\n assert candidate(nums = [55, 23, 45, 55, 23]) == 110\n assert candidate(nums = [55, 23, 45, 55]) == 110\n assert candidate(nums = [111, 222, 333, 444]) == -1\n assert candidate(nums = [1000000000]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [999999999, 999999999]) == 1999999998\n assert candidate(nums = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [999999999, 111111111, 222222222]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -1\n assert candidate(nums = [99, 18, 81, 27, 72]) == 153\n assert candidate(nums = [9, 99, 999, 9999]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500]) == -1\n assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 1100000000\n assert candidate(nums = [89, 98, 76, 67, 54, 45, 32, 23, 10, 1]) == 187\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [55, 23, 32, 44, 55]) == 110\n assert candidate(nums = [55, 23, 45, 67, 89, 90, 11]) == 135\n assert candidate(nums = [123, 321, 213, 132, 231, 312]) == 633\n assert candidate(nums = [10, 12, 19, 14]) == -1\n assert candidate(nums = [18, 43, 36, 13, 7]) == 54\n assert candidate(nums = [123, 321, 213]) == 534\n assert candidate(nums = [55, 23, 45, 67, 89, 90]) == 135\n assert candidate(nums = [123, 321, 213, 132, 312, 231]) == 633\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == -1\n assert candidate(nums = [123456789, 987654321, 234567891, 123456789, 987654321]) == 1975308642\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888]) == 1543209876\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(nums = [55555, 44444, 33333, 22222, 11111, 66666, 77777, 88888, 99999]) == -1\n assert candidate(nums = [12345, 54321, 13452, 21435, 23541, 32145, 42315, 52314, 34512, 54123]) == 108444\n assert candidate(nums = [12345, 54321, 23451, 45123, 34512, 123456, 654321, 234516, 165432, 321654, 654123, 412365, 564321, 123654, 654312]) == 1308633\n assert candidate(nums = [123, 321, 231, 312, 132, 213, 456, 654, 564, 546, 465, 645, 789, 987, 897, 879, 798, 978]) == 1965\n assert candidate(nums = [1001, 1100, 1010, 1001, 2002, 2020, 2200, 3003, 3030, 3300]) == 6330\n assert candidate(nums = [123456789, 987654321, 234567891, 345678912, 456789123, 567891234, 678912345, 789123456, 891234567]) == 1878888888\n assert candidate(nums = [1000000001, 1000000011, 1000000111, 1000001111, 1000011111, 1000111111, 1001111111, 1011111111, 1111111111]) == -1\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 10000]) == -1\n assert candidate(nums = [123, 132, 213, 231, 312, 321, 456, 465, 546, 564, 645, 654, 789, 798, 879, 897, 978, 987, 101, 110, 1001, 1010, 1100]) == 2110\n assert candidate(nums = [555555555, 222222222, 333333333, 444444444, 55555555, 22222222, 33333333, 44444444, 5555555, 2222222, 3333333, 4444444]) == -1\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == -1\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]) == 1100000000\n assert candidate(nums = [123, 321, 213, 132, 312, 231, 111, 222, 333]) == 633\n assert candidate(nums = [999, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 1998\n assert candidate(nums = [1001, 1100, 1010, 10001, 9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111]) == 11101\n assert candidate(nums = [99, 999, 9999, 99999, 999999]) == -1\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 123456789, 987654321]) == 1543209876\n assert candidate(nums = [1234, 4321, 2341, 1432, 1243, 2413, 3412, 4123, 1342, 3241]) == 8444\n assert candidate(nums = [999999999, 111111111, 222222222, 333333333, 444444444]) == -1\n assert candidate(nums = [987654321, 123456789, 98765432, 12345678, 9876543, 1234567]) == 1111111110\n assert candidate(nums = [1001, 1010, 1100, 2002, 2020, 2200, 3003, 3030, 3300]) == 6330\n assert candidate(nums = [11112, 22223, 33334, 44445, 55556, 66667, 77778, 88889, 99990]) == 177768\n assert candidate(nums = [123, 321, 111, 456, 654, 789, 987]) == 1776\n assert candidate(nums = [987654321, 123456789, 111222333, 333222111, 444444444, 555555555]) == 1543209876\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 1233\n assert candidate(nums = [876, 768, 687, 867, 678, 786, 543, 456, 345, 435, 543, 534]) == 1743\n assert candidate(nums = [12345, 54321, 11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == 87654\n assert candidate(nums = [1111111111, 111111111, 11111111, 1111111, 111111, 11111, 1111, 111, 11, 1]) == -1\n assert candidate(nums = [54321, 21345, 32145, 45321, 14523, 51423, 23451, 34512, 45123, 12354]) == 105744\n assert candidate(nums = [111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111, 11111111111]) == -1\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 1875\n assert candidate(nums = [500000000, 499999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 999999999]) == 500000005\n assert candidate(nums = [12, 21, 30, 13, 31, 40, 24, 42, 33, 50]) == 75\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == -1\n assert candidate(nums = [123, 321, 213, 111, 222, 333]) == 543\n assert candidate(nums = [999, 111, 222, 333, 444, 555, 666, 777, 888]) == -1\n assert candidate(nums = [9, 90, 900, 9000, 90000, 900000, 9000000, 90000000, 900000000]) == 990000000\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888]) == 1543209876\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]) == -1\n assert candidate(nums = [199, 288, 377, 466, 555, 644, 733, 822, 911, 1000]) == -1\n assert candidate(nums = [123, 321, 213, 132, 312, 231]) == 633\n assert candidate(nums = [12345, 54321, 23451, 15432, 67890, 98760, 89076, 76980, 32145, 54312]) == 187836\n assert candidate(nums = [999999999, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888]) == -1\n assert candidate(nums = [123456789, 12345678, 1234567, 123456, 12345, 1234, 123, 12, 1]) == -1\n assert candidate(nums = [123, 321, 213, 132, 231, 312, 456, 654, 546, 465, 564, 645, 789, 987, 897, 798, 879, 978]) == 1965\n assert candidate(nums = [987654321, 123456789, 234567891, 345678912, 456789123]) == 1444443444\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 18, 81, 123, 321, 132, 213, 231, 312]) == 633\n assert candidate(nums = [123456789, 987654321, 123456789, 987654321]) == 1975308642\n assert candidate(nums = [100, 101, 110, 111, 200, 201, 210, 211, 300, 301, 310, 311]) == 611\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 1100000000\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 171\n assert candidate(nums = [123, 321, 213, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 543\n assert candidate(nums = [99999999, 9999999, 999999, 99999, 9999, 999, 99, 9, 88888888, 8888888, 888888, 88888, 8888, 888, 88, 8]) == -1\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 9675\n assert candidate(nums = [12, 21, 13, 31, 14, 41, 15, 51, 16, 61, 17, 71, 18, 81, 19, 91]) == 110\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999]) == -1\n assert candidate(nums = [1001, 110, 1110, 1011, 11100, 11110, 10111]) == 21221\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(nums = [99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999999]) == -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]) == 31\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 102]) == -1\n assert candidate(nums = [100000000, 100000001, 100000002, 100000003, 100000004, 100000005]) == -1\n assert candidate(nums = [1001, 1010, 1100, 2002, 2020, 2200, 3003, 3030, 3300]) == 6330\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0]) == -1\n assert candidate(nums = [123456789, 987654321, 111222333, 444555666, 777888999]) == 1432209987\n assert candidate(nums = [123456789, 987654321, 234567891, 123456782, 111111111]) == 1222222212\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == -1\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 234, 432, 567, 765, 890, 980]) == 1870\n assert candidate(nums = [100000000, 200000000, 300000000, 111111111, 222222222, 333333333]) == -1\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 1100000000\n assert candidate(nums = [98765, 56789, 12345, 54321, 67890, 9876, 6789, 1234, 5678, 2345]) == 155554\n assert candidate(nums = [56, 65, 74, 47, 83, 38, 92, 29, 101, 110]) == 211\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == -1\n assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 1100000000\n assert candidate(nums = [876543210, 123456789, 111222333, 444555666, 777888999, 555555555, 666666666]) == 1000111221\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 100000000]) == -1\n assert candidate(nums = [12345, 54321, 1234, 4321, 123, 321, 12, 21, 1, 0]) == 66666\n assert candidate(nums = [999999999, 111111111, 222222222, 333333333, 444444444, 555555555]) == -1\n assert candidate(nums = [123, 1230, 1203, 1023, 10023, 100023, 1000023, 10000023, 100000023]) == 110000046\n assert candidate(nums = [112, 121, 211, 221, 212, 122, 333, 444, 555, 666, 777, 888, 999, 1001, 1010, 1100]) == 2110\n assert candidate(nums = [123, 321, 213, 132, 231, 312, 111, 222, 333, 444]) == 633\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == -1\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 1101, 2202, 3303, 4404, 5505]) == 10410\n assert candidate(nums = [101, 110, 202, 220, 303, 330, 404, 440, 505, 550]) == 1055\n assert candidate(nums = [1234, 4321, 2134, 1324, 2341, 3412, 3421, 4231, 4123, 2431]) == 8552\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909]) == -1\n assert candidate(nums = [123, 321, 213, 132, 231, 312, 12, 21, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 633\n assert candidate(nums = [11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == -1\n assert candidate(nums = [987654321, 98765432, 9876543, 987654, 98765, 9876, 987, 98, 9]) == -1\n assert candidate(nums = [123, 321, 213, 456, 654, 564, 999, 888, 777, 111]) == 1218\n assert candidate(nums = [987, 654, 321, 432, 789, 123]) == 1776\n assert candidate(nums = [88, 88, 88, 88, 88, 88, 88, 88, 88, 88]) == 176\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 1100000000\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumSum(int[] nums) {", "container": "Solution", "callable": "maximumSum", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2343, "task_id": "query-kth-smallest-trimmed-number", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of strings nums, where each string is of equal length and consists of only digits.\nYou are also given a 0-indexed 2D integer array queries where queries[i] = [ki, trimi]. For each queries[i], you need to:\n\nTrim each number in nums to its rightmost trimi digits.\nDetermine the index of the kith smallest trimmed number in nums. If two trimmed numbers are equal, the number with the lower index is considered to be smaller.\nReset each number in nums to its original length.\n\nReturn an array answer of the same length as queries, where answer[i] is the answer to the ith query.\nNote:\n\nTo trim to the rightmost x digits means to keep removing the leftmost digit, until only x digits remain.\nStrings in nums may contain leading zeros.\n\n \nExample 1:\n\nInput: nums = [\"102\",\"473\",\"251\",\"814\"], queries = [[1,1],[2,3],[4,2],[1,2]]\nOutput: [2,2,1,0]\nExplanation:\n1. After trimming to the last digit, nums = [\"2\",\"3\",\"1\",\"4\"]. The smallest number is 1 at index 2.\n2. Trimmed to the last 3 digits, nums is unchanged. The 2nd smallest number is 251 at index 2.\n3. Trimmed to the last 2 digits, nums = [\"02\",\"73\",\"51\",\"14\"]. The 4th smallest number is 73.\n4. Trimmed to the last 2 digits, the smallest number is 2 at index 0.\n Note that the trimmed number \"02\" is evaluated as 2.\n\nExample 2:\n\nInput: nums = [\"24\",\"37\",\"96\",\"04\"], queries = [[2,1],[2,2]]\nOutput: [3,0]\nExplanation:\n1. Trimmed to the last digit, nums = [\"4\",\"7\",\"6\",\"4\"]. The 2nd smallest number is 4 at index 3.\n There are two occurrences of 4, but the one at index 0 is considered smaller than the one at index 3.\n2. Trimmed to the last 2 digits, nums is unchanged. The 2nd smallest number is 24.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i].length <= 100\nnums[i] consists of only digits.\nAll nums[i].length are equal.\n1 <= queries.length <= 100\nqueries[i].length == 2\n1 <= ki <= nums.length\n1 <= trimi <= nums[i].length\n\n \nFollow up: Could you use the Radix Sort Algorithm to solve this problem? What will be the complexity of that solution?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = ['111', '222', '333', '444'],queries = [[1, 1], [2, 2], [3, 3], [4, 3]]) == [0, 1, 2, 3]\n assert candidate(nums = ['123', '456', '789', '012'],queries = [[1, 2], [3, 3], [2, 1]]) == [3, 1, 0]\n assert candidate(nums = ['001', '002', '003'],queries = [[1, 1], [2, 1], [3, 1]]) == [0, 1, 2]\n assert candidate(nums = ['001', '012', '123', '234'],queries = [[1, 2], [2, 3], [3, 1]]) == [0, 1, 2]\n assert candidate(nums = ['001', '002', '003', '004'],queries = [[1, 3], [4, 1], [2, 2]]) == [0, 3, 1]\n assert candidate(nums = ['24', '37', '96', '04'],queries = [[2, 1], [2, 2]]) == [3, 0]\n assert candidate(nums = ['111', '222', '333', '444'],queries = [[1, 1], [2, 2], [3, 3], [4, 4]]) == [0, 1, 2, 3]\n assert candidate(nums = ['56', '78', '90'],queries = [[1, 1], [2, 2]]) == [2, 1]\n assert candidate(nums = ['12', '12', '12'],queries = [[1, 1], [2, 1], [3, 1]]) == [0, 1, 2]\n assert candidate(nums = ['567', '890', '123'],queries = [[1, 3], [2, 2], [3, 1]]) == [2, 0, 0]\n assert candidate(nums = ['123', '456', '789'],queries = [[1, 2], [3, 3], [2, 1]]) == [0, 2, 1]\n assert candidate(nums = ['123', '456', '789'],queries = [[1, 2], [3, 1], [2, 3]]) == [0, 2, 1]\n assert candidate(nums = ['102', '473', '251', '814'],queries = [[1, 1], [2, 3], [4, 2], [1, 2]]) == [2, 2, 1, 0]\n assert candidate(nums = ['001', '010', '100'],queries = [[1, 1], [2, 2], [3, 3]]) == [1, 0, 2]\n assert candidate(nums = ['987', '654', '321'],queries = [[1, 3], [2, 2], [3, 1]]) == [2, 1, 0]\n assert candidate(nums = ['00123', '01234', '12345', '23456', '34567'],queries = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3]]) == [0, 1, 2, 3, 4]\n assert candidate(nums = ['1234567890', '9876543210', '0000000000', '1111111111', '2222222222'],queries = [[1, 5], [3, 10], [2, 3], [5, 2]]) == [2, 0, 3, 0]\n assert candidate(nums = ['9999', '8888', '7777', '6666'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [1, 4]]) == [3, 2, 1, 0, 3]\n assert candidate(nums = ['111111111', '222222222', '333333333', '444444444', '555555555', '666666666', '777777777', '888888888', '999999999'],queries = [[9, 1], [1, 9], [5, 5], [3, 7], [7, 3], [2, 8], [8, 2], [4, 6], [6, 4]]) == [8, 0, 4, 2, 6, 1, 7, 3, 5]\n assert candidate(nums = ['1001', '10001', '100001', '1000001', '10000001'],queries = [[1, 4], [2, 6], [3, 3], [4, 5], [5, 1]]) == [1, 4, 2, 1, 4]\n assert candidate(nums = ['123456', '654321', '135799', '975311', '246800'],queries = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2]]) == [0, 2, 3, 2, 2]\n assert candidate(nums = ['12345', '67890', '54321', '09876', '43210'],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [3, 4, 0, 3, 3]\n assert candidate(nums = ['123456789', '987654321', '135792468', '246801357', '579135791'],queries = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [1, 4], [2, 3], [3, 2], [4, 1]]) == [0, 2, 3, 2, 2, 3, 3, 2, 2]\n assert candidate(nums = ['10001', '01001', '00101', '00011', '11001'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [2, 3]]) == [0, 1, 4, 1, 4, 1]\n assert candidate(nums = ['00001', '00002', '00003', '00004', '00005', '00006', '00007', '00008', '00009'],queries = [[1, 1], [9, 1], [2, 1], [3, 1], [8, 1], [4, 1], [7, 1], [5, 1], [6, 1]]) == [0, 8, 1, 2, 7, 3, 6, 4, 5]\n assert candidate(nums = ['1234', '2345', '3456', '4567', '5678', '6789', '7890'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == [6, 1, 2, 3, 4, 5, 6]\n assert candidate(nums = ['00000', '00001', '00002', '00003', '00004'],queries = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 5]]) == [0, 1, 2, 3, 4, 0]\n assert candidate(nums = ['00001', '00010', '00100', '01000', '10000'],queries = [[1, 1], [5, 5], [3, 3], [2, 2], [4, 4]]) == [1, 4, 0, 3, 2]\n assert candidate(nums = ['987', '876', '765', '654', '543', '432', '321', '210', '109'],queries = [[1, 1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3], [7, 2], [8, 3], [9, 1]]) == [7, 6, 6, 5, 4, 3, 2, 1, 8]\n assert candidate(nums = ['1010', '0101', '0011', '1100'],queries = [[1, 2], [2, 1], [3, 4], [4, 3]]) == [3, 3, 0, 1]\n assert candidate(nums = ['1111', '2222', '3333', '4444', '5555'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 5]]) == [0, 1, 2, 3, 4, 0]\n assert candidate(nums = ['000001', '000010', '000100', '001000', '010000', '100000'],queries = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = ['11111', '11112', '11122', '11222', '12222'],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(nums = ['100100', '100010', '101000', '010100', '001100', '001010', '010010', '000101', '000011', '110000'],queries = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 6], [8, 5], [9, 4], [10, 3]]) == [8, 8, 6, 5, 9, 5, 1, 9, 5, 7]\n assert candidate(nums = ['11111', '22222', '33333', '44444', '55555'],queries = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]) == [0, 1, 2, 3, 4]\n assert candidate(nums = ['999', '888', '777', '666', '555'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 3]]) == [4, 3, 2, 1, 0]\n assert candidate(nums = ['00123', '00234', '00345', '00456'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [2, 3]]) == [0, 1, 2, 3, 1]\n assert candidate(nums = ['123', '234', '345', '456', '567', '678', '789', '890', '901', '012'],queries = [[1, 1], [10, 3], [5, 2], [3, 3], [8, 1], [2, 2], [7, 3], [4, 3], [6, 3], [9, 1]]) == [7, 8, 2, 1, 4, 9, 5, 2, 4, 5]\n assert candidate(nums = ['00000', '11111', '22222', '33333', '44444', '55555'],queries = [[1, 1], [6, 5], [3, 3], [4, 2], [2, 4], [5, 5]]) == [0, 5, 2, 3, 1, 4]\n assert candidate(nums = ['123', '456', '789', '101', '111'],queries = [[1, 1], [2, 2], [3, 3], [4, 1], [5, 2]]) == [3, 4, 0, 1, 2]\n assert candidate(nums = ['123456', '654321', '111111', '222222', '333333'],queries = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2]]) == [2, 3, 4, 4, 0]\n assert candidate(nums = ['999', '111', '222', '888', '333', '444', '555', '666', '777', '000'],queries = [[1, 1], [10, 3], [5, 2], [3, 3], [8, 1], [2, 2], [4, 4], [7, 5], [6, 6], [9, 9]]) == [9, 0, 5, 2, 8, 1, 4, 7, 6, 3]\n assert candidate(nums = ['09876', '54321', '01234', '98765', '43210'],queries = [[1, 3], [2, 2], [3, 1], [4, 5], [5, 4]]) == [4, 1, 2, 1, 0]\n assert candidate(nums = ['0000', '1111', '2222', '3333', '4444', '5555', '6666', '7777', '8888', '9999'],queries = [[1, 1], [5, 4], [10, 1], [3, 2], [7, 3]]) == [0, 4, 9, 2, 6]\n assert candidate(nums = ['00011', '00101', '01001', '10001', '00110', '01100', '11000', '10100', '01010', '10010'],queries = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3]]) == [6, 2, 3, 8, 9, 0, 5, 7, 1, 4]\n assert candidate(nums = ['123', '456', '789', '123', '456'],queries = [[1, 3], [2, 3], [3, 3], [4, 2], [5, 1]]) == [0, 3, 1, 4, 2]\n assert candidate(nums = ['00001', '00002', '00003', '00004', '00005', '00006', '00007', '00008', '00009', '00010'],queries = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = ['112233', '223344', '334455', '445566', '556677'],queries = [[1, 3], [2, 6], [3, 2], [4, 4], [5, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(nums = ['123456789', '234567890', '345678901', '456789012', '567890123'],queries = [[1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [1, 1]]) == [0, 1, 2, 3, 4, 1]\n assert candidate(nums = ['11111', '22222', '33333', '44444', '55555'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(nums = ['98765', '87654', '76543', '65432', '54321'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [4, 3, 2, 1, 0]\n assert candidate(nums = ['11111', '21111', '31111', '41111', '51111'],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [0, 1, 2, 3, 4]\n assert candidate(nums = ['9999999999', '1234567890', '1111111111', '2222222222', '3333333333'],queries = [[1, 10], [2, 5], [3, 7], [4, 2], [5, 9]]) == [2, 3, 4, 1, 0]\n assert candidate(nums = ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111'],queries = [[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]]) == [0, 2, 8, 12, 2, 10, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = ['111111111', '222222222', '333333333', '444444444', '555555555'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [3, 9], [5, 9]]) == [0, 1, 2, 3, 4, 2, 4]\n assert candidate(nums = ['0000', '0001', '0010', '0100', '1000'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 3, 1, 3, 4]\n assert candidate(nums = ['00011', '00101', '01001', '10001', '00110', '01100', '11000', '10100', '10010', '01010'],queries = [[1, 2], [3, 3], [5, 1], [7, 4], [9, 5], [2, 5], [4, 2], [6, 3], [8, 1], [10, 2]]) == [5, 3, 8, 6, 7, 1, 1, 0, 1, 0]\n assert candidate(nums = ['99999', '88888', '77777', '66666', '55555', '44444', '33333'],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [3, 5], [4, 4]]) == [6, 5, 4, 3, 2, 4, 3]\n assert candidate(nums = ['0011', '0101', '1001', '1100'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [1, 2]]) == [3, 1, 3, 3, 3]\n assert candidate(nums = ['0123456789', '1234567890', '2345678901', '3456789012', '4567890123'],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [0, 1, 2, 3, 4]\n assert candidate(nums = ['00001', '00011', '00111', '01111', '11111', '22222', '33333', '44444', '55555'],queries = [[1, 1], [5, 2], [9, 3], [4, 4], [3, 5], [8, 1], [2, 2]]) == [0, 4, 8, 3, 2, 7, 1]\n assert candidate(nums = ['12', '21', '11', '22', '12', '21'],queries = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [1, 2]]) == [1, 2, 5, 0, 3, 4, 2]\n assert candidate(nums = ['9990', '9909', '9099', '0999', '9999'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 1], [5, 2], [5, 3]]) == [0, 0, 0, 0, 4, 4, 4]\n assert candidate(nums = ['001100', '010101', '100100', '110011'],queries = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 3], [2, 4], [3, 5], [4, 6]]) == [0, 0, 1, 1, 3, 2, 3, 3]\n assert candidate(nums = ['00111', '01010', '10001', '11100', '10110'],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [0, 1, 2, 4, 3]\n assert candidate(nums = ['00123', '01234', '12345', '23456', '34567'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [2, 3], [3, 2]]) == [0, 1, 2, 3, 4, 1, 2]\n assert candidate(nums = ['12345', '23456', '34567', '45678', '56789'],queries = [[1, 1], [3, 2], [5, 3], [2, 4], [4, 5]]) == [0, 2, 4, 1, 3]\n assert candidate(nums = ['12345', '67890', '13579', '24680', '97531'],queries = [[1, 2], [3, 4], [5, 1], [2, 5], [4, 3]]) == [4, 3, 2, 2, 3]\n assert candidate(nums = ['1111111111', '2222222222', '3333333333', '4444444444', '5555555555', '6666666666', '7777777777', '8888888888', '9999999999'],queries = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = ['50000', '05000', '00500', '00050'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [3, 5], [4, 5]]) == [0, 1, 3, 1, 1, 0]\n assert candidate(nums = ['9876543210', '0123456789', '1029384756', '2918074653', '3827165430'],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [1, 1, 4, 3, 0]\n assert candidate(nums = ['123', '234', '345', '456', '567', '678', '789'],queries = [[1, 1], [2, 3], [4, 2], [5, 3], [7, 1]]) == [0, 1, 3, 4, 6]\n assert candidate(nums = ['999999', '888888', '777777', '666666', '555555'],queries = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2]]) == [4, 3, 2, 1, 0]\n assert candidate(nums = ['12345', '23456', '34567', '45678', '56789'],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [1, 1]]) == [0, 1, 2, 3, 4, 0]\n assert candidate(nums = ['00001', '00010', '00100', '01000', '10000'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 3, 0, 2, 4]\n assert candidate(nums = ['0000000000', '0000000001', '0000000010', '0000000100', '0000001000', '0000010000', '0000100000', '0001000000', '0010000000', '0100000000'],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = ['110011001', '101010101', '010101010', '001100110', '100110011'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 3], [2, 3], [3, 5], [4, 5], [5, 1]]) == [2, 1, 4, 0, 0, 0, 2, 4, 1, 4]\n assert candidate(nums = ['98765', '87654', '76543', '65432'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [1, 2], [2, 3]]) == [3, 2, 1, 0, 3, 2]\n assert candidate(nums = ['0001', '0010', '0100', '1000'],queries = [[1, 1], [2, 2], [3, 3], [4, 4]]) == [1, 3, 1, 3]\n assert candidate(nums = ['99999', '99998', '99997', '99996', '99995'],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [4, 3, 2, 1, 0]\n assert candidate(nums = ['1234', '5678', '9012', '3456'],queries = [[1, 1], [2, 4], [3, 3], [4, 2]]) == [2, 3, 3, 1]\n assert candidate(nums = ['001', '010', '100', '011', '101', '110'],queries = [[1, 1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3]]) == [1, 2, 4, 1, 4, 5]\n assert candidate(nums = ['11111', '22222', '33333', '44444'],queries = [[4, 5], [3, 4], [2, 3], [1, 2]]) == [3, 2, 1, 0]\n assert candidate(nums = ['9876543210', '8765432109', '7654321098', '6543210987', '5432109876'],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [4, 2, 0, 3, 1]\n assert candidate(nums = ['12345', '23456', '34567', '45678', '56789'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(nums = ['9876543210', '0123456789', '1098765432', '2987654321', '3876543210'],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == [1, 2, 3, 4, 0]\n assert candidate(nums = ['0011', '0101', '0110', '1001', '1010', '1100'],queries = [[1, 1], [3, 2], [2, 2], [4, 3], [5, 1], [6, 3]]) == [2, 3, 1, 5, 1, 2]\n assert candidate(nums = ['00100', '01010', '10001', '01110', '11001'],queries = [[1, 5], [2, 3], [3, 2], [4, 4], [5, 1]]) == [0, 4, 4, 1, 4]\n assert candidate(nums = ['987654321', '876543219', '765432198', '654321987', '543219876'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [3, 9]]) == [0, 0, 0, 0, 0, 2]\n assert candidate(nums = ['11111', '22222', '33333', '44444', '55555'],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(nums = ['00111', '01110', '11100', '11001', '10011'],queries = [[1, 3], [2, 2], [3, 1], [4, 4], [5, 5]]) == [3, 3, 0, 2, 2]\n assert candidate(nums = ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001'],queries = [[1, 4], [2, 3], [3, 2], [4, 1], [5, 4], [6, 3], [7, 2], [8, 1], [9, 4], [10, 3]]) == [0, 8, 8, 6, 4, 3, 2, 5, 8, 7]\n assert candidate(nums = ['00001', '00010', '00100', '01000', '10000'],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = ['00001', '00002', '00003', '00004', '00005'],queries = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().smallestTrimmedNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] smallestTrimmedNumbers(String[] nums, int[][] queries) {", "container": "Solution", "callable": "smallestTrimmedNumbers", "parameters": [{"name": "nums", "type": "String[]"}, {"name": "queries", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2344, "task_id": "minimum-deletions-to-make-array-divisible", "difficulty": "Hard", "problem_description": "You are given two positive integer arrays nums and numsDivide. You can delete any number of elements from nums.\nReturn the minimum number of deletions such that the smallest element in nums divides all the elements of numsDivide. If this is not possible, return -1.\nNote that an integer x divides y if y % x == 0.\n \nExample 1:\n\nInput: nums = [2,3,2,4,3], numsDivide = [9,6,9,3,15]\nOutput: 2\nExplanation: \nThe smallest element in [2,3,2,4,3] is 2, which does not divide all the elements of numsDivide.\nWe use 2 deletions to delete the elements in nums that are equal to 2 which makes nums = [3,4,3].\nThe smallest element in [3,4,3] is 3, which divides all the elements of numsDivide.\nIt can be shown that 2 is the minimum number of deletions needed.\n\nExample 2:\n\nInput: nums = [4,3,6], numsDivide = [8,2,6,10]\nOutput: -1\nExplanation: \nWe want the smallest element in nums to divide all the elements of numsDivide.\nThere is no way to delete elements from nums to allow this.\n \nConstraints:\n\n1 <= nums.length, numsDivide.length <= 105\n1 <= nums[i], numsDivide[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],numsDivide = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [5, 10, 15, 20],numsDivide = [5, 15, 25, 35]) == 0\n assert candidate(nums = [1, 3, 5, 7],numsDivide = [2, 4, 6, 8]) == 0\n assert candidate(nums = [10, 20, 30],numsDivide = [5, 10, 15]) == -1\n assert candidate(nums = [5, 5, 5, 5],numsDivide = [5, 5, 5, 5]) == 0\n assert candidate(nums = [3, 5, 7, 9],numsDivide = [15, 30, 45, 60]) == 0\n assert candidate(nums = [2, 4, 6, 8],numsDivide = [2, 4, 6, 8]) == 0\n assert candidate(nums = [5, 10, 15, 20],numsDivide = [10, 20, 30, 40]) == 0\n assert candidate(nums = [5, 7, 10],numsDivide = [14, 35, 70]) == 1\n assert candidate(nums = [2, 4, 8, 16],numsDivide = [1, 2, 3, 4]) == -1\n assert candidate(nums = [3, 5, 6, 8, 9],numsDivide = [30, 45, 60]) == 0\n assert candidate(nums = [1, 2, 3, 4],numsDivide = [2, 4, 6, 8]) == 0\n assert candidate(nums = [4, 3, 6],numsDivide = [8, 2, 6, 10]) == -1\n assert candidate(nums = [3, 9, 7, 3],numsDivide = [9, 18, 90, 72]) == 0\n assert candidate(nums = [2, 3, 2, 4, 3],numsDivide = [9, 6, 9, 3, 15]) == 2\n assert candidate(nums = [1],numsDivide = [1]) == 0\n assert candidate(nums = [3, 6, 9, 12],numsDivide = [3, 6, 9, 12]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15],numsDivide = [27, 54, 81, 108]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10],numsDivide = [20, 40, 60, 80, 100]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81],numsDivide = [162, 324, 486, 648]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],numsDivide = [84, 168, 252]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [100, 200, 300]) == 0\n assert candidate(nums = [17, 34, 51, 68],numsDivide = [34, 68, 102, 136, 170]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],numsDivide = [15, 30, 45, 60, 75]) == 0\n assert candidate(nums = [8, 16, 32, 64, 128],numsDivide = [256, 512, 1024, 2048]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35],numsDivide = [49, 98, 147, 196]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19],numsDivide = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == -1\n assert candidate(nums = [4, 8, 12, 16, 20],numsDivide = [8, 16, 24, 32, 40, 48, 56]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45],numsDivide = [18, 36, 54, 72]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],numsDivide = [18, 36, 54, 72, 90]) == 0\n assert candidate(nums = [21, 42, 63, 84],numsDivide = [42, 84, 126, 168, 210]) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128],numsDivide = [256, 512, 1024, 2048]) == 0\n assert candidate(nums = [3, 9, 27, 81, 243],numsDivide = [81, 243, 729, 2187]) == 0\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],numsDivide = [4, 8, 12, 16, 20]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12],numsDivide = [24, 48, 72, 96]) == 0\n assert candidate(nums = [3, 6, 9, 12],numsDivide = [18, 24, 30, 36, 42]) == 0\n assert candidate(nums = [13, 26, 39, 52],numsDivide = [260, 390, 520]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],numsDivide = [30, 45, 60, 75]) == -1\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64],numsDivide = [192, 384, 576, 768]) == 0\n assert candidate(nums = [12, 15, 18, 21],numsDivide = [36, 54, 72, 90]) == 2\n assert candidate(nums = [7, 11, 13, 17],numsDivide = [14, 22, 26, 34]) == -1\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13],numsDivide = [2, 3, 5, 7, 11, 13]) == 0\n assert candidate(nums = [13, 26, 39, 52, 65],numsDivide = [260, 390, 520, 650]) == 0\n assert candidate(nums = [31, 37, 41, 43, 47],numsDivide = [93, 121, 143, 187]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],numsDivide = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35],numsDivide = [14, 28, 42, 56]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [66, 132, 198, 264]) == 0\n assert candidate(nums = [2, 5, 7, 10, 14],numsDivide = [4, 10, 14, 20]) == 0\n assert candidate(nums = [13, 26, 39, 52, 65],numsDivide = [78, 156, 234, 312]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [100, 50, 25, 20]) == 0\n assert candidate(nums = [31, 62, 93, 124, 155],numsDivide = [186, 372, 558, 744]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],numsDivide = [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 = [101, 202, 303, 404],numsDivide = [202, 404, 606, 808, 1010]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [100, 200, 300, 400]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [220, 330, 440, 550]) == 0\n assert candidate(nums = [47, 94, 141, 188, 235],numsDivide = [282, 564, 846, 1128]) == 0\n assert candidate(nums = [29, 58, 87, 116, 145],numsDivide = [174, 348, 522, 696]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],numsDivide = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 0\n assert candidate(nums = [9, 18, 27, 36],numsDivide = [27, 54, 81, 108, 135]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15],numsDivide = [27, 54, 81, 108]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [22, 44, 66, 88]) == 0\n assert candidate(nums = [13, 26, 39, 52, 65],numsDivide = [78, 156, 234, 312]) == 0\n assert candidate(nums = [3, 5, 7, 11, 13],numsDivide = [15, 21, 35, 77]) == -1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],numsDivide = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [18, 27, 36, 45, 54],numsDivide = [54, 108, 162, 216]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15],numsDivide = [18, 36, 54, 72]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],numsDivide = [60, 105, 140, 231]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500],numsDivide = [1000, 2000, 3000, 4000]) == 0\n assert candidate(nums = [7, 14, 28, 35],numsDivide = [28, 56, 84, 112]) == 0\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],numsDivide = [1000000000, 500000000, 250000000, 125000000]) == 0\n assert candidate(nums = [1000000000, 2000000000, 3000000000],numsDivide = [5000000000, 10000000000]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10],numsDivide = [12, 18, 24, 30, 36]) == 0\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909],numsDivide = [1010, 2020, 3030]) == 0\n assert candidate(nums = [17, 34, 51, 68, 85],numsDivide = [102, 204, 306, 408]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [50, 75, 100]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numsDivide = [100, 200, 300, 400, 500]) == 0\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],numsDivide = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == -1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104],numsDivide = [104, 208, 312]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10],numsDivide = [12, 18, 24, 30]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11],numsDivide = [2310, 4620, 6930, 9240]) == 0\n assert candidate(nums = [7, 14, 21, 28],numsDivide = [42, 56, 70, 84]) == 0\n assert candidate(nums = [30, 40, 50, 60, 70],numsDivide = [300, 600, 900, 1200]) == 0\n assert candidate(nums = [18, 27, 36, 45],numsDivide = [162, 243, 324]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],numsDivide = [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 = [11, 22, 33, 44, 55, 66],numsDivide = [132, 264, 396]) == 0\n assert candidate(nums = [10, 15, 20, 25, 30],numsDivide = [100, 150, 200]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],numsDivide = [50, 100, 150, 200]) == 0\n assert candidate(nums = [12, 15, 20, 25, 30],numsDivide = [60, 90, 120, 150]) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42],numsDivide = [420, 840, 1260, 1680]) == 0\n assert candidate(nums = [7, 14, 28, 35, 42],numsDivide = [84, 168, 252, 336]) == 0\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],numsDivide = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == -1\n assert candidate(nums = [23, 46, 69, 92, 115],numsDivide = [138, 207, 276, 345, 414]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],numsDivide = [25, 50, 75, 100]) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13],numsDivide = [30030, 60060, 90090, 120120]) == 0\n assert candidate(nums = [12, 24, 36, 48],numsDivide = [60, 120, 180]) == 0\n assert candidate(nums = [43, 86, 129, 172, 215],numsDivide = [258, 387, 516, 645, 774]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35],numsDivide = [42, 56, 70, 84]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [220, 330, 440, 550, 660]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10],numsDivide = [3, 5, 7, 9, 11]) == -1\n assert candidate(nums = [2, 2, 2, 2, 2],numsDivide = [4, 6, 8, 10]) == 0\n assert candidate(nums = [8, 16, 24, 32, 40],numsDivide = [40, 80, 120, 160]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65],numsDivide = [165, 330, 495]) == 0\n assert candidate(nums = [43, 86, 129, 172, 215],numsDivide = [258, 516, 774, 1032]) == 0\n assert candidate(nums = [10, 15, 20, 25, 30],numsDivide = [150, 300, 450, 600, 750]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18],numsDivide = [180, 360, 540, 720, 900]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],numsDivide = [100, 200, 300, 400, 500]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19],numsDivide = [13, 17, 19, 29, 31]) == -1\n assert candidate(nums = [1001, 2002, 3003, 4004],numsDivide = [2002, 4004, 6006, 8008, 10010]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45],numsDivide = [108, 162, 216, 270, 324]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],numsDivide = [20, 40, 60, 80, 100]) == 0\n assert candidate(nums = [13, 26, 39, 52, 65],numsDivide = [78, 130, 195, 260, 325]) == 0\n assert candidate(nums = [3, 6, 9, 12],numsDivide = [36, 72, 108]) == 0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23],numsDivide = [2310, 4620, 6930, 9240]) == 0\n assert candidate(nums = [3, 9, 12, 18],numsDivide = [27, 54, 81, 108]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45],numsDivide = [75, 150, 225, 300]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [50, 100, 150, 200]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [110, 220, 330, 440, 550]) == 0\n assert candidate(nums = [37, 74, 111, 148, 185],numsDivide = [238, 357, 476, 595, 714]) == -1\n assert candidate(nums = [31, 62, 93, 124, 155],numsDivide = [186, 279, 372, 465, 558]) == 0\n assert candidate(nums = [41, 82, 123, 164, 205],numsDivide = [246, 369, 492, 615, 738]) == 0\n assert candidate(nums = [13, 26, 39, 52, 65, 78],numsDivide = [156, 195, 260, 390]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35],numsDivide = [49, 98, 147, 196]) == 0\n assert candidate(nums = [7, 14, 21, 28],numsDivide = [42, 56, 70]) == 0\n assert candidate(nums = [30, 60, 90, 120, 150, 180],numsDivide = [300, 600, 900, 1200]) == 0\n assert candidate(nums = [5, 15, 25, 35],numsDivide = [25, 50, 75, 100, 125]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],numsDivide = [150, 300, 450, 600]) == -1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],numsDivide = [14, 28, 42, 56, 70]) == 0\n assert candidate(nums = [13, 26, 39, 52],numsDivide = [26, 52, 78, 104, 130]) == 0\n assert candidate(nums = [17, 34, 51, 68, 85],numsDivide = [340, 680, 1020, 1360]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [50, 100, 150, 200]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42],numsDivide = [14, 28, 42, 56, 70]) == 0\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999],numsDivide = [1110, 2220, 3330]) == 0\n assert candidate(nums = [1, 2, 3, 5, 7, 11],numsDivide = [105, 165, 231]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63],numsDivide = [108, 162, 216, 270]) == 0\n assert candidate(nums = [13, 26, 39, 52, 65],numsDivide = [26, 52, 78, 104]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [66, 77, 88, 99]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30],numsDivide = [60, 120, 180, 240]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [50, 100, 150, 200, 250]) == 0\n assert candidate(nums = [100, 200, 300, 400],numsDivide = [500, 1000, 1500]) == 0\n assert candidate(nums = [37, 74, 111, 148, 185],numsDivide = [222, 444, 666, 888]) == 0\n assert candidate(nums = [29, 58, 87, 116, 145],numsDivide = [174, 261, 348, 435, 522]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],numsDivide = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [8, 16, 24, 32, 40],numsDivide = [100, 200, 300, 400]) == -1\n assert candidate(nums = [23, 46, 69, 92, 115],numsDivide = [138, 276, 414, 552]) == 0\n assert candidate(nums = [19, 38, 57, 76, 95],numsDivide = [114, 190, 285, 380, 475]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],numsDivide = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == -1\n assert candidate(nums = [19, 38, 57, 76, 95],numsDivide = [114, 228, 342, 456]) == 0\n assert candidate(nums = [10, 15, 20, 25],numsDivide = [100, 200, 300]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],numsDivide = [12, 24, 36, 48, 60]) == 0\n assert candidate(nums = [11, 22, 33, 44],numsDivide = [22, 44, 66, 88, 110]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10],numsDivide = [24, 36, 48, 60]) == 0\n assert candidate(nums = [17, 23, 31, 37, 41, 43],numsDivide = [51, 68, 85]) == 0\n assert candidate(nums = [8, 16, 24, 32, 40],numsDivide = [16, 32, 48, 64, 80, 96]) == 0\n assert candidate(nums = [19, 38, 57, 76],numsDivide = [38, 76, 114, 152, 190]) == 0\n assert candidate(nums = [41, 82, 123, 164, 205],numsDivide = [246, 492, 738, 984]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1],numsDivide = [1]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35],numsDivide = [42, 56, 84, 98, 140]) == 0\n assert candidate(nums = [6, 12, 18, 24, 30],numsDivide = [12, 24, 36, 48, 60, 72]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "numsDivide"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minOperations(int[] nums, int[] numsDivide) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "numsDivide", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2347, "task_id": "best-poker-hand", "difficulty": "Easy", "problem_description": "You are given an integer array ranks and a character array suits. You have 5 cards where the ith card has a rank of ranks[i] and a suit of suits[i].\nThe following are the types of poker hands you can make from best to worst:\n\n\"Flush\": Five cards of the same suit.\n\"Three of a Kind\": Three cards of the same rank.\n\"Pair\": Two cards of the same rank.\n\"High Card\": Any single card.\n\nReturn a string representing the best type of poker hand you can make with the given cards.\nNote that the return values are case-sensitive.\n \nExample 1:\n\nInput: ranks = [13,2,3,1,9], suits = [\"a\",\"a\",\"a\",\"a\",\"a\"]\nOutput: \"Flush\"\nExplanation: The hand with all the cards consists of 5 cards with the same suit, so we have a \"Flush\".\n\nExample 2:\n\nInput: ranks = [4,4,2,4,4], suits = [\"d\",\"a\",\"a\",\"b\",\"c\"]\nOutput: \"Three of a Kind\"\nExplanation: The hand with the first, second, and fourth card consists of 3 cards with the same rank, so we have a \"Three of a Kind\".\nNote that we could also make a \"Pair\" hand but \"Three of a Kind\" is a better hand.\nAlso note that other cards could be used to make the \"Three of a Kind\" hand.\nExample 3:\n\nInput: ranks = [10,10,2,12,9], suits = [\"a\",\"b\",\"c\",\"a\",\"d\"]\nOutput: \"Pair\"\nExplanation: The hand with the first and second card consists of 2 cards with the same rank, so we have a \"Pair\".\nNote that we cannot make a \"Flush\" or a \"Three of a Kind\".\n\n \nConstraints:\n\nranks.length == suits.length == 5\n1 <= ranks[i] <= 13\n'a' <= suits[i] <= 'd'\nNo two cards have the same rank and suit.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(ranks = [7, 7, 7, 7, 7],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [7, 7, 7, 8, 9],suits = ['a', 'b', 'c', 'a', 'd']) == \"Three of a Kind\"\n assert candidate(ranks = [10, 10, 2, 12, 9],suits = ['a', 'b', 'c', 'a', 'd']) == \"Pair\"\n assert candidate(ranks = [7, 7, 7, 7, 7],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [1, 1, 2, 2, 3],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'b', 'c', 'd', 'a']) == \"High Card\"\n assert candidate(ranks = [13, 2, 3, 1, 9],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [2, 3, 4, 5, 6],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [11, 11, 12, 12, 13],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n assert candidate(ranks = [4, 4, 2, 4, 4],suits = ['d', 'a', 'a', 'b', 'c']) == \"Three of a Kind\"\n assert candidate(ranks = [10, 10, 11, 11, 12],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n assert candidate(ranks = [6, 6, 6, 7, 7],suits = ['d', 'd', 'd', 'c', 'c']) == \"Three of a Kind\"\n assert candidate(ranks = [3, 3, 4, 4, 5],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [8, 8, 8, 9, 10],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [5, 6, 7, 8, 9],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [7, 7, 8, 8, 9],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [5, 5, 5, 3, 3],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [11, 12, 13, 13, 13],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [5, 5, 6, 6, 7],suits = ['a', 'b', 'a', 'b', 'a']) == \"Pair\"\n assert candidate(ranks = [6, 6, 7, 7, 8],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n assert candidate(ranks = [1, 2, 3, 3, 3],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [4, 4, 5, 5, 6],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n assert candidate(ranks = [9, 9, 9, 9, 9],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [1, 2, 3, 4, 4],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n assert candidate(ranks = [8, 8, 9, 9, 10],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n assert candidate(ranks = [10, 11, 12, 13, 13],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [5, 5, 5, 6, 7],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [6, 6, 6, 7, 8],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [10, 10, 10, 12, 13],suits = ['a', 'b', 'c', 'a', 'b']) == \"Three of a Kind\"\n assert candidate(ranks = [8, 8, 9, 9, 10],suits = ['a', 'a', 'b', 'b', 'c']) == \"Pair\"\n assert candidate(ranks = [3, 3, 3, 8, 8],suits = ['a', 'b', 'c', 'a', 'b']) == \"Three of a Kind\"\n assert candidate(ranks = [1, 3, 3, 3, 5],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [13, 13, 13, 13, 1],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [6, 6, 6, 7, 8],suits = ['a', 'a', 'a', 'b', 'c']) == \"Three of a Kind\"\n assert candidate(ranks = [1, 1, 2, 3, 4],suits = ['a', 'a', 'b', 'c', 'd']) == \"Pair\"\n assert candidate(ranks = [13, 13, 13, 13, 13],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [12, 12, 12, 12, 13],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [9, 9, 10, 11, 12],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [8, 8, 10, 10, 10],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [3, 3, 3, 4, 4],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [6, 6, 6, 6, 6],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [8, 8, 8, 9, 9],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [5, 5, 5, 5, 10],suits = ['a', 'a', 'a', 'a', 'b']) == \"Three of a Kind\"\n assert candidate(ranks = [1, 1, 2, 2, 3],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [7, 8, 9, 10, 11],suits = ['a', 'b', 'c', 'd', 'a']) == \"High Card\"\n assert candidate(ranks = [13, 12, 11, 10, 9],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [5, 5, 5, 6, 7],suits = ['a', 'b', 'c', 'a', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'b', 'c', 'd', 'e']) == \"High Card\"\n assert candidate(ranks = [2, 2, 3, 3, 4],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'b', 'c', 'd', 'e']) == \"High Card\"\n assert candidate(ranks = [6, 6, 6, 7, 8],suits = ['b', 'b', 'b', 'c', 'd']) == \"Three of a Kind\"\n assert candidate(ranks = [8, 8, 8, 9, 9],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [2, 2, 3, 4, 4],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [2, 3, 5, 5, 5],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'a', 'b', 'b', 'c']) == \"High Card\"\n assert candidate(ranks = [3, 3, 3, 3, 5],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [6, 6, 7, 7, 8],suits = ['a', 'a', 'b', 'b', 'c']) == \"Pair\"\n assert candidate(ranks = [2, 2, 2, 2, 2],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [9, 9, 9, 10, 10],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [13, 13, 2, 3, 4],suits = ['a', 'b', 'a', 'b', 'a']) == \"Pair\"\n assert candidate(ranks = [6, 6, 6, 6, 7],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [11, 11, 12, 12, 13],suits = ['a', 'a', 'b', 'b', 'c']) == \"Pair\"\n assert candidate(ranks = [10, 10, 11, 11, 12],suits = ['a', 'b', 'a', 'b', 'a']) == \"Pair\"\n assert candidate(ranks = [5, 6, 7, 8, 9],suits = ['a', 'b', 'c', 'd', 'a']) == \"High Card\"\n assert candidate(ranks = [1, 1, 1, 2, 3],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [8, 8, 8, 8, 2],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [13, 12, 11, 10, 9],suits = ['a', 'b', 'c', 'd', 'e']) == \"High Card\"\n assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [1, 1, 2, 3, 4],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n assert candidate(ranks = [1, 1, 2, 3, 4],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [2, 3, 4, 5, 6],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [2, 2, 2, 3, 3],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [1, 2, 2, 3, 4],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [13, 13, 13, 12, 12],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [5, 5, 5, 6, 7],suits = ['a', 'a', 'a', 'b', 'c']) == \"Three of a Kind\"\n assert candidate(ranks = [10, 10, 11, 11, 12],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [6, 6, 7, 7, 8],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [2, 2, 3, 4, 5],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n assert candidate(ranks = [7, 8, 9, 10, 11],suits = ['a', 'b', 'c', 'd', 'a']) == \"High Card\"\n assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'b', 'c', 'd', 'a']) == \"High Card\"\n assert candidate(ranks = [9, 10, 11, 12, 13],suits = ['a', 'b', 'c', 'd', 'e']) == \"High Card\"\n assert candidate(ranks = [9, 9, 10, 10, 11],suits = ['a', 'b', 'a', 'b', 'c']) == \"Pair\"\n assert candidate(ranks = [10, 11, 12, 13, 13],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [3, 3, 4, 4, 5],suits = ['a', 'a', 'b', 'b', 'c']) == \"Pair\"\n assert candidate(ranks = [9, 9, 9, 9, 10],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [13, 13, 13, 12, 11],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [7, 8, 9, 10, 11],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n assert candidate(ranks = [1, 1, 2, 2, 3],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n assert candidate(ranks = [9, 9, 9, 9, 9],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [2, 2, 2, 2, 3],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [13, 13, 13, 1, 1],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [6, 6, 6, 7, 7],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n assert candidate(ranks = [13, 13, 12, 12, 11],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [5, 5, 10, 10, 10],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [3, 3, 5, 5, 7],suits = ['a', 'b', 'a', 'b', 'a']) == \"Pair\"\n assert candidate(ranks = [1, 2, 3, 4, 4],suits = ['a', 'b', 'c', 'd', 'e']) == \"Pair\"\n assert candidate(ranks = [12, 12, 13, 13, 13],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'a', 'a', 'a', 'd']) == \"High Card\"\n assert candidate(ranks = [3, 3, 3, 3, 3],suits = ['a', 'b', 'c', 'd', 'e']) == \"Three of a Kind\"\n"}, "metadata": {"canonical_parameter_names": ["ranks", "suits"], "leetcode_dataset_entry_point": "Solution().bestHand", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String bestHand(int[] ranks, char[] suits) {", "container": "Solution", "callable": "bestHand", "parameters": [{"name": "ranks", "type": "int[]"}, {"name": "suits", "type": "char[]"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2348, "task_id": "number-of-zero-filled-subarrays", "difficulty": "Medium", "problem_description": "Given an integer array nums, return the number of subarrays filled with 0.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,3,0,0,2,0,0,4]\nOutput: 6\nExplanation: \nThere are 4 occurrences of [0] as a subarray.\nThere are 2 occurrences of [0,0] as a subarray.\nThere is no occurrence of a subarray with a size more than 2 filled with 0. Therefore, we return 6.\nExample 2:\n\nInput: nums = [0,0,0,2,0,0]\nOutput: 9\nExplanation:\nThere are 5 occurrences of [0] as a subarray.\nThere are 3 occurrences of [0,0] as a subarray.\nThere is 1 occurrence of [0,0,0] as a subarray.\nThere is no occurrence of a subarray with a size more than 3 filled with 0. Therefore, we return 9.\n\nExample 3:\n\nInput: nums = [2,10,2019]\nOutput: 0\nExplanation: There is no subarray filled with 0. Therefore, we return 0.\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 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 45\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 55\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 2\n assert candidate(nums = [1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]) == 30\n assert candidate(nums = [1, 3, 0, 0, 2, 0, 0, 4]) == 6\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 1\n assert candidate(nums = [5, 0, 0, 0, 0, 0, 0, 5]) == 21\n assert candidate(nums = [5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [0, 0, 0, 2, 0, 0]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 45\n assert candidate(nums = [2, 10, 2019]) == 0\n assert candidate(nums = [0]) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == 3\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0]) == 4\n assert candidate(nums = [0, 0, 0, 0]) == 10\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0]) == 9\n assert candidate(nums = [5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0]) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1]) == 3\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 0, 0]) == 8\n assert candidate(nums = [10, 20, 30, 0, 0, 0, 40, 50, 60, 0, 0, 70]) == 9\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 18\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7]) == 52\n assert candidate(nums = [1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0]) == 37\n assert candidate(nums = [999999999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 190\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, 1]) == 300\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 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]) == 210\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0]) == 63\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 175\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == 30\n assert candidate(nums = [1000000000, 0, 0, 0, -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]) == 502\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0]) == 45\n assert candidate(nums = [0, 0, 0, 1, 1, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == 37\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 0, 0, 0]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14]) == 45\n assert candidate(nums = [100, 0, 0, 0, 0, 0, 200, 0, 0, 0, 300, 0, 0, 0, 400, 0, 0, 0, 500]) == 33\n assert candidate(nums = [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]) == 39\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0]) == 50\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]) == 45\n assert candidate(nums = [10, 0, 0, 10, 0, 10, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0]) == 38\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 2850\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 8\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == 6\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]) == 54\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]) == 1596\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 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, 0, 0]) == 1891\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]) == 22\n assert candidate(nums = [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]) == 780\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 0, 0, 0, 0]) == 76\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]) == 990\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, 1000000000]) == 325\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]) == 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1275\n assert candidate(nums = [9, 0, 0, 8, 0, 0, 7, 0, 0, 6, 0, 0, 5, 0, 0, 4, 0, 0, 3, 0, 0, 2, 0, 0, 1, 0]) == 25\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == 5\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]) == 13\n assert candidate(nums = [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]) == 171\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 12\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]) == 4753\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 0, 4, 0, 0, 0, 5]) == 11\n assert candidate(nums = [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]) == 34\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(nums = [999999999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -999999999]) == 190\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 10]) == 42\n assert candidate(nums = [1, 2, 3, 0, 0, 0, 4, 5, 0, 0, 6, 7, 0, 0, 0, 0, 8]) == 19\n assert candidate(nums = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5]) == 25\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 = [0, 1, 0, 1, 0, 1, 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 = [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]) == 300\n assert candidate(nums = [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0, 9, 0, 0, 0]) == 54\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0]) == 22\n assert candidate(nums = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 55\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 5]) == 60\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 210\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0]) == 84\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]) == 325\n assert candidate(nums = [9, 0, 0, 0, 0, 8, 0, 0, 7, 0, 0, 0, 6, 0, 5, 0, 0, 4, 0, 0, 0, 3, 0, 0, 2, 0, 0, 1, 0]) == 36\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 106\n assert candidate(nums = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0]) == 12\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == 21\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]) == 34\n assert candidate(nums = [1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0]) == 34\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0]) == 9\n assert candidate(nums = [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == 62\n assert candidate(nums = [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]) == 496\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000, 1000000000, 1000000000]) == 153\n assert candidate(nums = [1, 0, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 0, 5, 0, 0, 6, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 9]) == 67\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 0, 0, 0, 0]) == 38\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]) == 595\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 9\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 2, 2, 2, 0, 0, 0, 3, 3, 3, 0, 0, 0]) == 24\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().zeroFilledSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long zeroFilledSubarray(int[] nums) {", "container": "Solution", "callable": "zeroFilledSubarray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2350, "task_id": "shortest-impossible-sequence-of-rolls", "difficulty": "Hard", "problem_description": "You are given an integer array rolls of length n and an integer k. You roll a k sided dice numbered from 1 to k, n times, where the result of the ith roll is rolls[i].\nReturn the length of the shortest sequence of rolls so that there's no such subsequence in rolls.\nA sequence of rolls of length len is the result of rolling a k sided dice len times.\n \nExample 1:\n\nInput: rolls = [4,2,1,2,3,3,2,4,1], k = 4\nOutput: 3\nExplanation: Every sequence of rolls of length 1, [1], [2], [3], [4], can be taken from rolls.\nEvery sequence of rolls of length 2, [1, 1], [1, 2], ..., [4, 4], can be taken from rolls.\nThe sequence [1, 4, 2] cannot be taken from rolls, so we return 3.\nNote that there are other sequences that cannot be taken from rolls.\nExample 2:\n\nInput: rolls = [1,1,2,2], k = 2\nOutput: 2\nExplanation: Every sequence of rolls of length 1, [1], [2], can be taken from rolls.\nThe sequence [2, 1] cannot be taken from rolls, so we return 2.\nNote that there are other sequences that cannot be taken from rolls but [2, 1] is the shortest.\n\nExample 3:\n\nInput: rolls = [1,1,3,2,2,2,3,3], k = 4\nOutput: 1\nExplanation: The sequence [4] cannot be taken from rolls, so we return 1.\nNote that there are other sequences that cannot be taken from rolls but [4] is the shortest.\n\n \nConstraints:\n\nn == rolls.length\n1 <= n <= 105\n1 <= rolls[i] <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 2\n assert candidate(rolls = [1, 1, 1, 1, 1],k = 1) == 6\n assert candidate(rolls = [1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 4\n assert candidate(rolls = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],k = 6) == 3\n assert candidate(rolls = [1, 1, 3, 2, 2, 2, 3, 3],k = 4) == 1\n assert candidate(rolls = [1, 1, 2, 2],k = 2) == 2\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 11\n assert candidate(rolls = [1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 3\n assert candidate(rolls = [4, 2, 1, 2, 3, 3, 2, 4, 1],k = 4) == 3\n assert candidate(rolls = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 4\n assert candidate(rolls = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 1\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 1\n assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 3\n assert candidate(rolls = [1],k = 1) == 2\n assert candidate(rolls = [5, 5, 5, 5, 5],k = 5) == 1\n assert candidate(rolls = [5, 4, 3, 2, 1],k = 5) == 2\n assert candidate(rolls = [1, 2, 3, 4, 5],k = 5) == 2\n assert candidate(rolls = [1, 3, 2, 3, 2, 1],k = 3) == 3\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 9\n assert candidate(rolls = [5, 1, 3, 4, 2, 5, 1, 3, 4, 2, 5, 1, 3, 4, 2],k = 5) == 4\n assert candidate(rolls = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 2, 2, 3, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 9\n assert candidate(rolls = [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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 5\n assert candidate(rolls = [1, 2, 3, 4, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],k = 6) == 3\n assert candidate(rolls = [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 = 3) == 18\n assert candidate(rolls = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 100000) == 1\n assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 2\n assert candidate(rolls = [1, 2, 3, 4, 4, 3, 2, 1, 1, 2, 3, 4, 4, 3, 2, 1],k = 4) == 5\n assert candidate(rolls = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 8\n assert candidate(rolls = [1, 2, 1, 3, 2, 1, 4, 2, 1, 3, 4, 2, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 1, 4, 2, 1, 3, 4, 2, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 1, 4, 2, 1, 3, 4, 2, 1, 3, 2, 4],k = 4) == 12\n assert candidate(rolls = [3, 1, 2, 1, 3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 10\n assert candidate(rolls = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(rolls = [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, 1, 2, 3, 4, 5],k = 5) == 10\n assert candidate(rolls = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 3\n assert candidate(rolls = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 6\n assert candidate(rolls = [1, 2, 2, 1, 3, 1, 2, 3, 4, 2, 1, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],k = 6) == 3\n assert candidate(rolls = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 4) == 2\n assert candidate(rolls = [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],k = 10) == 5\n assert candidate(rolls = [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],k = 10) == 3\n assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 2\n assert candidate(rolls = [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],k = 10) == 2\n assert candidate(rolls = [5, 5, 5, 5, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 3\n assert candidate(rolls = [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, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 12\n assert candidate(rolls = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 5) == 2\n assert candidate(rolls = [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, 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) == 8\n assert candidate(rolls = [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],k = 30) == 3\n assert candidate(rolls = [5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2],k = 5) == 4\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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) == 35\n assert candidate(rolls = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 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],k = 5) == 5\n assert candidate(rolls = [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, 1],k = 15) == 3\n assert candidate(rolls = [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 = 10) == 4\n assert candidate(rolls = [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],k = 7) == 2\n assert candidate(rolls = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 6\n assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4],k = 4) == 6\n assert candidate(rolls = [1],k = 100000) == 1\n assert candidate(rolls = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 4\n assert candidate(rolls = [2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4],k = 4) == 11\n assert candidate(rolls = [5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4],k = 5) == 4\n assert candidate(rolls = [1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 3\n assert candidate(rolls = [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, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 13\n assert candidate(rolls = [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 = 3) == 16\n assert candidate(rolls = [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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 4\n assert candidate(rolls = [1, 3, 2, 4, 2, 1, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 6\n assert candidate(rolls = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 2) == 11\n assert candidate(rolls = [7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1],k = 7) == 6\n assert candidate(rolls = [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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == 7\n assert candidate(rolls = [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],k = 15) == 2\n assert candidate(rolls = [1, 3, 3, 1, 2, 4, 4, 2, 3, 1, 4, 2, 3, 1, 2, 4, 4, 2, 3, 1, 4, 2, 3, 1, 2, 4, 4, 2, 3, 1, 4, 2, 3, 1, 2, 4, 4, 2, 3, 1, 4, 2, 3, 1, 2, 4],k = 4) == 10\n assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 1, 1, 2, 2, 3, 3],k = 6) == 2\n assert candidate(rolls = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 5) == 5\n assert candidate(rolls = [1, 2, 2, 1, 3, 3, 1, 2, 3, 4, 4, 1, 2, 3, 4, 5, 5, 1, 2, 3, 4, 5, 6, 6, 1, 2, 3, 4, 5, 6, 7, 7],k = 7) == 2\n assert candidate(rolls = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 3\n assert candidate(rolls = [3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4],k = 4) == 6\n assert candidate(rolls = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 5) == 2\n assert candidate(rolls = [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, 6],k = 6) == 2\n assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2],k = 5) == 4\n assert candidate(rolls = [7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7],k = 7) == 5\n assert candidate(rolls = [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],k = 10) == 4\n assert candidate(rolls = [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 = 3) == 9\n assert candidate(rolls = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 3\n assert candidate(rolls = [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],k = 4) == 2\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 16\n assert candidate(rolls = [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, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 5) == 12\n assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],k = 6) == 3\n assert candidate(rolls = [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],k = 5) == 4\n assert candidate(rolls = [1, 2, 2, 1, 3, 3, 3, 1, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 6\n assert candidate(rolls = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 5) == 4\n assert candidate(rolls = [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, 3, 2, 1, 3, 2, 1],k = 3) == 16\n assert candidate(rolls = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 9\n assert candidate(rolls = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 12\n assert candidate(rolls = [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 = 3) == 11\n assert candidate(rolls = [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) == 4\n assert candidate(rolls = [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],k = 4) == 2\n assert candidate(rolls = [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],k = 5) == 10\n assert candidate(rolls = [5, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4],k = 5) == 5\n assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 4\n assert candidate(rolls = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10],k = 20) == 2\n"}, "metadata": {"canonical_parameter_names": ["rolls", "k"], "leetcode_dataset_entry_point": "Solution().shortestSequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int shortestSequence(int[] rolls, int k) {", "container": "Solution", "callable": "shortestSequence", "parameters": [{"name": "rolls", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2351, "task_id": "first-letter-to-appear-twice", "difficulty": "Easy", "problem_description": "Given a string s consisting of lowercase English letters, return the first letter to appear twice.\nNote:\n\nA letter a appears twice before another letter b if the second occurrence of a is before the second occurrence of b.\ns will contain at least one letter that appears twice.\n\n \nExample 1:\n\nInput: s = \"abccbaacz\"\nOutput: \"c\"\nExplanation:\nThe letter 'a' appears on the indexes 0, 5 and 6.\nThe letter 'b' appears on the indexes 1 and 4.\nThe letter 'c' appears on the indexes 2, 3 and 7.\nThe letter 'z' appears on the index 8.\nThe letter 'c' is the first letter to appear twice, because out of all the letters the index of its second occurrence is the smallest.\n\nExample 2:\n\nInput: s = \"abcdd\"\nOutput: \"d\"\nExplanation:\nThe only letter that appears twice is 'd' so we return 'd'.\n\n \nConstraints:\n\n2 <= s.length <= 100\ns consists of lowercase English letters.\ns has at least one repeated letter.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"alphabet\") == \"a\"\n assert candidate(s = \"finding\") == \"i\"\n assert candidate(s = \"xyzxyz\") == \"x\"\n assert candidate(s = \"zabcdefghijkkl\") == \"k\"\n assert candidate(s = \"first\") == None\n assert candidate(s = \"second\") == None\n assert candidate(s = \"abcdefghijkk\") == \"k\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaa\") == \"a\"\n assert candidate(s = \"abcdefggh\") == \"g\"\n assert candidate(s = \"mnopqrsstuvwxzyz\") == \"s\"\n assert candidate(s = \"abccbaacz\") == \"c\"\n assert candidate(s = \"interview\") == \"i\"\n assert candidate(s = \"abcdefgah\") == \"a\"\n assert candidate(s = \"abcdd\") == \"d\"\n assert candidate(s = \"aabb\") == \"a\"\n assert candidate(s = \"xyzabczy\") == \"z\"\n assert candidate(s = \"xyzxyzxyz\") == \"x\"\n assert candidate(s = \"example\") == \"e\"\n assert candidate(s = \"repeated\") == \"e\"\n assert candidate(s = \"occurrence\") == \"c\"\n assert candidate(s = \"aabbccddeeff\") == \"a\"\n assert candidate(s = \"aab\") == \"a\"\n assert candidate(s = \"hello\") == \"l\"\n assert candidate(s = \"aabbcc\") == \"a\"\n assert candidate(s = \"abcdabc\") == \"a\"\n assert candidate(s = \"characters\") == \"a\"\n assert candidate(s = \"programming\") == \"r\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabc\") == \"a\"\n assert candidate(s = \"abcdefghia\") == \"a\"\n assert candidate(s = \"abcdefghijkklmno\") == \"k\"\n assert candidate(s = \"onetimeonetimethisisaverylongstringwithsomerepeatedcharacters\") == \"e\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmq\") == \"q\"\n assert candidate(s = \"abcdefghijkabcdefghijklmnopqrstuvwxyz\") == \"a\"\n assert candidate(s = \"findingthebestsolution\") == \"i\"\n assert candidate(s = \"hellothereitisme\") == \"l\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"a\"\n assert candidate(s = \"thisisareallylongstringtofindtherepeatedcharacter\") == \"i\"\n assert candidate(s = \"abracadabra\") == \"a\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzz\") == \"z\"\n assert candidate(s = \"ababababababababababababababababab\") == \"a\"\n assert candidate(s = \"fasterthanlighttravels\") == \"t\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == \"a\"\n assert candidate(s = \"zzzzzzzzzz\") == \"z\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwxyzz\") == \"a\"\n assert candidate(s = \"xyzzzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxz\") == \"z\"\n assert candidate(s = \"characterscharacterscharacterszzzzzzz\") == \"a\"\n assert candidate(s = \"abababababababababababababababab\") == \"a\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == \"a\"\n assert candidate(s = \"thisisareallylongstringwithsomerepeatedcharacters\") == \"i\"\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydoggg\") == \"o\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab\") == \"a\"\n assert candidate(s = \"repeatedcharacters\") == \"e\"\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydogzzzzzzzzzzzzz\") == \"o\"\n assert candidate(s = \"abcdefghijklmnopqrstuuvwxyzz\") == \"u\"\n assert candidate(s = \"everyletterappearsatleasttwicemanytimes\") == \"e\"\n assert candidate(s = \"abcabcabcabcabcabcabc\") == \"a\"\n assert candidate(s = \"abcdefghijzabcdefghijzabcdefghijzabcdefghijzabcdefghijzabcdefghijz\") == \"a\"\n assert candidate(s = \"uniqueabcunique\") == \"u\"\n assert candidate(s = \"abcdefghijkmnopqrstuvwxyzabcde\") == \"a\"\n assert candidate(s = \"mnopqrstuzyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == \"u\"\n assert candidate(s = \"nevergonnagiveyouupnevergonnagiveyouupnevergonnagiveyouupnevergonnaletyoudownnevergonnagiveyouupnevergonnagiveyouupwithpocketsfullloveyourfacegotayellowblackeye\") == \"e\"\n assert candidate(s = \"almostuniqueexceptfortheendzz\") == \"u\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == \"a\"\n assert candidate(s = \"alohafromhawaii\") == \"a\"\n assert candidate(s = \"supercalifragilisticexpialidociouszzzz\") == \"r\"\n assert candidate(s = \"vovelsaeiouaeiouaeiou\") == \"v\"\n assert candidate(s = \"abcdefghijkabcdefghijk\") == \"a\"\n assert candidate(s = \"manymanycharactersandcharacters\") == \"m\"\n assert candidate(s = \"thisisthesentencewithrepeatedwords\") == \"i\"\n assert candidate(s = \"charactersrepeatedoften\") == \"a\"\n assert candidate(s = \"sometextwithrepeatedlettersss\") == \"e\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"a\"\n assert candidate(s = \"abcdefghijklmnoab\") == \"a\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == \"a\"\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijk\") == \"a\"\n assert candidate(s = \"encyclopedia\") == \"c\"\n assert candidate(s = \"abcdefghijkllmnopqrstuvwxyz\") == \"l\"\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\") == \"z\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijklmno\") == \"m\"\n assert candidate(s = \"repeatedcharacterintheendzz\") == \"e\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(s = \"thelongestsubstringwithoutrepeatingcharactersxx\") == \"e\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcde\") == \"a\"\n assert candidate(s = \"abababababababababab\") == \"a\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(s = \"abcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyza\") == \"a\"\n assert candidate(s = \"mnopqrswxyzaabcdefgijkhl\") == \"a\"\n assert candidate(s = \"mnopqrstuvwxyzaabcdefghijklmnopqrstuvwxyz\") == \"a\"\n assert candidate(s = \"abacabadabacaba\") == \"a\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"a\"\n assert candidate(s = \"overlappingcharactersababababababababa\") == \"p\"\n assert candidate(s = \"abcdexyzzyxwvutsrqponmlkjihgfe\") == \"z\"\n assert candidate(s = \"abcdefghijklaaabbbccc\") == \"a\"\n assert candidate(s = \"testingtestingtesting\") == \"t\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaz\") == \"z\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\") == \"q\"\n assert candidate(s = \"characterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacterscharacters\") == \"a\"\n assert candidate(s = \"abcdefghijkllmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"l\"\n assert candidate(s = \"nestedcharactersandcharacters\") == \"e\"\n assert candidate(s = \"elevenletters\") == \"e\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"a\"\n assert candidate(s = \"tenletterstensletters\") == \"e\"\n assert candidate(s = \"uniquecharacterherea\") == \"u\"\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydogz\") == \"o\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\") == \"o\"\n assert candidate(s = \"aaaabbbbccccdddd\") == \"a\"\n assert candidate(s = \"abcdexyzabc\") == \"a\"\n assert candidate(s = \"abcdefghef\") == \"e\"\n assert candidate(s = \"abcdefghijjklmnopqrstuvwxyz\") == \"j\"\n assert candidate(s = \"thisisaverylongstringwithseveralrepeatedcharacters\") == \"i\"\n assert candidate(s = \"singleletterrepeatedmanytimesaaaaaaaaaaa\") == \"l\"\n assert candidate(s = \"abcdefghijkla\") == \"a\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzba\") == \"b\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyx\") == \"z\"\n assert candidate(s = \"aabccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"a\"\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\") == \"o\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"a\"\n assert candidate(s = \"verylongstringwithrepeatedcharactersqrs\") == \"r\"\n assert candidate(s = \"repeatedcharacharactercharacter\") == \"e\"\n assert candidate(s = \"programmingproblemsarefun\") == \"r\"\n assert candidate(s = \"charactersrepeatedinrandomorderzzzzzzzzzz\") == \"a\"\n assert candidate(s = \"thisproblemhasmanylettersrepeated\") == \"h\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzabcdefghijklmnopqrstuvwxyz\") == \"z\"\n assert candidate(s = \"characterscharacterscharacterscharacters\") == \"a\"\n assert candidate(s = \"mississippi\") == \"s\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbac\") == \"c\"\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbbccccccccccdddddddddd\") == \"a\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == \"z\"\n assert candidate(s = \"aaaaabbbbbccccc\") == \"a\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().repeatedCharacter", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public char repeatedCharacter(String s) {", "container": "Solution", "callable": "repeatedCharacter", "parameters": [{"name": "s", "type": "String"}], "return_type": "char", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2352, "task_id": "equal-row-and-column-pairs", "difficulty": "Medium", "problem_description": "Given a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal.\nA row and column pair is considered equal if they contain the same elements in the same order (i.e., an equal array).\n \nExample 1:\n\n\nInput: grid = [[3,2,1],[1,7,6],[2,7,7]]\nOutput: 1\nExplanation: There is 1 equal row and column pair:\n- (Row 2, Column 1): [2,7,7]\n\nExample 2:\n\n\nInput: grid = [[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]]\nOutput: 3\nExplanation: There are 3 equal row and column pairs:\n- (Row 0, Column 0): [3,1,2,2]\n- (Row 2, Column 2): [2,4,2,2]\n- (Row 3, Column 2): [2,4,2,2]\n\n \nConstraints:\n\nn == grid.length == grid[i].length\n1 <= n <= 200\n1 <= grid[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 9\n assert candidate(grid = [[5]]) == 1\n assert candidate(grid = [[3, 2, 1], [1, 7, 6], [2, 7, 7]]) == 1\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 16\n assert candidate(grid = [[1, 2, 3], [3, 2, 1], [2, 1, 3]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 16\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 0\n assert candidate(grid = [[3, 1, 2, 2], [1, 4, 4, 5], [2, 4, 2, 2], [2, 4, 2, 2]]) == 3\n assert candidate(grid = [[10, 20, 30], [30, 20, 10], [20, 10, 30]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [2, 2, 2, 2, 2, 2]]) == 0\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]]) == 36\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [5, 0, 5, 0, 5], [0, 5, 0, 5, 0], [7, 3, 9, 5, 1]]) == 0\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]]) == 49\n assert candidate(grid = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 30, 50, 70], [70, 50, 30, 10]]) == 0\n assert candidate(grid = [[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]]) == 5\n assert candidate(grid = [[100000, 1, 2, 3], [1, 100000, 2, 3], [2, 1, 100000, 3], [3, 2, 1, 100000]]) == 1\n assert candidate(grid = [[7, 8, 9, 10], [10, 9, 8, 7], [7, 7, 7, 7], [1, 2, 3, 4]]) == 0\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]]) == 5\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == 4\n assert candidate(grid = [[5, 1, 9, 1, 5], [1, 5, 1, 5, 1], [9, 1, 5, 1, 9], [1, 5, 1, 5, 1], [5, 1, 9, 1, 5]]) == 9\n assert candidate(grid = [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]]) == 4\n assert candidate(grid = [[1, 1, 2, 2, 3, 3, 4, 4], [4, 4, 3, 3, 2, 2, 1, 1], [2, 2, 1, 1, 4, 4, 3, 3], [3, 3, 4, 4, 1, 1, 2, 2]]) == 0\n assert candidate(grid = [[5, 6, 7, 8, 9], [9, 8, 7, 6, 5], [5, 5, 5, 5, 5], [1, 2, 3, 4, 5], [9, 7, 5, 3, 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, 1]]) == 25\n assert candidate(grid = [[7, 8, 9, 10], [8, 9, 10, 7], [9, 10, 7, 8], [10, 7, 8, 9]]) == 4\n assert candidate(grid = [[100, 101, 102, 103, 104, 105], [105, 104, 103, 102, 101, 100], [100, 102, 104, 106, 108, 110], [110, 108, 106, 104, 102, 100], [101, 103, 105, 107, 109, 111], [111, 109, 107, 105, 103, 101]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 9, 2, 8, 3, 7, 4, 6, 5]]) == 0\n assert candidate(grid = [[1, 2, 1], [2, 1, 2], [1, 2, 1]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 1, 1, 1, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2]]) == 0\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], [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]]) == 0\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], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [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]]) == 0\n assert candidate(grid = [[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]]) == 36\n assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == 5\n assert candidate(grid = [[7, 8, 9], [9, 7, 8], [8, 9, 7]]) == 0\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, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [13, 12, 11, 10, 9, 8, 7, 6, 5, 4], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 0\n assert candidate(grid = [[1, 5, 9, 13], [2, 6, 10, 14], [3, 7, 11, 15], [4, 8, 12, 16]]) == 0\n assert candidate(grid = [[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]]) == 0\n assert candidate(grid = [[1, 1, 2, 2], [2, 2, 1, 1], [1, 2, 1, 2], [2, 1, 2, 1]]) == 2\n assert candidate(grid = [[1, 2, 1, 2], [2, 1, 2, 1], [1, 2, 1, 2], [2, 1, 2, 1]]) == 8\n assert candidate(grid = [[12345, 67890, 54321], [67890, 54321, 12345], [54321, 12345, 67890]]) == 3\n assert candidate(grid = [[11, 12, 13, 14], [15, 16, 17, 18], [19, 20, 21, 22], [14, 18, 22, 26]]) == 1\n assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 10], [30, 40, 50, 10, 20], [40, 50, 10, 20, 30], [50, 10, 20, 30, 40]]) == 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, 9, 7, 5, 3, 1], [1, 3, 5, 7, 9, 10, 8, 6, 4, 2]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [2, 4, 6, 8, 10]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 1, 2, 1], [1, 3, 1, 3, 1], [1, 4, 1, 4, 1], [1, 5, 1, 5, 1]]) == 3\n assert candidate(grid = [[100, 200, 300, 400], [200, 300, 400, 500], [300, 400, 500, 600], [400, 500, 600, 700]]) == 4\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]]) == 100\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]]) == 36\n assert candidate(grid = [[9, 8, 7, 6], [8, 7, 6, 5], [7, 6, 5, 4], [6, 5, 4, 3]]) == 4\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]]) == 0\n assert candidate(grid = [[11, 22, 33, 44, 55, 66], [66, 55, 44, 33, 22, 11], [11, 11, 11, 11, 11, 11], [22, 33, 44, 55, 66, 77], [77, 66, 55, 44, 33, 22], [22, 22, 22, 22, 22, 22]]) == 0\n assert candidate(grid = [[5, 6, 7, 8, 9], [6, 7, 8, 9, 5], [7, 8, 9, 5, 6], [8, 9, 5, 6, 7], [9, 5, 6, 7, 8]]) == 5\n assert candidate(grid = [[11, 22, 33, 44, 55], [55, 44, 33, 22, 11], [11, 33, 55, 77, 99], [99, 77, 55, 33, 11], [22, 44, 66, 88, 100]]) == 0\n assert candidate(grid = [[4, 3, 2, 1], [1, 4, 3, 2], [2, 1, 4, 3], [3, 2, 1, 4]]) == 0\n assert candidate(grid = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100], [100, 300, 500, 700, 900], [900, 700, 500, 300, 100], [100, 100, 100, 100, 100]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1], [1, 1, 1, 2]]) == 4\n assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == 9\n assert candidate(grid = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1]]) == 13\n assert candidate(grid = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]) == 8\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, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().equalPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int equalPairs(int[][] grid) {", "container": "Solution", "callable": "equalPairs", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2354, "task_id": "number-of-excellent-pairs", "difficulty": "Hard", "problem_description": "You are given a 0-indexed positive integer array nums and a positive integer k.\nA pair of numbers (num1, num2) is called excellent if the following conditions are satisfied:\n\nBoth the numbers num1 and num2 exist in the array nums.\nThe sum of the number of set bits in num1 OR num2 and num1 AND num2 is greater than or equal to k, where OR is the bitwise OR operation and AND is the bitwise AND operation.\n\nReturn the number of distinct excellent pairs.\nTwo pairs (a, b) and (c, d) are considered distinct if either a != c or b != d. For example, (1, 2) and (2, 1) are distinct.\nNote that a pair (num1, num2) such that num1 == num2 can also be excellent if you have at least one occurrence of num1 in the array.\n \nExample 1:\n\nInput: nums = [1,2,3,1], k = 3\nOutput: 5\nExplanation: The excellent pairs are the following:\n- (3, 3). (3 AND 3) and (3 OR 3) are both equal to (11) in binary. The total number of set bits is 2 + 2 = 4, which is greater than or equal to k = 3.\n- (2, 3) and (3, 2). (2 AND 3) is equal to (10) in binary, and (2 OR 3) is equal to (11) in binary. The total number of set bits is 1 + 2 = 3.\n- (1, 3) and (3, 1). (1 AND 3) is equal to (01) in binary, and (1 OR 3) is equal to (11) in binary. The total number of set bits is 1 + 2 = 3.\nSo the number of excellent pairs is 5.\nExample 2:\n\nInput: nums = [5,1,1], k = 10\nOutput: 0\nExplanation: There are no excellent pairs for this array.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= k <= 60\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [2, 4, 8, 16],k = 3) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 4) == 93\n assert candidate(nums = [1, 2, 4, 8, 16, 32],k = 3) == 0\n assert candidate(nums = [9, 10, 11, 12, 13, 14, 15],k = 7) == 7\n assert candidate(nums = [1, 1, 2, 3, 4],k = 2) == 16\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 9) == 72\n assert candidate(nums = [5, 1, 1],k = 10) == 0\n assert candidate(nums = [31, 14, 7, 3],k = 6) == 11\n assert candidate(nums = [1, 3, 5, 7],k = 4) == 11\n assert candidate(nums = [3, 1, 2, 5, 3, 4],k = 4) == 4\n assert candidate(nums = [7, 8, 9],k = 5) == 3\n assert candidate(nums = [1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [31, 14, 7, 1],k = 8) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 5) == 0\n assert candidate(nums = [1, 2, 3, 1],k = 3) == 5\n assert candidate(nums = [6, 5, 3, 1, 8, 7, 2, 4],k = 6) == 1\n assert candidate(nums = [7, 7, 7, 7],k = 5) == 1\n assert candidate(nums = [1023, 511, 255, 127],k = 10) == 16\n assert candidate(nums = [8, 8, 8, 8],k = 4) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 3) == 0\n assert candidate(nums = [7, 10, 4, 3, 15],k = 5) == 14\n assert candidate(nums = [31, 15, 7, 3, 1],k = 8) == 6\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 6) == 76\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 10) == 64\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 15) == 21\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642, 2147483641, 2147483640, 2147483639, 2147483638],k = 30) == 100\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 = 5) == 348\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 10) == 25\n assert candidate(nums = [15, 8, 7, 3, 1, 1, 2, 2],k = 4) == 21\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],k = 10) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],k = 4) == 22\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 3) == 209\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 200\n assert candidate(nums = [123456789, 987654321, 234567891, 198765432, 345678912, 456789123, 567891234, 678912345, 789123456, 891234567],k = 25) == 88\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383],k = 15) == 25\n assert candidate(nums = [1, 5, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153],k = 18) == 0\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 9) == 72\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 = 25) == 0\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907],k = 25) == 140\n assert candidate(nums = [5, 13, 15, 31, 7, 63],k = 8) == 19\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000],k = 10) == 36\n assert candidate(nums = [128, 256, 512, 1024, 2048, 4096],k = 7) == 0\n assert candidate(nums = [31, 14, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128],k = 7) == 7\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 20) == 100\n assert candidate(nums = [1023, 511, 255, 127, 63, 31],k = 10) == 36\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [29, 15, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 12\n assert candidate(nums = [5, 7, 15, 31, 63, 127, 255, 511, 1023, 2047],k = 15) == 36\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31],k = 6) == 55\n assert candidate(nums = [100, 200, 300, 400, 500],k = 8) == 10\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 7) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 15) == 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 = 20) == 229\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 6) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 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],k = 4) == 44\n assert candidate(nums = [3, 7, 15, 31, 63],k = 5) == 24\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 9) == 72\n assert candidate(nums = [5, 7, 13, 17, 23, 29, 31, 37, 41, 43, 47, 53, 59],k = 8) == 73\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535],k = 18) == 120\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 10) == 67\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 3) == 48\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 10) == 64\n assert candidate(nums = [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047],k = 12) == 64\n assert candidate(nums = [7, 11, 13, 14, 15],k = 5) == 25\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303],k = 20) == 100\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191],k = 14) == 91\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],k = 8) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 5) == 219\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 1],k = 10) == 28\n assert candidate(nums = [10, 20, 30, 40, 50],k = 5) == 16\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 5) == 209\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29],k = 5) == 1\n assert candidate(nums = [999999937, 999999938, 999999939, 999999940, 999999941, 999999942, 999999943, 999999944, 999999945, 999999946],k = 40) == 0\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 = 14) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64],k = 7) == 0\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517],k = 20) == 256\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64],k = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 44\n assert candidate(nums = [2, 4, 8, 16, 32],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],k = 4) == 285\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 = 12) == 345\n assert candidate(nums = [29, 17, 23, 30, 14, 11, 13, 19, 21, 22],k = 6) == 87\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 10) == 0\n assert candidate(nums = [3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 25, 27, 30, 33, 34, 36, 40, 41, 42, 45, 48, 50, 51, 54, 57, 60, 62, 65, 66, 68, 72, 73, 74, 77, 80, 81, 82, 85, 88, 90, 93, 96, 98, 101, 102, 104, 105, 106, 108, 112, 113, 114, 117, 120, 122, 125, 126, 129, 130, 132, 135, 136, 138, 140, 141, 142, 144, 145, 146, 148, 150, 153, 154, 156, 159, 160, 162, 165, 168, 170, 171, 172, 174, 177, 180, 182, 185, 186, 188, 190, 192, 193, 194, 195, 196, 198, 200, 201, 204, 205, 208, 210, 213, 216, 218, 219, 220, 222, 224, 225, 226, 228, 230, 231, 232, 234, 237, 240, 242, 243, 244, 246, 248, 249, 250, 252, 255],k = 6) == 13945\n assert candidate(nums = [3, 5, 9, 17, 33, 65, 129, 257, 513],k = 7) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 7) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12],k = 5) == 24\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 12) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3],k = 1) == 1\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],k = 15) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 2) == 100\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 12) == 45\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431],k = 25) == 49\n assert candidate(nums = [3, 3, 3, 5, 5, 5, 7, 7, 7],k = 4) == 9\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 25) == 100\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],k = 12) == 170\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],k = 5) == 636\n assert candidate(nums = [5, 3, 9, 7, 11],k = 4) == 25\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 16\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 = 22) == 0\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255],k = 10) == 28\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 4) == 247\n assert candidate(nums = [33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967295],k = 30) == 15\n assert candidate(nums = [98304, 49152, 24576, 12288, 6144, 3072, 1536, 768, 384, 192, 96, 48, 24, 12, 6, 3, 1, 1, 1, 1],k = 12) == 0\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 12) == 100\n assert candidate(nums = [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, 1],k = 15) == 0\n assert candidate(nums = [8, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180],k = 4) == 239\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 = 8) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countExcellentPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countExcellentPairs(int[] nums, int k) {", "container": "Solution", "callable": "countExcellentPairs", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2357, "task_id": "make-array-zero-by-subtracting-equal-amounts", "difficulty": "Easy", "problem_description": "You are given a non-negative integer array nums. In one operation, you must:\n\nChoose a positive integer x such that x is less than or equal to the smallest non-zero element in nums.\nSubtract x from every positive element in nums.\n\nReturn the minimum number of operations to make every element in nums equal to 0.\n \nExample 1:\n\nInput: nums = [1,5,0,3,5]\nOutput: 3\nExplanation:\nIn the first operation, choose x = 1. Now, nums = [0,4,0,2,4].\nIn the second operation, choose x = 2. Now, nums = [0,2,0,0,2].\nIn the third operation, choose x = 2. Now, nums = [0,0,0,0,0].\n\nExample 2:\n\nInput: nums = [0]\nOutput: 0\nExplanation: Each element in nums is already 0 so no operations are needed.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n0 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [1, 5, 0, 3, 5]) == 3\n assert candidate(nums = [0, 1, 0, 1, 0]) == 1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4]) == 4\n assert candidate(nums = [100, 0, 50, 50]) == 2\n assert candidate(nums = [100, 0, 50, 50, 0]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [99, 99, 99, 99, 99]) == 1\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == 1\n assert candidate(nums = [100, 100, 100, 100, 100]) == 1\n assert candidate(nums = [100, 0, 50, 25, 75]) == 4\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [2, 2, 2, 2]) == 1\n assert candidate(nums = [5, 5, 5, 0, 0, 5, 0]) == 1\n assert candidate(nums = [2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [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]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 10\n assert candidate(nums = [50, 25, 12, 6, 3, 1, 0, 0, 0, 0]) == 6\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294]) == 7\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [7, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 7\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 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]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0]) == 10\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == 10\n assert candidate(nums = [5, 0, 3, 3, 5, 0, 2]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 10, 20, 30, 40, 50, 0]) == 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\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 = [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\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 10\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]) == 9\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 10\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, 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, 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]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [5, 10, 15, 20, 25]) == 5\n assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5]) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [1, 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, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(nums = [5, 3, 8, 6, 2, 0, 7]) == 6\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 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]) == 10\n assert candidate(nums = [1, 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]) == 5\n assert candidate(nums = [5, 3, 2, 1, 4, 0, 2, 3]) == 5\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0]) == 10\n assert candidate(nums = [42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0]) == 1\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93]) == 7\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 5\n assert candidate(nums = [5, 3, 2, 1, 4, 3, 5, 0, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 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 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 15\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 3\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == 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\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == 5\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 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]) == 25\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 15\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 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]) == 20\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 20\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 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, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 10\n assert candidate(nums = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 0, 10, 20, 30, 40, 50, 60, 70, 80]) == 10\n assert candidate(nums = [50, 25, 75, 50, 25, 75, 50, 25, 75, 50, 25, 75, 50, 25, 75]) == 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]) == 20\n assert candidate(nums = [0, 2, 3, 2, 1, 3, 4, 3, 2, 1]) == 4\n assert candidate(nums = [5, 1, 4, 2, 3, 1, 0, 2, 4, 3]) == 5\n assert candidate(nums = [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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 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\n assert candidate(nums = [7, 14, 21, 28, 35, 42]) == 6\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 10, 20, 30]) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 0, 0]) == 5\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 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 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]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [1, 10, 100, 1000, 10000, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [0, 23, 46, 69, 92, 115]) == 5\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 10, 20, 30, 40]) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumOperations(int[] nums) {", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2358, "task_id": "maximum-number-of-groups-entering-a-competition", "difficulty": "Medium", "problem_description": "You are given a positive integer array grades which represents the grades of students in a university. You would like to enter all these students into a competition in ordered non-empty groups, such that the ordering meets the following conditions:\n\nThe sum of the grades of students in the ith group is less than the sum of the grades of students in the (i + 1)th group, for all groups (except the last).\nThe total number of students in the ith group is less than the total number of students in the (i + 1)th group, for all groups (except the last).\n\nReturn the maximum number of groups that can be formed.\n \nExample 1:\n\nInput: grades = [10,6,12,7,3,5]\nOutput: 3\nExplanation: The following is a possible way to form 3 groups of students:\n- 1st group has the students with grades = [12]. Sum of grades: 12. Student count: 1\n- 2nd group has the students with grades = [6,7]. Sum of grades: 6 + 7 = 13. Student count: 2\n- 3rd group has the students with grades = [10,3,5]. Sum of grades: 10 + 3 + 5 = 18. Student count: 3\nIt can be shown that it is not possible to form more than 3 groups.\n\nExample 2:\n\nInput: grades = [8,8]\nOutput: 1\nExplanation: We can only form 1 group, since forming 2 groups would lead to an equal number of students in both groups.\n\n \nConstraints:\n\n1 <= grades.length <= 105\n1 <= grades[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grades = [10, 6, 12, 7, 3, 5]) == 3\n assert candidate(grades = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 4\n assert candidate(grades = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 4\n assert candidate(grades = [1]) == 1\n assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(grades = [100, 200, 300, 400, 500]) == 2\n assert candidate(grades = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 4\n assert candidate(grades = [1, 2]) == 1\n assert candidate(grades = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 4\n assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 5\n assert candidate(grades = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(grades = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 4\n assert candidate(grades = [8, 8]) == 1\n assert candidate(grades = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(grades = [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]) == 13\n assert candidate(grades = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 4\n assert candidate(grades = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 4\n assert candidate(grades = [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]) == 7\n assert candidate(grades = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 5\n assert candidate(grades = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 4\n assert candidate(grades = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 4\n assert candidate(grades = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 5\n assert candidate(grades = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 4\n assert candidate(grades = [9, 5, 1, 3, 7, 4, 2, 8, 6, 10]) == 4\n assert candidate(grades = [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]) == 6\n assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(grades = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(grades = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 6\n assert candidate(grades = [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]) == 7\n assert candidate(grades = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(grades = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970, 99969, 99968, 99967, 99966, 99965, 99964, 99963, 99962, 99961, 99960, 99959, 99958, 99957, 99956, 99955, 99954, 99953, 99952, 99951, 99950, 99949, 99948, 99947, 99946, 99945, 99944, 99943, 99942, 99941, 99940, 99939, 99938, 99937, 99936, 99935, 99934, 99933, 99932, 99931, 99930, 99929, 99928, 99927, 99926, 99925, 99924, 99923, 99922, 99921, 99920, 99919, 99918, 99917, 99916, 99915, 99914, 99913, 99912, 99911, 99910, 99909, 99908, 99907, 99906, 99905, 99904, 99903, 99902, 99901]) == 13\n assert candidate(grades = [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]) == 10\n assert candidate(grades = [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]) == 6\n assert candidate(grades = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 4\n assert candidate(grades = [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]) == 7\n assert candidate(grades = [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]) == 8\n assert candidate(grades = [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]) == 8\n assert candidate(grades = [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]) == 8\n assert candidate(grades = [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, 0, -1, -2, -3, -4, -5]) == 7\n assert candidate(grades = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 5\n assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(grades = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(grades = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 5\n assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(grades = [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]) == 7\n assert candidate(grades = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 5\n assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(grades = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10]) == 4\n assert candidate(grades = [2, 1, 3, 1, 2, 3, 4, 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]) == 7\n assert candidate(grades = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(grades = [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]) == 9\n assert candidate(grades = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(grades = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8\n assert candidate(grades = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(grades = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 5\n assert candidate(grades = [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]) == 6\n assert candidate(grades = [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]) == 6\n assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(grades = [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]) == 7\n assert candidate(grades = [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]) == 7\n assert candidate(grades = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(grades = [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]) == 7\n assert candidate(grades = [9, 3, 5, 7, 2, 8, 6, 4, 1, 10]) == 4\n assert candidate(grades = [30, 25, 20, 15, 10, 5, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 5\n assert candidate(grades = [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]) == 13\n assert candidate(grades = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(grades = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 5\n assert candidate(grades = [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]) == 6\n assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 5\n assert candidate(grades = [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]) == 7\n assert candidate(grades = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 4\n assert candidate(grades = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215]) == 6\n assert candidate(grades = [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\n assert candidate(grades = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019]) == 5\n assert candidate(grades = [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]) == 8\n assert candidate(grades = [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]) == 9\n assert candidate(grades = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981]) == 5\n assert candidate(grades = [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]) == 7\n assert candidate(grades = [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]) == 6\n assert candidate(grades = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 5\n assert candidate(grades = [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]) == 9\n assert candidate(grades = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16, 21, 30, 22, 29, 23, 28, 24, 27, 25, 26]) == 7\n"}, "metadata": {"canonical_parameter_names": ["grades"], "leetcode_dataset_entry_point": "Solution().maximumGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumGroups(int[] grades) {", "container": "Solution", "callable": "maximumGroups", "parameters": [{"name": "grades", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2359, "task_id": "find-closest-node-to-given-two-nodes", "difficulty": "Medium", "problem_description": "You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge.\nThe graph is represented with a given 0-indexed array edges of size n, indicating that there is a directed edge from node i to node edges[i]. If there is no outgoing edge from i, then edges[i] == -1.\nYou are also given two integers node1 and node2.\nReturn the index of the node that can be reached from both node1 and node2, such that the maximum between the distance from node1 to that node, and from node2 to that node is minimized. If there are multiple answers, return the node with the smallest index, and if no possible answer exists, return -1.\nNote that edges may contain cycles.\n \nExample 1:\n\n\nInput: edges = [2,2,3,-1], node1 = 0, node2 = 1\nOutput: 2\nExplanation: The distance from node 0 to node 2 is 1, and the distance from node 1 to node 2 is 1.\nThe maximum of those two distances is 1. It can be proven that we cannot get a node with a smaller maximum distance than 1, so we return node 2.\n\nExample 2:\n\n\nInput: edges = [1,2,-1], node1 = 0, node2 = 2\nOutput: 2\nExplanation: The distance from node 0 to node 2 is 2, and the distance from node 2 to itself is 0.\nThe maximum of those two distances is 2. It can be proven that we cannot get a node with a smaller maximum distance than 2, so we return node 2.\n\n \nConstraints:\n\nn == edges.length\n2 <= n <= 105\n-1 <= edges[i] < n\nedges[i] != i\n0 <= node1, node2 < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [5, -1, 3, 4, 5, 6, -1, -1, 4, 3],node1 = 0,node2 = 0) == 0\n assert candidate(edges = [4, 3, 0, 5, 3, -1],node1 = 4,node2 = 0) == 4\n assert candidate(edges = [1, 2, 0, -1],node1 = 0,node2 = 2) == 0\n assert candidate(edges = [4, 4, 4, 5, 1, 2, 2],node1 = 1,node2 = 1) == 1\n assert candidate(edges = [4, 4, 4, 5, 1, 2],node1 = 0,node2 = 1) == 4\n assert candidate(edges = [4, 4, 8, -1, 9, 8, 4, 4, 1, 1],node1 = 5,node2 = 6) == 1\n assert candidate(edges = [1, 2, 0, -1],node1 = 1,node2 = 2) == 2\n assert candidate(edges = [1, 2, 3, 4, -1],node1 = 0,node2 = 4) == 4\n assert candidate(edges = [3, 3, 2, 4, 3],node1 = 0,node2 = 4) == 3\n assert candidate(edges = [2, 2, 3, -1],node1 = 0,node2 = 1) == 2\n assert candidate(edges = [1, 2, -1],node1 = 0,node2 = 2) == 2\n assert candidate(edges = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],node1 = 0,node2 = 19) == 3\n assert candidate(edges = [3, 1, 3, 4, 5, -1, 2, 2, 3, 0],node1 = 2,node2 = 8) == 3\n assert candidate(edges = [3, 3, 2, 4, 3, -1, 5, 5, -1, -1, 6, 6, -1, -1],node1 = 2,node2 = 10) == -1\n assert candidate(edges = [4, 3, 0, 5, 3, 9, 8, 5, 4, 6],node1 = 0,node2 = 8) == 4\n assert candidate(edges = [4, 4, 8, 5, 9, 8, 4, 4, 1, 1],node1 = 5,node2 = 6) == 1\n assert candidate(edges = [3, 0, 5, 5, 5, 3, 2, 0],node1 = 1,node2 = 7) == 0\n assert candidate(edges = [9, 8, 7, 6, 5, 4, 3, 2, 1, -1],node1 = 0,node2 = 8) == -1\n assert candidate(edges = [1, 2, 0, -1, -1, -1],node1 = 2,node2 = 3) == -1\n assert candidate(edges = [3, 0, 5, 3, 5, 0, 2, 5, 3, 5],node1 = 1,node2 = 7) == 0\n assert candidate(edges = [1, 2, 0, 3, 5, 6, 4, -1, -1],node1 = 1,node2 = 7) == -1\n assert candidate(edges = [2, 1, 2, -1, -1],node1 = 0,node2 = 1) == -1\n assert candidate(edges = [2, 0, 0, 3, -1, 4, 5, 5, -1],node1 = 0,node2 = 6) == -1\n assert candidate(edges = [1, 0, -1, -1, -1, -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],node1 = 0,node2 = 10) == -1\n assert candidate(edges = [5, 3, 1, 5, 2, 3],node1 = 1,node2 = 0) == 3\n assert candidate(edges = [3, 2, 5, 1, 4, -1, 0, 3],node1 = 6,node2 = 4) == -1\n assert candidate(edges = [2, 2, 3, -1, 4, 5, 3],node1 = 0,node2 = 5) == -1\n assert candidate(edges = [2, 3, 1, 4, -1, 5, -1],node1 = 0,node2 = 5) == -1\n assert candidate(edges = [5, 5, 5, 5, 5, -1, -1, -1, -1, -1],node1 = 0,node2 = 5) == 5\n assert candidate(edges = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],node1 = 0,node2 = 19) == 1\n assert candidate(edges = [2, 0, 0, 2, 0, 5, 6, -1, 9, 8, 7],node1 = 6,node2 = 5) == -1\n assert candidate(edges = [3, 1, 0, 2, -1, -1, -1],node1 = 2,node2 = 5) == -1\n assert candidate(edges = [2, 2, 3, 4, 2, -1, -1, 1],node1 = 0,node2 = 6) == -1\n assert candidate(edges = [1, 2, 3, 4, 0, 5, 6, 7, 8, 9, -1],node1 = 0,node2 = 10) == -1\n assert candidate(edges = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],node1 = 0,node2 = 9) == 0\n assert candidate(edges = [3, 0, 2, -1, 1, 2],node1 = 0,node2 = 3) == 3\n assert candidate(edges = [2, 0, 0, 2, 5, 4, 4],node1 = 3,node2 = 4) == -1\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],node1 = 0,node2 = 5) == 0\n assert candidate(edges = [3, 1, 1, 4, 1],node1 = 1,node2 = 2) == 1\n assert candidate(edges = [4, 3, 0, 5, 3, -1],node1 = 0,node2 = 4) == 4\n assert candidate(edges = [3, 3, 3, 4, 3, -1, -1, -1, -1, -1, 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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],node1 = 0,node2 = 40) == -1\n assert candidate(edges = [5, 3, 1, 4, 3, 5, 2, -1],node1 = 1,node2 = 6) == 1\n assert candidate(edges = [9, 8, 7, 6, 5, 4, 3, 2, 1, -1, 0],node1 = 5,node2 = 0) == -1\n assert candidate(edges = [4, 4, 8, -1, 9, 8, 4, 4, 1, 11, 4, 4, 4, 8, 11, 2, 10, 4, 10, 1],node1 = 0,node2 = 13) == 4\n assert candidate(edges = [3, 0, 5, 3, 5, 3, 4, -1, 0, 1],node1 = 5,node2 = 4) == 5\n assert candidate(edges = [6, 3, 4, 5, 5, 6, 7, 1, 0, -1],node1 = 0,node2 = 5) == 6\n assert candidate(edges = [2, -1, 3, -1, -1, -1, -1, 7, 4, 5, 6, 1],node1 = 0,node2 = 9) == -1\n assert candidate(edges = [1, 2, 0, 1, 3, 4, 2],node1 = 2,node2 = 5) == 1\n assert candidate(edges = [2, 3, 1, 5, 4, 3, 6, 5, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],node1 = 0,node2 = 7) == 3\n assert candidate(edges = [2, 0, 0, 2, 1, 4],node1 = 3,node2 = 5) == 0\n assert candidate(edges = [1, 2, 3, 4, 0, -1],node1 = 0,node2 = 5) == -1\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1],node1 = 18,node2 = 19) == -1\n assert candidate(edges = [4, 4, 8, 5, 9, 8, 4, 4, 1, 4],node1 = 0,node2 = 7) == 4\n assert candidate(edges = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0],node1 = 0,node2 = 5) == 0\n assert candidate(edges = [3, 1, 2, -1, 0],node1 = 2,node2 = 4) == -1\n assert candidate(edges = [1, 2, 0, 5, -1, 5],node1 = 3,node2 = 4) == -1\n assert candidate(edges = [3, 3, 0, -1, -1, 0],node1 = 1,node2 = 5) == 3\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10],node1 = 0,node2 = 19) == -1\n assert candidate(edges = [1, 2, 0, 5, 2, 1, 3, 4, 6, 7, -1],node1 = 8,node2 = 9) == 1\n assert candidate(edges = [2, -1, 3, -1, -1, -1, -1, 5, 8, 9, 7, -1, 1, 10, 3, 7, -1, 14, 1, 13, 11, 13, 10],node1 = 1,node2 = 10) == -1\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, -1],node1 = 19,node2 = 20) == -1\n assert candidate(edges = [4, 4, 4, 5, 1, 2, 2],node1 = 1,node2 = 0) == 4\n assert candidate(edges = [3, 4, 4, 5, 1, 6, 5, 5, 6, 8, 8, 1, 7, 9, 8, 8, 8, 8, 8, 8],node1 = 0,node2 = 10) == 5\n assert candidate(edges = [1, 2, 2, -1, 3, 3, 4, 5, 5, -1],node1 = 0,node2 = 8) == -1\n assert candidate(edges = [1, 2, 3, 4, 0],node1 = 1,node2 = 4) == 1\n assert candidate(edges = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],node1 = 0,node2 = 19) == -1\n assert candidate(edges = [3, 0, 5, 1, 3, 2, 4, 2, 2, -1],node1 = 1,node2 = 8) == -1\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0],node1 = 0,node2 = 19) == 0\n assert candidate(edges = [7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1],node1 = 11,node2 = 2) == -1\n assert candidate(edges = [4, 4, 4, 4, 4],node1 = 0,node2 = 2) == 4\n assert candidate(edges = [2, -1, 3, 5, -1, 2],node1 = 0,node2 = 5) == 2\n assert candidate(edges = [4, 4, 4, 5, 1, 2],node1 = 0,node2 = 3) == 4\n assert candidate(edges = [2, 2, 0, 4, 1, 0, -1, -1, 0, 3],node1 = 6,node2 = 7) == -1\n assert candidate(edges = [5, 4, 0, 3, 5, 2, 3, -1],node1 = 2,node2 = 5) == 2\n assert candidate(edges = [4, 4, 4, 5, 1, 2, 2],node1 = 0,node2 = 3) == 4\n assert candidate(edges = [2, 3, 1, 4, -1, -1, -1, 7, -1, -1, 5, 6],node1 = 0,node2 = 8) == -1\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],node1 = 0,node2 = 19) == 0\n assert candidate(edges = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],node1 = 0,node2 = 18) == -1\n assert candidate(edges = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1],node1 = 0,node2 = 7) == -1\n assert candidate(edges = [1, 2, 3, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1],node1 = 0,node2 = 20) == -1\n assert candidate(edges = [5, 3, 4, 5, 3, 2, -1],node1 = 1,node2 = 4) == 3\n assert candidate(edges = [3, 1, 2, 3, -1, -1],node1 = 5,node2 = 0) == -1\n assert candidate(edges = [4, 4, 4, 5, 1, 2, 2],node1 = 1,node2 = 5) == 4\n assert candidate(edges = [1, 0, 0, 4, 1],node1 = 0,node2 = 3) == 1\n assert candidate(edges = [2, -1, 3, 1],node1 = 0,node2 = 2) == 2\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],node1 = 0,node2 = 9) == 0\n assert candidate(edges = [10, 15, 11, 14, 13, 12, 5, 15, 9, 12, 15, 9, 10, 11, 13, -1, 12, 14, 15, 8, 5],node1 = 0,node2 = 14) == 10\n assert candidate(edges = [5, 4, 0, 2, 3, 0, 2, 4, 0, 3, 2, 3, 2, 2, 3, 0, 2, 1, 0, 1],node1 = 0,node2 = 1) == 0\n assert candidate(edges = [6, 3, 0, 5, 8, 5, 8, 3, -1, 6],node1 = 5,node2 = 6) == -1\n assert candidate(edges = [3, 0, 5, 5, 2, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],node1 = 0,node2 = 18) == -1\n assert candidate(edges = [1, 0, 3, 2, 1, 4, 5, -1, -1, -1, 8, 9, 7, 10, 11, 12, 13, -1],node1 = 1,node2 = 7) == -1\n assert candidate(edges = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],node1 = 0,node2 = 9) == 1\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1],node1 = 0,node2 = 10) == 10\n assert candidate(edges = [2, 2, 3, 4, 5, -1, 2, 6, 7, -1, -1],node1 = 0,node2 = 1) == 2\n assert candidate(edges = [2, 3, 3, 2],node1 = 0,node2 = 1) == 2\n assert candidate(edges = [5, 4, 0, 2, 3, 0, 2, 4, 0, 3, 2, 3, 2, 2, 3, -1, 2],node1 = 0,node2 = 2) == 0\n assert candidate(edges = [5, 3, 1, 4, 2, 6, 3, 2],node1 = 0,node2 = 5) == 5\n assert candidate(edges = [5, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, -1, 13, -1, 14, -1, 15],node1 = 0,node2 = 15) == -1\n assert candidate(edges = [2, 2, 3, 4, 5, -1, -1, 5, 5, 5],node1 = 0,node2 = 9) == 5\n assert candidate(edges = [1, 2, 0, 1, 3, -1, -1, -1],node1 = 0,node2 = 1) == 1\n assert candidate(edges = [3, 3, 0, 5, -1, 2, 0, -1, -1, 3, 1],node1 = 3,node2 = 10) == 3\n"}, "metadata": {"canonical_parameter_names": ["edges", "node1", "node2"], "leetcode_dataset_entry_point": "Solution().closestMeetingNode", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int closestMeetingNode(int[] edges, int node1, int node2) {", "container": "Solution", "callable": "closestMeetingNode", "parameters": [{"name": "edges", "type": "int[]"}, {"name": "node1", "type": "int"}, {"name": "node2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2360, "task_id": "longest-cycle-in-a-graph", "difficulty": "Hard", "problem_description": "You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge.\nThe graph is represented with a given 0-indexed array edges of size n, indicating that there is a directed edge from node i to node edges[i]. If there is no outgoing edge from node i, then edges[i] == -1.\nReturn the length of the longest cycle in the graph. If no cycle exists, return -1.\nA cycle is a path that starts and ends at the same node.\n \nExample 1:\n\n\nInput: edges = [3,3,4,2,3]\nOutput: 3\nExplanation: The longest cycle in the graph is the cycle: 2 -> 4 -> 3 -> 2.\nThe length of this cycle is 3, so 3 is returned.\n\nExample 2:\n\n\nInput: edges = [2,-1,3,1]\nOutput: -1\nExplanation: There are no cycles in this graph.\n\n \nConstraints:\n\nn == edges.length\n2 <= n <= 105\n-1 <= edges[i] < n\nedges[i] != i\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [-1, 2, 0, 1, -1]) == -1\n assert candidate(edges = [1, 2, 0, 4, -1]) == 3\n assert candidate(edges = [5, 4, 5, 4, 5, 4]) == 2\n assert candidate(edges = [1, 0, -1, -1]) == 2\n assert candidate(edges = [1, 1, 1, 1, 1]) == 1\n assert candidate(edges = [1, 0, 0, 0, 1]) == 2\n assert candidate(edges = [1, 0, -1, -1, -1]) == 2\n assert candidate(edges = [2, -1, 1, -1, -1, -1, -1, -1, -1, -1]) == -1\n assert candidate(edges = [1, 1, 1, 1, 1, 0]) == 1\n assert candidate(edges = [5, 4, 3, 2, 1, 0]) == 2\n assert candidate(edges = [0, 1, 2, 3, 4, -1]) == 1\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 10\n assert candidate(edges = [1, 2, 0, 1, 3, -1]) == 3\n assert candidate(edges = [1, 2, 0, -1]) == 3\n assert candidate(edges = [1, 2, 3, 4, 0]) == 5\n assert candidate(edges = [3, 0, 1, 4, 2]) == 5\n assert candidate(edges = [-1, -1, -1, -1, -1]) == -1\n assert candidate(edges = [0, 1, 2, 3, -1]) == 1\n assert candidate(edges = [5, 4, 3, 2, 1, 0, -1, -1, -1, -1]) == 2\n assert candidate(edges = [3, 3, 4, 2, 3]) == 3\n assert candidate(edges = [1, 1, 1, 1, 1, 1]) == 1\n assert candidate(edges = [2, -1, 3, 1]) == -1\n assert candidate(edges = [4, 4, 4, 4, 4]) == 1\n assert candidate(edges = [1, 0, 0, 0, 0]) == 2\n assert candidate(edges = [0, 1, 2, -1, -1]) == 1\n assert candidate(edges = [1, 2, 3, 4, 5, 0]) == 6\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 15, 16, 17, 18, 19, 10, 11]) == 10\n assert candidate(edges = [3, 1, 2, 0, 5, 6, 7, 8, 9, 4]) == 6\n assert candidate(edges = [1, 2, 0, 3, 4, 5, 6, 7, 8, 9, -1]) == 3\n assert candidate(edges = [1, 3, 2, 3]) == 1\n assert candidate(edges = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 1\n assert candidate(edges = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = [1, 2, 0, 5, 6, 7, 8, 9, 3, 4]) == 7\n assert candidate(edges = [2, 3, 4, -1, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -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 = [3, 3, 4, 2, 3, 5, 5, 6, 7, 7]) == 3\n assert candidate(edges = [1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 2\n assert candidate(edges = [5, 4, 0, 2, 0, 1, -1, 3]) == 4\n assert candidate(edges = [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 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 10\n assert candidate(edges = [1, 2, 0, -1, 1, -1, -1, -1, -1, -1]) == 3\n assert candidate(edges = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 10]) == 10\n assert candidate(edges = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(edges = [1, 2, 0, 5, 6, 3, 4, 8, -1, 9, 10, -1]) == 3\n assert candidate(edges = [2, 2, 3, 2, 2]) == 2\n assert candidate(edges = [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, 0]) == 2\n assert candidate(edges = [1, 0, 3, 2, -1, -1, -1, -1, -1, -1]) == 2\n assert candidate(edges = [2, 1, 2]) == 1\n assert candidate(edges = [3, 3, 3, 1, 2]) == 2\n assert candidate(edges = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 2\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 15, 16, 17, 18, 19, 10, 11, 21, 22, 23, 24, 20]) == 10\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]) == -1\n assert candidate(edges = [3, 3, 3, 0, 5, 5, 5, 0, 7, 7, 7, 0, 9, 9, 9, 0, 11, 11, 11, 0, 13, 13, 13, 0, 15, 15, 15, 0, 17, 17, 17, 0, 19, 19, 19, 0, 21, 21, 21, 0, 23, 23, 23, 0, 25, 25, 25, 0, 27, 27, 27, 0, 29, 29, 29, 0]) == 2\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 20\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, 12, 14, 15, 16, 17, 18, 19, -1]) == 2\n assert candidate(edges = [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, 0]) == 41\n assert candidate(edges = [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, 30]) == 10\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 0]) == 8\n assert candidate(edges = [7, 4, 5, 6, 3, 1, 2, 0]) == 6\n assert candidate(edges = [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, 0]) == 31\n assert candidate(edges = [5, 4, 0, 2, 0, 1, 2, -1, -1, 10, 9]) == 4\n assert candidate(edges = [2, 3, 4, 5, 0, -1, -1, -1, -1, -1]) == 3\n assert candidate(edges = [3, 3, 4, 2, 3, -1, 5, 5, 6, 7, -1, 8, 9, 10, -1, 11, 12, -1, 13, 14, -1, 15, 16, -1, 17, 18, -1, 19, 20, -1, 21, 22, -1, 23, 24, -1, 25, 26, -1, 27, 28, -1, 29, 30, -1, 31, 32, -1, 33, 34, -1, 35, 36, -1, 37, 38, -1, 39, 40, -1, 41, 42, -1, 43, 44, -1, 45, 46, -1, 47, 48, -1, 49, 50, -1, 51, 52, -1, 53, 54, -1, 55, 56, -1, 57, 58, -1, 59, 60, -1, 61, 62, -1, 63, 64, -1, 65, 66, -1, 67, 68, -1, 69, 70, -1, 71, 72, -1, 73, 74, -1, 75, 76, -1, 77, 78, -1, 79, 80, -1, 81, 82, -1, 83, 84, -1, 85, 86, -1, 87, 88, -1, 89, 90, -1, 91, 92, -1, 93, 94, -1, 95, 96, -1, 97, 98, -1, 99, 100, -1]) == 3\n assert candidate(edges = [1, 3, 2, 2, 0, -1, -1, -1, -1, -1]) == 1\n assert candidate(edges = [1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3]) == 1\n assert candidate(edges = [1, 2, 0, 3, 4, 5, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 3\n assert candidate(edges = [2, 3, 4, -1, 5, 6, 7, 8, -1, 9, 10, 11, -1]) == 1\n assert candidate(edges = [2, 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\n assert candidate(edges = [1, 2, 0, 4, 3]) == 3\n assert candidate(edges = [1, 3, 4, 2, 1, -1, -1, -1]) == 4\n assert candidate(edges = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 1]) == 6\n assert candidate(edges = [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, 0]) == 100\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0]) == 20\n assert candidate(edges = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == -1\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 11\n assert candidate(edges = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == 16\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4]) == 21\n assert candidate(edges = [3, 3, 4, 2, 3, 5, -1, 6, 7, 5]) == 3\n assert candidate(edges = [4, 4, 4, 4, 0]) == 2\n assert candidate(edges = [5, 4, 3, 2, 1, -1, -1, -1, -1, -1]) == 2\n assert candidate(edges = [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, 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, 0]) == 201\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 20\n assert candidate(edges = [9, 9, 9, 9, 9, 9, 9, 9, 9, 0]) == 2\n assert candidate(edges = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -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(edges = [1, 2, 0, -1, -1, 5, 6, 5]) == 3\n assert candidate(edges = [3, 3, 4, 2, 3, 3, 4, 2, 3, 3]) == 3\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10]) == 10\n assert candidate(edges = [1, 2, 3, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 5\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0]) == 15\n assert candidate(edges = [3, 2, 1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 2\n assert candidate(edges = [5, 5, 5, 5, 5, -1, 5, 5, 5, 5]) == -1\n assert candidate(edges = [1, 2, 3, 4, 0, 6, 7, 8, 9, 5]) == 5\n assert candidate(edges = [4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, -1]) == 1\n assert candidate(edges = [1, 3, 2, 1, 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, 5]) == 2\n assert candidate(edges = [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, 0]) == 30\n assert candidate(edges = [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, 0]) == 50\n assert candidate(edges = [1, 2, 0, 5, 4, 3, -1, -1, 6, 8, 7]) == 3\n assert candidate(edges = [1, 2, 3, 4, 0, 6, 7, 8, 9, 5]) == 5\n assert candidate(edges = [3, 4, 5, 5, 3, -1, 6, 7, 8, 9, 10, -1]) == 1\n assert candidate(edges = [1, 2, 0, 4, 5, -1, 6, 7, 5, 8]) == 3\n assert candidate(edges = [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, 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, 0]) == 2\n assert candidate(edges = [5, 4, 0, 2, 0, 4, 2, 2, 0, 4]) == 3\n assert candidate(edges = [5, 4, 3, 2, 1, 0, 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, -1]) == 2\n assert candidate(edges = [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, 0]) == 40\n assert candidate(edges = [-1, 3, -1, -1, 5, -1, 7, -1, 9, -1, 11, -1, 13, -1, 15, -1, 17, -1, 19, -1, 21, -1, 23, -1, 25, -1]) == -1\n assert candidate(edges = [1, 2, 0, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 3\n assert candidate(edges = [1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1]) == 1\n assert candidate(edges = [4, 3, 0, 5, 3, -1, 2]) == -1\n"}, "metadata": {"canonical_parameter_names": ["edges"], "leetcode_dataset_entry_point": "Solution().longestCycle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestCycle(int[] edges) {", "container": "Solution", "callable": "longestCycle", "parameters": [{"name": "edges", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2363, "task_id": "merge-similar-items", "difficulty": "Easy", "problem_description": "You are given two 2D integer arrays, items1 and items2, representing two sets of items. Each array items has the following properties:\n\nitems[i] = [valuei, weighti] where valuei represents the value and weighti represents the weight of the ith item.\nThe value of each item in items is unique.\n\nReturn a 2D integer array ret where ret[i] = [valuei, weighti], with weighti being the sum of weights of all items with value valuei.\nNote: ret should be returned in ascending order by value.\n \nExample 1:\n\nInput: items1 = [[1,1],[4,5],[3,8]], items2 = [[3,1],[1,5]]\nOutput: [[1,6],[3,9],[4,5]]\nExplanation: \nThe item with value = 1 occurs in items1 with weight = 1 and in items2 with weight = 5, total weight = 1 + 5 = 6.\nThe item with value = 3 occurs in items1 with weight = 8 and in items2 with weight = 1, total weight = 8 + 1 = 9.\nThe item with value = 4 occurs in items1 with weight = 5, total weight = 5. \nTherefore, we return [[1,6],[3,9],[4,5]].\n\nExample 2:\n\nInput: items1 = [[1,1],[3,2],[2,3]], items2 = [[2,1],[3,2],[1,3]]\nOutput: [[1,4],[2,4],[3,4]]\nExplanation: \nThe item with value = 1 occurs in items1 with weight = 1 and in items2 with weight = 3, total weight = 1 + 3 = 4.\nThe item with value = 2 occurs in items1 with weight = 3 and in items2 with weight = 1, total weight = 3 + 1 = 4.\nThe item with value = 3 occurs in items1 with weight = 2 and in items2 with weight = 2, total weight = 2 + 2 = 4.\nTherefore, we return [[1,4],[2,4],[3,4]].\nExample 3:\n\nInput: items1 = [[1,3],[2,2]], items2 = [[7,1],[2,2],[1,4]]\nOutput: [[1,7],[2,4],[7,1]]\nExplanation:\nThe item with value = 1 occurs in items1 with weight = 3 and in items2 with weight = 4, total weight = 3 + 4 = 7. \nThe item with value = 2 occurs in items1 with weight = 2 and in items2 with weight = 2, total weight = 2 + 2 = 4. \nThe item with value = 7 occurs in items2 with weight = 1, total weight = 1.\nTherefore, we return [[1,7],[2,4],[7,1]].\n\n \nConstraints:\n\n1 <= items1.length, items2.length <= 1000\nitems1[i].length == items2[i].length == 2\n1 <= valuei, weighti <= 1000\nEach valuei in items1 is unique.\nEach valuei in items2 is unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(items1 = [[1, 3], [2, 2]],items2 = [[7, 1], [2, 2], [1, 4]]) == [(1, 7), (2, 4), (7, 1)]\n assert candidate(items1 = [[1, 1000]],items2 = [[2, 1000]]) == [(1, 1000), (2, 1000)]\n assert candidate(items1 = [[1, 1], [4, 5], [3, 8]],items2 = [[3, 1], [1, 5]]) == [(1, 6), (3, 9), (4, 5)]\n assert candidate(items1 = [[1000, 1]],items2 = [[999, 1000]]) == [(999, 1000), (1000, 1)]\n assert candidate(items1 = [[100, 100], [200, 200]],items2 = [[150, 150], [250, 250]]) == [(100, 100), (150, 150), (200, 200), (250, 250)]\n assert candidate(items1 = [[10, 10]],items2 = [[20, 20]]) == [(10, 10), (20, 20)]\n assert candidate(items1 = [[5, 5], [10, 10]],items2 = [[5, 5], [15, 15]]) == [(5, 10), (10, 10), (15, 15)]\n assert candidate(items1 = [[5, 5]],items2 = [[5, 5]]) == [(5, 10)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3]],items2 = [[4, 4], [5, 5], [6, 6]]) == [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]\n assert candidate(items1 = [[1, 1], [3, 2], [2, 3]],items2 = [[2, 1], [3, 2], [1, 3]]) == [(1, 4), (2, 4), (3, 4)]\n assert candidate(items1 = [[1, 100], [2, 200], [3, 300]],items2 = [[1, 100], [2, 200], [3, 300]]) == [(1, 200), (2, 400), (3, 600)]\n assert candidate(items1 = [[1, 500], [2, 400], [3, 300], [4, 200], [5, 100]],items2 = [[6, 100], [7, 200], [8, 300], [9, 400], [10, 500]]) == [(1, 500), (2, 400), (3, 300), (4, 200), (5, 100), (6, 100), (7, 200), (8, 300), (9, 400), (10, 500)]\n assert candidate(items1 = [[500, 500], [1, 1], [100, 100]],items2 = [[500, 500], [1, 1], [100, 100], [200, 200], [300, 300], [400, 400]]) == [(1, 2), (100, 200), (200, 200), (300, 300), (400, 400), (500, 1000)]\n assert candidate(items1 = [[1, 999], [2, 998], [3, 997], [4, 996], [5, 995]],items2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 1000), (2, 1000), (3, 1000), (4, 1000), (5, 1000)]\n assert candidate(items1 = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],items2 = [[50, 5], [150, 4], [250, 3], [350, 2], [450, 1]]) == [(50, 5), (100, 1), (150, 4), (200, 2), (250, 3), (300, 3), (350, 2), (400, 4), (450, 1), (500, 5)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4]],items2 = [[2, 4], [3, 6], [5, 8], [6, 10]]) == [(1, 1), (2, 6), (3, 9), (4, 4), (5, 8), (6, 10)]\n assert candidate(items1 = [[999, 1], [998, 2], [997, 3]],items2 = [[996, 4], [995, 5], [994, 6], [993, 7], [992, 8], [991, 9], [990, 10]]) == [(990, 10), (991, 9), (992, 8), (993, 7), (994, 6), (995, 5), (996, 4), (997, 3), (998, 2), (999, 1)]\n assert candidate(items1 = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1]],items2 = [[10, 99], [20, 98], [30, 97], [40, 96], [50, 95]]) == [(10, 100), (20, 99), (30, 98), (40, 97), (50, 96)]\n assert candidate(items1 = [[1, 10], [2, 20], [5, 50], [10, 100]],items2 = [[1, 5], [3, 30], [4, 40], [6, 60], [7, 70]]) == [(1, 15), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60), (7, 70), (10, 100)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4]],items2 = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [(1, 1), (2, 4), (3, 6), (4, 8), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)]\n assert candidate(items1 = [[1, 1], [10, 10], [100, 100]],items2 = [[1, 99], [10, 90], [100, 900], [1000, 1000]]) == [(1, 100), (10, 100), (100, 1000), (1000, 1000)]\n assert candidate(items1 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],items2 = [[3, 30], [4, 40], [5, 50], [6, 60], [7, 70]]) == [(1, 10), (2, 20), (3, 60), (4, 80), (5, 100), (6, 60), (7, 70)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],items2 = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == [(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(items1 = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45]],items2 = [[5, 45], [15, 35], [25, 25], [35, 15], [45, 5]]) == [(5, 50), (15, 50), (25, 50), (35, 50), (45, 50)]\n assert candidate(items1 = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],items2 = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55]]) == [(5, 5), (10, 1), (15, 15), (20, 2), (25, 25), (30, 3), (35, 35), (40, 4), (45, 45), (50, 5), (55, 55)]\n assert candidate(items1 = [[500, 100], [300, 200]],items2 = [[200, 300], [100, 400], [500, 600]]) == [(100, 400), (200, 300), (300, 200), (500, 700)]\n assert candidate(items1 = [[5, 1], [15, 2], [25, 3], [35, 4], [45, 5]],items2 = [[5, 5], [15, 4], [25, 3], [35, 2], [45, 1]]) == [(5, 6), (15, 6), (25, 6), (35, 6), (45, 6)]\n assert candidate(items1 = [[1, 10], [2, 20], [3, 30]],items2 = [[4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90]]) == [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60), (7, 70), (8, 80), (9, 90)]\n assert candidate(items1 = [[100, 100], [200, 200], [300, 300]],items2 = [[150, 150], [250, 250], [350, 350], [450, 450]]) == [(100, 100), (150, 150), (200, 200), (250, 250), (300, 300), (350, 350), (450, 450)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],items2 = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == [(1, 2), (2, 4), (3, 6), (4, 8), (5, 10)]\n assert candidate(items1 = [[1, 1000], [2, 1000], [3, 1000]],items2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 1001), (2, 1002), (3, 1003), (4, 4), (5, 5)]\n assert candidate(items1 = [[1, 1000], [2, 999], [3, 998], [4, 997]],items2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 1001), (2, 1001), (3, 1001), (4, 1001), (5, 5)]\n assert candidate(items1 = [[5, 5], [10, 10], [15, 15], [20, 20]],items2 = [[5, 5], [10, 10], [25, 25], [30, 30]]) == [(5, 10), (10, 20), (15, 15), (20, 20), (25, 25), (30, 30)]\n assert candidate(items1 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],items2 = [[6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60), (7, 70), (8, 80), (9, 90), (10, 100)]\n assert candidate(items1 = [[500, 5000], [1000, 10000]],items2 = [[250, 2500], [750, 7500]]) == [(250, 2500), (500, 5000), (750, 7500), (1000, 10000)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],items2 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == [(1, 11), (2, 22), (3, 33), (4, 44), (5, 55), (6, 66), (7, 77), (8, 88), (9, 99), (10, 110)]\n assert candidate(items1 = [[100, 1], [200, 2], [300, 3], [400, 4]],items2 = [[50, 5], [150, 15], [250, 25], [350, 35], [450, 45]]) == [(50, 5), (100, 1), (150, 15), (200, 2), (250, 25), (300, 3), (350, 35), (400, 4), (450, 45)]\n assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],items2 = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == [(10, 11), (20, 22), (30, 33), (40, 44), (50, 55), (60, 66), (70, 77), (80, 88), (90, 99), (100, 110)]\n assert candidate(items1 = [[10, 15], [20, 25], [30, 35], [40, 45]],items2 = [[10, 5], [20, 15], [50, 55]]) == [(10, 20), (20, 40), (30, 35), (40, 45), (50, 55)]\n assert candidate(items1 = [[1, 10], [2, 20], [3, 30]],items2 = [[4, 40], [5, 50], [6, 60], [7, 70], [8, 80]]) == [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60), (7, 70), (8, 80)]\n assert candidate(items1 = [[5, 10], [15, 20], [25, 30], [35, 40]],items2 = [[10, 5], [15, 15], [25, 25], [40, 45]]) == [(5, 10), (10, 5), (15, 35), (25, 55), (35, 40), (40, 45)]\n assert candidate(items1 = [[1000, 1]],items2 = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992]]) == [(1, 1000), (2, 999), (3, 998), (4, 997), (5, 996), (6, 995), (7, 994), (8, 993), (9, 992), (1000, 1)]\n assert candidate(items1 = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],items2 = [[100, 5], [200, 4], [300, 3], [400, 2], [500, 1]]) == [(100, 6), (200, 6), (300, 6), (400, 6), (500, 6)]\n assert candidate(items1 = [[999, 1], [998, 2], [997, 3], [996, 4], [995, 5]],items2 = [[994, 6], [993, 7], [992, 8], [991, 9], [990, 10]]) == [(990, 10), (991, 9), (992, 8), (993, 7), (994, 6), (995, 5), (996, 4), (997, 3), (998, 2), (999, 1)]\n assert candidate(items1 = [[999, 1], [998, 2], [997, 3]],items2 = [[996, 4], [995, 5], [994, 6], [993, 7], [992, 8]]) == [(992, 8), (993, 7), (994, 6), (995, 5), (996, 4), (997, 3), (998, 2), (999, 1)]\n assert candidate(items1 = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]],items2 = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]]) == [(5, 6), (10, 12), (15, 18), (20, 24), (25, 30)]\n assert candidate(items1 = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],items2 = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]]) == [(10, 6), (20, 6), (30, 6), (40, 6), (50, 6)]\n assert candidate(items1 = [[100, 1000], [200, 2000]],items2 = [[101, 1001], [201, 2001], [100, 1000]]) == [(100, 2000), (101, 1001), (200, 2000), (201, 2001)]\n assert candidate(items1 = [[1, 1000], [2, 999], [3, 998]],items2 = [[2, 1], [3, 2], [4, 3], [5, 4], [6, 5]]) == [(1, 1000), (2, 1000), (3, 1000), (4, 3), (5, 4), (6, 5)]\n assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60]],items2 = [[15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65]]) == [(10, 10), (15, 15), (20, 20), (25, 25), (30, 30), (35, 35), (40, 40), (45, 45), (50, 50), (55, 55), (60, 60), (65, 65)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],items2 = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == [(1, 2), (2, 4), (3, 6), (4, 8), (5, 10)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],items2 = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1]]) == [(1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7)]\n assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],items2 = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]]) == [(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)]\n assert candidate(items1 = [[10, 50], [20, 100], [30, 150], [40, 200]],items2 = [[10, 50], [20, 50], [30, 50], [50, 250]]) == [(10, 100), (20, 150), (30, 200), (40, 200), (50, 250)]\n assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],items2 = [[15, 15], [25, 25], [35, 35], [45, 45], [55, 55]]) == [(10, 10), (15, 15), (20, 20), (25, 25), (30, 30), (35, 35), (40, 40), (45, 45), (50, 50), (55, 55)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],items2 = [[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(items1 = [[2, 200], [4, 400], [6, 600], [8, 800]],items2 = [[1, 100], [3, 300], [5, 500], [7, 700], [9, 900]]) == [(1, 100), (2, 200), (3, 300), (4, 400), (5, 500), (6, 600), (7, 700), (8, 800), (9, 900)]\n assert candidate(items1 = [[1, 1000], [3, 1000], [5, 1000], [7, 1000], [9, 1000]],items2 = [[2, 1000], [4, 1000], [6, 1000], [8, 1000], [10, 1000]]) == [(1, 1000), (2, 1000), (3, 1000), (4, 1000), (5, 1000), (6, 1000), (7, 1000), (8, 1000), (9, 1000), (10, 1000)]\n assert candidate(items1 = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],items2 = [[2, 2], [4, 4], [6, 6], [8, 8], [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(items1 = [[1, 999]],items2 = [[1, 1]]) == [(1, 1000)]\n assert candidate(items1 = [[100, 1000], [200, 2000], [300, 3000]],items2 = [[50, 500], [150, 1500], [250, 2500], [350, 3500]]) == [(50, 500), (100, 1000), (150, 1500), (200, 2000), (250, 2500), (300, 3000), (350, 3500)]\n assert candidate(items1 = [[10, 5], [20, 15], [30, 25]],items2 = [[5, 5], [15, 10], [25, 15], [35, 20]]) == [(5, 5), (10, 5), (15, 10), (20, 15), (25, 15), (30, 25), (35, 20)]\n assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70]],items2 = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75]]) == [(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)]\n assert candidate(items1 = [[100, 100], [200, 200], [300, 300]],items2 = [[100, 50], [200, 150], [300, 250], [400, 350], [500, 450]]) == [(100, 150), (200, 350), (300, 550), (400, 350), (500, 450)]\n assert candidate(items1 = [[1, 100], [2, 200], [3, 300], [4, 400]],items2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [(1, 101), (2, 202), (3, 303), (4, 404), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)]\n assert candidate(items1 = [[1, 1000], [500, 1], [1000, 1000]],items2 = [[1, 1], [500, 1000], [1000, 1]]) == [(1, 1001), (500, 1001), (1000, 1001)]\n assert candidate(items1 = [[10, 50], [20, 100], [30, 150]],items2 = [[5, 25], [10, 75], [40, 200]]) == [(5, 25), (10, 125), (20, 100), (30, 150), (40, 200)]\n assert candidate(items1 = [[10, 10], [20, 20], [30, 30]],items2 = [[11, 11], [21, 21], [31, 31], [10, 9], [20, 18], [30, 27]]) == [(10, 19), (11, 11), (20, 38), (21, 21), (30, 57), (31, 31)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],items2 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == [(1, 11), (2, 22), (3, 33), (4, 44), (5, 55), (6, 66), (7, 77), (8, 88), (9, 99), (10, 110)]\n assert candidate(items1 = [[10, 100], [20, 200], [30, 300], [40, 400]],items2 = [[5, 50], [10, 150], [25, 250], [30, 350]]) == [(5, 50), (10, 250), (20, 200), (25, 250), (30, 650), (40, 400)]\n assert candidate(items1 = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50]],items2 = [[50, 5], [150, 15], [250, 25], [350, 35], [450, 45], [550, 55]]) == [(50, 5), (100, 10), (150, 15), (200, 20), (250, 25), (300, 30), (350, 35), (400, 40), (450, 45), (500, 50), (550, 55)]\n assert candidate(items1 = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900]],items2 = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9]]) == [(100, 101), (200, 202), (300, 303), (400, 404), (500, 505), (600, 606), (700, 707), (800, 808), (900, 909)]\n assert candidate(items1 = [[10, 100], [20, 200], [30, 300]],items2 = [[15, 150], [25, 250], [35, 350], [45, 450], [55, 550]]) == [(10, 100), (15, 150), (20, 200), (25, 250), (30, 300), (35, 350), (45, 450), (55, 550)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],items2 = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [(1, 6), (2, 6), (3, 6), (4, 6), (5, 6)]\n assert candidate(items1 = [[1, 100], [10, 100], [100, 100], [1000, 100]],items2 = [[2, 200], [20, 200], [200, 200], [2000, 200]]) == [(1, 100), (2, 200), (10, 100), (20, 200), (100, 100), (200, 200), (1000, 100), (2000, 200)]\n assert candidate(items1 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],items2 = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25]]) == [(1, 15), (2, 30), (3, 45), (4, 60), (5, 75)]\n assert candidate(items1 = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],items2 = [[2, 2], [4, 4], [6, 6], [8, 8], [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(items1 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],items2 = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25]]) == [(1, 15), (2, 30), (3, 45), (4, 60), (5, 75)]\n assert candidate(items1 = [[1, 1000], [2, 999], [3, 998], [4, 997]],items2 = [[5, 996], [6, 995], [7, 994], [8, 993]]) == [(1, 1000), (2, 999), (3, 998), (4, 997), (5, 996), (6, 995), (7, 994), (8, 993)]\n assert candidate(items1 = [[999, 1], [998, 2], [997, 3]],items2 = [[996, 4], [995, 5], [997, 6]]) == [(995, 5), (996, 4), (997, 9), (998, 2), (999, 1)]\n assert candidate(items1 = [[10, 10], [20, 20], [30, 30]],items2 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == [(10, 20), (20, 40), (30, 60), (40, 40), (50, 50)]\n assert candidate(items1 = [[100, 1], [200, 2], [300, 3], [400, 4]],items2 = [[50, 5], [150, 6], [250, 7], [350, 8], [450, 9]]) == [(50, 5), (100, 1), (150, 6), (200, 2), (250, 7), (300, 3), (350, 8), (400, 4), (450, 9)]\n assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],items2 = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45]]) == [(5, 5), (10, 10), (15, 15), (20, 20), (25, 25), (30, 30), (35, 35), (40, 40), (45, 45), (50, 50)]\n assert candidate(items1 = [[100, 1], [200, 1], [300, 1], [400, 1], [500, 1]],items2 = [[100, 1000], [200, 2000], [300, 3000], [400, 4000], [500, 5000]]) == [(100, 1001), (200, 2001), (300, 3001), (400, 4001), (500, 5001)]\n assert candidate(items1 = [[5, 50], [15, 150], [25, 250], [35, 350], [45, 450]],items2 = [[5, 50], [15, 150], [25, 250], [35, 350], [45, 450]]) == [(5, 100), (15, 300), (25, 500), (35, 700), (45, 900)]\n assert candidate(items1 = [[10, 1], [20, 2], [30, 3]],items2 = [[10, 9], [20, 8], [30, 7]]) == [(10, 10), (20, 10), (30, 10)]\n assert candidate(items1 = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]],items2 = [[5, 5], [10, 4], [15, 3], [20, 2], [25, 1]]) == [(5, 6), (10, 6), (15, 6), (20, 6), (25, 6)]\n assert candidate(items1 = [[500, 50], [1000, 100]],items2 = [[250, 25], [750, 75], [1000, 50]]) == [(250, 25), (500, 50), (750, 75), (1000, 150)]\n assert candidate(items1 = [[1, 1], [10, 10], [100, 100], [1000, 1000]],items2 = [[1, 1000], [10, 100], [100, 10], [1000, 1]]) == [(1, 1001), (10, 110), (100, 110), (1000, 1001)]\n assert candidate(items1 = [[500, 1], [501, 2], [502, 3], [503, 4], [504, 5]],items2 = [[500, 5], [501, 4], [502, 3], [503, 2], [504, 1]]) == [(500, 6), (501, 6), (502, 6), (503, 6), (504, 6)]\n assert candidate(items1 = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500]],items2 = [[5, 50], [15, 150], [25, 250], [35, 350], [45, 450], [55, 550]]) == [(5, 50), (10, 100), (15, 150), (20, 200), (25, 250), (30, 300), (35, 350), (40, 400), (45, 450), (50, 500), (55, 550)]\n assert candidate(items1 = [[1, 100], [3, 300], [5, 500], [7, 700]],items2 = [[2, 200], [4, 400], [6, 600], [8, 800]]) == [(1, 100), (2, 200), (3, 300), (4, 400), (5, 500), (6, 600), (7, 700), (8, 800)]\n assert candidate(items1 = [[999, 1], [998, 2], [997, 3]],items2 = [[999, 4], [998, 5], [997, 6], [996, 7]]) == [(996, 7), (997, 9), (998, 7), (999, 5)]\n assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],items2 = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [(1, 10), (2, 10), (3, 10), (4, 10), (5, 10), (6, 10), (7, 10), (8, 10), (9, 10)]\n assert candidate(items1 = [[10, 5], [20, 10], [30, 15], [40, 20]],items2 = [[10, 15], [20, 20], [50, 25], [60, 30]]) == [(10, 20), (20, 30), (30, 15), (40, 20), (50, 25), (60, 30)]\n assert candidate(items1 = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40]],items2 = [[3, 3], [6, 6], [9, 9], [12, 12], [18, 18], [21, 21], [24, 24], [27, 27], [33, 33], [36, 36], [39, 39], [42, 42]]) == [(3, 3), (5, 5), (6, 6), (9, 9), (10, 10), (12, 12), (15, 15), (18, 18), (20, 20), (21, 21), (24, 24), (25, 25), (27, 27), (30, 30), (33, 33), (35, 35), (36, 36), (39, 39), (40, 40), (42, 42)]\n assert candidate(items1 = [[5, 100], [15, 200], [25, 300], [35, 400]],items2 = [[5, 150], [25, 250], [35, 350], [45, 450]]) == [(5, 250), (15, 200), (25, 550), (35, 750), (45, 450)]\n assert candidate(items1 = [[1, 1000], [500, 500], [1000, 1]],items2 = [[1, 1000], [500, 500], [1000, 1]]) == [(1, 2000), (500, 1000), (1000, 2)]\n assert candidate(items1 = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],items2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [(1, 101), (2, 202), (3, 303), (4, 404), (5, 505), (6, 606), (7, 707), (8, 808), (9, 909), (10, 1010)]\n assert candidate(items1 = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]],items2 = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]) == [(5, 6), (10, 12), (15, 18), (20, 24), (25, 30)]\n"}, "metadata": {"canonical_parameter_names": ["items1", "items2"], "leetcode_dataset_entry_point": "Solution().mergeSimilarItems", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List> mergeSimilarItems(int[][] items1, int[][] items2) {", "container": "Solution", "callable": "mergeSimilarItems", "parameters": [{"name": "items1", "type": "int[][]"}, {"name": "items2", "type": "int[][]"}], "return_type": "List>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2364, "task_id": "count-number-of-bad-pairs", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. A pair of indices (i, j) is a bad pair if i < j and j - i != nums[j] - nums[i].\nReturn the total number of bad pairs in nums.\n \nExample 1:\n\nInput: nums = [4,1,3,3]\nOutput: 5\nExplanation: The pair (0, 1) is a bad pair since 1 - 0 != 1 - 4.\nThe pair (0, 2) is a bad pair since 2 - 0 != 3 - 4, 2 != -1.\nThe pair (0, 3) is a bad pair since 3 - 0 != 3 - 4, 3 != -1.\nThe pair (1, 2) is a bad pair since 2 - 1 != 3 - 1, 1 != 2.\nThe pair (2, 3) is a bad pair since 3 - 2 != 3 - 3, 1 != 0.\nThere are a total of 5 bad pairs, so we return 5.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5]\nOutput: 0\nExplanation: There are no bad pairs.\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]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 15\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 25\n assert candidate(nums = [9, 7, 5, 3, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1]) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(nums = [1, 3, 5, 7, 9]) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 41\n assert candidate(nums = [10, 20, 30, 40, 50]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3]) == 13\n assert candidate(nums = [4, 1, 3, 3]) == 5\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 42\n assert candidate(nums = [5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 21\n assert candidate(nums = [5, 3, 1, 4, 2]) == 10\n assert candidate(nums = [50, 40, 30, 20, 10]) == 10\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 25\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 190\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 25\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 44\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995, 7, 999999994, 8, 999999993, 9, 999999992, 10, 999999991]) == 190\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]) == 189\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\n assert candidate(nums = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106]) == 104\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\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, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 982\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 105\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]) == 465\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == 45\n assert candidate(nums = [10, 20, 30, 20, 10, 20, 30, 20, 10, 20]) == 45\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 186\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 105\n assert candidate(nums = [4, 7, 10, 13, 16, 19, 22, 25]) == 28\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 105\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 9, 8, 10, 11, 13, 12, 14, 15, 17, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 272\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]) == 435\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 190\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 325\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]) == 0\n assert candidate(nums = [3, 8, 3, 8, 3, 8, 3, 8, 3, 8]) == 42\n assert candidate(nums = [45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50, -55, -60, -65, -70, -75, -80, -85, -90, -95, -100]) == 435\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 241\n assert candidate(nums = [1, 2, 3, 4, 3, 4, 5, 6, 5, 6]) == 32\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]) == 300\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]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 185\n assert candidate(nums = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46]) == 44\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]) == 63\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]) == 496\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1]) == 42\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 50\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 99\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20, 21, 23, 22, 24, 25, 27, 26, 28, 29, 31, 30, 32, 33, 35, 34, 36, 37, 39, 38, 40]) == 500\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 45\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 175\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 35\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 245\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 145\n assert candidate(nums = [10, 11, 13, 16, 20, 25, 31, 38, 46, 55, 65, 76, 88, 101, 115, 130, 146, 163, 181, 200, 220, 241, 263, 286, 310, 335, 361, 388, 416, 445]) == 434\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]) == 299\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 44\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 189\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60]) == 153\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 17\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]) == 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]) == 435\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, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40]) == 1035\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600]) == 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]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 335\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 200\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 45\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 9, 8, 10, 11, 13, 12, 14, 15, 17, 16, 18, 19, 20]) == 112\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 2, 1]) == 25\n assert candidate(nums = [1, 5, 14, 30, 55, 91, 140, 204, 285, 385, 506, 650, 819, 1015, 1240, 1496, 1785, 2109, 2470, 2870, 3311, 3795, 4324, 4890, 5495, 6131, 6798, 7490, 8210, 8951]) == 435\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 66\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]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 45\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 65\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 190\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 190\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 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]) == 190\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 45\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517]) == 120\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 119\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 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]) == 426\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 43\n assert candidate(nums = [7, 7, 7, 10, 10, 10, 13, 13, 13, 16, 16, 16]) == 48\n assert candidate(nums = [5, 1, 9, 3, 7, 11, 15, 2, 6, 10, 14, 18, 22, 26, 30]) == 103\n assert candidate(nums = [1, 6, 3, 8, 5, 10, 7, 12, 9, 14, 11, 16, 13, 18, 15]) == 56\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 105\n assert candidate(nums = [1, 2, 5, 10, 17, 26, 37, 50, 65, 82, 101, 122, 145, 170, 197, 226, 257, 290, 325, 362, 401, 442, 485, 530, 577, 626, 677, 730, 785, 842]) == 434\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 = [100, 101, 102, 99, 98, 97, 96, 95, 94, 93]) == 42\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == 102\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 15\n assert candidate(nums = [5, 3, 1, 4, 2, 6, 8, 7, 10, 9]) == 40\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 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]) == 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, 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]) == 1741\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 55\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 190\n assert candidate(nums = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56]) == 54\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]) == 385\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [1, 2, 3, 6, 11, 20, 37, 68, 129, 246, 473, 910]) == 63\n assert candidate(nums = [1, 6, 15, 28, 45, 66, 91, 120, 153, 190, 231, 276, 325, 378, 435]) == 105\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 180\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004, 1000000005, 1000000006, 1000000007, 1000000008, 1000000009]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 105\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 269\n assert candidate(nums = [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, 52, 51, 54, 53, 56, 55]) == 784\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 190\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100]) == 66\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 105\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countBadPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countBadPairs(int[] nums) {", "container": "Solution", "callable": "countBadPairs", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2365, "task_id": "task-scheduler-ii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of positive integers tasks, representing tasks that need to be completed in order, where tasks[i] represents the type of the ith task.\nYou are also given a positive integer space, which represents the minimum number of days that must pass after the completion of a task before another task of the same type can be performed.\nEach day, until all tasks have been completed, you must either:\n\nComplete the next task from tasks, or\nTake a break.\n\nReturn the minimum number of days needed to complete all tasks.\n \nExample 1:\n\nInput: tasks = [1,2,1,2,3,1], space = 3\nOutput: 9\nExplanation:\nOne way to complete all tasks in 9 days is as follows:\nDay 1: Complete the 0th task.\nDay 2: Complete the 1st task.\nDay 3: Take a break.\nDay 4: Take a break.\nDay 5: Complete the 2nd task.\nDay 6: Complete the 3rd task.\nDay 7: Take a break.\nDay 8: Complete the 4th task.\nDay 9: Complete the 5th task.\nIt can be shown that the tasks cannot be completed in less than 9 days.\n\nExample 2:\n\nInput: tasks = [5,8,8,5], space = 2\nOutput: 6\nExplanation:\nOne way to complete all tasks in 6 days is as follows:\nDay 1: Complete the 0th task.\nDay 2: Complete the 1st task.\nDay 3: Take a break.\nDay 4: Take a break.\nDay 5: Complete the 2nd task.\nDay 6: Complete the 3rd task.\nIt can be shown that the tasks cannot be completed in less than 6 days.\n\n \nConstraints:\n\n1 <= tasks.length <= 105\n1 <= tasks[i] <= 109\n1 <= space <= tasks.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 10) == 10\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],space = 1) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5],space = 5) == 5\n assert candidate(tasks = [1, 1, 1, 1, 1],space = 1) == 9\n assert candidate(tasks = [1, 1, 1, 1],space = 2) == 10\n assert candidate(tasks = [1, 1, 1, 1, 1],space = 5) == 25\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],space = 5) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5],space = 1) == 5\n assert candidate(tasks = [1, 1, 1, 1],space = 1) == 7\n assert candidate(tasks = [1, 2, 1, 2, 3, 1],space = 3) == 9\n assert candidate(tasks = [5, 8, 8, 5],space = 2) == 6\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],space = 10) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 1) == 10\n assert candidate(tasks = [1000000000, 999999999, 1000000000, 999999999, 1000000000],space = 3) == 9\n assert candidate(tasks = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],space = 100000000) == 400000005\n assert candidate(tasks = [1, 3, 2, 3, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],space = 4) == 34\n assert candidate(tasks = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],space = 1) == 36\n assert candidate(tasks = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],space = 2) == 12\n assert candidate(tasks = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],space = 100000) == 400005\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 10) == 21\n assert candidate(tasks = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10],space = 3) == 34\n assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],space = 20) == 191\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 100) == 6869\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],space = 1) == 39\n assert candidate(tasks = [1, 2, 2, 1, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9, 10, 9, 10],space = 5) == 41\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 0) == 20\n assert candidate(tasks = [1000000000, 1, 2, 1000000000, 3, 4, 1000000000, 5],space = 2) == 8\n assert candidate(tasks = [5, 1, 2, 5, 1, 2, 5, 1, 2],space = 3) == 11\n assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],space = 3) == 38\n assert candidate(tasks = [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],space = 5) == 29\n assert candidate(tasks = [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],space = 2) == 64\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],space = 1) == 19\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 15) == 20\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 4) == 20\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],space = 9) == 91\n assert candidate(tasks = [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],space = 15) == 30\n assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],space = 1) == 20\n assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],space = 3) == 66\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],space = 10) == 188\n assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],space = 5) == 17\n assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],space = 2) == 10\n assert candidate(tasks = [5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],space = 5) == 25\n assert candidate(tasks = [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],space = 4) == 25\n assert candidate(tasks = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],space = 1) == 20\n assert candidate(tasks = [1000000000, 999999999, 1000000000, 999999999, 1000000000],space = 2) == 7\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 10) == 100\n assert candidate(tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],space = 2) == 20\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 10) == 210\n assert candidate(tasks = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 1000000000],space = 5) == 11\n assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],space = 1) == 20\n assert candidate(tasks = [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],space = 20) == 52\n assert candidate(tasks = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],space = 50) == 107\n assert candidate(tasks = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985],space = 10) == 15\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],space = 5) == 70\n assert candidate(tasks = [1, 2, 3, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1],space = 2) == 20\n assert candidate(tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],space = 3) == 18\n assert candidate(tasks = [1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3],space = 3) == 38\n assert candidate(tasks = [1, 3, 5, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9],space = 5) == 20\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],space = 3) == 77\n assert candidate(tasks = [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],space = 10) == 113\n assert candidate(tasks = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],space = 15) == 53\n assert candidate(tasks = [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],space = 10) == 32\n assert candidate(tasks = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],space = 1) == 12\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 19) == 20\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 5) == 20\n assert candidate(tasks = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],space = 2) == 34\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 5) == 20\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 2) == 20\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 5) == 20\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],space = 3) == 18\n assert candidate(tasks = [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],space = 5) == 140\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],space = 9) == 91\n assert candidate(tasks = [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],space = 3) == 31\n assert candidate(tasks = [1000000000, 999999999, 1000000000, 999999999, 1000000000, 999999999],space = 5) == 14\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],space = 2) == 40\n assert candidate(tasks = [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],space = 3) == 75\n assert candidate(tasks = [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],space = 3) == 35\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 3) == 20\n assert candidate(tasks = [1, 2, 3, 2, 1, 2, 1, 2, 1],space = 2) == 12\n assert candidate(tasks = [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],space = 4) == 105\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],space = 0) == 20\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],space = 2) == 40\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 100) == 111\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],space = 3) == 74\n assert candidate(tasks = [1, 3, 2, 3, 1, 4, 2, 3, 1, 2, 4, 3, 1, 2, 3, 4, 1, 2, 3, 4],space = 4) == 28\n assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],space = 4) == 15\n assert candidate(tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8],space = 2) == 20\n assert candidate(tasks = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],space = 3) == 18\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 1) == 20\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5],space = 4) == 14\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 5) == 265\n assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],space = 0) == 20\n assert candidate(tasks = [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],space = 10) == 30\n assert candidate(tasks = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],space = 1) == 21\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],space = 4) == 18\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3],space = 2) == 36\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 1) == 20\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 20) == 20\n assert candidate(tasks = [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],space = 1) == 30\n assert candidate(tasks = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 15) == 46\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 1) == 20\n assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],space = 4) == 47\n"}, "metadata": {"canonical_parameter_names": ["tasks", "space"], "leetcode_dataset_entry_point": "Solution().taskSchedulerII", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long taskSchedulerII(int[] tasks, int space) {", "container": "Solution", "callable": "taskSchedulerII", "parameters": [{"name": "tasks", "type": "int[]"}, {"name": "space", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2366, "task_id": "minimum-replacements-to-sort-the-array", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums. In one operation you can replace any element of the array with any two elements that sum to it.\n\nFor example, consider nums = [5,6,7]. In one operation, we can replace nums[1] with 2 and 4 and convert nums to [5,2,4,7].\n\nReturn the minimum number of operations to make an array that is sorted in non-decreasing order.\n \nExample 1:\n\nInput: nums = [3,9,3]\nOutput: 2\nExplanation: Here are the steps to sort the array in non-decreasing order:\n- From [3,9,3], replace the 9 with 3 and 6 so the array becomes [3,3,6,3]\n- From [3,3,6,3], replace the 6 with 3 and 3 so the array becomes [3,3,3,3,3]\nThere are 2 steps to sort the array in non-decreasing order. Therefore, we return 2.\n\n\nExample 2:\n\nInput: nums = [1,2,3,4,5]\nOutput: 0\nExplanation: The array is already in non-decreasing order. Therefore, we return 0. \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, 1000000000]) == 0\n assert candidate(nums = [9, 7, 5, 3, 1]) == 20\n assert candidate(nums = [10, 5, 3]) == 5\n assert candidate(nums = [100, 75, 50]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9]) == 0\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1000000000, 1000000000]) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [3, 9, 3]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 0\n assert candidate(nums = [9, 4, 2, 1]) == 12\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [7, 8, 9, 10]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [5, 3, 2, 4, 1]) == 10\n assert candidate(nums = [10, 3, 3, 3, 3]) == 3\n assert candidate(nums = [1, 2, 5, 5, 5]) == 0\n assert candidate(nums = [10, 5, 2]) == 11\n assert candidate(nums = [100, 75, 50, 25]) == 6\n assert candidate(nums = [10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 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, 1]) == 190\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000]) == 1999999998\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100]) == 297\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 56\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99]) == 0\n assert candidate(nums = [999999999, 100000000, 10000000, 1000000, 100000]) == 11106\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, 1]) == 4950\n assert candidate(nums = [99, 90, 81, 72, 63, 54, 45, 36, 27, 18, 9]) == 55\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, 1000000000]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 105\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 1, 1, 1]) == 190\n assert candidate(nums = [8, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 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]) == 0\n assert candidate(nums = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 45\n assert candidate(nums = [1000, 999, 998, 997, 996]) == 10\n assert candidate(nums = [1, 3, 2, 6, 5, 4, 7, 8, 9, 10]) == 4\n assert candidate(nums = [8, 22, 9, 11, 2]) == 41\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 3999999996\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1]) == 36\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 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]) == 81\n assert candidate(nums = [10, 15, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 125\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == 0\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000]) == 57\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 45\n assert candidate(nums = [7, 14, 7, 28, 14, 35, 21, 49, 28, 56]) == 4\n assert candidate(nums = [20, 10, 20, 10, 20, 10, 20]) == 3\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000]) == 26\n assert candidate(nums = [2, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 45\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 20\n assert candidate(nums = [10, 5, 25, 15, 20, 50, 30, 100, 40, 60]) == 5\n assert candidate(nums = [10, 20, 30, 25, 20, 15, 10]) == 16\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 1013\n assert candidate(nums = [5, 20, 15, 10, 25, 30, 5, 40, 35, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 16\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]) == 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]) == 90\n assert candidate(nums = [3, 12, 15, 9, 6, 3]) == 10\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 45\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 45\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [3, 10, 5, 15, 20, 25, 30, 5]) == 15\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(nums = [50, 40, 30, 20, 10, 5, 3, 1]) == 151\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]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [8, 12, 9, 6, 3, 1]) == 33\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 0\n assert candidate(nums = [34, 34, 21, 21, 13, 13, 8, 8, 5, 5, 3, 3, 2, 2]) == 155\n assert candidate(nums = [45, 36, 30, 24, 18, 15, 10, 5]) == 43\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 50]) == 9\n assert candidate(nums = [8, 12, 8, 16, 8]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5]) == 100\n assert candidate(nums = [9, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 52\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 10\n assert candidate(nums = [3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9]) == 44\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 81\n assert candidate(nums = [10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1]) == 120\n assert candidate(nums = [15, 10, 5, 10, 15, 20, 25, 30, 35, 40]) == 3\n assert candidate(nums = [1000000000, 999999999, 999999998]) == 3\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 10]) == 168\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]) == 4950\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 0\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 8, 8, 13, 13, 21, 21, 34, 34, 55, 55]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [50, 40, 30, 20, 10, 5, 1, 1, 1, 1]) == 149\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2036\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == 0\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000]) == 57\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 0\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumReplacement", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumReplacement(int[] nums) {", "container": "Solution", "callable": "minimumReplacement", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2367, "task_id": "number-of-arithmetic-triplets", "difficulty": "Easy", "problem_description": "You are given a 0-indexed, strictly increasing integer array nums and a positive integer diff. A triplet (i, j, k) is an arithmetic triplet if the following conditions are met:\n\ni < j < k,\nnums[j] - nums[i] == diff, and\nnums[k] - nums[j] == diff.\n\nReturn the number of unique arithmetic triplets.\n \nExample 1:\n\nInput: nums = [0,1,4,6,7,10], diff = 3\nOutput: 2\nExplanation:\n(1, 2, 4) is an arithmetic triplet because both 7 - 4 == 3 and 4 - 1 == 3.\n(2, 4, 5) is an arithmetic triplet because both 10 - 7 == 3 and 7 - 4 == 3. \n\nExample 2:\n\nInput: nums = [4,5,6,7,8,9], diff = 2\nOutput: 2\nExplanation:\n(0, 2, 4) is an arithmetic triplet because both 8 - 6 == 2 and 6 - 4 == 2.\n(1, 3, 5) is an arithmetic triplet because both 9 - 7 == 2 and 7 - 5 == 2.\n\n \nConstraints:\n\n3 <= nums.length <= 200\n0 <= nums[i] <= 200\n1 <= diff <= 50\nnums is strictly increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],diff = 2) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30],diff = 5) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],diff = 4) == 6\n assert candidate(nums = [4, 5, 6, 7, 8, 9],diff = 2) == 2\n assert candidate(nums = [1, 3, 5, 7, 9],diff = 2) == 3\n assert candidate(nums = [0, 3, 6, 9, 12],diff = 3) == 3\n assert candidate(nums = [0, 1, 4, 6, 7, 10],diff = 3) == 2\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41],diff = 4) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 1) == 8\n assert candidate(nums = [0, 2, 4, 6, 8, 10],diff = 2) == 4\n assert candidate(nums = [10, 20, 30, 40, 50],diff = 10) == 3\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20],diff = 3) == 5\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],diff = 3) == 8\n assert candidate(nums = [10, 15, 20, 25, 30, 35],diff = 5) == 4\n assert candidate(nums = [5, 10, 15, 20, 25],diff = 5) == 3\n assert candidate(nums = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],diff = 3) == 13\n assert candidate(nums = [10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98, 106, 114, 122],diff = 8) == 13\n assert candidate(nums = [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],diff = 4) == 23\n assert candidate(nums = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109],diff = 6) == 17\n assert candidate(nums = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98, 104, 110, 116, 122],diff = 6) == 19\n assert candidate(nums = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85],diff = 6) == 13\n assert candidate(nums = [3, 12, 21, 30, 39, 48, 57, 66, 75, 84, 93],diff = 9) == 9\n assert candidate(nums = [0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72],diff = 6) == 11\n assert candidate(nums = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],diff = 5) == 9\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160],diff = 8) == 18\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],diff = 5) == 18\n assert candidate(nums = [5, 12, 19, 26, 33, 40, 47, 54, 61, 68],diff = 7) == 8\n assert candidate(nums = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68],diff = 6) == 10\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133],diff = 7) == 17\n assert candidate(nums = [1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 113, 120, 127, 134, 141, 148, 155, 162, 169, 176, 183, 190, 197],diff = 7) == 27\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],diff = 10) == 14\n assert candidate(nums = [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80],diff = 4) == 19\n assert candidate(nums = [1, 5, 9, 14, 19, 24, 29, 34, 39, 44, 49],diff = 4) == 1\n assert candidate(nums = [2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 72],diff = 7) == 9\n assert candidate(nums = [0, 2, 6, 8, 10, 14, 18, 20, 24, 28, 32, 34, 38, 40],diff = 2) == 1\n assert candidate(nums = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191],diff = 10) == 18\n assert candidate(nums = [3, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115],diff = 4) == 0\n assert candidate(nums = [1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99],diff = 7) == 13\n assert candidate(nums = [1, 6, 9, 11, 15, 18, 21, 24, 27, 30],diff = 3) == 4\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198],diff = 11) == 16\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147, 153, 159, 165, 171, 177, 183, 189, 195],diff = 6) == 31\n assert candidate(nums = [2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 72, 79, 86, 93],diff = 7) == 12\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38],diff = 4) == 8\n assert candidate(nums = [3, 11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 91, 99, 107, 115, 123, 131, 139, 147, 155, 163, 171, 179],diff = 8) == 21\n assert candidate(nums = [2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62],diff = 5) == 11\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123],diff = 6) == 19\n assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101, 106, 111],diff = 5) == 21\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40],diff = 3) == 12\n assert candidate(nums = [0, 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],diff = 7) == 0\n assert candidate(nums = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45],diff = 5) == 8\n assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51],diff = 5) == 9\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39],diff = 3) == 11\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],diff = 3) == 8\n assert candidate(nums = [2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97, 102],diff = 5) == 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],diff = 1) == 18\n assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41],diff = 5) == 7\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71],diff = 6) == 10\n assert candidate(nums = [7, 17, 27, 37, 47, 57, 67, 77, 87, 97],diff = 10) == 8\n assert candidate(nums = [2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97],diff = 5) == 18\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98],diff = 4) == 23\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],diff = 10) == 8\n assert candidate(nums = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98],diff = 6) == 15\n assert candidate(nums = [0, 5, 11, 16, 22, 27, 33, 38, 44, 49],diff = 7) == 0\n assert candidate(nums = [0, 3, 7, 12, 15, 19, 24, 27, 31, 36, 39, 43, 48, 51, 55, 60, 63, 67, 72],diff = 3) == 0\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59],diff = 6) == 8\n assert candidate(nums = [5, 12, 19, 26, 33, 40, 47, 54, 61, 68, 75, 82, 89],diff = 7) == 11\n assert candidate(nums = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48],diff = 5) == 8\n assert candidate(nums = [5, 20, 35, 50, 65, 80, 95, 110, 125, 140, 155, 170, 185],diff = 15) == 11\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34],diff = 3) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],diff = 10) == 18\n assert candidate(nums = [3, 12, 21, 30, 39, 48, 57, 66, 75, 84, 93, 102, 111, 120, 129, 138, 147, 156, 165, 174],diff = 9) == 18\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25],diff = 3) == 7\n assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81],diff = 5) == 15\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95],diff = 6) == 14\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99],diff = 6) == 15\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],diff = 2) == 9\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20],diff = 1) == 0\n assert candidate(nums = [1, 5, 8, 11, 14, 17, 20, 23, 26],diff = 3) == 6\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],diff = 1) == 19\n assert candidate(nums = [0, 5, 10, 15, 20, 25, 30, 35, 40],diff = 5) == 7\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43],diff = 4) == 9\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],diff = 10) == 18\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61],diff = 3) == 19\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, 92, 93, 95, 96, 98, 99, 101, 102, 104, 105, 107, 108, 110, 111, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132, 134, 135, 137, 138, 140, 141, 143, 144, 146, 147, 149, 150, 152, 153, 155, 156, 158, 159, 161, 162, 164, 165, 167, 168, 170, 171, 173, 174, 176, 177, 179, 180, 182, 183, 185, 186, 188, 189, 191, 192, 194, 195, 197, 198],diff = 2) == 1\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22],diff = 3) == 6\n assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101, 106, 111, 116, 121, 126, 131, 136, 141, 146, 151, 156, 161, 166, 171, 176, 181, 186, 191, 196, 200],diff = 5) == 38\n assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61],diff = 5) == 11\n assert candidate(nums = [2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 72, 79, 86, 93, 100],diff = 7) == 13\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],diff = 2) == 2\n assert candidate(nums = [3, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],diff = 3) == 8\n assert candidate(nums = [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, 101],diff = 4) == 24\n assert candidate(nums = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97],diff = 6) == 15\n assert candidate(nums = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100],diff = 15) == 0\n assert candidate(nums = [7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67],diff = 5) == 11\n assert candidate(nums = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73, 78, 83, 88, 93, 98],diff = 5) == 18\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 109, 118, 127],diff = 9) == 13\n assert candidate(nums = [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44],diff = 4) == 10\n assert candidate(nums = [2, 10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98, 106, 114],diff = 8) == 13\n assert candidate(nums = [7, 17, 27, 37, 47, 57, 67, 77, 87, 97, 107, 117, 127, 137, 147, 157, 167, 177, 187, 197],diff = 10) == 18\n assert candidate(nums = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53],diff = 5) == 9\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49],diff = 4) == 11\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99],diff = 6) == 15\n assert candidate(nums = [0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],diff = 9) == 10\n assert candidate(nums = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73],diff = 5) == 13\n"}, "metadata": {"canonical_parameter_names": ["nums", "diff"], "leetcode_dataset_entry_point": "Solution().arithmeticTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int arithmeticTriplets(int[] nums, int diff) {", "container": "Solution", "callable": "arithmeticTriplets", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "diff", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2368, "task_id": "reachable-nodes-with-restrictions", "difficulty": "Medium", "problem_description": "There is an undirected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.\nYou 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. You are also given an integer array restricted which represents restricted nodes.\nReturn the maximum number of nodes you can reach from node 0 without visiting a restricted node.\nNote that node 0 will not be a restricted node.\n \nExample 1:\n\n\nInput: n = 7, edges = [[0,1],[1,2],[3,1],[4,0],[0,5],[5,6]], restricted = [4,5]\nOutput: 4\nExplanation: The diagram above shows the tree.\nWe have that [0,1,2,3] are the only nodes that can be reached from node 0 without visiting a restricted node.\n\nExample 2:\n\n\nInput: n = 7, edges = [[0,1],[0,2],[0,5],[0,4],[3,2],[6,5]], restricted = [4,2,1]\nOutput: 3\nExplanation: The diagram above shows the tree.\nWe have that [0,5,6] are the only nodes that can be reached from node 0 without visiting a restricted node.\n\n \nConstraints:\n\n2 <= n <= 105\nedges.length == n - 1\nedges[i].length == 2\n0 <= ai, bi < n\nai != bi\nedges represents a valid tree.\n1 <= restricted.length < n\n1 <= restricted[i] < n\nAll the values of restricted are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [2, 3], [2, 4], [4, 5]],restricted = [1, 4]) == 3\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]],restricted = [5, 7]) == 6\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7]],restricted = [2, 4]) == 5\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [7, 8]) == 8\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [6, 7]],restricted = [3, 5]) == 6\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [3, 1], [4, 0], [0, 5], [5, 6]],restricted = [4, 5]) == 4\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],restricted = [1, 2]) == 1\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],restricted = [1, 5]) == 2\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [0, 5], [0, 4], [3, 2], [6, 5]],restricted = [4, 2, 1]) == 3\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]],restricted = [2, 3]) == 3\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [2, 3], [2, 4]],restricted = [3]) == 4\n assert candidate(n = 30,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]],restricted = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 4\n assert candidate(n = 15,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]],restricted = [1, 5, 9]) == 5\n assert candidate(n = 18,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, 12], [8, 15]],restricted = [1, 6, 13, 16]) == 10\n assert candidate(n = 30,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]],restricted = [12, 14, 16, 18, 20, 22, 24, 26, 28]) == 19\n assert candidate(n = 15,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]],restricted = [2, 5, 8, 10]) == 6\n assert candidate(n = 20,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]],restricted = [3, 7, 12, 16]) == 11\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11]],restricted = [9, 10, 11]) == 9\n assert candidate(n = 15,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]],restricted = [3, 5, 7, 9, 11]) == 8\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [1, 5]) == 3\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],restricted = [2, 4]) == 5\n assert candidate(n = 25,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], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24]],restricted = [3, 5, 8, 12, 15]) == 9\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [1, 4, 6]) == 4\n assert candidate(n = 15,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]],restricted = [8, 9, 10, 11]) == 11\n assert candidate(n = 21,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], [10, 20]],restricted = [2, 6, 10, 15, 18, 20]) == 10\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],restricted = [2, 3, 5, 7, 9]) == 3\n assert candidate(n = 20,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]],restricted = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 4\n assert candidate(n = 25,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]],restricted = [5, 11, 17, 23]) == 19\n assert candidate(n = 20,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]],restricted = [1, 2, 3, 5, 6, 7, 10]) == 1\n assert candidate(n = 15,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], [7, 14]],restricted = [3, 5, 8]) == 8\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [0, 1, 2]) == 1\n assert candidate(n = 20,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], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19]],restricted = [2, 4, 7, 12]) == 6\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [1, 3, 5]) == 3\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],restricted = [1, 3, 5, 7]) == 3\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],restricted = [1, 4, 7]) == 4\n assert candidate(n = 16,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]],restricted = [1, 4, 6, 7, 11]) == 4\n assert candidate(n = 20,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]],restricted = [0, 4, 8, 12, 16]) == 11\n assert candidate(n = 18,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], [8, 16], [9, 17]],restricted = [1, 5, 8, 12, 15]) == 5\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11]],restricted = [1, 2, 3, 4]) == 1\n assert candidate(n = 30,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], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [10, 27], [11, 28], [11, 29]],restricted = [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]) == 1\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]],restricted = [2, 4, 6, 8]) == 5\n assert candidate(n = 25,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], [12, 24]],restricted = [0, 2, 4, 6, 8, 10, 12]) == 6\n assert candidate(n = 18,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]],restricted = [1, 3, 5, 8, 11, 15]) == 5\n assert candidate(n = 25,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]],restricted = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 5\n assert candidate(n = 20,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, 12]],restricted = [0, 2, 5, 8, 15, 18]) == 8\n assert candidate(n = 25,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]],restricted = [1, 5, 9, 13, 17, 21]) == 4\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],restricted = [2, 6, 10]) == 7\n assert candidate(n = 35,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]],restricted = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34]) == 6\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],restricted = [3, 5, 7]) == 6\n assert candidate(n = 30,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]],restricted = [2, 6, 10, 14, 18, 22, 26]) == 12\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11]],restricted = [0, 4, 7, 10]) == 8\n assert candidate(n = 17,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], [8, 16]],restricted = [0, 3, 6, 10, 13, 16]) == 8\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14]],restricted = [2, 4, 6, 8]) == 6\n assert candidate(n = 15,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]],restricted = [3, 5, 7, 10]) == 8\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],restricted = [2, 4, 7]) == 4\n assert candidate(n = 15,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]],restricted = [1, 5, 10]) == 5\n assert candidate(n = 14,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]],restricted = [0, 5, 8, 13]) == 9\n assert candidate(n = 25,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]],restricted = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(n = 15,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], [7, 14]],restricted = [1, 4, 6, 9]) == 5\n assert candidate(n = 25,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]],restricted = [1, 3, 5, 8, 11, 15, 21]) == 5\n assert candidate(n = 20,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], [8, 16], [9, 17], [10, 18], [11, 19]],restricted = [1, 3, 5, 7, 9]) == 5\n assert candidate(n = 30,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], [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]],restricted = [2, 4, 7, 12, 15, 20]) == 6\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],restricted = [1, 4, 6, 9, 11]) == 3\n assert candidate(n = 20,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]],restricted = [1, 3, 5, 8, 11]) == 5\n assert candidate(n = 14,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]],restricted = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 1\n assert candidate(n = 25,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], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24]],restricted = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 6\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]],restricted = [2, 7, 9]) == 5\n assert candidate(n = 20,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]],restricted = [3, 6, 9, 12, 15]) == 7\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [3, 6, 8]) == 6\n assert candidate(n = 20,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]],restricted = [3, 10, 15, 19]) == 13\n assert candidate(n = 18,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]],restricted = [0, 2, 4, 6, 8, 10, 12, 14, 16]) == 5\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "restricted"], "leetcode_dataset_entry_point": "Solution().reachableNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int reachableNodes(int n, int[][] edges, int[] restricted) {", "container": "Solution", "callable": "reachableNodes", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}, {"name": "restricted", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2369, "task_id": "check-if-there-is-a-valid-partition-for-the-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. You have to partition the array into one or more contiguous subarrays.\nWe call a partition of the array valid if each of the obtained subarrays satisfies one of the following conditions:\n\nThe subarray consists of exactly 2, equal elements. For example, the subarray [2,2] is good.\nThe subarray consists of exactly 3, equal elements. For example, the subarray [4,4,4] is good.\nThe subarray consists of exactly 3 consecutive increasing elements, that is, the difference between adjacent elements is 1. For example, the subarray [3,4,5] is good, but the subarray [1,3,5] is not.\n\nReturn true if the array has at least one valid partition. Otherwise, return false.\n \nExample 1:\n\nInput: nums = [4,4,4,5,6]\nOutput: true\nExplanation: The array can be partitioned into the subarrays [4,4] and [4,5,6].\nThis partition is valid, so we return true.\n\nExample 2:\n\nInput: nums = [1,1,1,2]\nOutput: false\nExplanation: There is no valid partition for this array.\n\n \nConstraints:\n\n2 <= nums.length <= 105\n1 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 4, 5]) == False\n assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 4]) == True\n assert candidate(nums = [2, 2, 3, 3, 4, 4]) == True\n assert candidate(nums = [1, 2, 3, 3, 3, 4, 5, 5]) == False\n assert candidate(nums = [1, 1, 2, 3, 4, 4, 5, 6]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 3, 5, 7, 9]) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == True\n assert candidate(nums = [1000000, 1000000]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 2]) == False\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == False\n assert candidate(nums = [4, 4, 4, 5, 6]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3]) == False\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [1, 2, 3, 2, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3]) == True\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [2, 2, 3, 4, 5, 5, 5]) == True\n assert candidate(nums = [2, 2]) == True\n assert candidate(nums = [4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == True\n assert candidate(nums = [1, 1, 1, 2, 3, 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]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10]) == False\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 16, 17, 18, 19, 20, 20, 20, 21, 22, 23]) == False\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]) == True\n assert candidate(nums = [5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14, 15, 15]) == True\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(nums = [3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == True\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]) == 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]) == True\n assert candidate(nums = [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 = [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]) == 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]) == True\n assert candidate(nums = [9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 8, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [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]) == 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, 10, 10, 11, 12, 13, 14, 15, 15, 15]) == True\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]) == True\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]) == True\n assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13]) == True\n assert candidate(nums = [9, 9, 10, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == False\n assert candidate(nums = [3, 3, 3, 4, 5, 6, 7, 7, 8, 9, 10, 10, 10]) == True\n assert candidate(nums = [10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 15, 16, 17, 18, 19, 19, 20]) == False\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]) == True\n assert candidate(nums = [5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 13]) == True\n assert candidate(nums = [5, 6, 7, 8, 8, 9, 10, 10, 11, 11]) == False\n assert candidate(nums = [10, 10, 10, 11, 12, 12, 12, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 17, 17]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 16, 17, 18, 19, 20, 20, 20, 21, 22, 23]) == False\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]) == True\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]) == True\n assert candidate(nums = [1, 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]) == True\n assert candidate(nums = [1, 1, 1, 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]) == 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, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 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 = [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, 24, 25, 26]) == False\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 3, 2, 2, 3, 4, 5, 6, 6, 6]) == True\n assert candidate(nums = [1, 1, 2, 3, 4, 4, 4, 5, 6, 7, 8, 9, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(nums = [5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == True\n assert candidate(nums = [5, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == False\n assert candidate(nums = [1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 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]) == False\n assert candidate(nums = [4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10]) == True\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 10, 11, 12, 12, 12]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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]) == False\n assert candidate(nums = [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, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 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, 21, 22, 22]) == False\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == True\n assert candidate(nums = [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]) == True\n assert candidate(nums = [3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20]) == True\n assert candidate(nums = [1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 16, 16, 16]) == True\n assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == True\n assert candidate(nums = [3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 4, 5, 6, 6, 7, 8, 8, 8]) == 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]) == True\n assert candidate(nums = [1, 1, 2, 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 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 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, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == True\n assert candidate(nums = [1, 1, 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 11, 12]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 13, 13, 14, 14]) == True\n assert candidate(nums = [1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 19]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8]) == 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, 21, 22, 23, 24, 25, 25, 25, 26, 27, 28, 29, 30, 30, 30]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 14, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23]) == 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, 12, 12, 13, 13]) == False\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == True\n assert candidate(nums = [1, 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]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == False\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\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]) == True\n assert candidate(nums = [1, 2, 3, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 16, 17, 18, 19, 20, 20, 20, 21, 22, 23, 24, 25]) == False\n assert candidate(nums = [9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10]) == False\n assert candidate(nums = [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]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == True\n assert candidate(nums = [2, 2, 3, 4, 5, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15]) == True\n assert candidate(nums = [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]) == True\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == False\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]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9]) == False\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [2, 2, 3, 3, 4, 5, 5, 6, 6, 7]) == False\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]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().validPartition", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean validPartition(int[] nums) {", "container": "Solution", "callable": "validPartition", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2370, "task_id": "longest-ideal-subsequence", "difficulty": "Medium", "problem_description": "You are given a string s consisting of lowercase letters and an integer k. We call a string t ideal if the following conditions are satisfied:\n\nt is a subsequence of the string s.\nThe absolute difference in the alphabet order of every two adjacent letters in t is less than or equal to k.\n\nReturn the length of the longest ideal string.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\nNote that the alphabet order is not cyclic. For example, the absolute difference in the alphabet order of 'a' and 'z' is 25, not 1.\n \nExample 1:\n\nInput: s = \"acfgbd\", k = 2\nOutput: 4\nExplanation: The longest ideal string is \"acbd\". The length of this string is 4, so 4 is returned.\nNote that \"acfgbd\" is not ideal because 'c' and 'f' have a difference of 3 in alphabet order.\nExample 2:\n\nInput: s = \"abcd\", k = 3\nOutput: 4\nExplanation: The longest ideal string is \"abcd\". The length of this string is 4, so 4 is returned.\n\n \nConstraints:\n\n1 <= s.length <= 105\n0 <= k <= 25\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 25) == 20\n assert candidate(s = \"a\",k = 0) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 0) == 1\n assert candidate(s = \"abcd\",k = 3) == 4\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 1) == 26\n assert candidate(s = \"a\",k = 5) == 1\n assert candidate(s = \"abacabadabacaba\",k = 1) == 12\n assert candidate(s = \"pqrspqrstuv\",k = 2) == 10\n assert candidate(s = \"abcabcabcabc\",k = 2) == 12\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",k = 25) == 27\n assert candidate(s = \"acfgbd\",k = 2) == 4\n assert candidate(s = \"aaaabbbbcccc\",k = 25) == 12\n assert candidate(s = \"zzzzzzzzz\",k = 25) == 9\n assert candidate(s = \"leetcode\",k = 2) == 5\n assert candidate(s = \"abcabcabc\",k = 2) == 9\n assert candidate(s = \"zyzyzyzyzyzyzyzyzyzy\",k = 1) == 20\n assert candidate(s = \"triplebyte\",k = 2) == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\",k = 1) == 52\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabb\",k = 1) == 32\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggg\",k = 2) == 28\n assert candidate(s = \"aabcdefghijklmnopqrstuvwxyz\",k = 24) == 27\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",k = 2) == 16\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == 26\n assert candidate(s = \"abacabadabacaba\",k = 0) == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 0) == 50\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 25) == 26\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 5) == 26\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhh\",k = 3) == 32\n assert candidate(s = \"aabcdefghijklmnopqrstuvwxyz\",k = 1) == 27\n assert candidate(s = \"abababababababababababababababab\",k = 0) == 16\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 3) == 32\n assert candidate(s = \"ababababababababababababababababab\",k = 0) == 17\n assert candidate(s = \"abcdxyzabcdxyzabcdxyz\",k = 4) == 12\n assert candidate(s = \"z\",k = 25) == 1\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 0) == 1\n assert candidate(s = \"mississippiissipi\",k = 4) == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 0) == 60\n assert candidate(s = \"thisisaverylongstringthatneedstobechecked\",k = 3) == 17\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",k = 25) == 51\n assert candidate(s = \"zzzzyyyyxxxwwvvuttsrrqqppoonnmmllkkjjiihhggffeeddccbbbaaa\",k = 3) == 57\n assert candidate(s = \"qpwoeirutyalskdjfhgzmxncbv\",k = 4) == 11\n assert candidate(s = \"aaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaab\",k = 0) == 40\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\",k = 3) == 28\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 2) == 29\n assert candidate(s = \"zzzyyyxxxwwwwvvvuuutttsssrrrqqqpPPPoonnmmlkkjjiihhhgggfffeeeddccbbbaaa\",k = 3) == 67\n assert candidate(s = \"abcdabcdabcdabcdabcdabcd\",k = 3) == 24\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\",k = 5) == 21\n assert candidate(s = \"abacabacabacaba\",k = 1) == 12\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 25) == 52\n assert candidate(s = \"zzzyyyxxxwwwwvvvuutttsssrqqppoonnmlkkjjiihhggffeeddccbbaaa\",k = 2) == 58\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 1) == 52\n assert candidate(s = \"zabcdefghijklmnopqrstuvwxyz\",k = 24) == 26\n assert candidate(s = \"bdfhjlnprtvxz\",k = 2) == 13\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrs\",k = 2) == 16\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 0) == 120\n assert candidate(s = \"qwertypoiuytrewqazxcvbnmnbvcxz\",k = 5) == 15\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",k = 5) == 22\n assert candidate(s = \"qpqprqqpqrqpqrqpqrqpq\",k = 1) == 20\n assert candidate(s = \"abcdxyzabcdxyzabcdxyz\",k = 3) == 12\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijkl\",k = 10) == 14\n assert candidate(s = \"mmppqqrrssttuuvvwwxxyyzz\",k = 1) == 22\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 0) == 20\n assert candidate(s = \"abababababababababababababababab\",k = 1) == 32\n assert candidate(s = \"abcdefgabcdefgabcdefg\",k = 5) == 19\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 24) == 26\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 0) == 2\n assert candidate(s = \"abacabadabacabadabacabad\",k = 1) == 18\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 2) == 26\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 3) == 30\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\",k = 12) == 52\n assert candidate(s = \"aeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",k = 0) == 63\n assert candidate(s = \"qpwoeirutyalskdjfhgxcvbnm\",k = 5) == 11\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 2) == 97\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 10) == 37\n assert candidate(s = \"abcdefghijkalmnopqrstuvwxyz\",k = 2) == 26\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == 84\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 2) == 52\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\",k = 1) == 128\n assert candidate(s = \"abcdabcdabcdabcd\",k = 3) == 16\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",k = 5) == 17\n assert candidate(s = \"a\",k = 25) == 1\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",k = 5) == 14\n assert candidate(s = \"mjmnjmmnjmnmjmmnj\",k = 0) == 8\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 24) == 26\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 24) == 52\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().longestIdealString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestIdealString(String s, int k) {", "container": "Solution", "callable": "longestIdealString", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2373, "task_id": "largest-local-values-in-a-matrix", "difficulty": "Easy", "problem_description": "You are given an n x n integer matrix grid.\nGenerate an integer matrix maxLocal of size (n - 2) x (n - 2) such that:\n\nmaxLocal[i][j] is equal to the largest value of the 3 x 3 matrix in grid centered around row i + 1 and column j + 1.\n\nIn other words, we want to find the largest value in every contiguous 3 x 3 matrix in grid.\nReturn the generated matrix.\n \nExample 1:\n\n\nInput: grid = [[9,9,8,1],[5,6,2,6],[8,2,6,4],[6,2,2,2]]\nOutput: [[9,9],[8,6]]\nExplanation: The diagram above shows the original matrix and the generated matrix.\nNotice that each value in the generated matrix corresponds to the largest value of a contiguous 3 x 3 matrix in grid.\nExample 2:\n\n\nInput: grid = [[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]]\nOutput: [[2,2,2],[2,2,2],[2,2,2]]\nExplanation: Notice that the 2 is contained within every contiguous 3 x 3 matrix in grid.\n\n \nConstraints:\n\nn == grid.length == grid[i].length\n3 <= n <= 100\n1 <= grid[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 5, 9, 1, 5, 9], [2, 6, 0, 2, 6, 0], [3, 7, 1, 3, 7, 1], [4, 8, 2, 4, 8, 2], [5, 9, 3, 5, 9, 3], [6, 0, 4, 6, 0, 4]]) == [[9, 9, 9, 9], [8, 8, 8, 8], [9, 9, 9, 9], [9, 9, 9, 9]]\n assert candidate(grid = [[5, 8, 4, 3], [3, 5, 9, 5], [7, 6, 7, 9], [4, 8, 5, 3]]) == [[9, 9], [9, 9]]\n assert candidate(grid = [[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]]) == [[2, 2, 2], [2, 2, 2], [2, 2, 2]]\n assert candidate(grid = [[3, 0, 0, 5], [0, 7, 3, 2], [0, 2, 9, 7], [5, 1, 0, 0]]) == [[9, 9], [9, 9]]\n assert candidate(grid = [[100, 100, 100], [100, 100, 100], [100, 100, 100]]) == [[100]]\n assert candidate(grid = [[3, 0, 0, 5], [0, 5, 0, 0], [0, 0, 0, 5], [5, 0, 5, 0]]) == [[5, 5], [5, 5]]\n assert candidate(grid = [[9, 9, 8, 1], [5, 6, 2, 6], [8, 2, 6, 4], [6, 2, 2, 2]]) == [[9, 9], [8, 6]]\n assert candidate(grid = [[1, 9, 2, 8, 3, 7, 4, 6, 5, 10], [11, 19, 12, 18, 13, 17, 14, 16, 15, 20], [21, 29, 22, 28, 23, 27, 24, 26, 25, 30], [31, 39, 32, 38, 33, 37, 34, 36, 35, 40], [41, 49, 42, 48, 43, 47, 44, 46, 45, 50], [51, 59, 52, 58, 53, 57, 54, 56, 55, 60], [61, 69, 62, 68, 63, 67, 64, 66, 65, 70], [71, 79, 72, 78, 73, 77, 74, 76, 75, 80], [81, 89, 82, 88, 83, 87, 84, 86, 85, 90], [91, 99, 92, 98, 93, 97, 94, 96, 95, 100]]) == [[29, 29, 28, 28, 27, 27, 26, 30], [39, 39, 38, 38, 37, 37, 36, 40], [49, 49, 48, 48, 47, 47, 46, 50], [59, 59, 58, 58, 57, 57, 56, 60], [69, 69, 68, 68, 67, 67, 66, 70], [79, 79, 78, 78, 77, 77, 76, 80], [89, 89, 88, 88, 87, 87, 86, 90], [99, 99, 98, 98, 97, 97, 96, 100]]\n assert candidate(grid = [[9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9]]) == [[9, 9], [9, 9]]\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]]) == [[100, 99, 98], [95, 94, 93], [90, 89, 88]]\n assert candidate(grid = [[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]]) == [[75, 80, 85, 90], [105, 110, 115, 120], [135, 140, 145, 150], [165, 170, 175, 180]]\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]]) == [[15, 16, 17, 18], [21, 22, 23, 24], [27, 28, 29, 30], [33, 34, 35, 36]]\n assert candidate(grid = [[90, 80, 70, 60, 50, 40], [30, 20, 10, 9, 8, 7], [6, 5, 4, 3, 2, 1], [100, 110, 120, 130, 140, 150], [160, 170, 180, 190, 200, 210], [220, 230, 240, 250, 260, 270]]) == [[90, 80, 70, 60], [120, 130, 140, 150], [180, 190, 200, 210], [240, 250, 260, 270]]\n assert candidate(grid = [[100, 1, 100, 1, 100, 1], [1, 100, 1, 100, 1, 100], [100, 1, 100, 1, 100, 1], [1, 100, 1, 100, 1, 100], [100, 1, 100, 1, 100, 1], [1, 100, 1, 100, 1, 100]]) == [[100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100]]\n assert candidate(grid = [[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]]) == [[50, 60, 70], [60, 70, 80], [70, 80, 90]]\n assert candidate(grid = [[50, 20, 30, 10, 60, 70, 80], [40, 10, 50, 30, 20, 60, 90], [60, 50, 40, 30, 20, 10, 70], [30, 40, 50, 60, 70, 80, 90], [20, 30, 40, 50, 60, 70, 80], [10, 20, 30, 40, 50, 60, 70], [5, 15, 25, 35, 45, 55, 65]]) == [[60, 50, 60, 70, 90], [60, 60, 70, 80, 90], [60, 60, 70, 80, 90], [50, 60, 70, 80, 90], [40, 50, 60, 70, 80]]\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, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [3, 6, 9, 12, 15, 12, 9, 6, 3], [4, 8, 12, 16, 20, 16, 12, 8, 4], [5, 10, 15, 20, 25, 20, 15, 10, 5], [6, 12, 18, 24, 30, 24, 18, 12, 6], [7, 14, 21, 28, 35, 28, 21, 14, 7]]) == [[9, 8, 9, 9, 9, 8, 9], [9, 8, 10, 10, 10, 8, 6], [9, 12, 15, 15, 15, 12, 9], [12, 16, 20, 20, 20, 16, 12], [15, 20, 25, 25, 25, 20, 15], [18, 24, 30, 30, 30, 24, 18], [21, 28, 35, 35, 35, 28, 21]]\n assert candidate(grid = [[70, 23, 16, 35, 40, 97, 89], [22, 28, 48, 39, 78, 49, 21], [72, 84, 43, 26, 14, 62, 54], [92, 25, 15, 61, 32, 86, 19], [11, 98, 85, 29, 53, 77, 94], [59, 34, 82, 76, 83, 36, 93], [50, 60, 51, 44, 46, 63, 79]]) == [[84, 84, 78, 97, 97], [92, 84, 78, 86, 86], [98, 98, 85, 86, 94], [98, 98, 85, 86, 94], [98, 98, 85, 83, 94]]\n assert candidate(grid = [[100, 1, 1, 1, 1, 1, 100], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 100]]) == [[100, 1, 1, 1, 100], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [100, 1, 1, 1, 100]]\n assert candidate(grid = [[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]]) == [[66, 67, 68, 69, 70], [73, 74, 75, 76, 77], [80, 81, 82, 83, 84], [87, 88, 89, 90, 91], [94, 95, 96, 97, 98]]\n assert candidate(grid = [[100, 99, 98, 97], [96, 95, 94, 93], [92, 91, 90, 89], [88, 87, 86, 85]]) == [[100, 99], [96, 95]]\n assert candidate(grid = [[50, 50, 50, 50, 50, 50], [50, 1, 2, 3, 4, 50], [50, 6, 7, 8, 9, 50], [50, 10, 11, 12, 13, 50], [50, 14, 15, 16, 17, 50], [50, 50, 50, 50, 50, 50]]) == [[50, 50, 50, 50], [50, 12, 13, 50], [50, 16, 17, 50], [50, 50, 50, 50]]\n assert candidate(grid = [[1, 10, 15, 20, 25, 30], [5, 6, 7, 8, 9, 10], [15, 20, 25, 30, 35, 40], [25, 30, 35, 40, 45, 50], [35, 40, 45, 50, 55, 60], [45, 50, 55, 60, 65, 70]]) == [[25, 30, 35, 40], [35, 40, 45, 50], [45, 50, 55, 60], [55, 60, 65, 70]]\n assert candidate(grid = [[100, 1, 2, 3, 4], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]]) == [[100, 5, 6], [5, 6, 7], [6, 7, 8]]\n assert candidate(grid = [[99, 1, 2, 3, 4, 5, 6, 7, 8], [8, 99, 1, 2, 3, 4, 5, 6, 7], [7, 8, 99, 1, 2, 3, 4, 5, 6], [6, 7, 8, 99, 1, 2, 3, 4, 5], [5, 6, 7, 8, 99, 1, 2, 3, 4], [4, 5, 6, 7, 8, 99, 1, 2, 3], [3, 4, 5, 6, 7, 8, 99, 1, 2], [2, 3, 4, 5, 6, 7, 8, 99, 1], [1, 2, 3, 4, 5, 6, 7, 8, 99]]) == [[99, 99, 99, 5, 6, 7, 8], [99, 99, 99, 99, 5, 6, 7], [99, 99, 99, 99, 99, 5, 6], [8, 99, 99, 99, 99, 99, 5], [7, 8, 99, 99, 99, 99, 99], [6, 7, 8, 99, 99, 99, 99], [5, 6, 7, 8, 99, 99, 99]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7], [13, 14, 15, 16, 17, 18], [18, 17, 16, 15, 14, 13]]) == [[9, 10, 11, 12], [12, 11, 11, 12], [15, 16, 17, 18], [18, 17, 17, 18]]\n assert candidate(grid = [[1, 3, 2, 1, 5], [4, 1, 5, 3, 2], [2, 5, 3, 4, 1], [3, 2, 4, 5, 3], [5, 4, 1, 2, 3]]) == [[5, 5, 5], [5, 5, 5], [5, 5, 5]]\n assert candidate(grid = [[90, 91, 92, 93, 94, 95], [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]]) == [[92, 93, 94, 95], [89, 88, 87, 86], [83, 82, 81, 80], [77, 76, 75, 74]]\n assert candidate(grid = [[9, 1, 3, 5, 7, 9], [5, 3, 1, 7, 9, 5], [3, 5, 7, 1, 3, 7], [7, 9, 5, 3, 1, 9], [9, 7, 3, 5, 7, 1], [1, 9, 7, 5, 3, 5]]) == [[9, 7, 9, 9], [9, 9, 9, 9], [9, 9, 7, 9], [9, 9, 7, 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, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [[9, 8, 9, 9, 9, 8, 9], [9, 8, 10, 10, 10, 8, 6], [6, 8, 10, 10, 10, 8, 9], [9, 8, 10, 10, 10, 8, 9], [9, 8, 9, 9, 9, 8, 9], [9, 8, 10, 10, 10, 8, 6], [6, 8, 10, 10, 10, 8, 9]]\n assert candidate(grid = [[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30], [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50], [70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70], [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100], [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [[32, 33, 34, 35, 36, 37, 38, 39, 40], [40, 39, 38, 37, 36, 37, 38, 39, 40], [52, 53, 54, 55, 56, 57, 58, 59, 60], [60, 59, 58, 57, 56, 57, 58, 59, 60], [72, 73, 74, 75, 76, 77, 78, 79, 80], [80, 79, 78, 77, 76, 77, 78, 79, 80], [92, 93, 94, 95, 96, 97, 98, 99, 100], [100, 99, 98, 97, 96, 97, 98, 99, 100], [100, 99, 98, 97, 96, 97, 98, 99, 100]]\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]]) == [[17, 18, 19, 20, 21], [24, 25, 26, 27, 28], [31, 32, 33, 34, 35], [38, 39, 40, 41, 42], [45, 46, 47, 48, 49]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3]]) == [[6, 5, 6, 7], [7, 6, 6, 7], [7, 6, 7, 8], [8, 7, 7, 8]]\n assert candidate(grid = [[5, 3, 1, 2, 7, 8, 4, 9, 6], [4, 5, 6, 7, 8, 9, 1, 2, 3], [7, 8, 9, 1, 2, 3, 4, 5, 6], [2, 1, 3, 4, 5, 6, 7, 8, 9], [8, 9, 1, 2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8, 9, 1, 2], [6, 7, 8, 9, 1, 2, 3, 4, 5], [9, 1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [[9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 6, 7, 8, 9], [9, 9, 7, 8, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 7, 8, 9]]\n assert candidate(grid = [[1, 100, 2, 99, 3, 98], [100, 99, 2, 1, 3, 98], [99, 98, 1, 2, 100, 3], [3, 2, 100, 1, 99, 2], [2, 1, 99, 3, 100, 98], [100, 98, 3, 99, 2, 1]]) == [[100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100]]\n assert candidate(grid = [[48, 12, 24, 87, 55, 96], [17, 94, 31, 76, 67, 33], [58, 28, 72, 57, 86, 52], [27, 74, 95, 65, 89, 60], [41, 62, 84, 43, 88, 9], [13, 77, 42, 82, 36, 70]]) == [[94, 94, 87, 96], [95, 95, 95, 89], [95, 95, 95, 89], [95, 95, 95, 89]]\n assert candidate(grid = [[1, 1, 1, 100, 1, 1, 1, 1, 1], [1, 1, 1, 1, 100, 1, 1, 1, 1], [1, 1, 1, 1, 1, 100, 1, 1, 1], [1, 1, 1, 1, 1, 1, 100, 1, 1], [1, 1, 1, 1, 1, 1, 1, 100, 1], [1, 1, 1, 1, 1, 1, 1, 1, 100], [1, 1, 1, 1, 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, 100, 100, 100, 100, 1], [1, 1, 100, 100, 100, 100, 100], [1, 1, 1, 100, 100, 100, 100], [1, 1, 1, 1, 100, 100, 100], [1, 1, 1, 1, 1, 100, 100], [1, 1, 1, 1, 1, 1, 100], [1, 1, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[83, 11, 52, 93, 48, 37, 29, 71, 88], [6, 13, 39, 96, 54, 15, 79, 38, 40], [87, 75, 99, 64, 49, 91, 27, 67, 56], [95, 70, 43, 25, 12, 81, 41, 69, 82], [9, 58, 66, 20, 33, 47, 80, 90, 65], [31, 55, 86, 46, 68, 74, 3, 16, 57], [4, 51, 73, 60, 85, 100, 5, 78, 18], [26, 32, 59, 45, 97, 7, 62, 53, 24], [63, 14, 98, 44, 35, 72, 8, 42, 17]]) == [[99, 99, 99, 96, 91, 91, 88], [99, 99, 99, 96, 91, 91, 82], [99, 99, 99, 91, 91, 91, 90], [95, 86, 86, 81, 81, 90, 90], [86, 86, 86, 100, 100, 100, 90], [86, 86, 97, 100, 100, 100, 78], [98, 98, 98, 100, 100, 100, 78]]\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 7, 5, 3, 1, 2, 4, 6, 8], [8, 6, 4, 2, 1, 3, 5, 7, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 7, 5, 3, 1, 2, 4, 6, 8], [8, 6, 4, 2, 1, 3, 5, 7, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [[9, 8, 7, 6, 7, 8, 9], [9, 7, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 7, 9], [9, 8, 7, 6, 7, 8, 9], [9, 8, 7, 6, 7, 8, 9], [9, 7, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 7, 9]]\n assert candidate(grid = [[10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 9, 9, 9, 9, 9, 9, 9, 10], [10, 9, 8, 8, 8, 8, 8, 9, 10], [10, 9, 8, 7, 7, 7, 8, 9, 10], [10, 9, 8, 7, 6, 7, 8, 9, 10], [10, 9, 8, 7, 7, 7, 8, 9, 10], [10, 9, 8, 8, 8, 8, 8, 9, 10], [10, 9, 9, 9, 9, 9, 9, 9, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10]]) == [[10, 10, 10, 10, 10, 10, 10], [10, 9, 9, 9, 9, 9, 10], [10, 9, 8, 8, 8, 9, 10], [10, 9, 8, 7, 8, 9, 10], [10, 9, 8, 8, 8, 9, 10], [10, 9, 9, 9, 9, 9, 10], [10, 10, 10, 10, 10, 10, 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, 9, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 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, 9, 9, 1, 1], [1, 1, 9, 9, 9, 1, 1], [1, 1, 9, 9, 9, 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(grid = [[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, 9, 7, 5, 3], [5, 1, 9, 7, 3, 6, 2, 8, 4], [2, 8, 6, 4, 7, 1, 3, 9, 5], [4, 9, 1, 3, 2, 8, 5, 7, 6], [3, 5, 2, 8, 4, 7, 6, 9, 1], [6, 7, 8, 9, 1, 2, 3, 4, 5]]) == [[9, 8, 9, 9, 9, 8, 9], [9, 8, 9, 9, 9, 9, 8], [9, 9, 9, 9, 9, 9, 8], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 8, 8, 9, 9], [9, 9, 8, 8, 8, 9, 9], [9, 9, 9, 9, 8, 9, 9]]\n assert candidate(grid = [[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]]) == [[48, 49, 50, 51, 52], [55, 56, 57, 58, 59], [62, 63, 64, 65, 66], [69, 70, 71, 72, 73], [76, 77, 78, 79, 80]]\n assert candidate(grid = [[1, 15, 3, 17, 7], [16, 18, 5, 14, 6], [12, 19, 9, 13, 11], [4, 8, 20, 1, 10], [15, 2, 16, 3, 18]]) == [[19, 19, 17], [20, 20, 20], [20, 20, 20]]\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, 75, 74, 73, 72, 71], [70, 69, 68, 67, 66, 65]]) == [[100, 99, 98, 97], [94, 93, 92, 91], [88, 87, 86, 85], [82, 81, 80, 79]]\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], [2, 4, 6, 8, 10, 12, 14, 16, 18], [18, 16, 14, 12, 10, 8, 6, 4, 2], [17, 15, 13, 11, 9, 7, 5, 3, 1], [9, 7, 5, 3, 1, 2, 4, 6, 8], [8, 6, 4, 2, 1, 3, 5, 7, 9], [7, 8, 9, 1, 2, 3, 4, 5, 6]]) == [[9, 8, 9, 11, 13, 15, 17], [9, 8, 10, 12, 14, 16, 18], [18, 16, 14, 12, 14, 16, 18], [18, 16, 14, 12, 14, 16, 18], [18, 16, 14, 12, 10, 8, 8], [17, 15, 13, 11, 9, 7, 9], [9, 9, 9, 3, 5, 7, 9]]\n assert candidate(grid = [[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]]\n assert candidate(grid = [[30, 1, 2, 3, 4, 5, 6], [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], [6, 7, 8, 9, 10, 11, 12]]) == [[30, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12]]\n assert candidate(grid = [[10, 9, 8, 7, 6], [7, 6, 5, 4, 3], [8, 7, 6, 5, 4], [9, 8, 7, 6, 5], [10, 9, 8, 7, 6]]) == [[10, 9, 8], [9, 8, 7], [10, 9, 8]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 3, 2, 1, 1], [1, 3, 5, 3, 1, 1], [1, 2, 3, 2, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == [[5, 5, 5, 3], [5, 5, 5, 3], [5, 5, 5, 3], [3, 3, 3, 2]]\n assert candidate(grid = [[90, 80, 70, 60, 50, 40, 30], [80, 70, 60, 50, 40, 30, 20], [70, 60, 50, 40, 30, 20, 10], [60, 50, 40, 30, 20, 10, 5], [50, 40, 30, 20, 10, 5, 1], [40, 30, 20, 10, 5, 1, 0], [30, 20, 10, 5, 1, 0, 1]]) == [[90, 80, 70, 60, 50], [80, 70, 60, 50, 40], [70, 60, 50, 40, 30], [60, 50, 40, 30, 20], [50, 40, 30, 20, 10]]\n assert candidate(grid = [[81, 82, 83, 84, 85, 86, 87], [88, 89, 90, 91, 92, 93, 94], [95, 96, 97, 98, 99, 100, 95], [94, 93, 92, 91, 90, 89, 88], [87, 86, 85, 84, 83, 82, 81], [82, 83, 84, 85, 86, 87, 88], [89, 90, 91, 92, 93, 94, 95]]) == [[97, 98, 99, 100, 100], [97, 98, 99, 100, 100], [97, 98, 99, 100, 100], [94, 93, 92, 91, 90], [91, 92, 93, 94, 95]]\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3], [3, 1, 2, 3, 4, 5, 3], [3, 4, 5, 6, 7, 8, 3], [3, 5, 6, 7, 8, 9, 3], [3, 6, 7, 8, 9, 8, 3], [3, 5, 6, 7, 8, 7, 3], [3, 3, 3, 3, 3, 3, 3]]) == [[5, 6, 7, 8, 8], [6, 7, 8, 9, 9], [7, 8, 9, 9, 9], [7, 8, 9, 9, 9], [7, 8, 9, 9, 9]]\n assert candidate(grid = [[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]]) == [[5, 5, 5], [5, 5, 5], [5, 5, 5]]\n assert candidate(grid = [[1, 50, 2, 51, 3, 52, 4, 53, 5], [5, 54, 6, 55, 7, 56, 8, 57, 9], [10, 59, 11, 60, 12, 61, 13, 62, 14], [15, 63, 16, 64, 17, 65, 18, 66, 19], [20, 67, 21, 68, 22, 69, 23, 70, 24], [25, 71, 26, 72, 27, 73, 28, 74, 29], [30, 75, 31, 76, 32, 77, 33, 78, 34], [35, 79, 36, 80, 37, 81, 38, 82, 39], [40, 83, 41, 84, 42, 85, 43, 86, 44]]) == [[59, 60, 60, 61, 61, 62, 62], [63, 64, 64, 65, 65, 66, 66], [67, 68, 68, 69, 69, 70, 70], [71, 72, 72, 73, 73, 74, 74], [75, 76, 76, 77, 77, 78, 78], [79, 80, 80, 81, 81, 82, 82], [83, 84, 84, 85, 85, 86, 86]]\n assert candidate(grid = [[5, 1, 9, 3, 5, 7, 8, 2, 9, 10], [6, 2, 8, 4, 7, 5, 3, 8, 10, 7], [9, 3, 5, 8, 2, 10, 4, 7, 6, 5], [1, 4, 7, 9, 8, 6, 2, 10, 3, 9], [8, 6, 2, 7, 5, 9, 10, 4, 8, 6], [4, 7, 8, 6, 10, 2, 9, 5, 7, 4], [7, 5, 3, 9, 4, 8, 6, 10, 2, 8], [2, 8, 10, 5, 7, 3, 9, 6, 4, 7], [9, 6, 4, 7, 8, 10, 5, 2, 3, 1], [10, 7, 6, 5, 9, 4, 8, 7, 6, 5]]) == [[9, 9, 9, 10, 10, 10, 10, 10], [9, 9, 9, 10, 10, 10, 10, 10], [9, 9, 9, 10, 10, 10, 10, 10], [8, 9, 10, 10, 10, 10, 10, 10], [8, 9, 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, 9, 7]]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().largestLocal", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] largestLocal(int[][] grid) {", "container": "Solution", "callable": "largestLocal", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2374, "task_id": "node-with-highest-edge-score", "difficulty": "Medium", "problem_description": "You are given a directed graph with n nodes labeled from 0 to n - 1, where each node has exactly one outgoing edge.\nThe graph is represented by a given 0-indexed integer array edges of length n, where edges[i] indicates that there is a directed edge from node i to node edges[i].\nThe edge score of a node i is defined as the sum of the labels of all the nodes that have an edge pointing to i.\nReturn the node with the highest edge score. If multiple nodes have the same edge score, return the node with the smallest index.\n \nExample 1:\n\n\nInput: edges = [1,0,0,0,0,7,7,5]\nOutput: 7\nExplanation:\n- The nodes 1, 2, 3 and 4 have an edge pointing to node 0. The edge score of node 0 is 1 + 2 + 3 + 4 = 10.\n- The node 0 has an edge pointing to node 1. The edge score of node 1 is 0.\n- The node 7 has an edge pointing to node 5. The edge score of node 5 is 7.\n- The nodes 5 and 6 have an edge pointing to node 7. The edge score of node 7 is 5 + 6 = 11.\nNode 7 has the highest edge score so return 7.\n\nExample 2:\n\n\nInput: edges = [2,0,0,2]\nOutput: 0\nExplanation:\n- The nodes 1 and 2 have an edge pointing to node 0. The edge score of node 0 is 1 + 2 = 3.\n- The nodes 0 and 3 have an edge pointing to node 2. The edge score of node 2 is 0 + 3 = 3.\nNodes 0 and 2 both have an edge score of 3. Since node 0 has a smaller index, we return 0.\n\n \nConstraints:\n\nn == edges.length\n2 <= n <= 105\n0 <= edges[i] < n\nedges[i] != i\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [2, 0, 0, 2]) == 0\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 0\n assert candidate(edges = [3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(edges = [3, 3, 3, 3]) == 3\n assert candidate(edges = [5, 1, 4, 3, 2, 0]) == 0\n assert candidate(edges = [1, 0, 0, 0, 0, 7, 7, 5]) == 7\n assert candidate(edges = [5, 1, 5, 1, 5, 1, 5, 1]) == 1\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 0]) == 0\n assert candidate(edges = [5, 3, 0, 5, 1, 6, 2]) == 2\n assert candidate(edges = [3, 3, 3, 3, 3]) == 3\n assert candidate(edges = [3, 1, 2, 0]) == 0\n assert candidate(edges = [4, 4, 4, 4, 4]) == 4\n assert candidate(edges = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(edges = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == 6\n assert candidate(edges = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(edges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(edges = [1, 2, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 0\n assert candidate(edges = [1, 2, 0, 0, 3, 4, 5, 6, 7, 8, 9, 0]) == 0\n assert candidate(edges = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(edges = [8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(edges = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(edges = [7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 0, 1, 2]) == 2\n assert candidate(edges = [2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 0\n assert candidate(edges = [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]) == 10\n assert candidate(edges = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == 8\n"}, "metadata": {"canonical_parameter_names": ["edges"], "leetcode_dataset_entry_point": "Solution().edgeScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int edgeScore(int[] edges) {", "container": "Solution", "callable": "edgeScore", "parameters": [{"name": "edges", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2375, "task_id": "construct-smallest-number-from-di-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string pattern of length n consisting of the characters 'I' meaning increasing and 'D' meaning decreasing.\nA 0-indexed string num of length n + 1 is created using the following conditions:\n\nnum consists of the digits '1' to '9', where each digit is used at most once.\nIf pattern[i] == 'I', then num[i] < num[i + 1].\nIf pattern[i] == 'D', then num[i] > num[i + 1].\n\nReturn the lexicographically smallest possible string num that meets the conditions.\n \nExample 1:\n\nInput: pattern = \"IIIDIDDD\"\nOutput: \"123549876\"\nExplanation:\nAt indices 0, 1, 2, and 4 we must have that num[i] < num[i+1].\nAt indices 3, 5, 6, and 7 we must have that num[i] > num[i+1].\nSome possible values of num are \"245639871\", \"135749862\", and \"123849765\".\nIt can be proven that \"123549876\" is the smallest possible num that meets the conditions.\nNote that \"123414321\" is not possible because the digit '1' is used more than once.\nExample 2:\n\nInput: pattern = \"DDD\"\nOutput: \"4321\"\nExplanation:\nSome possible values of num are \"9876\", \"7321\", and \"8742\".\nIt can be proven that \"4321\" is the smallest possible num that meets the conditions.\n\n \nConstraints:\n\n1 <= pattern.length <= 8\npattern consists of only the letters 'I' and 'D'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pattern = \"DDD\") == \"4321\"\n assert candidate(pattern = \"IIIDIDDD\") == \"123549876\"\n assert candidate(pattern = \"ID\") == \"132\"\n assert candidate(pattern = \"IIDDD\") == \"126543\"\n assert candidate(pattern = \"DDIII\") == \"321456\"\n assert candidate(pattern = \"IDID\") == \"13254\"\n assert candidate(pattern = \"IIII\") == \"12345\"\n assert candidate(pattern = \"DI\") == \"213\"\n assert candidate(pattern = \"IID\") == \"1243\"\n assert candidate(pattern = \"DDIDDIID\") == \"321654798\"\n assert candidate(pattern = \"IDIDIDID\") == \"132547698\"\n assert candidate(pattern = \"I\") == \"12\"\n assert candidate(pattern = \"DID\") == \"2143\"\n assert candidate(pattern = \"IIIII\") == \"123456\"\n assert candidate(pattern = \"DDDDD\") == \"654321\"\n assert candidate(pattern = \"D\") == \"21\"\n assert candidate(pattern = \"DDDD\") == \"54321\"\n assert candidate(pattern = \"DDIIDDIID\") == None\n assert candidate(pattern = \"IDIDIDIDID\") == None\n assert candidate(pattern = \"DDDIDIII\") == \"432165789\"\n assert candidate(pattern = \"DDDDDDIIIIIIII\") == None\n assert candidate(pattern = \"DDDIIIII\") == \"432156789\"\n assert candidate(pattern = \"IIIIIIIII\") == None\n assert candidate(pattern = \"IDDDDDID\") == \"176543298\"\n assert candidate(pattern = \"IDDDDDIDI\") == None\n assert candidate(pattern = \"DDIDIDIDIDIDID\") == None\n assert candidate(pattern = \"IIDID\") == \"124365\"\n assert candidate(pattern = \"DIIIDDDI\") == \"213487659\"\n assert candidate(pattern = \"DDDDDDDDDD\") == None\n assert candidate(pattern = \"IIIIIIIIII\") == None\n assert candidate(pattern = \"IIDDDDDDII\") == None\n assert candidate(pattern = \"DDIIDIDID\") == None\n assert candidate(pattern = \"IIIIIIDDD\") == None\n assert candidate(pattern = \"DDDDDDD\") == \"87654321\"\n assert candidate(pattern = \"DIDIDIDI\") == \"214365879\"\n assert candidate(pattern = \"IIDDDDDDD\") == None\n assert candidate(pattern = \"DDDDDDDD\") == \"987654321\"\n assert candidate(pattern = \"IIDDIIDDI\") == None\n assert candidate(pattern = \"IIDDDIIID\") == None\n assert candidate(pattern = \"DDDDIIII\") == \"543216789\"\n assert candidate(pattern = \"DDIIDDDDD\") == None\n assert candidate(pattern = \"IIDIDIDDD\") == None\n assert candidate(pattern = \"IIIIIDDDDDD\") == None\n assert candidate(pattern = \"IDIDIDDDDD\") == None\n assert candidate(pattern = \"IIIDIDID\") == \"123547698\"\n assert candidate(pattern = \"IDDDIIDI\") == \"154326879\"\n assert candidate(pattern = \"IIDIDDDI\") == \"124387659\"\n assert candidate(pattern = \"IIDDIDDIID\") == None\n assert candidate(pattern = \"DDDDDDDDDDDD\") == None\n assert candidate(pattern = \"DIDIDID\") == \"21436587\"\n assert candidate(pattern = \"IIIDDDIID\") == None\n assert candidate(pattern = \"DDIIIDDDIDI\") == None\n assert candidate(pattern = \"IIDDIIIIID\") == None\n assert candidate(pattern = \"DDDDIII\") == \"54321678\"\n assert candidate(pattern = \"IDIDID\") == \"1325476\"\n assert candidate(pattern = \"IIDIDIDI\") == \"124365879\"\n assert candidate(pattern = \"DDDDDDDDD\") == None\n assert candidate(pattern = \"DDDDDDI\") == \"76543218\"\n assert candidate(pattern = \"DDIDDDID\") == \"321765498\"\n assert candidate(pattern = \"DDIIIIIII\") == None\n assert candidate(pattern = \"DIIIIIII\") == \"213456789\"\n assert candidate(pattern = \"IIIDDDDDDID\") == None\n assert candidate(pattern = \"IDDDIDII\") == \"154327689\"\n assert candidate(pattern = \"DDIIDIDDDI\") == None\n assert candidate(pattern = \"DDDDIIIID\") == None\n assert candidate(pattern = \"DDIDIDID\") == \"321547698\"\n assert candidate(pattern = \"IIIDDDDD\") == \"123987654\"\n assert candidate(pattern = \"DDDDDIIIIII\") == None\n assert candidate(pattern = \"IIIDDDDIII\") == None\n assert candidate(pattern = \"IIIIIIIDDDDDD\") == None\n assert candidate(pattern = \"IIIIIID\") == \"12345687\"\n assert candidate(pattern = \"IIIIIIIIIII\") == None\n assert candidate(pattern = \"IDIDDDID\") == \"132765498\"\n assert candidate(pattern = \"IDIDIDIDIDIDID\") == None\n assert candidate(pattern = \"IDIDIIDID\") == None\n assert candidate(pattern = \"IIIIIII\") == \"12345678\"\n assert candidate(pattern = \"DDIIDDDD\") == \"321498765\"\n assert candidate(pattern = \"IIIIIIID\") == \"123456798\"\n assert candidate(pattern = \"IDIDIDIDIDID\") == None\n assert candidate(pattern = \"DIIDIDID\") == \"213547698\"\n assert candidate(pattern = \"DDIIDIDI\") == \"321465879\"\n assert candidate(pattern = \"DDDIIIDID\") == None\n assert candidate(pattern = \"IIDDDIIII\") == None\n assert candidate(pattern = \"IIDDDIID\") == \"126543798\"\n assert candidate(pattern = \"IIDDDIII\") == \"126543789\"\n assert candidate(pattern = \"IDIDIDIDIDIDIDID\") == None\n assert candidate(pattern = \"DIDID\") == \"214365\"\n assert candidate(pattern = \"DDDDDIII\") == \"654321789\"\n assert candidate(pattern = \"DDII\") == \"32145\"\n assert candidate(pattern = \"DDDIDDDD\") == \"432198765\"\n assert candidate(pattern = \"IIIDDDIDDD\") == None\n assert candidate(pattern = \"DDIDDDDDDID\") == None\n assert candidate(pattern = \"IDDDDDD\") == \"18765432\"\n assert candidate(pattern = \"IDII\") == \"13245\"\n assert candidate(pattern = \"DDDDDDII\") == \"765432189\"\n assert candidate(pattern = \"IIIDDDDI\") == \"123876549\"\n assert candidate(pattern = \"IDDDIDID\") == \"154327698\"\n assert candidate(pattern = \"IIIIIDDI\") == \"123458769\"\n assert candidate(pattern = \"DDDDDD\") == \"7654321\"\n assert candidate(pattern = \"IIDDDIDDDDD\") == None\n assert candidate(pattern = \"IIIIIDDD\") == \"123459876\"\n assert candidate(pattern = \"IDIDDDIDID\") == None\n assert candidate(pattern = \"IIIIIIIID\") == None\n assert candidate(pattern = \"DDDDDDDDDDDID\") == None\n assert candidate(pattern = \"IIIIIDDDD\") == None\n assert candidate(pattern = \"DDDDIID\") == \"54321687\"\n assert candidate(pattern = \"IDDDIIDDD\") == None\n assert candidate(pattern = \"IIIDDDDDDDDDD\") == None\n assert candidate(pattern = \"DDIIDDID\") == \"321476598\"\n assert candidate(pattern = \"IIDDDDDD\") == \"129876543\"\n assert candidate(pattern = \"IIDDDII\") == \"12654378\"\n assert candidate(pattern = \"DDIIDIDD\") == \"321465987\"\n assert candidate(pattern = \"IIDDIIDD\") == \"125436987\"\n assert candidate(pattern = \"IIIIIIII\") == \"123456789\"\n assert candidate(pattern = \"IIIDDDD\") == \"12387654\"\n assert candidate(pattern = \"DDIID\") == \"321465\"\n"}, "metadata": {"canonical_parameter_names": ["pattern"], "leetcode_dataset_entry_point": "Solution().smallestNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String smallestNumber(String pattern) {", "container": "Solution", "callable": "smallestNumber", "parameters": [{"name": "pattern", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2376, "task_id": "count-special-integers", "difficulty": "Hard", "problem_description": "We call a positive integer special if all of its digits are distinct.\nGiven a positive integer n, return the number of special integers that belong to the interval [1, n].\n \nExample 1:\n\nInput: n = 20\nOutput: 19\nExplanation: All the integers from 1 to 20, except 11, are special. Thus, there are 19 special integers.\n\nExample 2:\n\nInput: n = 5\nOutput: 5\nExplanation: All the integers from 1 to 5 are special.\n\nExample 3:\n\nInput: n = 135\nOutput: 110\nExplanation: There are 110 integers from 1 to 135 that are special.\nSome of the integers that are not special are: 22, 114, and 131.\n \nConstraints:\n\n1 <= n <= 2 * 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 135) == 110\n assert candidate(n = 999) == 738\n assert candidate(n = 200) == 162\n assert candidate(n = 10000) == 5274\n assert candidate(n = 1234) == 803\n assert candidate(n = 2000) == 1242\n assert candidate(n = 9876) == 5274\n assert candidate(n = 123456789) == 2392084\n assert candidate(n = 20) == 19\n assert candidate(n = 2000000) == 229050\n assert candidate(n = 2000000000) == 5974650\n assert candidate(n = 300) == 234\n assert candidate(n = 100) == 90\n assert candidate(n = 1999999999) == 5974650\n assert candidate(n = 1000) == 738\n assert candidate(n = 1) == 1\n assert candidate(n = 5) == 5\n assert candidate(n = 222222222) == 2789370\n assert candidate(n = 210) == 171\n assert candidate(n = 102030405060708090) == 8877690\n assert candidate(n = 999999999) == 5611770\n assert candidate(n = 12345) == 5660\n assert candidate(n = 9999999) == 712890\n assert candidate(n = 2147483647) == 6028170\n assert candidate(n = 111111) == 34170\n assert candidate(n = 111222333) == 2386170\n assert candidate(n = 111) == 98\n assert candidate(n = 213456789) == 2754964\n assert candidate(n = 987654) == 168570\n assert candidate(n = 876543210) == 5202657\n assert candidate(n = 200000) == 47610\n assert candidate(n = 2100000000) == 6014970\n assert candidate(n = 101010101) == 2345850\n assert candidate(n = 200000000) == 2708730\n assert candidate(n = 12344321) == 735990\n assert candidate(n = 9876543210) == 8877690\n assert candidate(n = 543210987) == 3975354\n assert candidate(n = 1122334455) == 5652090\n assert candidate(n = 9999) == 5274\n assert candidate(n = 555555555) == 3998970\n assert candidate(n = 1111111) == 175290\n assert candidate(n = 1000000000) == 5611770\n assert candidate(n = 88888) == 29130\n assert candidate(n = 1000000001) == 5611770\n assert candidate(n = 111111111) == 2386170\n assert candidate(n = 987654321) == 5611770\n assert candidate(n = 888888888) == 5208570\n assert candidate(n = 1234567890) == 5658004\n assert candidate(n = 567890123) == 4028371\n assert candidate(n = 101010) == 32490\n assert candidate(n = 987654320) == 5611769\n assert candidate(n = 98765) == 32490\n assert candidate(n = 1000000) == 168570\n assert candidate(n = 999999) == 168570\n assert candidate(n = 123456) == 34417\n assert candidate(n = 87654321) == 2141294\n assert candidate(n = 1111111111) == 5652090\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countSpecialNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countSpecialNumbers(int n) {", "container": "Solution", "callable": "countSpecialNumbers", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2379, "task_id": "minimum-recolors-to-get-k-consecutive-black-blocks", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string blocks of length n, where blocks[i] is either 'W' or 'B', representing the color of the ith block. The characters 'W' and 'B' denote the colors white and black, respectively.\nYou are also given an integer k, which is the desired number of consecutive black blocks.\nIn one operation, you can recolor a white block such that it becomes a black block.\nReturn the minimum number of operations needed such that there is at least one occurrence of k consecutive black blocks.\n \nExample 1:\n\nInput: blocks = \"WBBWWBBWBW\", k = 7\nOutput: 3\nExplanation:\nOne way to achieve 7 consecutive black blocks is to recolor the 0th, 3rd, and 4th blocks\nso that blocks = \"BBBBBBBWBW\". \nIt can be shown that there is no way to achieve 7 consecutive black blocks in less than 3 operations.\nTherefore, we return 3.\n\nExample 2:\n\nInput: blocks = \"WBWBBBW\", k = 2\nOutput: 0\nExplanation:\nNo changes need to be made, since 2 consecutive black blocks already exist.\nTherefore, we return 0.\n\n \nConstraints:\n\nn == blocks.length\n1 <= n <= 100\nblocks[i] is either 'W' or 'B'.\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(blocks = \"WWWW\",k = 2) == 2\n assert candidate(blocks = \"WBBBWWBBBW\",k = 3) == 0\n assert candidate(blocks = \"WBBWWBBWBW\",k = 7) == 3\n assert candidate(blocks = \"BBBBB\",k = 3) == 0\n assert candidate(blocks = \"BWBWBWBWBW\",k = 6) == 3\n assert candidate(blocks = \"WWWWWW\",k = 4) == 4\n assert candidate(blocks = \"WWWWWW\",k = 3) == 3\n assert candidate(blocks = \"BBBB\",k = 4) == 0\n assert candidate(blocks = \"BBBBBB\",k = 4) == 0\n assert candidate(blocks = \"WBWBBBW\",k = 2) == 0\n assert candidate(blocks = \"WBWBWBWBWB\",k = 5) == 2\n assert candidate(blocks = \"BBBBBB\",k = 3) == 0\n assert candidate(blocks = \"BBBBBBBBBBBBBBBBBBBB\",k = 20) == 0\n assert candidate(blocks = \"BBWBBWBBWBBWBBWBBWBBWBBWBBWBBWBBW\",k = 14) == 4\n assert candidate(blocks = \"WBBBWWWWWWBBBWWBB\",k = 7) == 2\n assert candidate(blocks = \"WBWBWBWBWBWBWBWBWB\",k = 10) == 5\n assert candidate(blocks = \"WBBWWBBWWBBWWBBWWBBW\",k = 8) == 4\n assert candidate(blocks = \"WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB\",k = 10) == 5\n assert candidate(blocks = \"WBWBWBWBWBWBWB\",k = 5) == 2\n assert candidate(blocks = \"WWBBWWBBWWBBWWBBWWBB\",k = 6) == 2\n assert candidate(blocks = \"BWBWBWBWBWBWBWBWBWBWBWBWBW\",k = 7) == 3\n assert candidate(blocks = \"BBWWBBWWBBW\",k = 5) == 2\n assert candidate(blocks = \"BWBWBWBWBWBWBW\",k = 7) == 3\n assert candidate(blocks = \"WBBBWWBBBWBBBWWBBB\",k = 7) == 1\n assert candidate(blocks = \"BBBBBBBBBBBBBBBB\",k = 16) == 0\n assert candidate(blocks = \"BBBBBBWWBBWWBBWWBBWW\",k = 6) == 0\n assert candidate(blocks = \"WWBWWBBWWB\",k = 6) == 3\n assert candidate(blocks = \"WWWWBBWWWBBWWBBWWB\",k = 5) == 2\n assert candidate(blocks = \"WBBWWWWBBBWBWWBBB\",k = 8) == 3\n assert candidate(blocks = \"BBWWBBWWBBWWBBWW\",k = 4) == 2\n assert candidate(blocks = \"BWWBWWBWWBWWBWWBWWBW\",k = 7) == 4\n assert candidate(blocks = \"BWBWBWBWBWBWBWBWBWBW\",k = 15) == 7\n assert candidate(blocks = \"WWWWWWWWWW\",k = 10) == 10\n assert candidate(blocks = \"WWBWWBWWBWWBWWBWWBWWBWWBWWB\",k = 3) == 2\n assert candidate(blocks = \"WBBBBBBWBBBBBBW\",k = 10) == 1\n assert candidate(blocks = \"BBBWBBWWWWBBBWWBBB\",k = 6) == 1\n assert candidate(blocks = \"BBBBBBBWWWWWWWBBBBBB\",k = 8) == 1\n assert candidate(blocks = \"WWWWBWWWWBWWWWBWWWWB\",k = 4) == 3\n assert candidate(blocks = \"WBBWBBWBBWBBWBBW\",k = 7) == 2\n assert candidate(blocks = \"BWBWBWBWBWBWBWBWBW\",k = 10) == 5\n assert candidate(blocks = \"BWBWBWBWBW\",k = 4) == 2\n assert candidate(blocks = \"WBBBWWBBBWWBBB\",k = 6) == 2\n assert candidate(blocks = \"WWWWWBBBWBBBWWWW\",k = 7) == 1\n assert candidate(blocks = \"BBBWWWBBBWWWBBB\",k = 9) == 3\n assert candidate(blocks = \"WBBWBWBWBWBWBWBWBW\",k = 8) == 3\n assert candidate(blocks = \"WWWWWWWW\",k = 4) == 4\n assert candidate(blocks = \"BBWWBBWWBBWW\",k = 4) == 2\n assert candidate(blocks = \"WWBBBWWBBBWWBBBWW\",k = 5) == 2\n assert candidate(blocks = \"WWWWWWWWWW\",k = 5) == 5\n assert candidate(blocks = \"WWWWWWWWWWWWWWWWWWWW\",k = 15) == 15\n assert candidate(blocks = \"BBBBBBBBBWWWWWWWWW\",k = 9) == 0\n assert candidate(blocks = \"BBBBBB\",k = 6) == 0\n assert candidate(blocks = \"BWBWBWBWBWBWBWBWBWBW\",k = 9) == 4\n assert candidate(blocks = \"BWBWBWBWBWBWBWBWBWBWBW\",k = 11) == 5\n assert candidate(blocks = \"BBBBBBBBBB\",k = 5) == 0\n assert candidate(blocks = \"BBBBWWBBBWBWB\",k = 6) == 2\n assert candidate(blocks = \"BBBBWBWBWBWBWBWBWB\",k = 11) == 4\n assert candidate(blocks = \"WBBBBBBBBBBBBBBBBBBBBBBBBBBW\",k = 25) == 0\n assert candidate(blocks = \"BBBBBBWWWWWW\",k = 4) == 0\n assert candidate(blocks = \"BBBWWBWBWBWBWBW\",k = 6) == 2\n assert candidate(blocks = \"BWBWBWBWBWBWBWBW\",k = 8) == 4\n assert candidate(blocks = \"WBBWWBBWBWWBBWBBWBWBWBWB\",k = 12) == 5\n assert candidate(blocks = \"BBBWWWBBBWWWBBBWWWBB\",k = 5) == 2\n assert candidate(blocks = \"WWBBWWBBWWBBWWBBWW\",k = 5) == 2\n assert candidate(blocks = \"BBBBBBBWBBB\",k = 8) == 1\n assert candidate(blocks = \"WBBBWWBBBWWBBB\",k = 8) == 2\n assert candidate(blocks = \"BBBWBBBWWBBBWWBBBWWB\",k = 7) == 1\n assert candidate(blocks = \"BBWWWWWWWWWW\",k = 3) == 1\n assert candidate(blocks = \"BWBWBWBWBW\",k = 8) == 4\n assert candidate(blocks = \"WBBBWBWBWBWBBB\",k = 5) == 1\n assert candidate(blocks = \"WWBWBWBWBW\",k = 5) == 2\n assert candidate(blocks = \"WBBWWBBWBBWWBBWBBWBBWWBBWB\",k = 8) == 2\n assert candidate(blocks = \"BBWWBBWWBBWWBBWWBBWWBBWW\",k = 5) == 2\n assert candidate(blocks = \"WBBBWWBBBWBBBWWBBB\",k = 6) == 1\n assert candidate(blocks = \"WBWBWBWBWBWBWBWBWBWB\",k = 10) == 5\n assert candidate(blocks = \"BWBWBWBWBWBWBWBW\",k = 6) == 3\n assert candidate(blocks = \"WBBWBBWWBBWWBBWBBWBBW\",k = 8) == 2\n assert candidate(blocks = \"WBBWWBBWBWWBBWBBW\",k = 10) == 4\n assert candidate(blocks = \"BWWWWBBWWWWBBWWWW\",k = 7) == 4\n assert candidate(blocks = \"BBBWBWBBBBBBBWB\",k = 9) == 1\n assert candidate(blocks = \"WWWWWWWWWWWW\",k = 5) == 5\n assert candidate(blocks = \"WBBWWWWBWBWWB\",k = 6) == 3\n assert candidate(blocks = \"WWBBWWBBWWBBWWBBWWBB\",k = 4) == 2\n assert candidate(blocks = \"WBBWBBWBBWBBWBBWBBWB\",k = 10) == 3\n assert candidate(blocks = \"BBWWBBWWBBWWBBWWBB\",k = 4) == 2\n assert candidate(blocks = \"BWWBWWBWWBWWBWWBWW\",k = 6) == 4\n assert candidate(blocks = \"WWWBWWWWBWBWWB\",k = 4) == 2\n assert candidate(blocks = \"WBWBWBWBWBWBWBWBWBWB\",k = 5) == 2\n assert candidate(blocks = \"WBBWBBWBBWBBWBBWBBWB\",k = 9) == 3\n assert candidate(blocks = \"BBBBBBBWWWWWWWWWW\",k = 7) == 0\n assert candidate(blocks = \"WWWWWWWWWWWWWWWWWWWW\",k = 1) == 1\n assert candidate(blocks = \"WBBWWBBWWBBWWBBWWBBWWBBW\",k = 7) == 3\n assert candidate(blocks = \"WWWWBBWWWWBBWWWWBBWWWWBB\",k = 4) == 2\n assert candidate(blocks = \"WWBBWWBBWWBBWW\",k = 5) == 2\n assert candidate(blocks = \"WWWWBWWWWBWWWWB\",k = 4) == 3\n assert candidate(blocks = \"BBBBBBBBBB\",k = 10) == 0\n assert candidate(blocks = \"BBBBBBBBBBBBBBBBBBBB\",k = 10) == 0\n assert candidate(blocks = \"WWWWWWWWWWWWWW\",k = 5) == 5\n assert candidate(blocks = \"WWBBWWBBWWBBWW\",k = 6) == 2\n assert candidate(blocks = \"BBBBBWWBBBWWBBBWWBBBWWBBB\",k = 5) == 0\n assert candidate(blocks = \"BWBWBWBWBWBWBWBWBWBWBWBWBWBWBW\",k = 15) == 7\n"}, "metadata": {"canonical_parameter_names": ["blocks", "k"], "leetcode_dataset_entry_point": "Solution().minimumRecolors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumRecolors(String blocks, int k) {", "container": "Solution", "callable": "minimumRecolors", "parameters": [{"name": "blocks", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2380, "task_id": "time-needed-to-rearrange-a-binary-string", "difficulty": "Medium", "problem_description": "You are given a binary string s. In one second, all occurrences of \"01\" are simultaneously replaced with \"10\". This process repeats until no occurrences of \"01\" exist.\nReturn the number of seconds needed to complete this process.\n \nExample 1:\n\nInput: s = \"0110101\"\nOutput: 4\nExplanation: \nAfter one second, s becomes \"1011010\".\nAfter another second, s becomes \"1101100\".\nAfter the third second, s becomes \"1110100\".\nAfter the fourth second, s becomes \"1111000\".\nNo occurrence of \"01\" exists any longer, and the process needed 4 seconds to complete,\nso we return 4.\n\nExample 2:\n\nInput: s = \"11100\"\nOutput: 0\nExplanation:\nNo occurrence of \"01\" exists in s, and the processes needed 0 seconds to complete,\nso we return 0.\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns[i] is either '0' or '1'.\n\n \nFollow up:\nCan you solve this problem in O(n) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 0\n assert candidate(s = \"00110011\") == 5\n assert candidate(s = \"0000\") == 0\n assert candidate(s = \"111000\") == 0\n assert candidate(s = \"0010110\") == 4\n assert candidate(s = \"1001001\") == 4\n assert candidate(s = \"000011110000\") == 7\n assert candidate(s = \"000111\") == 5\n assert candidate(s = \"1001001001\") == 6\n assert candidate(s = \"11111\") == 0\n assert candidate(s = \"01010101\") == 4\n assert candidate(s = \"10101010\") == 3\n assert candidate(s = \"110100110\") == 4\n assert candidate(s = \"1010101010\") == 4\n assert candidate(s = \"101010\") == 2\n assert candidate(s = \"1000000\") == 0\n assert candidate(s = \"11001100\") == 3\n assert candidate(s = \"11100\") == 0\n assert candidate(s = \"0101010101\") == 5\n assert candidate(s = \"0110101\") == 4\n assert candidate(s = \"0110011001\") == 5\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"0010010010\") == 6\n assert candidate(s = \"101010101010101010\") == 8\n assert candidate(s = \"011010101010101010100110\") == 12\n assert candidate(s = \"0010101010101010\") == 8\n assert candidate(s = \"000000000000000000000000000111111111111111111111111111111111111111111111111\") == 74\n assert candidate(s = \"01001010100101010010\") == 11\n assert candidate(s = \"11101110111011101110111011101110111011101110\") == 30\n assert candidate(s = \"00000000111111111111\") == 19\n assert candidate(s = \"1100110011001100\") == 7\n assert candidate(s = \"111011101110111011101110111011101110111011101110\") == 33\n assert candidate(s = \"000111000111000111000111000111000111\") == 20\n assert candidate(s = \"10101010101010101010101010\") == 12\n assert candidate(s = \"00000000000000001111111111111111\") == 31\n assert candidate(s = \"111000111000111\") == 8\n assert candidate(s = \"10110011001100110011\") == 10\n assert candidate(s = \"010101010101010101\") == 9\n assert candidate(s = \"0000000000000000000011111111111111111111\") == 39\n assert candidate(s = \"1100110011001100110011001100110011001100\") == 19\n assert candidate(s = \"1010101010101010\") == 7\n assert candidate(s = \"111111000000111111000000\") == 11\n assert candidate(s = \"11110000011110000111\") == 11\n assert candidate(s = \"111100001111000011110000\") == 11\n assert candidate(s = \"111111111111111111110000000000000000\") == 0\n assert candidate(s = \"0011001100110011\") == 9\n assert candidate(s = \"00000111111111\") == 13\n assert candidate(s = \"11111000001111100000\") == 9\n assert candidate(s = \"111111100000000\") == 0\n assert candidate(s = \"0000111100001111000011110000\") == 15\n assert candidate(s = \"01001000100001000001\") == 15\n assert candidate(s = \"00000101010111111\") == 13\n assert candidate(s = \"0110110110110110\") == 10\n assert candidate(s = \"01010101010101010101010101\") == 13\n assert candidate(s = \"11110000111100001111\") == 11\n assert candidate(s = \"01101101101101\") == 9\n assert candidate(s = \"000000001111111100000000\") == 15\n assert candidate(s = \"101010101010\") == 5\n assert candidate(s = \"000000011111111\") == 14\n assert candidate(s = \"110000000000001111\") == 15\n assert candidate(s = \"01001000100000001001\") == 15\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\") == 25\n assert candidate(s = \"001001001001001001001001\") == 16\n assert candidate(s = \"000101010101\") == 7\n assert candidate(s = \"10010010010010\") == 8\n assert candidate(s = \"0000001111111111\") == 15\n assert candidate(s = \"00000000001111111111\") == 19\n assert candidate(s = \"000000001111111111111111\") == 23\n assert candidate(s = \"00000111110000011111\") == 14\n assert candidate(s = \"01010010101101\") == 8\n assert candidate(s = \"11101110000111000011\") == 10\n assert candidate(s = \"1001001001001001\") == 10\n assert candidate(s = \"11001100110011001100\") == 9\n assert candidate(s = \"00111100001111000011\") == 11\n assert candidate(s = \"01010101010101010101010101010101\") == 16\n assert candidate(s = \"10010010010010010010\") == 12\n assert candidate(s = \"1010101010101010101010101010\") == 13\n assert candidate(s = \"01001100110011001100\") == 10\n assert candidate(s = \"1000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"111000111000\") == 5\n assert candidate(s = \"11000011110000\") == 7\n assert candidate(s = \"11111000000000\") == 0\n assert candidate(s = \"10101101010010\") == 6\n assert candidate(s = \"000000001111111111\") == 17\n assert candidate(s = \"10010101010101010101\") == 10\n assert candidate(s = \"0101010101010101\") == 8\n assert candidate(s = \"11111111111111111110\") == 0\n assert candidate(s = \"0000000000000000001\") == 18\n assert candidate(s = \"111111110000000011111111\") == 15\n assert candidate(s = \"00000111111111111111100000\") == 20\n assert candidate(s = \"0101010101010101010101010101\") == 14\n assert candidate(s = \"00010001000100010001\") == 15\n assert candidate(s = \"1111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"11111100000011111100\") == 11\n assert candidate(s = \"00110011001100110011\") == 11\n assert candidate(s = \"11111111000000000000\") == 0\n assert candidate(s = \"00010010010010010010010010010010010010010010\") == 29\n assert candidate(s = \"00000111100001111000\") == 12\n assert candidate(s = \"1001001001001001001001001\") == 16\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 28\n assert candidate(s = \"00100100100100100100100100100100100100100100\") == 28\n assert candidate(s = \"01010101010101\") == 7\n assert candidate(s = \"10101010100101010101\") == 10\n assert candidate(s = \"00101010101010101010101010\") == 13\n assert candidate(s = \"000001000001000001000001000001000001\") == 30\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 19\n assert candidate(s = \"1001001001001001001001001001001001001001001001001\") == 32\n assert candidate(s = \"1111000011110000111100001111\") == 15\n assert candidate(s = \"111110000011111\") == 9\n assert candidate(s = \"11111010101000000\") == 3\n assert candidate(s = \"01010101010101010101010101010101010101010101\") == 22\n assert candidate(s = \"01010101010101010101\") == 10\n assert candidate(s = \"111111110000000011111111000000001111\") == 19\n assert candidate(s = \"00011111100000111110\") == 13\n assert candidate(s = \"0000000000000000000000000000000000000001\") == 39\n assert candidate(s = \"11000011110000111100\") == 11\n assert candidate(s = \"01101101101101101101\") == 13\n assert candidate(s = \"10101010101010101010\") == 9\n assert candidate(s = \"11111111111111110000000000000000\") == 0\n assert candidate(s = \"100110011001100110011001\") == 12\n assert candidate(s = \"110110110110110110\") == 10\n assert candidate(s = \"00101010101000\") == 6\n assert candidate(s = \"11111111111111110000000000\") == 0\n assert candidate(s = \"000111000111000\") == 8\n assert candidate(s = \"001001001001001001\") == 12\n assert candidate(s = \"1000000000000001\") == 14\n assert candidate(s = \"0000111100001111\") == 11\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().secondsToRemoveOccurrences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int secondsToRemoveOccurrences(String s) {", "container": "Solution", "callable": "secondsToRemoveOccurrences", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2381, "task_id": "shifting-letters-ii", "difficulty": "Medium", "problem_description": "You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [starti, endi, directioni]. For every i, shift the characters in s from the index starti to the index endi (inclusive) forward if directioni = 1, or shift the characters backward if directioni = 0.\nShifting a character forward means replacing it with the next letter in the alphabet (wrapping around so that 'z' becomes 'a'). Similarly, shifting a character backward means replacing it with the previous letter in the alphabet (wrapping around so that 'a' becomes 'z').\nReturn the final string after all such shifts to s are applied.\n \nExample 1:\n\nInput: s = \"abc\", shifts = [[0,1,0],[1,2,1],[0,2,1]]\nOutput: \"ace\"\nExplanation: Firstly, shift the characters from index 0 to index 1 backward. Now s = \"zac\".\nSecondly, shift the characters from index 1 to index 2 forward. Now s = \"zbd\".\nFinally, shift the characters from index 0 to index 2 forward. Now s = \"ace\".\nExample 2:\n\nInput: s = \"dztz\", shifts = [[0,0,0],[1,1,1]]\nOutput: \"catz\"\nExplanation: Firstly, shift the characters from index 0 to index 0 backward. Now s = \"cztz\".\nFinally, shift the characters from index 1 to index 1 forward. Now s = \"catz\".\n\n \nConstraints:\n\n1 <= s.length, shifts.length <= 5 * 104\nshifts[i].length == 3\n0 <= starti <= endi < s.length\n0 <= directioni <= 1\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"world\",shifts = [[0, 4, 0], [0, 4, 0], [0, 4, 0], [0, 4, 0]]) == \"sknhz\"\n assert candidate(s = \"abc\",shifts = [[0, 1, 0], [1, 2, 1], [0, 2, 1]]) == \"ace\"\n assert candidate(s = \"xyz\",shifts = [[0, 2, 0]]) == \"wxy\"\n assert candidate(s = \"abcdef\",shifts = [[1, 4, 1], [2, 3, 0]]) == \"accdff\"\n assert candidate(s = \"aaa\",shifts = [[0, 2, 1], [0, 2, 1], [0, 2, 1]]) == \"ddd\"\n assert candidate(s = \"hello\",shifts = [[0, 4, 1], [1, 3, 0]]) == \"iellp\"\n assert candidate(s = \"hello\",shifts = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1]]) == \"ignnp\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1]]) == \"bcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"dztz\",shifts = [[0, 0, 0], [1, 1, 1]]) == \"catz\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",shifts = [[0, 25, 0]]) == \"yxwvutsrqponmlkjihgfedcbaz\"\n assert candidate(s = \"a\",shifts = [[0, 0, 1], [0, 0, 0]]) == \"a\"\n assert candidate(s = \"abcd\",shifts = [[0, 3, 1], [1, 2, 0], [2, 3, 1]]) == \"bbdf\"\n assert candidate(s = \"zzz\",shifts = [[0, 2, 0], [0, 2, 0], [0, 2, 0]]) == \"www\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 0]]) == \"zabcdefghijklmnopqrstuvwxy\"\n assert candidate(s = \"hello\",shifts = [[0, 4, 1]]) == \"ifmmp\"\n assert candidate(s = \"zzzzzzzzzz\",shifts = [[0, 4, 0], [5, 9, 1], [0, 9, 1], [3, 6, 0]]) == \"zzzyyaabbb\"\n assert candidate(s = \"alphabet\",shifts = [[0, 0, 1], [1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [5, 5, 1]]) == \"bkqgbbet\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [5, 10, 0], [15, 20, 1]]) == \"bcdeffghijkmnoprstuvwwxyza\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",shifts = [[0, 51, 1], [10, 40, 0], [20, 30, 1], [30, 40, 0]]) == \"bbccddeeffffgghhiijjllmmnnoopppoppqqrrsstvwwxxyyzzaa\"\n assert candidate(s = \"abacax\",shifts = [[0, 5, 1], [1, 4, 0], [2, 3, 1], [0, 5, 0]]) == \"aaaczx\"\n assert candidate(s = \"programming\",shifts = [[0, 9, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1], [9, 9, 0]]) == \"qrpgsanmjng\"\n assert candidate(s = \"abcdefghij\",shifts = [[0, 9, 0], [1, 8, 1], [2, 7, 0], [3, 6, 1], [4, 5, 0]]) == \"zbbddeggii\"\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijkl\",shifts = [[0, 25, 1], [5, 15, 0], [10, 20, 1], [15, 25, 0]]) == \"nopqrrstuvxyzabbdefghhijkl\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [0, 25, 1], [0, 25, 1], [0, 25, 0]]) == \"cdefghijklmnopqrstuvwxyzab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [0, 25, 0], [0, 25, 1], [0, 25, 0]]) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abababab\",shifts = [[0, 7, 1], [1, 6, 0], [2, 5, 1], [3, 4, 0]]) == \"bbbbacac\"\n assert candidate(s = \"zzzzzzzzzz\",shifts = [[0, 9, 1], [2, 8, 0], [4, 6, 1]]) == \"aazzaaazza\"\n assert candidate(s = \"algorithm\",shifts = [[0, 2, 1], [3, 5, 0], [6, 8, 1], [1, 4, 0], [2, 3, 1], [5, 7, 0], [7, 8, 1]]) == \"blhnpgtio\"\n assert candidate(s = \"abcdefghij\",shifts = [[0, 9, 1], [0, 9, 0], [0, 9, 1], [0, 9, 0], [0, 9, 1], [0, 9, 0], [0, 9, 1], [0, 9, 0], [0, 9, 1], [0, 9, 0]]) == \"abcdefghij\"\n assert candidate(s = \"codingame\",shifts = [[0, 1, 1], [2, 3, 0], [4, 5, 1], [6, 7, 0], [8, 8, 1], [0, 8, 0], [0, 8, 1], [0, 8, 0], [0, 8, 1]]) == \"dpchohzlf\"\n assert candidate(s = \"abacabadabacaba\",shifts = [[0, 14, 1], [1, 13, 0], [2, 12, 1], [3, 11, 0], [4, 10, 1], [5, 9, 0]]) == \"bbbcbbadabbcbbb\"\n assert candidate(s = \"abcdefghij\",shifts = [[0, 4, 1], [5, 9, 0], [0, 4, 0], [5, 9, 1], [0, 9, 1]]) == \"bcdefghijk\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [1, 24, 0], [2, 23, 1], [3, 22, 0], [4, 21, 1]]) == \"bbddfghijklmnopqrstuvwwyya\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",shifts = [[0, 25, 0], [5, 10, 1], [15, 20, 0]]) == \"yxwvuutsrqpnmlkihgfeddcbaz\"\n assert candidate(s = \"zzzzz\",shifts = [[0, 4, 0], [0, 4, 0], [0, 4, 0], [0, 4, 0], [0, 4, 1]]) == \"wwwww\"\n assert candidate(s = \"abcdefghij\",shifts = [[0, 9, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1]]) == \"bbddfggiik\"\n assert candidate(s = \"abcdefghij\",shifts = [[0, 9, 1], [0, 9, 0], [0, 9, 1], [0, 9, 0], [0, 9, 1]]) == \"bcdefghijk\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",shifts = [[0, 25, 1], [5, 15, 0], [10, 20, 1]]) == \"aaaaazzzzzaaaaaabbbbbaaaaa\"\n assert candidate(s = \"abcdefghijklmnop\",shifts = [[0, 0, 1], [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]]) == \"bcdefghijklmnopq\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 12, 1], [13, 25, 0], [0, 25, 1], [0, 25, 0], [0, 25, 1]]) == \"cdefghijklmnonopqrstuvwxyz\"\n assert candidate(s = \"alibabacloud\",shifts = [[0, 9, 1], [2, 4, 0], [5, 7, 1], [8, 11, 0], [0, 3, 1], [6, 9, 0], [1, 8, 1], [2, 7, 0]]) == \"cojcadbdlntc\"\n assert candidate(s = \"xyz\",shifts = [[0, 2, 1], [0, 2, 1], [0, 2, 0], [0, 2, 0]]) == \"xyz\"\n assert candidate(s = \"abcdefg\",shifts = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1]]) == \"bdefghh\"\n assert candidate(s = \"abacabadabacaba\",shifts = [[0, 4, 1], [5, 9, 0], [10, 14, 1], [0, 14, 0], [0, 14, 1]]) == \"bcbdbazczabdbcb\"\n assert candidate(s = \"hello world\",shifts = [[0, 4, 1], [6, 10, 0], [3, 8, 1], [1, 9, 0], [0, 10, 1]]) == \"jfmnqoworkd\"\n assert candidate(s = \"example\",shifts = [[0, 6, 1], [1, 5, 0], [2, 4, 1], [3, 6, 0]]) == \"fxbmpke\"\n assert candidate(s = \"abcdefghij\",shifts = [[0, 9, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1], [5, 4, 0], [6, 3, 1], [7, 2, 0], [8, 1, 1], [9, 0, 0]]) == \"bcdefghijk\"\n assert candidate(s = \"abcdefg\",shifts = [[0, 6, 1], [1, 5, 0], [2, 4, 1], [3, 3, 0]]) == \"bbddffh\"\n assert candidate(s = \"hellozworld\",shifts = [[0, 4, 1], [5, 9, 0], [6, 10, 1], [7, 8, 0], [9, 10, 1], [10, 10, 0]]) == \"ifmmpywnqme\"\n assert candidate(s = \"abcde\",shifts = [[0, 2, 1], [3, 4, 0], [1, 3, 1], [0, 1, 0], [4, 4, 1], [2, 2, 0]]) == \"acdde\"\n assert candidate(s = \"xylophone\",shifts = [[0, 8, 1], [1, 7, 0], [2, 6, 1], [3, 5, 0], [4, 4, 1]]) == \"yymoqhpnf\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [0, 25, 0], [0, 25, 1], [0, 25, 0], [0, 25, 1]]) == \"bcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"programming\",shifts = [[0, 9, 1], [4, 8, 0], [2, 6, 1], [1, 7, 0], [0, 8, 1]]) == \"rsqisbnmjog\"\n assert candidate(s = \"shiftmeplease\",shifts = [[0, 1, 1], [2, 3, 0], [4, 5, 1], [6, 7, 0], [8, 9, 1], [10, 11, 0], [12, 12, 1]]) == \"tiheundomfzrf\"\n assert candidate(s = \"algorithms\",shifts = [[0, 9, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1], [5, 4, 0], [6, 3, 1], [7, 2, 0], [8, 1, 1], [9, 0, 0]]) == \"bmhpsjuint\"\n assert candidate(s = \"quickbrownfox\",shifts = [[0, 12, 1], [1, 11, 0], [2, 10, 1], [3, 9, 0], [4, 8, 1], [5, 7, 0]]) == \"rujclbroxngoy\"\n assert candidate(s = \"mnopqr\",shifts = [[0, 2, 1], [3, 5, 0], [0, 5, 1], [1, 4, 0]]) == \"oopopr\"\n assert candidate(s = \"abcdefghijklmnop\",shifts = [[0, 15, 1], [1, 14, 0], [2, 13, 1], [3, 12, 0], [4, 11, 1], [5, 10, 0], [6, 9, 1], [7, 8, 0]]) == \"bbddffhhikkmmooq\"\n assert candidate(s = \"zzzzzzzzzz\",shifts = [[0, 9, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1]]) == \"azazaazaza\"\n assert candidate(s = \"mississippi\",shifts = [[0, 4, 0], [1, 3, 1], [2, 2, 0], [3, 5, 1], [6, 8, 0], [7, 7, 1], [8, 10, 0], [9, 9, 1], [10, 10, 0]]) == \"lirtitrinpg\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 0, 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, 0], [10, 10, 0], [11, 11, 0], [12, 12, 0], [13, 13, 0], [14, 14, 0], [15, 15, 0], [16, 16, 0], [17, 17, 0], [18, 18, 0], [19, 19, 0], [20, 20, 0], [21, 21, 0], [22, 22, 0], [23, 23, 0], [24, 24, 1], [25, 25, 1]]) == \"zabcdefghijklmnopqrstuvwza\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [5, 15, 0], [10, 20, 1]]) == \"bcdeffghijlmnopqstuvwwxyza\"\n assert candidate(s = \"programming\",shifts = [[0, 8, 1], [3, 7, 0], [2, 5, 1], [4, 10, 0], [1, 9, 1]]) == \"qtrisbmmjnf\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 0, 1], [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], [19, 19, 1], [20, 20, 1], [21, 21, 1], [22, 22, 1], [23, 23, 1], [24, 24, 1], [25, 25, 1]]) == \"bcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"abcdefgh\",shifts = [[0, 0, 0], [7, 7, 1], [2, 2, 1], [5, 5, 0], [3, 3, 1]]) == \"zbdeeegi\"\n assert candidate(s = \"a\",shifts = [[0, 0, 1], [0, 0, 0], [0, 0, 1], [0, 0, 0]]) == \"a\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [0, 25, 1], [0, 25, 1], [0, 25, 1], [0, 25, 1]]) == \"fghijklmnopqrstuvwxyzabcde\"\n assert candidate(s = \"abcdefg\",shifts = [[0, 1, 0], [1, 2, 0], [2, 3, 0], [3, 4, 0], [4, 5, 0], [5, 6, 0]]) == \"zzabcdf\"\n assert candidate(s = \"mnopqr\",shifts = [[0, 0, 1], [1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0]]) == \"nmporq\"\n assert candidate(s = \"abcdefghij\",shifts = [[0, 4, 0], [5, 9, 1], [0, 9, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1]]) == \"aaccehhjjl\"\n assert candidate(s = \"abcdefghij\",shifts = [[0, 1, 1], [2, 3, 0], [4, 5, 1], [6, 7, 0], [8, 9, 1]]) == \"bcbcfgfgjk\"\n assert candidate(s = \"mississippi\",shifts = [[0, 2, 1], [2, 4, 0], [4, 6, 1], [6, 8, 0], [8, 10, 1]]) == \"njsritshpqj\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",shifts = [[0, 9, 1], [10, 19, 0], [20, 25, 1], [0, 19, 0], [10, 25, 1], [0, 25, 0], [0, 25, 1]]) == \"qwertyuiopzrcefgijkyzexdpo\"\n assert candidate(s = \"aaaabbbbcccc\",shifts = [[0, 3, 1], [4, 7, 0], [8, 11, 1], [0, 11, 1]]) == \"ccccbbbbeeee\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",shifts = [[0, 51, 1], [0, 51, 0], [0, 51, 1], [0, 51, 0], [0, 51, 1]]) == \"bbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaa\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",shifts = [[0, 13, 0], [13, 25, 1], [0, 25, 0], [0, 25, 1]]) == \"yxwvutsrqponmmmlkjihgfedcb\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",shifts = [[0, 25, 0], [0, 25, 0], [0, 25, 0], [0, 25, 0], [0, 25, 0]]) == \"utsrqponmlkjihgfedcbazyxwv\"\n assert candidate(s = \"shiftthis\",shifts = [[0, 0, 1], [1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1]]) == \"tgjeusiht\"\n assert candidate(s = \"abcd\",shifts = [[0, 3, 1], [0, 2, 0], [1, 3, 1], [1, 2, 0], [2, 3, 1]]) == \"abdg\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",shifts = [[0, 25, 1], [1, 24, 0], [2, 23, 1], [3, 22, 0]]) == \"bbddefghijklmnopqrstuvwyyaa\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 0, 1], [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], [19, 19, 1], [20, 20, 1], [21, 21, 1], [22, 22, 1], [23, 23, 1], [24, 24, 0], [25, 25, 0]]) == \"bcdefghijklmnopqrstuvwxyxy\"\n assert candidate(s = \"python\",shifts = [[0, 5, 1], [1, 4, 0], [2, 3, 1], [0, 5, 0], [1, 4, 1]]) == \"pyuion\"\n assert candidate(s = \"abcdefghij\",shifts = [[0, 0, 1], [1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1], [9, 9, 0]]) == \"badcfehgji\"\n assert candidate(s = \"zzzzzzzzzz\",shifts = [[0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1]]) == \"jjjjjjjjjj\"\n assert candidate(s = \"xyzxyzxyz\",shifts = [[0, 2, 1], [3, 5, 0], [6, 8, 1], [0, 5, 1], [3, 8, 0], [0, 8, 1]]) == \"abcxyzyza\"\n assert candidate(s = \"aaaabbbb\",shifts = [[0, 3, 1], [4, 7, 0], [2, 5, 1], [1, 6, 0]]) == \"babbaaza\"\n assert candidate(s = \"zzzzzzzz\",shifts = [[0, 7, 1], [1, 6, 0], [2, 5, 1], [3, 4, 0]]) == \"azazzaza\"\n assert candidate(s = \"abcdefghij\",shifts = [[0, 4, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1]]) == \"bbddfffhhj\"\n assert candidate(s = \"abcdabcdabcd\",shifts = [[0, 3, 1], [4, 7, 0], [8, 11, 1], [0, 11, 0], [0, 11, 1]]) == \"bcdezabcbcde\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 0], [1, 24, 0], [2, 23, 0], [3, 22, 0], [4, 21, 0], [5, 20, 0], [6, 19, 0], [7, 18, 0], [8, 17, 0], [9, 16, 0], [10, 15, 0], [11, 14, 0], [12, 13, 0], [13, 12, 1], [14, 11, 1], [15, 10, 1], [16, 9, 1], [17, 8, 1], [18, 7, 1], [19, 6, 1], [20, 5, 1], [21, 4, 1], [22, 3, 1], [23, 2, 1], [24, 1, 1], [25, 0, 1]]) == \"zyxwvutsrqponoruxadgjmpsvy\"\n assert candidate(s = \"zzzzzzzzzz\",shifts = [[0, 9, 1], [0, 9, 0], [1, 8, 1], [1, 8, 0], [2, 7, 1], [2, 7, 0], [3, 6, 1], [3, 6, 0], [4, 5, 1], [4, 5, 0]]) == \"zzzzzzzzzz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 0, 1], [1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1], [9, 9, 0], [10, 10, 1], [11, 11, 0], [12, 12, 1], [13, 13, 0], [14, 14, 1], [15, 15, 0], [16, 16, 1], [17, 17, 0], [18, 18, 1], [19, 19, 0], [20, 20, 1], [21, 21, 0], [22, 22, 1], [23, 23, 0], [24, 24, 1], [25, 25, 0]]) == \"badcfehgjilknmporqtsvuxwzy\"\n assert candidate(s = \"xyzabc\",shifts = [[0, 2, 1], [3, 5, 0], [1, 4, 1], [2, 5, 0], [0, 5, 1]]) == \"zbbabb\"\n assert candidate(s = \"programming\",shifts = [[0, 3, 1], [4, 8, 0], [6, 10, 1], [7, 9, 0], [1, 5, 1]]) == \"qtqiramlhnh\"\n"}, "metadata": {"canonical_parameter_names": ["s", "shifts"], "leetcode_dataset_entry_point": "Solution().shiftingLetters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String shiftingLetters(String s, int[][] shifts) {", "container": "Solution", "callable": "shiftingLetters", "parameters": [{"name": "s", "type": "String"}, {"name": "shifts", "type": "int[][]"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2382, "task_id": "maximum-segment-sum-after-removals", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums and removeQueries, both of length n. For the ith query, the element in nums at the index removeQueries[i] is removed, splitting nums into different segments.\nA segment is a contiguous sequence of positive integers in nums. A segment sum is the sum of every element in a segment.\nReturn an integer array answer, of length n, where answer[i] is the maximum segment sum after applying the ith removal.\nNote: The same index will not be removed more than once.\n \nExample 1:\n\nInput: nums = [1,2,5,6,1], removeQueries = [0,3,2,4,1]\nOutput: [14,7,2,2,0]\nExplanation: Using 0 to indicate a removed element, the answer is as follows:\nQuery 1: Remove the 0th element, nums becomes [0,2,5,6,1] and the maximum segment sum is 14 for segment [2,5,6,1].\nQuery 2: Remove the 3rd element, nums becomes [0,2,5,0,1] and the maximum segment sum is 7 for segment [2,5].\nQuery 3: Remove the 2nd element, nums becomes [0,2,0,0,1] and the maximum segment sum is 2 for segment [2]. \nQuery 4: Remove the 4th element, nums becomes [0,2,0,0,0] and the maximum segment sum is 2 for segment [2]. \nQuery 5: Remove the 1st element, nums becomes [0,0,0,0,0] and the maximum segment sum is 0, since there are no segments.\nFinally, we return [14,7,2,2,0].\nExample 2:\n\nInput: nums = [3,2,11,1], removeQueries = [3,2,1,0]\nOutput: [16,5,3,0]\nExplanation: Using 0 to indicate a removed element, the answer is as follows:\nQuery 1: Remove the 3rd element, nums becomes [3,2,11,0] and the maximum segment sum is 16 for segment [3,2,11].\nQuery 2: Remove the 2nd element, nums becomes [3,2,0,0] and the maximum segment sum is 5 for segment [3,2].\nQuery 3: Remove the 1st element, nums becomes [3,0,0,0] and the maximum segment sum is 3 for segment [3].\nQuery 4: Remove the 0th element, nums becomes [0,0,0,0] and the maximum segment sum is 0, since there are no segments.\nFinally, we return [16,5,3,0].\n\n \nConstraints:\n\nn == nums.length == removeQueries.length\n1 <= n <= 105\n1 <= nums[i] <= 109\n0 <= removeQueries[i] < n\nAll the values of removeQueries are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 5, 6, 1],removeQueries = [0, 3, 2, 4, 1]) == [14, 7, 2, 2, 0]\n assert candidate(nums = [5, 1, 4, 3, 2],removeQueries = [2, 0, 4, 1, 3]) == [6, 5, 3, 3, 0]\n assert candidate(nums = [1000000000, 1000000000, 1000000000],removeQueries = [0, 1, 2]) == [2000000000, 1000000000, 0]\n assert candidate(nums = [10, 20, 30, 40, 50],removeQueries = [4, 3, 2, 1, 0]) == [100, 60, 30, 10, 0]\n assert candidate(nums = [5, 1, 4, 3],removeQueries = [1, 2, 0, 3]) == [7, 5, 3, 0]\n assert candidate(nums = [3, 2, 11, 1],removeQueries = [3, 2, 1, 0]) == [16, 5, 3, 0]\n assert candidate(nums = [10, 20, 30, 40, 50],removeQueries = [0, 1, 2, 3, 4]) == [140, 120, 90, 50, 0]\n assert candidate(nums = [10, 20, 30, 40, 50],removeQueries = [2, 4, 0, 1, 3]) == [90, 40, 40, 40, 0]\n assert candidate(nums = [5, 2, 3, 1, 4],removeQueries = [2, 0, 4, 3, 1]) == [7, 5, 2, 2, 0]\n assert candidate(nums = [1, 1, 1, 1, 1],removeQueries = [0, 1, 2, 3, 4]) == [4, 3, 2, 1, 0]\n assert candidate(nums = [1000000000, 1000000000, 1000000000],removeQueries = [0, 1, 2]) == [2000000000, 1000000000, 0]\n assert candidate(nums = [5, 1, 3, 2, 4],removeQueries = [2, 0, 1, 3, 4]) == [6, 6, 6, 4, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],removeQueries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n assert candidate(nums = [5, 2, 3, 1, 4],removeQueries = [2, 0, 3, 4, 1]) == [7, 5, 4, 2, 0]\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9000000000, 8000000000, 7000000000, 6000000000, 5000000000, 4000000000, 3000000000, 2000000000, 1000000000, 0]\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000],removeQueries = [5, 4, 3, 2, 1, 0]) == [111110, 11110, 1110, 110, 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, 21, 22, 23, 24, 25],removeQueries = [24, 12, 6, 0, 2, 10, 14, 20, 22, 8, 16, 18, 4, 15, 11, 13, 7, 19, 17, 3, 5, 9, 1, 21, 23, 25]) == [300, 209, 209, 209, 209, 209, 180, 90, 90, 90, 57, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0]\n assert candidate(nums = [9, 1, 5, 3, 2, 4, 8, 6, 7, 10],removeQueries = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == [46, 36, 35, 28, 23, 17, 14, 6, 4, 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],removeQueries = [0, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [324, 299, 275, 252, 230, 209, 189, 170, 152, 135, 119, 104, 90, 77, 65, 54, 44, 35, 27, 20, 14, 9, 5, 2, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],removeQueries = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [5400, 4900, 4000, 2700, 1000, 1000, 1000, 1000, 1000, 0]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40],removeQueries = [3, 6, 0, 5, 1, 7, 2, 4]) == [130, 55, 55, 40, 40, 25, 25, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],removeQueries = [14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [105, 104, 102, 99, 95, 90, 84, 77, 69, 60, 50, 39, 27, 14, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [4, 2, 6, 8, 0, 1, 3, 5, 7, 9]) == [400, 400, 270, 100, 100, 100, 100, 100, 100, 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],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [380, 342, 306, 272, 240, 210, 182, 156, 132, 110, 90, 72, 56, 42, 30, 20, 12, 6, 2, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],removeQueries = [19, 0, 18, 1, 17, 2, 16, 3, 15, 4, 14, 5, 13, 6, 12, 7, 11, 8, 10, 9]) == [45, 45, 36, 36, 28, 28, 21, 21, 15, 15, 10, 10, 6, 6, 3, 3, 1, 1, 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],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],removeQueries = [14, 0, 7, 2, 9, 4, 12, 6, 11, 3, 8, 13, 5, 10, 1]) == [196, 195, 132, 132, 96, 96, 44, 44, 27, 27, 27, 21, 21, 3, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],removeQueries = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 3, 4, 0, 1]) == [65, 61, 58, 56, 55, 54, 52, 49, 45, 40, 40, 40, 40, 40, 40, 19, 19, 19, 9, 0]\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],removeQueries = [2, 0, 1, 3]) == [2000000000, 1000000000, 1000000000, 0]\n assert candidate(nums = [100, 200, 300, 400, 500],removeQueries = [4, 3, 2, 1, 0]) == [1000, 600, 300, 100, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [5, 2, 8, 0, 4, 7, 1, 9, 6, 3]) == [340, 340, 150, 150, 150, 100, 100, 70, 40, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [5, 2, 8, 1, 7, 4, 3, 9, 6, 0]) == [340, 340, 150, 150, 100, 100, 100, 70, 10, 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],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 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],removeQueries = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [190, 153, 120, 91, 66, 45, 28, 19, 19, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],removeQueries = [14, 1, 2, 12, 0, 3, 4, 13, 5, 6, 11, 7, 8, 9, 10]) == [10500, 10200, 9900, 7200, 7200, 6800, 6300, 6300, 5700, 5000, 3800, 3000, 2100, 1100, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],removeQueries = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 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],removeQueries = [19, 9, 18, 8, 17, 7, 16, 6, 15, 5, 14, 4, 13, 3, 12, 2, 11, 1, 10, 0]) == [1900, 1350, 1160, 1160, 980, 980, 810, 810, 650, 650, 500, 500, 360, 360, 230, 230, 110, 110, 10, 0]\n assert candidate(nums = [31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62, 64, 33, 83, 27, 95, 28, 84, 19, 71],removeQueries = [10, 18, 8, 12, 17, 19, 16, 7, 5, 0, 14, 2, 15, 9, 6, 13, 3, 4, 11, 1]) == [565, 565, 458, 458, 458, 458, 458, 365, 210, 205, 179, 97, 97, 97, 83, 79, 64, 64, 41, 0]\n assert candidate(nums = [2, 1, 3, 4, 2, 3, 4, 1, 5, 6, 7, 8, 9, 10],removeQueries = [1, 3, 5, 7, 9, 11, 13, 0, 2, 4, 6, 8, 10, 12]) == [62, 55, 50, 45, 34, 19, 9, 9, 9, 9, 9, 9, 9, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [540, 490, 400, 270, 100, 100, 100, 100, 100, 0]\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],removeQueries = [4, 2, 0, 3, 1]) == [10000000000, 4000000000, 4000000000, 2000000000, 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],removeQueries = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == [190, 153, 120, 91, 66, 45, 28, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [5, 3, 7, 1, 9, 4, 0, 6, 8, 2]) == [340, 340, 190, 190, 90, 90, 90, 90, 30, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],removeQueries = [4, 2, 6, 8, 0, 3, 5, 7, 9, 1]) == [4000, 4000, 2700, 1000, 1000, 1000, 1000, 1000, 200, 0]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [89, 85, 77, 74, 72, 69, 60, 53, 44, 39, 36, 31, 25, 23, 14, 9, 8, 4, 3, 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],removeQueries = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]) == [190, 153, 120, 91, 66, 45, 28, 19, 19, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],removeQueries = [2, 4, 6, 8, 10, 12, 14, 0, 1, 3, 5, 7, 9, 11, 13]) == [11400, 10500, 9200, 7500, 5400, 2900, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 0]\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],removeQueries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1996093750, 1992187500, 1984375000, 1968750000, 1937500000, 1875000000, 1750000000, 1500000000, 1000000000, 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],removeQueries = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [46, 39, 34, 31, 30, 28, 24, 18, 10, 0]\n assert candidate(nums = [5, 1, 4, 3, 9, 8, 7, 2, 6],removeQueries = [2, 5, 0, 3, 4, 8, 6, 7, 1]) == [35, 15, 15, 15, 15, 9, 2, 1, 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],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [4, 8, 3, 7, 2, 6, 1, 5, 0]) == [30, 30, 24, 24, 17, 17, 9, 9, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [45, 36, 28, 21, 15, 10, 6, 3, 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],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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],removeQueries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 132, 119, 105, 90, 74, 57, 39, 20, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [5, 7, 3, 1, 9, 0, 8, 6, 2, 4]) == [340, 190, 190, 190, 90, 90, 70, 50, 50, 0]\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],removeQueries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9000000000, 8000000000, 7000000000, 6000000000, 5000000000, 4000000000, 3000000000, 2000000000, 1000000000, 0]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],removeQueries = [5, 0, 4, 9, 2, 8, 6, 3, 7, 1]) == [25, 24, 22, 21, 16, 11, 10, 10, 10, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],removeQueries = [14, 1, 2, 12, 0, 3, 4, 13, 5, 6, 11, 7, 8, 9, 10]) == [105, 102, 99, 72, 72, 68, 63, 63, 57, 50, 38, 30, 21, 11, 0]\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],removeQueries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9000000000, 8000000000, 7000000000, 6000000000, 5000000000, 4000000000, 3000000000, 2000000000, 1000000000, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],removeQueries = [7, 14, 0, 13, 1, 12, 2, 11, 3, 10, 4, 9, 5, 8, 6]) == [840, 690, 690, 550, 550, 420, 420, 300, 300, 190, 190, 130, 90, 70, 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],removeQueries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == [90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1999996181, 1999992367, 1999984738, 1999969480, 1999938963, 1999877928, 1999755858, 1999511718, 1999023437, 1998046875, 1996093750, 1992187500, 1984375000, 1968750000, 1937500000, 1875000000, 1750000000, 1500000000, 1000000000, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],removeQueries = [11, 5, 3, 7, 9, 1, 8, 10, 4, 2, 6, 0]) == [6600, 4500, 4500, 3000, 1100, 1100, 1100, 700, 700, 700, 100, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == [36, 28, 21, 15, 10, 6, 3, 1, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 8, 1, 7, 2, 6, 3, 5, 4]) == [36, 35, 27, 25, 18, 15, 9, 5, 0]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],removeQueries = [0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13]) == [54, 50, 44, 37, 29, 20, 10, 5, 5, 5, 5, 5, 5, 5, 0]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115],removeQueries = [7, 15, 3, 11, 13, 5, 9, 1, 12, 14, 8, 10, 6, 2, 4, 0]) == [892, 777, 777, 339, 327, 327, 303, 114, 114, 110, 110, 106, 104, 104, 100, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],removeQueries = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],removeQueries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 8, 1, 7, 2, 6, 3, 5, 4]) == [36, 35, 27, 25, 18, 15, 9, 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],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n assert candidate(nums = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [209, 206, 204, 199, 195, 189, 182, 174, 165, 155, 144, 132, 119, 105, 90, 74, 57, 39, 20, 0]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],removeQueries = [15, 10, 5, 0, 19, 14, 9, 4, 18, 13, 8, 3, 17, 12, 7, 2, 16, 11, 6, 1]) == [120, 74, 74, 74, 54, 54, 54, 54, 39, 35, 35, 35, 25, 17, 17, 17, 12, 7, 4, 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],removeQueries = [10, 5, 15, 2, 18, 8, 0, 17, 3, 14, 9, 11, 7, 1, 12, 6, 13, 4, 16, 19]) == [10, 9, 5, 4, 4, 4, 4, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],removeQueries = [10, 2, 16, 14, 18, 6, 8, 12, 4, 1, 13, 7, 15, 3, 9, 19, 11, 5, 17, 0]) == [47, 47, 31, 31, 31, 17, 17, 15, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 0]\n assert candidate(nums = [7, 2, 5, 4, 6, 3, 9, 8, 1, 0, 8, 1, 0, 8, 1, 0, 8, 1, 0, 8],removeQueries = [15, 11, 5, 13, 3, 19, 9, 17, 7, 1, 0, 12, 4, 8, 16, 2, 14, 6, 10, 18]) == [54, 53, 26, 26, 26, 26, 18, 18, 14, 9, 9, 9, 9, 9, 9, 9, 9, 8, 0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [5, 7, 9, 1, 3, 8, 2, 6, 4, 0]) == [340, 190, 150, 120, 90, 70, 70, 50, 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],removeQueries = [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, 0]) == [435, 406, 378, 351, 325, 300, 276, 253, 231, 210, 190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],removeQueries = [7, 3, 9, 13, 5, 11, 1, 6, 2, 14, 8, 0, 12, 10, 4]) == [840, 840, 650, 360, 360, 150, 150, 150, 150, 130, 130, 130, 110, 50, 0]\n assert candidate(nums = [5, 2, 3, 1, 4, 6, 8, 7, 9, 10],removeQueries = [4, 0, 3, 2, 5, 1, 8, 9, 7, 6]) == [40, 40, 40, 40, 34, 34, 15, 15, 8, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 2, 4, 6, 8, 1, 3, 5, 7]) == [36, 21, 10, 8, 8, 6, 4, 2, 0]\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],removeQueries = [0, 1, 2, 3, 4]) == [4000000000, 3000000000, 2000000000, 1000000000, 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],removeQueries = [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, 0]) == [1225, 1176, 1128, 1081, 1035, 990, 946, 903, 861, 820, 780, 741, 703, 666, 630, 595, 561, 528, 496, 465, 435, 406, 378, 351, 325, 300, 276, 253, 231, 210, 190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [4, 2, 7, 5, 8, 1, 0, 9, 3, 6]) == [400, 400, 190, 190, 100, 100, 100, 70, 70, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],removeQueries = [5, 7, 3, 9, 1, 6, 0, 8, 2, 4]) == [64, 36, 36, 17, 17, 17, 17, 9, 9, 0]\n"}, "metadata": {"canonical_parameter_names": ["nums", "removeQueries"], "leetcode_dataset_entry_point": "Solution().maximumSegmentSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long[] maximumSegmentSum(int[] nums, int[] removeQueries) {", "container": "Solution", "callable": "maximumSegmentSum", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "removeQueries", "type": "int[]"}], "return_type": "long[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2383, "task_id": "minimum-hours-of-training-to-win-a-competition", "difficulty": "Easy", "problem_description": "You are entering a competition, and are given two positive integers initialEnergy and initialExperience denoting your initial energy and initial experience respectively.\nYou are also given two 0-indexed integer arrays energy and experience, both of length n.\nYou will face n opponents in order. The energy and experience of the ith opponent is denoted by energy[i] and experience[i] respectively. When you face an opponent, you need to have both strictly greater experience and energy to defeat them and move to the next opponent if available.\nDefeating the ith opponent increases your experience by experience[i], but decreases your energy by energy[i].\nBefore starting the competition, you can train for some number of hours. After each hour of training, you can either choose to increase your initial experience by one, or increase your initial energy by one.\nReturn the minimum number of training hours required to defeat all n opponents.\n \nExample 1:\n\nInput: initialEnergy = 5, initialExperience = 3, energy = [1,4,3,2], experience = [2,6,3,1]\nOutput: 8\nExplanation: You can increase your energy to 11 after 6 hours of training, and your experience to 5 after 2 hours of training.\nYou face the opponents in the following order:\n- You have more energy and experience than the 0th opponent so you win.\n Your energy becomes 11 - 1 = 10, and your experience becomes 5 + 2 = 7.\n- You have more energy and experience than the 1st opponent so you win.\n Your energy becomes 10 - 4 = 6, and your experience becomes 7 + 6 = 13.\n- You have more energy and experience than the 2nd opponent so you win.\n Your energy becomes 6 - 3 = 3, and your experience becomes 13 + 3 = 16.\n- You have more energy and experience than the 3rd opponent so you win.\n Your energy becomes 3 - 2 = 1, and your experience becomes 16 + 1 = 17.\nYou did a total of 6 + 2 = 8 hours of training before the competition, so we return 8.\nIt can be proven that no smaller answer exists.\n\nExample 2:\n\nInput: initialEnergy = 2, initialExperience = 4, energy = [1], experience = [3]\nOutput: 0\nExplanation: You do not need any additional energy or experience to win the competition, so we return 0.\n\n \nConstraints:\n\nn == energy.length == experience.length\n1 <= n <= 100\n1 <= initialEnergy, initialExperience, energy[i], experience[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 50],experience = [50, 50]) == 52\n assert candidate(initialEnergy = 5,initialExperience = 3,energy = [1, 4, 3, 2],experience = [2, 6, 3, 1]) == 8\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [100],experience = [100]) == 200\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 25, 25],experience = [50, 25, 25]) == 1\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30],experience = [10, 20, 30]) == 11\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [100],experience = [100]) == 2\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 50],experience = [50, 50]) == 1\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 0\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(initialEnergy = 2,initialExperience = 4,energy = [1],experience = [3]) == 0\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 5\n assert candidate(initialEnergy = 99,initialExperience = 99,energy = [100],experience = [100]) == 4\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],experience = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 71\n assert candidate(initialEnergy = 50,initialExperience = 25,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(initialEnergy = 30,initialExperience = 25,energy = [10, 15, 20, 5, 10],experience = [20, 15, 10, 25, 15]) == 31\n assert candidate(initialEnergy = 40,initialExperience = 40,energy = [20, 20, 20, 20],experience = [20, 20, 20, 20]) == 41\n assert candidate(initialEnergy = 30,initialExperience = 20,energy = [10, 20, 30, 40, 50],experience = [1, 2, 3, 4, 5]) == 121\n assert candidate(initialEnergy = 15,initialExperience = 8,energy = [7, 7, 7, 7, 7, 7],experience = [6, 6, 6, 6, 6, 6]) == 28\n assert candidate(initialEnergy = 70,initialExperience = 40,energy = [5, 15, 25, 35, 45],experience = [45, 35, 25, 15, 5]) == 62\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],experience = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 135\n assert candidate(initialEnergy = 2,initialExperience = 2,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(initialEnergy = 20,initialExperience = 25,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(initialEnergy = 10,initialExperience = 5,energy = [5, 6, 7, 8],experience = [1, 2, 3, 4]) == 17\n assert candidate(initialEnergy = 20,initialExperience = 5,energy = [10, 15, 5, 20],experience = [3, 7, 10, 2]) == 31\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30, 40],experience = [5, 15, 25, 35]) == 51\n assert candidate(initialEnergy = 40,initialExperience = 25,energy = [10, 15, 10, 20, 15, 25],experience = [25, 20, 15, 10, 25, 20]) == 57\n assert candidate(initialEnergy = 30,initialExperience = 30,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],experience = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 181\n assert candidate(initialEnergy = 10,initialExperience = 20,energy = [1, 3, 5, 7, 9],experience = [9, 7, 5, 3, 1]) == 16\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 51\n assert candidate(initialEnergy = 50,initialExperience = 30,energy = [40, 35, 20, 10, 5],experience = [25, 20, 15, 10, 5]) == 61\n assert candidate(initialEnergy = 70,initialExperience = 30,energy = [20, 10, 30, 5, 20],experience = [15, 25, 10, 20, 5]) == 16\n assert candidate(initialEnergy = 20,initialExperience = 15,energy = [10, 20, 30],experience = [5, 15, 25]) == 41\n assert candidate(initialEnergy = 1,initialExperience = 10,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9],experience = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(initialEnergy = 20,initialExperience = 15,energy = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],experience = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5]) == 76\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [25, 25, 25, 25],experience = [20, 20, 20, 20]) == 51\n assert candidate(initialEnergy = 15,initialExperience = 10,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 42\n assert candidate(initialEnergy = 25,initialExperience = 15,energy = [8, 7, 6, 5, 4, 3, 2, 1],experience = [1, 2, 3, 4, 5, 6, 7, 8]) == 12\n assert candidate(initialEnergy = 5,initialExperience = 5,energy = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],experience = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 26\n assert candidate(initialEnergy = 10,initialExperience = 15,energy = [3, 2, 6, 1],experience = [8, 4, 2, 7]) == 3\n assert candidate(initialEnergy = 20,initialExperience = 25,energy = [10, 10, 10, 10],experience = [25, 26, 27, 28]) == 22\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 15, 25, 35],experience = [30, 20, 10, 5]) == 92\n assert candidate(initialEnergy = 30,initialExperience = 30,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 47\n assert candidate(initialEnergy = 30,initialExperience = 50,energy = [10, 20, 30],experience = [25, 20, 15]) == 31\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],experience = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 91\n assert candidate(initialEnergy = 15,initialExperience = 20,energy = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2]) == 46\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [20, 30, 40, 50, 60, 70, 80, 90, 100],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 441\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [10, 20, 30, 40, 50],experience = [1, 2, 3, 4, 5]) == 141\n assert candidate(initialEnergy = 25,initialExperience = 25,energy = [20, 15, 10, 5],experience = [5, 10, 15, 20]) == 26\n assert candidate(initialEnergy = 30,initialExperience = 20,energy = [15, 25, 10],experience = [10, 15, 25]) == 21\n assert candidate(initialEnergy = 50,initialExperience = 30,energy = [10, 20, 15, 25],experience = [5, 25, 20, 30]) == 21\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [99, 98, 97, 96, 95],experience = [95, 96, 97, 98, 99]) == 580\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [10, 20, 30, 40],experience = [40, 30, 20, 10]) == 140\n assert candidate(initialEnergy = 10,initialExperience = 5,energy = [3, 2, 6, 1],experience = [5, 4, 3, 2]) == 4\n assert candidate(initialEnergy = 5,initialExperience = 5,energy = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],experience = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 26\n assert candidate(initialEnergy = 5,initialExperience = 5,energy = [1, 2, 3, 4, 5],experience = [5, 4, 3, 2, 1]) == 12\n assert candidate(initialEnergy = 60,initialExperience = 30,energy = [20, 20, 20, 20, 20],experience = [20, 20, 20, 20, 20]) == 41\n assert candidate(initialEnergy = 75,initialExperience = 40,energy = [40, 30, 20, 10, 5],experience = [50, 40, 30, 20, 10]) == 42\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [25, 10, 10, 5],experience = [20, 25, 30, 10]) == 1\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],experience = [51, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == 408\n assert candidate(initialEnergy = 10,initialExperience = 5,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 52\n assert candidate(initialEnergy = 20,initialExperience = 10,energy = [25, 15, 5, 10, 20],experience = [30, 20, 10, 5, 15]) == 77\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],experience = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 947\n assert candidate(initialEnergy = 1,initialExperience = 100,energy = [0, 0, 0, 0],experience = [99, 98, 97, 96]) == 0\n assert candidate(initialEnergy = 30,initialExperience = 30,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 26\n assert candidate(initialEnergy = 5,initialExperience = 3,energy = [1, 2, 3, 4, 5],experience = [5, 4, 3, 2, 1]) == 14\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 6, 7, 8],experience = [15, 14, 13, 12]) == 23\n assert candidate(initialEnergy = 80,initialExperience = 60,energy = [15, 20, 25, 30, 35],experience = [65, 70, 75, 80, 85]) == 52\n assert candidate(initialEnergy = 40,initialExperience = 30,energy = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],experience = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 61\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 30, 20],experience = [20, 30, 50]) == 1\n assert candidate(initialEnergy = 25,initialExperience = 25,energy = [13, 14, 15, 16, 17],experience = [17, 16, 15, 14, 13]) == 51\n assert candidate(initialEnergy = 30,initialExperience = 30,energy = [29, 28, 27, 26, 25],experience = [25, 26, 27, 28, 29]) == 106\n assert candidate(initialEnergy = 20,initialExperience = 20,energy = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 31\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 25, 12, 6, 3, 1],experience = [1, 3, 6, 12, 25, 50]) == 0\n assert candidate(initialEnergy = 80,initialExperience = 70,energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 471\n assert candidate(initialEnergy = 100,initialExperience = 1,energy = [99, 99, 99],experience = [98, 97, 96]) == 296\n assert candidate(initialEnergy = 10,initialExperience = 15,energy = [3, 4, 5, 6, 7],experience = [5, 6, 7, 8, 9]) == 16\n assert candidate(initialEnergy = 20,initialExperience = 10,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 37\n assert candidate(initialEnergy = 50,initialExperience = 20,energy = [25, 25, 25, 25],experience = [15, 15, 15, 15]) == 51\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30, 40],experience = [40, 30, 20, 10]) == 51\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],experience = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 212\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 40, 30, 20, 10],experience = [10, 20, 30, 40, 50]) == 51\n assert candidate(initialEnergy = 60,initialExperience = 25,energy = [20, 20, 20, 20],experience = [15, 25, 35, 45]) == 21\n assert candidate(initialEnergy = 60,initialExperience = 40,energy = [10, 20, 30, 40],experience = [40, 30, 20, 10]) == 42\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30, 40],experience = [45, 35, 25, 15]) == 51\n assert candidate(initialEnergy = 3,initialExperience = 4,energy = [2, 5, 7, 8],experience = [5, 3, 6, 10]) == 22\n assert candidate(initialEnergy = 50,initialExperience = 10,energy = [30, 20, 10, 5, 25],experience = [15, 25, 5, 10, 30]) == 47\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [99, 1, 1],experience = [1, 99, 1]) == 199\n assert candidate(initialEnergy = 20,initialExperience = 20,energy = [10, 20, 30, 40],experience = [15, 15, 15, 15]) == 81\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [99, 99, 99, 99],experience = [99, 99, 99, 99]) == 297\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [90, 80, 70, 60, 50, 40, 30, 20, 10],experience = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 459\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [25, 25, 25, 25],experience = [20, 30, 20, 30]) == 51\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [10, 10, 10, 10],experience = [11, 12, 13, 14]) == 33\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [10, 20, 30, 40, 50],experience = [50, 40, 30, 20, 10]) == 200\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 3, 2, 4, 5, 3, 2, 1],experience = [2, 1, 3, 2, 1, 4, 3, 2]) == 23\n assert candidate(initialEnergy = 100,initialExperience = 1,energy = [98, 1, 0, 0, 0],experience = [98, 1, 0, 0, 0]) == 98\n assert candidate(initialEnergy = 30,initialExperience = 25,energy = [5, 15, 25, 35, 45],experience = [40, 35, 30, 25, 20]) == 112\n assert candidate(initialEnergy = 20,initialExperience = 10,energy = [5, 10, 15, 20],experience = [8, 6, 4, 2]) == 31\n assert candidate(initialEnergy = 50,initialExperience = 30,energy = [10, 20, 30, 40],experience = [20, 30, 40, 50]) == 51\n assert candidate(initialEnergy = 15,initialExperience = 20,energy = [3, 3, 3, 3, 3],experience = [1, 2, 3, 4, 5]) == 1\n assert candidate(initialEnergy = 10,initialExperience = 50,energy = [25, 25, 25, 25],experience = [51, 52, 53, 54]) == 93\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [10, 20, 30],experience = [30, 20, 10]) == 90\n assert candidate(initialEnergy = 50,initialExperience = 100,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 2, 3, 4, 5],experience = [1, 2, 3, 4, 5]) == 16\n assert candidate(initialEnergy = 30,initialExperience = 15,energy = [5, 10, 15, 20, 25],experience = [10, 15, 20, 25, 30]) == 46\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [25, 25, 25, 25],experience = [25, 25, 25, 25]) == 51\n assert candidate(initialEnergy = 60,initialExperience = 60,energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],experience = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 532\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 5, 5, 5],experience = [5, 5, 5, 5]) == 11\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 56\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30],experience = [15, 25, 35]) == 11\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 5, 5, 5, 5],experience = [1, 2, 3, 4, 5]) == 16\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 1, 1],experience = [1, 1, 1]) == 4\n assert candidate(initialEnergy = 1,initialExperience = 100,energy = [1, 1, 1],experience = [1, 1, 1]) == 3\n assert candidate(initialEnergy = 1,initialExperience = 50,energy = [50, 50, 50, 50],experience = [1, 1, 1, 1]) == 200\n assert candidate(initialEnergy = 100,initialExperience = 1,energy = [100],experience = [1]) == 2\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 25, 25],experience = [50, 25, 25]) == 1\n assert candidate(initialEnergy = 5,initialExperience = 5,energy = [2, 3, 4],experience = [4, 3, 2]) == 5\n assert candidate(initialEnergy = 30,initialExperience = 30,energy = [10, 20, 10],experience = [5, 15, 10]) == 11\n assert candidate(initialEnergy = 15,initialExperience = 15,energy = [5, 5, 5],experience = [5, 5, 5]) == 1\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30, 40],experience = [10, 20, 30, 40]) == 51\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 50],experience = [50, 50]) == 52\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 5\n assert candidate(initialEnergy = 20,initialExperience = 20,energy = [5, 5, 5, 5, 5],experience = [5, 5, 5, 5, 5]) == 6\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 40, 30],experience = [30, 40, 50]) == 71\n assert candidate(initialEnergy = 50,initialExperience = 1,energy = [25, 25, 25],experience = [25, 25, 25]) == 51\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [5, 4, 3, 2, 1],experience = [1, 2, 3, 4, 5]) == 16\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [10, 10, 10],experience = [10, 10, 10]) == 22\n assert candidate(initialEnergy = 50,initialExperience = 1,energy = [1, 1, 1, 1],experience = [50, 50, 50, 50]) == 50\n assert candidate(initialEnergy = 1,initialExperience = 100,energy = [1],experience = [100]) == 2\n assert candidate(initialEnergy = 20,initialExperience = 20,energy = [10, 10, 10],experience = [10, 10, 10]) == 11\n assert candidate(initialEnergy = 100,initialExperience = 1,energy = [99, 98, 97],experience = [97, 98, 99]) == 292\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 10, 10, 10, 10],experience = [10, 10, 10, 10, 10]) == 1\n assert candidate(initialEnergy = 1,initialExperience = 100,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 4\n assert candidate(initialEnergy = 5,initialExperience = 5,energy = [3, 2, 1],experience = [1, 2, 3]) == 2\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(initialEnergy = 5,initialExperience = 5,energy = [10, 10, 10],experience = [10, 10, 10]) == 32\n assert candidate(initialEnergy = 30,initialExperience = 10,energy = [10, 10, 10],experience = [5, 5, 5]) == 1\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 2, 3, 4, 5],experience = [5, 4, 3, 2, 1]) == 6\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [25, 25, 25, 25],experience = [25, 25, 25, 25]) == 51\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 2, 3, 4, 5],experience = [5, 4, 3, 2, 1]) == 6\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],experience = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30],experience = [15, 25, 35]) == 11\n assert candidate(initialEnergy = 10,initialExperience = 1,energy = [2, 3, 4, 5],experience = [3, 4, 5, 6]) == 8\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [10, 20, 30],experience = [30, 20, 10]) == 0\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 30],experience = [40, 60]) == 0\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 5, 5, 5],experience = [5, 5, 5, 5]) == 11\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 2, 3],experience = [1, 2, 3]) == 7\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 0\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [10, 9, 8, 7],experience = [7, 8, 9, 10]) == 25\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 25, 25],experience = [50, 25, 25]) == 52\n assert candidate(initialEnergy = 3,initialExperience = 3,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 2\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 50, 50],experience = [50, 50, 50]) == 102\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 50, 50],experience = [30, 30, 30]) == 51\n assert candidate(initialEnergy = 20,initialExperience = 20,energy = [10, 10],experience = [10, 10]) == 1\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [10, 10, 10],experience = [10, 10, 10]) == 22\n assert candidate(initialEnergy = 10,initialExperience = 1,energy = [10, 10, 10],experience = [1, 1, 1]) == 22\n assert candidate(initialEnergy = 30,initialExperience = 10,energy = [15, 15, 15],experience = [5, 5, 5]) == 16\n assert candidate(initialEnergy = 60,initialExperience = 50,energy = [30, 20, 10],experience = [10, 20, 30]) == 1\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30],experience = [5, 15, 25]) == 11\n assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 40, 30],experience = [10, 20, 30]) == 21\n assert candidate(initialEnergy = 3,initialExperience = 3,energy = [1, 1, 3, 3],experience = [3, 3, 1, 1]) == 7\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30],experience = [5, 15, 25]) == 11\n assert candidate(initialEnergy = 1,initialExperience = 50,energy = [25, 25, 25],experience = [25, 25, 25]) == 75\n assert candidate(initialEnergy = 100,initialExperience = 1,energy = [1, 1, 1],experience = [1, 1, 1]) == 1\n assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50],experience = [50]) == 2\n assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 5, 5],experience = [5, 5, 5]) == 6\n"}, "metadata": {"canonical_parameter_names": ["initialEnergy", "initialExperience", "energy", "experience"], "leetcode_dataset_entry_point": "Solution().minNumberOfHours", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {", "container": "Solution", "callable": "minNumberOfHours", "parameters": [{"name": "initialEnergy", "type": "int"}, {"name": "initialExperience", "type": "int"}, {"name": "energy", "type": "int[]"}, {"name": "experience", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2384, "task_id": "largest-palindromic-number", "difficulty": "Medium", "problem_description": "You are given a string num consisting of digits only.\nReturn the largest palindromic integer (in the form of a string) that can be formed using digits taken from num. It should not contain leading zeroes.\nNotes:\n\nYou do not need to use all the digits of num, but you must use at least one digit.\nThe digits can be reordered.\n\n \nExample 1:\n\nInput: num = \"444947137\"\nOutput: \"7449447\"\nExplanation: \nUse the digits \"4449477\" from \"444947137\" to form the palindromic integer \"7449447\".\nIt can be shown that \"7449447\" is the largest palindromic integer that can be formed.\n\nExample 2:\n\nInput: num = \"00009\"\nOutput: \"9\"\nExplanation: \nIt can be shown that \"9\" is the largest palindromic integer that can be formed.\nNote that the integer returned should not contain leading zeroes.\n\n \nConstraints:\n\n1 <= num.length <= 105\nnum consists of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"1111\") == \"1111\"\n assert candidate(num = \"00000\") == \"0\"\n assert candidate(num = \"10\") == \"1\"\n assert candidate(num = \"9\") == \"9\"\n assert candidate(num = \"1111111111\") == \"1111111111\"\n assert candidate(num = \"00009\") == \"9\"\n assert candidate(num = \"000\") == \"0\"\n assert candidate(num = \"220022\") == \"220022\"\n assert candidate(num = \"1\") == \"1\"\n assert candidate(num = \"55555\") == \"55555\"\n assert candidate(num = \"12345678987654321\") == \"87654321912345678\"\n assert candidate(num = \"9876543210\") == \"9\"\n assert candidate(num = \"0\") == \"0\"\n assert candidate(num = \"444947137\") == \"7449447\"\n assert candidate(num = \"22\") == \"22\"\n assert candidate(num = \"123321\") == \"321123\"\n assert candidate(num = \"1234567890\") == \"9\"\n assert candidate(num = \"9876543210000000000\") == \"9\"\n assert candidate(num = \"1001\") == \"1001\"\n assert candidate(num = \"987654321111111111111111111111111111111111111111111987654321\") == \"987654321111111111111111111111111111111111111111111123456789\"\n assert candidate(num = \"1001001001001001\") == \"1110000000000111\"\n assert candidate(num = \"123456789987654321123456789987654321\") == \"998877665544332211112233445566778899\"\n assert candidate(num = \"12345543211234554321\") == \"55443322111122334455\"\n assert candidate(num = \"98765432109876543210\") == \"98765432100123456789\"\n assert candidate(num = \"1000000000000000000000001\") == \"1000000000000000000000001\"\n assert candidate(num = \"900000000000000000000000000000009\") == \"900000000000000000000000000000009\"\n assert candidate(num = \"33330000000000000000000\") == \"33000000000000000000033\"\n assert candidate(num = \"0987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210\") == \"99998888777766665555444433332222111100000900000111122223333444455556666777788889999\"\n assert candidate(num = \"5555555555555555555\") == \"5555555555555555555\"\n assert candidate(num = \"101010101010101010101010101010101010101010101010101010101010101010101010101010101\") == \"111111111111111111110000000000000000000010000000000000000000011111111111111111111\"\n assert candidate(num = \"1111100000111110000011111\") == \"1111111000001000001111111\"\n assert candidate(num = \"11000011\") == \"11000011\"\n assert candidate(num = \"123455432109876567890\") == \"987654321050123456789\"\n assert candidate(num = \"999999999999999999999999999\") == \"999999999999999999999999999\"\n assert candidate(num = \"10000000000000000000000000000000000000000000000000000000000000000000000000001\") == \"10000000000000000000000000000000000000000000000000000000000000000000000000001\"\n assert candidate(num = \"090090090\") == \"900090009\"\n assert candidate(num = \"111122223333444455556666777788889999\") == \"998877665544332211112233445566778899\"\n assert candidate(num = \"1234567898765432100000000000000000000000000000000000000000000000000000000000000000\") == \"876543210000000000000000000000000000000090000000000000000000000000000000012345678\"\n assert candidate(num = \"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009\") == \"9\"\n assert candidate(num = \"123321456654123321\") == \"654332211112233456\"\n assert candidate(num = \"543210987654321098765432109876543210\") == \"987655443322110090011223344556789\"\n assert candidate(num = \"00000000000000000000000000000000000000000000000000000000000000000000000000009\") == \"9\"\n assert candidate(num = \"101010101010101010101010101010101\") == \"111111110000000010000000011111111\"\n assert candidate(num = \"1234567890987654321\") == \"9876543210123456789\"\n assert candidate(num = \"0000000001000000000\") == \"1\"\n assert candidate(num = \"111222333444555666777888999\") == \"9876543219123456789\"\n assert candidate(num = \"987654321234567890000000\") == \"98765432000100023456789\"\n assert candidate(num = \"987654321234567890\") == \"98765432123456789\"\n assert candidate(num = \"122111221\") == \"221111122\"\n assert candidate(num = \"908070605040302010\") == \"9\"\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().largestPalindromic", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String largestPalindromic(String num) {", "container": "Solution", "callable": "largestPalindromic", "parameters": [{"name": "num", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2385, "task_id": "amount-of-time-for-binary-tree-to-be-infected", "difficulty": "Medium", "problem_description": "You are given the root of a binary tree with unique values, and an integer start. At minute 0, an infection starts from the node with value start.\nEach minute, a node becomes infected if:\n\nThe node is currently uninfected.\nThe node is adjacent to an infected node.\n\nReturn the number of minutes needed for the entire tree to be infected.\n \nExample 1:\n\n\nInput: root = [1,5,3,null,4,10,6,9,2], start = 3\nOutput: 4\nExplanation: The following nodes are infected during:\n- Minute 0: Node 3\n- Minute 1: Nodes 1, 10 and 6\n- Minute 2: Node 5\n- Minute 3: Node 4\n- Minute 4: Nodes 9 and 2\nIt takes 4 minutes for the whole tree to be infected so we return 4.\n\nExample 2:\n\n\nInput: root = [1], start = 1\nOutput: 0\nExplanation: At minute 0, the only node in the tree is infected so we return 0.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 105].\n1 <= Node.val <= 105\nEach node has a unique value.\nA node with a value of start exists in the tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5]),start = 4) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5]),start = 3) == 2\n assert candidate(root = tree_node([2, 1, 3]),start = 1) == 2\n assert candidate(root = tree_node([1]),start = 1) == 0\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5]),start = 3) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),start = 3) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),start = 2) == 3\n assert candidate(root = tree_node([1, 5, 3, None, 4, 10, 6, 9, 2]),start = 3) == 4\n assert candidate(root = tree_node([3, 1, 4, None, 2]),start = 2) == 3\n assert candidate(root = tree_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, None, None, None, 31, None, None, None, None, None, None, None, None, None, None, None, None, None, 32, None, None, None, 33, None, None, None, 34, None, None, None, 35]),start = 17) == 9\n assert candidate(root = tree_node([7, 1, 4, 2, 5, None, None, None, None, 3, 6, 8, 9, 10]),start = 4) == 5\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, None, None, 6, 7, None, None, None, None, 8, 9]),start = 3) == 2\n assert candidate(root = tree_node([1, 5, 3, None, 4, 10, 6, 9, 2, 7, None, 11, None, None, 8, None, None, None, None, None, 12]),start = 3) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),start = 8) == 6\n assert candidate(root = tree_node([10, 5, 15, 3, 8, None, 20, 1, 4, 6, 9, None, None, 11, 13, None, None, 12, 14, None, None, None, None]),start = 13) == 6\n assert candidate(root = tree_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]),start = 12) == 7\n assert candidate(root = tree_node([3, 1, 4, None, 2, None, None, None, None, None, 5]),start = 5) == 0\n assert candidate(root = tree_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]),start = 16) == 8\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30, None, 31, None, 32, None, 33, None, 34, None, 35]),start = 20) == 19\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),start = 7) == 6\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, None, 6, 7, 8, 9, None, None, 10, 11]),start = 4) == 7\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, None, 6, None, None, 14, None, None, None, 8, None, None, None, 9, 11, None, 12, None, None, 13, None, 16, None, 17, 19, None, 20, 21]),start = 10) == 5\n assert candidate(root = tree_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]),start = 15) == 7\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, None, None, 7, None, None, None, 8, 9, None, None, 10, 11]),start = 1) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, 8, 9, 10, 11, 12, None, None, 13, 14, 15, 16, 17, 18, 19, 20]),start = 10) == 6\n assert candidate(root = tree_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]),start = 13) == 7\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4]),start = 5) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),start = 7) == 5\n assert candidate(root = tree_node([1, 5, 3, None, 4, 10, 6, 9, 2, None, None, None, None, None, 7, 8]),start = 3) == 5\n assert candidate(root = tree_node([3, 1, 4, None, 2, None, None, 5, 6]),start = 5) == 4\n assert candidate(root = tree_node([20, 15, 25, 10, 18, 23, 27, 5, 12, None, 19, 22, 24, 26, 28]),start = 23) == 5\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, 4, 6, 9, None, None, 19]),start = 10) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, 7, None, None, None, None, 8, 9, 10, 11, 12, None, None, 13, 14, 15, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),start = 15) == 12\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9]),start = 3) == 6\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20]),start = 20) == 19\n assert candidate(root = tree_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]),start = 25) == 9\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11]),start = 6) == 4\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11, None, None, 12, 13, None, None, 14, 15]),start = 10) == 6\n assert candidate(root = tree_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]),start = 15) == 7\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, 8, 9, 10, None, None, 11, 12, None, 13, None, None, 14]),start = 6) == 6\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9]),start = 5) == 4\n assert candidate(root = tree_node([8, 5, 12, 4, 6, 11, 13, None, None, 7, 9, None, None, 10, 14]),start = 8) == 3\n assert candidate(root = tree_node([5, 4, 6, None, 3, None, 7, None, 2, None, None, None, None, 8, None]),start = 4) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, 7, None, 8, 9, None, None, 10, None]),start = 5) == 6\n assert candidate(root = tree_node([1, 5, 3, None, 4, 10, 6, 9, 2, 7, None, 8, None, 11, 12]),start = 3) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),start = 4) == 9\n assert candidate(root = tree_node([2, 1, 4, 3, None, None, 5, None, 6, None, 7, None, None, None, None, None, 8]),start = 1) == 4\n assert candidate(root = tree_node([7, 5, 8, None, 6, None, 9, None, None, None, 10, 11, 12, None, None, None, None, None, None, None, None, 13, 14, 15]),start = 6) == 6\n assert candidate(root = tree_node([3, 1, 2, None, None, None, None, 4, None, None, 5, None, None, 6, None, None, 7, None, None, 8]),start = 2) == 2\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19]),start = 10) == 9\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18]),start = 3) == 4\n assert candidate(root = tree_node([3, 1, 4, None, 2, None, None, None, None, 5, 6, 7, 8]),start = 2) == 3\n assert candidate(root = tree_node([3, None, 4, None, None, 2, None, None, 5, None, 1, None, 6]),start = 4) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),start = 3) == 7\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12]),start = 6) == 6\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, 7, None, None, None, None, 8, 9, 10]),start = 1) == 4\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),start = 5) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, None, None, None, None, 8, 9]),start = 3) == 5\n assert candidate(root = tree_node([7, 3, 15, None, None, 9, 20, None, None, 8, None, 16, None, None, None]),start = 7) == 4\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),start = 5) == 7\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),start = 1) == 7\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),start = 1) == 14\n assert candidate(root = tree_node([10, 7, 15, 4, 8, None, 16, None, None, 6, 9, 12, 18, None, None, None, None, None, 11, 13]),start = 10) == 4\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, None, None, 6, None, 7, None, None, None, None, 8, None, 9]),start = 2) == 4\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30, None, 31]),start = 31) == 30\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30, None, 31]),start = 17) == 16\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15]),start = 1) == 6\n assert candidate(root = tree_node([5, 4, 6, 1, None, 3, None, 2, None, 9, None, None, None, None, 10, None, 8, 11, None, None, 12]),start = 5) == 7\n assert candidate(root = tree_node([5, 1, 7, None, None, 3, 8, None, 4, 6, None, None, None, None, 2, None, None, None, None, 9]),start = 7) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]),start = 15) == 12\n"}, "metadata": {"canonical_parameter_names": ["root", "start"], "leetcode_dataset_entry_point": "Solution().amountOfTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2386, "task_id": "find-the-k-sum-of-an-array", "difficulty": "Hard", "problem_description": "You are given an integer array nums and a positive integer k. You can choose any subsequence of the array and sum all of its elements together.\nWe define the K-Sum of the array as the kth largest subsequence sum that can be obtained (not necessarily distinct).\nReturn the K-Sum of the array.\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.\nNote that the empty subsequence is considered to have a sum of 0.\n \nExample 1:\n\nInput: nums = [2,4,-2], k = 5\nOutput: 2\nExplanation: All the possible subsequence sums that we can obtain are the following sorted in decreasing order:\n- 6, 4, 4, 2, 2, 0, 0, -2.\nThe 5-Sum of the array is 2.\n\nExample 2:\n\nInput: nums = [1,-2,3,4,-10,12], k = 16\nOutput: 10\nExplanation: The 16-Sum of the array is 10.\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\n-109 <= nums[i] <= 109\n1 <= k <= min(2000, 2n)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 100\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000],k = 7) == 0\n assert candidate(nums = [1000000000, -1000000000, 1000000000],k = 3) == 1000000000\n assert candidate(nums = [1, 2, 3],k = 1) == 6\n assert candidate(nums = [5, 8, 3, 1],k = 8) == 9\n assert candidate(nums = [0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [0, 0, 0, 0],k = 1) == 0\n assert candidate(nums = [-1, -2, -3],k = 4) == -3\n assert candidate(nums = [-1, -2, -3, -4],k = 4) == -3\n assert candidate(nums = [5, 10, -3, 7, 2, -8],k = 3) == 21\n assert candidate(nums = [1, 2, 3],k = 2) == 5\n assert candidate(nums = [2, 4, -2],k = 5) == 2\n assert candidate(nums = [1, -2, 3, 4, -10, 12],k = 16) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000) == 80\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 = 1000) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 512) == 27\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 500) == 0\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],k = 20) == 6000000000\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 100) == -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],k = 1000) == 17\n assert candidate(nums = [5, 7, -3, 9, -6, 2, 8, -4],k = 20) == 21\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 20) == 8000000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1024) == 0\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8],k = 20) == 12\n assert candidate(nums = [100, 200, 300, -100, -200, -300, 400, 500, -400, -500],k = 50) == 900\n assert candidate(nums = [100, 200, -150, 250, -300, 400, -50, -500, 600, 700, -1000, 800, 900],k = 1000) == 2150\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6],k = 25) == 17\n assert candidate(nums = [5, -3, 7, 1, -2, 4],k = 15) == 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 = 200) == 193\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 = 750) == 76\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45],k = 100) == 60\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 100) == 70\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 100) == 7\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1, 0, -1, -3, -7, -14, -29, -59, -119, -238, -476, -953, -1907, -3814, -7629, -15258, -30517, -61035, -122070, -244140, -488281, -976562, -1953125, -3906250, -7812500, -15625000, -31250000, -62500000, -125000000, -250000000, -500000000, -1000000000],k = 5000) == 1999999861\n assert candidate(nums = [1, 3, -2, 5, -4, 2, 6],k = 10) == 13\n assert candidate(nums = [1000000000, -500000000, 2000000000, -3000000000, 4000000000],k = 5) == 5000000000\n assert candidate(nums = [5, -3, 7, 9, -2, 10],k = 15) == 19\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1000) == 2000000000\n assert candidate(nums = [1000000000, -999999999, 999999998, -999999997, 999999996, -999999995, 999999994, -999999993, 999999992, -999999991],k = 200) == 1000000004\n assert candidate(nums = [5, -3, 2, 1, -2, 4, -1, 3, -5, 6],k = 150) == 11\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 50) == 1902343750\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 500) == 280\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 500) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50, -55, -60, -65, -70, -75, -80, -85, -90, -95, -100],k = 1500) == 975\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 512) == 280\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 = 1000) == 840\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1000) == 93\n assert candidate(nums = [-1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000],k = 1000) == -8000000000\n assert candidate(nums = [10, 20, 30, -10, -20, -30, 40, 50, 60, -40, -50, -60],k = 150) == 120\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 2000) == 31\n assert candidate(nums = [100, 200, 300, -100, -200, -300, 400, 500, 600, -400, -500, -600, 700, 800, 900],k = 500) == 3300\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 256) == -210\n assert candidate(nums = [5, 3, -1, 4, -6, 2, -2, 3],k = 10) == 13\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000],k = 2000) == 3800\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 30) == 1000000000\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 = 1024) == 17\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 = 2000) == 6\n assert candidate(nums = [1000000, -500000, 2000000, -1000000, 3000000, -1500000],k = 20) == 2500000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100) == 40\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 = 500) == 172\n assert candidate(nums = [5, -1, 3, -4, 2, -6, 7, -8, 9, -10],k = 128) == 10\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 50) == -11\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000],k = 512) == 0\n assert candidate(nums = [-1000000000, -2000000000, -3000000000, -4000000000, -5000000000],k = 5) == -3000000000\n assert candidate(nums = [5, 4, 3, 2, 1],k = 20) == 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 = 500) == 188\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 = 500) == 17\n assert candidate(nums = [10, -5, 3, -2, 1, -1, 0],k = 15) == 11\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500],k = 300) == 4400\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],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],k = 1500) == 181\n assert candidate(nums = [-1000000000, -2000000000, -3000000000, -4000000000, -5000000000, -6000000000, -7000000000, -8000000000, -9000000000, -10000000000],k = 20) == -8000000000\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 20) == -9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 400\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 7) == -4\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, -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],k = 2000) == 2147483585\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1024) == 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 = 1000) == 33\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 = 2000) == 343\n assert candidate(nums = [999999999, -999999999, 999999998, -999999998, 999999997, -999999997, 999999996, -999999996, 999999995, -999999995],k = 500) == 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 = 2000) == 179\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1000) == 33\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 = 1024) == 351\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 = 200) == 8\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 1000) == 4100\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000, 10000000000],k = 20) == 47000000000\n assert candidate(nums = [5, -3, 2, 7, -8, 10, -2, 3, 4, -1],k = 15) == 26\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 = 2000) == 16\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 1024) == -55\n assert candidate(nums = [500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1],k = 1000) == 999998131\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 = 1000) == 17\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 15) == -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],k = 500) == 88\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 = 1024) == 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 = 1000) == 184\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 1500) == 3900\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 = 750) == 420\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 1500) == 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],k = 500) == 43\n assert candidate(nums = [100, 200, 300, -100, -200, -300, 400, 500, -400, -500, 600, 700, -600, -700, 800, 900, -800, -900, 1000, -1000],k = 1000) == 4100\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 15) == 7\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 5) == -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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 28\n assert candidate(nums = [1000000000, -500000000, 500000000, -250000000, 250000000, -125000000, 125000000],k = 100) == 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 = 1200) == 167\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().kSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long kSum(int[] nums, int k) {", "container": "Solution", "callable": "kSum", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2389, "task_id": "longest-subsequence-with-limited-sum", "difficulty": "Easy", "problem_description": "You are given an integer array nums of length n, and an integer array queries of length m.\nReturn an array answer of length m where answer[i] is the maximum size of a subsequence that you can take from nums such that the sum of its elements is less than or equal to queries[i].\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 = [4,5,2,1], queries = [3,10,21]\nOutput: [2,3,4]\nExplanation: We answer the queries as follows:\n- The subsequence [2,1] has a sum less than or equal to 3. It can be proven that 2 is the maximum size of such a subsequence, so answer[0] = 2.\n- The subsequence [4,5,1] has a sum less than or equal to 10. It can be proven that 3 is the maximum size of such a subsequence, so answer[1] = 3.\n- The subsequence [4,5,2,1] has a sum less than or equal to 21. It can be proven that 4 is the maximum size of such a subsequence, so answer[2] = 4.\n\nExample 2:\n\nInput: nums = [2,3,4,5], queries = [1]\nOutput: [0]\nExplanation: The empty subsequence is the only subsequence that has a sum less than or equal to 1, so answer[0] = 0.\n \nConstraints:\n\nn == nums.length\nm == queries.length\n1 <= n, m <= 1000\n1 <= nums[i], queries[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [1, 2, 3, 4, 5]) == [1, 1, 2, 2, 2]\n assert candidate(nums = [10, 20, 30],queries = [10, 25, 50, 70]) == [1, 1, 2, 3]\n assert candidate(nums = [10, 20, 30],queries = [5, 15, 25, 35]) == [0, 1, 1, 2]\n assert candidate(nums = [10, 20, 30],queries = [10, 25, 50, 60]) == [1, 1, 2, 3]\n assert candidate(nums = [5, 4, 3, 2, 1],queries = [1, 2, 3, 4, 5]) == [1, 1, 2, 2, 2]\n assert candidate(nums = [4, 5, 2, 1],queries = [3, 10, 21]) == [2, 3, 4]\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [100, 200, 300, 400, 500]) == [4, 5, 5, 5, 5]\n assert candidate(nums = [5, 5, 5, 5, 5],queries = [1, 5, 10, 15, 25]) == [0, 1, 2, 3, 5]\n assert candidate(nums = [2, 3, 4, 5],queries = [1]) == [0]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 30],queries = [5, 15, 25, 35, 45]) == [0, 1, 1, 2, 2]\n assert candidate(nums = [10, 20, 30],queries = [15, 25, 35, 45]) == [1, 1, 2, 2]\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [15, 10, 5]) == [5, 4, 2]\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [15, 10, 5, 3, 1]) == [5, 4, 2, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [15, 10, 5, 3]) == [5, 4, 2, 2]\n assert candidate(nums = [5, 4, 3, 2, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [55]) == [10]\n assert candidate(nums = [1000000],queries = [1000000]) == [1]\n assert candidate(nums = [5, 5, 5, 5, 5],queries = [5, 10, 15, 20, 25]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1, 1000000],queries = [1000000]) == [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 = [5, 10, 15, 20, 25, 30]) == [5, 10, 15, 20, 20, 20]\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]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],queries = [55, 165, 275, 385, 495, 605, 715, 825, 935, 1045, 1155, 1265, 1375, 1485, 1595]) == [2, 5, 6, 8, 9, 10, 11, 12, 13, 13, 14, 15, 15, 15, 15]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],queries = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],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, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [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, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [3, 4, 5, 6, 7, 7, 8, 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],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210]) == [4, 5, 7, 8, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 16, 17, 17, 18, 19, 19, 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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 0, 3, 0, 5, 5, 9, 0, 4, 2, 8, 4, 9, 6, 2, 8, 0, 3, 4, 6, 2, 0, 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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 0, 3, 0, 5],queries = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == [49, 65, 78, 89, 99, 107, 115, 122, 129, 135]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [2, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [1, 5, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 385, 440, 500]) == [1, 2, 5, 7, 9, 11, 14, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(nums = [100, 10, 1, 50, 20, 60],queries = [50, 150, 200, 300, 400]) == [3, 5, 5, 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [1, 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]) == [1, 2, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [55, 45, 35, 25, 15, 5, 0]) == [10, 9, 7, 6, 5, 2, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6]\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],queries = [1000000, 1999998, 2999995, 3999990, 4999982, 5999969, 6999949, 7999924, 8999884, 9999828]) == [1, 2, 3, 4, 5, 6, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],queries = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 8500, 9500]) == [2, 5, 6, 7, 9, 10, 10, 10, 10, 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],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [4, 5, 7, 8, 9, 10, 11, 12, 12, 13]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],queries = [10, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500]) == [1, 2, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],queries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [5, 8, 10, 12, 13, 15, 16, 17, 18, 19]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],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]) == [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, 2, 3]\n assert candidate(nums = [7, 3, 10, 1, 5, 2, 8, 6, 4, 9],queries = [15, 25, 30, 35, 40, 45, 50]) == [5, 6, 7, 7, 8, 9, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [9, 7, 5, 3, 1],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [3, 4, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 4, 3, 2, 1, 3, 2, 1, 2, 1, 1],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, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 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]\n assert candidate(nums = [7, 3, 4, 9, 1],queries = [10, 15, 20, 25, 30, 35, 40]) == [3, 4, 4, 5, 5, 5, 5]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],queries = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 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],queries = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [150, 300, 450, 600, 750, 900, 1050]) == [1, 2, 2, 3, 3, 3, 4]\n assert candidate(nums = [7, 1, 3, 2, 8, 5, 6, 4],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 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 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == [10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums = [300, 200, 100, 400, 500],queries = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 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],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\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],queries = [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]) == [2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 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],queries = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 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, 51, 53, 55, 57, 59],queries = [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]) == [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [50, 40, 30, 20, 10],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7]\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991],queries = [500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 8500, 9500]) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [987654321, 123456789, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567],queries = [500000000, 1000000000, 1500000000, 2000000000, 2500000000, 3000000000]) == [2, 3, 4, 5, 6, 6]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [2, 4, 5, 5, 6, 7, 7, 8, 9, 9]\n assert candidate(nums = [999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1000000, 500000, 100000, 50000]) == [19, 19, 19, 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 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == [2, 5, 6, 7, 9, 10, 10, 11, 12, 13, 14, 14, 15, 15, 16, 17, 17, 18, 18, 19]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],queries = [10, 30, 60, 100, 150, 210, 280, 360, 450, 550, 660, 780, 910, 1050, 1200, 1360, 1530, 1710, 1900, 2100]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],queries = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [1, 2, 3, 4, 5, 6, 7, 7, 7, 7]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3]\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],queries = [1000, 10000, 100000, 1000000, 10000000]) == [2, 3, 3, 8, 10]\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500],queries = [100000, 250000, 500000, 750000, 1000000]) == [1, 2, 3, 3, 4]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1, 2, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],queries = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],queries = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\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]) == [1, 2, 2, 3, 3, 4, 4, 4, 5, 5]\n assert candidate(nums = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711],queries = [10, 100, 1000, 10000, 100000, 1000000]) == [3, 7, 12, 16, 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],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [90, 180, 270, 360, 450, 540, 630, 720, 810, 900, 990]) == [3, 5, 6, 8, 9, 9, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14]\n assert candidate(nums = [9, 7, 5, 3, 1],queries = [5, 10, 15, 20, 25, 30]) == [2, 3, 3, 4, 5, 5]\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],queries = [5000000, 10000000, 15000000, 20000000, 25000000]) == [5, 10, 10, 10, 10]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 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]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 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],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, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == [1, 50, 100, 145, 145, 145, 145, 145, 145, 145, 145]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],queries = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500]) == [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 1, 1, 2, 2, 3, 3, 4, 4, 5]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],queries = [1000000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000, 4500000, 5000000]) == [9, 9, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 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, 1, 1, 1],queries = [1, 5, 10, 20, 50, 100, 200, 500, 1000]) == [1, 5, 10, 20, 50, 91, 91, 91, 91]\n assert candidate(nums = [33, 21, 47, 55, 17, 82, 38, 67, 25, 12, 99, 78, 63, 44, 5, 85, 93, 4, 52, 36, 73, 29, 31, 88, 57, 90, 19, 15, 81, 77, 7, 48, 53, 18, 11, 34, 86, 59, 97, 40, 30, 92, 68, 49, 61, 50, 54, 91, 74, 75, 70, 60, 83, 64, 41, 87, 62, 24, 22, 27, 66, 35, 23, 58, 79, 98, 94, 39, 28, 20, 65, 43, 51, 46, 6, 95, 71, 1, 96, 3, 8, 9, 10, 13, 14, 16, 26, 32, 37, 42, 45, 56, 72, 80, 84, 89, 91],queries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == [12, 18, 23, 26, 30, 33, 35, 38, 40, 43, 45, 47, 49, 51, 53]\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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 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],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, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [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, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5]\n assert candidate(nums = [500, 400, 300, 200, 100],queries = [150, 250, 350, 450, 550, 650, 750, 850, 950]) == [1, 1, 2, 2, 2, 3, 3, 3, 3]\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200],queries = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == [5, 6, 7, 9, 10, 10, 10, 10, 10, 10]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().answerQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] answerQueries(int[] nums, int[] queries) {", "container": "Solution", "callable": "answerQueries", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "queries", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2390, "task_id": "removing-stars-from-a-string", "difficulty": "Medium", "problem_description": "You are given a string s, which contains stars *.\nIn one operation, you can:\n\nChoose a star in s.\nRemove the closest non-star character to its left, as well as remove the star itself.\n\nReturn the string after all stars have been removed.\nNote:\n\nThe input will be generated such that the operation is always possible.\nIt can be shown that the resulting string will always be unique.\n\n \nExample 1:\n\nInput: s = \"leet**cod*e\"\nOutput: \"lecoe\"\nExplanation: Performing the removals from left to right:\n- The closest character to the 1st star is 't' in \"leet**cod*e\". s becomes \"lee*cod*e\".\n- The closest character to the 2nd star is 'e' in \"lee*cod*e\". s becomes \"lecod*e\".\n- The closest character to the 3rd star is 'd' in \"lecod*e\". s becomes \"lecoe\".\nThere are no more stars, so we return \"lecoe\".\nExample 2:\n\nInput: s = \"erase*****\"\nOutput: \"\"\nExplanation: The entire string is removed, so we return an empty string.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of lowercase English letters and stars *.\nThe operation above can be performed on s.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc*def*ghi*jkl*mno*pqr*stu*vwx*y*z\") == \"abdeghjkmnpqstvwz\"\n assert candidate(s = \"leet**cod*e\") == \"lecoe\"\n assert candidate(s = \"a*b*c*d*e*\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"ab*cd*ef*gh*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*\") == \"aceg\"\n assert candidate(s = \"a*ab*abc*abcd*abcde*abcdef*abcdefg*abcdefgh*abcdefghi*abcdefghij*abcdefghijk*abcdefghijkl*abcdefghijklm*abcdefghijklmn*abcdefghijklmno*abcdefghijklmnop*abcdefghijklmnopq*abcdefghijklmnopqr*abcdefghijklmnopqrs*abcdefghijklmnopqrst*abcdefghijklmnopqrstu*abcdefghijklmnopqrstuv*abcdefghijklmnopqrstuvw*abcdefghijklmnopqrstuvwx*abcdefghijklmnopqrstuvwxy*abcdefghijklmnopqrstuvwxyza\") == \"aababcabcdabcdeabcdefabcdefgabcdefghabcdefghiabcdefghijabcdefghijkabcdefghijklabcdefghijklmabcdefghijklmnabcdefghijklmnoabcdefghijklmnopabcdefghijklmnopqabcdefghijklmnopqrabcdefghijklmnopqrsabcdefghijklmnopqrstabcdefghijklmnopqrstuabcdefghijklmnopqrstuvabcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"abcdef\") == \"abcdef\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a\") == \"a\"\n assert candidate(s = \"ab*cd*ef*gh*ij*kl*mn*op*qr*st*uv*wx*yz\") == \"acegikmoqsuwyz\"\n assert candidate(s = \"abcde\") == \"abcde\"\n assert candidate(s = \"abc***\") == \"\"\n assert candidate(s = \"ab*cd*ef*g*hi*j*\") == \"aceh\"\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 = \"erase*****\") == \"\"\n assert candidate(s = \"abcd**efgh**ijkl**mnop**qrst**uvw**x**y**z\") == \"abefijmnqz\"\n assert candidate(s = \"aaabbbcccddd***eee***fffgggggghhhhiiiiijkkkkkllllmmmmnnnnoooo***pppppqqqqrrrrsssss\") == \"aaabbbcccfffgggggghhhhiiiiijkkkkkllllmmmmnnnnopppppqqqqrrrrsssss\"\n assert candidate(s = \"abcde**fghij**klmno**pqrst**uvwxy**z\") == \"abcfghklmpqruvwz\"\n assert candidate(s = \"abcdefghijklmnopqrstuv*xyzwvutsrponmlkjihgfedcba*\") == \"abcdefghijklmnopqrstuxyzwvutsrponmlkjihgfedcb\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz*zyxwvutsrqponmlkjihgfedcba*\") == \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcb\"\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 = \"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*\") == \"aaaaabbbbbcccccdddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooopppppqqqqqrrrrrssssstttttuuuuuvvvvvwwwwwxxxxxyyyyyzzzzz\"\n assert candidate(s = \"abcde*fghij*klmno*pqrst*uvwxy*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*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\") == \"abcdfghiklmnpqrsuvwxz\"\n assert candidate(s = \"abc*def*ghi*jkl*mno*pqr*stu*vwx*yz*\") == \"abdeghjkmnpqstvwy\"\n assert candidate(s = \"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*\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz*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\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcde*fg*hi*jkl*mno*pqr*stu*vwx*y*z*\") == \"abcdfhjkmnpqstvw\"\n assert candidate(s = \"aabbccddeeefffggg***hhiijjkkllmmnn***oo***ppqqrrssttttuuuuuuuuuuvvvvvvvvwxyz\") == \"aabbccddeeefffhhiijjkkllppqqrrssttttuuuuuuuuuuvvvvvvvvwxyz\"\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*zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz*****\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwx\"\n assert candidate(s = \"z*yz*zyxw*vyxwv*u*vwxy*ts*rq*ponm*ln*kj*i*hg*fed*cb*a*\") == \"yzyxvyxwvwxtrponlkhfec\"\n assert candidate(s = \"abc***def**ghij***klmno**pqrstuv***wxyz\") == \"dgklmpqrswxyz\"\n assert candidate(s = \"abcdefghij*klmnopqrst*uvwxyz*zyxwvutsr*qp*on*m*l*k*j*i*h*g*f*e*d*c*b*a\") == \"abcdefghiklmnopqrsuvwxyzyxwvutsqoa\"\n assert candidate(s = \"a*ab*abc*abcd*abcde*abcdef*abcdefg*abcdefgh*abcdefghi*abcdefghij*abcdefghijk*abcdefghijkl*abcdefghijklm*abcdefghijklmn*abcdefghijklmno*abcdefghijklmnop*abcdefghijklmnopq*abcdefghijklmnopqr*abcdefghijklmnopqrs*abcdefghijklmnopqrst*abcdefghijklmnopqrstu*abcdefghijklmnopqrstuv*abcdefghijklmnopqrstuvw*abcdefghijklmnopqrstuvwx*abcdefghijklmnopqrstuvwxy*abcdefghijklmnopqrstuvwxyz*\") == \"aababcabcdabcdeabcdefabcdefgabcdefghabcdefghiabcdefghijabcdefghijkabcdefghijklabcdefghijklmabcdefghijklmnabcdefghijklmnoabcdefghijklmnopabcdefghijklmnopqabcdefghijklmnopqrabcdefghijklmnopqrsabcdefghijklmnopqrstabcdefghijklmnopqrstuabcdefghijklmnopqrstuvabcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxy\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz****\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxx\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxy**z\") == \"abcdefghijklmnopqrstuvwz\"\n assert candidate(s = \"xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz\") == \"xyz\"\n assert candidate(s = \"abcde*****fghij*****klmno*****pqrst*****uvwxy*****z\") == \"z\"\n assert candidate(s = \"abcdefghij***klmnopqrst***uvwxyz***abcd***efghij***klmno***pqrst***uvwxy***z\") == \"abcdefgklmnopquvwaefgklpquvz\"\n assert candidate(s = \"abcdefghijk***lmnopqrstuvwxyz**aaaaaaaaaabbbbbbbbbbccccccccccddddeeeeee****\") == \"abcdefghlmnopqrstuvwxaaaaaaaaaabbbbbbbbbbccccccccccddddee\"\n assert candidate(s = \"abcd*efgh*ijkl*mnop*qrst*uvw*x*y*z*\") == \"abcefgijkmnoqrsuv\"\n assert candidate(s = \"nested*stars*****in*string*example***\") == \"nesteistrinexam\"\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 = \"a*bb*ccc*dddd*eeeee*ffffff*gggggg*hhhhhhh*iiiiiiii*jjjjjjjjj*kkkkkkkkk*llllllllll*mmmmmmmmmm*nnnnnnnnnnn*ooooooooooo*pppppppppppp*qqqqqqqqqqqqq*rrrrrrrrrrrrrr*sssssssssssssss*ttttttttttttttttt*uuuuuuuuuuuuuuuuuu*vvvvvvvvvvvvvvvvvvv*wwwwwwwwwwwwwwwwwwww*xxyyz**\") == \"bccdddeeeefffffggggghhhhhhiiiiiiijjjjjjjjkkkkkkkklllllllllmmmmmmmmmnnnnnnnnnnoooooooooopppppppppppqqqqqqqqqqqqrrrrrrrrrrrrrssssssssssssssttttttttttttttttuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwxxy\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz*abcdefghijklmnopqrstuvwxyz*\") == \"abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxy\"\n assert candidate(s = \"abcde*fg*hij*k*lmnop*qrs*tuvw*x*y*z*\") == \"abcdfhilmnoqrtuv\"\n assert candidate(s = \"abcdefghi*jk*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z**\") == \"abcdefgh\"\n assert candidate(s = \"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*x*x*x*x*x*x*x*x*x*x*x\") == \"x\"\n assert candidate(s = \"aabbaa*bbcc*ddcc*eeff*ffgg*hhiijj*kkll*mmnn*oopp*qqrr*sttuu*vwwxxyyzz*****\") == \"aabbabbcddceefffghhiijkklmmnoopqqrsttuvwwx\"\n assert candidate(s = \"abc**def**ghi**jkl**mno**pqr**stu**vwx**yz**\") == \"adgjmpsv\"\n assert candidate(s = \"mississippi***ipp*ss*m*i**\") == \"mississiip\"\n assert candidate(s = \"a*bc*def*ghij*klmno*pqrst*uvwxy*z\") == \"bdeghiklmnpqrsuvwxz\"\n assert candidate(s = \"mnopqrstu*****vwxyz*****abcdefghi*****jklmno*****pqrst*****uvw*****xy*****z\") == \"mnopz\"\n assert candidate(s = \"abcde*fgh*i*jklmno*pqrstu*v*wxyz*\") == \"abcdfgjklmnpqrstwxy\"\n assert candidate(s = \"abc*def*ghi*jkl*mno*pqr*stu*vwx*y*z**\") == \"abdeghjkmnpqstv\"\n assert candidate(s = \"a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxy**z*\") == \"abcdefghijklmnopqrstuvw\"\n assert candidate(s = \"xy*z*ab*cd*ef*gh*ij*kl*mn*op*qr*st*uv*wx*yz*\") == \"xacegikmoqsuwy\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz*\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz\"\n assert candidate(s = \"python*is*awesome***so**is**java**\") == \"pythoiawesja\"\n assert candidate(s = \"longstringwith*various*characters*and*stars*through*out***\") == \"longstringwitvarioucharacteranstarthroug\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz*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*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 = \"a*ab*abc*abcd*abcde*abcdef*abcdefg*abcdefgh*abcdefghi*abcdefghij*abcdefghijk\") == \"aababcabcdabcdeabcdefabcdefgabcdefghabcdefghiabcdefghijk\"\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*abcdefghijklmnopqrstuvwxyz*zyxwvutsrqponmlkjihgfedcba*\") == \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcb\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().removeStars", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String removeStars(String s) {", "container": "Solution", "callable": "removeStars", "parameters": [{"name": "s", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2391, "task_id": "minimum-amount-of-time-to-collect-garbage", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of strings garbage where garbage[i] represents the assortment of garbage at the ith house. garbage[i] consists only of the characters 'M', 'P' and 'G' representing one unit of metal, paper and glass garbage respectively. Picking up one unit of any type of garbage takes 1 minute.\nYou are also given a 0-indexed integer array travel where travel[i] is the number of minutes needed to go from house i to house i + 1.\nThere are three garbage trucks in the city, each responsible for picking up one type of garbage. Each garbage truck starts at house 0 and must visit each house in order; however, they do not need to visit every house.\nOnly one garbage truck may be used at any given moment. While one truck is driving or picking up garbage, the other two trucks cannot do anything.\nReturn the minimum number of minutes needed to pick up all the garbage.\n \nExample 1:\n\nInput: garbage = [\"G\",\"P\",\"GP\",\"GG\"], travel = [2,4,3]\nOutput: 21\nExplanation:\nThe paper garbage truck:\n1. Travels from house 0 to house 1\n2. Collects the paper garbage at house 1\n3. Travels from house 1 to house 2\n4. Collects the paper garbage at house 2\nAltogether, it takes 8 minutes to pick up all the paper garbage.\nThe glass garbage truck:\n1. Collects the glass garbage at house 0\n2. Travels from house 0 to house 1\n3. Travels from house 1 to house 2\n4. Collects the glass garbage at house 2\n5. Travels from house 2 to house 3\n6. Collects the glass garbage at house 3\nAltogether, it takes 13 minutes to pick up all the glass garbage.\nSince there is no metal garbage, we do not need to consider the metal garbage truck.\nTherefore, it takes a total of 8 + 13 = 21 minutes to collect all the garbage.\n\nExample 2:\n\nInput: garbage = [\"MMM\",\"PGM\",\"GP\"], travel = [3,10]\nOutput: 37\nExplanation:\nThe metal garbage truck takes 7 minutes to pick up all the metal garbage.\nThe paper garbage truck takes 15 minutes to pick up all the paper garbage.\nThe glass garbage truck takes 15 minutes to pick up all the glass garbage.\nIt takes a total of 7 + 15 + 15 = 37 minutes to collect all the garbage.\n\n \nConstraints:\n\n2 <= garbage.length <= 105\ngarbage[i] consists of only the letters 'M', 'P', and 'G'.\n1 <= garbage[i].length <= 10\ntravel.length == garbage.length - 1\n1 <= travel[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(garbage = ['M', 'P', 'G', 'M', 'P', 'G'],travel = [1, 2, 3, 4, 5]) == 37\n assert candidate(garbage = ['P', 'G', 'M', 'P'],travel = [1, 1, 1]) == 10\n assert candidate(garbage = ['GGG', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM'],travel = [10, 10, 10, 10, 10]) == 138\n assert candidate(garbage = ['G'],travel = []) == 1\n assert candidate(garbage = ['G', 'P', 'M'],travel = [1, 1]) == 6\n assert candidate(garbage = ['', 'G', '', 'M', 'P'],travel = [2, 3, 2, 5]) == 24\n assert candidate(garbage = ['M', 'P', 'G'],travel = [1, 1]) == 6\n assert candidate(garbage = ['GGGG', 'MM', 'PP', 'GG'],travel = [5, 5, 5]) == 40\n assert candidate(garbage = ['GGP', 'GGP', 'GGP', 'GGP'],travel = [2, 2, 2]) == 24\n assert candidate(garbage = ['', '', '', '', ''],travel = [1, 1, 1, 1]) == 0\n assert candidate(garbage = ['P', 'M', 'G'],travel = [1]) == 4\n assert candidate(garbage = ['M', 'M', 'M', 'M', 'M'],travel = [1, 1, 1, 1]) == 9\n assert candidate(garbage = ['', '', '', ''],travel = [1, 1, 1]) == 0\n assert candidate(garbage = ['G', 'P', 'GP', 'GG'],travel = [2, 4, 3]) == 21\n assert candidate(garbage = ['MMM', 'PGM', 'GP'],travel = [3, 10]) == 37\n assert candidate(garbage = ['GMP', 'GMP', 'GMP'],travel = [10, 10]) == 69\n assert candidate(garbage = ['MG', 'GP', 'PM', 'MG'],travel = [3, 4, 2]) == 33\n assert candidate(garbage = ['MG', 'GP', 'MM', 'PG', 'GG'],travel = [2, 3, 1, 5]) == 32\n assert candidate(garbage = ['MGP', 'MGP', 'MGP', 'MGP'],travel = [5, 5, 5]) == 57\n assert candidate(garbage = ['GGG', 'MMM', 'PPP'],travel = [5, 5]) == 24\n assert candidate(garbage = ['GP', 'GP', 'GP', 'GP'],travel = [1, 1, 1]) == 14\n assert candidate(garbage = ['GP', 'MM', 'GG', 'PP', 'GG'],travel = [5, 2, 4, 3]) == 40\n assert candidate(garbage = ['P', 'G', 'M'],travel = [1, 2]) == 7\n assert candidate(garbage = ['G', 'M', 'P', '', '', 'G', 'P', 'M', ''],travel = [1, 1, 1, 1, 1, 1, 1, 1]) == 24\n assert candidate(garbage = ['G', 'P', 'M', 'GP', 'MG', 'PG', 'GMP', 'MGP', 'PMG', 'G'],travel = [2, 3, 1, 5, 4, 2, 3, 1, 4]) == 86\n assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [2, 2, 2, 2, 2, 2, 2, 2]) == 51\n assert candidate(garbage = ['G', 'P', 'M', 'GP', 'GM', 'MP', 'PGM', 'MGP', 'GMP', 'PGMG', 'GMPG', 'MPGM'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 228\n assert candidate(garbage = ['MPG', 'G', 'M', 'P', 'G', 'M', 'P', 'G'],travel = [10, 20, 30, 40, 50, 60, 70]) == 650\n assert candidate(garbage = ['GGG', 'PPP', 'MMM', 'GPM', 'GPM', 'GPM', 'GPM'],travel = [2, 2, 2, 2, 2, 2]) == 57\n assert candidate(garbage = ['GGP', 'PGM', 'MG', 'PG', 'GM', 'MP', 'GG', 'PP', 'MM'],travel = [3, 3, 3, 3, 3, 3, 3, 3]) == 83\n assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 2, 1, 2, 1, 2, 1, 2]) == 40\n assert candidate(garbage = ['GGGPPPMMM', 'GGGPPPMMM', 'GGGPPPMMM', 'GGGPPPMMM'],travel = [10, 10, 10]) == 126\n assert candidate(garbage = ['', 'G', 'P', 'M', '', 'GP', 'MG', '', '', 'MG'],travel = [2, 1, 4, 2, 1, 5, 2, 1, 1]) == 57\n assert candidate(garbage = ['M', 'G', 'P', 'MG', 'PG', 'GM', 'GMP', 'P', 'M'],travel = [2, 3, 1, 4, 2, 3, 1, 2]) == 63\n assert candidate(garbage = ['G', 'M', 'P', 'G', 'M', 'P', 'G', 'M', 'P', 'G', 'M', 'P', 'G', 'M', 'P'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 289\n assert candidate(garbage = ['M', 'P', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 146\n assert candidate(garbage = ['GGG', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM'],travel = [10, 20, 30, 10, 20, 30, 10, 20]) == 427\n assert candidate(garbage = ['MP', 'GP', 'MG', 'PG', 'GM', 'PM', 'MG', 'PG', 'GM', 'PM'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n assert candidate(garbage = ['MGP', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'MGP'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 58\n assert candidate(garbage = ['MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP'],travel = [2, 2, 2, 2, 2, 2, 2]) == 66\n assert candidate(garbage = ['MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n assert candidate(garbage = ['GMPGMP', 'PMPMPM', 'MGMGMG', 'PGPGPG', 'GMPGMP', 'PMPMPM', 'MGMGMG', 'PGPGPG'],travel = [15, 15, 15, 15, 15, 15, 15]) == 348\n assert candidate(garbage = ['G', 'M', 'P', 'G', 'M', 'P', 'G', 'M', 'P'],travel = [1, 2, 3, 4, 5, 6, 7, 8]) == 94\n assert candidate(garbage = ['PG', 'G', 'P', 'G', 'P', 'G', 'P', 'G', 'P', 'G', 'P'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 112\n assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 66\n assert candidate(garbage = ['GMM', 'GGP', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM'],travel = [7, 8, 9, 10, 11, 12]) == 157\n assert candidate(garbage = ['GMM', 'GGP', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM', 'GPP', 'MG', 'PGM', 'PG', 'GM', 'MP', 'PGM', 'GMP'],travel = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 608\n assert candidate(garbage = ['', '', '', '', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 45\n assert candidate(garbage = ['GGGG', 'PPPP', 'MMMM', 'PPPP', 'GGGG', 'MMMM'],travel = [3, 4, 5, 6, 7]) == 79\n assert candidate(garbage = ['G', 'P', 'M', 'GP', 'MG', 'PG', 'GMP', 'MGP', 'PMG', 'G', 'P', 'M', 'GP', 'MG', 'PG', 'GMP', 'MGP', 'PMG', 'G'],travel = [2, 3, 1, 5, 4, 2, 3, 1, 4, 2, 3, 1, 5, 4, 2, 3, 1, 4]) == 179\n assert candidate(garbage = ['GP', 'MG', 'PM', 'MG', 'PM', 'MG', 'PM', 'MG', 'PM', 'MG'],travel = [5, 10, 5, 10, 5, 10, 5, 10, 5]) == 210\n assert candidate(garbage = ['P', 'M', 'G', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 130\n assert candidate(garbage = ['GMP', 'P', 'G', 'M', 'P', 'G', 'M', 'P', 'G', 'M'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 121\n assert candidate(garbage = ['MPG', 'PGM', 'GMP', 'MGP', 'GPM', 'PGM', 'GMP', 'MGP', 'GPM', 'PGM'],travel = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 705\n assert candidate(garbage = ['', '', '', '', '', '', '', '', '', 'MGP'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(garbage = ['G', 'M', 'P', 'G', 'M', 'P', 'G', 'M', 'P', 'G'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 130\n assert candidate(garbage = ['MGP', 'G', 'P', 'M', 'GP', 'MG', 'PG', 'GM', 'PM'],travel = [10, 5, 7, 6, 8, 9, 2, 3]) == 163\n assert candidate(garbage = ['MMM', 'GGG', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM'],travel = [5, 5, 5, 5, 5, 5]) == 96\n assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 42\n assert candidate(garbage = ['GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 513\n assert candidate(garbage = ['MMG', 'PG', 'MM', 'GGG', 'PP', 'G'],travel = [3, 5, 2, 6, 4]) == 57\n assert candidate(garbage = ['GGGG', 'PPPP', 'MMMM', 'GGGG', 'PPPP', 'MMMM'],travel = [1, 2, 3, 4, 5]) == 55\n assert candidate(garbage = ['G', 'M', 'P', 'GM', 'PG', 'MG', 'GPM', 'PMG', 'MPG', 'GMP'],travel = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 183\n assert candidate(garbage = ['MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 165\n assert candidate(garbage = ['MGP', '', 'MGP', '', 'MGP', '', 'MGP'],travel = [2, 2, 2, 2, 2, 2]) == 48\n assert candidate(garbage = ['MGP', 'GP', 'MGG', 'PGG', 'MMM', 'GGP', 'PGM'],travel = [3, 5, 2, 4, 6, 7]) == 101\n assert candidate(garbage = ['MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP'],travel = [10, 10, 10, 10, 10, 10, 10, 10, 10]) == 300\n assert candidate(garbage = ['MMMGGGPPP', 'MMMGGGPPP', 'MMMGGGPPP', 'MMMGGGPPP'],travel = [15, 15, 15]) == 171\n assert candidate(garbage = ['', '', '', '', '', '', '', '', '', '', 'PGM'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 168\n assert candidate(garbage = ['GMP', 'GMP', 'GMP', '', '', '', 'GMP', '', '', 'GMP', 'GMP', 'GMP', '', '', '', 'GMP', 'GMP', 'GMP', ''],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 285\n assert candidate(garbage = ['', '', '', '', '', '', '', ''],travel = [1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(garbage = ['MGPG', 'GPMP', 'PGMG', 'P', 'M', 'G', 'MGP', 'P', 'G', 'MP'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 148\n assert candidate(garbage = ['', '', 'MGP', '', '', '', '', '', '', 'MGP'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 141\n assert candidate(garbage = ['MPG', 'G', 'P', 'M', 'PG', 'GM', 'PGM'],travel = [7, 3, 8, 2, 5, 6]) == 106\n assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 382\n assert candidate(garbage = ['MMM', 'MMM', 'MMM', 'MMM', 'MMM'],travel = [10, 10, 10, 10]) == 55\n assert candidate(garbage = ['G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 21\n assert candidate(garbage = ['', 'MGP', '', 'P', 'G', 'MP', '', 'MGP', '', 'P', 'G', 'MP', '', 'MGP', ''],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 290\n assert candidate(garbage = ['GMP', 'P', 'M', 'G', 'MPG', 'MG', 'PG', 'GMP', 'GMP', 'P'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 145\n assert candidate(garbage = ['GP', 'GP', 'GP', 'GP', 'GP', 'GP', 'GP'],travel = [1, 1, 1, 1, 1, 1]) == 26\n assert candidate(garbage = ['MMM', 'PPP', 'GGG', 'MMM', 'PPP', 'GGG', 'MMM', 'PPP', 'GGG'],travel = [10, 10, 10, 10, 10, 10, 10, 10]) == 237\n assert candidate(garbage = ['MG', 'PGP', 'GGM', 'PPG', 'MMG'],travel = [3, 5, 2, 7]) == 58\n assert candidate(garbage = ['MMM', '', 'GG', '', '', 'P', '', 'G'],travel = [10, 2, 3, 4, 5, 6, 7]) == 68\n assert candidate(garbage = ['MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM'],travel = [10, 10, 10, 10, 10, 10, 10, 10]) == 107\n assert candidate(garbage = ['GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 165\n assert candidate(garbage = ['G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(garbage = ['G', 'P', 'M', 'G', '', 'P', 'M', 'G', '', 'P', 'M', 'G', '', 'P', 'M', 'G', '', 'P', 'M', 'G'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 51\n assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 2, 3, 4, 5, 6, 7, 8]) == 94\n assert candidate(garbage = ['G', 'P', 'M', '', 'G', 'P', 'M', ''],travel = [1, 2, 3, 4, 5, 6, 7]) == 52\n assert candidate(garbage = ['MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG'],travel = [5, 5, 5, 5, 5, 5, 5]) == 129\n assert candidate(garbage = ['MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 57\n assert candidate(garbage = ['MGP', 'MGP', '', '', '', '', '', 'MGP', 'MGP', 'MGP', '', '', '', '', 'MGP'],travel = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 228\n assert candidate(garbage = ['', '', '', '', '', '', '', '', '', 'G'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 427\n assert candidate(garbage = ['MMMM', 'PPPP', 'GGGG', 'MMMM', 'PPPP', 'GGGG'],travel = [10, 10, 10, 10, 10]) == 144\n assert candidate(garbage = ['MMM', 'PPP', 'GGG', 'MMM', 'PPP', 'GGG', 'MMM'],travel = [10, 10, 10, 10, 10, 10]) == 171\n assert candidate(garbage = ['MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 69\n assert candidate(garbage = ['MMM', 'GGG', 'PPP', 'MGP', 'GMP', 'PMM', 'GGP', 'PPG', 'MPM', 'MGP'],travel = [10, 20, 15, 10, 5, 12, 8, 18, 7]) == 345\n assert candidate(garbage = ['M', 'P', 'G', 'MPG', 'GMP', 'PGM'],travel = [1, 3, 2, 4, 5]) == 57\n assert candidate(garbage = ['MGP', '', '', 'MGP', '', '', 'MGP', '', '', 'MGP'],travel = [2, 1, 3, 2, 1, 3, 2, 1, 3]) == 66\n assert candidate(garbage = ['M', 'P', 'G', 'MP', 'PG', 'GM', 'MG', 'PGM'],travel = [2, 3, 1, 4, 5, 6]) == 14\n assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 115\n assert candidate(garbage = ['MGP', 'MG', 'P', 'G', 'MP', 'GM', 'PG', 'MG', 'PGM'],travel = [5, 5, 5, 5, 5, 5, 5, 5]) == 138\n assert candidate(garbage = ['G', '', 'P', '', 'M', '', 'G', '', 'P', '', 'M'],travel = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 42\n assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 289\n assert candidate(garbage = ['G', 'P', 'M', 'PG', 'GM', 'MP', 'PGM'],travel = [1, 2, 3, 4, 5, 6]) == 75\n"}, "metadata": {"canonical_parameter_names": ["garbage", "travel"], "leetcode_dataset_entry_point": "Solution().garbageCollection", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int garbageCollection(String[] garbage, int[] travel) {", "container": "Solution", "callable": "garbageCollection", "parameters": [{"name": "garbage", "type": "String[]"}, {"name": "travel", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2392, "task_id": "build-a-matrix-with-conditions", "difficulty": "Hard", "problem_description": "You are given a positive integer k. You are also given:\n\na 2D integer array rowConditions of size n where rowConditions[i] = [abovei, belowi], and\na 2D integer array colConditions of size m where colConditions[i] = [lefti, righti].\n\nThe two arrays contain integers from 1 to k.\nYou have to build a k x k matrix that contains each of the numbers from 1 to k exactly once. The remaining cells should have the value 0.\nThe matrix should also satisfy the following conditions:\n\nThe number abovei should appear in a row that is strictly above the row at which the number belowi appears for all i from 0 to n - 1.\nThe number lefti should appear in a column that is strictly left of the column at which the number righti appears for all i from 0 to m - 1.\n\nReturn any matrix that satisfies the conditions. If no answer exists, return an empty matrix.\n \nExample 1:\n\n\nInput: k = 3, rowConditions = [[1,2],[3,2]], colConditions = [[2,1],[3,2]]\nOutput: [[3,0,0],[0,0,1],[0,2,0]]\nExplanation: The diagram above shows a valid example of a matrix that satisfies all the conditions.\nThe row conditions are the following:\n- Number 1 is in row 1, and number 2 is in row 2, so 1 is above 2 in the matrix.\n- Number 3 is in row 0, and number 2 is in row 2, so 3 is above 2 in the matrix.\nThe column conditions are the following:\n- Number 2 is in column 1, and number 1 is in column 2, so 2 is left of 1 in the matrix.\n- Number 3 is in column 0, and number 2 is in column 1, so 3 is left of 2 in the matrix.\nNote that there may be multiple correct answers.\n\nExample 2:\n\nInput: k = 3, rowConditions = [[1,2],[2,3],[3,1],[2,3]], colConditions = [[2,1]]\nOutput: []\nExplanation: From the first two conditions, 3 has to be below 1 but the third conditions needs 3 to be above 1 to be satisfied.\nNo matrix can satisfy all the conditions, so we return the empty matrix.\n\n \nConstraints:\n\n2 <= k <= 400\n1 <= rowConditions.length, colConditions.length <= 104\nrowConditions[i].length == colConditions[i].length == 2\n1 <= abovei, belowi, lefti, righti <= k\nabovei != belowi\nlefti != righti\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 5,rowConditions = [[1, 5], [2, 5], [3, 5], [4, 5]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [[1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 5]]\n assert candidate(k = 3,rowConditions = [[1, 2], [3, 2]],colConditions = [[2, 1], [3, 2]]) == [[0, 0, 1], [3, 0, 0], [0, 2, 0]]\n assert candidate(k = 4,rowConditions = [[4, 3], [3, 2], [2, 1]],colConditions = [[4, 3], [3, 2], [2, 1]]) == [[4, 0, 0, 0], [0, 3, 0, 0], [0, 0, 2, 0], [0, 0, 0, 1]]\n assert candidate(k = 4,rowConditions = [[1, 2], [2, 3], [3, 4]],colConditions = [[1, 2], [2, 3], [3, 4]]) == [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]\n assert candidate(k = 6,rowConditions = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6]],colConditions = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6]]) == [[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], [0, 0, 0, 0, 0, 6]]\n assert candidate(k = 4,rowConditions = [[1, 2], [3, 4]],colConditions = [[1, 3], [2, 4]]) == [[1, 0, 0, 0], [0, 0, 3, 0], [0, 2, 0, 0], [0, 0, 0, 4]]\n assert candidate(k = 3,rowConditions = [[1, 2], [2, 3], [3, 1], [2, 3]],colConditions = [[2, 1]]) == []\n assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == []\n assert candidate(k = 15,rowConditions = [[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], [1, 15]],colConditions = [[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], [1, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 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, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n assert candidate(k = 7,rowConditions = [[7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [[0, 0, 0, 0, 0, 0, 7], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0]]\n assert candidate(k = 15,rowConditions = [[1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9]],colConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 10, 0, 0, 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(k = 8,rowConditions = [[8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[0, 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, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(k = 15,rowConditions = [[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]],colConditions = [[1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 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, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n assert candidate(k = 15,rowConditions = [[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], [1, 15]],colConditions = [[1, 15], [2, 15], [3, 15], [4, 15], [5, 15], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15], [1, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 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, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n assert candidate(k = 10,rowConditions = [[1, 5], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10]],colConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 9], [0, 0, 10, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(k = 9,rowConditions = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 6]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0]]\n assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6], [2, 5], [3, 6], [4, 6]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6], [2, 5], [3, 6], [4, 6]]) == [[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], [0, 0, 0, 0, 0, 6]]\n assert candidate(k = 7,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],colConditions = [[1, 7], [2, 6], [3, 5], [4, 5], [5, 6], [6, 7]]) == [[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]]\n assert candidate(k = 8,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[1, 8], [2, 7], [3, 6], [4, 5]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 5], [0, 0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 8, 0, 0, 0]]\n assert candidate(k = 10,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],colConditions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 6], [0, 0, 0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0]]\n assert candidate(k = 7,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],colConditions = [[1, 4], [4, 7], [2, 5], [5, 7], [3, 6], [6, 7]]) == [[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]]\n assert candidate(k = 8,rowConditions = [[1, 8], [2, 7], [3, 6], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n assert candidate(k = 9,rowConditions = [[1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],colConditions = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n assert candidate(k = 10,rowConditions = [[1, 3], [2, 4], [5, 8], [6, 9], [3, 7], [4, 10]],colConditions = [[1, 5], [2, 6], [3, 9], [4, 10], [7, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 8], [0, 0, 0, 0, 0, 0, 0, 9, 0, 0], [0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 10, 0]]\n assert candidate(k = 6,rowConditions = [[1, 3], [2, 3], [4, 5], [4, 6], [5, 6]],colConditions = [[1, 4], [2, 5], [3, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]\n assert candidate(k = 12,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],colConditions = [[1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n assert candidate(k = 13,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],colConditions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 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, 2], [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0], [0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0], [0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(k = 12,rowConditions = [[1, 6], [6, 11], [2, 7], [7, 12], [3, 8], [4, 9], [5, 10]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n assert candidate(k = 8,rowConditions = [[1, 3], [3, 5], [5, 7], [2, 4], [4, 6], [6, 8]],colConditions = [[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0], [0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 4, 0, 0], [0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 7, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [[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], [0, 0, 0, 0, 0, 6]]\n assert candidate(k = 12,rowConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11]],colConditions = [[1, 4], [4, 8], [2, 5], [5, 9], [3, 6], [6, 10], [7, 11], [8, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0], [0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0]]\n assert candidate(k = 11,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11]]\n assert candidate(k = 10,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],colConditions = [[1, 3], [3, 5], [5, 7], [7, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 3, 0, 0, 0], [0, 0, 4, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 8, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 9], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0]]\n assert candidate(k = 7,rowConditions = [[1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7]],colConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7]]) == [[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]]\n assert candidate(k = 9,rowConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]],colConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n assert candidate(k = 9,rowConditions = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]],colConditions = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == []\n assert candidate(k = 12,rowConditions = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12]],colConditions = [[1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n assert candidate(k = 10,rowConditions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],colConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n assert candidate(k = 8,rowConditions = [[1, 4], [4, 7], [7, 8], [2, 5], [5, 8], [3, 6], [6, 8]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n assert candidate(k = 6,rowConditions = [[1, 4], [2, 4], [3, 4], [5, 6]],colConditions = [[1, 3], [2, 3], [5, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 3, 0], [0, 0, 0, 5, 0, 0], [0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 0, 6]]\n assert candidate(k = 9,rowConditions = [[1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8], [0, 9, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(k = 7,rowConditions = [[1, 7], [2, 6], [3, 5], [4, 5], [5, 6], [6, 7]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [[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]]\n assert candidate(k = 15,rowConditions = [[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]],colConditions = [[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]]) == [[1, 0, 0, 0, 0, 0, 0, 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, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n assert candidate(k = 11,rowConditions = [[1, 11], [2, 10], [3, 9], [4, 8], [5, 7]],colConditions = [[1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0]]\n assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]],colConditions = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1]]) == []\n assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6]]) == [[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], [0, 0, 0, 0, 0, 6]]\n assert candidate(k = 9,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n assert candidate(k = 8,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n assert candidate(k = 10,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],colConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [2, 4], [4, 6], [6, 8], [8, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n assert candidate(k = 20,rowConditions = [[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]],colConditions = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20]]\n assert candidate(k = 7,rowConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 6], [3, 7], [4, 7], [5, 7]],colConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 6], [3, 7], [4, 7], [5, 7]]) == [[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]]\n assert candidate(k = 10,rowConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [2, 4], [4, 6], [6, 8], [8, 10]],colConditions = [[1, 4], [4, 7], [7, 10], [2, 5], [5, 8], [3, 6], [6, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n assert candidate(k = 7,rowConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [[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]]\n assert candidate(k = 12,rowConditions = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12]],colConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11]]) == [[1, 0, 0, 0, 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, 0, 3, 0, 0, 0, 0], [0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11], [0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0]]\n assert candidate(k = 7,rowConditions = [[1, 2], [2, 3], [4, 5], [5, 6], [6, 7]],colConditions = [[1, 2], [3, 4], [5, 6], [6, 7]]) == [[1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 2, 0, 0, 0], [0, 0, 5, 0, 0, 0, 0], [0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]\n assert candidate(k = 8,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[1, 3], [3, 5], [5, 7], [2, 4], [4, 6], [6, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n assert candidate(k = 12,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n assert candidate(k = 5,rowConditions = [[1, 5], [2, 5], [3, 5], [4, 5]],colConditions = [[1, 3], [2, 3], [3, 4], [4, 5]]) == [[1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 5]]\n assert candidate(k = 6,rowConditions = [[1, 4], [2, 5], [3, 6], [4, 6]],colConditions = [[1, 3], [2, 4], [3, 5], [4, 6]]) == [[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], [0, 0, 0, 0, 0, 6]]\n assert candidate(k = 9,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n assert candidate(k = 8,rowConditions = [[1, 8], [2, 7], [3, 6], [4, 5]],colConditions = [[1, 8], [2, 7], [3, 6], [4, 5]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 0, 5]]\n assert candidate(k = 7,rowConditions = [[1, 3], [2, 5], [3, 6], [4, 7], [5, 7], [6, 7]],colConditions = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 7], [6, 7]]) == [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]\n assert candidate(k = 12,rowConditions = [[1, 6], [6, 11], [11, 3], [3, 9], [9, 5], [5, 2], [2, 8], [8, 4], [4, 12], [12, 7], [7, 10]],colConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0], [0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0], [0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0]]\n assert candidate(k = 15,rowConditions = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],colConditions = [[1, 3], [2, 4], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 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, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n assert candidate(k = 6,rowConditions = [[1, 6], [2, 5], [3, 4], [4, 6], [5, 6]],colConditions = [[1, 5], [2, 6], [3, 5], [4, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 0, 6]]\n assert candidate(k = 12,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],colConditions = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n assert candidate(k = 8,rowConditions = [[1, 3], [3, 5], [2, 4], [4, 6], [5, 7], [6, 8]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n assert candidate(k = 20,rowConditions = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],colConditions = [[1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(k = 8,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1]]) == [[0, 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, 0, 0, 0], [0, 0, 6, 0, 0, 0, 0, 0], [0, 7, 0, 0, 0, 0, 0, 0], [8, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(k = 15,rowConditions = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]],colConditions = [[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]]) == [[1, 0, 0, 0, 0, 0, 0, 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, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n assert candidate(k = 10,rowConditions = [[1, 3], [2, 3], [3, 5], [3, 6], [4, 7], [7, 8], [9, 10]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0]]\n assert candidate(k = 20,rowConditions = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],colConditions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [11, 19], [12, 18], [13, 17], [14, 16], [15, 20]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(k = 10,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n assert candidate(k = 10,rowConditions = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],colConditions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 3, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, 0], [0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 9, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n assert candidate(k = 12,rowConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n assert candidate(k = 9,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],colConditions = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 7], [6, 8], [7, 9], [8, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],colConditions = [[1, 3], [3, 5], [5, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0], [0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]\n assert candidate(k = 15,rowConditions = [[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]],colConditions = [[1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9], [8, 8]]) == []\n assert candidate(k = 10,rowConditions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],colConditions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 6]]\n assert candidate(k = 8,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[1, 3], [3, 5], [5, 7]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 3, 0, 0], [0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 5, 0], [0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 7], [0, 0, 0, 0, 8, 0, 0, 0]]\n assert candidate(k = 9,rowConditions = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 9], [6, 9], [7, 9], [8, 9]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n assert candidate(k = 12,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],colConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11]]) == [[1, 0, 0, 0, 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, 0, 3, 0, 0, 0, 0], [0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11], [0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0]]\n assert candidate(k = 6,rowConditions = [[1, 3], [2, 3], [1, 4], [2, 4], [1, 5], [3, 5], [1, 6], [2, 6]],colConditions = [[1, 2], [1, 3], [2, 4], [3, 4], [1, 5], [3, 5]]) == [[1, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0], [0, 0, 0, 3, 0, 0], [0, 0, 0, 0, 4, 0], [0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5]]\n assert candidate(k = 15,rowConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14]],colConditions = [[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]]) == [[1, 0, 0, 0, 0, 0, 0, 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, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n assert candidate(k = 10,rowConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],colConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n"}, "metadata": {"canonical_parameter_names": ["k", "rowConditions", "colConditions"], "leetcode_dataset_entry_point": "Solution().buildMatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] buildMatrix(int k, int[][] rowConditions, int[][] colConditions) {", "container": "Solution", "callable": "buildMatrix", "parameters": [{"name": "k", "type": "int"}, {"name": "rowConditions", "type": "int[][]"}, {"name": "colConditions", "type": "int[][]"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2395, "task_id": "find-subarrays-with-equal-sum", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, determine whether there exist two subarrays of length 2 with equal sum. Note that the two subarrays must begin at different indices.\nReturn true if these subarrays exist, and false otherwise.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [4,2,4]\nOutput: true\nExplanation: The subarrays with elements [4,2] and [2,4] have the same sum of 6.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5]\nOutput: false\nExplanation: No two subarrays of size 2 have the same sum.\n\nExample 3:\n\nInput: nums = [0,0,0]\nOutput: true\nExplanation: The subarrays [nums[0],nums[1]] and [nums[1],nums[2]] have the same sum of 0. \nNote that even though the subarrays have the same content, the two subarrays are considered different because they are in different positions in the original array.\n\n \nConstraints:\n\n2 <= nums.length <= 1000\n-109 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 0, 1, -1, 0]) == True\n assert candidate(nums = [1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [5, -1, 5, -1]) == True\n assert candidate(nums = [1, 2, 3, 3, 2, 1]) == True\n assert candidate(nums = [-1, 0, 1, 0, -1]) == True\n assert candidate(nums = [1000000000, 1000000000]) == False\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == False\n assert candidate(nums = [-1, -2, -3, -4, -5]) == False\n assert candidate(nums = [1, 2, 3, 4, 5]) == False\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == True\n assert candidate(nums = [0, 0, 0]) == True\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == True\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1]) == True\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == False\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 1, 2]) == True\n assert candidate(nums = [1, 1, 2, 3, 3, 4]) == False\n assert candidate(nums = [-1, 0, 1, -1, 0, 1]) == True\n assert candidate(nums = [-1000000000, 1000000000, -1000000000, 1000000000]) == True\n assert candidate(nums = [4, 2, 4]) == True\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == True\n assert candidate(nums = [-1, -2, -3, -1, -2, -3, -1, -2, -3]) == 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]) == True\n assert candidate(nums = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30]) == True\n assert candidate(nums = [7, 3, 5, 7, 9, 5, 3, 1, 5, 7, 9, 3, 5, 7, 1]) == 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]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200]) == True\n assert candidate(nums = [-1, -2, -3, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == True\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]) == 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]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == True\n assert candidate(nums = [500000000, -500000000, 500000000, -500000000, 500000000, -500000000]) == True\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 = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000, 125000000, -125000000]) == True\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110]) == True\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]) == False\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == False\n assert candidate(nums = [999999999, -999999999, 999999999, -999999999, 999999999, -999999999, 999999999, -999999999]) == True\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 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]) == 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]) == True\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(nums = [5, 5, 10, 15, 5, 5]) == True\n assert candidate(nums = [-1, -2, -3, -4, -5, -1, -2, -3, -4, -5]) == True\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 10, 11]) == True\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, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == False\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 4, 3, 2, 1, 0]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == False\n assert candidate(nums = [5, -5, 5, -5, 5, -5]) == True\n assert candidate(nums = [5, 3, 5, 3, 5, 3]) == True\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == True\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == 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]) == False\n assert candidate(nums = [0, 1, 2, 3, 4, 3, 2, 1, 0]) == 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]) == True\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1]) == True\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 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]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\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]) == False\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -10]) == 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]) == False\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == True\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1]) == True\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == True\n assert candidate(nums = [999999999, 999999999, -999999999, -999999999, 1, -1, 1, -1]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == False\n assert candidate(nums = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == True\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110, 100, 120, 110, 130, 120, 140, 130, 150, 140, 160]) == True\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1, -2, -3, -4, -5]) == True\n assert candidate(nums = [5, -5, 5, -5, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == False\n assert candidate(nums = [-1, 2, -1, 2, -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]) == False\n assert candidate(nums = [5, 15, -10, 5, 10, 0, -5, 15, 5]) == True\n assert candidate(nums = [100, -100, 100, -100, 100, -100]) == True\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1, -2]) == 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 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == 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 = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 600]) == True\n assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == True\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == True\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 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]) == True\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == True\n assert candidate(nums = [100, 200, 300, 100, 200, 300, 100, 200, 300]) == 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, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == True\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3]) == True\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean findSubarrays(int[] nums) {", "container": "Solution", "callable": "findSubarrays", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2396, "task_id": "strictly-palindromic-number", "difficulty": "Medium", "problem_description": "An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromic.\nGiven an integer n, return true if n is strictly palindromic and false otherwise.\nA string is palindromic if it reads the same forward and backward.\n \nExample 1:\n\nInput: n = 9\nOutput: false\nExplanation: In base 2: 9 = 1001 (base 2), which is palindromic.\nIn base 3: 9 = 100 (base 3), which is not palindromic.\nTherefore, 9 is not strictly palindromic so we return false.\nNote that in bases 4, 5, 6, and 7, n = 9 is also not palindromic.\n\nExample 2:\n\nInput: n = 4\nOutput: false\nExplanation: We only consider base 2: 4 = 100 (base 2), which is not palindromic.\nTherefore, we return false.\n\n\n \nConstraints:\n\n4 <= n <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 15) == False\n assert candidate(n = 4) == False\n assert candidate(n = 9) == False\n assert candidate(n = 6) == False\n assert candidate(n = 20) == False\n assert candidate(n = 100) == False\n assert candidate(n = 10) == False\n assert candidate(n = 5) == False\n assert candidate(n = 99999) == False\n assert candidate(n = 4096) == False\n assert candidate(n = 21) == False\n assert candidate(n = 50000) == False\n assert candidate(n = 1000) == False\n assert candidate(n = 50) == False\n assert candidate(n = 10001) == False\n assert candidate(n = 300) == False\n assert candidate(n = 30) == False\n assert candidate(n = 99) == False\n assert candidate(n = 16) == False\n assert candidate(n = 33) == False\n assert candidate(n = 10000) == False\n assert candidate(n = 17) == False\n assert candidate(n = 1001) == False\n assert candidate(n = 23) == False\n assert candidate(n = 42) == False\n assert candidate(n = 360) == False\n assert candidate(n = 1024) == False\n assert candidate(n = 101) == False\n assert candidate(n = 100000) == False\n assert candidate(n = 2048) == False\n assert candidate(n = 255) == False\n assert candidate(n = 999) == False\n assert candidate(n = 75) == False\n assert candidate(n = 256) == False\n assert candidate(n = 32) == False\n assert candidate(n = 5000) == False\n assert candidate(n = 18) == False\n assert candidate(n = 123456) == False\n assert candidate(n = 75000) == False\n assert candidate(n = 9999) == False\n assert candidate(n = 65535) == False\n assert candidate(n = 88888) == False\n assert candidate(n = 81) == False\n assert candidate(n = 4321) == False\n assert candidate(n = 150) == False\n assert candidate(n = 200) == False\n assert candidate(n = 400) == False\n assert candidate(n = 31) == False\n assert candidate(n = 1234) == False\n assert candidate(n = 750) == False\n assert candidate(n = 121) == False\n assert candidate(n = 199) == False\n assert candidate(n = 700) == False\n assert candidate(n = 500) == False\n assert candidate(n = 54321) == False\n assert candidate(n = 25) == False\n assert candidate(n = 25000) == False\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().isStrictlyPalindromic", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isStrictlyPalindromic(int n) {", "container": "Solution", "callable": "isStrictlyPalindromic", "parameters": [{"name": "n", "type": "int"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2397, "task_id": "maximum-rows-covered-by-columns", "difficulty": "Medium", "problem_description": "You are given an m x n binary matrix matrix and an integer numSelect.\nYour goal is to select exactly numSelect distinct columns from matrix such that you cover as many rows as possible.\nA row is considered covered if all the 1's in that row are also part of a column that you have selected. If a row does not have any 1s, it is also considered covered.\nMore formally, let us consider selected = {c1, c2, ...., cnumSelect} as the set of columns selected by you. A row i is covered by selected if:\n\nFor each cell where matrix[i][j] == 1, the column j is in selected.\nOr, no cell in row i has a value of 1.\n\nReturn the maximum number of rows that can be covered by a set of numSelect columns.\n \nExample 1:\n\n\nInput: matrix = [[0,0,0],[1,0,1],[0,1,1],[0,0,1]], numSelect = 2\nOutput: 3\nExplanation:\nOne possible way to cover 3 rows is shown in the diagram above.\nWe choose s = {0, 2}.\n- Row 0 is covered because it has no occurrences of 1.\n- Row 1 is covered because the columns with value 1, i.e. 0 and 2 are present in s.\n- Row 2 is not covered because matrix[2][1] == 1 but 1 is not present in s.\n- Row 3 is covered because matrix[2][2] == 1 and 2 is present in s.\nThus, we can cover three rows.\nNote that s = {1, 2} will also cover 3 rows, but it can be shown that no more than three rows can be covered.\n\nExample 2:\n\n\nInput: matrix = [[1],[0]], numSelect = 1\nOutput: 2\nExplanation:\nSelecting the only column will result in both rows being covered since the entire matrix is selected.\n\n \nConstraints:\n\nm == matrix.length\nn == matrix[i].length\n1 <= m, n <= 12\nmatrix[i][j] is either 0 or 1.\n1 <= numSelect <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],numSelect = 4) == 3\n assert candidate(matrix = [[1, 1], [0, 0], [1, 0], [0, 1]],numSelect = 1) == 2\n assert candidate(matrix = [[1, 1, 1], [0, 1, 1], [1, 0, 1]],numSelect = 1) == 0\n assert candidate(matrix = [[0, 0], [0, 0]],numSelect = 1) == 2\n assert candidate(matrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],numSelect = 4) == 4\n assert candidate(matrix = [[0, 1, 0], [1, 0, 1], [0, 1, 0]],numSelect = 1) == 2\n assert candidate(matrix = [[0, 0, 1, 1], [1, 0, 1, 0], [1, 1, 0, 0]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],numSelect = 1) == 0\n assert candidate(matrix = [[1], [0]],numSelect = 1) == 2\n assert candidate(matrix = [[1, 1, 0, 0], [0, 1, 1, 0], [1, 0, 1, 1], [0, 0, 0, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]],numSelect = 2) == 2\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],numSelect = 4) == 4\n assert candidate(matrix = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1]],numSelect = 2) == 1\n assert candidate(matrix = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 0, 0, 0]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 1, 1], [1, 0, 1], [0, 0, 0], [1, 1, 1]],numSelect = 2) == 2\n assert candidate(matrix = [[0, 0], [0, 0], [1, 1]],numSelect = 2) == 3\n assert candidate(matrix = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 1, 0, 1]],numSelect = 2) == 1\n assert candidate(matrix = [[0, 0, 0], [1, 0, 1], [0, 1, 1], [0, 0, 1]],numSelect = 2) == 3\n assert candidate(matrix = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1]],numSelect = 3) == 1\n assert candidate(matrix = [[0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 0, 1], [1, 0, 0, 0]],numSelect = 3) == 3\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],numSelect = 1) == 3\n assert candidate(matrix = [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 1, 1], [0, 0, 1, 0]],numSelect = 2) == 2\n assert candidate(matrix = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]],numSelect = 2) == 1\n assert candidate(matrix = [[1, 0, 0, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 1, 0, 0, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],numSelect = 2) == 0\n assert candidate(matrix = [[1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1]],numSelect = 4) == 2\n assert candidate(matrix = [[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], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0]],numSelect = 8) == 7\n assert candidate(matrix = [[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]],numSelect = 2) == 0\n assert candidate(matrix = [[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]],numSelect = 5) == 2\n assert candidate(matrix = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1]],numSelect = 4) == 3\n assert candidate(matrix = [[1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]],numSelect = 4) == 1\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],numSelect = 5) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 0, 1, 1, 0], [1, 0, 0, 0, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[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]],numSelect = 5) == 2\n assert candidate(matrix = [[1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0]],numSelect = 7) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]],numSelect = 5) == 3\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [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]],numSelect = 4) == 3\n assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 0, 1, 0, 0], [1, 1, 0, 1, 0], [0, 0, 0, 0, 1], [1, 0, 1, 1, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0]],numSelect = 4) == 4\n assert candidate(matrix = [[0, 1, 1, 1, 0], [1, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 0, 0, 0, 0], [1, 1, 0, 0, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 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]],numSelect = 5) == 3\n assert candidate(matrix = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1]],numSelect = 4) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 1]],numSelect = 5) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 1], [1, 1, 0, 0, 1, 0]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 0, 1, 1, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]],numSelect = 6) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 0, 0, 1, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 1, 1, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]],numSelect = 4) == 2\n assert candidate(matrix = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]],numSelect = 4) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 0, 0, 0, 0, 1, 1]],numSelect = 6) == 2\n assert candidate(matrix = [[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], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],numSelect = 6) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]],numSelect = 5) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 0, 1, 0]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 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, 1, 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, 1, 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, 1, 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, 1, 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, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],numSelect = 2) == 2\n assert candidate(matrix = [[0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]],numSelect = 4) == 2\n assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0]],numSelect = 2) == 0\n assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]],numSelect = 3) == 1\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],numSelect = 4) == 2\n assert candidate(matrix = [[1, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1], [1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]],numSelect = 5) == 3\n assert candidate(matrix = [[1, 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, 1, 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, 1, 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, 1, 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, 1, 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, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],numSelect = 6) == 6\n assert candidate(matrix = [[1, 0, 0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1]],numSelect = 5) == 1\n assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]],numSelect = 3) == 1\n assert candidate(matrix = [[1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0]],numSelect = 4) == 2\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 1], [1, 1, 0, 0, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],numSelect = 5) == 3\n assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],numSelect = 3) == 1\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1]],numSelect = 4) == 2\n assert candidate(matrix = [[0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],numSelect = 8) == 3\n assert candidate(matrix = [[0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1], [0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 1]],numSelect = 4) == 2\n assert candidate(matrix = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0], [1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0]],numSelect = 5) == 3\n assert candidate(matrix = [[1, 1, 0, 1, 1, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 1, 0, 0]],numSelect = 4) == 1\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0]],numSelect = 4) == 3\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]],numSelect = 6) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 1], [1, 1, 0, 1, 0, 0]],numSelect = 4) == 2\n assert candidate(matrix = [[0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 1], [0, 0, 1, 0, 0, 1, 0]],numSelect = 5) == 2\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]],numSelect = 5) == 1\n assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],numSelect = 2) == 2\n assert candidate(matrix = [[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]],numSelect = 5) == 3\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0]],numSelect = 4) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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]],numSelect = 6) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 0]],numSelect = 4) == 2\n assert candidate(matrix = [[1, 1, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 0, 1, 1, 0, 0]],numSelect = 2) == 0\n assert candidate(matrix = [[1, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 0], [1, 1, 0, 1, 0], [0, 0, 1, 0, 1], [1, 0, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 0, 0, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],numSelect = 7) == 3\n assert candidate(matrix = [[0, 1, 0, 1, 1], [1, 1, 0, 1, 0], [0, 0, 1, 1, 1], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1]],numSelect = 3) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [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]],numSelect = 5) == 3\n assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 0, 0, 1, 1], [1, 1, 1, 0, 1]],numSelect = 3) == 1\n assert candidate(matrix = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],numSelect = 5) == 2\n assert candidate(matrix = [[1, 1, 0, 1, 1, 0, 1, 1], [0, 0, 1, 0, 0, 1, 0, 0], [1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0]],numSelect = 4) == 2\n assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 1, 1, 1, 0, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0]],numSelect = 5) == 2\n assert candidate(matrix = [[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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],numSelect = 6) == 3\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],numSelect = 2) == 0\n assert candidate(matrix = [[0, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 0, 1, 0]],numSelect = 5) == 3\n assert candidate(matrix = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0]],numSelect = 2) == 2\n assert candidate(matrix = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 0]],numSelect = 4) == 2\n assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1]],numSelect = 4) == 1\n"}, "metadata": {"canonical_parameter_names": ["matrix", "numSelect"], "leetcode_dataset_entry_point": "Solution().maximumRows", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumRows(int[][] matrix, int numSelect) {", "container": "Solution", "callable": "maximumRows", "parameters": [{"name": "matrix", "type": "int[][]"}, {"name": "numSelect", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2398, "task_id": "maximum-number-of-robots-within-budget", "difficulty": "Hard", "problem_description": "You have n robots. You are given two 0-indexed integer arrays, chargeTimes and runningCosts, both of length n. The ith robot costs chargeTimes[i] units to charge and costs runningCosts[i] units to run. You are also given an integer budget.\nThe total cost of running k chosen robots is equal to max(chargeTimes) + k * sum(runningCosts), where max(chargeTimes) is the largest charge cost among the k robots and sum(runningCosts) is the sum of running costs among the k robots.\nReturn the maximum number of consecutive robots you can run such that the total cost does not exceed budget.\n \nExample 1:\n\nInput: chargeTimes = [3,6,1,3,4], runningCosts = [2,1,3,4,5], budget = 25\nOutput: 3\nExplanation: \nIt is possible to run all individual and consecutive pairs of robots within budget.\nTo obtain answer 3, consider the first 3 robots. The total cost will be max(3,6,1) + 3 * sum(2,1,3) = 6 + 3 * 6 = 24 which is less than 25.\nIt can be shown that it is not possible to run more than 3 consecutive robots within budget, so we return 3.\n\nExample 2:\n\nInput: chargeTimes = [11,12,19], runningCosts = [10,8,7], budget = 19\nOutput: 0\nExplanation: No robot can be run that does not exceed the budget, so we return 0.\n\n \nConstraints:\n\nchargeTimes.length == runningCosts.length == n\n1 <= n <= 5 * 104\n1 <= chargeTimes[i], runningCosts[i] <= 105\n1 <= budget <= 1015\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(chargeTimes = [7, 1, 3, 9, 2],runningCosts = [8, 6, 4, 5, 0],budget = 30) == 2\n assert candidate(chargeTimes = [1, 1, 1, 1, 1],runningCosts = [100000, 100000, 100000, 100000, 100000],budget = 500000) == 2\n assert candidate(chargeTimes = [7, 7, 7, 7],runningCosts = [1, 1, 1, 1],budget = 20) == 3\n assert candidate(chargeTimes = [100000, 100000, 100000, 100000, 100000],runningCosts = [100000, 100000, 100000, 100000, 100000],budget = 1000000000000) == 5\n assert candidate(chargeTimes = [1, 2, 3, 4, 5],runningCosts = [1, 2, 3, 4, 5],budget = 20) == 2\n assert candidate(chargeTimes = [100000, 100000, 100000],runningCosts = [1, 1, 1],budget = 300001) == 3\n assert candidate(chargeTimes = [5, 11, 2, 7],runningCosts = [3, 9, 1, 10],budget = 30) == 2\n assert candidate(chargeTimes = [11, 12, 19],runningCosts = [10, 8, 7],budget = 19) == 0\n assert candidate(chargeTimes = [1, 2, 3],runningCosts = [10, 20, 30],budget = 100) == 2\n assert candidate(chargeTimes = [1, 2, 3, 4, 5],runningCosts = [5, 4, 3, 2, 1],budget = 20) == 2\n assert candidate(chargeTimes = [5, 5, 5, 5, 5],runningCosts = [1, 1, 1, 1, 1],budget = 15) == 3\n assert candidate(chargeTimes = [3, 6, 1, 3, 4],runningCosts = [2, 1, 3, 4, 5],budget = 25) == 3\n assert candidate(chargeTimes = [100000, 100000, 100000],runningCosts = [100000, 100000, 100000],budget = 100000000000) == 3\n assert candidate(chargeTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 500) == 4\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 50) == 4\n assert candidate(chargeTimes = [1, 3, 2, 4, 5, 3, 2, 1, 4, 5],runningCosts = [5, 1, 4, 2, 3, 5, 1, 4, 2, 3],budget = 25) == 3\n assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 20) == 4\n assert candidate(chargeTimes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 30) == 4\n assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],runningCosts = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],budget = 100) == 4\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 10) == 2\n assert candidate(chargeTimes = [20, 10, 15, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],budget = 300) == 7\n assert candidate(chargeTimes = [3, 6, 1, 3, 4, 5, 7, 8, 9, 10, 2, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],runningCosts = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],budget = 100) == 5\n assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9],budget = 40) == 3\n assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 20) == 4\n assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 300) == 10\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 1000) == 10\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],runningCosts = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 500) == 9\n assert candidate(chargeTimes = [3, 7, 9, 8, 5, 6, 2, 4],runningCosts = [10, 8, 5, 3, 9, 6, 7, 2],budget = 50) == 2\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 100) == 5\n assert candidate(chargeTimes = [10, 20, 30, 40, 50],runningCosts = [5, 15, 25, 35, 45],budget = 500) == 4\n assert candidate(chargeTimes = [10, 15, 20, 25, 30],runningCosts = [1, 2, 3, 4, 5],budget = 50) == 3\n assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],budget = 500005) == 2\n assert candidate(chargeTimes = [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],runningCosts = [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],budget = 500) == 9\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 50) == 4\n assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60],budget = 250) == 3\n assert candidate(chargeTimes = [100, 200, 300, 400, 500],runningCosts = [5, 5, 5, 5, 5],budget = 1500) == 5\n assert candidate(chargeTimes = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 30) == 5\n assert candidate(chargeTimes = [3, 6, 1, 3, 4, 9, 12, 8, 10, 5],runningCosts = [2, 1, 3, 4, 5, 1, 2, 3, 4, 5],budget = 100) == 5\n assert candidate(chargeTimes = [1, 2, 3, 4, 5],runningCosts = [10000, 10000, 10000, 10000, 10000],budget = 50000) == 2\n assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 500) == 9\n assert candidate(chargeTimes = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],runningCosts = [5, 9, 2, 6, 5, 3, 5, 9, 1, 4, 1],budget = 150) == 6\n assert candidate(chargeTimes = [10000, 20000, 30000, 40000, 50000],runningCosts = [1000, 2000, 3000, 4000, 5000],budget = 100000) == 4\n assert candidate(chargeTimes = [100000, 100000, 100000, 100000, 100000],runningCosts = [1, 1, 1, 1, 1],budget = 500005) == 5\n assert candidate(chargeTimes = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],runningCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],budget = 1000) == 6\n assert candidate(chargeTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 10000) == 10\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 100) == 5\n assert candidate(chargeTimes = [1, 10, 100, 1000, 10000],runningCosts = [1, 10, 100, 1000, 10000],budget = 111111) == 5\n assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9],budget = 50) == 4\n assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],runningCosts = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],budget = 1000) == 9\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 55) == 4\n assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 5) == 2\n assert candidate(chargeTimes = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],runningCosts = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],budget = 100) == 3\n assert candidate(chargeTimes = [100, 200, 300, 400, 500],runningCosts = [5, 10, 15, 20, 25],budget = 1000) == 5\n assert candidate(chargeTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 25) == 4\n assert candidate(chargeTimes = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 45) == 3\n assert candidate(chargeTimes = [50, 25, 75, 100, 125, 200, 150, 225, 300, 350],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 1000) == 5\n assert candidate(chargeTimes = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 10) == 2\n assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 5) == 2\n assert candidate(chargeTimes = [1, 5, 1, 5, 1, 5],runningCosts = [1, 1, 1, 1, 1, 1],budget = 12) == 2\n assert candidate(chargeTimes = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 1000000) == 10\n assert candidate(chargeTimes = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 100) == 5\n assert candidate(chargeTimes = [50, 40, 30, 20, 10],runningCosts = [1, 2, 3, 4, 5],budget = 100) == 4\n assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9],budget = 45) == 3\n assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 10) == 3\n assert candidate(chargeTimes = [50, 40, 30, 20, 10],runningCosts = [1, 2, 3, 4, 5],budget = 200) == 5\n assert candidate(chargeTimes = [100000, 100000, 100000, 100000, 100000],runningCosts = [100000, 100000, 100000, 100000, 100000],budget = 500000) == 2\n assert candidate(chargeTimes = [100, 200, 300, 400, 500],runningCosts = [50, 40, 30, 20, 10],budget = 1000) == 4\n assert candidate(chargeTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 100) == 5\n assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],runningCosts = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],budget = 500) == 4\n assert candidate(chargeTimes = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 5000010) == 10\n assert candidate(chargeTimes = [10, 20, 30, 40, 50],runningCosts = [1, 2, 3, 4, 5],budget = 100) == 4\n assert candidate(chargeTimes = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],runningCosts = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6],budget = 300) == 2\n assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],runningCosts = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],budget = 50) == 3\n assert candidate(chargeTimes = [100, 200, 300, 400, 500, 600],runningCosts = [1, 2, 3, 4, 5, 6],budget = 1500) == 6\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 100) == 5\n assert candidate(chargeTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],budget = 100) == 5\n assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 15) == 3\n assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 500) == 4\n assert candidate(chargeTimes = [9, 7, 5, 11, 13, 2, 8],runningCosts = [4, 8, 12, 16, 20, 24, 28],budget = 100) == 3\n assert candidate(chargeTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 1500) == 13\n assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 50) == 3\n assert candidate(chargeTimes = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 50) == 4\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],runningCosts = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 100) == 5\n assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 10) == 3\n assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 20) == 4\n assert candidate(chargeTimes = [1, 3, 2, 5, 4],runningCosts = [5, 3, 6, 2, 4],budget = 20) == 2\n assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9],budget = 100) == 5\n assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 200) == 6\n assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70],runningCosts = [1, 2, 3, 4, 5, 6, 7],budget = 200) == 6\n assert candidate(chargeTimes = [50, 40, 30, 20, 10],runningCosts = [1, 2, 3, 4, 5],budget = 300) == 5\n assert candidate(chargeTimes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],runningCosts = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 150) == 6\n assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9],budget = 30) == 3\n assert candidate(chargeTimes = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 1000000) == 10\n assert candidate(chargeTimes = [100000, 90000, 80000, 70000, 60000],runningCosts = [10000, 9000, 8000, 7000, 6000],budget = 10000000) == 5\n assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 250) == 3\n assert candidate(chargeTimes = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 200) == 10\n assert candidate(chargeTimes = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],runningCosts = [25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3],budget = 200) == 5\n assert candidate(chargeTimes = [20, 18, 15, 12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 100) == 4\n assert candidate(chargeTimes = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 100) == 7\n assert candidate(chargeTimes = [100000, 100000, 100000, 100000, 100000],runningCosts = [1, 1, 1, 1, 1],budget = 500000) == 5\n assert candidate(chargeTimes = [1000, 2000, 3000, 4000, 5000],runningCosts = [5, 5, 5, 5, 5],budget = 10000) == 5\n assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 300) == 16\n assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 500) == 10\n assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 500) == 4\n assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 150) == 5\n assert candidate(chargeTimes = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],runningCosts = [9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3],budget = 200) == 6\n assert candidate(chargeTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],budget = 250) == 7\n assert candidate(chargeTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 50) == 4\n"}, "metadata": {"canonical_parameter_names": ["chargeTimes", "runningCosts", "budget"], "leetcode_dataset_entry_point": "Solution().maximumRobots", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumRobots(int[] chargeTimes, int[] runningCosts, long budget) {", "container": "Solution", "callable": "maximumRobots", "parameters": [{"name": "chargeTimes", "type": "int[]"}, {"name": "runningCosts", "type": "int[]"}, {"name": "budget", "type": "long"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2399, "task_id": "check-distances-between-same-letters", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string s consisting of only lowercase English letters, where each letter in s appears exactly twice. You are also given a 0-indexed integer array distance of length 26.\nEach letter in the alphabet is numbered from 0 to 25 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, ... , 'z' -> 25).\nIn a well-spaced string, the number of letters between the two occurrences of the ith letter is distance[i]. If the ith letter does not appear in s, then distance[i] can be ignored.\nReturn true if s is a well-spaced string, otherwise return false.\n \nExample 1:\n\nInput: s = \"abaccb\", distance = [1,3,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\nOutput: true\nExplanation:\n- 'a' appears at indices 0 and 2 so it satisfies distance[0] = 1.\n- 'b' appears at indices 1 and 5 so it satisfies distance[1] = 3.\n- 'c' appears at indices 3 and 4 so it satisfies distance[2] = 0.\nNote that distance[3] = 5, but since 'd' does not appear in s, it can be ignored.\nReturn true because s is a well-spaced string.\n\nExample 2:\n\nInput: s = \"aa\", distance = [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]\nOutput: false\nExplanation:\n- 'a' appears at indices 0 and 1 so there are zero letters between them.\nBecause distance[0] = 1, s is not a well-spaced string.\n\n \nConstraints:\n\n2 <= s.length <= 52\ns consists only of lowercase English letters.\nEach letter appears in s exactly twice.\ndistance.length == 26\n0 <= distance[i] <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrztuvwxyz\",distance = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(s = \"zz\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50]) == False\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",distance = [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]) == False\n assert candidate(s = \"abcdcba\",distance = [3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"bbcaac\",distance = [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]) == False\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\",distance = [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, 0]) == False\n assert candidate(s = \"abcabc\",distance = [2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abba\",distance = [2, 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]) == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",distance = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(s = \"aa\",distance = [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]) == False\n assert candidate(s = \"abaccb\",distance = [1, 3, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",distance = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",distance = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcde\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"zazbzczdzdzczbza\",distance = [2, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdefghijkllkjihgfedcba\",distance = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"zxyxzyxzyx\",distance = [0, 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]) == False\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",distance = [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]) == False\n assert candidate(s = \"aabbaa\",distance = [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]) == False\n assert candidate(s = \"qrstuvwxyzzzyxwvutsrqp\",distance = [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]) == False\n assert candidate(s = \"zyxzyxzyxzyx\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == False\n assert candidate(s = \"acbacbacbacbacbacb\",distance = [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]) == False\n assert candidate(s = \"abcdefghijabcdefghij\",distance = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"zamnzamn\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == False\n assert candidate(s = \"abcdefghijzyxwvutsrqponmlk\",distance = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",distance = [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]) == False\n assert candidate(s = \"abcdefggfedcba\",distance = [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]) == False\n assert candidate(s = \"abcdefgabcdefg\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"lkjihglkjh\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\",distance = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdefgghgfedcba\",distance = [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abababababababab\",distance = [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]) == True\n assert candidate(s = \"abababababababababababab\",distance = [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]) == True\n assert candidate(s = \"pqrstuvwxyzzzyxwvutsrqp\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(s = \"abacabadabacabad\",distance = [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]) == False\n assert candidate(s = \"abcdefghijklmabcdefghijklm\",distance = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdefgihgfedcba\",distance = [6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"qponmlkjihgfedcbazyxwvutsr\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"zzzyyxxwwvvuuttssrrqqppoonnmmlkkjjiihhggffeeddccbaa\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50]) == False\n assert candidate(s = \"acbacbacbacb\",distance = [2, 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]) == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzz\",distance = [25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"zyxzyxzyxzyxzyxzyx\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == False\n assert candidate(s = \"qrstuvwxzyabcdefghijklmnop\",distance = [23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0]) == True\n assert candidate(s = \"mnopqrstuvwxzzyxwvutsrqponmlkjihgfedcba\",distance = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",distance = [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]) == False\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxw\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 7, 6, 5]) == False\n assert candidate(s = \"abcdabcd\",distance = [3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"abcdefgihgfedcba\",distance = [0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdefgabcdefg\",distance = [5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"qrstuvqr\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"mnopqrsmnopqr\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"mnopmnop\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",distance = [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]) == False\n assert candidate(s = \"qrstuvqrstuv\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdefgabcdefg\",distance = [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"zebrazebra\",distance = [23, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdefghijhgfedcba\",distance = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"ababababababababababababababababababababab\",distance = [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]) == True\n assert candidate(s = \"mnopqrsvwxyzxyzwvrsqponm\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"lmnopqrstuvw\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"abcdefgihgfedcba\",distance = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"mnopqrstuvwxyzz\",distance = [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]) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",distance = [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, 0]) == False\n assert candidate(s = \"pqrsrqpq\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"zabyxwvutsrqponmlkjihgfedcba\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdabcdabcdabcdabcdabcd\",distance = [3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"qrstuvrstu\",distance = [0, 0, 0, 0, 0, 0, 0, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"acbacbacbacbacbacb\",distance = [1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"lkjhlkjhlkjh\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"mnopqrsmnopqr\",distance = [0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdeffedcba\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0]) == False\n assert candidate(s = \"zabzyabzyabzyabz\",distance = [0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == False\n assert candidate(s = \"abcdefghigfedcba\",distance = [7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"aabbaaccddaaff\",distance = [2, 2, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",distance = [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]) == False\n assert candidate(s = \"abcdefghijabcdefghij\",distance = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdabcdeff\",distance = [1, 1, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"mnopqrstuvtwxzyabcdeffedcba\",distance = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",distance = [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]) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzza\",distance = [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, 0]) == False\n assert candidate(s = \"mnopqrstuv\",distance = [0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"mnopqrmpqr\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"lmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",distance = [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, 0]) == False\n assert candidate(s = \"mnopmnop\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"acbacbacba\",distance = [0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"mnopqrsmnopqrsmnopqrs\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"fedcbafedcba\",distance = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdef\",distance = [5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxzy\",distance = [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]) == True\n assert candidate(s = \"qrstuvqponmlkjihgfedcbazyxw\",distance = [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]) == False\n assert candidate(s = \"abcdabcdabcd\",distance = [3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n"}, "metadata": {"canonical_parameter_names": ["s", "distance"], "leetcode_dataset_entry_point": "Solution().checkDistances", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean checkDistances(String s, int[] distance) {", "container": "Solution", "callable": "checkDistances", "parameters": [{"name": "s", "type": "String"}, {"name": "distance", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2400, "task_id": "number-of-ways-to-reach-a-position-after-exactly-k-steps", "difficulty": "Medium", "problem_description": "You are given two positive integers startPos and endPos. Initially, you are standing at position startPos on an infinite number line. With one step, you can move either one position to the left, or one position to the right.\nGiven a positive integer k, return the number of different ways to reach the position endPos starting from startPos, such that you perform exactly k steps. Since the answer may be very large, return it modulo 109 + 7.\nTwo ways are considered different if the order of the steps made is not exactly the same.\nNote that the number line includes negative integers.\n \nExample 1:\n\nInput: startPos = 1, endPos = 2, k = 3\nOutput: 3\nExplanation: We can reach position 2 from 1 in exactly 3 steps in three ways:\n- 1 -> 2 -> 3 -> 2.\n- 1 -> 2 -> 1 -> 2.\n- 1 -> 0 -> 1 -> 2.\nIt can be proven that no other way is possible, so we return 3.\nExample 2:\n\nInput: startPos = 2, endPos = 5, k = 10\nOutput: 0\nExplanation: It is impossible to reach position 5 from position 2 in exactly 10 steps.\n\n \nConstraints:\n\n1 <= startPos, endPos, k <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startPos = 1,endPos = 2,k = 3) == 3\n assert candidate(startPos = 5,endPos = 5,k = 0) == 1\n assert candidate(startPos = 0,endPos = 0,k = 2) == 2\n assert candidate(startPos = 10,endPos = 1,k = 15) == 455\n assert candidate(startPos = 5,endPos = 5,k = 10) == 252\n assert candidate(startPos = 10,endPos = 1,k = 9) == 1\n assert candidate(startPos = 0,endPos = 0,k = 0) == 1\n assert candidate(startPos = 2,endPos = 5,k = 10) == 0\n assert candidate(startPos = 1,endPos = 2,k = 100) == 0\n assert candidate(startPos = 100,endPos = 50,k = 150) == 713790273\n assert candidate(startPos = 500,endPos = 450,k = 100) == 244856590\n assert candidate(startPos = -5,endPos = -10,k = 7) == 7\n assert candidate(startPos = 2,endPos = 1,k = 4) == 0\n assert candidate(startPos = 10,endPos = -10,k = 20) == 1\n assert candidate(startPos = 500,endPos = 400,k = 100) == 1\n assert candidate(startPos = -50,endPos = 50,k = 100) == 1\n assert candidate(startPos = 5,endPos = 5,k = 1) == 0\n assert candidate(startPos = 1000,endPos = 990,k = 20) == 15504\n assert candidate(startPos = -1,endPos = 1,k = 2) == 1\n assert candidate(startPos = 100,endPos = 50,k = 200) == 489348363\n assert candidate(startPos = -10,endPos = 10,k = 20) == 1\n assert candidate(startPos = 0,endPos = 1,k = 3) == 3\n assert candidate(startPos = 1,endPos = -1,k = 2) == 1\n assert candidate(startPos = 5,endPos = 15,k = 12) == 12\n assert candidate(startPos = -100,endPos = -200,k = 300) == 236868103\n assert candidate(startPos = 1,endPos = 2,k = 5) == 10\n assert candidate(startPos = 100,endPos = 100,k = 200) == 407336795\n assert candidate(startPos = -100,endPos = 100,k = 200) == 1\n assert candidate(startPos = 500,endPos = 400,k = 199) == 0\n assert candidate(startPos = 3,endPos = 3,k = 6) == 20\n assert candidate(startPos = 100,endPos = -100,k = 200) == 1\n assert candidate(startPos = 100,endPos = 100,k = 1) == 0\n assert candidate(startPos = -5,endPos = 5,k = 10) == 1\n assert candidate(startPos = 0,endPos = -10,k = 20) == 15504\n assert candidate(startPos = 50,endPos = 50,k = 50) == 605552882\n assert candidate(startPos = 1,endPos = 0,k = 3) == 3\n assert candidate(startPos = 100,endPos = 200,k = 150) == 297103639\n assert candidate(startPos = 1,endPos = -1,k = 4) == 4\n assert candidate(startPos = 3,endPos = -2,k = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["startPos", "endPos", "k"], "leetcode_dataset_entry_point": "Solution().numberOfWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfWays(int startPos, int endPos, int k) {", "container": "Solution", "callable": "numberOfWays", "parameters": [{"name": "startPos", "type": "int"}, {"name": "endPos", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2401, "task_id": "longest-nice-subarray", "difficulty": "Medium", "problem_description": "You are given an array nums consisting of positive integers.\nWe call a subarray of nums nice if the bitwise AND of every pair of elements that are in different positions in the subarray is equal to 0.\nReturn the length of the longest nice subarray.\nA subarray is a contiguous part of an array.\nNote that subarrays of length 1 are always considered nice.\n \nExample 1:\n\nInput: nums = [1,3,8,48,10]\nOutput: 3\nExplanation: The longest nice subarray is [3,8,48]. This subarray satisfies the conditions:\n- 3 AND 8 = 0.\n- 3 AND 48 = 0.\n- 8 AND 48 = 0.\nIt can be proven that no longer nice subarray can be obtained, so we return 3.\nExample 2:\n\nInput: nums = [3,1,5,11,13]\nOutput: 1\nExplanation: The length of the longest nice subarray is 1. Any subarray of length 1 can be chosen.\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 = [3, 1, 5, 11, 13]) == 1\n assert candidate(nums = [31, 1, 4, 32, 16]) == 4\n assert candidate(nums = [7, 11, 13, 14, 2, 5, 3]) == 2\n assert candidate(nums = [1, 2, 4, 8, 16]) == 5\n assert candidate(nums = [16, 17, 71, 62, 12, 24, 14]) == 1\n assert candidate(nums = [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, 1]) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [7, 14, 28, 56, 112]) == 1\n assert candidate(nums = [1073741824, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 1, 5, 6, 7, 4, 10]) == 2\n assert candidate(nums = [30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [31, 15, 7, 3, 1]) == 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]) == 20\n assert candidate(nums = [1, 3, 8, 48, 10]) == 3\n assert candidate(nums = [7, 11, 14, 18, 21, 23, 26, 28, 31, 33, 34, 38, 39, 42, 43, 46, 47, 50, 51, 54]) == 1\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 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\n assert candidate(nums = [1, 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]) == 30\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]) == 21\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, 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]) == 1\n assert candidate(nums = [31, 62, 124, 248, 496, 992, 1984, 3968, 7936, 15872, 31744, 63488, 126976, 253952, 507904, 1015808, 2031616, 4063232, 8126464, 16252928, 32505856, 65011712, 130023424, 260046848, 520093696, 1040187392, 2080374784]) == 1\n assert candidate(nums = [2147483647, 1, 2147483647, 2, 2147483647, 4, 2147483647, 8, 2147483647, 16, 2147483647, 32, 2147483647, 64, 2147483647, 128, 2147483647, 256, 2147483647, 512, 2147483647, 1024, 2147483647, 2048, 2147483647, 4096, 2147483647, 8192, 2147483647]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 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, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]) == 31\n assert candidate(nums = [2147483647, 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]) == 25\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]) == 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]) == 1\n assert candidate(nums = [1, 1073741824, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 21\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\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, 146, 150, 154, 158, 162, 166, 170]) == 1\n assert candidate(nums = [1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 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]) == 11\n assert candidate(nums = [1, 2, 3, 5, 6, 10, 12, 15, 17, 20, 24, 28, 30, 31, 35, 40, 42, 48, 56, 60]) == 2\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 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]) == 1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1023, 511, 255, 127, 63, 31, 15, 7, 3]) == 11\n assert candidate(nums = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432]) == 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]) == 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, 51, 53, 55, 57, 59]) == 1\n assert candidate(nums = [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864]) == 20\n assert candidate(nums = [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, 101, 105, 109, 113, 117, 121, 125]) == 1\n assert candidate(nums = [1073741823, 1, 1073741822, 2, 1073741821, 3, 1073741820, 4, 1073741819, 5, 1073741818, 6, 1073741817, 7, 1073741816, 8, 1073741815, 9, 1073741814, 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 2\n assert candidate(nums = [255, 256, 257, 258, 259, 260, 261, 262, 263, 264]) == 2\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]) == 22\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, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 21\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864, 3145728, 6291456, 12582912, 25165824, 50331648]) == 1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 20\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 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]) == 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, 31, 32]) == 2\n assert candidate(nums = [1, 2, 3, 5, 6, 10, 12, 15, 20, 21, 30, 60, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608]) == 23\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [2, 3, 6, 7, 14, 21, 23, 26, 31, 35, 38, 39, 42, 43, 46, 47, 51, 53, 54, 55, 58, 59, 62, 63, 66, 67, 70, 71, 75, 77, 78, 79, 82, 83, 86, 87, 91, 93, 94, 95, 98, 99, 102, 103, 106, 107, 111, 113, 114, 115, 118, 119, 122, 123, 127]) == 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]) == 25\n assert candidate(nums = [1, 2, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289]) == 2\n assert candidate(nums = [31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383]) == 1\n assert candidate(nums = [31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 16\n assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920, 163840, 327680, 655360, 1310720, 2621440, 5242880, 10485760, 20971520, 41943040, 83886080]) == 2\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, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == 2\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]) == 1\n assert candidate(nums = [1, 3, 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]) == 29\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\n assert candidate(nums = [1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 9\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, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 31\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]) == 30\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, 67108863, 134217727, 268435455, 536870911, 1073741823]) == 1\n assert candidate(nums = [3, 12, 48, 192, 768, 3072, 12288, 49152, 196608, 786432, 3145728, 12582912, 50331648, 201326592, 805306368, 3221225472, 12884901888, 51539607552, 206158430208, 824633720832]) == 20\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, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == 2\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]) == 31\n assert candidate(nums = [1, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864]) == 2\n assert candidate(nums = [1073741823, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 19\n assert candidate(nums = [1, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864]) == 2\n assert candidate(nums = [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, 1, 1073741824]) == 31\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]) == 21\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920, 163840, 327680, 655360, 1310720, 2621440, 5242880, 10485760, 20971520, 41943040, 83886080, 167772160]) == 2\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911]) == 1\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 25, 30, 33, 34, 40, 41, 48, 50, 60, 64]) == 2\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]) == 31\n assert candidate(nums = [1023, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 2\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, 2147483647]) == 31\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 10000000000000000, 100000000000000000, 1000000000000000000]) == 3\n assert candidate(nums = [1, 5, 3, 9, 7, 11, 13, 17, 15, 23, 21, 29, 27, 33, 31, 37, 35, 41, 39, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63]) == 1\n assert candidate(nums = [1, 6, 10, 18, 33, 66, 132, 264, 528, 1056, 2112, 4224, 8448, 16896, 33792, 67584, 135168, 270336, 540672, 1081344]) == 5\n assert candidate(nums = [1, 1073741823, 2, 536870911, 4, 268435455, 8, 134217727, 16, 67108863, 32, 33554431, 64, 16777215, 128, 8388607, 256, 4194303, 512, 2097151, 1024, 1048575, 2048, 524287, 4096, 262143, 8192, 131071, 16384, 65535, 32768, 32767]) == 2\n assert candidate(nums = [8388607, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384]) == 9\n assert candidate(nums = [1, 5, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217, 33554433, 67108865, 134217729, 268435457, 536870913, 1073741825]) == 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]) == 2\n assert candidate(nums = [2147483647, 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, 1]) == 31\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]) == 2\n assert candidate(nums = [1, 2, 3, 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920, 163840, 327680]) == 2\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1]) == 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]) == 2\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864, 3145728, 6291456, 12582912, 25165824, 50331648, 100663296, 201326592, 402653184, 805306368, 1610612736]) == 1\n assert candidate(nums = [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, 1]) == 31\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, 2147483647, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 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]) == 1\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344, 114688, 229376, 458752, 917504, 1835008, 3670016]) == 1\n assert candidate(nums = [2, 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920, 163840, 327680, 655360, 1310720, 2621440, 5242880, 10485760, 20971520, 41943040, 83886080, 167772160, 335544320, 671088640, 1342177280]) == 2\n assert candidate(nums = [3, 5, 1, 2, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 19\n assert candidate(nums = [1073741824, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 20\n assert candidate(nums = [31, 62, 124, 248, 496, 992, 1984, 3968, 7936, 15872, 31744, 63488, 126976, 253952, 507904, 1015808, 2031616, 4063232, 8126464, 16252928]) == 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]) == 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, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647]) == 1\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 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]) == 31\n assert candidate(nums = [511, 255, 127, 63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 12\n assert candidate(nums = [31, 28, 24, 20, 16, 12, 8, 4, 0]) == 3\n assert candidate(nums = [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, 1]) == 30\n assert candidate(nums = [999999999, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestNiceSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestNiceSubarray(int[] nums) {", "container": "Solution", "callable": "longestNiceSubarray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2402, "task_id": "meeting-rooms-iii", "difficulty": "Hard", "problem_description": "You are given an integer n. There are n rooms numbered from 0 to n - 1.\nYou are given a 2D integer array meetings where meetings[i] = [starti, endi] means that a meeting will be held during the half-closed time interval [starti, endi). All the values of starti are unique.\nMeetings are allocated to rooms in the following manner:\n\nEach meeting will take place in the unused room with the lowest number.\nIf there are no available rooms, the meeting will be delayed until a room becomes free. The delayed meeting should have the same duration as the original meeting.\nWhen a room becomes unused, meetings that have an earlier original start time should be given the room.\n\nReturn the number of the room that held the most meetings. If there are multiple rooms, return the room with the lowest number.\nA half-closed interval [a, b) is the interval between a and b including a and not including b.\n \nExample 1:\n\nInput: n = 2, meetings = [[0,10],[1,5],[2,7],[3,4]]\nOutput: 0\nExplanation:\n- At time 0, both rooms are not being used. The first meeting starts in room 0.\n- At time 1, only room 1 is not being used. The second meeting starts in room 1.\n- At time 2, both rooms are being used. The third meeting is delayed.\n- At time 3, both rooms are being used. The fourth meeting is delayed.\n- At time 5, the meeting in room 1 finishes. The third meeting starts in room 1 for the time period [5,10).\n- At time 10, the meetings in both rooms finish. The fourth meeting starts in room 0 for the time period [10,11).\nBoth rooms 0 and 1 held 2 meetings, so we return 0. \n\nExample 2:\n\nInput: n = 3, meetings = [[1,20],[2,10],[3,5],[4,9],[6,8]]\nOutput: 1\nExplanation:\n- At time 1, all three rooms are not being used. The first meeting starts in room 0.\n- At time 2, rooms 1 and 2 are not being used. The second meeting starts in room 1.\n- At time 3, only room 2 is not being used. The third meeting starts in room 2.\n- At time 4, all three rooms are being used. The fourth meeting is delayed.\n- At time 5, the meeting in room 2 finishes. The fourth meeting starts in room 2 for the time period [5,10).\n- At time 6, all three rooms are being used. The fifth meeting is delayed.\n- At time 10, the meetings in rooms 1 and 2 finish. The fifth meeting starts in room 1 for the time period [10,12).\nRoom 0 held 1 meeting while rooms 1 and 2 each held 2 meetings, so we return 1. \n\n \nConstraints:\n\n1 <= n <= 100\n1 <= meetings.length <= 105\nmeetings[i].length == 2\n0 <= starti < endi <= 5 * 105\nAll the values of starti are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,meetings = [[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]]) == 0\n assert candidate(n = 5,meetings = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6]]) == 0\n assert candidate(n = 10,meetings = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]]) == 0\n assert candidate(n = 5,meetings = [[0, 30], [5, 10], [15, 20], [5, 10]]) == 1\n assert candidate(n = 2,meetings = [[0, 10], [1, 5], [2, 7], [3, 4]]) == 0\n assert candidate(n = 4,meetings = [[0, 2], [0, 3], [1, 2], [2, 4], [3, 5]]) == 0\n assert candidate(n = 1,meetings = [[1, 2], [3, 4], [5, 6]]) == 0\n assert candidate(n = 5,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(n = 1,meetings = [[0, 1], [2, 3], [4, 5]]) == 0\n assert candidate(n = 10,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 0\n assert candidate(n = 4,meetings = [[0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 0\n assert candidate(n = 2,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(n = 3,meetings = [[1, 20], [2, 10], [3, 5], [4, 9], [6, 8]]) == 1\n assert candidate(n = 3,meetings = [[0, 100], [101, 200], [201, 300], [301, 400]]) == 0\n assert candidate(n = 1,meetings = [[0, 100], [100, 200], [200, 300]]) == 0\n assert candidate(n = 4,meetings = [[1, 10], [2, 15], [3, 20], [4, 25], [5, 30]]) == 0\n assert candidate(n = 10,meetings = [[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]]) == 0\n assert candidate(n = 7,meetings = [[1, 5], [1, 10], [1, 15], [1, 20], [2, 6], [2, 11], [2, 16], [2, 21], [3, 7], [3, 12], [3, 17], [3, 22], [4, 8], [4, 13], [4, 18], [4, 23], [5, 9], [5, 14], [5, 19], [5, 24]]) == 4\n assert candidate(n = 6,meetings = [[0, 100], [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], [31, 69], [32, 68], [33, 67], [34, 66], [35, 65], [36, 64], [37, 63], [38, 62], [39, 61], [40, 60], [41, 59], [42, 58], [43, 57], [44, 56], [45, 55], [46, 54], [47, 53], [48, 52], [49, 51]]) == 0\n assert candidate(n = 10,meetings = [[1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20], [11, 21], [12, 22], [13, 23], [14, 24], [15, 25], [16, 26], [17, 27], [18, 28], [19, 29], [20, 30]]) == 0\n assert candidate(n = 6,meetings = [[1, 3], [2, 5], [4, 7], [6, 9], [8, 11], [10, 13], [12, 15], [14, 17], [16, 19], [18, 21]]) == 0\n assert candidate(n = 4,meetings = [[1, 10], [2, 8], [3, 6], [4, 5], [5, 15], [6, 12], [7, 10], [8, 20], [9, 11], [10, 13]]) == 1\n assert candidate(n = 5,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]]) == 0\n assert candidate(n = 7,meetings = [[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]]) == 0\n assert candidate(n = 8,meetings = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20], [12, 21], [13, 22], [14, 23], [15, 24], [16, 25], [17, 26], [18, 27], [19, 28], [20, 29], [21, 30]]) == 0\n assert candidate(n = 3,meetings = [[10, 15], [20, 25], [30, 35], [5, 10], [15, 20], [25, 30], [35, 40], [5, 15], [10, 20], [20, 30]]) == 0\n assert candidate(n = 10,meetings = [[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]]) == 0\n assert candidate(n = 3,meetings = [[0, 10], [1, 5], [2, 7], [3, 4], [4, 6], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12]]) == 1\n assert candidate(n = 10,meetings = [[0, 1000], [500, 1500], [1000, 2000], [1500, 2500], [2000, 3000], [2500, 3500], [3000, 4000], [3500, 4500], [4000, 5000], [4500, 5500]]) == 0\n assert candidate(n = 2,meetings = [[0, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550]]) == 0\n assert candidate(n = 2,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [0, 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]]) == 0\n assert candidate(n = 5,meetings = [[0, 2], [0, 4], [0, 6], [0, 8], [0, 10], [1, 3], [1, 5], [1, 7], [1, 9], [2, 4], [2, 6], [2, 8], [3, 5], [3, 7], [4, 6], [4, 8], [5, 7], [6, 8], [7, 9], [8, 10]]) == 0\n assert candidate(n = 7,meetings = [[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]]) == 0\n assert candidate(n = 3,meetings = [[0, 3], [1, 2], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13]]) == 0\n assert candidate(n = 4,meetings = [[0, 10], [1, 5], [2, 7], [3, 4], [8, 12], [10, 15], [13, 18]]) == 1\n assert candidate(n = 3,meetings = [[0, 20], [1, 19], [2, 18], [3, 17], [4, 16], [5, 15], [6, 14], [7, 13], [8, 12], [9, 11], [10, 10], [11, 9], [12, 8], [13, 7], [14, 6], [15, 5], [16, 4], [17, 3], [18, 2], [19, 1]]) == 1\n assert candidate(n = 6,meetings = [[0, 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]]) == 0\n assert candidate(n = 2,meetings = [[100, 105], [101, 106], [102, 107], [103, 108], [104, 109], [105, 110], [106, 111], [107, 112], [108, 113], [109, 114]]) == 0\n assert candidate(n = 5,meetings = [[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]]) == 0\n assert candidate(n = 3,meetings = [[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]]) == 0\n assert candidate(n = 4,meetings = [[0, 50], [10, 60], [20, 70], [30, 80], [40, 90], [50, 100], [60, 110], [70, 120], [80, 130], [90, 140]]) == 0\n assert candidate(n = 6,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]]) == 0\n assert candidate(n = 2,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [0, 15], [15, 25], [25, 35], [35, 45], [45, 55]]) == 0\n assert candidate(n = 7,meetings = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 5], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8]]) == 1\n assert candidate(n = 7,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15]]) == 0\n assert candidate(n = 5,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]]) == 0\n assert candidate(n = 10,meetings = [[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]]) == 0\n assert candidate(n = 4,meetings = [[0, 30], [5, 10], [15, 20], [25, 35], [10, 25], [20, 30], [30, 40]]) == 1\n assert candidate(n = 7,meetings = [[1, 5], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [15, 21], [16, 22], [17, 23], [18, 24], [19, 25], [20, 26], [21, 27], [22, 28], [23, 29], [24, 30], [25, 31], [26, 32], [27, 33], [28, 34], [29, 35], [30, 36], [31, 37], [32, 38], [33, 39], [34, 40], [35, 41], [36, 42], [37, 43], [38, 44], [39, 45], [40, 46], [41, 47], [42, 48], [43, 49], [44, 50], [45, 51], [46, 52], [47, 53], [48, 54], [49, 55]]) == 0\n assert candidate(n = 6,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]]) == 0\n assert candidate(n = 7,meetings = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7]]) == 0\n assert candidate(n = 3,meetings = [[0, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400]]) == 0\n assert candidate(n = 4,meetings = [[0, 3], [1, 5], [2, 6], [3, 9], [4, 10], [5, 12], [6, 13], [7, 15], [8, 17], [9, 18]]) == 0\n assert candidate(n = 8,meetings = [[0, 15], [15, 30], [30, 45], [45, 60], [60, 75], [75, 90], [90, 105], [105, 120], [120, 135], [135, 150], [150, 165], [165, 180], [180, 195], [195, 210], [210, 225]]) == 0\n assert candidate(n = 3,meetings = [[0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [0, 30], [10, 40], [20, 50]]) == 0\n assert candidate(n = 8,meetings = [[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]]) == 0\n assert candidate(n = 5,meetings = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65]]) == 0\n assert candidate(n = 5,meetings = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [12, 14], [14, 16], [16, 18], [18, 20]]) == 0\n assert candidate(n = 5,meetings = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20], [11, 21], [12, 22], [13, 23], [14, 24], [15, 25], [16, 26], [17, 27], [18, 28], [19, 29]]) == 0\n assert candidate(n = 3,meetings = [[1, 100], [101, 200], [201, 300], [10, 110], [110, 210], [210, 310], [20, 120], [120, 220], [220, 320], [30, 130], [130, 230], [230, 330]]) == 0\n assert candidate(n = 6,meetings = [[0, 2], [1, 4], [2, 6], [3, 8], [4, 10], [5, 12], [6, 14], [7, 16], [8, 18], [9, 20], [10, 22], [11, 24], [12, 26], [13, 28], [14, 30], [15, 32], [16, 34], [17, 36], [18, 38], [19, 40]]) == 0\n assert candidate(n = 2,meetings = [[0, 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]]) == 0\n assert candidate(n = 4,meetings = [[1, 15], [2, 3], [5, 12], [8, 10], [6, 14], [16, 20], [17, 19], [21, 25], [22, 24], [23, 26]]) == 1\n assert candidate(n = 6,meetings = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21], [17, 22], [18, 23], [19, 24], [20, 25], [21, 26], [22, 27], [23, 28], [24, 29], [25, 30]]) == 0\n assert candidate(n = 5,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [1, 11], [11, 21], [21, 31], [31, 41], [41, 51]]) == 0\n assert candidate(n = 6,meetings = [[1, 1000], [2, 2000], [3, 3000], [4, 4000], [5, 5000], [6, 6000], [7, 7000], [8, 8000], [9, 9000], [10, 10000]]) == 0\n assert candidate(n = 3,meetings = [[0, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600], [550, 650], [600, 700], [650, 750], [700, 800]]) == 0\n assert candidate(n = 3,meetings = [[0, 2], [0, 5], [0, 10], [5, 10], [10, 15], [5, 15], [10, 20], [15, 25], [20, 30], [25, 35]]) == 0\n assert candidate(n = 7,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]]) == 0\n assert candidate(n = 4,meetings = [[1, 10], [2, 15], [3, 12], [4, 11], [5, 14], [6, 13], [7, 16], [8, 17], [9, 18], [10, 19]]) == 0\n assert candidate(n = 3,meetings = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]]) == 0\n assert candidate(n = 5,meetings = [[0, 2], [1, 4], [2, 6], [3, 8], [4, 10], [5, 12], [6, 14], [7, 16], [8, 18], [9, 20], [10, 22], [11, 24], [12, 26], [13, 28], [14, 30]]) == 0\n assert candidate(n = 5,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [5, 15], [15, 25], [25, 35], [35, 45], [45, 55]]) == 0\n assert candidate(n = 3,meetings = [[0, 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]]) == 0\n assert candidate(n = 3,meetings = [[1, 30], [2, 25], [3, 20], [4, 15], [5, 10], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 30], [12, 25], [13, 20], [14, 15], [15, 10], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]) == 2\n assert candidate(n = 2,meetings = [[0, 100], [50, 60], [20, 30], [10, 20], [30, 40], [70, 80], [110, 120], [90, 100], [130, 140], [150, 160]]) == 1\n assert candidate(n = 4,meetings = [[1, 18], [2, 15], [3, 12], [4, 9], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18]]) == 3\n assert candidate(n = 10,meetings = [[0, 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], [19, 21]]) == 0\n assert candidate(n = 7,meetings = [[0, 100], [100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [100, 500], [200, 600], [300, 700], [400, 800], [500, 900], [600, 1000]]) == 0\n assert candidate(n = 4,meetings = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50]]) == 0\n assert candidate(n = 8,meetings = [[0, 2], [0, 4], [0, 6], [0, 8], [0, 10], [0, 12], [0, 14], [0, 16], [0, 18], [0, 20], [1, 3], [1, 5], [1, 7], [1, 9], [1, 11], [1, 13], [1, 15], [1, 17], [1, 19], [1, 21]]) == 2\n assert candidate(n = 4,meetings = [[0, 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], [19, 21]]) == 0\n assert candidate(n = 5,meetings = [[0, 50], [10, 60], [20, 70], [30, 80], [40, 90], [50, 100], [60, 110], [70, 120], [80, 130], [90, 140]]) == 0\n assert candidate(n = 5,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]]) == 0\n assert candidate(n = 4,meetings = [[1, 10], [10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50], [45, 55], [50, 60], [55, 65], [60, 70]]) == 0\n assert candidate(n = 3,meetings = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 5], [2, 6], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12]]) == 0\n assert candidate(n = 7,meetings = [[0, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600], [550, 650], [600, 700], [650, 750], [700, 800]]) == 0\n assert candidate(n = 6,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]]) == 0\n assert candidate(n = 1,meetings = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [12, 130], [13, 140], [14, 150], [15, 160], [16, 170], [17, 180], [18, 190], [19, 200], [20, 210], [21, 220], [22, 230], [23, 240], [24, 250], [25, 260], [26, 270], [27, 280], [28, 290], [29, 300]]) == 0\n assert candidate(n = 6,meetings = [[1, 6], [2, 5], [3, 4], [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]]) == 0\n assert candidate(n = 10,meetings = [[0, 10], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 0\n assert candidate(n = 4,meetings = [[0, 15], [5, 20], [10, 25], [15, 30], [20, 35], [25, 40]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["n", "meetings"], "leetcode_dataset_entry_point": "Solution().mostBooked", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int mostBooked(int n, int[][] meetings) {", "container": "Solution", "callable": "mostBooked", "parameters": [{"name": "n", "type": "int"}, {"name": "meetings", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2404, "task_id": "most-frequent-even-element", "difficulty": "Easy", "problem_description": "Given an integer array nums, return the most frequent even element.\nIf there is a tie, return the smallest one. If there is no such element, return -1.\n \nExample 1:\n\nInput: nums = [0,1,2,2,4,4,1]\nOutput: 2\nExplanation:\nThe even elements are 0, 2, and 4. Of these, 2 and 4 appear the most.\nWe return the smallest one, which is 2.\nExample 2:\n\nInput: nums = [4,4,4,9,2,4]\nOutput: 4\nExplanation: 4 is the even element appears the most.\n\nExample 3:\n\nInput: nums = [29,47,21,41,13,37,25,7]\nOutput: -1\nExplanation: There is no even element.\n\n \nConstraints:\n\n1 <= nums.length <= 2000\n0 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [29, 47, 21, 41, 13, 37, 25, 7]) == -1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]) == 4\n assert candidate(nums = [8, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6]) == 8\n assert candidate(nums = [10, 20, 20, 10, 10, 20, 20, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9]) == -1\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 30, 20, 20]) == 20\n assert candidate(nums = [10, 20, 20, 10, 10, 20, 20]) == 20\n assert candidate(nums = [6, 6, 6, 6, 8, 8, 8, 8, 10, 10]) == 6\n assert candidate(nums = [6, 6, 6, 8, 8, 8, 10, 10, 10]) == 6\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4]) == 2\n assert candidate(nums = [0, 1, 2, 2, 4, 4, 1]) == 2\n assert candidate(nums = [2]) == 2\n assert candidate(nums = [6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8]) == 8\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == -1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == -1\n assert candidate(nums = [6, 6, 6, 8, 8, 8, 10, 10]) == 6\n assert candidate(nums = [6, 6, 8, 8, 8, 10, 10, 10, 10]) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8]) == 8\n assert candidate(nums = [100000, 100000, 99998, 99998, 99996]) == 99998\n assert candidate(nums = [10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30]) == 10\n assert candidate(nums = [4, 4, 4, 9, 2, 4]) == 4\n assert candidate(nums = [100000, 100000, 99998, 99998, 99998]) == 99998\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [2, 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, 22, 24, 26, 28, 30]) == 2\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 10\n assert candidate(nums = [99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131]) == -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, 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(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]) == 2\n assert candidate(nums = [0, 0, 0, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8]) == 8\n assert candidate(nums = [6, 6, 8, 8, 8, 10, 10, 10, 10, 12, 12, 12, 12, 12]) == 12\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 10000, 10000, 10000]) == 10000\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 200, 300, 300, 300, 300]) == 300\n assert candidate(nums = [0, 0, 0, 2, 2, 2, 4, 4, 4, 6, 6, 8, 8, 8, 8]) == 8\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 = [100000, 100000, 100000, 99998, 99998, 99996, 99996, 99996, 99994, 99994]) == 99996\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(nums = [1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500]) == 1500\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 4\n assert candidate(nums = [99998, 99998, 99998, 99996, 99996, 99994, 99994, 99994, 99992, 99992, 99992, 99992]) == 99992\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 50000\n assert candidate(nums = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 12\n assert candidate(nums = [5, 3, 1, 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, 8, 8, 8, 10, 10, 10, 12, 12, 14, 14, 14, 16, 16, 16, 16]) == 8\n assert candidate(nums = [100000, 99998, 99998, 99996, 99996, 99996, 99994, 99994]) == 99996\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 100]) == 100\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, 4, 6, 8, 10]) == 2\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\n assert candidate(nums = [0, 0, 2, 2, 2, 4, 4, 4, 4, 6, 6]) == 4\n assert candidate(nums = [2, 2, 4, 4, 4, 6, 6, 6, 6, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(nums = [100000, 100000, 100000, 99998, 99998, 99998, 99996, 99996, 99994]) == 99998\n assert candidate(nums = [18, 18, 18, 18, 20, 20, 20, 20, 22, 22, 22, 22, 24, 24, 24, 24]) == 18\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]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10]) == 2\n assert candidate(nums = [200000, 200000, 199998, 199998, 199996, 199996, 199994, 199994, 199992, 199992, 199990, 199990, 199988]) == 199990\n assert candidate(nums = [2, 2, 2, 4, 4, 4, 6, 6, 6, 8, 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, 14, 16, 16, 16, 18, 18, 18, 20, 20, 20, 22, 22, 22, 24, 24, 24, 26, 26, 26, 28, 28, 28, 30, 30, 30, 32, 32, 32, 34, 34, 34, 36, 36, 36, 38, 38, 38, 40, 40, 40, 42, 42, 42, 44, 44, 44, 46, 46, 46, 48, 48, 48, 50, 50, 50, 52, 52, 52, 54, 54, 54, 56, 56, 56, 58, 58, 58, 60, 60, 60, 62, 62, 62, 64, 64, 64, 66, 66, 66, 68, 68, 68, 70, 70, 70, 72, 72, 72, 74, 74, 74, 76, 76, 76, 78, 78, 78, 80, 80, 80, 82, 82, 82, 84, 84, 84, 86, 86, 86, 88, 88, 88, 90, 90, 90, 92, 92, 92, 94, 94, 94, 96, 96, 96, 98, 98, 98]) == 2\n assert candidate(nums = [6, 8, 10, 8, 6, 6, 8, 10, 10, 10, 10, 8]) == 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]) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(nums = [1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 19, 19]) == -1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 4\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 40, 40, 40, 50, 50, 50, 50]) == 50\n assert candidate(nums = [100000, 100000, 99998, 99998, 99998, 99996, 99996, 99996, 99996]) == 99996\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\n assert candidate(nums = [100000, 50000, 100000, 50000, 20000, 20000, 20000, 20000]) == 20000\n assert candidate(nums = [2, 4, 6, 8, 10, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10]) == 2\n assert candidate(nums = [8, 6, 8, 8, 6, 6, 8, 8, 6, 6, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums = [10, 20, 10, 30, 20, 20, 40, 40, 40, 40, 60, 60]) == 40\n assert candidate(nums = [18, 18, 18, 20, 20, 20, 22, 22, 22, 24, 24, 24, 26, 26, 26, 28, 28, 28, 30, 30, 30]) == 18\n assert candidate(nums = [1048576, 1048576, 2097152, 2097152, 3145728, 3145728, 4194304, 4194304]) == 1048576\n assert candidate(nums = [8, 3, 8, 6, 8, 5, 6, 6, 2, 2, 2, 10, 10, 10, 10]) == 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, 52, 54, 56, 58, 60]) == 2\n assert candidate(nums = [0, 2, 2, 4, 4, 4, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8]) == 8\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, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 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, 200]) == 4\n assert candidate(nums = [10, 10, 10, 12, 12, 14, 14, 14, 16, 16, 16, 16, 18, 18, 18, 18, 18, 20, 20, 20, 20, 20]) == 18\n assert candidate(nums = [20000, 20000, 19998, 19998, 19996, 19996, 19994, 19994, 19992, 19992]) == 19992\n assert candidate(nums = [2, 2, 4, 4, 4, 6, 6, 6, 8, 8, 8, 8, 10, 10, 10, 10, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 12, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 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, 8, 10]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40]) == 40\n assert candidate(nums = [200000, 200000, 100000, 100000, 50000, 50000, 25000, 25000]) == 25000\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\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18]) == 8\n assert candidate(nums = [20000, 19998, 19998, 19996, 19996, 19996, 19994, 19994, 19992, 19992, 19992, 19992]) == 19992\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\n assert candidate(nums = [2, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 8, 8, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 10, 10, 10, 10]) == 10\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]) == 0\n assert candidate(nums = [2, 4, 4, 6, 6, 6, 8, 8, 8, 8, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12]) == 12\n assert candidate(nums = [100000, 100000, 99998, 99998, 99998, 99996, 99996, 99996, 99994, 99994, 99994, 99994]) == 99994\n assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32, 34, 34, 36, 36, 38, 38, 40, 40, 42, 42, 44, 44, 46, 46, 48, 48, 50, 50, 52, 52, 54, 54, 56, 56, 58, 58, 60, 60, 62, 62, 64, 64, 66, 66, 68, 68, 70, 70, 72, 72, 74, 74, 76, 76, 78, 78, 80, 80, 82, 82, 84, 84, 86, 86, 88, 88, 90, 90, 92, 92, 94, 94, 96, 96, 98, 98, 100, 100]) == 2\n assert candidate(nums = [1000, 2000, 1000, 3000, 4000, 4000, 5000, 5000, 5000, 5000, 6000, 6000, 6000, 6000, 6000]) == 6000\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 4, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 6]) == 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, 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, 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]) == 2\n assert candidate(nums = [100000, 100000, 100000, 50000, 50000, 50000, 50000, 25000, 25000]) == 50000\n assert candidate(nums = [42, 42, 42, 42, 44, 44, 44, 44, 46, 46, 46, 46]) == 42\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\n assert candidate(nums = [8, 8, 8, 6, 6, 6, 4, 4, 4, 4]) == 4\n assert candidate(nums = [5000, 4000, 3000, 2000, 1000, 1000, 2000, 3000, 4000, 5000, 5000, 4000, 3000, 2000, 1000]) == 1000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 200, 200, 300, 300, 300, 400, 400, 400, 400, 500, 500, 500, 500, 500, 600, 600, 600, 600, 600, 600, 700, 700, 700, 700, 700, 700, 700, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 1000\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().mostFrequentEven", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int mostFrequentEven(int[] nums) {", "container": "Solution", "callable": "mostFrequentEven", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2405, "task_id": "optimal-partition-of-string", "difficulty": "Medium", "problem_description": "Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a single substring more than once.\nReturn the minimum number of substrings in such a partition.\nNote that each character should belong to exactly one substring in a partition.\n \nExample 1:\n\nInput: s = \"abacaba\"\nOutput: 4\nExplanation:\nTwo possible partitions are (\"a\",\"ba\",\"cab\",\"a\") and (\"ab\",\"a\",\"ca\",\"ba\").\nIt can be shown that 4 is the minimum number of substrings needed.\n\nExample 2:\n\nInput: s = \"ssssss\"\nOutput: 6\nExplanation:\nThe only valid partition is (\"s\",\"s\",\"s\",\"s\",\"s\",\"s\").\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of only English lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefg\") == 1\n assert candidate(s = \"abac\") == 2\n assert candidate(s = \"abcdabcdeabcdefabcdefg\") == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 44\n assert candidate(s = \"abababab\") == 4\n assert candidate(s = \"aaaaa\") == 5\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"optimal\") == 1\n assert candidate(s = \"abcabcabc\") == 3\n assert candidate(s = \"ssssss\") == 6\n assert candidate(s = \"abcabcabcabc\") == 4\n assert candidate(s = \"ab\") == 1\n assert candidate(s = \"partition\") == 2\n assert candidate(s = \"racecar\") == 2\n assert candidate(s = \"xyzxyzxyz\") == 3\n assert candidate(s = \"abcadef\") == 2\n assert candidate(s = \"banana\") == 3\n assert candidate(s = \"abc\") == 1\n assert candidate(s = \"pqrspqrspqrs\") == 3\n assert candidate(s = \"aabbccddeeff\") == 7\n assert candidate(s = \"abcdeabcde\") == 2\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"unique\") == 2\n assert candidate(s = \"characters\") == 2\n assert candidate(s = \"aaaaaaaaa\") == 9\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 27\n assert candidate(s = \"abacaba\") == 4\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"zxyxzyxz\") == 3\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzxy\") == 40\n assert candidate(s = \"abcdeabcdeabcdeabcdeabcde\") == 5\n assert candidate(s = \"xyxxyxyxyxxyxyxyxyxyx\") == 12\n assert candidate(s = \"repeatrepeatrepeatrepeatrepeat\") == 10\n assert candidate(s = \"uniquecharacterswithoutrepeating\") == 6\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 23\n assert candidate(s = \"abacabadabacabaeabacabafabacabadabacabaeabacabaf\") == 24\n assert candidate(s = \"abacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabaf\") == 72\n assert candidate(s = \"abacabadabacabad\") == 8\n assert candidate(s = \"aaaaabbbbbccccdddd\") == 15\n assert candidate(s = \"abcdabcdeabcdabcdef\") == 4\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiijjjjjjkkkkkkklllllllmmmmmmmnnnnnnnooooooooppppppppqqqqqqqqrrrrrrrrssssssssttttttttuuuuuuuuvvvvvvvvwwwwwwwwxxxxxxxxxyyyyyyyyzzzzzzzz\") == 145\n assert candidate(s = \"longerstringwithoutrepeats\") == 5\n assert candidate(s = \"abcba\") == 2\n assert candidate(s = \"mississippimississippimississippi\") == 15\n assert candidate(s = \"aaaaabbbbbcccccdddddeeeeeeaaaaabbbbbcccccdddddeeeeeeaaaaabbbbbcccccdddddeeeeeeaaaaabbbbbcccccdddddeeeeee\") == 85\n assert candidate(s = \"aaaaabbbbbcccccdddddeeeee\") == 21\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 30\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 16\n assert candidate(s = \"abracadabraabracadabraabracadabra\") == 15\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeffffffffgggggggghhhhhhhh\") == 59\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == 29\n assert candidate(s = \"noon\") == 2\n assert candidate(s = \"abcabcabcabcabcabc\") == 6\n assert candidate(s = \"thisisaverylongstringthatwilltestthealgorithm\") == 9\n assert candidate(s = \"hellohellohellohellohellohello\") == 12\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzz\") == 24\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 4\n assert candidate(s = \"abcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcba\") == 20\n assert candidate(s = \"abacdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 3\n assert candidate(s = \"abacaxbabax\") == 5\n assert candidate(s = \"aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee\") == 36\n assert candidate(s = \"nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn\") == 40\n assert candidate(s = \"abababababababababab\") == 10\n assert candidate(s = \"abacabadabacaba\") == 8\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 36\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 3\n assert candidate(s = \"thecuriouscaseofjeffersonraisethetrapdoor\") == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 28\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 70\n assert candidate(s = \"aaaaabbbbbccccddddeeeeffffgggg\") == 24\n assert candidate(s = \"xyzzysabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"abcdefghijklaaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 38\n assert candidate(s = \"abracadabraabracadabra\") == 10\n assert candidate(s = \"ababcbabcab\") == 5\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 28\n assert candidate(s = \"mnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 61\n assert candidate(s = \"abacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabaf\") == 36\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 13\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 40\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 9\n assert candidate(s = \"thisisanexamplestringthatneedstobepartitionedproperly\") == 9\n assert candidate(s = \"abacabadabacabaeabacabaf\") == 12\n assert candidate(s = \"abacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabaf\") == 60\n assert candidate(s = \"aabcbcbcbaabcabcbcbcba\") == 10\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrs\") == 4\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 2\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 5\n assert candidate(s = \"aaaaaabbcccddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooo\") == 43\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 2\n assert candidate(s = \"abcdabcdaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 29\n assert candidate(s = \"abacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabaf\") == 48\n assert candidate(s = \"ppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxxyyyyzzzz\") == 35\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 29\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzz\") == 12\n assert candidate(s = \"mississippi\") == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzz\") == 43\n assert candidate(s = \"abcabcabcabcabc\") == 5\n assert candidate(s = \"aaaaabbbbbbbaaaabbbbbbbaaaabbbbbbbaaaabbbbb\") == 36\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 50\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().partitionString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int partitionString(String s) {", "container": "Solution", "callable": "partitionString", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2406, "task_id": "divide-intervals-into-minimum-number-of-groups", "difficulty": "Medium", "problem_description": "You are given a 2D integer array intervals where intervals[i] = [lefti, righti] represents the inclusive interval [lefti, righti].\nYou have to divide the intervals into one or more groups such that each interval is in exactly one group, and no two intervals that are in the same group intersect each other.\nReturn the minimum number of groups you need to make.\nTwo intervals intersect if there is at least one common number between them. For example, the intervals [1, 5] and [5, 8] intersect.\n \nExample 1:\n\nInput: intervals = [[5,10],[6,8],[1,5],[2,3],[1,10]]\nOutput: 3\nExplanation: We can divide the intervals into the following groups:\n- Group 1: [1, 5], [6, 8].\n- Group 2: [2, 3], [5, 10].\n- Group 3: [1, 10].\nIt can be proven that it is not possible to divide the intervals into fewer than 3 groups.\n\nExample 2:\n\nInput: intervals = [[1,3],[5,6],[8,10],[11,13]]\nOutput: 1\nExplanation: None of the intervals overlap, so we can put all of them in one group.\n\n \nConstraints:\n\n1 <= intervals.length <= 105\nintervals[i].length == 2\n1 <= lefti <= righti <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 1\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n assert candidate(intervals = [[1, 1000000]]) == 1\n assert candidate(intervals = [[5, 10], [6, 8], [1, 5], [2, 3], [1, 10]]) == 3\n assert candidate(intervals = [[1, 3], [5, 6], [8, 10], [11, 13]]) == 1\n assert candidate(intervals = [[1, 100], [50, 60], [60, 90]]) == 3\n assert candidate(intervals = [[1, 10], [10, 20], [20, 30]]) == 2\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 1\n assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5]]) == 4\n assert candidate(intervals = [[1, 5], [2, 9], [3, 7], [4, 10]]) == 4\n assert candidate(intervals = [[1, 100], [2, 99], [3, 98], [4, 97]]) == 4\n assert candidate(intervals = [[5, 10], [11, 15], [16, 20], [21, 25], [1, 5], [6, 10], [11, 15], [16, 20], [21, 25]]) == 2\n assert candidate(intervals = [[5, 15], [10, 20], [25, 30], [5, 10], [15, 25], [20, 25]]) == 3\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]]) == 3\n assert candidate(intervals = [[1, 10], [2, 5], [3, 8], [4, 9], [5, 10], [6, 11]]) == 5\n assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [5, 15], [15, 25]]) == 3\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 2\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 3\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 2\n assert candidate(intervals = [[1000, 2000], [1500, 2500], [2000, 3000], [2500, 3500], [3000, 4000], [3500, 4500]]) == 3\n assert candidate(intervals = [[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]]) == 25\n assert candidate(intervals = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 5\n assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == 5\n assert candidate(intervals = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]]) == 10\n assert candidate(intervals = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15]]) == 5\n assert candidate(intervals = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50]]) == 3\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 5\n assert candidate(intervals = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50], [45, 55], [50, 60], [55, 65]]) == 3\n assert candidate(intervals = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [1, 50], [51, 100]]) == 11\n assert candidate(intervals = [[1, 500000], [500001, 1000000], [2, 499999], [500002, 999998], [3, 499998], [500003, 999997]]) == 3\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 5\n assert candidate(intervals = [[1, 500000], [500001, 1000000], [1, 500000], [500001, 1000000]]) == 2\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 3\n assert candidate(intervals = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == 10\n assert candidate(intervals = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50]]) == 2\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 5\n assert candidate(intervals = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 10\n assert candidate(intervals = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 10\n assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [10, 15], [20, 25], [30, 35], [15, 20], [25, 30], [35, 40], [20, 25]]) == 4\n assert candidate(intervals = [[1, 10], [11, 20], [1, 10], [11, 20], [1, 10], [11, 20]]) == 3\n assert candidate(intervals = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15]]) == 4\n assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 9\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30], [1, 10], [6, 15], [11, 20], [16, 25]]) == 3\n assert candidate(intervals = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10]]) == 10\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 2\n assert candidate(intervals = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]) == 2\n assert candidate(intervals = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997]]) == 4\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 5\n assert candidate(intervals = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 2\n assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [5, 20], [10, 25], [15, 30], [5, 30]]) == 5\n assert candidate(intervals = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]]) == 10\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 4\n assert candidate(intervals = [[1, 100000], [100000, 200000], [200000, 300000], [300000, 400000], [400000, 500000]]) == 2\n assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 2\n assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7]]) == 6\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400]]) == 3\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 5], [5, 9], [9, 13]]) == 3\n assert candidate(intervals = [[1, 3], [2, 5], [4, 7], [6, 9], [8, 11], [10, 13], [12, 15]]) == 2\n assert candidate(intervals = [[1, 1000000], [1000000, 2000000], [1, 1000000], [1000000, 2000000], [1, 1000000], [1000000, 2000000]]) == 6\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350]]) == 3\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 3\n assert candidate(intervals = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]]) == 9\n assert candidate(intervals = [[1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100]]) == 10\n assert candidate(intervals = [[1, 10], [11, 20], [1, 10], [11, 20], [1, 10], [11, 20], [1, 10], [11, 20]]) == 4\n assert candidate(intervals = [[1, 2], [2, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 2\n assert candidate(intervals = [[1, 5], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 3\n assert candidate(intervals = [[1, 1000000], [1, 1000000], [1, 1000000]]) == 3\n assert candidate(intervals = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]]) == 6\n assert candidate(intervals = [[1, 3], [1, 3], [1, 3], [2, 4], [2, 4], [2, 4], [3, 5], [3, 5], [3, 5], [4, 6], [4, 6], [4, 6], [5, 7], [5, 7], [5, 7]]) == 9\n assert candidate(intervals = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996]]) == 5\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]]) == 3\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 2\n assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50]]) == 2\n assert candidate(intervals = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996]]) == 5\n assert candidate(intervals = [[1, 1000], [500, 1500], [1000, 2000], [1500, 2500], [2000, 3000], [2500, 3500], [3000, 4000]]) == 3\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 6\n assert candidate(intervals = [[1, 3], [2, 6], [8, 10], [15, 18], [3, 5], [6, 9], [12, 14]]) == 3\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [1, 10], [11, 20], [21, 30], [31, 40], [1, 10]]) == 3\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 6\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [10, 20], [20, 30], [30, 40], [10, 30], [20, 40], [30, 50]]) == 7\n assert candidate(intervals = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35]]) == 2\n assert candidate(intervals = [[1, 10], [1, 10], [1, 10], [10, 20], [10, 20], [10, 20]]) == 6\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 6\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == 3\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == 5\n assert candidate(intervals = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3]]) == 10\n assert candidate(intervals = [[1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]]) == 6\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [200, 300]]) == 3\n assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [35, 40], [10, 15], [20, 25], [30, 35]]) == 2\n assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [1, 50]]) == 3\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]]) == 3\n assert candidate(intervals = [[1, 20], [5, 15], [10, 25], [15, 30], [20, 35]]) == 4\n assert candidate(intervals = [[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]]) == 1\n assert candidate(intervals = [[1, 3], [4, 7], [8, 10], [2, 5], [6, 9], [11, 13], [1, 4], [5, 8], [9, 12]]) == 3\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 2\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10], [2, 9]]) == 3\n"}, "metadata": {"canonical_parameter_names": ["intervals"], "leetcode_dataset_entry_point": "Solution().minGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minGroups(int[][] intervals) {", "container": "Solution", "callable": "minGroups", "parameters": [{"name": "intervals", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2407, "task_id": "longest-increasing-subsequence-ii", "difficulty": "Hard", "problem_description": "You are given an integer array nums and an integer k.\nFind the longest subsequence of nums that meets the following requirements:\n\nThe subsequence is strictly increasing and\nThe difference between adjacent elements in the subsequence is at most k.\n\nReturn the length of the longest subsequence that meets the requirements.\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 = [4,2,1,4,3,4,5,8,15], k = 3\nOutput: 5\nExplanation:\nThe longest subsequence that meets the requirements is [1,3,4,5,8].\nThe subsequence has a length of 5, so we return 5.\nNote that the subsequence [1,3,4,5,8,15] does not meet the requirements because 15 - 8 = 7 is larger than 3.\n\nExample 2:\n\nInput: nums = [7,4,5,1,8,12,4,7], k = 5\nOutput: 4\nExplanation:\nThe longest subsequence that meets the requirements is [4,5,8,12].\nThe subsequence has a length of 4, so we return 4.\n\nExample 3:\n\nInput: nums = [1,5], k = 1\nOutput: 1\nExplanation:\nThe longest subsequence that meets the requirements is [1].\nThe subsequence has a length of 1, so we return 1.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i], k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18],k = 10) == 3\n assert candidate(nums = [5, 4, 3, 2, 1],k = 2) == 1\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18],k = 5) == 3\n assert candidate(nums = [7, 4, 5, 1, 8, 12, 4, 7],k = 5) == 4\n assert candidate(nums = [5, 4, 3, 2, 1],k = 1) == 1\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18],k = 2) == 2\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18],k = 4) == 3\n assert candidate(nums = [9, 7, 5, 3, 1],k = 2) == 1\n assert candidate(nums = [1, 3, 5, 7, 9],k = 2) == 5\n assert candidate(nums = [4, 2, 1, 4, 3, 4, 5, 8, 15],k = 3) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 5\n assert candidate(nums = [1, 5],k = 1) == 1\n assert candidate(nums = [5, 8, 7, 1, 9, 1, 5, 10, 4, 3, 2, 1],k = 2) == 4\n assert candidate(nums = [3, 1, 2, 4, 6, 5, 9, 7, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20],k = 3) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 4) == 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 = 19) == 20\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 9) == 2\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 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],k = 5) == 10\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 11\n assert candidate(nums = [100, 200, 300, 400, 500, 401, 402, 403, 501, 502, 503, 504],k = 10) == 5\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 = 1) == 2\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 15) == 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],k = 1) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 10\n assert candidate(nums = [5, 8, 7, 1, 9, 12, 10, 13, 14, 15],k = 4) == 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 = 2) == 20\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],k = 4) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 10\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 = 50) == 10\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 10\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9],k = 2) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 10\n assert candidate(nums = [1, 4, 3, 5, 6, 2, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],k = 4) == 11\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 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],k = 1) == 20\n assert candidate(nums = [9, 1, 4, 7, 3, 2, 5, 8, 6],k = 3) == 4\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 = 1) == 1\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 = 1) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 1\n assert candidate(nums = [20, 10, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 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],k = 3) == 30\n assert candidate(nums = [1, 6, 7, 8, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12],k = 3) == 10\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8],k = 2) == 8\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],k = 99999) == 6\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],k = 1) == 3\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 9) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 2) == 15\n assert candidate(nums = [2, 3, 1, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 3) == 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) == 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],k = 5) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 14) == 15\n assert candidate(nums = [3, 1, 5, 2, 6, 4, 7],k = 3) == 4\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == 16\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6],k = 3) == 6\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 1\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 4) == 2\n assert candidate(nums = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 10\n assert candidate(nums = [3, 1, 2, 5, 4, 8, 7, 6, 10, 9],k = 3) == 5\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 10) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 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],k = 19) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 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],k = 0) == 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],k = 1) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 1\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 10) == 1\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985],k = 5) == 1\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 92, 83, 74, 65, 56, 47, 38, 29],k = 9) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 10\n assert candidate(nums = [3, 1, 5, 4, 7, 6, 9, 8, 11, 10],k = 2) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 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 = 2) == 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 = 1) == 2\n assert candidate(nums = [3, 10, 2, 1, 20, 15, 25, 28, 30, 100],k = 10) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],k = 5) == 1\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 4) == 1\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 2) == 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) == 20\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],k = 3) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 90) == 10\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 16\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 0) == 1\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93],k = 90) == 9\n assert candidate(nums = [5, 3, 4, 8, 9, 10, 20, 30, 15, 25, 35, 45, 55, 65, 75],k = 20) == 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 = 2) == 10\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6],k = 2) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10],k = 3) == 10\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58],k = 2) == 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],k = 2) == 20\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],k = 3) == 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],k = 1) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 10\n assert candidate(nums = [4, 3, 5, 4, 7, 6, 8, 9, 10, 11, 12],k = 3) == 8\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 1\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 100) == 1\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 = 5) == 1\n assert candidate(nums = [4, 3, 2, 1, 100, 101, 102, 103, 104],k = 3) == 5\n assert candidate(nums = [3, 10, 2, 1, 20, 1, 15, 5, 17, 6, 8, 9, 11, 13, 14],k = 4) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 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, 1, 2, 3, 4, 5],k = 5) == 20\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 3) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 50) == 15\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().lengthOfLIS", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int lengthOfLIS(int[] nums, int k) {", "container": "Solution", "callable": "lengthOfLIS", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2409, "task_id": "count-days-spent-together", "difficulty": "Easy", "problem_description": "Alice and Bob are traveling to Rome for separate business meetings.\nYou are given 4 strings arriveAlice, leaveAlice, arriveBob, and leaveBob. Alice will be in the city from the dates arriveAlice to leaveAlice (inclusive), while Bob will be in the city from the dates arriveBob to leaveBob (inclusive). Each will be a 5-character string in the format \"MM-DD\", corresponding to the month and day of the date.\nReturn the total number of days that Alice and Bob are in Rome together.\nYou can assume that all dates occur in the same calendar year, which is not a leap year. Note that the number of days per month can be represented as: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31].\n \nExample 1:\n\nInput: arriveAlice = \"08-15\", leaveAlice = \"08-18\", arriveBob = \"08-16\", leaveBob = \"08-19\"\nOutput: 3\nExplanation: Alice will be in Rome from August 15 to August 18. Bob will be in Rome from August 16 to August 19. They are both in Rome together on August 16th, 17th, and 18th, so the answer is 3.\n\nExample 2:\n\nInput: arriveAlice = \"10-01\", leaveAlice = \"10-31\", arriveBob = \"11-01\", leaveBob = \"12-31\"\nOutput: 0\nExplanation: There is no day when Alice and Bob are in Rome together, so we return 0.\n\n \nConstraints:\n\nAll dates are provided in the format \"MM-DD\".\nAlice and Bob's arrival dates are earlier than or equal to their leaving dates.\nThe given dates are valid dates of a non-leap year.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arriveAlice = \"03-10\",leaveAlice = \"05-20\",arriveBob = \"04-01\",leaveBob = \"04-30\") == 30\n assert candidate(arriveAlice = \"06-15\",leaveAlice = \"06-20\",arriveBob = \"06-18\",leaveBob = \"06-25\") == 3\n assert candidate(arriveAlice = \"10-01\",leaveAlice = \"10-31\",arriveBob = \"11-01\",leaveBob = \"12-31\") == 0\n assert candidate(arriveAlice = \"01-01\",leaveAlice = \"12-31\",arriveBob = \"01-01\",leaveBob = \"12-31\") == 365\n assert candidate(arriveAlice = \"08-15\",leaveAlice = \"08-18\",arriveBob = \"08-16\",leaveBob = \"08-19\") == 3\n assert candidate(arriveAlice = \"12-20\",leaveAlice = \"12-31\",arriveBob = \"12-25\",leaveBob = \"12-30\") == 6\n assert candidate(arriveAlice = \"05-24\",leaveAlice = \"07-24\",arriveBob = \"07-25\",leaveBob = \"08-25\") == 0\n assert candidate(arriveAlice = \"07-20\",leaveAlice = \"08-15\",arriveBob = \"07-25\",leaveBob = \"08-10\") == 17\n assert candidate(arriveAlice = \"07-01\",leaveAlice = \"08-01\",arriveBob = \"07-15\",leaveBob = \"07-30\") == 16\n assert candidate(arriveAlice = \"07-10\",leaveAlice = \"07-20\",arriveBob = \"07-15\",leaveBob = \"07-25\") == 6\n assert candidate(arriveAlice = \"01-01\",leaveAlice = \"01-31\",arriveBob = \"01-01\",leaveBob = \"01-31\") == 31\n assert candidate(arriveAlice = \"03-10\",leaveAlice = \"03-10\",arriveBob = \"03-10\",leaveBob = \"03-10\") == 1\n assert candidate(arriveAlice = \"06-15\",leaveAlice = \"06-15\",arriveBob = \"06-15\",leaveBob = \"06-15\") == 1\n assert candidate(arriveAlice = \"01-01\",leaveAlice = \"01-31\",arriveBob = \"01-15\",leaveBob = \"01-20\") == 6\n assert candidate(arriveAlice = \"03-14\",leaveAlice = \"03-14\",arriveBob = \"03-14\",leaveBob = \"03-14\") == 1\n assert candidate(arriveAlice = \"06-01\",leaveAlice = \"06-30\",arriveBob = \"05-25\",leaveBob = \"06-10\") == 10\n assert candidate(arriveAlice = \"10-01\",leaveAlice = \"10-20\",arriveBob = \"09-25\",leaveBob = \"10-25\") == 20\n assert candidate(arriveAlice = \"11-15\",leaveAlice = \"12-31\",arriveBob = \"12-01\",leaveBob = \"12-31\") == 31\n assert candidate(arriveAlice = \"04-10\",leaveAlice = \"06-10\",arriveBob = \"05-01\",leaveBob = \"06-30\") == 41\n assert candidate(arriveAlice = \"01-10\",leaveAlice = \"02-20\",arriveBob = \"02-15\",leaveBob = \"03-25\") == 6\n assert candidate(arriveAlice = \"09-15\",leaveAlice = \"09-15\",arriveBob = \"09-15\",leaveBob = \"09-15\") == 1\n assert candidate(arriveAlice = \"12-20\",leaveAlice = \"12-31\",arriveBob = \"12-15\",leaveBob = \"01-10\") == 0\n assert candidate(arriveAlice = \"05-05\",leaveAlice = \"07-05\",arriveBob = \"05-05\",leaveBob = \"05-05\") == 1\n assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-15\",arriveBob = \"03-01\",leaveBob = \"03-31\") == 15\n assert candidate(arriveAlice = \"08-15\",leaveAlice = \"09-15\",arriveBob = \"09-15\",leaveBob = \"10-15\") == 1\n assert candidate(arriveAlice = \"03-05\",leaveAlice = \"03-20\",arriveBob = \"03-15\",leaveBob = \"03-25\") == 6\n assert candidate(arriveAlice = \"03-15\",leaveAlice = \"03-20\",arriveBob = \"03-10\",leaveBob = \"03-14\") == 0\n assert candidate(arriveAlice = \"06-01\",leaveAlice = \"06-30\",arriveBob = \"06-15\",leaveBob = \"06-25\") == 11\n assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-10\",arriveBob = \"03-01\",leaveBob = \"03-15\") == 10\n assert candidate(arriveAlice = \"01-15\",leaveAlice = \"01-15\",arriveBob = \"01-15\",leaveBob = \"01-15\") == 1\n assert candidate(arriveAlice = \"01-01\",leaveAlice = \"01-31\",arriveBob = \"01-15\",leaveBob = \"02-14\") == 17\n assert candidate(arriveAlice = \"12-15\",leaveAlice = \"12-15\",arriveBob = \"12-16\",leaveBob = \"12-16\") == 0\n assert candidate(arriveAlice = \"11-11\",leaveAlice = \"11-11\",arriveBob = \"11-11\",leaveBob = \"11-11\") == 1\n assert candidate(arriveAlice = \"11-20\",leaveAlice = \"12-15\",arriveBob = \"11-25\",leaveBob = \"12-25\") == 21\n assert candidate(arriveAlice = \"11-11\",leaveAlice = \"11-25\",arriveBob = \"11-20\",leaveBob = \"12-10\") == 6\n assert candidate(arriveAlice = \"04-30\",leaveAlice = \"05-30\",arriveBob = \"04-15\",leaveBob = \"05-15\") == 16\n assert candidate(arriveAlice = \"07-20\",leaveAlice = \"08-10\",arriveBob = \"07-25\",leaveBob = \"08-05\") == 12\n assert candidate(arriveAlice = \"08-05\",leaveAlice = \"10-10\",arriveBob = \"09-01\",leaveBob = \"10-05\") == 35\n assert candidate(arriveAlice = \"08-15\",leaveAlice = \"09-20\",arriveBob = \"09-05\",leaveBob = \"10-05\") == 16\n assert candidate(arriveAlice = \"01-15\",leaveAlice = \"03-20\",arriveBob = \"02-10\",leaveBob = \"04-15\") == 39\n assert candidate(arriveAlice = \"10-20\",leaveAlice = \"11-10\",arriveBob = \"11-05\",leaveBob = \"12-15\") == 6\n assert candidate(arriveAlice = \"06-30\",leaveAlice = \"07-01\",arriveBob = \"06-29\",leaveBob = \"07-02\") == 2\n assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-01\",arriveBob = \"03-01\",leaveBob = \"03-02\") == 1\n assert candidate(arriveAlice = \"04-01\",leaveAlice = \"04-30\",arriveBob = \"03-20\",leaveBob = \"04-25\") == 25\n assert candidate(arriveAlice = \"09-10\",leaveAlice = \"10-10\",arriveBob = \"09-15\",leaveBob = \"09-20\") == 6\n assert candidate(arriveAlice = \"05-10\",leaveAlice = \"05-10\",arriveBob = \"05-10\",leaveBob = \"05-10\") == 1\n assert candidate(arriveAlice = \"07-20\",leaveAlice = \"07-25\",arriveBob = \"07-20\",leaveBob = \"07-25\") == 6\n assert candidate(arriveAlice = \"08-01\",leaveAlice = \"08-31\",arriveBob = \"07-20\",leaveBob = \"08-10\") == 10\n assert candidate(arriveAlice = \"06-15\",leaveAlice = \"06-20\",arriveBob = \"06-21\",leaveBob = \"06-25\") == 0\n assert candidate(arriveAlice = \"12-15\",leaveAlice = \"12-20\",arriveBob = \"12-15\",leaveBob = \"12-20\") == 6\n assert candidate(arriveAlice = \"11-01\",leaveAlice = \"11-30\",arriveBob = \"10-25\",leaveBob = \"11-25\") == 25\n assert candidate(arriveAlice = \"07-31\",leaveAlice = \"07-31\",arriveBob = \"08-01\",leaveBob = \"08-01\") == 0\n assert candidate(arriveAlice = \"08-01\",leaveAlice = \"08-31\",arriveBob = \"07-25\",leaveBob = \"08-15\") == 15\n assert candidate(arriveAlice = \"02-14\",leaveAlice = \"03-14\",arriveBob = \"03-01\",leaveBob = \"04-01\") == 14\n assert candidate(arriveAlice = \"08-10\",leaveAlice = \"09-10\",arriveBob = \"09-05\",leaveBob = \"09-20\") == 6\n assert candidate(arriveAlice = \"01-01\",leaveAlice = \"01-31\",arriveBob = \"02-01\",leaveBob = \"02-28\") == 0\n assert candidate(arriveAlice = \"03-15\",leaveAlice = \"03-31\",arriveBob = \"04-01\",leaveBob = \"04-10\") == 0\n assert candidate(arriveAlice = \"01-01\",leaveAlice = \"12-31\",arriveBob = \"06-15\",leaveBob = \"06-15\") == 1\n assert candidate(arriveAlice = \"11-15\",leaveAlice = \"11-30\",arriveBob = \"12-01\",leaveBob = \"12-31\") == 0\n assert candidate(arriveAlice = \"09-01\",leaveAlice = \"11-15\",arriveBob = \"10-01\",leaveBob = \"10-31\") == 31\n assert candidate(arriveAlice = \"04-15\",leaveAlice = \"06-20\",arriveBob = \"05-01\",leaveBob = \"07-15\") == 51\n assert candidate(arriveAlice = \"08-20\",leaveAlice = \"09-20\",arriveBob = \"09-10\",leaveBob = \"10-10\") == 11\n assert candidate(arriveAlice = \"07-10\",leaveAlice = \"08-10\",arriveBob = \"07-20\",leaveBob = \"08-20\") == 22\n assert candidate(arriveAlice = \"05-10\",leaveAlice = \"06-10\",arriveBob = \"05-20\",leaveBob = \"06-20\") == 22\n assert candidate(arriveAlice = \"06-01\",leaveAlice = \"06-10\",arriveBob = \"06-05\",leaveBob = \"06-05\") == 1\n assert candidate(arriveAlice = \"11-10\",leaveAlice = \"11-10\",arriveBob = \"11-11\",leaveBob = \"11-11\") == 0\n assert candidate(arriveAlice = \"09-01\",leaveAlice = \"10-31\",arriveBob = \"08-01\",leaveBob = \"09-15\") == 15\n assert candidate(arriveAlice = \"12-15\",leaveAlice = \"12-31\",arriveBob = \"12-10\",leaveBob = \"12-15\") == 1\n assert candidate(arriveAlice = \"07-01\",leaveAlice = \"07-31\",arriveBob = \"06-25\",leaveBob = \"07-25\") == 25\n assert candidate(arriveAlice = \"03-10\",leaveAlice = \"04-10\",arriveBob = \"04-05\",leaveBob = \"05-10\") == 6\n assert candidate(arriveAlice = \"03-31\",leaveAlice = \"03-31\",arriveBob = \"04-01\",leaveBob = \"04-01\") == 0\n assert candidate(arriveAlice = \"09-10\",leaveAlice = \"10-10\",arriveBob = \"09-15\",leaveBob = \"10-15\") == 26\n assert candidate(arriveAlice = \"05-25\",leaveAlice = \"06-05\",arriveBob = \"05-26\",leaveBob = \"06-04\") == 10\n assert candidate(arriveAlice = \"10-15\",leaveAlice = \"10-20\",arriveBob = \"09-25\",leaveBob = \"10-16\") == 2\n assert candidate(arriveAlice = \"09-01\",leaveAlice = \"10-31\",arriveBob = \"08-15\",leaveBob = \"09-15\") == 15\n assert candidate(arriveAlice = \"03-01\",leaveAlice = \"03-31\",arriveBob = \"02-28\",leaveBob = \"03-10\") == 10\n assert candidate(arriveAlice = \"06-01\",leaveAlice = \"08-31\",arriveBob = \"07-01\",leaveBob = \"07-31\") == 31\n assert candidate(arriveAlice = \"07-25\",leaveAlice = \"08-25\",arriveBob = \"07-26\",leaveBob = \"07-27\") == 2\n assert candidate(arriveAlice = \"06-01\",leaveAlice = \"08-31\",arriveBob = \"07-01\",leaveBob = \"09-30\") == 62\n assert candidate(arriveAlice = \"02-15\",leaveAlice = \"03-15\",arriveBob = \"03-10\",leaveBob = \"04-10\") == 6\n assert candidate(arriveAlice = \"04-30\",leaveAlice = \"05-01\",arriveBob = \"04-29\",leaveBob = \"05-02\") == 2\n assert candidate(arriveAlice = \"09-01\",leaveAlice = \"09-15\",arriveBob = \"08-20\",leaveBob = \"09-10\") == 10\n assert candidate(arriveAlice = \"03-15\",leaveAlice = \"03-15\",arriveBob = \"03-15\",leaveBob = \"03-15\") == 1\n assert candidate(arriveAlice = \"05-05\",leaveAlice = \"05-05\",arriveBob = \"05-04\",leaveBob = \"05-06\") == 1\n assert candidate(arriveAlice = \"08-25\",leaveAlice = \"09-05\",arriveBob = \"09-01\",leaveBob = \"09-10\") == 5\n assert candidate(arriveAlice = \"07-05\",leaveAlice = \"08-10\",arriveBob = \"08-05\",leaveBob = \"09-15\") == 6\n assert candidate(arriveAlice = \"09-10\",leaveAlice = \"11-20\",arriveBob = \"10-01\",leaveBob = \"10-31\") == 31\n assert candidate(arriveAlice = \"09-15\",leaveAlice = \"10-15\",arriveBob = \"10-01\",leaveBob = \"11-01\") == 15\n assert candidate(arriveAlice = \"12-15\",leaveAlice = \"12-31\",arriveBob = \"12-20\",leaveBob = \"01-15\") == 0\n assert candidate(arriveAlice = \"05-05\",leaveAlice = \"07-10\",arriveBob = \"06-01\",leaveBob = \"06-30\") == 30\n assert candidate(arriveAlice = \"03-15\",leaveAlice = \"05-15\",arriveBob = \"04-01\",leaveBob = \"04-30\") == 30\n assert candidate(arriveAlice = \"11-10\",leaveAlice = \"11-20\",arriveBob = \"11-21\",leaveBob = \"11-30\") == 0\n assert candidate(arriveAlice = \"02-20\",leaveAlice = \"03-10\",arriveBob = \"03-05\",leaveBob = \"04-01\") == 6\n assert candidate(arriveAlice = \"01-05\",leaveAlice = \"01-10\",arriveBob = \"01-08\",leaveBob = \"01-15\") == 3\n assert candidate(arriveAlice = \"01-29\",leaveAlice = \"02-02\",arriveBob = \"02-01\",leaveBob = \"02-28\") == 2\n assert candidate(arriveAlice = \"10-10\",leaveAlice = \"10-20\",arriveBob = \"09-30\",leaveBob = \"10-10\") == 1\n assert candidate(arriveAlice = \"04-01\",leaveAlice = \"04-30\",arriveBob = \"04-10\",leaveBob = \"04-20\") == 11\n assert candidate(arriveAlice = \"05-15\",leaveAlice = \"06-15\",arriveBob = \"06-10\",leaveBob = \"07-10\") == 6\n assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-01\",arriveBob = \"02-28\",leaveBob = \"03-01\") == 2\n assert candidate(arriveAlice = \"01-10\",leaveAlice = \"02-10\",arriveBob = \"02-01\",leaveBob = \"03-10\") == 10\n assert candidate(arriveAlice = \"11-01\",leaveAlice = \"11-30\",arriveBob = \"11-15\",leaveBob = \"12-15\") == 16\n assert candidate(arriveAlice = \"05-01\",leaveAlice = \"05-31\",arriveBob = \"04-30\",leaveBob = \"05-10\") == 10\n assert candidate(arriveAlice = \"12-10\",leaveAlice = \"12-31\",arriveBob = \"12-20\",leaveBob = \"01-10\") == 0\n assert candidate(arriveAlice = \"07-20\",leaveAlice = \"08-20\",arriveBob = \"08-01\",leaveBob = \"08-19\") == 19\n assert candidate(arriveAlice = \"01-10\",leaveAlice = \"02-10\",arriveBob = \"01-15\",leaveBob = \"03-15\") == 27\n assert candidate(arriveAlice = \"05-10\",leaveAlice = \"05-15\",arriveBob = \"05-12\",leaveBob = \"05-20\") == 4\n assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-05\",arriveBob = \"03-01\",leaveBob = \"03-10\") == 5\n assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-01\",arriveBob = \"02-29\",leaveBob = \"03-02\") == 1\n assert candidate(arriveAlice = \"11-25\",leaveAlice = \"12-10\",arriveBob = \"12-01\",leaveBob = \"12-15\") == 10\n assert candidate(arriveAlice = \"04-10\",leaveAlice = \"04-30\",arriveBob = \"04-15\",leaveBob = \"05-15\") == 16\n assert candidate(arriveAlice = \"07-10\",leaveAlice = \"07-20\",arriveBob = \"07-20\",leaveBob = \"07-30\") == 1\n assert candidate(arriveAlice = \"11-11\",leaveAlice = \"11-30\",arriveBob = \"11-15\",leaveBob = \"11-25\") == 11\n assert candidate(arriveAlice = \"03-20\",leaveAlice = \"03-31\",arriveBob = \"04-01\",leaveBob = \"04-10\") == 0\n assert candidate(arriveAlice = \"09-15\",leaveAlice = \"10-15\",arriveBob = \"10-10\",leaveBob = \"11-10\") == 6\n assert candidate(arriveAlice = \"11-01\",leaveAlice = \"11-15\",arriveBob = \"10-25\",leaveBob = \"11-10\") == 10\n assert candidate(arriveAlice = \"07-20\",leaveAlice = \"08-20\",arriveBob = \"07-15\",leaveBob = \"07-25\") == 6\n"}, "metadata": {"canonical_parameter_names": ["arriveAlice", "leaveAlice", "arriveBob", "leaveBob"], "leetcode_dataset_entry_point": "Solution().countDaysTogether", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countDaysTogether(String arriveAlice, String leaveAlice, String arriveBob, String leaveBob) {", "container": "Solution", "callable": "countDaysTogether", "parameters": [{"name": "arriveAlice", "type": "String"}, {"name": "leaveAlice", "type": "String"}, {"name": "arriveBob", "type": "String"}, {"name": "leaveBob", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2410, "task_id": "maximum-matching-of-players-with-trainers", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array players, where players[i] represents the ability of the ith player. You are also given a 0-indexed integer array trainers, where trainers[j] represents the training capacity of the jth trainer.\nThe ith player can match with the jth trainer if the player's ability is less than or equal to the trainer's training capacity. Additionally, the ith player can be matched with at most one trainer, and the jth trainer can be matched with at most one player.\nReturn the maximum number of matchings between players and trainers that satisfy these conditions.\n \nExample 1:\n\nInput: players = [4,7,9], trainers = [8,2,5,8]\nOutput: 2\nExplanation:\nOne of the ways we can form two matchings is as follows:\n- players[0] can be matched with trainers[0] since 4 <= 8.\n- players[1] can be matched with trainers[3] since 7 <= 8.\nIt can be proven that 2 is the maximum number of matchings that can be formed.\n\nExample 2:\n\nInput: players = [1,1,1], trainers = [10]\nOutput: 1\nExplanation:\nThe trainer can be matched with any of the 3 players.\nEach player can only be matched with one trainer, so the maximum answer is 1.\n\n \nConstraints:\n\n1 <= players.length, trainers.length <= 105\n1 <= players[i], trainers[j] <= 109\n\n \nNote: This question is the same as 445: Assign Cookies.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(players = [1, 2, 3],trainers = [10, 11, 12]) == 3\n assert candidate(players = [10, 20, 30],trainers = [1, 2, 3]) == 0\n assert candidate(players = [1, 2, 3, 4, 5],trainers = [5, 4, 3, 2, 1]) == 5\n assert candidate(players = [1000000000],trainers = [1000000000]) == 1\n assert candidate(players = [1, 2, 3],trainers = [4, 5, 6, 7, 8]) == 3\n assert candidate(players = [1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1]) == 5\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10]) == 1\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(players = [1],trainers = [1]) == 1\n assert candidate(players = [1, 10, 100],trainers = [10, 100, 1000]) == 3\n assert candidate(players = [5, 6, 7],trainers = [8, 9, 10]) == 3\n assert candidate(players = [1, 3, 5, 7, 9],trainers = [2, 4, 6, 8, 10]) == 5\n assert candidate(players = [5, 5, 5],trainers = [5, 5, 5]) == 3\n assert candidate(players = [9, 7, 5, 3, 1],trainers = [10, 8, 6, 4, 2]) == 5\n assert candidate(players = [1, 2, 3],trainers = [10, 20, 30]) == 3\n assert candidate(players = [10, 20, 30, 40],trainers = [5, 15, 25, 35, 45]) == 4\n assert candidate(players = [10, 20, 30],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(players = [1, 1000000000],trainers = [1000000000, 1]) == 2\n assert candidate(players = [5, 5, 5, 5],trainers = [5, 5, 5, 5]) == 4\n assert candidate(players = [1, 3, 5, 7],trainers = [2, 4, 6, 8]) == 4\n assert candidate(players = [1, 1, 1],trainers = [10]) == 1\n assert candidate(players = [4, 7, 9],trainers = [8, 2, 5, 8]) == 2\n assert candidate(players = [100, 200, 300],trainers = [150, 250, 350]) == 3\n assert candidate(players = [3, 7, 11, 15, 19],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(players = [4, 7, 9, 11, 13, 15],trainers = [10, 8, 12, 6, 14, 16]) == 6\n assert candidate(players = [100, 200, 300, 400, 500],trainers = [50, 150, 250, 350, 450, 550]) == 5\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(players = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(players = [1, 2, 3, 4, 5],trainers = [5, 5, 5, 5, 5]) == 5\n assert candidate(players = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(players = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],trainers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(players = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],trainers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 10\n assert candidate(players = [3, 3, 3, 4, 4, 4, 5, 5, 5],trainers = [3, 4, 5]) == 3\n assert candidate(players = [1, 5, 8, 9, 11, 13, 15, 17, 19],trainers = [2, 3, 6, 7, 10, 12, 14, 16, 18, 20]) == 8\n assert candidate(players = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 4\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(players = [50, 40, 30, 20, 10],trainers = [15, 25, 35, 45, 55]) == 5\n assert candidate(players = [1, 1, 1, 1, 1],trainers = [1, 2, 3, 4, 5]) == 5\n assert candidate(players = [1, 3, 6, 7, 8],trainers = [2, 4, 5, 8, 9]) == 4\n assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(players = [1, 100, 1000, 10000, 100000],trainers = [1, 100, 1000, 10000, 100000]) == 5\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 10\n assert candidate(players = [5, 10, 15, 20, 25, 30],trainers = [25, 10, 5, 30, 20, 15]) == 6\n assert candidate(players = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],trainers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4],trainers = [1, 2, 2, 3, 3, 4, 4, 5]) == 8\n assert candidate(players = [10, 20, 30, 40, 50],trainers = [15, 25, 35, 45, 55]) == 5\n assert candidate(players = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],trainers = [500, 600, 700, 800, 900, 1000, 100, 200, 300, 400]) == 10\n assert candidate(players = [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],trainers = [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\n assert candidate(players = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],trainers = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 10\n assert candidate(players = [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],trainers = [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]) == 25\n assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trainers = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 5\n assert candidate(players = [1, 5, 9, 13, 17],trainers = [3, 7, 11, 15, 19]) == 5\n assert candidate(players = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],trainers = [5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 15\n assert candidate(players = [3, 6, 7, 8, 10, 11, 15],trainers = [4, 5, 8, 9, 12, 16, 20]) == 6\n assert candidate(players = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],trainers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 10\n assert candidate(players = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],trainers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(players = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1]) == 5\n assert candidate(players = [5, 10, 15, 20, 25, 30],trainers = [3, 6, 9, 12, 18, 21, 24, 27]) == 5\n assert candidate(players = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500],trainers = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 10\n assert candidate(players = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],trainers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 15\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(players = [10, 20, 30, 40, 50],trainers = [1, 2, 3, 4, 5]) == 0\n assert candidate(players = [1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 20\n assert candidate(players = [1, 10, 100, 1000, 10000, 100000],trainers = [100000, 10000, 1000, 100, 10, 1]) == 6\n assert candidate(players = [100, 200, 300, 400, 500],trainers = [250, 350, 150, 450, 550]) == 5\n assert candidate(players = [10, 10, 10, 10, 10],trainers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(players = [100, 200, 300, 400, 500],trainers = [150, 250, 350, 450, 550]) == 5\n assert candidate(players = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],trainers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 9\n assert candidate(players = [1000000000, 1000000000, 1000000000],trainers = [1000000000, 1000000000]) == 2\n assert candidate(players = [1, 100, 200, 300, 400, 500],trainers = [500, 400, 300, 200, 100, 1]) == 6\n assert candidate(players = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],trainers = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 1099, 1199, 1299, 1399, 1499]) == 14\n assert candidate(players = [1000000000, 999999999, 999999998, 999999997, 999999996],trainers = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5\n assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],trainers = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10]) == 10\n assert candidate(players = [10, 20, 30, 40, 50],trainers = [5, 15, 25, 35, 45, 55]) == 5\n assert candidate(players = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],trainers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],trainers = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 15\n assert candidate(players = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],trainers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 9\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(players = [1, 1, 1, 1, 1],trainers = [1]) == 1\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(players = [5, 5, 5, 5, 5],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(players = [1, 2, 3, 4, 5],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(players = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],trainers = [2, 20, 200, 2000, 20000, 200000, 2000000, 20000000, 200000000, 2000000000]) == 10\n assert candidate(players = [5, 5, 5, 5, 5],trainers = [5, 5, 5, 5, 5]) == 5\n assert candidate(players = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],trainers = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 10\n assert candidate(players = [2, 5, 8, 12, 15],trainers = [3, 5, 7, 9, 11, 15]) == 4\n assert candidate(players = [1, 2, 3, 4, 5],trainers = [1, 1, 1, 1, 1]) == 1\n assert candidate(players = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],trainers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 9\n assert candidate(players = [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],trainers = [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]) == 25\n assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trainers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(players = [10, 20, 30, 40, 50],trainers = [15, 25, 35, 45, 55]) == 5\n assert candidate(players = [3, 6, 9, 12, 15, 18, 21],trainers = [10, 12, 14, 16, 18, 20, 22]) == 7\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(players = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],trainers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trainers = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 10\n assert candidate(players = [5, 5, 5, 5, 5],trainers = [1, 2, 3, 4, 5]) == 1\n assert candidate(players = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],trainers = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 10\n assert candidate(players = [5, 10, 15, 20, 25],trainers = [1, 5, 10, 15, 20, 25, 30]) == 5\n assert candidate(players = [100, 100, 100, 100, 100],trainers = [100, 100, 100, 100, 100, 100]) == 5\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],trainers = [3, 6, 9, 12, 15]) == 5\n assert candidate(players = [5, 5, 5, 5, 5],trainers = [1, 2, 3, 4, 5]) == 1\n assert candidate(players = [100, 200, 300],trainers = [150, 100, 250, 300]) == 3\n assert candidate(players = [50, 40, 30, 20, 10],trainers = [10, 20, 30, 40, 50]) == 5\n assert candidate(players = [10, 20, 30, 40, 50],trainers = [9, 19, 29, 39, 49]) == 4\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],trainers = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(players = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 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(players = [90, 80, 70, 60, 50, 40, 30, 20, 10],trainers = [85, 95, 90, 75, 65, 55, 45, 35, 25, 15]) == 9\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trainers = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 10\n assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(players = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],trainers = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 10\n"}, "metadata": {"canonical_parameter_names": ["players", "trainers"], "leetcode_dataset_entry_point": "Solution().matchPlayersAndTrainers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int matchPlayersAndTrainers(int[] players, int[] trainers) {", "container": "Solution", "callable": "matchPlayersAndTrainers", "parameters": [{"name": "players", "type": "int[]"}, {"name": "trainers", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2411, "task_id": "smallest-subarrays-with-maximum-bitwise-or", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of length n, consisting of non-negative integers. For each index i from 0 to n - 1, you must determine the size of the minimum sized non-empty subarray of nums starting at i (inclusive) that has the maximum possible bitwise OR.\n\nIn other words, let Bij be the bitwise OR of the subarray nums[i...j]. You need to find the smallest subarray starting at i, such that bitwise OR of this subarray is equal to max(Bik) where i <= k <= n - 1.\n\nThe bitwise OR of an array is the bitwise OR of all the numbers in it.\nReturn an integer array answer of size n where answer[i] is the length of the minimum sized subarray starting at i with maximum bitwise OR.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,0,2,1,3]\nOutput: [3,3,2,2,1]\nExplanation:\nThe maximum possible bitwise OR starting at any index is 3. \n- Starting at index 0, the shortest subarray that yields it is [1,0,2].\n- Starting at index 1, the shortest subarray that yields the maximum bitwise OR is [0,2,1].\n- Starting at index 2, the shortest subarray that yields the maximum bitwise OR is [2,1].\n- Starting at index 3, the shortest subarray that yields the maximum bitwise OR is [1,3].\n- Starting at index 4, the shortest subarray that yields the maximum bitwise OR is [3].\nTherefore, we return [3,3,2,2,1]. \n\nExample 2:\n\nInput: nums = [1,2]\nOutput: [2,1]\nExplanation:\nStarting at index 0, the shortest subarray that yields the maximum bitwise OR is of length 2.\nStarting at index 1, the shortest subarray that yields the maximum bitwise OR is of length 1.\nTherefore, we return [2,1].\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\n0 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [8, 16, 32, 64, 128]) == [5, 4, 3, 2, 1]\n assert candidate(nums = [1, 0, 1, 0, 1]) == [1, 2, 1, 2, 1]\n assert candidate(nums = [1073741823, 1073741823, 1073741823]) == [1, 1, 1]\n assert candidate(nums = [3, 1, 5, 7, 9]) == [5, 4, 3, 2, 1]\n assert candidate(nums = [8, 4, 2, 1]) == [4, 3, 2, 1]\n assert candidate(nums = [1, 3, 5, 7, 9]) == [5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [8, 7, 6, 5, 4, 3, 2, 3, 2, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 2, 1, 2, 1]\n assert candidate(nums = [1, 0, 2, 1, 3]) == [3, 3, 2, 2, 1]\n assert candidate(nums = [8, 4, 2, 1, 0]) == [4, 3, 2, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 3, 2, 1, 4, 7, 8, 5, 6, 9]) == [7, 6, 5, 4, 3, 2, 3, 3, 2, 1]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [0, 0, 0, 0]) == [1, 1, 1, 1]\n assert candidate(nums = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 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, 1023]) == [10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [31, 15, 7, 3, 1]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2]) == [2, 1]\n assert candidate(nums = [3, 3, 3, 3, 3]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == [10, 9, 8, 7, 6, 5, 4, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 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 = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [8, 4, 2, 1, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1, 64, 32, 16, 8, 4, 2, 1]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 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]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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]) == [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]\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]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004]) == [1, 2, 3, 2, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 1, 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]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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, 1, 1, 4, 3, 2, 1, 1, 1, 4, 3, 2, 1, 1, 1, 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]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 255, 127, 63, 31, 15, 7, 3, 1, 511, 255, 127, 63]) == [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1]\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643]) == [1, 2, 3, 2, 1]\n assert candidate(nums = [1, 0, 2, 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, 67108863, 134217727, 268435455, 536870911, 1073741823]) == [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]\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]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 5, 4, 3, 2, 3, 2, 1]\n assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014]) == [1, 2, 3, 2, 5, 4, 3, 2, 1, 1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [7, 6, 5, 4, 3, 2, 4, 3, 2, 1]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [8, 7, 6, 5, 4, 3, 2, 5, 4, 3, 2, 3, 2, 2, 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]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 5, 4, 3, 2, 3, 2, 1, 1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [8, 6, 2, 3, 7, 5, 1, 4, 9, 10]) == [4, 8, 7, 6, 5, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1]\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]) == [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 = [1023, 0, 2047, 0, 4095, 0, 8191, 0, 16383, 0]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 1]\n assert candidate(nums = [8, 15, 3, 12, 7, 9, 1, 5, 11, 6, 4, 10, 2, 14, 0, 13]) == [2, 1, 2, 2, 2, 4, 3, 2, 2, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [2, 3, 1, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0]) == [4, 5, 4, 4, 4, 3, 3, 2, 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 5, 4, 3, 2, 3, 2, 2, 1]\n assert candidate(nums = [31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 1, 1, 3, 7, 15, 31, 1, 1, 3, 7, 15, 31, 1, 1, 3, 7, 15, 31]) == [1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 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, 31, 32]) == [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]\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [16, 8, 4, 2, 1, 32, 64, 128, 256, 512]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [1, 8, 7, 6, 5, 4, 3, 2, 1, 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, 0]) == [2, 3, 2, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 2, 5, 4, 3, 2, 1, 2, 3, 2, 1, 2, 1, 1]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 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]) == [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 3, 2, 2, 1]\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035]) == [10, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 2, 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]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 5, 4, 3, 2, 1]\n assert candidate(nums = [3, 1, 2, 7, 4, 6, 5, 0, 8, 9]) == [9, 8, 7, 6, 5, 4, 3, 3, 2, 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]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [31, 15, 7, 3, 1, 1, 3, 7, 15, 31]) == [1, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [9, 3, 1, 7, 5, 11, 13, 15, 8, 12, 14, 6, 10, 2, 4, 0]) == [4, 5, 4, 3, 2, 2, 2, 1, 3, 2, 1, 2, 3, 2, 1, 1]\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == [8, 7, 6, 5, 4, 3, 2, 3, 2, 1]\n assert candidate(nums = [15, 7, 3, 1, 14, 6, 2, 0, 13, 5, 1, 0, 9, 3, 1, 0, 8, 2, 0, 7]) == [1, 4, 3, 2, 5, 4, 3, 7, 6, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1]\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 1]\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0, 0]) == [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]) == [3, 2, 9, 8, 7, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 2, 1, 2, 1, 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]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 3, 2, 1]\n assert candidate(nums = [268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 3, 1, 7, 9, 11, 13, 15, 17, 19]) == [9, 8, 7, 6, 5, 4, 3, 2, 2, 1]\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 128, 64, 32, 16, 8, 4, 2, 1, 256, 512, 1024, 2048, 4096]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [31, 14, 7, 3, 1, 0, 1, 3, 7, 14, 31, 0, 1, 3, 7, 14, 31, 0, 1, 3, 7, 14, 31]) == [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0]) == [1, 1, 1, 4, 3, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 0, 2, 1, 3, 1, 0, 2, 1, 3, 1, 0, 2, 1, 3, 1, 0, 2, 1, 3]) == [3, 3, 2, 2, 1, 3, 3, 2, 2, 1, 3, 3, 2, 2, 1, 3, 3, 2, 2, 1]\n assert candidate(nums = [5, 8, 14, 23, 42, 67, 98, 132, 175, 220, 270, 325, 385, 450, 520]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 255, 128, 64, 32, 16, 8, 4, 2, 1, 255, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 8, 8, 7, 6, 5, 4, 3, 2, 1, 8, 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643]) == [1, 2, 3, 2, 1]\n assert candidate(nums = [2147483647, 1, 2147483647, 2, 2147483647, 3, 2147483647, 4, 2147483647, 5]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 1]\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1, 0]) == [10, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1]\n assert candidate(nums = [1, 0, 3, 2, 1, 2, 3, 0, 1, 2]) == [3, 2, 1, 2, 2, 2, 1, 3, 2, 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]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [31, 15, 7, 3, 1, 63, 31, 15, 7, 3, 1, 127, 63, 31, 15, 7, 3, 1, 255, 127, 63, 31, 15, 7, 3, 1]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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]\n assert candidate(nums = [987654321, 987654320, 987654319, 987654318, 987654317, 987654316, 987654315, 987654314, 987654313, 987654312]) == [3, 2, 1, 2, 3, 2, 1, 2, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 0, 3, 2, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == [3, 2, 1, 2, 2, 2, 1, 3, 2, 2, 1, 3, 2, 2, 1, 3, 2, 2, 1, 1]\n assert candidate(nums = [2147483647, 0, 2147483647, 0, 2147483647, 0, 2147483647, 0, 2147483647, 0]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 1]\n assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004]) == [1, 2, 3, 2, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 1, 1]\n assert candidate(nums = [31, 15, 7, 3, 1, 0, 1, 3, 5, 7, 9]) == [1, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().smallestSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] smallestSubarrays(int[] nums) {", "container": "Solution", "callable": "smallestSubarrays", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2412, "task_id": "minimum-money-required-before-transactions", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array transactions, where transactions[i] = [costi, cashbacki].\nThe array describes transactions, where each transaction must be completed exactly once in some order. At any given moment, you have a certain amount of money. In order to complete transaction i, money >= costi must hold true. After performing a transaction, money becomes money - costi + cashbacki.\nReturn the minimum amount of money required before any transaction so that all of the transactions can be completed regardless of the order of the transactions.\n \nExample 1:\n\nInput: transactions = [[2,1],[5,0],[4,2]]\nOutput: 10\nExplanation:\nStarting with money = 10, the transactions can be performed in any order.\nIt can be shown that starting with money < 10 will fail to complete all transactions in some order.\n\nExample 2:\n\nInput: transactions = [[3,0],[0,3]]\nOutput: 3\nExplanation:\n- If transactions are in the order [[3,0],[0,3]], the minimum money required to complete the transactions is 3.\n- If transactions are in the order [[0,3],[3,0]], the minimum money required to complete the transactions is 0.\nThus, starting with money = 3, the transactions can be performed in any order.\n\n \nConstraints:\n\n1 <= transactions.length <= 105\ntransactions[i].length == 2\n0 <= costi, cashbacki <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(transactions = [[1, 2], [3, 4], [5, 6]]) == 5\n assert candidate(transactions = [[1, 0], [2, 0], [3, 0]]) == 6\n assert candidate(transactions = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 4\n assert candidate(transactions = [[0, 0], [0, 0], [0, 0]]) == 0\n assert candidate(transactions = [[7, 3], [2, 1], [4, 4]]) == 9\n assert candidate(transactions = [[2, 1], [5, 0], [4, 2]]) == 10\n assert candidate(transactions = [[0, 0], [1, 1], [2, 2]]) == 2\n assert candidate(transactions = [[10, 5], [2, 2], [8, 3]]) == 15\n assert candidate(transactions = [[1000000000, 0], [0, 1000000000]]) == 1000000000\n assert candidate(transactions = [[10, 5], [5, 10], [20, 10]]) == 25\n assert candidate(transactions = [[100, 0], [0, 100], [50, 50]]) == 150\n assert candidate(transactions = [[10, 5], [2, 2], [1, 1]]) == 10\n assert candidate(transactions = [[3, 0], [0, 3]]) == 3\n assert candidate(transactions = [[1000000000, 500000000], [500000000, 250000000]]) == 1250000000\n assert candidate(transactions = [[1000000000, 0], [0, 1000000000], [500000000, 500000000]]) == 1500000000\n assert candidate(transactions = [[5, 5], [5, 5], [5, 5]]) == 5\n assert candidate(transactions = [[100, 50], [50, 100], [25, 25]]) == 100\n assert candidate(transactions = [[0, 1], [0, 2], [0, 3]]) == 0\n assert candidate(transactions = [[10, 0], [0, 10], [5, 5]]) == 15\n assert candidate(transactions = [[5, 10], [3, 6], [7, 8]]) == 7\n assert candidate(transactions = [[100, 99], [99, 98], [98, 97], [97, 96], [96, 95], [95, 94], [94, 93], [93, 92], [92, 91], [91, 90]]) == 109\n assert candidate(transactions = [[100, 50], [50, 100], [25, 75], [75, 25]]) == 150\n assert candidate(transactions = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96]]) == 1\n assert candidate(transactions = [[1000000000, 500000000], [500000000, 1000000000], [250000000, 750000000], [750000000, 250000000]]) == 1500000000\n assert candidate(transactions = [[1000000000, 0], [0, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000]]) == 1750000000\n assert candidate(transactions = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995]]) == 5\n assert candidate(transactions = [[5, 10], [10, 5], [3, 15], [15, 3], [8, 8]]) == 25\n assert candidate(transactions = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 46\n assert candidate(transactions = [[1000000000, 500000000], [500000000, 250000000], [250000000, 125000000], [125000000, 62500000], [62500000, 31250000]]) == 1468750000\n assert candidate(transactions = [[5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [4, 5], [3, 5], [2, 5], [1, 5]]) == 20\n assert candidate(transactions = [[1, 1000000000], [2, 1000000000], [3, 1000000000], [4, 1000000000], [5, 1000000000], [6, 1000000000], [7, 1000000000], [8, 1000000000], [9, 1000000000], [10, 1000000000]]) == 10\n assert candidate(transactions = [[1000000000, 500000000], [500000000, 250000000], [250000000, 125000000], [125000000, 62500000], [62500000, 31250000], [31250000, 15625000], [15625000, 7812500], [7812500, 3906250], [3906250, 1953125], [1953125, 976562], [976562, 488281], [488281, 244140], [244140, 122070], [122070, 61035], [61035, 30517], [30517, 15258], [15258, 7629], [7629, 3814], [3814, 1907], [1907, 953], [953, 476], [476, 238], [238, 119], [119, 59], [59, 29], [29, 14], [14, 7], [7, 3], [3, 1]]) == 1499999999\n assert candidate(transactions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30]]) == 135\n assert candidate(transactions = [[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [3, 1], [3, 3]]) == 6\n assert candidate(transactions = [[1000000000, 0], [0, 1000000000], [500000000, 500000000], [500000001, 499999999]]) == 1500000002\n assert candidate(transactions = [[10, 5], [9, 4], [8, 3], [7, 2], [6, 1], [5, 0], [4, 6], [3, 7], [2, 8], [1, 9]]) == 35\n assert candidate(transactions = [[100, 50], [200, 150], [300, 100], [400, 50], [500, 0]]) == 1300\n assert candidate(transactions = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 460\n assert candidate(transactions = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]]) == 45\n assert candidate(transactions = [[5, 0], [0, 5], [5, 5], [0, 0], [10, 10]]) == 15\n assert candidate(transactions = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]]) == 55\n assert candidate(transactions = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45]]) == 70\n assert candidate(transactions = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]]) == 14\n assert candidate(transactions = [[100, 90], [90, 80], [80, 70], [70, 60], [60, 50]]) == 140\n assert candidate(transactions = [[9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 17\n assert candidate(transactions = [[1000, 500], [1500, 1000], [2000, 1500], [2500, 2000], [3000, 2500]]) == 5000\n assert candidate(transactions = [[1000000000, 900000000], [500000000, 400000000], [300000000, 200000000], [100000000, 90000000]]) == 1210000000\n assert candidate(transactions = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]]) == 55\n assert candidate(transactions = [[500, 500], [500, 500], [500, 500], [500, 500], [500, 500]]) == 500\n assert candidate(transactions = [[10, 1], [5, 5], [15, 10], [20, 15], [25, 20], [30, 25], [35, 30], [40, 35], [45, 40]]) == 84\n assert candidate(transactions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 9\n assert candidate(transactions = [[10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]]) == 50\n assert candidate(transactions = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 1], [1, 2]]) == 4\n assert candidate(transactions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == 505\n assert candidate(transactions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n assert candidate(transactions = [[5, 2], [10, 3], [15, 5], [20, 10]]) == 40\n assert candidate(transactions = [[100, 0], [0, 100], [50, 50], [25, 25], [75, 75]]) == 175\n assert candidate(transactions = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 10\n assert candidate(transactions = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 30\n assert candidate(transactions = [[10, 0], [20, 10], [30, 20], [40, 30], [50, 40], [60, 50], [70, 60], [80, 70], [90, 80]]) == 170\n assert candidate(transactions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 19\n assert candidate(transactions = [[100, 1], [101, 1], [102, 1], [103, 1], [104, 1]]) == 506\n assert candidate(transactions = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 6\n assert candidate(transactions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 10\n assert candidate(transactions = [[9, 8], [7, 6], [5, 4], [3, 2], [1, 0]]) == 13\n assert candidate(transactions = [[10, 15], [20, 10], [30, 5], [40, 0], [50, 25], [60, 30], [70, 20]]) == 210\n assert candidate(transactions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 8\n assert candidate(transactions = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]]) == 25\n assert candidate(transactions = [[100, 50], [200, 150], [50, 100], [300, 200]]) == 400\n assert candidate(transactions = [[100, 50], [200, 100], [300, 150], [50, 25]]) == 475\n assert candidate(transactions = [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]) == 0\n assert candidate(transactions = [[50, 0], [25, 0], [0, 50], [0, 25], [75, 0], [0, 75]]) == 150\n assert candidate(transactions = [[20, 10], [25, 15], [30, 20], [35, 25], [40, 30], [45, 35], [50, 40], [55, 45], [60, 50], [65, 55]]) == 155\n assert candidate(transactions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == 6\n assert candidate(transactions = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96]]) == 5\n assert candidate(transactions = [[9, 8], [7, 6], [5, 4], [3, 2], [1, 0]]) == 13\n assert candidate(transactions = [[100, 10], [90, 20], [80, 30], [70, 40], [60, 50], [50, 60], [40, 70], [30, 80], [20, 90], [10, 100]]) == 300\n assert candidate(transactions = [[500, 250], [250, 125], [125, 62], [62, 31], [31, 15], [15, 7], [7, 3], [3, 1], [1, 0]]) == 750\n assert candidate(transactions = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]]) == 300\n assert candidate(transactions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 100\n assert candidate(transactions = [[5, 0], [5, 5], [5, 10], [5, 15], [5, 20], [5, 25], [5, 30], [5, 35], [5, 40], [5, 45]]) == 10\n assert candidate(transactions = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 4\n assert candidate(transactions = [[100, 50], [50, 100], [200, 150], [150, 200]]) == 250\n assert candidate(transactions = [[10, 5], [5, 10], [15, 20], [20, 15], [25, 30], [30, 25]]) == 40\n assert candidate(transactions = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 5]]) == 7\n assert candidate(transactions = [[1000000000, 0], [0, 1000000000], [500000000, 500000000]]) == 1500000000\n assert candidate(transactions = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0]]) == 15\n assert candidate(transactions = [[100, 0], [50, 100], [25, 50], [10, 25], [5, 10], [1, 5]]) == 150\n assert candidate(transactions = [[10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 19\n assert candidate(transactions = [[5, 10], [15, 5], [25, 20], [35, 30], [45, 40], [55, 50], [65, 60], [75, 70], [85, 80]]) == 125\n assert candidate(transactions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25]]) == 100\n assert candidate(transactions = [[5, 10], [10, 5], [0, 0], [7, 7], [3, 3]]) == 12\n assert candidate(transactions = [[1000, 1000], [2000, 1000], [3000, 1000], [4000, 1000], [5000, 1000], [6000, 1000], [7000, 1000], [8000, 1000], [9000, 1000], [10000, 1000]]) == 46000\n assert candidate(transactions = [[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]]) == 150\n assert candidate(transactions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]) == 505\n assert candidate(transactions = [[1, 0], [0, 1], [1, 1], [0, 0], [1, 0], [0, 1]]) == 3\n assert candidate(transactions = [[1000000000, 0], [0, 1000000000]]) == 1000000000\n assert candidate(transactions = [[100000, 50000], [50000, 25000], [25000, 12500], [12500, 6250], [6250, 3125], [3125, 1562], [1562, 781], [781, 390], [390, 195]]) == 149805\n assert candidate(transactions = [[100, 0], [90, 10], [80, 20], [70, 30], [60, 40], [50, 50], [40, 60], [30, 70], [20, 80], [10, 90]]) == 350\n assert candidate(transactions = [[500, 400], [400, 300], [300, 200], [200, 100]]) == 800\n assert candidate(transactions = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]]) == 0\n assert candidate(transactions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 7\n assert candidate(transactions = [[0, 100], [100, 200], [200, 300], [300, 400], [400, 500]]) == 400\n assert candidate(transactions = [[10, 0], [0, 10], [5, 5], [5, 0], [0, 5], [7, 7], [3, 3], [2, 2], [1, 1]]) == 22\n assert candidate(transactions = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 10\n assert candidate(transactions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 8\n assert candidate(transactions = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 65\n assert candidate(transactions = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9]]) == 54\n assert candidate(transactions = [[10, 5], [15, 10], [20, 15], [25, 20], [30, 25], [35, 30], [40, 35], [45, 40], [50, 45], [55, 50]]) == 100\n"}, "metadata": {"canonical_parameter_names": ["transactions"], "leetcode_dataset_entry_point": "Solution().minimumMoney", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumMoney(int[][] transactions) {", "container": "Solution", "callable": "minimumMoney", "parameters": [{"name": "transactions", "type": "int[][]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2413, "task_id": "smallest-even-multiple", "difficulty": "Easy", "problem_description": "Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.\n \nExample 1:\n\nInput: n = 5\nOutput: 10\nExplanation: The smallest multiple of both 5 and 2 is 10.\n\nExample 2:\n\nInput: n = 6\nOutput: 6\nExplanation: The smallest multiple of both 6 and 2 is 6. Note that a number is a multiple of itself.\n\n \nConstraints:\n\n1 <= n <= 150\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 6\n assert candidate(n = 100) == 100\n assert candidate(n = 33) == 66\n assert candidate(n = 75) == 150\n assert candidate(n = 6) == 6\n assert candidate(n = 2) == 2\n assert candidate(n = 1) == 2\n assert candidate(n = 7) == 14\n assert candidate(n = 5) == 10\n assert candidate(n = 150) == 150\n assert candidate(n = 45) == 90\n assert candidate(n = 119) == 238\n assert candidate(n = 53) == 106\n assert candidate(n = 43) == 86\n assert candidate(n = 103) == 206\n assert candidate(n = 145) == 290\n assert candidate(n = 37) == 74\n assert candidate(n = 23) == 46\n assert candidate(n = 73) == 146\n assert candidate(n = 133) == 266\n assert candidate(n = 8) == 8\n assert candidate(n = 147) == 294\n assert candidate(n = 131) == 262\n assert candidate(n = 27) == 54\n assert candidate(n = 35) == 70\n assert candidate(n = 77) == 154\n assert candidate(n = 11) == 22\n assert candidate(n = 142) == 142\n assert candidate(n = 55) == 110\n assert candidate(n = 65) == 130\n assert candidate(n = 97) == 194\n assert candidate(n = 88) == 88\n assert candidate(n = 29) == 58\n assert candidate(n = 135) == 270\n assert candidate(n = 144) == 144\n assert candidate(n = 107) == 214\n assert candidate(n = 21) == 42\n assert candidate(n = 115) == 230\n assert candidate(n = 87) == 174\n assert candidate(n = 137) == 274\n assert candidate(n = 17) == 34\n assert candidate(n = 42) == 42\n assert candidate(n = 101) == 202\n assert candidate(n = 89) == 178\n assert candidate(n = 112) == 112\n assert candidate(n = 71) == 142\n assert candidate(n = 81) == 162\n assert candidate(n = 41) == 82\n assert candidate(n = 9) == 18\n assert candidate(n = 83) == 166\n assert candidate(n = 121) == 242\n assert candidate(n = 105) == 210\n assert candidate(n = 79) == 158\n assert candidate(n = 84) == 84\n assert candidate(n = 63) == 126\n assert candidate(n = 61) == 122\n assert candidate(n = 130) == 130\n assert candidate(n = 49) == 98\n assert candidate(n = 47) == 94\n assert candidate(n = 113) == 226\n assert candidate(n = 93) == 186\n assert candidate(n = 57) == 114\n assert candidate(n = 111) == 222\n assert candidate(n = 123) == 246\n assert candidate(n = 95) == 190\n assert candidate(n = 141) == 282\n assert candidate(n = 51) == 102\n assert candidate(n = 127) == 254\n assert candidate(n = 15) == 30\n assert candidate(n = 13) == 26\n assert candidate(n = 69) == 138\n assert candidate(n = 125) == 250\n assert candidate(n = 12) == 12\n assert candidate(n = 117) == 234\n assert candidate(n = 59) == 118\n assert candidate(n = 67) == 134\n assert candidate(n = 99) == 198\n assert candidate(n = 64) == 64\n assert candidate(n = 143) == 286\n assert candidate(n = 128) == 128\n assert candidate(n = 129) == 258\n assert candidate(n = 140) == 140\n assert candidate(n = 149) == 298\n assert candidate(n = 19) == 38\n assert candidate(n = 39) == 78\n assert candidate(n = 91) == 182\n assert candidate(n = 139) == 278\n assert candidate(n = 85) == 170\n assert candidate(n = 109) == 218\n assert candidate(n = 31) == 62\n assert candidate(n = 25) == 50\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().smallestEvenMultiple", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int smallestEvenMultiple(int n) {", "container": "Solution", "callable": "smallestEvenMultiple", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2414, "task_id": "length-of-the-longest-alphabetical-continuous-substring", "difficulty": "Medium", "problem_description": "An alphabetical continuous string is a string consisting of consecutive letters in the alphabet. In other words, it is any substring of the string \"abcdefghijklmnopqrstuvwxyz\".\n\nFor example, \"abc\" is an alphabetical continuous string, while \"acb\" and \"za\" are not.\n\nGiven a string s consisting of lowercase letters only, return the length of the longest alphabetical continuous substring.\n \nExample 1:\n\nInput: s = \"abacaba\"\nOutput: 2\nExplanation: There are 4 distinct continuous substrings: \"a\", \"b\", \"c\" and \"ab\".\n\"ab\" is the longest continuous substring.\n\nExample 2:\n\nInput: s = \"abcde\"\nOutput: 5\nExplanation: \"abcde\" is the longest continuous substring.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of only English lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzz\") == 1\n assert candidate(s = \"abxyz\") == 3\n assert candidate(s = \"qrstuvwpqrstu\") == 7\n assert candidate(s = \"mnopqrstuvwxyzz\") == 14\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"mnopqrstuvwxyza\") == 14\n assert candidate(s = \"abababab\") == 2\n assert candidate(s = \"qrstuvwxyza\") == 10\n assert candidate(s = \"bcdfghij\") == 5\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"abcdabcde\") == 5\n assert candidate(s = \"pqrstuvwxyzabc\") == 11\n assert candidate(s = \"ababababab\") == 2\n assert candidate(s = \"mnopqr\") == 6\n assert candidate(s = \"abcde\") == 5\n assert candidate(s = \"xyz\") == 3\n assert candidate(s = \"mnopqrstu\") == 9\n assert candidate(s = \"qrstuvwpqr\") == 7\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"abccba\") == 3\n assert candidate(s = \"acdfg\") == 2\n assert candidate(s = \"defghijklmno\") == 12\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 2\n assert candidate(s = \"zab\") == 2\n assert candidate(s = \"abxyzab\") == 3\n assert candidate(s = \"bcdfghjkl\") == 3\n assert candidate(s = \"abacaba\") == 2\n assert candidate(s = \"xyzabc\") == 3\n assert candidate(s = \"abcabcvwxyz\") == 5\n assert candidate(s = \"abcdefgxyzabcdefghijlmnopqrstuvwxyz\") == 15\n assert candidate(s = \"abcdefghijlmnopqrstuvwxyzmnopqrstuvwxy\") == 15\n assert candidate(s = \"mnopqrstuabcdefghijklmnopqrstuvwxyzaabcdeefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"defghijklmnopqrstuvwxyz\") == 23\n assert candidate(s = \"mnopqrstuvmnopqrstu\") == 10\n assert candidate(s = \"mnopqrstuuvwxyzaaaa\") == 9\n assert candidate(s = \"abcabcdabcdeabcdeabcd\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzab\") == 26\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzz\") == 26\n assert candidate(s = \"pqrsabcdewxyz\") == 5\n assert candidate(s = \"xyzabcd\") == 4\n assert candidate(s = \"aaaabbbbcccc\") == 2\n assert candidate(s = \"zzzzzzzzzz\") == 1\n assert candidate(s = \"abxyzabxyz\") == 3\n assert candidate(s = \"abdefgxyz\") == 4\n assert candidate(s = \"defghijklmnopqrstuvw\") == 20\n assert candidate(s = \"mnopqrstuvxyzab\") == 10\n assert candidate(s = \"pqrstuvwxyzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 11\n assert candidate(s = \"mnopqrstuabcde\") == 9\n assert candidate(s = \"abcxyzab\") == 3\n assert candidate(s = \"abcdefgxyzabcde\") == 7\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 3\n assert candidate(s = \"pqrstuvwxyza\") == 11\n assert candidate(s = \"mnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 14\n assert candidate(s = \"mnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyz\") == 14\n assert candidate(s = \"lmnopqrstuvwxyzabc\") == 15\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijkl\") == 14\n assert candidate(s = \"qrsabcdabcdxyz\") == 4\n assert candidate(s = \"defghijklmnopqrstuvwxyza\") == 23\n assert candidate(s = \"mnopqrstuvwxyzmnopqrstuvwxyza\") == 14\n assert candidate(s = \"abcdeabfghicdef\") == 5\n assert candidate(s = \"xyzabxyzuvwxyza\") == 6\n assert candidate(s = \"abxyzabcxyz\") == 3\n assert candidate(s = \"qrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 10\n assert candidate(s = \"abcdefabcdeabcde\") == 6\n assert candidate(s = \"pqrsabcd\") == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzmnopqrstuvwxyz\") == 26\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 26\n assert candidate(s = \"klmnopqrstuvxyz\") == 12\n assert candidate(s = \"abababababab\") == 2\n assert candidate(s = \"mnopqrstuabcdefghijklmnopqrstuvwxyzaabcde\") == 26\n assert candidate(s = \"mnopqrstuvwxyzabcde\") == 14\n assert candidate(s = \"xyzabcde\") == 5\n assert candidate(s = \"mnopqrstuzyxwvutsrqponmlkjihgfedcba\") == 9\n assert candidate(s = \"qrsabcdabcdabcd\") == 4\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijklmno\") == 15\n assert candidate(s = \"abcdeabcdabcdabcdabcde\") == 5\n assert candidate(s = \"mnopqrstuabcdefghijklmnopqrstuvwxyza\") == 26\n assert candidate(s = \"aaaaa\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"zabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"xyzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxz\") == 3\n assert candidate(s = \"mnopqrstuuvwxyza\") == 9\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefg\") == 7\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"qrstuvwxyzabcdefghijklmnop\") == 16\n assert candidate(s = \"abcdxyzuvwxyza\") == 6\n assert candidate(s = \"mnopqrstuvwxyzmnopqrstu\") == 14\n assert candidate(s = \"xyzzyxwvutsrqponmlkjihgfedcba\") == 3\n assert candidate(s = \"zabcdefghijklmnopqrstuvwxy\") == 25\n assert candidate(s = \"zabcvwxyz\") == 5\n assert candidate(s = \"abxyzabcd\") == 4\n assert candidate(s = \"mnopqrlmnopqr\") == 7\n assert candidate(s = \"aabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"abxyzabc\") == 3\n assert candidate(s = \"qrstuvwpqrstuzyxwvutsrqponmlkjihgfedcba\") == 7\n assert candidate(s = \"zabcdefghijklmnopqrstuvwxyza\") == 26\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaabbcc\") == 2\n assert candidate(s = \"abcdefghijlmnopqrstuvwxyz\") == 15\n assert candidate(s = \"abcddefghijklmnopqrstuvwxyz\") == 23\n assert candidate(s = \"abcdeabcdeabcde\") == 5\n assert candidate(s = \"qrstuvwxyz\") == 10\n assert candidate(s = \"abcdefghijkabcde\") == 11\n assert candidate(s = \"abcdefgabcdefgabcdefg\") == 7\n assert candidate(s = \"abcdefg hijklmnop qrstuvwx yz\") == 9\n assert candidate(s = \"abcdefghijlkjihgfedcba\") == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == 1\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaabcdefghijklmnopqrstuvwxyza\") == 26\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"xyzzyxwvutsrqpomnlkjihgfedcba\") == 3\n assert candidate(s = \"pqrstuvwxyzabcde\") == 11\n assert candidate(s = \"lmnopqrsabcd\") == 8\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestContinuousSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestContinuousSubstring(String s) {", "container": "Solution", "callable": "longestContinuousSubstring", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2415, "task_id": "reverse-odd-levels-of-binary-tree", "difficulty": "Medium", "problem_description": "Given the root of a perfect binary tree, reverse the node values at each odd level of the tree.\n\nFor example, suppose the node values at level 3 are [2,1,3,4,7,11,29,18], then it should become [18,29,11,7,4,3,1,2].\n\nReturn the root of the reversed tree.\nA binary tree is perfect if all parent nodes have two children and all leaves are on the same level.\nThe level of a node is the number of edges along the path between it and the root node.\n \nExample 1:\n\n\nInput: root = [2,3,5,8,13,21,34]\nOutput: [2,5,3,8,13,21,34]\nExplanation: \nThe tree has only one odd level.\nThe nodes at level 1 are 3, 5 respectively, which are reversed and become 5, 3.\n\nExample 2:\n\n\nInput: root = [7,13,11]\nOutput: [7,11,13]\nExplanation: \nThe nodes at level 1 are 13, 11, which are reversed and become 11, 13.\n\nExample 3:\n\nInput: root = [0,1,2,0,0,0,0,1,1,1,1,2,2,2,2]\nOutput: [0,2,1,0,0,0,0,2,2,2,2,1,1,1,1]\nExplanation: \nThe odd levels have non-zero values.\nThe nodes at level 1 were 1, 2, and are 2, 1 after the reversal.\nThe nodes at level 3 were 1, 1, 1, 1, 2, 2, 2, 2, and are 2, 2, 2, 2, 1, 1, 1, 1 after the reversal.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 214].\n0 <= Node.val <= 105\nroot is a perfect binary tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([7, 13, 11])), tree_node([7, 11, 13]))\n assert is_same_tree(candidate(root = tree_node([0, 1, 2, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2])), tree_node([0, 2, 1, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 1, 1]))\n assert is_same_tree(candidate(root = tree_node([2, 3, 5, 8, 13, 21, 34])), tree_node([2, 5, 3, 8, 13, 21, 34]))\n assert is_same_tree(candidate(root = tree_node([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, 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])), tree_node([9, 7, 8, 6, 5, 4, 3, 5, 4, 3, 2, 1, 0, 1, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 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, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]))\n assert is_same_tree(candidate(root = tree_node([5, 4, 6, 3, 8, 7, 9, 2, 10, 1, 11, 12, 13, 14, 15])), tree_node([5, 6, 4, 3, 8, 7, 9, 15, 14, 13, 12, 11, 1, 10, 2]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 3, 7, 9, 13, 17, 21, 27, 29, 33, 37, 39, 43, 49, 51, 55, 57, 61, 65, 67, 71, 73, 77, 79, 83, 85, 87, 89, 93, 95, 97, 99])), tree_node([20, 30, 10, 5, 15, 25, 35, 27, 21, 17, 13, 9, 7, 3, 1, 29, 33, 37, 39, 43, 49, 51, 55, 57, 61, 65, 67, 71, 73, 77, 79, 99, 97, 95, 93, 89, 87, 85, 83]))\n assert is_same_tree(candidate(root = tree_node([1, 3, 2, 7, 6, 5, 4, 15, 14, 13, 12, 11, 10, 9, 8, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 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])), tree_node([1, 2, 3, 7, 6, 5, 4, 8, 9, 10, 11, 12, 13, 14, 15, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 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]))\n assert is_same_tree(candidate(root = tree_node([15, 14, 13, 12, 11, 10, 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])), tree_node([15, 13, 14, 12, 11, 10, 9, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_tree(candidate(root = tree_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])), tree_node([1, 3, 2, 4, 5, 6, 7, 15, 14, 13, 12, 11, 10, 9, 8, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 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]))\n assert is_same_tree(candidate(root = tree_node([5, 4, 7, 9, 6, 11, 13, 17, 14, 15, 18, 21, 23, 25, 27, 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])), tree_node([5, 7, 4, 9, 6, 11, 13, 27, 25, 23, 21, 18, 15, 14, 17, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]))\n assert is_same_tree(candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 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])), tree_node([10, 8, 9, 7, 6, 5, 4, 14, 13, 12, 11, 0, 1, 2, 3, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 6, 2, 4, 1, 7, 8, 9, 10, 11, 12, 13, 14, 15])), tree_node([5, 6, 3, 2, 4, 1, 7, 15, 14, 13, 12, 11, 10, 9, 8]))\n assert is_same_tree(candidate(root = tree_node([1, 3, 2, 7, 6, 5, 4, 15, 14, 13, 12, 11, 10, 9, 8, 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])), tree_node([1, 2, 3, 7, 6, 5, 4, 8, 9, 10, 11, 12, 13, 14, 15, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_tree(candidate(root = tree_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, 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])), tree_node([1, 3, 2, 4, 5, 6, 7, 15, 14, 13, 12, 11, 10, 9, 8, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 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, 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]))\n assert is_same_tree(candidate(root = tree_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])), tree_node([1, 3, 2, 4, 5, 6, 7, 15, 14, 13, 12, 11, 10, 9, 8, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]))\n assert is_same_tree(candidate(root = tree_node([100000, 50000, 150000, 25000, 75000, 125000, 175000, 12500, 37500, 62500, 93750, 143750, 181250, 228750, 275000, 6250, 18750, 28125, 46875, 56250, 70312, 84375, 110937, 121875, 148437, 159375, 182812, 193750, 220312, 231250, 257812, 268750, 306250, 317187, 335937, 346875, 373437, 384375, 410937, 421875, 448437, 459375, 1250, 3750, 4688, 7500, 9375, 12500, 14375, 16875, 18750, 21875, 23750, 26875, 28125, 31250, 33125, 35937, 37500, 40625, 42188, 44375, 46250, 49375, 50938, 53125, 55000, 57812, 59375, 62500, 63750, 66562, 68125, 71250, 72813, 75000, 76562, 79688, 81250, 84375, 85938, 89062, 90625, 93750, 95313, 98438, 100000, 101563, 104688, 106250, 109375, 110938, 114062, 115625, 118750, 120313, 123438, 125000, 126563, 129688, 131250, 134375, 135938, 139062, 140625, 143750, 145313, 148438, 150000, 151563, 154688, 156250, 159375, 160938, 164062, 165625, 168750, 170313, 173438, 175000, 176563, 179688, 181250, 184375, 185938, 189062, 190625, 193750, 195313, 198438, 200000])), tree_node([100000, 150000, 50000, 25000, 75000, 125000, 175000, 275000, 228750, 181250, 143750, 93750, 62500, 37500, 12500, 6250, 18750, 28125, 46875, 56250, 70312, 84375, 110937, 121875, 148437, 159375, 182812, 193750, 220312, 231250, 257812, 46250, 44375, 42188, 40625, 37500, 35937, 33125, 31250, 28125, 26875, 23750, 21875, 18750, 16875, 14375, 12500, 9375, 7500, 4688, 3750, 1250, 459375, 448437, 421875, 410937, 384375, 373437, 346875, 335937, 317187, 306250, 268750, 49375, 50938, 53125, 55000, 57812, 59375, 62500, 63750, 66562, 68125, 71250, 72813, 75000, 76562, 79688, 81250, 84375, 85938, 89062, 90625, 93750, 95313, 98438, 100000, 101563, 104688, 106250, 109375, 110938, 114062, 115625, 118750, 120313, 123438, 125000, 126563, 129688, 131250, 134375, 135938, 139062, 140625, 143750, 145313, 148438, 150000, 151563, 154688, 156250, 159375, 160938, 164062, 165625, 168750, 170313, 173438, 175000, 176563, 179688, 181250, 184375, 185938, 189062, 190625, 200000, 198438, 195313, 193750]))\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().reverseOddLevels", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2416, "task_id": "sum-of-prefix-scores-of-strings", "difficulty": "Hard", "problem_description": "You are given an array words of size n consisting of non-empty strings.\nWe define the score of a string term as the number of strings words[i] such that term is a prefix of words[i].\n\nFor example, if words = [\"a\", \"ab\", \"abc\", \"cab\"], then the score of \"ab\" is 2, since \"ab\" is a prefix of both \"ab\" and \"abc\".\n\nReturn an array answer of size n where answer[i] is the sum of scores of every non-empty prefix of words[i].\nNote that a string is considered as a prefix of itself.\n \nExample 1:\n\nInput: words = [\"abc\",\"ab\",\"bc\",\"b\"]\nOutput: [5,4,3,2]\nExplanation: The answer for each string is the following:\n- \"abc\" has 3 prefixes: \"a\", \"ab\", and \"abc\".\n- There are 2 strings with the prefix \"a\", 2 strings with the prefix \"ab\", and 1 string with the prefix \"abc\".\nThe total is answer[0] = 2 + 2 + 1 = 5.\n- \"ab\" has 2 prefixes: \"a\" and \"ab\".\n- There are 2 strings with the prefix \"a\", and 2 strings with the prefix \"ab\".\nThe total is answer[1] = 2 + 2 = 4.\n- \"bc\" has 2 prefixes: \"b\" and \"bc\".\n- There are 2 strings with the prefix \"b\", and 1 string with the prefix \"bc\".\nThe total is answer[2] = 2 + 1 = 3.\n- \"b\" has 1 prefix: \"b\".\n- There are 2 strings with the prefix \"b\".\nThe total is answer[3] = 2.\n\nExample 2:\n\nInput: words = [\"abcd\"]\nOutput: [4]\nExplanation:\n\"abcd\" has 4 prefixes: \"a\", \"ab\", \"abc\", and \"abcd\".\nEach prefix has a score of one, so the total is answer[0] = 1 + 1 + 1 + 1 = 4.\n\n \nConstraints:\n\n1 <= words.length <= 1000\n1 <= words[i].length <= 1000\nwords[i] consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['hello', 'hell', 'he', 'h']) == [12, 11, 7, 4]\n assert candidate(words = ['abc', 'ab', 'bc', 'b']) == [5, 4, 3, 2]\n assert candidate(words = ['a', 'b', 'c', 'd']) == [1, 1, 1, 1]\n assert candidate(words = ['aa', 'aaa', 'aaaa', 'aaaaa']) == [8, 11, 13, 14]\n assert candidate(words = ['a', 'ab', 'abc', 'abcd']) == [4, 7, 9, 10]\n assert candidate(words = ['abcde', 'abcd', 'abc', 'ab', 'a']) == [15, 14, 12, 9, 5]\n assert candidate(words = ['b', 'bb', 'bbb', 'bbbb']) == [4, 7, 9, 10]\n assert candidate(words = ['xyz', 'xy', 'x']) == [6, 5, 3]\n assert candidate(words = ['abcd']) == [4]\n assert candidate(words = ['xyz', 'xy', 'x', 'xyzabc']) == [9, 7, 4, 12]\n assert candidate(words = ['aa', 'ab', 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc']) == [4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(words = ['aaaa', 'aa', 'a']) == [7, 5, 3]\n assert candidate(words = ['dynamic', 'dyn', 'dynam', 'dynamicp', 'dynamicpr', 'dynamicpro', 'dynamicprogra', 'dynamicprogram', 'dynamicprogramming']) == [57, 27, 43, 63, 68, 72, 81, 83, 87]\n assert candidate(words = ['optimization', 'optimize', 'opt', 'opti', 'optim', 'optimi']) == [37, 33, 18, 23, 27, 30]\n assert candidate(words = ['xylophone', 'xylo', 'xylophon', 'xy', 'xyl', 'xylophonist', 'xylophoneplayer', 'xylophoneplayerperformance']) == [52, 29, 49, 16, 23, 52, 64, 75]\n assert candidate(words = ['xylophone', 'xylography', 'xylo', 'xylophoneography', 'xyl', 'xylonate']) == [33, 29, 23, 40, 18, 27]\n assert candidate(words = ['aabbcc', 'aabbc', 'aabb', 'aa', 'a', 'aabbbccc', 'aabbbbcccc', 'aabbbbccccd']) == [30, 29, 27, 15, 8, 33, 40, 41]\n assert candidate(words = ['aaaa', 'aaab', 'aaac', 'aabb', 'aabc', 'abaa', 'abab', 'abac', 'abba', 'abbb', 'abbc', 'abca', 'abcb', 'abcc', 'acaa', 'acab', 'acac', 'acba', 'acbb', 'acbc', 'acca', 'accc']) == [31, 31, 31, 30, 30, 35, 35, 35, 35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 34, 33, 33]\n assert candidate(words = ['abacax', 'abaca', 'bacax', 'abac', 'ab']) == [17, 16, 5, 14, 8]\n assert candidate(words = ['apple', 'app', 'application', 'applesauce', 'appetizer']) == [20, 15, 25, 25, 21]\n assert candidate(words = ['pneumonoultramicroscopicsilicovolcanoconiosis', 'pneumo', 'pneumonoultra', 'pneumonoultramicro', 'pneumonoultramicroscopicsilico', 'pneumonoultramicroscopicsilicovolcano', 'pneumo']) == [155, 42, 77, 97, 133, 147, 42]\n assert candidate(words = ['programming', 'program', 'pro', 'prog', 'progr']) == [30, 26, 15, 19, 22]\n assert candidate(words = ['algorithm', 'algo', 'al', 'alex', 'ale', 'all']) == [21, 16, 12, 15, 14, 13]\n assert candidate(words = ['abcdabcd', 'abcabc', 'ababab', 'aaaaaa', 'bbbbbb', 'cccccc', 'dddddd']) == [14, 12, 11, 9, 6, 6, 6]\n assert candidate(words = ['algorithm', 'algo', 'alg', 'algor', 'algorith', 'algori']) == [35, 23, 18, 27, 34, 30]\n assert candidate(words = ['aabbcc', 'aabbc', 'aabb', 'aab', 'aa', 'a', 'aabbbcc', 'aabbb', 'aabbbb']) == [33, 32, 30, 24, 17, 9, 35, 33, 34]\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa']) == [9, 17, 24, 30, 35, 39, 42, 44, 45]\n assert candidate(words = ['prefix', 'pre', 'prefer', 'preference', 'presentation', 'president', 'presidency']) == [26, 21, 28, 32, 32, 33, 34]\n assert candidate(words = ['hello', 'hell', 'he', 'h', 'hero', 'helium', 'helper']) == [20, 19, 13, 7, 15, 20, 20]\n assert candidate(words = ['unique', 'un', 'uni', 'unic', 'uniqu', 'uniquee', 'uniqueee', 'uniqueeee']) == [37, 16, 23, 24, 33, 40, 42, 43]\n assert candidate(words = ['prefix', 'pre', 'pref', 'prefi', 'prefin', 'prefixation', 'prefixes', 'prefixing', 'prefixes', 'preference', 'prefer']) == [55, 33, 43, 50, 51, 60, 59, 58, 59, 51, 47]\n assert candidate(words = ['apple', 'app', 'ap', 'application', 'appetite']) == [17, 14, 10, 23, 19]\n assert candidate(words = ['aabbcc', 'aab', 'abc', 'aac', 'acc', 'aaa', 'bbb', 'ccc', 'aabbc', 'aabbbc', 'aabbbcc', 'aabbbccc']) == [32, 24, 12, 19, 12, 19, 3, 3, 31, 35, 37, 38]\n assert candidate(words = ['complex', 'com', 'compl', 'complexity', 'composite']) == [26, 15, 22, 29, 24]\n assert candidate(words = ['cat', 'cater', 'caterpillar', 'catering', 'caterer', 'caterers', 'catered', 'catering']) == [24, 38, 44, 44, 43, 44, 42, 44]\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa']) == [10, 19, 27, 34, 40, 45, 49, 52, 54, 55]\n assert candidate(words = ['optimization', 'opt', 'opti', 'optim', 'optimiz', 'optimise', 'optimized']) == [44, 21, 27, 32, 39, 38, 41]\n assert candidate(words = ['data', 'dat', 'database', 'datascience', 'datastructure']) == [19, 15, 23, 27, 29]\n assert candidate(words = ['car', 'cat', 'catch', 'cart', 'card', 'carpet']) == [16, 14, 16, 17, 17, 19]\n assert candidate(words = ['banana', 'band', 'ball', 'bat', 'basketball']) == [15, 13, 12, 11, 18]\n assert candidate(words = ['programming', 'program', 'pro', 'pr', 'p', 'prefix', 'pre', 'preprocessing']) == [30, 26, 18, 15, 8, 21, 18, 28]\n assert candidate(words = ['longword', 'longworder', 'longworderer', 'longwordererest', 'longwordereresterest']) == [40, 48, 54, 60, 65]\n assert candidate(words = ['algorithm', 'algo', 'al', 'alex', 'algorithmic', 'algorithms']) == [35, 20, 12, 14, 37, 36]\n assert candidate(words = ['aaa', 'aab', 'aac', 'aba', 'abb', 'abc', 'aca', 'acb', 'acc', 'baa', 'bab', 'bac', 'bba', 'bbb', 'bbc', 'bca', 'bcb', 'bcc', 'caa', 'cab', 'cac', 'cba', 'cbb', 'cbc', 'cca', 'ccb', 'ccc']) == [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\n assert candidate(words = ['backtracking', 'back', 'backt', 'backtr', 'backtra', 'backtrac', 'backtrack', 'backtracki', 'backtrackin', 'backtrackin', 'backtrackinga', 'backtrackingal', 'backtrackingalg', 'backtrackingalgo']) == [131, 56, 69, 81, 92, 102, 111, 119, 126, 126, 135, 138, 140, 141]\n assert candidate(words = ['prefix', 'pre', 'pres', 'presum', 'pressure']) == [18, 15, 18, 20, 22]\n assert candidate(words = ['interview', 'inter', 'inte', 'interw', 'interv', 'intervi', 'interviewe']) == [45, 34, 28, 35, 38, 41, 46]\n assert candidate(words = ['zebra', 'zoo', 'zookeeper', 'zoozoo', 'ze', 'zee', 'z']) == [13, 13, 19, 16, 10, 11, 7]\n assert candidate(words = ['repeated', 'repeat', 'rep', 're', 'r', 'peated', 'eat', 'e', 't', 'ted', 'tedious', 'tediousness']) == [20, 18, 12, 9, 5, 6, 4, 2, 4, 10, 18, 22]\n assert candidate(words = ['banana', 'ban', 'bananas', 'band', 'bandana', 'bandwidth']) == [24, 18, 25, 21, 24, 26]\n assert candidate(words = ['repeated', 'repeats', 'repeat', 'repeating', 'repeatedly', 'repeatability']) == [40, 37, 36, 39, 42, 43]\n assert candidate(words = ['algorithm', 'al', 'algo', 'all', 'algorithms', 'application', 'app']) == [28, 12, 18, 13, 29, 19, 11]\n assert candidate(words = ['flower', 'flow', 'flight', 'flour', 'flourish', 'flourishingly']) == [21, 19, 16, 23, 29, 34]\n assert candidate(words = ['banana', 'ban', 'band', 'bandana', 'bandanna', 'banda']) == [21, 18, 22, 28, 29, 25]\n assert candidate(words = ['hello', 'hell', 'he', 'h', 'helicopter', 'helium', 'help', 'hero', 'her', 'hemoglobin']) == [27, 26, 19, 10, 32, 28, 25, 22, 21, 27]\n assert candidate(words = ['unique', 'uniques', 'unicorn', 'unicycle', 'universality']) == [21, 22, 20, 21, 24]\n assert candidate(words = ['optimization', 'optimizer', 'optimize', 'optimal', 'optimism', 'optimist', 'optimistic', 'optimum', 'opt', 'optional']) == [61, 59, 58, 49, 57, 58, 60, 49, 30, 43]\n assert candidate(words = ['complex', 'complicated', 'complicate', 'complexity', 'complexion', 'complexing', 'complexified', 'complexify', 'complexifies', 'complexing']) == [66, 61, 60, 75, 75, 77, 81, 77, 81, 77]\n assert candidate(words = ['abracadabra', 'abra', 'bracadabra', 'bracada', 'braca', 'bracad', 'bracadab', 'bracadabr', 'bracadabra', 'bracadabram', 'bracadabramm']) == [15, 8, 75, 60, 45, 53, 66, 71, 75, 77, 78]\n assert candidate(words = ['hello', 'hell', 'help', 'hero', 'her', 'hers', 'he', 'hem', 'hemoglobin']) == [24, 23, 22, 22, 21, 22, 18, 20, 27]\n assert candidate(words = ['trie', 'tr', 'tree', 'tries', 'trigger', 'trig']) == [18, 12, 14, 19, 21, 18]\n assert candidate(words = ['aabbcc', 'aabbc', 'aabb', 'aab', 'aa', 'a']) == [21, 20, 18, 15, 11, 6]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcde', 'abcdef', 'abcdefghij', 'a']) == [48, 21, 24, 32, 5]\n assert candidate(words = ['algorithm', 'algo', 'algor', 'algorit', 'algorith', 'algorithme', 'algori', 'algorithmically']) == [57, 32, 39, 50, 54, 58, 45, 63]\n assert candidate(words = ['banana', 'ban', 'band', 'bandana', 'bandwidth']) == [18, 15, 18, 21, 23]\n assert candidate(words = ['algorithm', 'algebra', 'alien', 'alliance', 'alibi', 'allocate', 'allot', 'allow', 'allude', 'allure', 'alloy', 'ally']) == [32, 30, 28, 37, 28, 40, 37, 37, 36, 36, 37, 33]\n assert candidate(words = ['prefix', 'pre', 'pref', 'prefer', 'preference', 'preferred', 'preferring']) == [29, 21, 27, 35, 39, 39, 40]\n assert candidate(words = ['data', 'database', 'datastructure', 'datamining', 'dataviz', 'datascience', 'datamodel']) == [28, 32, 38, 35, 31, 36, 34]\n assert candidate(words = ['programming', 'program', 'pro', 'progress', 'profound', 'process', 'progressive']) == [37, 33, 21, 35, 26, 25, 38]\n assert candidate(words = ['programming', 'program', 'pro', 'programminglanguage', 'prolog', 'protocol']) == [38, 30, 18, 46, 21, 23]\n assert candidate(words = ['abacaxi', 'abacax', 'abac', 'aba', 'ab', 'a', 'abc', 'abcd', 'abcde']) == [29, 28, 24, 21, 17, 9, 20, 22, 23]\n assert candidate(words = ['zebra', 'ze', 'zoo', 'zookeeper', 'zest', 'zippy', 'zeta', 'zone']) == [15, 12, 13, 19, 14, 12, 14, 13]\n assert candidate(words = ['complexity', 'comp', 'compl', 'comple', 'complex', 'complexe', 'complexit']) == [48, 28, 34, 39, 43, 44, 47]\n assert candidate(words = ['algorithm', 'algebra', 'al', 'algorithmically', 'algo']) == [27, 18, 10, 33, 17]\n assert candidate(words = ['unique', 'un', 'uni', 'unic', 'uniqu', 'uniqueness', 'uniquely', 'uniques']) == [37, 16, 23, 24, 33, 41, 39, 38]\n assert candidate(words = ['datastructure', 'data', 'datas', 'datast', 'datastr', 'datastru', 'datastruc']) == [52, 28, 34, 39, 43, 46, 48]\n assert candidate(words = ['prefix', 'prefixes', 'pref', 'prefer', 'prefixing']) == [26, 28, 20, 22, 29]\n assert candidate(words = ['apple', 'app', 'ap', 'a', 'application']) == [15, 12, 9, 5, 21]\n assert candidate(words = ['banana', 'bandana', 'band', 'bandwidth', 'bandage']) == [18, 23, 19, 24, 23]\n assert candidate(words = ['abacaxi', 'abac', 'aba', 'ab', 'a', 'abacax', 'abacaxs', 'abacaxus']) == [35, 26, 21, 15, 8, 34, 35, 36]\n assert candidate(words = ['interview', 'inter', 'interac', 'interactive', 'interact', 'interactivity']) == [34, 30, 38, 46, 41, 48]\n assert candidate(words = ['prefix', 'prefixing', 'prefixation', 'prefixer', 'pref', 'pre', 'p']) == [32, 35, 37, 34, 24, 19, 7]\n assert candidate(words = ['zebra', 'zebr', 'zeb', 'ze', 'z', 'zebraa', 'zebrab', 'zebrac', 'zebrad']) == [35, 30, 24, 17, 9, 36, 36, 36, 36]\n assert candidate(words = ['cat', 'cater', 'category', 'categories', 'caterpillar', 'catering', 'catered', 'caterer', 'caterers', 'catering']) == [30, 46, 46, 48, 52, 52, 50, 51, 52, 52]\n assert candidate(words = ['abacaxi', 'abacax', 'abac', 'aba', 'ab', 'a', 'bacaxi', 'bacax', 'bac', 'ba', 'b']) == [23, 22, 18, 15, 11, 6, 17, 16, 12, 9, 5]\n assert candidate(words = ['abacax', 'abaca', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']) == [21, 20, 14, 18, 21, 23, 24]\n assert candidate(words = ['xylophone', 'xylo', 'xylophon', 'xylophone', 'xylophones', 'xylophonist', 'xylophonists', 'xylophonistic', 'xylophonistically', 'xylophonists', 'xylophonist']) == [87, 44, 84, 87, 88, 102, 104, 106, 110, 104, 102]\n assert candidate(words = ['algorithm', 'algo', 'al', 'alex', 'alert']) == [19, 14, 10, 13, 14]\n assert candidate(words = ['banana', 'ban', 'band', 'bandana', 'bandwidth', 'bandage']) == [21, 18, 22, 26, 27, 26]\n assert candidate(words = ['test', 'testing', 'tested', 'testify', 'testimony', 'testimonial', 'testament', 'testamentary', 'testator', 'testatrix']) == [40, 46, 42, 46, 51, 53, 52, 55, 48, 49]\n assert candidate(words = ['banana', 'band', 'bandana', 'bandanna', 'bandage', 'bandaid']) == [21, 23, 30, 31, 29, 29]\n assert candidate(words = ['abcd', 'abc', 'ab', 'a', 'zyx', 'zy', 'z', 'mnop', 'mno', 'mn', 'm']) == [10, 9, 7, 4, 6, 5, 3, 10, 9, 7, 4]\n assert candidate(words = ['optimization', 'optimizer', 'optimize', 'optimal', 'optimism', 'optimist', 'optimum', 'option', 'optional', 'opt', 'optic', 'optics']) == [67, 65, 64, 56, 62, 62, 56, 51, 53, 36, 49, 50]\n assert candidate(words = ['banana', 'ban', 'band', 'bandana', 'bandanna', 'banda', 'bandanaaa']) == [24, 21, 26, 35, 35, 30, 37]\n assert candidate(words = ['supercalifragilisticexpialidocious', 'super', 'supercal', 'supercalifrag', 'supercalifragilistic', 'supercalifragilisticex', 'supercalifragilisticexp', 'supercalifragilisticexpia', 'supercalifragilisticexpiali', 'supercalifragilisticexpialidoc', 'supercalifragilisticexpialidociou', 'supercalifragilisticexpialidociousness']) == [274, 60, 93, 143, 206, 222, 229, 241, 251, 263, 272, 278]\n assert candidate(words = ['interspecies', 'inter', 'interstellar', 'interact', 'interaction', 'interference', 'internet', 'interim']) == [48, 40, 48, 46, 49, 47, 43, 42]\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().sumPrefixScores", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] sumPrefixScores(String[] words) {", "container": "Solution", "callable": "sumPrefixScores", "parameters": [{"name": "words", "type": "String[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2418, "task_id": "sort-the-people", "difficulty": "Easy", "problem_description": "You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n.\nFor each index i, names[i] and heights[i] denote the name and height of the ith person.\nReturn names sorted in descending order by the people's heights.\n \nExample 1:\n\nInput: names = [\"Mary\",\"John\",\"Emma\"], heights = [180,165,170]\nOutput: [\"Mary\",\"Emma\",\"John\"]\nExplanation: Mary is the tallest, followed by Emma and John.\n\nExample 2:\n\nInput: names = [\"Alice\",\"Bob\",\"Bob\"], heights = [155,185,150]\nOutput: [\"Bob\",\"Alice\",\"Bob\"]\nExplanation: The first Bob is the tallest, followed by Alice and the second Bob.\n\n \nConstraints:\n\nn == names.length == heights.length\n1 <= n <= 103\n1 <= names[i].length <= 20\n1 <= heights[i] <= 105\nnames[i] consists of lower and upper case English letters.\nAll the values of heights are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(names = ['Zoe', 'Lily', 'Rose'],heights = [150, 145, 155]) == ['Rose', 'Zoe', 'Lily']\n assert candidate(names = ['Qwen', 'Alibaba', 'Cloud'],heights = [200, 190, 180]) == ['Qwen', 'Alibaba', 'Cloud']\n assert candidate(names = ['Ava', 'Sophia', 'Isabella'],heights = [160, 165, 170]) == ['Isabella', 'Sophia', 'Ava']\n assert candidate(names = ['Mary', 'John', 'Emma'],heights = [180, 165, 170]) == ['Mary', 'Emma', 'John']\n assert candidate(names = ['A', 'B', 'C', 'D'],heights = [150, 160, 170, 180]) == ['D', 'C', 'B', 'A']\n assert candidate(names = ['Ava', 'Ella', 'Olivia'],heights = [168, 162, 170]) == ['Olivia', 'Ava', 'Ella']\n assert candidate(names = ['Alice', 'Bob', 'Bob'],heights = [155, 185, 150]) == ['Bob', 'Alice', 'Bob']\n assert candidate(names = ['Zoe', 'Liam', 'Noah'],heights = [165, 175, 185]) == ['Noah', 'Liam', 'Zoe']\n assert candidate(names = ['Noah', 'Liam', 'Mason'],heights = [185, 180, 175]) == ['Noah', 'Liam', 'Mason']\n assert candidate(names = ['Mia', 'Ella', 'Olivia'],heights = [168, 162, 170]) == ['Olivia', 'Mia', 'Ella']\n assert candidate(names = ['Tom', 'Jerry', 'Spike'],heights = [190, 160, 175]) == ['Tom', 'Spike', 'Jerry']\n assert candidate(names = ['Zoe', 'Liam', 'Noah'],heights = [175, 180, 165]) == ['Liam', 'Zoe', 'Noah']\n assert candidate(names = ['Z', 'Y', 'X'],heights = [165, 175, 185]) == ['X', 'Y', 'Z']\n assert candidate(names = ['Anna', 'Elsa', 'Olaf'],heights = [170, 180, 160]) == ['Elsa', 'Anna', 'Olaf']\n assert candidate(names = ['Liam', 'Noah', 'Oliver', 'Elijah', 'James', 'William', 'Benjamin'],heights = [179, 178, 177, 176, 175, 174, 173]) == ['Liam', 'Noah', 'Oliver', 'Elijah', 'James', 'William', 'Benjamin']\n assert candidate(names = ['William', 'James', 'Benjamin', 'Henry'],heights = [190, 170, 180, 160]) == ['William', 'Benjamin', 'James', 'Henry']\n assert candidate(names = ['Jackson', 'Aiden', 'Mason', 'Lucas'],heights = [182, 188, 178, 180]) == ['Aiden', 'Jackson', 'Lucas', 'Mason']\n assert candidate(names = ['Dominic', 'Penelope', 'Victor', 'Emilia', 'Mason'],heights = [178, 173, 189, 169, 174]) == ['Victor', 'Dominic', 'Mason', 'Penelope', 'Emilia']\n assert candidate(names = ['Ezra', 'Isabella', 'Oliver', 'Sophia', 'Noah', 'Emma', 'James', 'Amelia', 'Benjamin', 'Ava', 'Elijah', 'Liam'],heights = [177, 165, 183, 170, 185, 171, 179, 172, 180, 167, 182, 184]) == ['Noah', 'Liam', 'Oliver', 'Elijah', 'Benjamin', 'James', 'Ezra', 'Amelia', 'Emma', 'Sophia', 'Ava', 'Isabella']\n assert candidate(names = ['Daniel', 'Matthew', 'Ethan', 'Logan', 'Jackson'],heights = [175, 170, 165, 160, 155]) == ['Daniel', 'Matthew', 'Ethan', 'Logan', 'Jackson']\n assert candidate(names = ['William', 'James', 'George', 'Charles'],heights = [188, 192, 178, 180]) == ['James', 'William', 'Charles', 'George']\n assert candidate(names = ['Liam', 'Noah', 'Oliver', 'Elijah', 'William'],heights = [180, 178, 175, 173, 170]) == ['Liam', 'Noah', 'Oliver', 'Elijah', 'William']\n assert candidate(names = ['Sophia', 'Jackson', 'Mia', 'Logan'],heights = [160, 200, 180, 170]) == ['Jackson', 'Mia', 'Logan', 'Sophia']\n assert candidate(names = ['Amelia', 'Olivia', 'Emma', 'Sophia'],heights = [155, 165, 175, 185]) == ['Sophia', 'Emma', 'Olivia', 'Amelia']\n assert candidate(names = ['Emma', 'Noah', 'Olivia', 'Elijah', 'Ava', 'Sophia'],heights = [173, 186, 168, 183, 170, 165]) == ['Noah', 'Elijah', 'Emma', 'Ava', 'Olivia', 'Sophia']\n assert candidate(names = ['Levi', 'Carter', 'Aria', 'Sebastian', 'Avery'],heights = [175, 184, 168, 189, 176]) == ['Sebastian', 'Carter', 'Avery', 'Levi', 'Aria']\n assert candidate(names = ['Sophia', 'Olivia', 'Isabella', 'Ava', 'Emma'],heights = [162, 178, 168, 173, 175]) == ['Olivia', 'Emma', 'Ava', 'Isabella', 'Sophia']\n assert candidate(names = ['William', 'James', 'Oliver', 'Noah', 'Elijah', 'Lucas'],heights = [195, 194, 193, 192, 191, 190]) == ['William', 'James', 'Oliver', 'Noah', 'Elijah', 'Lucas']\n assert candidate(names = ['Zachary', 'Christopher', 'Jonathan', 'Matthew'],heights = [195, 190, 180, 185]) == ['Zachary', 'Christopher', 'Matthew', 'Jonathan']\n assert candidate(names = ['Charlie', 'Delta', 'Echo', 'Foxtrot', 'Golf'],heights = [160, 165, 170, 175, 180]) == ['Golf', 'Foxtrot', 'Echo', 'Delta', 'Charlie']\n assert candidate(names = ['Ava', 'Isabella', 'Sophia', 'Emma', 'Olivia', 'Mia'],heights = [155, 157, 158, 160, 159, 156]) == ['Emma', 'Olivia', 'Sophia', 'Isabella', 'Mia', 'Ava']\n assert candidate(names = ['Grace', 'Heidi', 'Ivy', 'Judy', 'Kara'],heights = [158, 168, 178, 188, 198]) == ['Kara', 'Judy', 'Ivy', 'Heidi', 'Grace']\n assert candidate(names = ['Mila', 'Aaron', 'Jasper', 'Sophie'],heights = [170, 160, 200, 180]) == ['Jasper', 'Sophie', 'Mila', 'Aaron']\n assert candidate(names = ['Finn', 'Jake', 'BMO', 'Marceline', 'LSP'],heights = [160, 170, 155, 180, 150]) == ['Marceline', 'Jake', 'Finn', 'BMO', 'LSP']\n assert candidate(names = ['Zoe', 'Chris', 'Ava', 'Ian'],heights = [165, 190, 175, 180]) == ['Chris', 'Ian', 'Ava', 'Zoe']\n assert candidate(names = ['Grace', 'Katherine', 'Ava', 'Sophie', 'Liam'],heights = [165, 172, 160, 170, 180]) == ['Liam', 'Katherine', 'Sophie', 'Grace', 'Ava']\n assert candidate(names = ['Olivia', 'Emma', 'Ava', 'Sophia'],heights = [158, 159, 160, 157]) == ['Ava', 'Emma', 'Olivia', 'Sophia']\n assert candidate(names = ['Evelyn', 'Arthur', 'Sophie', 'Miles'],heights = [160, 190, 180, 175]) == ['Arthur', 'Sophie', 'Miles', 'Evelyn']\n assert candidate(names = ['Ethan', 'Abigail', 'Daniel', 'Ella'],heights = [185, 168, 195, 175]) == ['Daniel', 'Ethan', 'Ella', 'Abigail']\n assert candidate(names = ['Ava', 'Ella', 'Scarlett', 'Grace'],heights = [185, 175, 165, 155]) == ['Ava', 'Ella', 'Scarlett', 'Grace']\n assert candidate(names = ['Amelia', 'Olivia', 'Ava', 'Isla'],heights = [168, 169, 170, 171]) == ['Isla', 'Ava', 'Olivia', 'Amelia']\n assert candidate(names = ['Noah', 'Sophia', 'Mia', 'Ethan'],heights = [195, 180, 175, 170]) == ['Noah', 'Sophia', 'Mia', 'Ethan']\n assert candidate(names = ['Michael', 'Jordan', 'LeBron', 'Stephen', 'Kobe'],heights = [198, 206, 203, 191, 198]) == ['Jordan', 'LeBron', 'Michael', 'Kobe', 'Stephen']\n assert candidate(names = ['Alex', 'Brian', 'Carter', 'David', 'Ethan'],heights = [155, 165, 175, 185, 195]) == ['Ethan', 'David', 'Carter', 'Brian', 'Alex']\n assert candidate(names = ['Jonathan', 'Katherine', 'Lucas', 'Mia', 'Nina'],heights = [175, 165, 180, 170, 160]) == ['Lucas', 'Jonathan', 'Mia', 'Katherine', 'Nina']\n assert candidate(names = ['Lucas', 'Hannah', 'Olivia', 'Avery'],heights = [185, 168, 190, 175]) == ['Olivia', 'Lucas', 'Avery', 'Hannah']\n assert candidate(names = ['Nina', 'Nora', 'Nina', 'Nora'],heights = [160, 162, 158, 159]) == ['Nora', 'Nina', 'Nora', 'Nina']\n assert candidate(names = ['Daniel', 'Matilda', 'Samuel', 'Lucas', 'Mia', 'Emily', 'Oliver', 'Ava'],heights = [182, 165, 178, 184, 170, 167, 190, 173]) == ['Oliver', 'Lucas', 'Daniel', 'Samuel', 'Ava', 'Mia', 'Emily', 'Matilda']\n assert candidate(names = ['Sophia', 'Olivia', 'Ava', 'Isabella', 'Mia'],heights = [160, 165, 170, 175, 180]) == ['Mia', 'Isabella', 'Ava', 'Olivia', 'Sophia']\n assert candidate(names = ['Sophia', 'Oliver', 'Isabella', 'Noah'],heights = [172, 180, 168, 182]) == ['Noah', 'Oliver', 'Sophia', 'Isabella']\n assert candidate(names = ['Zoe', 'Sophia', 'Ava', 'Isabella'],heights = [163, 164, 165, 162]) == ['Ava', 'Sophia', 'Zoe', 'Isabella']\n assert candidate(names = ['Oliver', 'Amelia', 'Evelyn', 'Jasper'],heights = [185, 170, 180, 190]) == ['Jasper', 'Oliver', 'Evelyn', 'Amelia']\n assert candidate(names = ['Emily', 'Emma', 'Mia', 'Sophia', 'Isabella', 'Ava', 'Olivia'],heights = [163, 164, 162, 165, 166, 161, 160]) == ['Isabella', 'Sophia', 'Emma', 'Emily', 'Mia', 'Ava', 'Olivia']\n assert candidate(names = ['Isabella', 'Sophia', 'Olivia', 'Ava', 'Emma'],heights = [162, 172, 182, 192, 202]) == ['Emma', 'Ava', 'Olivia', 'Sophia', 'Isabella']\n assert candidate(names = ['Liam', 'Noah', 'Oliver', 'Lucas', 'Ethan'],heights = [200, 199, 198, 197, 196]) == ['Liam', 'Noah', 'Oliver', 'Lucas', 'Ethan']\n assert candidate(names = ['Scarlett', 'Ava', 'Emma', 'Olivia', 'Sophia'],heights = [175, 180, 170, 165, 185]) == ['Sophia', 'Ava', 'Scarlett', 'Emma', 'Olivia']\n assert candidate(names = ['Sophia', 'Emma', 'Ava', 'Olivia', 'Isabella', 'Mia'],heights = [169, 168, 167, 166, 165, 164]) == ['Sophia', 'Emma', 'Ava', 'Olivia', 'Isabella', 'Mia']\n assert candidate(names = ['Benjamin', 'Logan', 'Jackson', 'David', 'Aiden'],heights = [150, 160, 170, 180, 190]) == ['Aiden', 'David', 'Jackson', 'Logan', 'Benjamin']\n assert candidate(names = ['Mia', 'Evelyn', 'Abigail', 'Scarlett', 'Amelia'],heights = [180, 175, 170, 165, 160]) == ['Mia', 'Evelyn', 'Abigail', 'Scarlett', 'Amelia']\n assert candidate(names = ['Camila', 'Lincoln', 'Madison', 'Isaac', 'Scarlett'],heights = [167, 187, 170, 182, 163]) == ['Lincoln', 'Isaac', 'Madison', 'Camila', 'Scarlett']\n assert candidate(names = ['Sophia', 'Isabella', 'Olivia', 'Ava', 'Mia'],heights = [162, 171, 168, 165, 169]) == ['Isabella', 'Mia', 'Olivia', 'Ava', 'Sophia']\n assert candidate(names = ['Theodore', 'George', 'Thomas', 'James'],heights = [175, 185, 180, 170]) == ['George', 'Thomas', 'Theodore', 'James']\n assert candidate(names = ['Sam', 'Max', 'Leo', 'Sam'],heights = [185, 182, 179, 184]) == ['Sam', 'Sam', 'Max', 'Leo']\n assert candidate(names = ['Charlotte', 'Sophia', 'Ava', 'Isabella'],heights = [165, 170, 175, 180]) == ['Isabella', 'Ava', 'Sophia', 'Charlotte']\n assert candidate(names = ['Charlotte', 'Amelia', 'Evelyn', 'Abigail', 'Sofia'],heights = [150, 155, 160, 165, 170]) == ['Sofia', 'Abigail', 'Evelyn', 'Amelia', 'Charlotte']\n assert candidate(names = ['Lily', 'Aaron', 'Emma', 'Nolan'],heights = [165, 185, 175, 195]) == ['Nolan', 'Aaron', 'Emma', 'Lily']\n assert candidate(names = ['Sophia', 'Isabella', 'Olivia', 'Ava'],heights = [165, 172, 168, 170]) == ['Isabella', 'Ava', 'Olivia', 'Sophia']\n assert candidate(names = ['Ethan', 'Noah', 'Liam', 'Mason'],heights = [180, 185, 170, 175]) == ['Noah', 'Ethan', 'Mason', 'Liam']\n assert candidate(names = ['Alexander', 'Sophia', 'Benjamin', 'Charlotte', 'Elijah', 'Mia', 'James', 'Amelia'],heights = [180, 166, 175, 168, 183, 172, 178, 171]) == ['Elijah', 'Alexander', 'James', 'Benjamin', 'Mia', 'Amelia', 'Charlotte', 'Sophia']\n assert candidate(names = ['William', 'James', 'Oliver', 'Benjamin', 'Elijah', 'Lucas'],heights = [187, 186, 185, 184, 183, 182]) == ['William', 'James', 'Oliver', 'Benjamin', 'Elijah', 'Lucas']\n assert candidate(names = ['Eva', 'Nathan', 'Ella', 'Samuel', 'Sophia'],heights = [169, 179, 171, 186, 174]) == ['Samuel', 'Nathan', 'Sophia', 'Ella', 'Eva']\n assert candidate(names = ['Zoe', 'Addison', 'Mia', 'Hannah', 'Abigail'],heights = [168, 167, 166, 165, 164]) == ['Zoe', 'Addison', 'Mia', 'Hannah', 'Abigail']\n assert candidate(names = ['Benjamin', 'Olivia', 'Daniel', 'Zachary'],heights = [170, 180, 160, 190]) == ['Zachary', 'Olivia', 'Benjamin', 'Daniel']\n assert candidate(names = ['Carter', 'Jackson', 'Lucas', 'Logan', 'Benjamin'],heights = [190, 185, 180, 175, 170]) == ['Carter', 'Jackson', 'Lucas', 'Logan', 'Benjamin']\n assert candidate(names = ['Amelia', 'Oliver', 'Ava', 'Noah', 'Sophia', 'Ethan', 'Isabella', 'Elijah'],heights = [172, 188, 169, 185, 171, 182, 168, 184]) == ['Oliver', 'Noah', 'Elijah', 'Ethan', 'Amelia', 'Sophia', 'Ava', 'Isabella']\n assert candidate(names = ['Michael', 'Christopher', 'Jessica', 'Matthew', 'Ashley'],heights = [182, 178, 165, 180, 170]) == ['Michael', 'Matthew', 'Christopher', 'Ashley', 'Jessica']\n assert candidate(names = ['Amelia', 'Sophia', 'Isabella', 'Olivia', 'Ava', 'Emma'],heights = [150, 151, 152, 153, 154, 155]) == ['Emma', 'Ava', 'Olivia', 'Isabella', 'Sophia', 'Amelia']\n assert candidate(names = ['Catherine', 'Margaret', 'Joan', 'Eleanor'],heights = [167, 173, 170, 169]) == ['Margaret', 'Joan', 'Eleanor', 'Catherine']\n assert candidate(names = ['Mason', 'Jacob', 'William', 'Ethan', 'Alexander'],heights = [155, 165, 175, 185, 195]) == ['Alexander', 'Ethan', 'William', 'Jacob', 'Mason']\n assert candidate(names = ['Sophia', 'Ava', 'Emma', 'Isabella', 'Olivia', 'Mia', 'Charlotte'],heights = [169, 168, 167, 166, 165, 164, 163]) == ['Sophia', 'Ava', 'Emma', 'Isabella', 'Olivia', 'Mia', 'Charlotte']\n assert candidate(names = ['Scarlett', 'Avery', 'James', 'Michael', 'Evelyn'],heights = [162, 177, 181, 180, 166]) == ['James', 'Michael', 'Avery', 'Evelyn', 'Scarlett']\n assert candidate(names = ['Sophia', 'Jackson', 'Ava', 'Lucas', 'Mia', 'Ethan'],heights = [160, 195, 168, 180, 170, 185]) == ['Jackson', 'Ethan', 'Lucas', 'Mia', 'Ava', 'Sophia']\n assert candidate(names = ['Sophia', 'Isabella', 'Olivia', 'Ava', 'Emma'],heights = [160, 165, 170, 175, 180]) == ['Emma', 'Ava', 'Olivia', 'Isabella', 'Sophia']\n assert candidate(names = ['Alexander', 'Michael', 'Benjamin', 'Daniel'],heights = [190, 188, 185, 187]) == ['Alexander', 'Michael', 'Daniel', 'Benjamin']\n assert candidate(names = ['Mia', 'Ethan', 'Amelia', 'Liam', 'Olivia'],heights = [168, 180, 169, 182, 165]) == ['Liam', 'Ethan', 'Amelia', 'Mia', 'Olivia']\n assert candidate(names = ['Sophia', 'Olivia', 'Ava', 'Isabella'],heights = [165, 170, 175, 180]) == ['Isabella', 'Ava', 'Olivia', 'Sophia']\n assert candidate(names = ['Alexander', 'Michael', 'William', 'James', 'Benjamin'],heights = [155, 190, 165, 185, 170]) == ['Michael', 'James', 'Benjamin', 'William', 'Alexander']\n assert candidate(names = ['Emily', 'Emma', 'Sophia', 'Olivia', 'Isabella', 'Ava'],heights = [161, 160, 159, 158, 157, 156]) == ['Emily', 'Emma', 'Sophia', 'Olivia', 'Isabella', 'Ava']\n assert candidate(names = ['Zoe', 'Lily', 'Rosie', 'Lena'],heights = [160, 162, 158, 159]) == ['Lily', 'Zoe', 'Lena', 'Rosie']\n assert candidate(names = ['Zoe', 'Abigail', 'Daniel', 'Jackson', 'Harper'],heights = [165, 172, 179, 183, 170]) == ['Jackson', 'Daniel', 'Abigail', 'Harper', 'Zoe']\n assert candidate(names = ['Jackson', 'Aiden', 'Lucas', 'Caleb', 'Noah'],heights = [151, 161, 171, 181, 191]) == ['Noah', 'Caleb', 'Lucas', 'Aiden', 'Jackson']\n assert candidate(names = ['Alexander', 'Noah', 'Daniel', 'Matthew', 'Logan'],heights = [182, 181, 183, 180, 179]) == ['Daniel', 'Alexander', 'Noah', 'Matthew', 'Logan']\n assert candidate(names = ['Liam', 'Noah', 'Oliver', 'Elijah', 'James'],heights = [170, 180, 190, 200, 210]) == ['James', 'Elijah', 'Oliver', 'Noah', 'Liam']\n assert candidate(names = ['Lucas', 'Mason', 'Logan', 'Ethan'],heights = [178, 177, 179, 176]) == ['Logan', 'Lucas', 'Mason', 'Ethan']\n assert candidate(names = ['Peter', 'Paul', 'Mary', 'John', 'Jane'],heights = [175, 180, 165, 170, 160]) == ['Paul', 'Peter', 'John', 'Mary', 'Jane']\n assert candidate(names = ['William', 'James', 'Benjamin', 'Henry', 'Noah', 'Liam'],heights = [185, 180, 175, 170, 190, 195]) == ['Liam', 'Noah', 'William', 'James', 'Benjamin', 'Henry']\n assert candidate(names = ['Zoe', 'Lily', 'Ella', 'Amelia'],heights = [160, 165, 170, 175]) == ['Amelia', 'Ella', 'Lily', 'Zoe']\n assert candidate(names = ['Amelia', 'Connor', 'Sophia', 'Ethan'],heights = [175, 195, 180, 185]) == ['Connor', 'Ethan', 'Sophia', 'Amelia']\n assert candidate(names = ['William', 'James', 'Oliver', 'Benjamin', 'Elijah'],heights = [190, 185, 180, 175, 170]) == ['William', 'James', 'Oliver', 'Benjamin', 'Elijah']\n assert candidate(names = ['Emily', 'Ava', 'Sophia', 'Charlotte', 'Isabella'],heights = [160, 170, 165, 155, 175]) == ['Isabella', 'Ava', 'Sophia', 'Emily', 'Charlotte']\n assert candidate(names = ['Liam', 'Noah', 'Oliver', 'Elijah', 'William', 'James'],heights = [179, 178, 177, 176, 175, 174]) == ['Liam', 'Noah', 'Oliver', 'Elijah', 'William', 'James']\n assert candidate(names = ['Jonathan', 'Jordan', 'Jack', 'Jared', 'James', 'Jackson'],heights = [198, 197, 196, 195, 194, 193]) == ['Jonathan', 'Jordan', 'Jack', 'Jared', 'James', 'Jackson']\n assert candidate(names = ['Zoe', 'Yasmin', 'Xander', 'Will', 'Vera'],heights = [150, 160, 170, 180, 190]) == ['Vera', 'Will', 'Xander', 'Yasmin', 'Zoe']\n assert candidate(names = ['Ava', 'Isabella', 'Sophia', 'Mia'],heights = [165, 175, 185, 155]) == ['Sophia', 'Isabella', 'Ava', 'Mia']\n assert candidate(names = ['Zara', 'Oliver', 'Isabella', 'Charlie'],heights = [175, 190, 165, 180]) == ['Oliver', 'Charlie', 'Zara', 'Isabella']\n assert candidate(names = ['Alex', 'Brian', 'Craig', 'David', 'Evan'],heights = [173, 171, 175, 169, 172]) == ['Craig', 'Alex', 'Evan', 'Brian', 'David']\n assert candidate(names = ['Alexander', 'Michael', 'James', 'John', 'Daniel', 'David'],heights = [172, 171, 173, 174, 175, 176]) == ['David', 'Daniel', 'John', 'James', 'Alexander', 'Michael']\n assert candidate(names = ['Scarlett', 'William', 'Lily', 'James', 'Ava', 'Thomas', 'Ella', 'Noah', 'Ethan', 'Mia', 'Olivia'],heights = [174, 185, 167, 180, 168, 182, 170, 183, 181, 169, 165]) == ['William', 'Noah', 'Thomas', 'Ethan', 'James', 'Scarlett', 'Ella', 'Mia', 'Ava', 'Lily', 'Olivia']\n assert candidate(names = ['Emma', 'Charlotte', 'Ava', 'Logan', 'Benjamin'],heights = [163, 170, 167, 178, 185]) == ['Benjamin', 'Logan', 'Charlotte', 'Ava', 'Emma']\n assert candidate(names = ['Sophie', 'Grayson', 'Hannah', 'Isaac', 'Layla'],heights = [170, 185, 165, 188, 172]) == ['Isaac', 'Grayson', 'Layla', 'Sophie', 'Hannah']\n assert candidate(names = ['Evelyn', 'Sophie', 'Isabella', 'Mia', 'Emma'],heights = [168, 170, 166, 165, 172]) == ['Emma', 'Sophie', 'Evelyn', 'Isabella', 'Mia']\n assert candidate(names = ['Zara', 'Xander', 'Yasmin', 'Will'],heights = [160, 175, 170, 165]) == ['Xander', 'Yasmin', 'Will', 'Zara']\n assert candidate(names = ['Liam', 'Hannah', 'Sophie', 'Lucas'],heights = [195, 170, 180, 175]) == ['Liam', 'Sophie', 'Lucas', 'Hannah']\n assert candidate(names = ['Liam', 'Olivia', 'Noah', 'Emma', 'Oliver', 'Ava', 'Sophia', 'Elijah', 'Amelia'],heights = [181, 168, 185, 171, 183, 167, 170, 182, 173]) == ['Noah', 'Oliver', 'Elijah', 'Liam', 'Amelia', 'Emma', 'Sophia', 'Olivia', 'Ava']\n assert candidate(names = ['Sophia', 'Ava', 'Isabella', 'Mia'],heights = [160, 170, 175, 180]) == ['Mia', 'Isabella', 'Ava', 'Sophia']\n assert candidate(names = ['Avery', 'Grayson', 'Evan', 'Nathan'],heights = [172, 182, 175, 180]) == ['Grayson', 'Nathan', 'Evan', 'Avery']\n assert candidate(names = ['Willow', 'Tara', 'Xander', 'Alyson', 'Reese'],heights = [175, 160, 170, 165, 180]) == ['Reese', 'Willow', 'Xander', 'Alyson', 'Tara']\n assert candidate(names = ['Eli', 'Ella', 'Ezra', 'Emilia', 'Evan'],heights = [170, 175, 160, 180, 165]) == ['Emilia', 'Ella', 'Eli', 'Evan', 'Ezra']\n assert candidate(names = ['James', 'Benjamin', 'Mason', 'Noah', 'Lucas'],heights = [170, 175, 180, 185, 190]) == ['Lucas', 'Noah', 'Mason', 'Benjamin', 'James']\n assert candidate(names = ['Jack', 'Rose', 'Cal', 'Fabian', 'Molly'],heights = [170, 175, 165, 180, 160]) == ['Fabian', 'Rose', 'Jack', 'Cal', 'Molly']\n"}, "metadata": {"canonical_parameter_names": ["names", "heights"], "leetcode_dataset_entry_point": "Solution().sortPeople", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String[] sortPeople(String[] names, int[] heights) {", "container": "Solution", "callable": "sortPeople", "parameters": [{"name": "names", "type": "String[]"}, {"name": "heights", "type": "int[]"}], "return_type": "String[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2419, "task_id": "longest-subarray-with-maximum-bitwise-and", "difficulty": "Medium", "problem_description": "You are given an integer array nums of size n.\nConsider a non-empty subarray from nums that has the maximum possible bitwise AND.\n\nIn other words, let k be the maximum value of the bitwise AND of any subarray of nums. Then, only subarrays with a bitwise AND equal to k should be considered.\n\nReturn the length of the longest such subarray.\nThe bitwise AND of an array is the bitwise AND of all the numbers in it.\nA subarray is a contiguous sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,2,3,3,2,2]\nOutput: 2\nExplanation:\nThe maximum possible bitwise AND of a subarray is 3.\nThe longest subarray with that value is [3,3], so we return 2.\n\nExample 2:\n\nInput: nums = [1,2,3,4]\nOutput: 1\nExplanation:\nThe maximum possible bitwise AND of a subarray is 4.\nThe longest subarray with that value is [4], so we return 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 = [8, 9, 10, 11, 12, 13, 14, 15, 16]) == 1\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 1\n assert candidate(nums = [8, 9, 10, 10, 10, 8]) == 3\n assert candidate(nums = [2, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1048576, 1048576, 1048576, 1048575, 1048574]) == 3\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [8, 1, 2, 3, 7, 8, 8]) == 2\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 = [8, 9, 7, 6, 8, 9, 9, 8]) == 2\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 3, 4]) == 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]) == 1\n assert candidate(nums = [1048575, 1048575, 1048575, 1048575]) == 4\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1000000, 1, 2, 3, 1000000, 1000000]) == 2\n assert candidate(nums = [3, 1, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 10\n assert candidate(nums = [1, 2, 3, 3, 2, 2]) == 2\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995]) == 1\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 2, 2, 2, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2]) == 6\n assert candidate(nums = [32, 32, 32, 32, 31, 30, 29, 28, 27, 26]) == 4\n assert candidate(nums = [2, 3, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8]) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 10, 10, 2, 10, 10, 10, 5, 5, 5, 5, 10, 10, 10, 10, 1, 1, 1, 1]) == 4\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]) == 30\n assert candidate(nums = [17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 19, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]) == 10\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 = [13, 13, 13, 14, 14, 14, 14, 13, 13, 14, 14, 14, 14, 14, 13, 13, 13, 14, 14, 14]) == 5\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483646, 2147483647, 2147483647, 2147483647, 2147483646]) == 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 55\n assert candidate(nums = [32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]) == 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, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 16\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 22\n assert candidate(nums = [1000000, 1000000, 500000, 500000, 250000, 250000, 125000, 125000, 62500, 62500, 31250, 31250, 15625, 15625, 7812, 7812, 3906, 3906, 1953, 1953]) == 2\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, 10, 10, 10, 10, 10, 10, 10, 10]) == 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, 50, 50, 50, 50, 50, 50, 50, 50, 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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1000000, 1000000, 1000000, 1000000]) == 4\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, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 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, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 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]) == 51\n assert candidate(nums = [128, 255, 255, 128, 255, 255, 255, 128, 128, 255, 255, 255, 255, 255, 128]) == 5\n assert candidate(nums = [5, 5, 6, 6, 6, 5, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 5, 5, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6]) == 8\n assert candidate(nums = [999999, 999998, 999999, 999997, 999999, 999999, 999996, 999999, 999999, 999999]) == 3\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestSubarray(int[] nums) {", "container": "Solution", "callable": "longestSubarray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2420, "task_id": "find-all-good-indices", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of size n and a positive integer k.\nWe call an index i in the range k <= i < n - k good if the following conditions are satisfied:\n\nThe k elements that are just before the index i are in non-increasing order.\nThe k elements that are just after the index i are in non-decreasing order.\n\nReturn an array of all good indices sorted in increasing order.\n \nExample 1:\n\nInput: nums = [2,1,1,1,3,4,1], k = 2\nOutput: [2,3]\nExplanation: There are two good indices in the array:\n- Index 2. The subarray [2,1] is in non-increasing order, and the subarray [1,3] is in non-decreasing order.\n- Index 3. The subarray [1,1] is in non-increasing order, and the subarray [3,4] is in non-decreasing order.\nNote that the index 4 is not good because [4,1] is not non-decreasing.\nExample 2:\n\nInput: nums = [2,1,1,2], k = 2\nOutput: []\nExplanation: There are no good indices in this array.\n\n \nConstraints:\n\nn == nums.length\n3 <= n <= 105\n1 <= nums[i] <= 106\n1 <= k <= n / 2\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5],k = 3) == [7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1],k = 2) == []\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 4, 3, 2, 1],k = 3) == []\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == []\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992],k = 3) == []\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5],k = 2) == [3, 4, 5]\n assert candidate(nums = [5, 4, 5, 3, 4, 5, 6, 7, 8],k = 2) == [2, 4]\n assert candidate(nums = [2, 1, 1, 2],k = 2) == []\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 3) == []\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],k = 2) == []\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == [7, 8, 9]\n assert candidate(nums = [5, 4, 3, 4, 5],k = 1) == [1, 2, 3]\n assert candidate(nums = [2, 1, 1, 1, 3, 4, 1],k = 2) == [2, 3]\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1],k = 3) == [4, 7, 15, 18]\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 3) == [3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == [7, 8, 9]\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 2) == []\n assert candidate(nums = [100, 99, 98, 97, 96, 97, 98, 99, 100, 101, 102, 103, 104, 103, 102, 101, 100],k = 4) == [4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3],k = 2) == [6, 10, 14]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],k = 5) == [5]\n assert candidate(nums = [10, 20, 30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10, 20, 30],k = 4) == []\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == []\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == [7, 8, 9, 10]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [5, 6, 7]\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 2, 1, 2, 3],k = 2) == [3, 7]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 1, 1, 20, 30, 40],k = 3) == [9, 10, 11, 12]\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],k = 3) == [4, 5, 6]\n assert candidate(nums = [10, 9, 8, 7, 7, 6, 5, 4, 4, 3, 2, 1],k = 3) == []\n assert candidate(nums = [1, 3, 2, 3, 2, 3, 2, 3, 2, 1],k = 2) == [3, 5]\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 2) == [3, 4, 5, 6, 13, 14, 15, 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 = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1],k = 2) == [5, 6, 10, 11, 15, 16]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\n assert candidate(nums = [10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11],k = 2) == [3, 5, 7, 9, 11, 13]\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],k = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == []\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],k = 3) == []\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999997, 999998, 999999, 1000000],k = 3) == [3, 4, 5]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3],k = 3) == [7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == [14]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [8, 9, 10, 11]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == [3, 4, 5, 6]\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],k = 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],k = 5) == []\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1],k = 3) == [6]\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [5, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == []\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 4, 3, 2, 1],k = 2) == [3]\n assert candidate(nums = [8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == []\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6],k = 3) == [8, 9, 10]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 2) == [3, 5, 7, 9, 11]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1],k = 4) == []\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1],k = 4) == [5, 6, 7, 11, 12, 13, 14]\n assert candidate(nums = [5, 3, 2, 1, 1, 1, 2, 3, 4, 5],k = 2) == [2, 3, 4, 5, 6]\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2],k = 3) == []\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [3, 4, 5, 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],k = 3) == [3, 4, 5, 6, 9, 10, 11, 12, 15, 16, 17, 18]\n assert candidate(nums = [5, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7],k = 3) == [7, 8, 9, 15]\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10],k = 2) == [3, 5, 7, 9, 11, 13, 15]\n assert candidate(nums = [1, 3, 2, 2, 2, 1, 3, 4, 3, 2, 1, 2, 3, 4, 5],k = 2) == [4, 5, 9, 10, 11]\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 3, 3, 2, 2, 1, 1],k = 2) == [3, 4, 5, 10]\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],k = 4) == [4, 5, 6, 7, 8, 9]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 11, 12, 13, 14, 15],k = 5) == [8, 9]\n assert candidate(nums = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == [3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4],k = 3) == [15, 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 = 5) == []\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 4) == []\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1],k = 3) == []\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == [4, 5, 6, 7]\n assert candidate(nums = [5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5],k = 2) == [5, 6, 7]\n assert candidate(nums = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [9, 10, 11]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],k = 5) == [7, 8, 9]\n assert candidate(nums = [5, 4, 4, 3, 2, 2, 3, 4, 5],k = 2) == [3, 4, 5, 6]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],k = 3) == []\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [7, 8, 9]\n assert candidate(nums = [5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],k = 3) == [5, 6, 7]\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],k = 3) == [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\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 = 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],k = 3) == []\n assert candidate(nums = [1, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 2, 1],k = 2) == [5, 7, 11, 13]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == [7, 8, 9, 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, 3, 2, 1],k = 5) == []\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],k = 5) == [10]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],k = 2) == [4, 8, 12]\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2],k = 2) == [3, 4, 7, 8]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [8, 9, 10]\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == [6, 7, 8, 9, 10, 11, 12, 13, 14]\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) == []\n assert candidate(nums = [3, 2, 1, 1, 1, 2, 3, 4, 5, 6],k = 2) == [2, 3, 4, 5]\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 = 5) == []\n assert candidate(nums = [1, 2, 3, 4, 3, 3, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1],k = 3) == [6, 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, 1],k = 2) == [4, 8, 12, 16]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == []\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 5, 6, 7, 8, 9],k = 3) == [4, 5, 6]\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5],k = 3) == [9, 10]\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) == []\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],k = 2) == [2, 4, 6, 8, 10, 12, 14, 16]\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],k = 5) == [5]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 4) == [8, 9, 10]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 2) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().goodIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List goodIndices(int[] nums, int k) {", "container": "Solution", "callable": "goodIndices", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2421, "task_id": "number-of-good-paths", "difficulty": "Hard", "problem_description": "There is a tree (i.e. a connected, undirected graph with no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges.\nYou are given a 0-indexed integer array vals of length n where vals[i] denotes the value of the ith node. You are also given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai and bi.\nA good path is a simple path that satisfies the following conditions:\n\nThe starting node and the ending node have the same value.\nAll nodes between the starting node and the ending node have values less than or equal to the starting node (i.e. the starting node's value should be the maximum value along the path).\n\nReturn the number of distinct good paths.\nNote that a path and its reverse are counted as the same path. For example, 0 -> 1 is considered to be the same as 1 -> 0. A single node is also considered as a valid path.\n \nExample 1:\n\n\nInput: vals = [1,3,2,1,3], edges = [[0,1],[0,2],[2,3],[2,4]]\nOutput: 6\nExplanation: There are 5 good paths consisting of a single node.\nThere is 1 additional good path: 1 -> 0 -> 2 -> 4.\n(The reverse path 4 -> 2 -> 0 -> 1 is treated as the same as 1 -> 0 -> 2 -> 4.)\nNote that 0 -> 2 -> 3 is not a good path because vals[2] > vals[0].\n\nExample 2:\n\n\nInput: vals = [1,1,2,2,3], edges = [[0,1],[1,2],[2,3],[2,4]]\nOutput: 7\nExplanation: There are 5 good paths consisting of a single node.\nThere are 2 additional good paths: 0 -> 1 and 2 -> 3.\n\nExample 3:\n\n\nInput: vals = [1], edges = []\nOutput: 1\nExplanation: The tree consists of only one node, so there is one good path.\n\n \nConstraints:\n\nn == vals.length\n1 <= n <= 3 * 104\n0 <= vals[i] <= 105\nedges.length == n - 1\nedges[i].length == 2\n0 <= ai, bi < n\nai != bi\nedges represents a valid tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(vals = [2, 2, 2, 2, 2],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 15\n assert candidate(vals = [1],edges = []) == 1\n assert candidate(vals = [1, 2, 3, 4, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 5\n assert candidate(vals = [1, 2, 2, 3, 3, 4, 4],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 10\n assert candidate(vals = [2, 2, 2, 2],edges = [[0, 1], [1, 2], [2, 3]]) == 10\n assert candidate(vals = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(vals = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(vals = [10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3]]) == 10\n assert candidate(vals = [1, 1, 2, 2, 3],edges = [[0, 1], [1, 2], [2, 3], [2, 4]]) == 7\n assert candidate(vals = [5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 5\n assert candidate(vals = [1, 3, 2, 1, 3],edges = [[0, 1], [0, 2], [2, 3], [2, 4]]) == 6\n assert candidate(vals = [1, 3, 3, 3, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 8\n assert candidate(vals = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 12\n assert candidate(vals = [3, 1, 4, 4, 3],edges = [[0, 1], [1, 2], [2, 3], [2, 4]]) == 6\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 55\n assert candidate(vals = [1, 2, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [2, 4]]) == 5\n assert candidate(vals = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],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]]) == 56\n assert candidate(vals = [1, 3, 2, 3, 1, 4, 2, 3, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [4, 7], [6, 8]]) == 13\n assert candidate(vals = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 24\n assert candidate(vals = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],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]]) == 20\n assert candidate(vals = [1, 2, 2, 3, 3, 3, 4],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 11\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],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], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]) == 20\n assert candidate(vals = [2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10]]) == 28\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],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]]) == 15\n assert candidate(vals = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 15\n assert candidate(vals = [1, 3, 2, 3, 1, 3, 3, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7]]) == 14\n assert candidate(vals = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 15\n assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],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]]) == 120\n assert candidate(vals = [1, 2, 1, 2, 1, 2, 1, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 15\n assert candidate(vals = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == 37\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(vals = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],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]]) == 15\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],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]]) == 20\n assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],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]]) == 19\n assert candidate(vals = [5, 4, 5, 3, 4, 5, 2, 1, 5, 5, 5],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 26\n assert candidate(vals = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],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]]) == 91\n assert candidate(vals = [10, 5, 10, 10, 3, 5, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [3, 5], [4, 6]]) == 13\n assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == 66\n assert candidate(vals = [7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7],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]]) == 43\n assert candidate(vals = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7], [6, 8], [6, 9]]) == 11\n assert candidate(vals = [4, 2, 5, 3, 1, 6, 1, 2, 4, 5],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [0, 5], [5, 6], [5, 7], [7, 8], [7, 9]]) == 10\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],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]]) == 16\n assert candidate(vals = [1, 2, 3, 4, 5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [3, 5], [5, 6], [6, 7], [7, 8]]) == 10\n assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]]) == 45\n assert candidate(vals = [1, 3, 2, 3, 1, 3, 1, 3, 1, 3],edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 23\n assert candidate(vals = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 55\n assert candidate(vals = [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],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]]) == 19\n assert candidate(vals = [4, 2, 3, 4, 3, 4, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 10\n assert candidate(vals = [4, 2, 3, 4, 4, 3, 2, 4],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]]) == 15\n assert candidate(vals = [1, 3, 1, 2, 3, 1, 1, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7]]) == 12\n assert candidate(vals = [3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 28\n assert candidate(vals = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10]]) == 32\n assert candidate(vals = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 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]]) == 23\n assert candidate(vals = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5],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]]) == 33\n assert candidate(vals = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 16\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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]]) == 210\n assert candidate(vals = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 19\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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]]) == 466\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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]]) == 465\n assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 36\n assert candidate(vals = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],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], [8, 16], [9, 17], [10, 18], [11, 19]]) == 210\n assert candidate(vals = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]]) == 55\n assert candidate(vals = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 10\n assert candidate(vals = [5, 3, 5, 3, 3, 5, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 13\n assert candidate(vals = [1, 2, 2, 1, 3, 3, 1, 1, 2, 2],edges = [[0, 1], [0, 3], [1, 2], [3, 4], [3, 7], [4, 5], [5, 6], [7, 8], [8, 9]]) == 20\n assert candidate(vals = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],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]]) == 73\n assert candidate(vals = [5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 36\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(vals = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3],edges = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [3, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 31\n assert candidate(vals = [5, 3, 5, 5, 2, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == 30\n assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8]]) == 45\n assert candidate(vals = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 16\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 9\n assert candidate(vals = [3, 1, 2, 3, 1, 3, 2, 1, 3, 2, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 19\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],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]]) == 210\n assert candidate(vals = [2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1],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]]) == 49\n assert candidate(vals = [3, 1, 2, 3, 3, 2, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 14\n assert candidate(vals = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7], [7, 8], [7, 9], [9, 10], [9, 11], [11, 12], [11, 13], [13, 14], [13, 15], [15, 16], [15, 17], [17, 18], [17, 19], [19, 20]]) == 21\n assert candidate(vals = [5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 45\n assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 210\n assert candidate(vals = [4, 3, 3, 4, 4, 4, 3, 4],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]]) == 19\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 10\n"}, "metadata": {"canonical_parameter_names": ["vals", "edges"], "leetcode_dataset_entry_point": "Solution().numberOfGoodPaths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfGoodPaths(int[] vals, int[][] edges) {", "container": "Solution", "callable": "numberOfGoodPaths", "parameters": [{"name": "vals", "type": "int[]"}, {"name": "edges", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2423, "task_id": "remove-letter-to-equalize-frequency", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string word, consisting of lowercase English letters. You need to select one index and remove the letter at that index from word so that the frequency of every letter present in word is equal.\nReturn true if it is possible to remove one letter so that the frequency of all letters in word are equal, and false otherwise.\nNote:\n\nThe frequency of a letter x is the number of times it occurs in the string.\nYou must remove exactly one letter and cannot choose to do nothing.\n\n \nExample 1:\n\nInput: word = \"abcc\"\nOutput: true\nExplanation: Select index 3 and delete it: word becomes \"abc\" and each character has a frequency of 1.\n\nExample 2:\n\nInput: word = \"aazz\"\nOutput: false\nExplanation: We must delete a character, so either the frequency of \"a\" is 1 and the frequency of \"z\" is 2, or vice versa. It is impossible to make all present letters have equal frequency.\n\n \nConstraints:\n\n2 <= word.length <= 100\nword consists of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aabbccd\") == True\n assert candidate(word = \"aaabbbccc\") == False\n assert candidate(word = \"zazaza\") == False\n assert candidate(word = \"aaaaabbbbbcccc\") == False\n assert candidate(word = \"zzzzzzzz\") == True\n assert candidate(word = \"aabbccddeff\") == True\n assert candidate(word = \"aabbbbcccc\") == False\n assert candidate(word = \"aazz\") == False\n assert candidate(word = \"aabbbccccc\") == False\n assert candidate(word = \"aaa\") == True\n assert candidate(word = \"aabbbccddd\") == False\n assert candidate(word = \"abcdef\") == True\n assert candidate(word = \"aabbcccddd\") == False\n assert candidate(word = \"aabbc\") == True\n assert candidate(word = \"aabbccddeee\") == True\n assert candidate(word = \"abacabad\") == False\n assert candidate(word = \"abcdabcd\") == False\n assert candidate(word = \"aabbbccc\") == False\n assert candidate(word = \"aabbccdde\") == True\n assert candidate(word = \"aabbbcccc\") == False\n assert candidate(word = \"aabbbcccccc\") == False\n assert candidate(word = \"zzzz\") == True\n assert candidate(word = \"abcc\") == True\n assert candidate(word = \"xyyz\") == True\n assert candidate(word = \"aab\") == True\n assert candidate(word = \"aabbcc\") == False\n assert candidate(word = \"abcde\") == True\n assert candidate(word = \"aaabbbb\") == True\n assert candidate(word = \"aabbbb\") == False\n assert candidate(word = \"abcd\") == True\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == False\n assert candidate(word = \"abbbccddde\") == False\n assert candidate(word = \"abcabcabc\") == False\n assert candidate(word = \"qwerty\") == True\n assert candidate(word = \"aabbbcccd\") == False\n assert candidate(word = \"aabbccddd\") == True\n assert candidate(word = \"abc\") == True\n assert candidate(word = \"abcddd\") == False\n assert candidate(word = \"abcdefghijklmnopqrstuvwxzy\") == True\n assert candidate(word = \"aaaabbbb\") == False\n assert candidate(word = \"aabbccc\") == True\n assert candidate(word = \"abcdabcdabcd\") == False\n assert candidate(word = \"abcdefghi\") == True\n assert candidate(word = \"aabbcccd\") == False\n assert candidate(word = \"abcdefghijj\") == True\n assert candidate(word = \"aabbbcccdddde\") == False\n assert candidate(word = \"aabbcccc\") == False\n assert candidate(word = \"aabbccddeeefffg\") == False\n assert candidate(word = \"aabbccddeeeffffgggg\") == False\n assert candidate(word = \"aabbbccccddddeeeeeffffffggggg\") == False\n assert candidate(word = \"aabbccddeeffg\") == True\n assert candidate(word = \"zzzzzzzzzz\") == True\n assert candidate(word = \"aabbbccccdddde\") == False\n assert candidate(word = \"aabbccddeeffgg\") == False\n assert candidate(word = \"abcdefghij\") == True\n assert candidate(word = \"aabbccddeeffgggh\") == False\n assert candidate(word = \"aabbccddeeff\") == False\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word = \"abcabcabcabcabcabcabcabc\") == False\n assert candidate(word = \"zzzzzyyyyy\") == False\n assert candidate(word = \"aaaabbbbccccdddd\") == False\n assert candidate(word = \"aabbbccccdddd\") == False\n assert candidate(word = \"aabbbcccddd\") == False\n assert candidate(word = \"abcdefg\") == True\n assert candidate(word = \"aabbbccccddddeeeeeffffff\") == False\n assert candidate(word = \"abcdefghijjk\") == True\n assert candidate(word = \"aabbbcccde\") == False\n assert candidate(word = \"abbbbcccccdddddeeeeee\") == False\n assert candidate(word = \"aabbccddeeeffff\") == False\n assert candidate(word = \"aabbbccccddddeeeee\") == False\n assert candidate(word = \"aabbccddeeffggghhhh\") == False\n assert candidate(word = \"abcabcabcabc\") == False\n assert candidate(word = \"aabbbcccdddd\") == False\n assert candidate(word = \"aabbcddd\") == False\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().equalFrequency", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean equalFrequency(String word) {", "container": "Solution", "callable": "equalFrequency", "parameters": [{"name": "word", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2425, "task_id": "bitwise-xor-of-all-pairings", "difficulty": "Medium", "problem_description": "You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers. Let there be another array, nums3, which contains the bitwise XOR of all pairings of integers between nums1 and nums2 (every integer in nums1 is paired with every integer in nums2 exactly once).\nReturn the bitwise XOR of all integers in nums3.\n \nExample 1:\n\nInput: nums1 = [2,1,3], nums2 = [10,2,5,0]\nOutput: 13\nExplanation:\nA possible nums3 array is [8,0,7,2,11,3,4,1,9,1,6,3].\nThe bitwise XOR of all these numbers is 13, so we return 13.\n\nExample 2:\n\nInput: nums1 = [1,2], nums2 = [3,4]\nOutput: 0\nExplanation:\nAll possible pairs of bitwise XORs are nums1[0] ^ nums2[0], nums1[0] ^ nums2[1], nums1[1] ^ nums2[0],\nand nums1[1] ^ nums2[1].\nThus, one possible nums3 array is [2,5,1,6].\n2 ^ 5 ^ 1 ^ 6 = 0, so we return 0.\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 105\n0 <= nums1[i], nums2[j] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [8, 16, 24, 32],nums2 = [4, 8, 12, 16, 20]) == 32\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1]) == 11\n assert candidate(nums1 = [2, 1, 3],nums2 = [10, 2, 5, 0]) == 13\n assert candidate(nums1 = [7, 8, 9],nums2 = [10, 11, 12, 13]) == 0\n assert candidate(nums1 = [14, 15, 16],nums2 = [17, 18]) == 3\n assert candidate(nums1 = [5],nums2 = [5]) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 0\n assert candidate(nums1 = [1, 1, 1],nums2 = [1, 1, 1]) == 0\n assert candidate(nums1 = [1, 3, 5, 7],nums2 = [2, 4, 6, 8]) == 0\n assert candidate(nums1 = [1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1000000000],nums2 = [1000000000]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums1 = [9, 8, 7, 6],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [9, 8, 7],nums2 = [6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums1 = [1, 2],nums2 = [3, 4]) == 0\n assert candidate(nums1 = [1],nums2 = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums1 = [1, 2, 3],nums2 = [6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == 0\n assert candidate(nums1 = [5],nums2 = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums1 = [7, 14, 21],nums2 = [3, 6, 9, 12]) == 0\n assert candidate(nums1 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],nums2 = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 0\n assert candidate(nums1 = [13, 29, 37, 41, 53],nums2 = [67, 71, 73, 79, 83, 89, 97, 101]) == 12\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]) == 0\n assert candidate(nums1 = [7, 11, 13, 14],nums2 = [18, 19, 20, 21, 22]) == 15\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums1 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],nums2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 682\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 0\n assert candidate(nums1 = [15, 30, 45, 60, 75],nums2 = [1, 3, 5, 7, 9, 11, 13]) == 68\n assert candidate(nums1 = [255, 127, 63, 31],nums2 = [1, 2, 4, 8, 16, 32]) == 0\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]) == 0\n assert candidate(nums1 = [7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15]) == 12\n assert candidate(nums1 = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195],nums2 = [199, 299, 399, 499, 599, 699]) == 380\n assert candidate(nums1 = [1000000000],nums2 = [1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(nums1 = [7, 8, 9, 10],nums2 = [3, 1, 4, 1, 5, 9]) == 0\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums1 = [1431655765, 1431655765, 1431655765, 1431655765],nums2 = [1431655765]) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [1, 3, 5, 7, 9]) == 1\n assert candidate(nums1 = [100, 200, 300],nums2 = [101, 202, 303, 404]) == 20\n assert candidate(nums1 = [123456789, 987654321, 1122334455],nums2 = [554433221, 987654321, 123456789, 1000000000]) == 655660385\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 0\n assert candidate(nums1 = [1000000000],nums2 = [500000000, 600000000, 700000000, 800000000, 900000000]) == 908472064\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [100, 200, 300],nums2 = [101, 202, 303, 404, 505]) == 109\n assert candidate(nums1 = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90],nums2 = [96, 102, 108, 114, 120, 126]) == 30\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]) == 0\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums1 = [255, 254, 253, 252, 251],nums2 = [127, 63, 31, 15, 7]) == 172\n assert candidate(nums1 = [0, 255, 511, 1023, 2047],nums2 = [1, 128, 256, 512, 1024]) == 641\n assert candidate(nums1 = [1, 1000000000],nums2 = [1, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000001\n assert candidate(nums1 = [7, 15, 21],nums2 = [9, 3, 12, 8]) == 14\n assert candidate(nums1 = [255, 128, 64, 32, 16],nums2 = [1, 2, 4, 8, 16, 32]) == 63\n assert candidate(nums1 = [999999999, 888888888, 777777777],nums2 = [666666666, 555555555, 444444444, 333333333, 222222222]) == 587645496\n assert candidate(nums1 = [123456789, 987654321, 456789123],nums2 = [321654987, 789123456, 654987321, 123456789]) == 477404263\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],nums2 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2046\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 16\n assert candidate(nums1 = [13, 17, 19, 23, 29, 31],nums2 = [37, 41, 43, 47, 53, 59, 61, 67, 71]) == 26\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 0\n assert candidate(nums1 = [1000000000],nums2 = [1000000000, 1000000000]) == 0\n assert candidate(nums1 = [13, 29, 31, 47, 53, 59, 61, 67, 71, 73],nums2 = [79, 83, 89, 97, 101, 103, 107, 109, 113, 127]) == 0\n assert candidate(nums1 = [255, 128, 64, 32, 16, 8, 4, 2, 1],nums2 = [1, 3, 7, 15, 31, 63, 127, 255]) == 170\n assert candidate(nums1 = [255, 511, 765, 1023, 1279],nums2 = [15, 31, 47, 63, 79]) == 1202\n assert candidate(nums1 = [255, 128, 64, 32, 16, 8, 4, 2, 1],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 17\n assert candidate(nums1 = [7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [123456789],nums2 = [987654321, 1122334455, 6677889900]) == 8345112639\n assert candidate(nums1 = [999999999, 888888888, 777777777, 666666666],nums2 = [555555555, 444444444, 333333333, 222222222]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 11\n assert candidate(nums1 = [1000000000, 2000000000, 3000000000],nums2 = [1, 1000000000, 2000000000]) == 3000000001\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [666],nums2 = [666, 666, 666, 666, 666, 666]) == 0\n assert candidate(nums1 = [1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == 0\n assert candidate(nums1 = [1024, 2048, 4096, 8192, 16384],nums2 = [1, 2, 4, 8, 16]) == 31775\n assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [3, 6, 9, 12, 15]) == 12\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [1024, 2048, 4096, 8192, 16384]) == 1023\n assert candidate(nums1 = [123456789, 987654321],nums2 = [1000000007, 1111111111]) == 0\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 0\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [50, 60, 70]) == 16\n assert candidate(nums1 = [255, 128, 64, 32],nums2 = [16, 8, 4, 2, 1]) == 31\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0]) == 0\n assert candidate(nums1 = [111, 222, 333, 444, 555, 666, 777, 888, 999],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 707\n assert candidate(nums1 = [123456789, 987654321, 111111111, 222222222],nums2 = [333333333, 444444444, 555555555]) == 908335597\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6],nums2 = [7, 8, 9, 10, 11, 12, 13]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2]) == 3\n assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000],nums2 = [500000, 600000, 700000]) == 67840\n assert candidate(nums1 = [100, 200, 300],nums2 = [50, 150, 250, 350, 450]) == 322\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10]) == 2\n assert candidate(nums1 = [2147483647, 2147483646, 2147483645],nums2 = [1073741823, 1073741824, 1073741825]) == 1073741826\n assert candidate(nums1 = [13, 23, 33, 43, 53, 63, 73, 83, 93, 103, 113],nums2 = [11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111]) == 42\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [13, 14, 15, 16, 17, 18, 19, 20],nums2 = [21, 22, 23, 24, 25, 26, 27, 28]) == 0\n assert candidate(nums1 = [15, 23, 42, 8, 16],nums2 = [32, 19, 10, 7, 11]) == 31\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10, 12, 14]) == 9\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums1 = [1024, 512, 256, 128],nums2 = [64, 32, 16, 8, 4, 2, 1]) == 1920\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().xorAllNums", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int xorAllNums(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "xorAllNums", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2426, "task_id": "number-of-pairs-satisfying-inequality", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2, each of size n, and an integer diff. Find the number of pairs (i, j) such that:\n\n0 <= i < j <= n - 1 and\nnums1[i] - nums1[j] <= nums2[i] - nums2[j] + diff.\n\nReturn the number of pairs that satisfy the conditions.\n \nExample 1:\n\nInput: nums1 = [3,2,5], nums2 = [2,2,1], diff = 1\nOutput: 3\nExplanation:\nThere are 3 pairs that satisfy the conditions:\n1. i = 0, j = 1: 3 - 2 <= 2 - 2 + 1. Since i < j and 1 <= 1, this pair satisfies the conditions.\n2. i = 0, j = 2: 3 - 5 <= 2 - 1 + 1. Since i < j and -2 <= 2, this pair satisfies the conditions.\n3. i = 1, j = 2: 2 - 5 <= 2 - 1 + 1. Since i < j and -3 <= 2, this pair satisfies the conditions.\nTherefore, we return 3.\n\nExample 2:\n\nInput: nums1 = [3,-1], nums2 = [-2,2], diff = -1\nOutput: 0\nExplanation:\nSince there does not exist any pair that satisfies the conditions, we return 0.\n\n \nConstraints:\n\nn == nums1.length == nums2.length\n2 <= n <= 105\n-104 <= nums1[i], nums2[i] <= 104\n-104 <= diff <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [3, -1],nums2 = [-2, 2],diff = -1) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],diff = 0) == 10\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],diff = 50) == 10\n assert candidate(nums1 = [-10, -20, -30, -40, -50],nums2 = [-1, -2, -3, -4, -5],diff = -10) == 0\n assert candidate(nums1 = [-10, -20, -30],nums2 = [-1, -2, -3],diff = -5) == 0\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0],diff = 10) == 6\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [-5, -4, -3, -2, -1],diff = -10) == 0\n assert candidate(nums1 = [9, 7, 5, 3, 1],nums2 = [10, 8, 6, 4, 2],diff = -1) == 0\n assert candidate(nums1 = [10000, -10000],nums2 = [-10000, 10000],diff = 20000) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],diff = 1) == 10\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],diff = 10) == 10\n assert candidate(nums1 = [10, 20, 30],nums2 = [1, 2, 3],diff = 5) == 3\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],diff = 0) == 10\n assert candidate(nums1 = [3, 2, 5],nums2 = [2, 2, 1],diff = 1) == 3\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0],diff = 10000) == 6\n assert candidate(nums1 = [10000, -10000, 5000, -5000, 0],nums2 = [-10000, 10000, -5000, 5000, 0],diff = 0) == 4\n assert candidate(nums1 = [10000, -5000, 3000, -1000, 2000],nums2 = [5000, -2500, 1500, -500, 1000],diff = 2000) == 6\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],diff = -1) == 45\n assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],nums2 = [-10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000],diff = 20000) == 45\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],diff = 5) == 45\n assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000],nums2 = [1, 2, 3, 4, 5],diff = 10000) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],diff = 0) == 10\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],diff = -100) == 45\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],diff = -1) == 0\n assert candidate(nums1 = [10000, -10000, 5000, -5000, 0],nums2 = [-5000, 5000, -10000, 10000, 0],diff = 15000) == 7\n assert candidate(nums1 = [10000, -10000, 5000, -5000, 2500, -2500],nums2 = [5000, -5000, 10000, -10000, 7500, -7500],diff = 15000) == 15\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [50, 150, 250, 350, 450],diff = 0) == 10\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],diff = 1) == 45\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [0, 0, 0, 0, 0],diff = 0) == 10\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],diff = 10000) == 45\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],diff = 500) == 45\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],diff = 1) == 55\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],nums2 = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],diff = 10) == 190\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],diff = 1000) == 45\n assert candidate(nums1 = [-500, -1000, -1500, -2000, -2500, -3000],nums2 = [500, 1000, 1500, 2000, 2500, 3000],diff = -1000) == 0\n assert candidate(nums1 = [-9999, -8888, -7777, -6666, -5555],nums2 = [-10000, -8889, -7778, -6667, -5556],diff = 1) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 0) == 45\n assert candidate(nums1 = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 10) == 45\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],diff = 100) == 45\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],diff = 20) == 17\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],diff = -1000) == 0\n assert candidate(nums1 = [-10000, 10000, -5000, 5000, 0, -100, 100, -50, 50],nums2 = [-1, 1, -2, 2, 0, -10, 10, -5, 5],diff = 20000) == 36\n assert candidate(nums1 = [5000, 5000, 5000, 5000, 5000],nums2 = [-5000, -5000, -5000, -5000, -5000],diff = 10000) == 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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],diff = 1) == 190\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],diff = -2) == 0\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],diff = 0) == 20\n assert candidate(nums1 = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],diff = 500) == 45\n assert candidate(nums1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 0) == 45\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],diff = 0) == 45\n assert candidate(nums1 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 100) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],diff = 500) == 45\n assert candidate(nums1 = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],nums2 = [-50, -45, -40, -35, -30, -25, -20, -15, -10, -5],diff = -15) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 100) == 45\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],diff = 10) == 45\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55],nums2 = [0, 10, 20, 30, 40, 50],diff = 5) == 15\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],diff = 100) == 45\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],diff = 0) == 0\n assert candidate(nums1 = [0, -10, -20, -30, -40],nums2 = [0, 10, 20, 30, 40],diff = 10) == 0\n assert candidate(nums1 = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],nums2 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],diff = -1000) == 0\n assert candidate(nums1 = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 1) == 30\n assert candidate(nums1 = [100, -50, 25, -25, 75, -100],nums2 = [0, 10, 20, -10, 30, -20],diff = 50) == 7\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 0) == 45\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],diff = 1) == 45\n assert candidate(nums1 = [-5, -10, -15, -20, -25],nums2 = [5, 10, 15, 20, 25],diff = 0) == 0\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],diff = 5) == 45\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],diff = 0) == 45\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [10, 20, 30, 40, 50],diff = 50) == 10\n assert candidate(nums1 = [10000, -10000, 5000, -5000, 0],nums2 = [1, -1, 2, -2, 0],diff = 10001) == 8\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],diff = -4) == 45\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [1, -1, 2, -2, 3],diff = 3) == 8\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],diff = 25) == 45\n assert candidate(nums1 = [10000, -10000, 10000, -10000, 10000],nums2 = [0, 0, 0, 0, 0],diff = 0) == 7\n assert candidate(nums1 = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 0) == 20\n assert candidate(nums1 = [5000, -5000, 3000, -3000, 1000],nums2 = [1, -1, 2, -2, 3],diff = 10000) == 10\n assert candidate(nums1 = [-5000, 5000, -2500, 2500, 0],nums2 = [5000, -5000, 2500, -2500, 0],diff = 0) == 6\n assert candidate(nums1 = [10000, -10000, 10000, -10000, 10000],nums2 = [-10000, 10000, -10000, 10000, -10000],diff = 0) == 7\n assert candidate(nums1 = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],nums2 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],diff = -50) == 0\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],diff = 20000) == 45\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],diff = -2) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [0, 2, 4, 6, 8, 10, 12, 14],diff = 0) == 28\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3, 4, -4],nums2 = [0, 0, 0, 0, 0, 0, 0, 0],diff = 0) == 12\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 999) == 45\n assert candidate(nums1 = [5000, 4000, 3000, 2000, 1000, 0, -1000, -2000, -3000, -4000, -5000],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 2000) == 19\n assert candidate(nums1 = [1, -1, 1, -1, 1],nums2 = [-1, 1, -1, 1, -1],diff = 2) == 7\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 1, 1, 1, 1],diff = 99) == 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],diff = 10) == 35\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],diff = 0) == 35\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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],diff = 0) == 190\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],diff = -1) == 0\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],diff = 1) == 45\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],diff = 0) == 45\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],diff = 1) == 45\n assert candidate(nums1 = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000],nums2 = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000],diff = 0) == 35\n assert candidate(nums1 = [5, 3, 8, 6, 2],nums2 = [1, 4, 3, 2, 5],diff = 1) == 5\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],diff = -5) == 0\n assert candidate(nums1 = [-10000, -9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = -10) == 0\n assert candidate(nums1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],diff = -5) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],diff = 10) == 105\n assert candidate(nums1 = [10000, -10000, 5000, -5000, 0],nums2 = [0, 0, 0, 0, 0],diff = 20000) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "diff"], "leetcode_dataset_entry_point": "Solution().numberOfPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long numberOfPairs(int[] nums1, int[] nums2, int diff) {", "container": "Solution", "callable": "numberOfPairs", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}, {"name": "diff", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2427, "task_id": "number-of-common-factors", "difficulty": "Easy", "problem_description": "Given two positive integers a and b, return the number of common factors of a and b.\nAn integer x is a common factor of a and b if x divides both a and b.\n \nExample 1:\n\nInput: a = 12, b = 6\nOutput: 4\nExplanation: The common factors of 12 and 6 are 1, 2, 3, 6.\n\nExample 2:\n\nInput: a = 25, b = 30\nOutput: 2\nExplanation: The common factors of 25 and 30 are 1, 5.\n\n \nConstraints:\n\n1 <= a, b <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 7,b = 13) == 1\n assert candidate(a = 500,b = 500) == 12\n assert candidate(a = 42,b = 56) == 4\n assert candidate(a = 999,b = 1000) == 1\n assert candidate(a = 77,b = 14) == 2\n assert candidate(a = 98,b = 42) == 4\n assert candidate(a = 77,b = 143) == 2\n assert candidate(a = 12,b = 6) == 4\n assert candidate(a = 500,b = 250) == 8\n assert candidate(a = 25,b = 30) == 2\n assert candidate(a = 500,b = 200) == 9\n assert candidate(a = 100,b = 10) == 4\n assert candidate(a = 1,b = 1) == 1\n assert candidate(a = 60,b = 120) == 12\n assert candidate(a = 7,b = 14) == 2\n assert candidate(a = 49,b = 7) == 2\n assert candidate(a = 1000,b = 1000) == 16\n assert candidate(a = 81,b = 27) == 4\n assert candidate(a = 999,b = 333) == 6\n assert candidate(a = 2,b = 3) == 1\n assert candidate(a = 987,b = 651) == 4\n assert candidate(a = 315,b = 105) == 8\n assert candidate(a = 600,b = 400) == 12\n assert candidate(a = 675,b = 900) == 9\n assert candidate(a = 675,b = 375) == 6\n assert candidate(a = 777,b = 111) == 4\n assert candidate(a = 789,b = 321) == 2\n assert candidate(a = 456,b = 123) == 2\n assert candidate(a = 360,b = 180) == 18\n assert candidate(a = 221,b = 143) == 2\n assert candidate(a = 504,b = 1008) == 24\n assert candidate(a = 840,b = 420) == 24\n assert candidate(a = 495,b = 135) == 6\n assert candidate(a = 999,b = 111) == 4\n assert candidate(a = 999,b = 891) == 4\n assert candidate(a = 543,b = 234) == 2\n assert candidate(a = 960,b = 720) == 20\n assert candidate(a = 777,b = 222) == 4\n assert candidate(a = 500,b = 1000) == 12\n assert candidate(a = 987,b = 654) == 2\n assert candidate(a = 450,b = 150) == 12\n assert candidate(a = 560,b = 315) == 4\n assert candidate(a = 420,b = 560) == 12\n assert candidate(a = 840,b = 1008) == 16\n assert candidate(a = 432,b = 504) == 12\n assert candidate(a = 100,b = 150) == 6\n assert candidate(a = 420,b = 168) == 12\n assert candidate(a = 729,b = 243) == 6\n assert candidate(a = 400,b = 500) == 9\n assert candidate(a = 504,b = 252) == 18\n assert candidate(a = 500,b = 100) == 9\n assert candidate(a = 495,b = 363) == 4\n assert candidate(a = 84,b = 105) == 4\n assert candidate(a = 315,b = 135) == 6\n assert candidate(a = 729,b = 2187) == 7\n assert candidate(a = 48,b = 180) == 6\n assert candidate(a = 333,b = 111) == 4\n assert candidate(a = 121,b = 220) == 2\n assert candidate(a = 1024,b = 512) == 10\n assert candidate(a = 560,b = 240) == 10\n assert candidate(a = 143,b = 169) == 2\n assert candidate(a = 440,b = 88) == 8\n assert candidate(a = 441,b = 147) == 6\n assert candidate(a = 675,b = 225) == 9\n assert candidate(a = 560,b = 840) == 16\n assert candidate(a = 729,b = 81) == 5\n assert candidate(a = 500,b = 400) == 9\n assert candidate(a = 210,b = 140) == 8\n assert candidate(a = 576,b = 288) == 18\n assert candidate(a = 777,b = 555) == 4\n assert candidate(a = 220,b = 88) == 6\n assert candidate(a = 720,b = 540) == 18\n assert candidate(a = 882,b = 147) == 6\n assert candidate(a = 210,b = 420) == 16\n assert candidate(a = 987,b = 329) == 4\n assert candidate(a = 1024,b = 256) == 9\n assert candidate(a = 675,b = 1025) == 3\n assert candidate(a = 882,b = 630) == 12\n assert candidate(a = 840,b = 1050) == 16\n assert candidate(a = 890,b = 345) == 2\n assert candidate(a = 462,b = 231) == 8\n assert candidate(a = 84,b = 28) == 6\n assert candidate(a = 450,b = 180) == 12\n assert candidate(a = 504,b = 168) == 16\n assert candidate(a = 100,b = 200) == 9\n assert candidate(a = 400,b = 160) == 10\n assert candidate(a = 1000,b = 750) == 8\n assert candidate(a = 840,b = 700) == 12\n assert candidate(a = 456,b = 342) == 8\n assert candidate(a = 650,b = 260) == 8\n assert candidate(a = 101,b = 103) == 1\n assert candidate(a = 128,b = 256) == 8\n assert candidate(a = 1234,b = 456) == 2\n assert candidate(a = 987,b = 323) == 1\n assert candidate(a = 729,b = 486) == 6\n assert candidate(a = 987,b = 567) == 4\n assert candidate(a = 600,b = 750) == 12\n assert candidate(a = 987,b = 399) == 4\n assert candidate(a = 360,b = 720) == 24\n assert candidate(a = 882,b = 98) == 6\n assert candidate(a = 612,b = 468) == 9\n assert candidate(a = 360,b = 240) == 16\n assert candidate(a = 900,b = 450) == 18\n assert candidate(a = 960,b = 480) == 24\n assert candidate(a = 504,b = 756) == 18\n assert candidate(a = 1000,b = 900) == 9\n assert candidate(a = 678,b = 456) == 4\n"}, "metadata": {"canonical_parameter_names": ["a", "b"], "leetcode_dataset_entry_point": "Solution().commonFactors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int commonFactors(int a, int b) {", "container": "Solution", "callable": "commonFactors", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2428, "task_id": "maximum-sum-of-an-hourglass", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix grid.\nWe define an hourglass as a part of the matrix with the following form:\n\nReturn the maximum sum of the elements of an hourglass.\nNote that an hourglass cannot be rotated and must be entirely contained within the matrix.\n \nExample 1:\n\n\nInput: grid = [[6,2,1,3],[4,2,1,5],[9,2,8,7],[4,1,2,9]]\nOutput: 30\nExplanation: The cells shown above represent the hourglass with the maximum sum: 6 + 2 + 1 + 2 + 9 + 2 + 8 = 30.\n\nExample 2:\n\n\nInput: grid = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: 35\nExplanation: There is only one hourglass in the matrix, with the sum: 1 + 2 + 3 + 5 + 7 + 8 + 9 = 35.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n3 <= m, n <= 150\n0 <= grid[i][j] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\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]]) == 133\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 1\n assert candidate(grid = [[1000000, 1000000, 1000000], [1000000, 1000000, 1000000], [1000000, 1000000, 1000000]]) == 7000000\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]]) == 7\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 7\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 35\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[6, 2, 1, 3], [4, 2, 1, 5], [9, 2, 8, 7], [4, 1, 2, 9]]) == 30\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, 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]]) == 3\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]]) == 5\n assert candidate(grid = [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200], [1300, 1400, 1500]]) == 7700\n assert candidate(grid = [[9, 8, 7, 6, 5, 4], [3, 2, 1, 0, 1, 2], [4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7]]) == 47\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 4, 3, 1], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == 20\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]]) == 203\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]]) == 35\n assert candidate(grid = [[1000000, 0, 1000000, 0, 1000000], [0, 0, 0, 0, 0], [1000000, 0, 1000000, 0, 1000000], [0, 0, 0, 0, 0], [1000000, 0, 1000000, 0, 1000000]]) == 4000000\n assert candidate(grid = [[1000000, 999999, 999998, 999997, 999996], [999995, 999994, 999993, 999992, 999991], [999990, 999989, 999988, 999987, 999986], [999985, 999984, 999983, 999982, 999981], [999980, 999979, 999978, 999977, 999976]]) == 6999958\n assert candidate(grid = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == 0\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]]) == 35\n assert candidate(grid = [[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]]) == 63\n assert candidate(grid = [[999999, 999998, 999997], [999996, 999995, 999994], [999993, 999992, 999991], [999990, 999989, 999988], [999987, 999986, 999985], [999984, 999983, 999982]]) == 6999965\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, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [1, 5, 9, 13, 17, 13, 9, 5, 1], [2, 6, 10, 14, 18, 14, 10, 6, 2]]) == 89\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]]) == 203\n assert candidate(grid = [[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, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 63\n assert candidate(grid = [[9, 8, 7, 6], [6, 5, 4, 3], [3, 2, 1, 0], [0, 1, 2, 3]]) == 35\n assert candidate(grid = [[1, 0, 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]]) == 280\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]]) == 5\n assert candidate(grid = [[0, 1, 0, 2, 0, 3, 0, 4, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 2, 0, 3, 0, 4, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 2, 0, 3, 0, 4, 0]]) == 15\n assert candidate(grid = [[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]]) == 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], [26, 27, 28, 29, 30]]) == 168\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]]) == 119\n assert candidate(grid = [[1, 5, 1, 3, 7], [4, 3, 2, 6, 8], [9, 5, 6, 1, 2], [7, 8, 9, 4, 5], [3, 4, 2, 7, 1]]) == 38\n assert candidate(grid = [[1, 3, 1, 1, 1, 3, 1], [1, 9, 1, 1, 1, 9, 1], [1, 3, 1, 1, 1, 3, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 3, 1, 1, 1, 3, 1]]) == 19\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], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 7\n assert candidate(grid = [[1, 5, 0, 2, 1], [6, 9, 2, 4, 3], [5, 6, 8, 1, 1], [2, 3, 4, 7, 9], [1, 2, 3, 4, 5]]) == 37\n assert candidate(grid = [[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]]) == 105\n assert candidate(grid = [[1000000, 1000000, 1000000, 1000000, 1000000], [1000000, 0, 0, 0, 1000000], [1000000, 0, 1000000, 0, 1000000], [1000000, 0, 0, 0, 1000000], [1000000, 1000000, 1000000, 1000000, 1000000]]) == 5000000\n assert candidate(grid = [[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, 9, 9, 9, 9, 9, 9]]) == 63\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]]) == 35\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 150], [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, 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]]) == 938\n assert candidate(grid = [[1, 0, 0, 1, 1], [0, 1, 1, 0, 0], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 1]]) == 4\n assert candidate(grid = [[1000000, 999999, 999998, 999997, 999996], [999995, 999994, 999993, 999992, 999991], [999990, 999989, 999988, 999987, 999986], [999985, 999984, 999983, 999982, 999981], [999980, 999979, 999978, 999977, 999976]]) == 6999958\n assert candidate(grid = [[100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000]]) == 700000\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]]) == 217\n assert candidate(grid = [[5, 1, 3, 9, 4], [2, 6, 7, 3, 8], [1, 5, 4, 7, 2], [6, 8, 2, 9, 5], [3, 7, 5, 1, 4]]) == 41\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, 51, 52, 53, 54], [55, 56, 57, 58, 59, 60, 61, 62, 63]]) == 371\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [5, 4, 3, 2, 1], [0, 1, 2, 3, 4], [9, 8, 7, 6, 5]]) == 39\n assert candidate(grid = [[9, 1, 8, 5, 6], [4, 7, 3, 2, 9], [10, 5, 1, 8, 2], [6, 3, 2, 7, 4], [5, 8, 9, 2, 1]]) == 41\n assert candidate(grid = [[5, 8, 4, 6], [9, 2, 3, 4], [1, 6, 7, 8], [4, 5, 6, 7], [8, 9, 0, 1], [2, 3, 4, 5]]) == 42\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, 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]]) == 413\n assert candidate(grid = [[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]]) == 294\n assert candidate(grid = [[1, 0, 7, 0, 8, 4], [4, 9, 3, 2, 5, 10], [0, 2, 8, 5, 3, 9], [3, 1, 6, 7, 4, 8], [8, 5, 2, 9, 0, 3], [1, 4, 7, 6, 9, 5]]) == 48\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]]) == 7\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160], [170, 180, 190, 200]]) == 1050\n assert candidate(grid = [[1000000, 1000000, 1000000], [1000000, 1000000, 1000000], [1000000, 1000000, 1000000], [1000000, 1000000, 1000000], [1000000, 1000000, 1000000]]) == 7000000\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [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, 0]]) == 49\n assert candidate(grid = [[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]]) == 1680\n assert candidate(grid = [[9, 1, 2, 3, 4], [8, 7, 6, 5, 4], [3, 5, 7, 9, 1], [2, 4, 6, 8, 0], [5, 5, 5, 5, 5]]) == 43\n assert candidate(grid = [[-9, -8, -7], [-6, -5, -4], [-3, -2, -1]]) == 0\n assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == 700000\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, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 7\n assert candidate(grid = [[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], [6, 7, 8, 9, 10, 11, 12], [7, 8, 9, 10, 11, 12, 13]]) == 77\n assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [0, 10, 20, 30, 40], [9, 19, 29, 39, 49]]) == 248\n assert candidate(grid = [[1000000, 500000, 300000, 200000], [100000, 50000, 30000, 20000], [10000, 5000, 3000, 2000], [1000, 500, 300, 200]]) == 1868000\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxSum(int[][] grid) {", "container": "Solution", "callable": "maxSum", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2429, "task_id": "minimize-xor", "difficulty": "Medium", "problem_description": "Given two positive integers num1 and num2, find the positive integer x such that:\n\nx has the same number of set bits as num2, and\nThe value x XOR num1 is minimal.\n\nNote that XOR is the bitwise XOR operation.\nReturn the integer x. The test cases are generated such that x is uniquely determined.\nThe number of set bits of an integer is the number of 1's in its binary representation.\n \nExample 1:\n\nInput: num1 = 3, num2 = 5\nOutput: 3\nExplanation:\nThe binary representations of num1 and num2 are 0011 and 0101, respectively.\nThe integer 3 has the same number of set bits as num2, and the value 3 XOR 3 = 0 is minimal.\n\nExample 2:\n\nInput: num1 = 1, num2 = 12\nOutput: 3\nExplanation:\nThe binary representations of num1 and num2 are 0001 and 1100, respectively.\nThe integer 3 has the same number of set bits as num2, and the value 3 XOR 1 = 2 is minimal.\n\n \nConstraints:\n\n1 <= num1, num2 <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num1 = 1,num2 = 12) == 3\n assert candidate(num1 = 8,num2 = 3) == 9\n assert candidate(num1 = 29,num2 = 15) == 29\n assert candidate(num1 = 3,num2 = 5) == 3\n assert candidate(num1 = 7,num2 = 10) == 6\n assert candidate(num1 = 1000000000,num2 = 1) == 536870912\n assert candidate(num1 = 1,num2 = 2000000000) == 8191\n assert candidate(num1 = 987654321,num2 = 1000000000) == 987654144\n assert candidate(num1 = 8,num2 = 31) == 31\n assert candidate(num1 = 2147483647,num2 = 2147483647) == 2147483647\n assert candidate(num1 = 134217728,num2 = 671088640) == 134217729\n assert candidate(num1 = 1023,num2 = 511) == 1022\n assert candidate(num1 = 8388607,num2 = 16777215) == 16777215\n assert candidate(num1 = 123456789,num2 = 31) == 122683392\n assert candidate(num1 = 1,num2 = 1023) == 1023\n assert candidate(num1 = 32768,num2 = 65535) == 65535\n assert candidate(num1 = 1234567890,num2 = 9876543210) == 1234567903\n assert candidate(num1 = 2147483647,num2 = 1) == 1073741824\n assert candidate(num1 = 1023,num2 = 1) == 512\n assert candidate(num1 = 123456789,num2 = 987654321) == 123456791\n assert candidate(num1 = 2147483647,num2 = 1073741823) == 2147483646\n assert candidate(num1 = 1000000000,num2 = 100000000) == 999999488\n assert candidate(num1 = 123,num2 = 987654321) == 131071\n assert candidate(num1 = 500000000,num2 = 750000000) == 499999744\n assert candidate(num1 = 1073741823,num2 = 1) == 536870912\n assert candidate(num1 = 1073741824,num2 = 4294967295) == 2147483647\n assert candidate(num1 = 134217728,num2 = 32767) == 134234111\n assert candidate(num1 = 858993459,num2 = 12) == 805306368\n assert candidate(num1 = 4294967295,num2 = 2) == 1073741824\n assert candidate(num1 = 123456,num2 = 32) == 65536\n assert candidate(num1 = 512,num2 = 256) == 512\n assert candidate(num1 = 894567321,num2 = 987654321) == 894567423\n assert candidate(num1 = 1,num2 = 1073741823) == 1073741823\n assert candidate(num1 = 65535,num2 = 8) == 32768\n assert candidate(num1 = 536870911,num2 = 2147483647) == 1073741823\n assert candidate(num1 = 111111111,num2 = 222222222) == 111111111\n assert candidate(num1 = 1,num2 = 2147483647) == 1073741823\n assert candidate(num1 = 512,num2 = 255) == 639\n assert candidate(num1 = 834567,num2 = 987654) == 834564\n assert candidate(num1 = 999999999,num2 = 1) == 536870912\n assert candidate(num1 = 134217728,num2 = 1073741824) == 134217728\n assert candidate(num1 = 1073741823,num2 = 536870912) == 536870912\n assert candidate(num1 = 54321,num2 = 98765) == 54323\n assert candidate(num1 = 987654321,num2 = 16) == 536870912\n assert candidate(num1 = 1023,num2 = 10) == 768\n assert candidate(num1 = 987654,num2 = 24) == 786432\n assert candidate(num1 = 777777777,num2 = 333333333) == 777777760\n assert candidate(num1 = 1048575,num2 = 1048575) == 1048575\n assert candidate(num1 = 987654321,num2 = 123456789) == 987654320\n assert candidate(num1 = 131071,num2 = 65535) == 131070\n assert candidate(num1 = 999999999,num2 = 1000000000) == 999999744\n assert candidate(num1 = 1073741824,num2 = 536870912) == 1073741824\n assert candidate(num1 = 4294967295,num2 = 15) == 2013265920\n assert candidate(num1 = 1073741824,num2 = 2147483647) == 2147483647\n assert candidate(num1 = 16777215,num2 = 8388607) == 16777214\n assert candidate(num1 = 8192,num2 = 16384) == 8192\n assert candidate(num1 = 1023,num2 = 2047) == 2047\n assert candidate(num1 = 987654321,num2 = 135792468) == 987496448\n assert candidate(num1 = 134217728,num2 = 25) == 134217731\n assert candidate(num1 = 1000000000,num2 = 1000000000) == 1000000000\n assert candidate(num1 = 16,num2 = 3) == 17\n assert candidate(num1 = 2147483646,num2 = 2147483646) == 2147483646\n assert candidate(num1 = 2147483647,num2 = 1073741824) == 1073741824\n assert candidate(num1 = 1048575,num2 = 524288) == 524288\n assert candidate(num1 = 134217728,num2 = 67108864) == 134217728\n assert candidate(num1 = 888888888,num2 = 888888888) == 888888888\n assert candidate(num1 = 1000000007,num2 = 20) == 805306368\n assert candidate(num1 = 1000000000,num2 = 500000000) == 1000000000\n assert candidate(num1 = 4294967295,num2 = 2147483647) == 2147483647\n assert candidate(num1 = 8388607,num2 = 2147483647) == 1073741823\n assert candidate(num1 = 1023456789,num2 = 987654321) == 1023456895\n assert candidate(num1 = 67890,num2 = 13579) == 67891\n assert candidate(num1 = 999999999,num2 = 888888888) == 999999992\n assert candidate(num1 = 2147483647,num2 = 4294967294) == 2147483647\n assert candidate(num1 = 1,num2 = 1048575) == 1048575\n assert candidate(num1 = 123456789,num2 = 123456789) == 123456789\n assert candidate(num1 = 8388607,num2 = 4194304) == 4194304\n assert candidate(num1 = 8388607,num2 = 1048575) == 8388600\n assert candidate(num1 = 536870911,num2 = 268435456) == 268435456\n assert candidate(num1 = 135792468,num2 = 246813579) == 135794687\n assert candidate(num1 = 65535,num2 = 65535) == 65535\n assert candidate(num1 = 500000000,num2 = 800000000) == 499999744\n assert candidate(num1 = 4294967295,num2 = 1073741824) == 1073741824\n assert candidate(num1 = 1024,num2 = 1023) == 1535\n assert candidate(num1 = 1000000007,num2 = 1000000008) == 1000000004\n"}, "metadata": {"canonical_parameter_names": ["num1", "num2"], "leetcode_dataset_entry_point": "Solution().minimizeXor", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimizeXor(int num1, int num2) {", "container": "Solution", "callable": "minimizeXor", "parameters": [{"name": "num1", "type": "int"}, {"name": "num2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2430, "task_id": "maximum-deletions-on-a-string", "difficulty": "Hard", "problem_description": "You are given a string s consisting of only lowercase English letters. In one operation, you can:\n\nDelete the entire string s, or\nDelete the first i letters of s if the first i letters of s are equal to the following i letters in s, for any i in the range 1 <= i <= s.length / 2.\n\nFor example, if s = \"ababc\", then in one operation, you could delete the first two letters of s to get \"abc\", since the first two letters of s and the following two letters of s are both equal to \"ab\".\nReturn the maximum number of operations needed to delete all of s.\n \nExample 1:\n\nInput: s = \"abcabcdabc\"\nOutput: 2\nExplanation:\n- Delete the first 3 letters (\"abc\") since the next 3 letters are equal. Now, s = \"abcdabc\".\n- Delete all the letters.\nWe used 2 operations so return 2. It can be proven that 2 is the maximum number of operations needed.\nNote that in the second operation we cannot delete \"abc\" again because the next occurrence of \"abc\" does not happen in the next 3 letters.\n\nExample 2:\n\nInput: s = \"aaabaab\"\nOutput: 4\nExplanation:\n- Delete the first letter (\"a\") since the next letter is equal. Now, s = \"aabaab\".\n- Delete the first 3 letters (\"aab\") since the next 3 letters are equal. Now, s = \"aab\".\n- Delete the first letter (\"a\") since the next letter is equal. Now, s = \"ab\".\n- Delete all the letters.\nWe used 4 operations so return 4. It can be proven that 4 is the maximum number of operations needed.\n\nExample 3:\n\nInput: s = \"aaaaa\"\nOutput: 5\nExplanation: In each operation, we can delete the first letter of s.\n\n \nConstraints:\n\n1 <= s.length <= 4000\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababab\") == 48\n assert candidate(s = \"aaabaab\") == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 90\n assert candidate(s = \"abacabadabacaba\") == 1\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 29\n assert candidate(s = \"abcabcabcabc\") == 4\n assert candidate(s = \"abcdabcdabcd\") == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvsuwxyzabcdefghijklmnopqrstuvsuwxyz\") == 2\n assert candidate(s = \"abcabcdabc\") == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 102\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 66\n assert candidate(s = \"abcdef\") == 1\n assert candidate(s = \"abababab\") == 4\n assert candidate(s = \"abcd\") == 1\n assert candidate(s = \"aaaaa\") == 5\n assert candidate(s = \"aabbccddeeff\") == 2\n assert candidate(s = \"abacabadabacabadabacaba\") == 2\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 32\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 26\n assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeff\") == 4\n assert candidate(s = \"abcababcababcababcababcababcababcababcababcababcababcab\") == 11\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 13\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 26\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdef\") == 5\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefgh\") == 4\n assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff\") == 9\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 19\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 10\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 24\n assert candidate(s = \"abababababababababababababababababababababababababababababababab\") == 32\n assert candidate(s = \"abababababababcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 20\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 27\n assert candidate(s = \"ababccababccababccababccababcc\") == 6\n assert candidate(s = \"aaaaabbbbbccccdddd\") == 5\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 28\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcab\") == 9\n assert candidate(s = \"abcdabcabcdabcabcd\") == 2\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 106\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 20\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababababab\") == 37\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 18\n assert candidate(s = \"abababababababababababababababababababc\") == 19\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabac\") == 20\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\") == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzwwxxyyzzwwxxyyzz\") == 2\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 12\n assert candidate(s = \"aaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaab\") == 20\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 10\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabb\") == 9\n assert candidate(s = \"abcdabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 94\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 10\n assert candidate(s = \"abracadabraabracadabraabracadabra\") == 3\n assert candidate(s = \"aaabaaaabaaaaabaaaaaaaabaaaaaaaaabaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaab\") == 11\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 24\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 110\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 21\n assert candidate(s = \"abababababababababababababababababababababab\") == 22\n assert candidate(s = \"ababababababababababababababababababababababababababababababababab\") == 33\n assert candidate(s = \"ababccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 2\n assert candidate(s = \"aabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == 7\n assert candidate(s = \"ababababababababababababababababa\") == 16\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 25\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 14\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 11\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 18\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 9\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 16\n assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff\") == 8\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 27\n assert candidate(s = \"abacabadabcaba\") == 1\n assert candidate(s = \"banana\") == 1\n assert candidate(s = \"abacabacabacabacabacabacabacabac\") == 8\n assert candidate(s = \"aaabbbcccdddcccbbbcccaaa\") == 3\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 30\n assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff\") == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 21\n assert candidate(s = \"abcdabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 1\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 8\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 22\n assert candidate(s = \"ababcabcabcabcabcabc\") == 7\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 16\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\") == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcd\") == 10\n assert candidate(s = \"abacabadabacabadabacabad\") == 3\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababab\") == 46\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababab\") == 40\n assert candidate(s = \"ababccababccababccababccababccababccababccababccababccababccababccababccababccababccababcc\") == 16\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 29\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdabcdabcdabcdabcd\") == 2\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababcabcabc\") == 37\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzwwxxyyzz\") == 2\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabac\") == 21\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == 11\n assert candidate(s = \"ababccababccababccababccababccababccababccababccababccababccababccababccababcc\") == 14\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabacabadabacabadabacabadabacabad\") == 2\n assert candidate(s = \"abacabacabacabacabacabacabacabacabac\") == 9\n assert candidate(s = \"mississippi\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabacabadabacabadabacabadabacabadabacabadabacabad\") == 2\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababababababababab\") == 41\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().deleteString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int deleteString(String s) {", "container": "Solution", "callable": "deleteString", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2432, "task_id": "the-employee-that-worked-on-the-longest-task", "difficulty": "Easy", "problem_description": "There are n employees, each with a unique id from 0 to n - 1.\nYou are given a 2D integer array logs where logs[i] = [idi, leaveTimei] where:\n\nidi is the id of the employee that worked on the ith task, and\nleaveTimei is the time at which the employee finished the ith task. All the values leaveTimei are unique.\n\nNote that the ith task starts the moment right after the (i - 1)th task ends, and the 0th task starts at time 0.\nReturn the id of the employee that worked the task with the longest time. If there is a tie between two or more employees, return the smallest id among them.\n \nExample 1:\n\nInput: n = 10, logs = [[0,3],[2,5],[0,9],[1,15]]\nOutput: 1\nExplanation: \nTask 0 started at 0 and ended at 3 with 3 units of times.\nTask 1 started at 3 and ended at 5 with 2 units of times.\nTask 2 started at 5 and ended at 9 with 4 units of times.\nTask 3 started at 9 and ended at 15 with 6 units of times.\nThe task with the longest time is task 3 and the employee with id 1 is the one that worked on it, so we return 1.\n\nExample 2:\n\nInput: n = 26, logs = [[1,1],[3,7],[2,12],[7,17]]\nOutput: 3\nExplanation: \nTask 0 started at 0 and ended at 1 with 1 unit of times.\nTask 1 started at 1 and ended at 7 with 6 units of times.\nTask 2 started at 7 and ended at 12 with 5 units of times.\nTask 3 started at 12 and ended at 17 with 5 units of times.\nThe tasks with the longest time is task 1. The employee that worked on it is 3, so we return 3.\n\nExample 3:\n\nInput: n = 2, logs = [[0,10],[1,20]]\nOutput: 0\nExplanation: \nTask 0 started at 0 and ended at 10 with 10 units of times.\nTask 1 started at 10 and ended at 20 with 10 units of times.\nThe tasks with the longest time are tasks 0 and 1. The employees that worked on them are 0 and 1, so we return the smallest id 0.\n\n \nConstraints:\n\n2 <= n <= 500\n1 <= logs.length <= 500\nlogs[i].length == 2\n0 <= idi <= n - 1\n1 <= leaveTimei <= 500\nidi != idi+1\nleaveTimei are sorted in a strictly increasing order.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,logs = [[0, 1], [2, 2], [1, 3], [3, 4]]) == 0\n assert candidate(n = 2,logs = [[0, 10], [1, 20]]) == 0\n assert candidate(n = 6,logs = [[0, 2], [1, 6], [2, 10], [3, 14], [4, 18], [5, 22]]) == 1\n assert candidate(n = 5,logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(n = 26,logs = [[1, 1], [3, 7], [2, 12], [7, 17]]) == 3\n assert candidate(n = 4,logs = [[0, 5], [1, 10], [2, 15], [3, 20]]) == 0\n assert candidate(n = 3,logs = [[0, 10], [1, 20], [2, 30]]) == 0\n assert candidate(n = 4,logs = [[3, 10], [1, 15], [2, 20], [0, 25]]) == 3\n assert candidate(n = 3,logs = [[0, 5], [1, 10], [2, 15]]) == 0\n assert candidate(n = 10,logs = [[0, 3], [2, 5], [0, 9], [1, 15]]) == 1\n assert candidate(n = 5,logs = [[0, 2], [1, 5], [0, 9]]) == 0\n assert candidate(n = 5,logs = [[0, 2], [1, 5], [0, 9], [1, 15]]) == 1\n assert candidate(n = 4,logs = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 0\n assert candidate(n = 5,logs = [[0, 2], [1, 4], [2, 6], [3, 8], [4, 10]]) == 0\n assert candidate(n = 10,logs = [[0, 5], [1, 12], [2, 18], [3, 25], [4, 32], [5, 40], [6, 48], [7, 55], [8, 60], [9, 65]]) == 5\n assert candidate(n = 8,logs = [[6, 2], [4, 5], [3, 9], [5, 14], [1, 18], [7, 23], [2, 29], [0, 34]]) == 2\n assert candidate(n = 6,logs = [[0, 10], [1, 20], [0, 30], [1, 40], [0, 50], [1, 60]]) == 0\n assert candidate(n = 20,logs = [[0, 10], [2, 20], [4, 30], [6, 40], [8, 50], [10, 60], [12, 70], [14, 80], [16, 90], [18, 100]]) == 0\n assert candidate(n = 8,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80]]) == 0\n assert candidate(n = 10,logs = [[0, 5], [3, 12], [2, 18], [1, 22], [0, 30]]) == 0\n assert candidate(n = 12,logs = [[0, 100], [1, 150], [2, 200], [3, 250], [4, 300], [5, 350], [6, 400], [7, 450], [8, 500], [9, 550], [10, 600], [11, 650]]) == 0\n assert candidate(n = 10,logs = [[0, 1], [2, 4], [4, 7], [6, 10], [8, 13], [1, 16], [3, 19], [5, 22], [7, 25], [9, 28]]) == 1\n assert candidate(n = 7,logs = [[0, 5], [1, 10], [2, 15], [0, 20], [1, 25], [2, 30], [0, 35]]) == 0\n assert candidate(n = 20,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [10, 55], [11, 60], [12, 65], [13, 70], [14, 75], [15, 80], [16, 85], [17, 90], [18, 95], [19, 100]]) == 0\n assert candidate(n = 30,logs = [[0, 2], [1, 5], [2, 9], [3, 14], [4, 20], [5, 27], [6, 35], [7, 44], [8, 54], [9, 65], [10, 77], [11, 90], [12, 104], [13, 119], [14, 135], [15, 152], [16, 170], [17, 189], [18, 209], [19, 230], [20, 252], [21, 275], [22, 300], [23, 326], [24, 353], [25, 381], [26, 410], [27, 440], [28, 471], [29, 500]]) == 28\n assert candidate(n = 3,logs = [[0, 10], [1, 20], [2, 20]]) == 0\n assert candidate(n = 5,logs = [[0, 5], [1, 10], [2, 10], [3, 15], [4, 20]]) == 0\n assert candidate(n = 11,logs = [[10, 10], [9, 20], [8, 30], [7, 40], [6, 50], [5, 60], [4, 70], [3, 80], [2, 90], [1, 100], [0, 110]]) == 0\n assert candidate(n = 10,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [0, 110], [1, 120]]) == 0\n assert candidate(n = 7,logs = [[0, 10], [1, 10], [2, 10], [3, 20], [4, 20], [5, 20], [6, 30]]) == 0\n assert candidate(n = 6,logs = [[0, 15], [1, 28], [2, 42], [3, 57], [4, 72], [5, 88]]) == 5\n assert candidate(n = 10,logs = [[0, 1], [1, 3], [2, 6], [3, 10], [4, 15], [5, 21], [6, 28], [7, 36], [8, 45], [9, 55]]) == 9\n assert candidate(n = 20,logs = [[19, 1], [18, 3], [17, 6], [16, 10], [15, 15], [14, 21], [13, 28], [12, 36], [11, 45], [10, 55], [9, 66], [8, 78], [7, 91], [6, 105], [5, 120], [4, 136], [3, 153], [2, 171], [1, 190], [0, 210]]) == 0\n assert candidate(n = 25,logs = [[0, 1], [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]]) == 1\n assert candidate(n = 9,logs = [[0, 2], [1, 5], [2, 10], [3, 17], [4, 26], [5, 37], [6, 50], [7, 65], [8, 82]]) == 8\n assert candidate(n = 10,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100]]) == 0\n assert candidate(n = 9,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90]]) == 0\n assert candidate(n = 15,logs = [[1, 5], [2, 15], [3, 25], [4, 35], [5, 45], [6, 55], [7, 65], [8, 75], [9, 85], [10, 95], [11, 105], [12, 115], [13, 125], [14, 135]]) == 2\n assert candidate(n = 12,logs = [[0, 2], [1, 4], [2, 7], [3, 11], [4, 16], [5, 22], [6, 29], [7, 37], [8, 46], [9, 56], [10, 67], [11, 78]]) == 10\n assert candidate(n = 6,logs = [[0, 10], [1, 10], [2, 20], [3, 20], [4, 30], [5, 30]]) == 0\n assert candidate(n = 7,logs = [[6, 3], [5, 9], [4, 14], [3, 20], [2, 27], [1, 35], [0, 44]]) == 0\n assert candidate(n = 12,logs = [[11, 2], [10, 5], [9, 9], [8, 14], [7, 20], [6, 27], [5, 35], [4, 44], [3, 54], [2, 65], [1, 77], [0, 90]]) == 0\n assert candidate(n = 6,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30]]) == 0\n assert candidate(n = 10,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50]]) == 0\n assert candidate(n = 7,logs = [[0, 5], [1, 10], [2, 15], [0, 20], [3, 25], [1, 30], [4, 35]]) == 0\n assert candidate(n = 15,logs = [[14, 1], [13, 3], [12, 6], [11, 10], [10, 15], [9, 21], [8, 28], [7, 36], [6, 45], [5, 55], [4, 66], [3, 78], [2, 91], [1, 105], [0, 120]]) == 0\n assert candidate(n = 12,logs = [[11, 10], [10, 20], [9, 30], [8, 40], [7, 50], [6, 60], [5, 70], [4, 80], [3, 90], [2, 100], [1, 110], [0, 120]]) == 0\n assert candidate(n = 12,logs = [[0, 15], [1, 30], [2, 45], [3, 60], [4, 75], [5, 90], [6, 105], [7, 120], [8, 135], [9, 150], [10, 165], [11, 180]]) == 0\n assert candidate(n = 10,logs = [[0, 3], [2, 5], [0, 9], [1, 15], [4, 20], [6, 30], [5, 35], [3, 40]]) == 6\n assert candidate(n = 10,logs = [[0, 10], [1, 15], [2, 20], [3, 25], [4, 30], [5, 35], [6, 40], [7, 45], [8, 50], [9, 55], [0, 60], [1, 65], [2, 70], [3, 75], [4, 80], [5, 85], [6, 90], [7, 95], [8, 100], [9, 105]]) == 0\n assert candidate(n = 7,logs = [[0, 2], [1, 5], [2, 9], [3, 14], [4, 20], [5, 27], [6, 35]]) == 6\n assert candidate(n = 500,logs = [[0, 2], [1, 5], [2, 9], [3, 14], [4, 20], [5, 27], [6, 35], [7, 44], [8, 54], [9, 65], [10, 77], [11, 90], [12, 104], [13, 119], [14, 135], [15, 152], [16, 170], [17, 189], [18, 209], [19, 230], [20, 252], [21, 275], [22, 300], [23, 326], [24, 353], [25, 381], [26, 410], [27, 440], [28, 471], [29, 500], [30, 530], [31, 561], [32, 593], [33, 626], [34, 660], [35, 695], [36, 731], [37, 768], [38, 806], [39, 845], [40, 885], [41, 926], [42, 968], [43, 1011], [44, 1055], [45, 1100], [46, 1146], [47, 1193], [48, 1241], [49, 1290], [50, 1340], [51, 1391], [52, 1443], [53, 1496], [54, 1550], [55, 1605], [56, 1661], [57, 1718], [58, 1776], [59, 1835], [60, 1895], [61, 1956], [62, 2018], [63, 2081], [64, 2145], [65, 2210], [66, 2276], [67, 2343], [68, 2411], [69, 2480], [70, 2550], [71, 2621], [72, 2693], [73, 2766], [74, 2840], [75, 2915], [76, 2991], [77, 3068], [78, 3146], [79, 3225], [80, 3305], [81, 3386], [82, 3468], [83, 3551], [84, 3635], [85, 3720], [86, 3806], [87, 3893], [88, 3981], [89, 4070], [90, 4160], [91, 4251], [92, 4343], [93, 4436], [94, 4530], [95, 4625], [96, 4721], [97, 4818], [98, 4916], [99, 5000], [100, 5085], [101, 5171], [102, 5258], [103, 5346], [104, 5435], [105, 5525], [106, 5616], [107, 5708], [108, 5801], [109, 5895], [110, 5990], [111, 6086], [112, 6183], [113, 6281], [114, 6380], [115, 6480], [116, 6581], [117, 6683], [118, 6786], [119, 6890], [120, 6995], [121, 7101], [122, 7208], [123, 7316], [124, 7425], [125, 7535], [126, 7646], [127, 7758], [128, 7871], [129, 7985], [130, 8100], [131, 8216], [132, 8333], [133, 8451], [134, 8570], [135, 8690], [136, 8811], [137, 8933], [138, 9056], [139, 9180], [140, 9305], [141, 9431], [142, 9558], [143, 9686], [144, 9815], [145, 9945], [146, 10076], [147, 10208], [148, 10341], [149, 10475], [150, 10610], [151, 10746], [152, 10883], [153, 11021], [154, 11160], [155, 11300], [156, 11441], [157, 11583], [158, 11726], [159, 11870], [160, 12015], [161, 12161], [162, 12308], [163, 12456], [164, 12605], [165, 12755], [166, 12906], [167, 13058], [168, 13211], [169, 13365], [170, 13520], [171, 13676], [172, 13833], [173, 13991], [174, 14150], [175, 14310], [176, 14471], [177, 14633], [178, 14796], [179, 14960], [180, 15125], [181, 15291], [182, 15458], [183, 15626], [184, 15795], [185, 15965], [186, 16136], [187, 16308], [188, 16481], [189, 16655], [190, 16830], [191, 17006], [192, 17183], [193, 17361], [194, 17540], [195, 17720], [196, 17901], [197, 18083], [198, 18266], [199, 18450], [200, 18635], [201, 18821], [202, 19008], [203, 19196], [204, 19385], [205, 19575], [206, 19766], [207, 19958], [208, 20151], [209, 20345], [210, 20540], [211, 20736], [212, 20933], [213, 21131], [214, 21330], [215, 21530], [216, 21731], [217, 21933], [218, 22136], [219, 22340], [220, 22545], [221, 22751], [222, 22958], [223, 23166], [224, 23375], [225, 23585], [226, 23796], [227, 24008], [228, 24221], [229, 24435], [230, 24650], [231, 24866], [232, 25083], [233, 25301], [234, 25520], [235, 25740], [236, 25961], [237, 26183], [238, 26406], [239, 26630], [240, 26855], [241, 27081], [242, 27308], [243, 27536], [244, 27765], [245, 27995], [246, 28226], [247, 28458], [248, 28691], [249, 28925], [250, 29160], [251, 29396], [252, 29633], [253, 29871], [254, 30110], [255, 30350], [256, 30591], [257, 30833], [258, 31076], [259, 31320], [260, 31565], [261, 31811], [262, 32058], [263, 32306], [264, 32555], [265, 32805], [266, 33056], [267, 33308], [268, 33561], [269, 33815], [270, 34070], [271, 34326], [272, 34583], [273, 34841], [274, 35000], [275, 35260], [276, 35521], [277, 35783], [278, 36046], [279, 36310], [280, 36575], [281, 36841], [282, 37108], [283, 37376], [284, 37645], [285, 37915], [286, 38186], [287, 38458], [288, 38731], [289, 38905], [290, 39080], [291, 39256], [292, 39433], [293, 39611], [294, 39790], [295, 39970], [296, 40151], [297, 40333], [298, 40516], [299, 40700], [300, 40885], [301, 41071], [302, 41258], [303, 41446], [304, 41635], [305, 41825], [306, 42016], [307, 42208], [308, 42401], [309, 42595], [310, 42790], [311, 42986], [312, 43183], [313, 43381], [314, 43580], [315, 43780], [316, 43981], [317, 44183], [318, 44386], [319, 44590], [320, 44795], [321, 45001], [322, 45208], [323, 45416], [324, 45625], [325, 45835], [326, 46046], [327, 46258], [328, 46471], [329, 46685], [330, 46900], [331, 47116], [332, 47333], [333, 47551], [334, 47770], [335, 47990], [336, 48211], [337, 48433], [338, 48656], [339, 48880], [340, 49105], [341, 49331], [342, 49558], [343, 49786], [344, 50000]]) == 288\n assert candidate(n = 8,logs = [[0, 2], [1, 6], [2, 12], [3, 18], [4, 24], [5, 30], [6, 36], [7, 42]]) == 2\n assert candidate(n = 5,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [0, 60], [1, 70], [2, 80], [3, 90], [4, 100], [0, 110], [1, 120], [2, 130], [3, 140], [4, 150], [0, 160], [1, 170], [2, 180], [3, 190], [4, 200]]) == 0\n assert candidate(n = 8,logs = [[0, 20], [1, 30], [2, 40], [3, 50], [4, 60], [5, 70], [6, 80], [7, 90]]) == 0\n assert candidate(n = 7,logs = [[0, 1], [1, 3], [2, 6], [3, 10], [4, 15], [5, 21], [6, 28]]) == 6\n assert candidate(n = 12,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [0, 130], [1, 140], [2, 150], [3, 160], [4, 170], [5, 180], [6, 190], [7, 200], [8, 210], [9, 220], [10, 230], [11, 240]]) == 0\n assert candidate(n = 15,logs = [[5, 10], [7, 20], [2, 25], [3, 30], [10, 35], [6, 40], [1, 45]]) == 5\n assert candidate(n = 8,logs = [[0, 3], [1, 7], [2, 14], [3, 22], [4, 31], [5, 41], [6, 53], [7, 66]]) == 7\n assert candidate(n = 15,logs = [[0, 2], [1, 6], [2, 11], [3, 17], [4, 24], [5, 32], [6, 41], [7, 51], [8, 62], [9, 74], [10, 87], [11, 101], [12, 116], [13, 132], [14, 149]]) == 14\n assert candidate(n = 11,logs = [[0, 2], [1, 5], [2, 10], [3, 17], [4, 26], [5, 37], [6, 50], [7, 65], [8, 82], [9, 101], [10, 122]]) == 10\n assert candidate(n = 5,logs = [[0, 10], [1, 15], [2, 20], [3, 25], [4, 30], [0, 35], [1, 40]]) == 0\n assert candidate(n = 9,logs = [[0, 11], [1, 22], [2, 33], [3, 44], [4, 55], [5, 66], [6, 77], [7, 88], [8, 99]]) == 0\n assert candidate(n = 5,logs = [[4, 100], [2, 200], [3, 300], [1, 400], [0, 500]]) == 0\n assert candidate(n = 12,logs = [[0, 5], [1, 12], [2, 22], [3, 35], [4, 50], [5, 67], [6, 86], [7, 107], [8, 130], [9, 155], [10, 182], [11, 211]]) == 11\n assert candidate(n = 8,logs = [[7, 1], [1, 2], [3, 5], [2, 10], [4, 20], [6, 30], [5, 40], [0, 50]]) == 0\n assert candidate(n = 20,logs = [[0, 1], [2, 3], [4, 6], [6, 10], [8, 15], [10, 21], [12, 28], [14, 36], [16, 45], [18, 55], [1, 65], [3, 75], [5, 85], [7, 95]]) == 1\n assert candidate(n = 5,logs = [[0, 1], [1, 10], [2, 11], [3, 12], [4, 13]]) == 1\n assert candidate(n = 10,logs = [[0, 10], [1, 15], [2, 20], [3, 25], [4, 30], [5, 35], [6, 40], [7, 45], [8, 50], [9, 55]]) == 0\n assert candidate(n = 10,logs = [[9, 10], [8, 20], [7, 30], [6, 40], [5, 50], [4, 60], [3, 70], [2, 80], [1, 90], [0, 100]]) == 0\n assert candidate(n = 10,logs = [[0, 5], [1, 15], [2, 25], [3, 35], [4, 45], [5, 55], [6, 65], [7, 75], [8, 85], [9, 95]]) == 1\n assert candidate(n = 15,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [12, 130], [13, 140], [14, 150]]) == 0\n assert candidate(n = 10,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 30], [5, 40], [6, 50], [7, 60], [8, 70], [9, 80]]) == 4\n assert candidate(n = 7,logs = [[0, 12], [1, 23], [2, 34], [3, 45], [4, 56], [5, 67], [6, 78]]) == 0\n assert candidate(n = 25,logs = [[0, 12], [1, 24], [2, 36], [3, 48], [4, 60], [5, 72], [6, 84], [7, 96], [8, 108], [9, 120], [10, 132], [11, 144], [12, 156], [13, 168], [14, 180], [15, 192], [16, 204], [17, 216], [18, 228], [19, 240], [20, 252], [21, 264], [22, 276], [23, 288], [24, 300]]) == 0\n assert candidate(n = 8,logs = [[7, 15], [3, 25], [5, 40], [6, 50], [2, 60], [1, 70], [4, 80], [0, 90]]) == 5\n assert candidate(n = 10,logs = [[0, 5], [1, 9], [2, 13], [3, 17], [4, 21], [5, 25], [6, 29], [7, 33], [8, 37], [9, 41]]) == 0\n assert candidate(n = 6,logs = [[5, 10], [0, 20], [2, 30], [1, 40], [3, 50], [4, 60]]) == 0\n assert candidate(n = 15,logs = [[0, 2], [1, 5], [2, 9], [3, 14], [4, 20], [5, 27], [6, 35], [7, 44], [8, 54], [9, 65], [10, 77], [11, 90], [12, 104], [13, 119], [14, 135]]) == 14\n assert candidate(n = 13,logs = [[12, 2], [11, 5], [10, 9], [9, 14], [8, 20], [7, 27], [6, 35], [5, 44], [4, 54], [3, 65], [2, 77], [1, 90], [0, 104]]) == 0\n assert candidate(n = 10,logs = [[9, 2], [3, 6], [7, 10], [2, 15], [4, 20], [1, 25], [5, 30], [8, 35], [6, 40], [0, 50]]) == 0\n assert candidate(n = 7,logs = [[0, 5], [1, 10], [0, 15], [1, 20], [0, 25], [1, 30], [0, 35]]) == 0\n assert candidate(n = 15,logs = [[14, 3], [13, 7], [12, 12], [11, 18], [10, 24], [9, 31], [8, 38], [7, 45], [6, 52], [5, 59], [4, 66], [3, 73], [2, 80], [1, 87], [0, 94]]) == 0\n assert candidate(n = 30,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [10, 55], [11, 60], [12, 65], [13, 70], [14, 75], [15, 80], [16, 85], [17, 90], [18, 95], [19, 100], [20, 105], [21, 110], [22, 115], [23, 120], [24, 125], [25, 130], [26, 135], [27, 140], [28, 145], [29, 150]]) == 0\n assert candidate(n = 10,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [0, 55], [1, 60], [2, 65], [3, 70], [4, 75], [5, 80], [6, 85], [7, 90], [8, 95], [9, 100]]) == 0\n assert candidate(n = 9,logs = [[8, 1], [7, 3], [6, 6], [5, 10], [4, 15], [3, 21], [2, 28], [1, 36], [0, 45]]) == 0\n assert candidate(n = 20,logs = [[0, 15], [1, 30], [2, 45], [3, 60], [4, 75], [5, 90], [6, 105], [7, 120], [8, 135], [9, 150], [10, 165], [11, 180], [12, 195], [13, 210], [14, 225], [15, 240], [16, 255], [17, 270], [18, 285], [19, 300]]) == 0\n assert candidate(n = 15,logs = [[0, 5], [1, 15], [2, 25], [3, 35], [4, 45], [5, 55], [6, 65], [7, 75], [8, 85], [9, 95], [10, 105], [11, 115], [12, 125], [13, 135], [14, 145]]) == 1\n assert candidate(n = 10,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [0, 55], [1, 60], [2, 65], [3, 70], [4, 75], [5, 80], [6, 85], [7, 90], [8, 95], [9, 100], [0, 105], [1, 110], [2, 115], [3, 120], [4, 125], [5, 130], [6, 135], [7, 140], [8, 145], [9, 150]]) == 0\n assert candidate(n = 5,logs = [[0, 50], [1, 100], [2, 150], [3, 200], [4, 250]]) == 0\n assert candidate(n = 4,logs = [[0, 10], [1, 20], [2, 30], [3, 40]]) == 0\n assert candidate(n = 5,logs = [[4, 2], [3, 5], [2, 9], [1, 14], [0, 20]]) == 0\n assert candidate(n = 7,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [0, 80]]) == 0\n assert candidate(n = 6,logs = [[0, 5], [1, 15], [2, 25], [3, 35], [4, 45], [5, 55]]) == 1\n assert candidate(n = 7,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [0, 80], [1, 90], [2, 100], [3, 110], [4, 120], [5, 130], [6, 140], [0, 150], [1, 160], [2, 170], [3, 180], [4, 190], [5, 200], [6, 210]]) == 0\n assert candidate(n = 5,logs = [[0, 100], [1, 150], [2, 200], [3, 250], [4, 300], [0, 350], [1, 400], [2, 450], [3, 500], [4, 550], [0, 600], [1, 650], [2, 700], [3, 750], [4, 800]]) == 0\n assert candidate(n = 8,logs = [[0, 2], [1, 4], [2, 8], [3, 14], [4, 22], [5, 32], [6, 44], [7, 58]]) == 7\n assert candidate(n = 5,logs = [[0, 50], [1, 100], [2, 150], [3, 200], [4, 250], [0, 300], [1, 350], [2, 400], [3, 450], [4, 500]]) == 0\n assert candidate(n = 15,logs = [[14, 10], [3, 20], [5, 30], [7, 40], [9, 50], [11, 60], [13, 70]]) == 3\n"}, "metadata": {"canonical_parameter_names": ["n", "logs"], "leetcode_dataset_entry_point": "Solution().hardestWorker", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int hardestWorker(int n, int[][] logs) {", "container": "Solution", "callable": "hardestWorker", "parameters": [{"name": "n", "type": "int"}, {"name": "logs", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2433, "task_id": "find-the-original-array-of-prefix-xor", "difficulty": "Medium", "problem_description": "You are given an integer array pref of size n. Find and return the array arr of size n that satisfies:\n\npref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i].\n\nNote that ^ denotes the bitwise-xor operation.\nIt can be proven that the answer is unique.\n \nExample 1:\n\nInput: pref = [5,2,0,3,1]\nOutput: [5,7,2,3,2]\nExplanation: From the array [5,7,2,3,2] we have the following:\n- pref[0] = 5.\n- pref[1] = 5 ^ 7 = 2.\n- pref[2] = 5 ^ 7 ^ 2 = 0.\n- pref[3] = 5 ^ 7 ^ 2 ^ 3 = 3.\n- pref[4] = 5 ^ 7 ^ 2 ^ 3 ^ 2 = 1.\n\nExample 2:\n\nInput: pref = [13]\nOutput: [13]\nExplanation: We have pref[0] = arr[0] = 13.\n\n \nConstraints:\n\n1 <= pref.length <= 105\n0 <= pref[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pref = [5, 2, 0, 3, 1]) == [5, 7, 2, 3, 2]\n assert candidate(pref = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(pref = [0, 1, 2, 3, 4]) == [0, 1, 3, 1, 7]\n assert candidate(pref = [10, 4, 6, 3, 5]) == [10, 14, 2, 5, 6]\n assert candidate(pref = [13]) == [13]\n assert candidate(pref = [1, 1, 1, 1, 1]) == [1, 0, 0, 0, 0]\n assert candidate(pref = [2, 3, 4, 5, 6]) == [2, 1, 7, 1, 3]\n assert candidate(pref = [1, 2, 3, 4, 5]) == [1, 3, 1, 7, 1]\n assert candidate(pref = [1000000, 500000, 250000, 125000, 62500]) == [1000000, 582496, 291248, 145624, 72812]\n assert candidate(pref = [1, 3, 7, 15, 31]) == [1, 2, 4, 8, 16]\n assert candidate(pref = [10, 15, 5, 12, 9]) == [10, 5, 10, 9, 5]\n assert candidate(pref = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [65535, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]\n assert candidate(pref = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 0, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999]) == [999999, 184839, 413193, 127515, 153097, 963135, 253449, 422427, 185865, 111111, 111111, 185865, 422427, 253449, 963135, 153097, 127515, 413193, 184839]\n assert candidate(pref = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642, 2147483641]) == [2147483647, 1, 3, 1, 7, 1, 3]\n assert candidate(pref = [16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304]) == [16384, 49152, 98304, 196608, 393216, 786432, 1572864, 3145728, 6291456]\n assert candidate(pref = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1, 3, 6, 12, 24, 48, 96, 192, 384, 768]\n assert candidate(pref = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234]) == [123456, 161287, 446985, 245275, 938503, 192935, 414177, 106271, 21881]\n assert candidate(pref = [0, 1, 3, 6, 15, 31, 63, 127, 255, 511]) == [0, 1, 2, 5, 9, 16, 32, 64, 128, 256]\n assert candidate(pref = [0, 1, 3, 0, 4, 5, 1, 2, 6, 7, 1, 0]) == [0, 1, 2, 3, 4, 1, 4, 3, 4, 1, 6, 1]\n assert candidate(pref = [0, 1, 3, 6, 10, 15, 21]) == [0, 1, 2, 5, 12, 5, 26]\n assert candidate(pref = [1023456, 2046912, 1023456, 3070368, 3070368, 2046912, 1023456, 0, 1, 5, 6, 7, 1]) == [1023456, 1091104, 1091104, 2180160, 0, 3269216, 1091104, 1023456, 1, 4, 3, 1, 6]\n assert candidate(pref = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == [1, 3, 6, 12, 24, 48, 96, 192, 384]\n assert candidate(pref = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1024, 1536, 768, 384, 192, 96, 48, 24, 12, 6, 3, 1, 1, 3, 6, 12, 24, 48, 96, 192, 384, 768]\n assert candidate(pref = [0, 1, 3, 0, 4, 7, 4, 3, 1, 0]) == [0, 1, 2, 3, 4, 3, 3, 7, 2, 1]\n assert candidate(pref = [123456, 654321, 111111, 222222, 333333, 444444]) == [123456, 530865, 543222, 185865, 422427, 253449]\n assert candidate(pref = [255, 127, 63, 31, 15, 7, 3, 1, 0]) == [255, 128, 64, 32, 16, 8, 4, 2, 1]\n assert candidate(pref = [888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == [888888, 413193, 127515, 153097, 963135, 253449, 422427, 185865]\n assert candidate(pref = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1]\n assert candidate(pref = [888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 0]) == [888888, 413193, 127515, 153097, 963135, 253449, 422427, 185865, 111111]\n assert candidate(pref = [987654321, 123456789, 987654321, 222222222, 333333333, 444444444, 555555555]) == [987654321, 1032168868, 1032168868, 937475903, 518034651, 161737801, 996193791]\n assert candidate(pref = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642, 2147483641, 2147483640, 2147483639, 2147483638, 2147483637, 2147483636, 2147483635, 2147483634, 2147483633, 2147483632, 2147483631, 2147483630, 2147483629, 2147483628]) == [2147483647, 1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1, 31, 1, 3, 1]\n assert candidate(pref = [0, 2147483647, 0, 2147483647, 0, 2147483647, 0, 2147483647, 0, 2147483647]) == [0, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647]\n assert candidate(pref = [256, 272, 258, 274, 259, 275, 260, 276, 261, 277, 262, 278, 263, 279, 264, 280, 265, 281, 266, 282, 267, 283, 268, 284, 269, 285, 270, 286, 271, 287, 272, 288]) == [256, 16, 18, 16, 17, 16, 23, 16, 17, 16, 19, 16, 17, 16, 31, 16, 17, 16, 19, 16, 17, 16, 23, 16, 17, 16, 19, 16, 17, 16, 15, 48]\n assert candidate(pref = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 3, 1, 7, 1, 3, 1, 15, 1, 3]\n assert candidate(pref = [42, 84, 168, 336, 672, 1344, 2688, 5376, 10752, 21504, 43008, 86016, 172032, 344064, 688128, 1376256, 2752512, 5505024, 11010048, 22020096, 44040192, 88080384, 176160768, 352321536, 704643072, 1409286144, 2818572288, 5637144576, 11274289152, 22548578304, 45097156608, 90194313216, 180388626432, 360777252864, 721554505728, 1443109011456, 2886218022912]) == [42, 126, 252, 504, 1008, 2016, 4032, 8064, 16128, 32256, 64512, 129024, 258048, 516096, 1032192, 2064384, 4128768, 8257536, 16515072, 33030144, 66060288, 132120576, 264241152, 528482304, 1056964608, 2113929216, 4227858432, 8455716864, 16911433728, 33822867456, 67645734912, 135291469824, 270582939648, 541165879296, 1082331758592, 2164663517184, 4329327034368]\n assert candidate(pref = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 172, 484, 188, 100, 940, 228, 412, 164, 108]\n assert candidate(pref = [123456, 654321, 111111, 222222, 333333]) == [123456, 530865, 543222, 185865, 422427]\n assert candidate(pref = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == [100, 172, 484, 188, 100, 940, 228, 412, 164, 108, 1956, 252]\n assert candidate(pref = [15, 14, 13, 12, 11, 10, 9, 8, 7]) == [15, 1, 3, 1, 7, 1, 3, 1, 15]\n assert candidate(pref = [17, 23, 14, 31, 5, 9, 12, 7]) == [17, 6, 25, 17, 26, 12, 5, 11]\n assert candidate(pref = [16777215, 8388607, 4194303, 2097151, 1048575, 524287]) == [16777215, 8388608, 4194304, 2097152, 1048576, 524288]\n assert candidate(pref = [1234567, 7654321, 1357924, 2468135, 9876543]) == [1234567, 6692150, 6321109, 3215683, 11738392]\n assert candidate(pref = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]\n assert candidate(pref = [8, 12, 10, 15, 7, 13, 9, 14, 6, 11]) == [8, 4, 6, 5, 8, 10, 4, 7, 8, 13]\n assert candidate(pref = [13, 13, 26, 26, 52, 52, 104, 104, 208, 208]) == [13, 0, 23, 0, 46, 0, 92, 0, 184, 0]\n assert candidate(pref = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == [1, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152]\n assert candidate(pref = [1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1048575, 524287, 786432, 393216, 196608, 98304, 49152, 24576, 12288, 6144, 3072, 1536, 768, 384, 192, 96, 48, 24, 12, 6, 3]\n assert candidate(pref = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(pref = [256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16]) == [256, 384, 192, 96, 48, 24, 12, 6, 3, 1, 1, 3, 6, 12, 24]\n assert candidate(pref = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == [1, 0, 3, 1, 6, 13, 5, 24, 55, 21, 110, 201, 121, 400, 795, 441, 1510, 3109, 6733, 2616]\n assert candidate(pref = [999999, 899999, 799999, 699999, 599999, 499999, 399999, 299999, 199999, 99999]) == [999999, 194976, 102240, 432800, 231904, 951968, 113504, 166304, 499424, 166816]\n assert candidate(pref = [1234567, 7654321, 1357924, 2468013, 3456789, 9876543, 8642013]) == [1234567, 6692150, 6321109, 3215561, 1120184, 10619690, 1403362]\n assert candidate(pref = [123456, 654321, 111222, 333444, 555666, 777888]) == [123456, 530865, 543111, 304370, 879638, 238642]\n assert candidate(pref = [7, 14, 21, 28, 35, 42, 49]) == [7, 9, 27, 9, 63, 9, 27]\n assert candidate(pref = [42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21]) == [42, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63]\n assert candidate(pref = [4294967295, 4294967294, 4294967293, 4294967292, 4294967291, 4294967290, 4294967289, 4294967288, 4294967287, 4294967286]) == [4294967295, 1, 3, 1, 7, 1, 3, 1, 15, 1]\n assert candidate(pref = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(pref = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(pref = [1024, 2048, 1024, 2048, 1024, 2048, 1024, 2048, 1024, 2048, 1024, 2048]) == [1024, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072]\n assert candidate(pref = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 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(pref = [16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [16777215, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]\n assert candidate(pref = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1048576, 1572864, 786432, 393216, 196608, 98304, 49152, 24576, 12288, 6144, 3072, 1536, 768, 384, 192, 96, 48, 24, 12, 6, 3]\n assert candidate(pref = [1024, 2048, 4096, 8192, 16384, 32768]) == [1024, 3072, 6144, 12288, 24576, 49152]\n assert candidate(pref = [255, 0, 255, 0, 255, 0, 255, 0, 255]) == [255, 255, 255, 255, 255, 255, 255, 255, 255]\n assert candidate(pref = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]) == [0, 1, 2, 5, 12, 5, 26, 9, 56, 9]\n assert candidate(pref = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930]) == [123, 435, 733, 100845, 232367, 30433, 39331, 100961, 48807, 494561]\n assert candidate(pref = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(pref = [8000000, 4000000, 2000000, 1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == [8000000, 4659968, 2329984, 1164992, 582496, 291248, 145624, 72812, 36406, 18203, 9101, 4550, 2275]\n assert candidate(pref = [1365, 1364, 1360, 1344, 1312, 1248, 1120, 896, 512, 0]) == [1365, 1, 4, 16, 96, 448, 128, 2016, 384, 512]\n assert candidate(pref = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [1, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]\n assert candidate(pref = [100, 200, 100, 300, 200, 500, 400, 700, 600, 1100, 1000, 1500, 1400, 1900, 1800]) == [100, 172, 172, 328, 484, 316, 100, 812, 228, 1556, 1956, 1588, 164, 532, 100]\n assert candidate(pref = [16, 28, 40, 52, 64, 76, 88, 100]) == [16, 12, 52, 28, 116, 12, 20, 60]\n assert candidate(pref = [1234567, 7654321, 111222333, 9876543, 333222111]) == [1234567, 6692150, 114677132, 104311298, 323626208]\n assert candidate(pref = [16, 24, 28, 20, 26, 30, 22, 31, 27, 29, 31, 15, 7, 11, 13, 12]) == [16, 8, 4, 8, 14, 4, 8, 9, 4, 6, 2, 16, 8, 12, 6, 1]\n assert candidate(pref = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [5, 15, 5, 27, 13, 7, 61, 11, 5, 31, 5, 11]\n assert candidate(pref = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(pref = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [1, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576]\n assert candidate(pref = [3, 1, 2, 3, 1, 0, 1]) == [3, 2, 3, 1, 2, 1, 1]\n assert candidate(pref = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(pref = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246]) == [255, 1, 3, 1, 7, 1, 3, 1, 15, 1]\n assert candidate(pref = [1024, 1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016]) == [1024, 2047, 1, 3, 1, 7, 1, 3, 1]\n assert candidate(pref = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [15, 1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1]\n assert candidate(pref = [987654, 321456, 654321, 789012, 123456, 456789]) == [987654, 783798, 859201, 389605, 911444, 465429]\n assert candidate(pref = [8, 12, 14, 8, 10, 3, 9, 0, 1, 5, 6, 7, 1]) == [8, 4, 2, 6, 2, 9, 10, 9, 1, 4, 3, 1, 6]\n assert candidate(pref = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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(pref = [987654321, 123456789, 98765432, 12345678, 9876543, 1234567, 987654, 123456, 98765, 12345, 9876, 1234, 987, 123, 98, 12, 9, 1]) == [987654321, 1032168868, 45664109, 90139446, 2807153, 8676024, 1950849, 979014, 25485, 111092, 5805, 8774, 1801, 928, 25, 110, 5, 8]\n assert candidate(pref = [255, 254, 252, 248, 240, 224, 192, 128, 64, 0]) == [255, 1, 2, 4, 8, 16, 32, 64, 192, 64]\n assert candidate(pref = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584]) == [7, 9, 18, 36, 72, 144, 288, 576, 1152, 2304]\n assert candidate(pref = [8, 12, 10, 14, 13, 11, 15, 9, 13, 11, 15, 9]) == [8, 4, 6, 4, 3, 6, 4, 6, 4, 6, 4, 6]\n assert candidate(pref = [15, 11, 13, 9, 15, 7]) == [15, 4, 6, 4, 6, 8]\n assert candidate(pref = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000, 0]) == [10000000, 1163968, 15943232, 1105344, 3228224, 1558208, 7422528, 1101760, 3359296, 1164992, 1000000]\n assert candidate(pref = [8, 12, 14, 13, 9, 3, 6, 10, 11, 7]) == [8, 4, 2, 3, 4, 10, 5, 12, 1, 12]\n assert candidate(pref = [1234567, 890123, 456789, 123456, 789012]) == [1234567, 2048908, 748894, 465429, 911444]\n assert candidate(pref = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10]) == [10, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]\n assert candidate(pref = [16777215, 33554430, 16777215, 50331645, 50331645, 33554430, 16777215, 0, 1, 5, 6, 7, 1]) == [16777215, 16777217, 16777217, 33554434, 0, 50331651, 16777217, 16777215, 1, 4, 3, 1, 6]\n assert candidate(pref = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [1, 2, 5, 12, 5, 26, 9, 56, 9, 26]\n assert candidate(pref = [131313, 131312, 131311, 131310, 131309, 131308, 131307, 131306, 131305, 131304]) == [131313, 1, 31, 1, 3, 1, 7, 1, 3, 1]\n assert candidate(pref = [15, 30, 60, 120, 240, 480, 960, 1920, 3840, 7680]) == [15, 17, 34, 68, 136, 272, 544, 1088, 2176, 4352]\n"}, "metadata": {"canonical_parameter_names": ["pref"], "leetcode_dataset_entry_point": "Solution().findArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] findArray(int[] pref) {", "container": "Solution", "callable": "findArray", "parameters": [{"name": "pref", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2434, "task_id": "using-a-robot-to-print-the-lexicographically-smallest-string", "difficulty": "Medium", "problem_description": "You are given a string s and a robot that currently holds an empty string t. Apply one of the following operations until s and t are both empty:\n\nRemove the first character of a string s and give it to the robot. The robot will append this character to the string t.\nRemove the last character of a string t and give it to the robot. The robot will write this character on paper.\n\nReturn the lexicographically smallest string that can be written on the paper.\n \nExample 1:\n\nInput: s = \"zza\"\nOutput: \"azz\"\nExplanation: Let p denote the written string.\nInitially p=\"\", s=\"zza\", t=\"\".\nPerform first operation three times p=\"\", s=\"\", t=\"zza\".\nPerform second operation three times p=\"azz\", s=\"\", t=\"\".\n\nExample 2:\n\nInput: s = \"bac\"\nOutput: \"abc\"\nExplanation: Let p denote the written string.\nPerform first operation twice p=\"\", s=\"c\", t=\"ba\". \nPerform second operation twice p=\"ab\", s=\"c\", t=\"\". \nPerform first operation p=\"ab\", s=\"\", t=\"c\". \nPerform second operation p=\"abc\", s=\"\", t=\"\".\n\nExample 3:\n\nInput: s = \"bdda\"\nOutput: \"addb\"\nExplanation: Let p denote the written string.\nInitially p=\"\", s=\"bdda\", t=\"\".\nPerform first operation four times p=\"\", s=\"\", t=\"bdda\".\nPerform second operation four times p=\"addb\", s=\"\", t=\"\".\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of only English lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbcc\") == \"aabbcc\"\n assert candidate(s = \"bdda\") == \"addb\"\n assert candidate(s = \"cba\") == \"abc\"\n assert candidate(s = \"bac\") == \"abc\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aaa\") == \"aaa\"\n assert candidate(s = \"abcde\") == \"abcde\"\n assert candidate(s = \"zza\") == \"azz\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"edcba\") == \"abcde\"\n assert candidate(s = \"abacabadabacaba\") == \"aaaaaaaabcbdbcb\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"aaaabbbbccccdddd\") == \"aaaabbbbccccdddd\"\n assert candidate(s = \"fedcb\") == \"bcdef\"\n assert candidate(s = \"ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\") == \"ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\"\n assert candidate(s = \"aaabbbccc\") == \"aaabbbccc\"\n assert candidate(s = \"fedcbafedcbafedcba\") == \"aaabcdefbcdefbcdef\"\n assert candidate(s = \"fedcbaghijk\") == \"abcdefghijk\"\n assert candidate(s = \"mjwqeqpdpdwdwwvwqwdqeqpqwwqwwqwwpqwwqwpqwwqppwpqpqppwpqpqpqpqpqpqpqpqpqpqpqpqpqpqppwqqqqqqqppqqqpqpwq\") == \"ddddepppppppppppppppppppppppppppppqqqqqqqqqqqqwwqqqqqqqqqqqqqqwqqwqwwqwqwwqwwqwwqwwqqqwqwvwwwppqeqwjm\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnooopppqqqrrrssstttuuuuvvvwwwxxxyyyzzz\") == \"aaabbbcccdddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnooopppqqqrrrssstttuuuuvvvwwwxxxyyyzzz\"\n assert candidate(s = \"acbcbabcbabcba\") == \"aaaabcbbcbbcbc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"aaaaaaaaaaaaaaaaaaabcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\"\n assert candidate(s = \"bbbaaa\") == \"aaabbb\"\n assert candidate(s = \"abcdcba\") == \"aabcdcb\"\n assert candidate(s = \"zazbzczdz\") == \"abcdzzzzz\"\n assert candidate(s = \"zzzaaa\") == \"aaazzz\"\n assert candidate(s = \"amazingleetcodeproblem\") == \"aabelmorpedocteelgnizm\"\n assert candidate(s = \"abcdefgzyxwvutsrqponmlkjihgfedcba\") == \"aabcdefghijklmnopqrstuvwxyzgfedcb\"\n assert candidate(s = \"fedcbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbac\") == \"aaaaaaaaaaaaaaaaabcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbccdef\"\n assert candidate(s = \"abracadabra\") == \"aaaaarbdcrb\"\n assert candidate(s = \"aabccccaaa\") == \"aaaaaccccb\"\n assert candidate(s = \"abcdabcda\") == \"aaadcbdcb\"\n assert candidate(s = \"bacbacbacb\") == \"aaabbccbcb\"\n assert candidate(s = \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\") == \"aaaaaaaaaabcdedcbedcbedcbedcbedcbedcbedcbedcbedcbe\"\n assert candidate(s = \"zzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzz\") == \"abcdefghijklmnopqrstuvwxyzz\"\n assert candidate(s = \"zzzyyyxxxwwwwvvvuuutttsssrqqqpppoonnmmlkkjjiihhggffeedcba\") == \"abcdeeffgghhiijjkklmmnnoopppqqqrssstttuuuvvvwwwwxxxyyyzzz\"\n assert candidate(s = \"caabdbac\") == \"aaabcdbc\"\n assert candidate(s = \"aaaabbbbccccddddeeeeffff\") == \"aaaabbbbccccddddeeeeffff\"\n assert candidate(s = \"fedcba\") == \"abcdef\"\n assert candidate(s = \"abcdabcabc\") == \"aaabcbcdcb\"\n assert candidate(s = \"leetcode\") == \"cdeoteel\"\n assert candidate(s = \"racecar\") == \"aacecrr\"\n assert candidate(s = \"zzzyyxxwvwuvuttrssrqqponnmlkkjjiihhhggffeeddcbbbaaa\") == \"aaabbbcddeeffgghhhiijjkklmnnopqqrssrttuvuwvwxxyyzzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"aabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcb\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"aaaabcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcbzyxwvutsrqponmlkjihgfedcbzyxwvutsrqponmlkjihgfedcbz\"\n assert candidate(s = \"banana\") == \"aaannb\"\n assert candidate(s = \"abcdeabcde\") == \"aabcdedcbe\"\n assert candidate(s = \"mississippi\") == \"iiiippssssm\"\n assert candidate(s = \"acacacacac\") == \"aaaaaccccc\"\n assert candidate(s = \"abcdabcdbacd\") == \"aaabcdcbdcbd\"\n assert candidate(s = \"bbaaccdd\") == \"aabbccdd\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcdabcdabcdabcd\") == \"aaaabcdcbdcbdcbd\"\n assert candidate(s = \"aaabbbcccddd\") == \"aaabbbcccddd\"\n assert candidate(s = \"qrsnspndpsnpppdnspndpdpsnsnspdpspndpdpsnpsdpsnpspdpsndpdpsnpdpsnpsdpsnpd\") == \"ddddddddddddddpnspspnsppnsppnsppspnspspnsppnpsppsnsnsppnpsnpppnspnpsnsrq\"\n assert candidate(s = \"abababababababababababababab\") == \"aaaaaaaaaaaaaabbbbbbbbbbbbbb\"\n assert candidate(s = \"xyzzyxzyx\") == \"xxxyzyzzy\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().robotWithString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String robotWithString(String s) {", "container": "Solution", "callable": "robotWithString", "parameters": [{"name": "s", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2435, "task_id": "paths-in-matrix-whose-sum-is-divisible-by-k", "difficulty": "Hard", "problem_description": "You are given a 0-indexed m x n integer matrix grid and an integer k. You are currently at position (0, 0) and you want to reach position (m - 1, n - 1) moving only down or right.\nReturn the number of paths where the sum of the elements on the path is divisible by k. Since the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: grid = [[5,2,4],[3,0,5],[0,7,2]], k = 3\nOutput: 2\nExplanation: There are two paths where the sum of the elements on the path is divisible by k.\nThe first path highlighted in red has a sum of 5 + 2 + 4 + 5 + 2 = 18 which is divisible by 3.\nThe second path highlighted in blue has a sum of 5 + 3 + 0 + 5 + 2 = 15 which is divisible by 3.\n\nExample 2:\n\n\nInput: grid = [[0,0]], k = 5\nOutput: 1\nExplanation: The path highlighted in red has a sum of 0 + 0 = 0 which is divisible by 5.\n\nExample 3:\n\n\nInput: grid = [[7,3,4,9],[2,3,6,2],[2,3,7,0]], k = 1\nOutput: 10\nExplanation: Every integer is divisible by 1 so the sum of the elements on every possible path is divisible by k.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 5 * 104\n1 <= m * n <= 5 * 104\n0 <= grid[i][j] <= 100\n1 <= k <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10]],k = 5) == 6\n assert candidate(grid = [[100, 100], [100, 100]],k = 101) == 0\n assert candidate(grid = [[100, 100], [100, 100]],k = 5) == 2\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]],k = 2) == 3\n assert candidate(grid = [[7, 3, 4, 9], [2, 3, 6, 2], [2, 3, 7, 0]],k = 1) == 10\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 2) == 0\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10]],k = 10) == 6\n assert candidate(grid = [[10, 20, 30], [40, 50, 60]],k = 10) == 3\n assert candidate(grid = [[5, 2, 4], [3, 0, 5], [0, 7, 2]],k = 3) == 2\n assert candidate(grid = [[0, 0]],k = 5) == 1\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, 2, 2, 2, 2, 2, 2]],k = 11) == 0\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], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]],k = 15) == 48\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 = 7) == 5\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 = 3) == 13\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, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 0, 9, 8, 7, 6, 5, 4, 3, 2]],k = 10) == 44\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 = 3) == 0\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 7, 5, 3, 1, 2, 4, 6, 8]],k = 4) == 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 = 3) == 0\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]],k = 50) == 7\n assert candidate(grid = [[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]],k = 7) == 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], [21, 22, 23, 24, 25]],k = 11) == 7\n assert candidate(grid = [[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 = 3) == 22\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], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]],k = 11) == 65\n assert candidate(grid = [[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]],k = 29) == 41\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]],k = 19) == 9\n assert candidate(grid = [[100, 0, 0, 100], [0, 100, 100, 0], [100, 0, 0, 100], [0, 100, 100, 0]],k = 100) == 20\n assert candidate(grid = [[97, 23, 14], [12, 54, 67], [11, 22, 33], [44, 55, 66]],k = 49) == 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, 1, 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) == 0\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]],k = 10) == 0\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]],k = 13) == 2\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50]],k = 13) == 6\n assert candidate(grid = [[5, 15, 25, 35, 45], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [10, 20, 30, 40, 50]],k = 7) == 5\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]],k = 5) == 16\n assert candidate(grid = [[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 = 5) == 0\n assert candidate(grid = [[3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8], [9, 8, 7, 6, 5, 4, 3, 2], [1, 3, 5, 7, 9, 11, 13, 15]],k = 7) == 20\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 = 4) == 35\n assert candidate(grid = [[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]],k = 50) == 0\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]],k = 8) == 5\n assert candidate(grid = [[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]],k = 25) == 0\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, 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], [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], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 11) == 4500\n assert candidate(grid = [[42, 24, 64, 18, 81], [30, 37, 30, 26, 44], [30, 37, 30, 26, 44], [30, 37, 30, 26, 44], [30, 37, 30, 26, 44]],k = 17) == 5\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],k = 2) == 35\n assert candidate(grid = [[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(grid = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]],k = 11) == 119\n assert candidate(grid = [[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 = 100) == 55\n assert candidate(grid = [[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 = 17) == 1\n assert candidate(grid = [[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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],k = 3) == 16568\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 = 10) == 35\n assert candidate(grid = [[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 = 13) == 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 = 7) == 55\n assert candidate(grid = [[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 = 4) == 16\n assert candidate(grid = [[42, 35, 18, 57], [61, 36, 35, 90], [61, 28, 47, 66], [84, 84, 53, 71]],k = 17) == 1\n assert candidate(grid = [[5, 8, 3, 6, 2], [7, 1, 4, 9, 10], [12, 5, 16, 3, 8], [4, 13, 11, 20, 6]],k = 7) == 4\n assert candidate(grid = [[7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2]],k = 11) == 2\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, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 7) == 12\n assert candidate(grid = [[34, 21, 54, 23], [12, 34, 56, 78], [90, 12, 34, 56], [78, 90, 12, 34]],k = 13) == 1\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 0]],k = 5) == 1\n assert candidate(grid = [[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]],k = 42) == 50\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]],k = 7) == 715\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],k = 3) == 0\n assert candidate(grid = [[99, 98, 97, 96], [95, 94, 93, 92], [91, 90, 89, 88]],k = 50) == 0\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, 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]],k = 50) == 0\n assert candidate(grid = [[3, 1, 4, 1, 5], [9, 2, 6, 5, 3], [5, 8, 9, 7, 9], [3, 2, 3, 8, 4], [0, 2, 1, 3, 8]],k = 13) == 4\n assert candidate(grid = [[3, 1, 2, 3, 4], [1, 3, 4, 5, 2], [2, 4, 5, 1, 3], [4, 5, 1, 3, 2], [5, 1, 3, 2, 4]],k = 13) == 39\n assert candidate(grid = [[99, 98, 97, 96, 95], [94, 93, 92, 91, 90], [89, 88, 87, 86, 85], [84, 83, 82, 81, 80]],k = 25) == 2\n assert candidate(grid = [[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]],k = 49) == 0\n assert candidate(grid = [[100, 0, 100, 0, 100], [0, 100, 0, 100, 0], [100, 0, 100, 0, 100], [0, 100, 0, 100, 0], [100, 0, 100, 0, 100]],k = 5) == 70\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]],k = 11) == 5\n assert candidate(grid = [[37, 37, 37, 37, 37, 37, 37, 37, 37, 37], [37, 37, 37, 37, 37, 37, 37, 37, 37, 37], [37, 37, 37, 37, 37, 37, 37, 37, 37, 37], [37, 37, 37, 37, 37, 37, 37, 37, 37, 37], [37, 37, 37, 37, 37, 37, 37, 37, 37, 37]],k = 47) == 0\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 = 2) == 70\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]],k = 19) == 3\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 10], [10, 8, 6, 4, 2, 0]],k = 4) == 14\n assert candidate(grid = [[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]],k = 7) == 10\n assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]],k = 27) == 1\n"}, "metadata": {"canonical_parameter_names": ["grid", "k"], "leetcode_dataset_entry_point": "Solution().numberOfPaths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfPaths(int[][] grid, int k) {", "container": "Solution", "callable": "numberOfPaths", "parameters": [{"name": "grid", "type": "int[][]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2437, "task_id": "number-of-valid-clock-times", "difficulty": "Easy", "problem_description": "You are given a string of length 5 called time, representing the current time on a digital clock in the format \"hh:mm\". The earliest possible time is \"00:00\" and the latest possible time is \"23:59\".\nIn the string time, the digits represented by the ? symbol are unknown, and must be replaced with a digit from 0 to 9.\nReturn an integer answer, the number of valid clock times that can be created by replacing every ? with a digit from 0 to 9.\n \nExample 1:\n\nInput: time = \"?5:00\"\nOutput: 2\nExplanation: We can replace the ? with either a 0 or 1, producing \"05:00\" or \"15:00\". Note that we cannot replace it with a 2, since the time \"25:00\" is invalid. In total, we have two choices.\n\nExample 2:\n\nInput: time = \"0?:0?\"\nOutput: 100\nExplanation: Each ? can be replaced by any digit from 0 to 9, so we have 100 total choices.\n\nExample 3:\n\nInput: time = \"??:??\"\nOutput: 1440\nExplanation: There are 24 possible choices for the hours, and 60 possible choices for the minutes. In total, we have 24 * 60 = 1440 choices.\n\n \nConstraints:\n\ntime is a valid string of length 5 in the format \"hh:mm\".\n\"00\" <= hh <= \"23\"\n\"00\" <= mm <= \"59\"\nSome of the digits might be replaced with '?' and need to be replaced with digits from 0 to 9.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(time = \"23:?0\") == 6\n assert candidate(time = \"23:5?\") == 10\n assert candidate(time = \"09:5?\") == 10\n assert candidate(time = \"23:?9\") == 6\n assert candidate(time = \"1?:?0\") == 60\n assert candidate(time = \"00:??\") == 60\n assert candidate(time = \"1?:?5\") == 60\n assert candidate(time = \"0?:0?\") == 100\n assert candidate(time = \"?3:59\") == 3\n assert candidate(time = \"1?:2?\") == 100\n assert candidate(time = \"09:?9\") == 6\n assert candidate(time = \"??:??\") == 1440\n assert candidate(time = \"00:00\") == 1\n assert candidate(time = \"23:59\") == 1\n assert candidate(time = \"1?:30\") == 10\n assert candidate(time = \"2?:45\") == 4\n assert candidate(time = \"1?:5?\") == 100\n assert candidate(time = \"12:??\") == 60\n assert candidate(time = \"2?:4?\") == 40\n assert candidate(time = \"1??:3?\") == 0\n assert candidate(time = \"?3:21\") == 3\n assert candidate(time = \"1?:45\") == 10\n assert candidate(time = \"1?:?1\") == 60\n assert candidate(time = \"12:?5\") == 6\n assert candidate(time = \"1?:3?\") == 100\n assert candidate(time = \"09:??\") == 60\n assert candidate(time = \"12:?3\") == 6\n assert candidate(time = \"??:59\") == 24\n assert candidate(time = \"?5:00\") == 2\n assert candidate(time = \"2?:3?\") == 40\n assert candidate(time = \"??:45\") == 24\n assert candidate(time = \"?4:??\") == 120\n assert candidate(time = \"19:?5\") == 6\n assert candidate(time = \"2?:15\") == 4\n assert candidate(time = \"2?:?3\") == 24\n assert candidate(time = \"???:30\") == 0\n assert candidate(time = \"23:?5\") == 6\n assert candidate(time = \"23:?7\") == 6\n assert candidate(time = \"??:2?\") == 240\n assert candidate(time = \"0?:??:\") == 600\n assert candidate(time = \"??:00\") == 24\n assert candidate(time = \"19:?7\") == 6\n assert candidate(time = \"2?:59\") == 4\n assert candidate(time = \"2?:1?\") == 40\n assert candidate(time = \"19:?1\") == 6\n assert candidate(time = \"22:?8\") == 6\n assert candidate(time = \"?4:3?\") == 20\n assert candidate(time = \"0?:?9\") == 60\n assert candidate(time = \"?3:?1\") == 18\n assert candidate(time = \"1?:??\") == 600\n assert candidate(time = \"??:3?\") == 240\n assert candidate(time = \"??:?1\") == 144\n assert candidate(time = \"12:?7\") == 6\n assert candidate(time = \"2?:35\") == 4\n assert candidate(time = \"0??:59\") == 0\n assert candidate(time = \"2?:?0\") == 24\n assert candidate(time = \"09:?5\") == 6\n assert candidate(time = \"???:??\") == 0\n assert candidate(time = \"?0:5?\") == 30\n assert candidate(time = \"0?:3?\") == 100\n assert candidate(time = \"1?:?9\") == 60\n assert candidate(time = \"12:?9\") == 6\n assert candidate(time = \"?3:45\") == 3\n assert candidate(time = \"19:??\") == 60\n assert candidate(time = \"19:?4\") == 6\n assert candidate(time = \"23:?4\") == 6\n assert candidate(time = \"?1:??\") == 180\n assert candidate(time = \"?3:?0\") == 18\n assert candidate(time = \"0?:?5\") == 60\n assert candidate(time = \"0?:4?\") == 100\n assert candidate(time = \"2?:5?\") == 40\n assert candidate(time = \"??:10\") == 24\n assert candidate(time = \"0?:?3\") == 60\n assert candidate(time = \"19:?0\") == 6\n assert candidate(time = \"2?:?5\") == 24\n assert candidate(time = \"2?:40\") == 4\n assert candidate(time = \"19:?9\") == 6\n assert candidate(time = \"1?:0?\") == 100\n assert candidate(time = \"???:00\") == 0\n assert candidate(time = \"2?:22\") == 4\n assert candidate(time = \"0?:5?\") == 100\n assert candidate(time = \"1??:0?\") == 0\n assert candidate(time = \"0?:30\") == 10\n assert candidate(time = \"2?:?4\") == 24\n assert candidate(time = \"21:??\") == 60\n assert candidate(time = \"20:?7\") == 6\n assert candidate(time = \"?4:?3\") == 12\n assert candidate(time = \"2?:00\") == 4\n assert candidate(time = \"09:4?\") == 10\n assert candidate(time = \"?9:??\") == 120\n assert candidate(time = \"1?:?7\") == 60\n assert candidate(time = \"0?:59\") == 10\n assert candidate(time = \"0?:??\") == 600\n assert candidate(time = \"0?:?0\") == 60\n assert candidate(time = \"?4:5?\") == 20\n assert candidate(time = \"?2:??\") == 180\n assert candidate(time = \"1?:59\") == 10\n assert candidate(time = \"0?:1?\") == 100\n assert candidate(time = \"2?:??:\") == 240\n assert candidate(time = \"1??:??\") == 0\n assert candidate(time = \"?:09\") == 0\n assert candidate(time = \"?9:0?\") == 20\n assert candidate(time = \"2?:?2\") == 24\n assert candidate(time = \"?1:?2\") == 18\n assert candidate(time = \"2?:?9\") == 24\n assert candidate(time = \"0?:19\") == 10\n assert candidate(time = \"??:0?\") == 240\n assert candidate(time = \"?4:?9\") == 12\n assert candidate(time = \"20:??\") == 60\n assert candidate(time = \"??:30\") == 24\n assert candidate(time = \"1?:??:\") == 600\n assert candidate(time = \"?4:2?\") == 20\n assert candidate(time = \"1?:23\") == 10\n assert candidate(time = \"2?:2?\") == 40\n"}, "metadata": {"canonical_parameter_names": ["time"], "leetcode_dataset_entry_point": "Solution().countTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countTime(String time) {", "container": "Solution", "callable": "countTime", "parameters": [{"name": "time", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2438, "task_id": "range-product-queries-of-powers", "difficulty": "Medium", "problem_description": "Given a positive integer n, there exists a 0-indexed array called powers, composed of the minimum number of powers of 2 that sum to n. The array is sorted in non-decreasing order, and there is only one way to form the array.\nYou are also given a 0-indexed 2D integer array queries, where queries[i] = [lefti, righti]. Each queries[i] represents a query where you have to find the product of all powers[j] with lefti <= j <= righti.\nReturn an array answers, equal in length to queries, where answers[i] is the answer to the ith query. Since the answer to the ith query may be too large, each answers[i] should be returned modulo 109 + 7.\n \nExample 1:\n\nInput: n = 15, queries = [[0,1],[2,2],[0,3]]\nOutput: [2,4,64]\nExplanation:\nFor n = 15, powers = [1,2,4,8]. It can be shown that powers cannot be a smaller size.\nAnswer to 1st query: powers[0] * powers[1] = 1 * 2 = 2.\nAnswer to 2nd query: powers[2] = 4.\nAnswer to 3rd query: powers[0] * powers[1] * powers[2] * powers[3] = 1 * 2 * 4 * 8 = 64.\nEach answer modulo 109 + 7 yields the same answer, so [2,4,64] is returned.\n\nExample 2:\n\nInput: n = 2, queries = [[0,0]]\nOutput: [2]\nExplanation:\nFor n = 2, powers = [2].\nThe answer to the only query is powers[0] = 2. The answer modulo 109 + 7 is the same, so [2] is returned.\n\n \nConstraints:\n\n1 <= n <= 109\n1 <= queries.length <= 105\n0 <= starti <= endi < powers.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,queries = [[0, 0], [1, 1], [0, 2]]) == [2, 8, 16]\n assert candidate(n = 1023,queries = [[0, 9], [3, 5]]) == [371842544, 4096]\n assert candidate(n = 1023,queries = [[0, 9], [4, 5], [2, 8]]) == [371842544, 512, 359738130]\n assert candidate(n = 100,queries = [[0, 0], [1, 2], [2, 2]]) == [4, 2048, 64]\n assert candidate(n = 29,queries = [[0, 2], [1, 3]]) == [32, 512]\n assert candidate(n = 5,queries = [[0, 1], [0, 2], [1, 2]]) == [4, 4, 4]\n assert candidate(n = 1023,queries = [[0, 9], [3, 5], [6, 8]]) == [371842544, 4096, 2097152]\n assert candidate(n = 8,queries = [[0, 2], [1, 1], [0, 3]]) == [8, 1, 8]\n assert candidate(n = 1023,queries = [[0, 9], [2, 6], [0, 8]]) == [371842544, 1048576, 719476260]\n assert candidate(n = 1023,queries = [[0, 9], [1, 3], [5, 7]]) == [371842544, 64, 262144]\n assert candidate(n = 255,queries = [[0, 7], [3, 5], [1, 2]]) == [268435456, 4096, 8]\n assert candidate(n = 5,queries = [[0, 0], [0, 1], [0, 2]]) == [1, 4, 4]\n assert candidate(n = 1000000000,queries = [[0, 29]]) == [371048337]\n assert candidate(n = 15,queries = [[0, 1], [2, 2], [0, 3]]) == [2, 4, 64]\n assert candidate(n = 2,queries = [[0, 0]]) == [2]\n assert candidate(n = 134217727,queries = [[0, 26], [10, 15], [20, 25]]) == [867243987, 640520040, 792931211]\n assert candidate(n = 8388607,queries = [[0, 22], [12, 17], [20, 21], [0, 5], [18, 22]]) == [349105660, 570065479, 23240159, 32768, 976371285]\n assert candidate(n = 1024,queries = [[0, 9], [4, 4], [2, 2], [8, 8], [0, 0]]) == [1024, 1, 1, 1, 1024]\n assert candidate(n = 1048575,queries = [[0, 19], [5, 10], [15, 18]]) == [953612746, 371842544, 329376018]\n assert candidate(n = 65535,queries = [[0, 15], [4, 7], [10, 13], [0, 15]]) == [489373567, 4194304, 743685088, 489373567]\n assert candidate(n = 1073741823,queries = [[0, 29], [16, 22], [24, 29]]) == [549790477, 948232808, 106966330]\n assert candidate(n = 999999935,queries = [[0, 29], [10, 20], [15, 25], [5, 15], [0, 29]]) == [756589216, 355395742, 948232808, 711461273, 756589216]\n assert candidate(n = 999999935,queries = [[0, 29], [10, 16], [20, 26]]) == [756589216, 990388602, 1]\n assert candidate(n = 1048575,queries = [[0, 19], [10, 15], [5, 10], [18, 19]]) == [953612746, 640520040, 371842544, 438952513]\n assert candidate(n = 1000000000,queries = [[0, 29], [15, 20], [30, 30]]) == [371048337, 1, 1]\n assert candidate(n = 16777215,queries = [[0, 23], [14, 18], [6, 9], [12, 15], [0, 23]]) == [511821710, 496641140, 73741817, 383381198, 511821710]\n assert candidate(n = 524287,queries = [[0, 18], [7, 12], [3, 8], [0, 19]]) == [134084614, 67049563, 589934536, 134084614]\n assert candidate(n = 2147483647,queries = [[0, 30], [14, 20], [7, 13], [0, 29]]) == [459478873, 744686787, 270016253, 549790477]\n assert candidate(n = 1234567,queries = [[0, 20], [7, 12], [3, 8]]) == [975523612, 329376018, 658752036]\n assert candidate(n = 67108863,queries = [[0, 25], [12, 19], [6, 11], [0, 24]]) == [217770278, 829977023, 797922655, 322050759]\n assert candidate(n = 2147483647,queries = [[0, 29], [5, 10], [15, 20], [0, 29], [10, 15]]) == [549790477, 371842544, 243880903, 549790477, 640520040]\n assert candidate(n = 524287,queries = [[0, 18], [5, 8], [10, 15], [17, 18], [0, 19]]) == [134084614, 67108864, 640520040, 359738130, 134084614]\n assert candidate(n = 999999935,queries = [[0, 29], [10, 20], [15, 25], [5, 15]]) == [756589216, 355395742, 948232808, 711461273]\n assert candidate(n = 65535,queries = [[0, 15], [7, 10], [3, 7], [0, 14], [12, 15]]) == [489373567, 179869065, 33554432, 243880903, 383381198]\n assert candidate(n = 1024,queries = [[0, 0], [0, 9], [1, 8]]) == [1024, 1024, 1]\n assert candidate(n = 1047552,queries = [[0, 19], [5, 12], [15, 18]]) == [961554387, 892516375, 1]\n assert candidate(n = 1048575,queries = [[0, 19], [10, 15], [5, 14], [0, 20]]) == [953612746, 640520040, 936761609, 953612746]\n assert candidate(n = 524287,queries = [[0, 18], [4, 9], [10, 15]]) == [134084614, 755810045, 640520040]\n assert candidate(n = 131071,queries = [[0, 16], [6, 10], [8, 12], [14, 16]]) == [585862415, 511620083, 898961331, 371842544]\n assert candidate(n = 536870911,queries = [[0, 28], [3, 8], [12, 17], [0, 28], [8, 13]]) == [733922348, 589934536, 570065479, 733922348, 291172004]\n assert candidate(n = 5,queries = [[0, 0], [1, 1], [0, 1]]) == [1, 4, 4]\n assert candidate(n = 4194303,queries = [[0, 21], [4, 9], [12, 16], [3, 8], [0, 21]]) == [686331837, 755810045, 270016253, 589934536, 686331837]\n assert candidate(n = 1,queries = [[0, 0]]) == [1]\n assert candidate(n = 2147483647,queries = [[0, 30], [18, 24], [26, 30]]) == [459478873, 846217527, 373798577]\n assert candidate(n = 65535,queries = [[0, 15], [3, 7], [9, 12], [0, 15], [8, 11]]) == [489373567, 33554432, 46480318, 489373567, 877905026]\n assert candidate(n = 65535,queries = [[0, 15], [5, 10], [10, 15], [0, 15]]) == [489373567, 371842544, 640520040, 489373567]\n assert candidate(n = 536870911,queries = [[0, 28], [14, 20], [22, 28]]) == [733922348, 744686787, 145353810]\n assert candidate(n = 8388607,queries = [[0, 22], [6, 12], [14, 18]]) == [349105660, 291172004, 496641140]\n assert candidate(n = 511,queries = [[0, 8], [3, 7], [1, 4], [0, 9]]) == [719476260, 33554432, 1024, 719476260]\n assert candidate(n = 3,queries = [[0, 0], [0, 1], [1, 1]]) == [1, 2, 2]\n assert candidate(n = 134217727,queries = [[0, 26], [5, 13], [18, 23], [10, 17], [0, 26]]) == [867243987, 993282280, 914988515, 951047217, 867243987]\n assert candidate(n = 4294967295,queries = [[0, 31], [15, 25], [8, 20], [0, 32], [5, 12], [20, 24]]) == [461905191, 112151530, 605287554, 461905191, 317504065, 804188847]\n assert candidate(n = 16777215,queries = [[0, 23], [5, 10], [15, 18]]) == [511821710, 371842544, 329376018]\n assert candidate(n = 524287,queries = [[0, 18], [7, 12], [3, 8]]) == [134084614, 67049563, 589934536]\n assert candidate(n = 4194303,queries = [[0, 21], [13, 17], [20, 21], [5, 10], [0, 21]]) == [686331837, 640520040, 23240159, 371842544, 686331837]\n assert candidate(n = 33554431,queries = [[0, 24], [12, 19], [6, 15], [0, 25], [3, 8], [10, 13]]) == [322050759, 829977023, 243880903, 322050759, 589934536, 743685088]\n assert candidate(n = 2097151,queries = [[0, 20], [8, 12], [16, 20], [10, 15], [0, 20]]) == [431750151, 898961331, 560523804, 640520040, 431750151]\n assert candidate(n = 33554431,queries = [[0, 24], [16, 20], [8, 11], [2, 5], [0, 24]]) == [322050759, 560523804, 877905026, 16384, 322050759]\n assert candidate(n = 2147483647,queries = [[0, 30], [20, 25], [15, 19], [10, 13], [0, 30]]) == [459478873, 792931211, 892516375, 743685088, 459478873]\n assert candidate(n = 8388607,queries = [[0, 22], [11, 16], [4, 8], [0, 21]]) == [349105660, 993282280, 73741817, 686331837]\n assert candidate(n = 4194303,queries = [[0, 21], [10, 15], [18, 20], [5, 8], [0, 21]]) == [686331837, 640520040, 67049563, 67108864, 686331837]\n assert candidate(n = 536870911,queries = [[0, 28], [12, 18], [20, 25], [0, 29]]) == [733922348, 243880903, 792931211, 733922348]\n assert candidate(n = 33554431,queries = [[0, 24], [8, 13], [16, 20]]) == [322050759, 291172004, 560523804]\n assert candidate(n = 1000000000,queries = [[0, 29], [10, 20], [15, 25]]) == [371048337, 946258191, 1]\n assert candidate(n = 8388607,queries = [[0, 22], [7, 11], [14, 18], [2, 6], [0, 22]]) == [349105660, 371842544, 496641140, 1048576, 349105660]\n assert candidate(n = 8388607,queries = [[0, 22], [8, 13], [16, 20]]) == [349105660, 291172004, 560523804]\n assert candidate(n = 1048575,queries = [[0, 19], [10, 15], [5, 18]]) == [953612746, 640520040, 427865320]\n assert candidate(n = 511,queries = [[0, 8], [3, 6], [1, 7]]) == [719476260, 262144, 268435456]\n assert candidate(n = 34359738367,queries = [[0, 34], [17, 22], [25, 30], [0, 35]]) == [363951854, 936171702, 845845078, 363951854]\n assert candidate(n = 33554431,queries = [[0, 24], [12, 18], [5, 10], [0, 9], [20, 24]]) == [322050759, 243880903, 371842544, 371842544, 804188847]\n assert candidate(n = 131071,queries = [[0, 16], [8, 12], [0, 0], [15, 16]]) == [585862415, 898961331, 1, 147483634]\n assert candidate(n = 8388607,queries = [[0, 22], [9, 16], [5, 11], [0, 23], [2, 7]]) == [349105660, 976371285, 533524785, 349105660, 134217728]\n assert candidate(n = 1048576,queries = [[0, 19], [5, 10], [15, 20]]) == [1048576, 1, 1]\n assert candidate(n = 255,queries = [[0, 7], [3, 6], [1, 5], [0, 0], [7, 7]]) == [268435456, 262144, 32768, 1, 128]\n assert candidate(n = 8388607,queries = [[0, 22], [11, 14], [20, 22], [15, 18], [0, 22]]) == [349105660, 898961331, 291172004, 329376018, 349105660]\n assert candidate(n = 500000000,queries = [[0, 28], [10, 20], [5, 15]]) == [885909558, 993282280, 369201595]\n assert candidate(n = 134217727,queries = [[0, 26], [10, 16], [18, 24]]) == [867243987, 121047601, 846217527]\n assert candidate(n = 524287,queries = [[0, 18], [3, 8], [12, 15], [0, 19]]) == [134084614, 589934536, 383381198, 134084614]\n assert candidate(n = 524287,queries = [[0, 18], [3, 7], [9, 14], [0, 17]]) == [134084614, 33554432, 635008130, 157921350]\n assert candidate(n = 1048575,queries = [[0, 19], [9, 15], [5, 10], [0, 18], [17, 19]]) == [953612746, 946258191, 371842544, 134084614, 383381198]\n assert candidate(n = 8388607,queries = [[0, 22], [10, 15], [5, 18]]) == [349105660, 640520040, 427865320]\n assert candidate(n = 7,queries = [[0, 0], [0, 1], [0, 2], [1, 2], [2, 2]]) == [1, 2, 8, 8, 4]\n assert candidate(n = 134217727,queries = [[0, 26], [13, 18], [8, 12], [0, 27], [4, 9]]) == [867243987, 484190404, 898961331, 867243987, 755810045]\n assert candidate(n = 1073741823,queries = [[0, 29], [10, 19], [15, 24], [5, 14], [0, 29]]) == [549790477, 961554387, 515607662, 936761609, 549790477]\n assert candidate(n = 67108863,queries = [[0, 25], [8, 14], [16, 22]]) == [217770278, 562080146, 948232808]\n assert candidate(n = 1000000000,queries = [[0, 29], [15, 20], [10, 14], [0, 9], [25, 29]]) == [371048337, 1, 946258191, 581415240, 1]\n assert candidate(n = 999999999,queries = [[0, 29], [10, 15], [20, 25]]) == [421709488, 951047217, 536870912]\n assert candidate(n = 17592186044415,queries = [[0, 41], [20, 28], [30, 35], [0, 42], [15, 25]]) == [342742191, 632009475, 515607662, 918181383, 112151530]\n assert candidate(n = 268435455,queries = [[0, 27], [12, 18], [20, 26]]) == [742004924, 243880903, 427865320]\n assert candidate(n = 1073741823,queries = [[0, 29], [18, 23], [9, 12], [0, 5], [25, 29]]) == [549790477, 914988515, 46480318, 32768, 792931211]\n"}, "metadata": {"canonical_parameter_names": ["n", "queries"], "leetcode_dataset_entry_point": "Solution().productQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] productQueries(int n, int[][] queries) {", "container": "Solution", "callable": "productQueries", "parameters": [{"name": "n", "type": "int"}, {"name": "queries", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2439, "task_id": "minimize-maximum-of-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums comprising of n non-negative integers.\nIn one operation, you must:\n\nChoose an integer i such that 1 <= i < n and nums[i] > 0.\nDecrease nums[i] by 1.\nIncrease nums[i - 1] by 1.\n\nReturn the minimum possible value of the maximum integer of nums after performing any number of operations.\n \nExample 1:\n\nInput: nums = [3,7,1,6]\nOutput: 5\nExplanation:\nOne set of optimal operations is as follows:\n1. Choose i = 1, and nums becomes [4,6,1,6].\n2. Choose i = 3, and nums becomes [4,6,2,5].\n3. Choose i = 1, and nums becomes [5,5,2,5].\nThe maximum integer of nums is 5. It can be shown that the maximum number cannot be less than 5.\nTherefore, we return 5.\n\nExample 2:\n\nInput: nums = [10,1]\nOutput: 10\nExplanation:\nIt is optimal to leave nums as is, and since 10 is the maximum value, we return 10.\n\n \nConstraints:\n\nn == nums.length\n2 <= n <= 105\n0 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 9, 1, 9, 1]) == 5\n assert candidate(nums = [1, 1000000000]) == 500000001\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n assert candidate(nums = [9, 7, 5, 3, 1]) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1000000000, 1000000000]) == 1000000000\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 3\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1]) == 500000001\n assert candidate(nums = [1, 2, 1000000000, 2, 1]) == 333333335\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1000000000, 0, 0, 0, 0]) == 1000000000\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 1000000000, 1, 1, 1]) == 500000001\n assert candidate(nums = [1, 1000000000, 1]) == 500000001\n assert candidate(nums = [10, 1]) == 10\n assert candidate(nums = [3, 7, 1, 6]) == 5\n assert candidate(nums = [1000000000, 1]) == 1000000000\n assert candidate(nums = [500, 450, 400, 350, 300, 250, 200, 150, 100, 50]) == 500\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]) == 5\n assert candidate(nums = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 550\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 103\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\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\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\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\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\n assert candidate(nums = [10, 20, 30, 40, 50]) == 30\n assert candidate(nums = [1, 999999999, 2, 999999998, 3, 999999997, 4, 999999996, 5]) == 500000000\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\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000]) == 47619048\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\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 1000000000\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\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1000000000]) == 100000005\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 3\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000]) == 3000000000\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\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\n assert candidate(nums = [1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1000000000\n assert candidate(nums = [5, 3, 8, 2, 9, 1]) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 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, 1000000000]) == 47619049\n assert candidate(nums = [0, 0, 0, 0, 0, 1000000000]) == 166666667\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 28\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 100000001\n assert candidate(nums = [999999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 999999999\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 1000000000\n assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 20\n assert candidate(nums = [100, 50, 10, 5, 1, 0, 0, 0, 0, 0]) == 100\n assert candidate(nums = [5000000000, 4000000000, 3000000000, 2000000000, 1000000000]) == 5000000000\n assert candidate(nums = [0, 1000000000, 0, 0, 0, 0, 0, 0, 0, 0]) == 500000000\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\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\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 11\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000]) == 50000000\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 19\n assert candidate(nums = [100, 10, 1, 1, 1, 1, 1, 1, 1, 1]) == 100\n assert candidate(nums = [1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1000000000\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]) == 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\n assert candidate(nums = [0, 1000000000, 0, 1000000000, 0, 1000000000, 0]) == 500000000\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 111111112\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000000\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 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, 21, 22, 23, 24, 25]) == 13\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 50000001\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]) == 10\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 1000\n assert candidate(nums = [1, 999999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 500000000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 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]) == 105\n assert candidate(nums = [10, 20, 30, 40, 50]) == 30\n assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == 275\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 11\n assert candidate(nums = [1, 2, 100, 4, 5, 6, 7, 8, 9, 10]) == 35\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]) == 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]) == 11\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == 1000000000\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 100\n assert candidate(nums = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000]) == 100000000\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 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 100\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 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000]) == 100000000\n assert candidate(nums = [333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333]) == 333333333\n assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == 168\n assert candidate(nums = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000000\n assert candidate(nums = [999999999, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 999999999\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 1000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 55\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, 0]) == 30\n assert candidate(nums = [1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1000000000\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, 1000000000]) == 31250001\n assert candidate(nums = [5, 3, 8, 12, 2]) == 7\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 = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 500\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1000]) == 105\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 6\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimizeArrayValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimizeArrayValue(int[] nums) {", "container": "Solution", "callable": "minimizeArrayValue", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2440, "task_id": "create-components-with-same-value", "difficulty": "Hard", "problem_description": "There is an undirected tree with n nodes labeled from 0 to n - 1.\nYou are given a 0-indexed integer array nums of length n where nums[i] represents the value of the ith node. You are also 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 allowed to delete some edges, splitting the tree into multiple connected components. Let the value of a component be the sum of all nums[i] for which node i is in the component.\nReturn the maximum number of edges you can delete, such that every connected component in the tree has the same value.\n \nExample 1:\n\n\nInput: nums = [6,2,2,2,6], edges = [[0,1],[1,2],[1,3],[3,4]] \nOutput: 2 \nExplanation: The above figure shows how we can delete the edges [0,1] and [3,4]. The created components are nodes [0], [1,2,3] and [4]. The sum of the values in each component equals 6. It can be proven that no better deletion exists, so the answer is 2.\n\nExample 2:\n\nInput: nums = [2], edges = []\nOutput: 0\nExplanation: There are no edges to be deleted.\n\n \nConstraints:\n\n1 <= n <= 2 * 104\nnums.length == n\n1 <= nums[i] <= 50\nedges.length == n - 1\nedges[i].length == 2\n0 <= edges[i][0], edges[i][1] <= n - 1\nedges represents a valid tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3]]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5]]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5]]) == 5\n assert candidate(nums = [4, 4, 4, 4, 4, 4],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5]]) == 5\n assert candidate(nums = [10, 10, 10, 10],edges = [[0, 1], [1, 2], [1, 3]]) == 3\n assert candidate(nums = [3, 2, 6, 1, 3],edges = [[0, 1], [1, 2], [1, 3], [3, 4]]) == 0\n assert candidate(nums = [3, 3, 3, 9, 3],edges = [[0, 1], [1, 2], [1, 3], [1, 4]]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == 7\n assert candidate(nums = [7, 7, 7, 7, 7, 7],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5]]) == 5\n assert candidate(nums = [4, 4, 4, 4, 4, 4],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n assert candidate(nums = [6, 2, 2, 2, 6],edges = [[0, 1], [1, 2], [1, 3], [3, 4]]) == 2\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n assert candidate(nums = [2],edges = []) == 0\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5]]) == 0\n assert candidate(nums = [1, 2, 3, 6, 2, 2, 2, 6],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [3, 6], [0, 7]]) == 1\n assert candidate(nums = [15, 10, 5, 5, 10, 10, 10, 5, 10, 10],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9]]) == 2\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 9\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],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]]) == 19\n assert candidate(nums = [1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [0, 6], [6, 7], [6, 8], [8, 9], [9, 10], [8, 11], [7, 12], [12, 13], [12, 14], [14, 15], [14, 16], [6, 17], [17, 18], [17, 19]]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9]]) == 9\n assert candidate(nums = [5, 10, 5, 10, 5, 10, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 1\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 0\n assert candidate(nums = [10, 15, 15, 10, 20, 20, 10, 30],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7]]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],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]]) == 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],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]]) == 19\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],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], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49]]) == 62\n assert candidate(nums = [15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10],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]]) == 0\n assert candidate(nums = [12, 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, 3, 3, 3, 3, 3, 3, 3],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]]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 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],edges = [[0, 1], [1, 2], [1, 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(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],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\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, 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, 4, 4, 4, 4],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]]) == 63\n assert candidate(nums = [10, 10, 5, 5, 5, 5, 10, 5, 5, 5, 5, 10],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [0, 8], [8, 9], [8, 10], [9, 11]]) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],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]]) == 19\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == 0\n assert candidate(nums = [3, 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, 3, 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, 3, 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],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]]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 0\n assert candidate(nums = [10, 5, 5, 2, 2, 2, 10, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]]) == 0\n assert candidate(nums = [2, 4, 8, 8, 8, 16, 16, 16, 16],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8]]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]]) == 9\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],edges = [[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(nums = [20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [5, 17], [6, 18], [7, 19]]) == 0\n assert candidate(nums = [6, 3, 3, 2, 2, 2, 6],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [0, 6]]) == 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],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 9], [2, 10], [2, 11], [2, 12], [3, 13], [3, 14], [3, 15], [3, 16], [4, 17], [4, 18], [4, 19], [4, 20], [5, 21], [5, 22], [5, 23], [6, 24], [6, 25], [6, 26], [7, 27], [7, 28], [7, 29], [8, 30], [8, 31], [8, 32], [9, 33], [9, 34], [9, 35], [10, 36], [10, 37], [10, 38], [11, 39], [11, 40], [11, 41], [12, 42], [12, 43], [12, 44], [13, 45], [13, 46], [13, 47], [14, 48], [14, 49], [14, 50]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "edges"], "leetcode_dataset_entry_point": "Solution().componentValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int componentValue(int[] nums, int[][] edges) {", "container": "Solution", "callable": "componentValue", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "edges", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2441, "task_id": "largest-positive-integer-that-exists-with-its-negative", "difficulty": "Easy", "problem_description": "Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array.\nReturn the positive integer k. If there is no such integer, return -1.\n \nExample 1:\n\nInput: nums = [-1,2,-3,3]\nOutput: 3\nExplanation: 3 is the only valid k we can find in the array.\n\nExample 2:\n\nInput: nums = [-1,10,6,7,-7,1]\nOutput: 7\nExplanation: Both 1 and 7 have their corresponding negative values in the array. 7 has a larger value.\n\nExample 3:\n\nInput: nums = [-10,8,6,7,-2,-3]\nOutput: -1\nExplanation: There is no a single valid k, we return -1.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-1000 <= nums[i] <= 1000\nnums[i] != 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, -4, -3, -2]) == 4\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250, 125, -125]) == 1000\n assert candidate(nums = [5, 4, 3, 2, 1, -1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, -5, -4, -3, -2, -1]) == 5\n assert candidate(nums = [0, 1, -1]) == 1\n assert candidate(nums = [-1]) == -1\n assert candidate(nums = [1]) == -1\n assert candidate(nums = [-5, -4, -3, -2, -1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [100, 200, -100, -200, 300, 400]) == 200\n assert candidate(nums = [1000, -1000]) == 1000\n assert candidate(nums = [-100, -99, -98, 98, 99, 100]) == 100\n assert candidate(nums = [-10, 8, 6, 7, -2, -3]) == -1\n assert candidate(nums = [999, -999, 500, -500, 250, -250]) == 999\n assert candidate(nums = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250]) == 1000\n assert candidate(nums = [1, 2, 3, -2, -1]) == 2\n assert candidate(nums = [1, 2, -2, 3, -3, 4, -4]) == 4\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 5\n assert candidate(nums = [-1, 10, 6, 7, -7, 1]) == 7\n assert candidate(nums = [-1, 2, -3, 3]) == 3\n assert candidate(nums = [-999, 999, -998, 998, -997, 997, -996, 996, -995, 995, -994, 994, -993, 993, -992, 992, -991, 991, -990, 990]) == 999\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, 17, 18, 19, 20]) == 5\n assert candidate(nums = [1, -1, 1000, -1000, 500, -500, 250, -250, 125, -125, 625, -625, 312, -312, 156, -156, 78, -78, 39, -39]) == 1000\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]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 9\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, 95, 96, 97, 98, 99, 100]) == 100\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100]) == 100\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 = [50, -50, 23, -23, 47, -47, 38, -38, 19, -19, 11, -11, 7, -7, 3, -3, 1, -1]) == 50\n assert candidate(nums = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995, 994, -994]) == 999\n assert candidate(nums = [-1, -2, -3, -4, -5, 6, 7, 8, 9, 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]) == 50\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, 170, -170, 180, -180, 190, -190, 200, -200]) == 200\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, -6, 7, -7, 8, -8, 9, -9]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -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, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15]) == 15\n assert candidate(nums = [999, -999, 500, -500, 250, -250, 125, -125]) == 999\n assert candidate(nums = [100, -100, 99, -99, 98, -98, 97, -97, 96, -96, 95, -95, 94, -94, 93, -93, 92, -92, 91, -91]) == 100\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 = [-100, 100, 50, -50, 25, -25, 12, -12, 6, -6]) == 100\n assert candidate(nums = [42, -42, 24, -24, 36, -36, 48, -48, 60, -60, 72, -72, 84, -84, 96, -96, 108, -108, 120, -120]) == 120\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900]) == 900\n assert candidate(nums = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == -1\n assert candidate(nums = [7, -7, 14, -14, 21, -21, 28, -28, 35, -35, 42, -42, 49, -49, 56, -56, 63, -63, 70, -70, 77, -77, 84, -84]) == 84\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, -1, -3, -5, -7, -9, -11, -13, -15, -17, -19]) == 19\n assert candidate(nums = [10, 20, 30, -10, -20, -30, 40, 50, -40, -50, 60, -60, 70]) == 60\n assert candidate(nums = [-500, 500, 250, -250, 125, -125, 625, -625]) == 625\n assert candidate(nums = [500, -500, 250, -250, 125, -125, 62, -62, 31, -31, 15, -15, 7, -7, 3, -3, 1, -1]) == 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]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10, -6, -7, -8, -9, -10, 11, 12, 13, 14, 15, -11, -12, -13, -14, -15]) == 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, -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 = [-1000, 1000, -999, 999, -998, 998, -1, 1]) == 1000\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 150, -150, 250, -250, 350, -350]) == 500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15]) == 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]) == -1\n assert candidate(nums = [-500, 500, -400, 400, -300, 300, -200, 200, -100, 100, 0, 1, -1]) == 500\n assert candidate(nums = [999, 998, 997, 996, 995, -999, -998, -997, -996, -995, 994, 993, 992, 991, -994, -993, -992, -991]) == 999\n assert candidate(nums = [-500, 500, -499, 499, -498, 498, -1, 1, 2, -2]) == 500\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]) == 10\n assert candidate(nums = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995, 994, -994, 993, -993]) == 999\n assert candidate(nums = [-500, 500, -499, 499, -200, 200, 100, -100, 50, -50, 1, -1]) == 500\n assert candidate(nums = [7, -7, 14, -14, 21, -21, 28, -28, 35, -35, 42, -42, 49, -49, 56, -56]) == 56\n assert candidate(nums = [2, -2, 4, -4, 6, -6, 8, -8, 10, -10, 12, -12, 14, -14, 16, -16, 18, -18, 20, -20, 22, -22, 24, -24, 26, -26]) == 26\n assert candidate(nums = [-333, 333, -222, 222, -111, 111, 444, -444, 555, -555, 666, -666, 777, -777, 888, -888, 999]) == 888\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50, 60, 65, 70, 75, -60, -65, -70, -75]) == 75\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500, -600, 600, -700, 700, -800, 800, -900, 900, -1000, 1000]) == 1000\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85, 95, -95, 105, -105, 115, -115]) == 115\n assert candidate(nums = [123, -123, 456, -456, 789, -789, 101112, -101112, 131415, -131415, 161718, -161718, 192021, -192021, 222324, -222324]) == 222324\n assert candidate(nums = [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]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10, -6, -7, -8, -9, -10]) == 10\n assert candidate(nums = [-500, 500, 250, -250, 125, -125, 62, -62]) == 500\n assert candidate(nums = [100, 200, 300, 400, -100, -200, -300, -400, 500, -500]) == 500\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]) == 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, -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]) == 15\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]) == 120\n assert candidate(nums = [-500, 500, 250, -250, 125, -125, 625, -625, 312, -312]) == 625\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90]) == 90\n assert candidate(nums = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995]) == 999\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, -109, -108, -107, -106, -105, -104, -103, -102, -101]) == 109\n assert candidate(nums = [-100, 100, -50, 50, -25, 25, -10, 10]) == 100\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50, 60, -60, 70, -70, 80, -80, 90, -90]) == 90\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\n assert candidate(nums = [-100, 100, -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]) == 100\n assert candidate(nums = [200, -200, 150, -150, 100, -100, 50, -50, 25, -25, 10, -10, 5, -5, 1, -1]) == 200\n assert candidate(nums = [-500, 500, -250, 250, -125, 125, -62, 62, -31, 31, -15, 15, -7, 7, -3, 3, -1, 1]) == 500\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 100\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]) == 1000\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15]) == 15\n assert candidate(nums = [-500, 500, 250, -250, 100, -100, 50, -50, 10, -10]) == 500\n assert candidate(nums = [-500, -400, -300, -200, -100, 100, 200, 300, 400, 500, -1, 1]) == 500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -15]) == 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, 11, 12, 13, 14, 15, -11, -12, -13, -14, -15, 16, 17, 18, 19, 20, -16, -17, -18, -19, -20]) == 20\n assert candidate(nums = [10, 20, 30, 40, -10, -20, -30, 50, 60, -50, -60, 70, 80, -70, -80, 90, -90, 100, -100]) == 100\n assert candidate(nums = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995, 994, -994, 993, -993, 992, -992, 991, -991, 990, -990]) == 999\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]) == 12\n assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30]) == 30\n assert candidate(nums = [1, -1, 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]) == 29\n assert candidate(nums = [-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]) == 15\n assert candidate(nums = [-999, 999, -998, 998, -997, 997, -996, 996, -995, 995]) == 999\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, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30]) == 30\n assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40]) == 40\n assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45]) == 45\n assert candidate(nums = [-500, 500, -499, 499, -498, 498, -497, 497, -496, 496, -495, 495]) == 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, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25]) == 25\n assert candidate(nums = [-1, -2, -3, -4, -5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -1\n assert candidate(nums = [77, -77, 66, -66, 55, -55, 44, -44, 33, -33, 22, -22, 11, -11, 1, -1]) == 77\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 = [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]) == 65\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1]) == 19\n assert candidate(nums = [-1000, 1000, -999, 999, -998, 998, -997, 997, -996, 996]) == 1000\n assert candidate(nums = [88, -88, 77, -77, 66, -66, 55, -55, 44, -44, 33, -33, 22, -22, 11, -11, 1, -1, 0]) == 88\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500, 600, -600, 700, -700, 800, -800, 900, -900]) == 900\n assert candidate(nums = [-23, 23, -45, 45, -67, 67, -89, 89, 101, -101, 123, -123, 145, -145, 167, -167, 189, -189]) == 189\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findMaxK", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findMaxK(int[] nums) {", "container": "Solution", "callable": "findMaxK", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2442, "task_id": "count-number-of-distinct-integers-after-reverse-operations", "difficulty": "Medium", "problem_description": "You are given an array nums consisting of positive integers.\nYou have to take each integer in the array, reverse its digits, and add it to the end of the array. You should apply this operation to the original integers in nums.\nReturn the number of distinct integers in the final array.\n \nExample 1:\n\nInput: nums = [1,13,10,12,31]\nOutput: 6\nExplanation: After including the reverse of each number, the resulting array is [1,13,10,12,31,1,31,1,21,13].\nThe reversed integers that were added to the end of the array are underlined. Note that for the integer 10, after reversing it, it becomes 01 which is just 1.\nThe number of distinct integers in this array is 6 (The numbers 1, 10, 12, 13, 21, and 31).\nExample 2:\n\nInput: nums = [2,2,2]\nOutput: 1\nExplanation: After including the reverse of each number, the resulting array is [2,2,2,2,2,2].\nThe number of distinct integers in this array is 1 (The number 2).\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 = [2, 2, 2]) == 1\n assert candidate(nums = [123, 321, 111, 222]) == 4\n assert candidate(nums = [100, 200, 300, 400]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [9, 99, 999, 9999]) == 4\n assert candidate(nums = [987, 654, 321]) == 6\n assert candidate(nums = [111, 222, 333, 444, 555]) == 5\n assert candidate(nums = [123, 321, 456, 654]) == 4\n assert candidate(nums = [100, 200, 300]) == 6\n assert candidate(nums = [120, 210, 130, 310]) == 8\n assert candidate(nums = [111, 222, 333, 444]) == 4\n assert candidate(nums = [1, 13, 10, 12, 31]) == 6\n assert candidate(nums = [123, 321, 111, 456, 654]) == 5\n assert candidate(nums = [123456, 654321, 111222, 222111, 101010, 100100, 200200, 300300, 400400]) == 14\n assert candidate(nums = [123456, 654321, 112233, 332211, 445566, 665544, 778899, 998877]) == 8\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1001, 2002, 3003]) == 12\n assert candidate(nums = [10001, 20002, 30003, 40004, 50005, 111111, 222222, 333333, 444444, 555555]) == 10\n assert candidate(nums = [999, 998, 997, 996, 995, 994]) == 11\n assert candidate(nums = [987654, 456789, 876543, 345678, 765432, 234567]) == 6\n assert candidate(nums = [987654, 456789, 123, 321, 111, 222, 333]) == 7\n assert candidate(nums = [1234321, 2345432, 3456543, 4567654, 5678765]) == 5\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 27\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 9\n assert candidate(nums = [101010, 202020, 303030, 404040, 505050]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 18\n assert candidate(nums = [100001, 200002, 300003, 400004, 500005, 600006, 700007, 800008, 900009]) == 9\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 111, 222, 333, 444, 555, 666]) == 12\n assert candidate(nums = [123, 321, 120, 210, 102, 201, 213, 312, 132, 321]) == 12\n assert candidate(nums = [987654321, 123456789, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 11\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007]) == 7\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210]) == 10\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005]) == 5\n assert candidate(nums = [1, 12, 123, 1234, 12345]) == 9\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000]) == 7\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]) == 24\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 9\n assert candidate(nums = [999999, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888]) == 9\n assert candidate(nums = [123, 231, 312, 132, 213, 321]) == 6\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 101, 202, 303]) == 9\n assert candidate(nums = [123, 321, 120, 210, 102, 201, 132, 231, 312, 321, 123, 213]) == 12\n assert candidate(nums = [100000, 20000, 3000, 400, 50]) == 10\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 9\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 18\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210, 432109, 321098]) == 14\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890]) == 10\n assert candidate(nums = [12345, 54321, 11223, 32211, 11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == 13\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876]) == 18\n assert candidate(nums = [123, 321, 132, 213, 231, 312, 456, 654, 465, 546, 564, 645]) == 12\n assert candidate(nums = [987654, 456789, 111222, 222111, 333444]) == 6\n assert candidate(nums = [12, 21, 13, 31, 14, 41, 15, 51, 16, 61, 17, 71, 18, 81, 19, 91]) == 16\n assert candidate(nums = [100200, 200100, 101010, 110110, 202020, 220220, 303030, 330330, 404040]) == 18\n assert candidate(nums = [123, 321, 213, 132, 312, 231]) == 6\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 123, 321, 132, 213, 231, 312]) == 15\n assert candidate(nums = [12345, 54321, 11111, 22222, 33333]) == 5\n assert candidate(nums = [101, 110, 202, 220, 303, 330]) == 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]) == 28\n assert candidate(nums = [123456, 654321, 111111, 222222, 333333]) == 5\n assert candidate(nums = [123321, 234432, 345543, 456654, 567765]) == 5\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005]) == 5\n assert candidate(nums = [123456, 654321, 111222, 222111, 1001]) == 5\n assert candidate(nums = [123456, 654321, 112233, 332211, 987654]) == 6\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 202, 303, 404, 505, 606, 707, 808, 909, 110, 210, 310, 410, 510]) == 27\n assert candidate(nums = [1234, 4321, 1122, 2211, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == 13\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000]) == 10\n assert candidate(nums = [100, 101, 102, 103, 104, 105]) == 11\n assert candidate(nums = [10101, 20202, 30303, 40404, 50505, 11111, 22222, 33333, 44444, 55555]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999]) == 6\n assert candidate(nums = [987654, 456789, 876543, 345678]) == 4\n assert candidate(nums = [12345, 54321, 11122, 22111, 33344, 44333, 55556, 65555, 76543, 34567]) == 10\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000]) == 7\n assert candidate(nums = [123456789, 987654321, 100000001, 110000011, 120000021, 130000031]) == 6\n assert candidate(nums = [1000000001, 1000000010, 1000000100, 1000001000, 1000010000, 1000100000, 1001000000, 1010000000, 1100000000]) == 17\n assert candidate(nums = [100000, 100001, 100010, 100100, 101000]) == 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]) == 28\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000]) == 21\n assert candidate(nums = [123456789, 987654321, 987654312, 123456798, 876543219, 987654321, 123456789, 876543210, 109876543]) == 12\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555]) == 5\n assert candidate(nums = [1234567, 7654321, 1111111, 2222222, 3333333]) == 5\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555]) == 5\n assert candidate(nums = [111222, 222333, 333444, 444555, 555666]) == 10\n assert candidate(nums = [123, 321, 213, 132, 312, 231, 456, 654, 546, 465, 645, 564]) == 12\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 9\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 1001, 2002, 3003, 4004, 5005]) == 14\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210]) == 10\n assert candidate(nums = [123456, 654321, 111222, 222111]) == 4\n assert candidate(nums = [100021, 123456, 789012, 321654, 210987]) == 8\n assert candidate(nums = [123456, 654321, 111111, 222222, 333333, 444444]) == 6\n assert candidate(nums = [987654, 456789, 987653, 356789, 987652, 256789, 987651, 156789, 987643]) == 10\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000]) == 10\n assert candidate(nums = [101010, 202020, 303030, 404040, 505050]) == 10\n assert candidate(nums = [100001, 200002, 300003, 400004, 500005]) == 5\n assert candidate(nums = [123456, 654321, 112233, 332211, 445566]) == 6\n assert candidate(nums = [123456, 654321, 111222, 222111, 101010]) == 6\n assert candidate(nums = [12345, 54321, 11122, 22111, 33344, 44333, 55566, 66555, 77788, 88777]) == 10\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000]) == 10\n assert candidate(nums = [10001, 10010, 10100, 11000, 10001]) == 7\n assert candidate(nums = [12, 21, 101, 110, 1001, 1010, 1100, 2002, 2020, 2200]) == 13\n assert candidate(nums = [100, 200, 300, 400, 500, 101, 202, 303, 404, 505]) == 15\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555]) == 5\n assert candidate(nums = [1234, 4321, 1122, 2211, 1331, 1133, 2442, 2244, 4224, 4422]) == 11\n assert candidate(nums = [9, 98, 987, 9876, 98765]) == 9\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countDistinctIntegers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countDistinctIntegers(int[] nums) {", "container": "Solution", "callable": "countDistinctIntegers", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2443, "task_id": "sum-of-number-and-its-reverse", "difficulty": "Medium", "problem_description": "Given a non-negative integer num, return true if num can be expressed as the sum of any non-negative integer and its reverse, or false otherwise.\n \nExample 1:\n\nInput: num = 443\nOutput: true\nExplanation: 172 + 271 = 443 so we return true.\n\nExample 2:\n\nInput: num = 63\nOutput: false\nExplanation: 63 cannot be expressed as the sum of a non-negative integer and its reverse so we return false.\n\nExample 3:\n\nInput: num = 181\nOutput: true\nExplanation: 140 + 041 = 181 so we return true. Note that when a number is reversed, there may be leading zeros.\n\n \nConstraints:\n\n0 <= num <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 443) == True\n assert candidate(num = 181) == True\n assert candidate(num = 99999) == False\n assert candidate(num = 1001) == True\n assert candidate(num = 0) == True\n assert candidate(num = 63) == False\n assert candidate(num = 1000) == False\n assert candidate(num = 121) == True\n assert candidate(num = 100) == False\n assert candidate(num = 123) == False\n assert candidate(num = 100000) == False\n assert candidate(num = 696) == False\n assert candidate(num = 1101) == False\n assert candidate(num = 999) == False\n assert candidate(num = 67876) == True\n assert candidate(num = 727) == True\n assert candidate(num = 454) == False\n assert candidate(num = 6789) == False\n assert candidate(num = 929) == True\n assert candidate(num = 1202) == False\n assert candidate(num = 767) == True\n assert candidate(num = 646) == True\n assert candidate(num = 1230) == False\n assert candidate(num = 67890) == False\n assert candidate(num = 808) == True\n assert candidate(num = 131) == False\n assert candidate(num = 303) == True\n assert candidate(num = 535) == False\n assert candidate(num = 12345) == False\n assert candidate(num = 606) == True\n assert candidate(num = 101010) == True\n assert candidate(num = 12321) == False\n assert candidate(num = 252) == False\n assert candidate(num = 474) == False\n assert candidate(num = 343) == True\n assert candidate(num = 434) == False\n assert candidate(num = 868) == True\n assert candidate(num = 56789) == False\n assert candidate(num = 171) == False\n assert candidate(num = 797) == False\n assert candidate(num = 22222) == True\n assert candidate(num = 101) == True\n assert candidate(num = 987654) == False\n assert candidate(num = 8008) == True\n assert candidate(num = 86420) == False\n assert candidate(num = 50005) == True\n assert candidate(num = 666) == True\n assert candidate(num = 939) == False\n assert candidate(num = 585) == True\n assert candidate(num = 440044) == True\n assert candidate(num = 2002) == True\n assert candidate(num = 393) == False\n assert candidate(num = 222) == True\n assert candidate(num = 98765) == False\n assert candidate(num = 151) == False\n assert candidate(num = 99009) == False\n assert candidate(num = 11) == True\n assert candidate(num = 959) == False\n assert candidate(num = 654321) == False\n assert candidate(num = 5050) == False\n assert candidate(num = 8228) == True\n assert candidate(num = 414) == False\n assert candidate(num = 67676) == True\n assert candidate(num = 876543) == False\n assert candidate(num = 898) == False\n assert candidate(num = 292) == False\n assert candidate(num = 878) == False\n assert candidate(num = 1331) == True\n assert candidate(num = 89898) == True\n assert candidate(num = 141) == True\n assert candidate(num = 80708) == False\n assert candidate(num = 191) == False\n assert candidate(num = 55555) == False\n assert candidate(num = 282) == True\n assert candidate(num = 575) == False\n assert candidate(num = 919) == False\n assert candidate(num = 848) == True\n assert candidate(num = 550055) == True\n assert candidate(num = 123456) == False\n assert candidate(num = 6006) == True\n assert candidate(num = 828) == True\n assert candidate(num = 262) == True\n assert candidate(num = 272) == False\n assert candidate(num = 353) == False\n assert candidate(num = 818) == False\n assert candidate(num = 110011) == True\n assert candidate(num = 525) == True\n assert candidate(num = 9) == False\n assert candidate(num = 43211234) == True\n assert candidate(num = 330033) == True\n assert candidate(num = 979) == False\n assert candidate(num = 424) == True\n assert candidate(num = 99990) == False\n assert candidate(num = 456654) == True\n assert candidate(num = 616) == False\n assert candidate(num = 707) == True\n assert candidate(num = 66666) == True\n assert candidate(num = 595) == False\n assert candidate(num = 100001) == True\n assert candidate(num = 88888) == True\n assert candidate(num = 1221) == True\n assert candidate(num = 323) == True\n assert candidate(num = 555) == False\n assert candidate(num = 383) == True\n assert candidate(num = 888) == True\n assert candidate(num = 100100) == False\n assert candidate(num = 757) == False\n assert candidate(num = 636) == False\n assert candidate(num = 313) == False\n assert candidate(num = 464) == True\n assert candidate(num = 494) == False\n assert candidate(num = 717) == False\n assert candidate(num = 7007) == True\n assert candidate(num = 686) == True\n assert candidate(num = 9009) == True\n assert candidate(num = 60006) == True\n assert candidate(num = 20202) == True\n assert candidate(num = 24680) == False\n assert candidate(num = 737) == False\n assert candidate(num = 8888) == True\n assert candidate(num = 543210) == False\n assert candidate(num = 1) == False\n assert candidate(num = 1010) == True\n assert candidate(num = 545) == True\n assert candidate(num = 656) == False\n assert candidate(num = 909) == True\n assert candidate(num = 565) == True\n assert candidate(num = 232) == False\n assert candidate(num = 54321) == False\n assert candidate(num = 98789) == False\n assert candidate(num = 45454) == True\n assert candidate(num = 50505) == False\n assert candidate(num = 11111) == False\n assert candidate(num = 90000) == False\n assert candidate(num = 45654) == True\n assert candidate(num = 78987) == False\n assert candidate(num = 676) == False\n assert candidate(num = 6789876) == False\n assert candidate(num = 1234321) == True\n assert candidate(num = 505) == True\n assert candidate(num = 363) == True\n assert candidate(num = 123321) == True\n assert candidate(num = 949) == True\n assert candidate(num = 1020) == False\n assert candidate(num = 220022) == True\n assert candidate(num = 838) == False\n assert candidate(num = 161) == True\n assert candidate(num = 33333) == False\n assert candidate(num = 626) == True\n assert candidate(num = 444) == True\n assert candidate(num = 13579) == False\n assert candidate(num = 787) == True\n assert candidate(num = 202) == True\n assert candidate(num = 75309) == False\n assert candidate(num = 373) == False\n assert candidate(num = 333) == False\n assert candidate(num = 22) == True\n assert candidate(num = 50000) == False\n assert candidate(num = 404) == True\n assert candidate(num = 13531) == False\n assert candidate(num = 989) == True\n assert candidate(num = 2022) == False\n assert candidate(num = 10101) == False\n assert candidate(num = 858) == False\n assert candidate(num = 111) == False\n assert candidate(num = 484) == True\n assert candidate(num = 515) == False\n assert candidate(num = 242) == True\n assert candidate(num = 50050) == False\n assert candidate(num = 777) == False\n assert candidate(num = 54545) == False\n assert candidate(num = 969) == True\n assert candidate(num = 747) == True\n assert candidate(num = 5005) == True\n assert candidate(num = 9999) == True\n assert candidate(num = 212) == False\n assert candidate(num = 10000) == False\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().sumOfNumberAndReverse", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean sumOfNumberAndReverse(int num) {", "container": "Solution", "callable": "sumOfNumberAndReverse", "parameters": [{"name": "num", "type": "int"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2444, "task_id": "count-subarrays-with-fixed-bounds", "difficulty": "Hard", "problem_description": "You are given an integer array nums and two integers minK and maxK.\nA fixed-bound subarray of nums is a subarray that satisfies the following conditions:\n\nThe minimum value in the subarray is equal to minK.\nThe maximum value in the subarray is equal to maxK.\n\nReturn the number of fixed-bound subarrays.\nA subarray is a contiguous part of an array.\n \nExample 1:\n\nInput: nums = [1,3,5,2,7,5], minK = 1, maxK = 5\nOutput: 2\nExplanation: The fixed-bound subarrays are [1,3,5] and [1,3,5,2].\n\nExample 2:\n\nInput: nums = [1,1,1,1], minK = 1, maxK = 1\nOutput: 10\nExplanation: Every subarray of nums is a fixed-bound subarray. There are 10 possible subarrays.\n\n \nConstraints:\n\n2 <= nums.length <= 105\n1 <= nums[i], minK, maxK <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 3,maxK = 7) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 3,maxK = 7) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5],minK = 2,maxK = 4) == 4\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],minK = 3,maxK = 7) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 1,maxK = 10) == 1\n assert candidate(nums = [2, 4, 3, 2, 4, 6],minK = 2,maxK = 4) == 8\n assert candidate(nums = [10, 9, 8, 7, 6],minK = 6,maxK = 10) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],minK = 2,maxK = 8) == 1\n assert candidate(nums = [1, 2, 3, 2, 1],minK = 1,maxK = 3) == 5\n assert candidate(nums = [10, 20, 30, 40, 50],minK = 10,maxK = 50) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],minK = 2,maxK = 5) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],minK = 2,maxK = 4) == 1\n assert candidate(nums = [1, 3, 5, 2, 7, 5],minK = 1,maxK = 5) == 2\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],minK = 6,maxK = 6) == 55\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],minK = 1,maxK = 5) == 4\n assert candidate(nums = [5, 5, 5, 5, 5],minK = 5,maxK = 5) == 15\n assert candidate(nums = [5, 4, 3, 2, 1],minK = 2,maxK = 4) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],minK = 5,maxK = 5) == 55\n assert candidate(nums = [1, 1, 1, 1],minK = 1,maxK = 1) == 10\n assert candidate(nums = [2, 3, 5, 1, 5, 7, 5],minK = 1,maxK = 5) == 7\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 2,maxK = 9) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 2,maxK = 8) == 1\n assert candidate(nums = [2, 1, 5, 1, 3, 5, 4, 2],minK = 1,maxK = 5) == 20\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],minK = 5,maxK = 20) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],minK = 1,maxK = 5) == 108\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],minK = 2,maxK = 2) == 210\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],minK = 2,maxK = 9) == 3\n assert candidate(nums = [6, 2, 5, 3, 4, 2, 3, 2, 2, 3, 5, 4, 3, 2, 1],minK = 2,maxK = 5) == 47\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],minK = 2,maxK = 2) == 120\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],minK = 1,maxK = 3) == 39\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],minK = 7,maxK = 7) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10],minK = 1,maxK = 10) == 38\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],minK = 3,maxK = 12) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 7, 8],minK = 3,maxK = 5) == 3\n assert candidate(nums = [10, 7, 5, 3, 2, 2, 5, 7, 10],minK = 2,maxK = 7) == 8\n assert candidate(nums = [3, 1, 5, 4, 2, 5, 1, 3, 4],minK = 1,maxK = 5) == 26\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],minK = 3,maxK = 3) == 210\n assert candidate(nums = [7, 9, 5, 6, 3, 1, 8, 4, 2, 5],minK = 3,maxK = 7) == 0\n assert candidate(nums = [7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10],minK = 7,maxK = 10) == 246\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],minK = 1,maxK = 8) == 225\n assert candidate(nums = [5, 3, 3, 3, 1, 4, 5, 5, 2, 5],minK = 1,maxK = 5) == 22\n assert candidate(nums = [5, 3, 4, 5, 3, 5, 3, 4, 5, 3],minK = 3,maxK = 5) == 41\n assert candidate(nums = [1, 5, 3, 5, 2, 3, 5, 1, 2, 5],minK = 1,maxK = 5) == 28\n assert candidate(nums = [6, 4, 5, 1, 2, 3, 1, 5, 4, 6, 1, 2, 3, 1, 5, 4, 6, 1, 2, 3, 1, 5, 4, 6],minK = 1,maxK = 5) == 36\n assert candidate(nums = [1, 3, 2, 5, 4, 6, 5, 3, 2, 1, 4, 5, 6, 7, 8, 9],minK = 2,maxK = 8) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],minK = 5,maxK = 10) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1],minK = 1,maxK = 3) == 20\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],minK = 10,maxK = 15) == 1\n assert candidate(nums = [7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 1,maxK = 7) == 9\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 20, 10],minK = 10,maxK = 20) == 9\n assert candidate(nums = [1, 5, 4, 5, 1, 1, 5, 2, 1, 3, 4, 5],minK = 1,maxK = 5) == 53\n assert candidate(nums = [7, 3, 3, 5, 7, 3, 5, 7, 3, 5],minK = 3,maxK = 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],minK = 1,maxK = 1) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],minK = 4,maxK = 12) == 1\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],minK = 2,maxK = 4) == 2\n assert candidate(nums = [5, 4, 5, 3, 5, 4, 5, 2, 5, 4, 5, 3, 5, 4, 5, 1, 5, 4, 5, 3],minK = 1,maxK = 5) == 79\n assert candidate(nums = [1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1],minK = 1,maxK = 3) == 103\n assert candidate(nums = [5, 3, 1, 4, 5, 2, 3, 4, 5, 2, 1, 4, 5, 3, 2, 1, 5],minK = 1,maxK = 5) == 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],minK = 2,maxK = 6) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],minK = 2,maxK = 5) == 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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 1,maxK = 10) == 303\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8],minK = 5,maxK = 8) == 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],minK = 1,maxK = 10) == 102\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],minK = 8,maxK = 8) == 210\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],minK = 3,maxK = 6) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1],minK = 1,maxK = 10) == 21\n assert candidate(nums = [1, 5, 3, 5, 2, 3, 1, 5, 2],minK = 1,maxK = 5) == 23\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],minK = 2,maxK = 4) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 3,maxK = 7) == 2\n assert candidate(nums = [5, 5, 3, 5, 2, 3, 3, 5, 3, 3, 5, 3, 2, 5, 5, 3, 3, 5, 5, 5],minK = 2,maxK = 5) == 139\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],minK = 1,maxK = 5) == 154\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],minK = 1,maxK = 5) == 106\n assert candidate(nums = [1, 3, 5, 3, 1, 5, 3, 1, 5, 3, 1, 5, 3, 1, 5, 3, 1, 5, 3, 1],minK = 1,maxK = 5) == 175\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],minK = 6,maxK = 24) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],minK = 10,maxK = 150) == 1\n assert candidate(nums = [7, 8, 9, 10, 7, 8, 9, 10, 7, 8],minK = 7,maxK = 10) == 34\n assert candidate(nums = [7, 3, 5, 1, 5, 2, 5, 5, 2, 5, 1, 5, 3, 7],minK = 1,maxK = 7) == 21\n assert candidate(nums = [2, 1, 3, 3, 2, 3, 1, 2, 3, 2, 1, 2, 3],minK = 1,maxK = 3) == 63\n assert candidate(nums = [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],minK = 1,maxK = 5) == 312\n assert candidate(nums = [1, 3, 1, 3, 5, 1, 3, 5, 2, 5, 3, 2, 3, 1, 2, 3, 5, 1, 3, 5, 2, 5],minK = 1,maxK = 5) == 181\n assert candidate(nums = [100, 200, 100, 300, 200, 100, 300, 200, 100],minK = 100,maxK = 300) == 29\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 9, 7, 5, 3, 1, 2, 4, 6, 8],minK = 3,maxK = 9) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5],minK = 2,maxK = 5) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 3,maxK = 8) == 1\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6],minK = 5,maxK = 6) == 190\n assert candidate(nums = [2, 4, 2, 1, 5, 4, 2, 3, 5, 1],minK = 1,maxK = 5) == 29\n assert candidate(nums = [8, 7, 6, 7, 8, 9, 10, 9, 8, 7, 6, 7, 8, 9],minK = 6,maxK = 9) == 10\n assert candidate(nums = [3, 6, 3, 7, 3, 5, 3, 4, 3, 3],minK = 3,maxK = 7) == 27\n assert candidate(nums = [5, 1, 3, 5, 7, 5, 3, 1, 5],minK = 1,maxK = 5) == 8\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],minK = 1,maxK = 2) == 45\n assert candidate(nums = [5, 1, 3, 5, 1, 3, 5, 1, 3, 5, 1, 3, 5, 1, 3, 5],minK = 1,maxK = 5) == 110\n assert candidate(nums = [1, 5, 3, 5, 3, 5, 3, 5, 3, 1],minK = 1,maxK = 5) == 16\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 3,maxK = 7) == 1\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],minK = 6,maxK = 6) == 55\n assert candidate(nums = [2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4],minK = 2,maxK = 4) == 120\n assert candidate(nums = [1000000, 999999, 1000000, 999999, 1000000, 999999, 1000000],minK = 999999,maxK = 1000000) == 21\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],minK = 5,maxK = 10) == 4\n assert candidate(nums = [2, 1, 5, 3, 5, 1, 5, 2, 5, 1, 5, 3, 2, 1],minK = 1,maxK = 5) == 79\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 3,maxK = 8) == 2\n assert candidate(nums = [2, 1, 3, 4, 5, 1, 5, 2],minK = 1,maxK = 5) == 19\n assert candidate(nums = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 5, 5, 5, 5],minK = 1,maxK = 5) == 48\n assert candidate(nums = [1, 3, 2, 5, 4, 6, 5, 4, 3, 2, 1, 3, 5, 2, 4, 6, 5, 4, 3, 2, 1],minK = 2,maxK = 5) == 10\n assert candidate(nums = [5, 3, 1, 3, 1, 5, 3, 1, 3, 1, 5, 3, 1, 3, 1],minK = 1,maxK = 5) == 84\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, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],minK = 5,maxK = 10) == 3\n assert candidate(nums = [1, 2, 2, 3, 4, 3, 5, 2, 3, 4, 5, 3, 4, 5, 3, 4, 2, 3, 4, 5, 3, 4, 2, 5, 3, 4, 5],minK = 2,maxK = 5) == 256\n assert candidate(nums = [6, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],minK = 2,maxK = 5) == 4\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 6, 7, 8, 9],minK = 5,maxK = 9) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4],minK = 1,maxK = 4) == 75\n assert candidate(nums = [2, 1, 5, 3, 4, 2, 1, 5, 3, 4, 2, 1, 5, 3, 4],minK = 1,maxK = 5) == 83\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 1, 5, 2, 5, 3, 5, 4, 5, 1, 5, 2],minK = 1,maxK = 5) == 147\n assert candidate(nums = [1, 5, 3, 4, 2, 1, 5, 4, 3, 2],minK = 2,maxK = 5) == 2\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],minK = 1,maxK = 5) == 51\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],minK = 3,maxK = 7) == 4\n assert candidate(nums = [1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000],minK = 1,maxK = 1000000) == 66\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1],minK = 1,maxK = 4) == 46\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4],minK = 2,maxK = 4) == 8\n"}, "metadata": {"canonical_parameter_names": ["nums", "minK", "maxK"], "leetcode_dataset_entry_point": "Solution().countSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countSubarrays(int[] nums, int minK, int maxK) {", "container": "Solution", "callable": "countSubarrays", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "minK", "type": "int"}, {"name": "maxK", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2446, "task_id": "determine-if-two-events-have-conflict", "difficulty": "Easy", "problem_description": "You are given two arrays of strings that represent two inclusive events that happened on the same day, event1 and event2, where:\n\nevent1 = [startTime1, endTime1] and\nevent2 = [startTime2, endTime2].\n\nEvent times are valid 24 hours format in the form of HH:MM.\nA conflict happens when two events have some non-empty intersection (i.e., some moment is common to both events).\nReturn true if there is a conflict between two events. Otherwise, return false.\n \nExample 1:\n\nInput: event1 = [\"01:15\",\"02:00\"], event2 = [\"02:00\",\"03:00\"]\nOutput: true\nExplanation: The two events intersect at time 2:00.\n\nExample 2:\n\nInput: event1 = [\"01:00\",\"02:00\"], event2 = [\"01:20\",\"03:00\"]\nOutput: true\nExplanation: The two events intersect starting from 01:20 to 02:00.\n\nExample 3:\n\nInput: event1 = [\"10:00\",\"11:00\"], event2 = [\"14:00\",\"15:00\"]\nOutput: false\nExplanation: The two events do not intersect.\n\n \nConstraints:\n\nevent1.length == event2.length == 2\nevent1[i].length == event2[i].length == 5\nstartTime1 <= endTime1\nstartTime2 <= endTime2\nAll the event times follow the HH:MM format.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(event1 = ['10:00', '11:00'],event2 = ['14:00', '15:00']) == False\n assert candidate(event1 = ['00:00', '23:59'],event2 = ['12:00', '12:01']) == True\n assert candidate(event1 = ['00:00', '23:59'],event2 = ['12:00', '12:00']) == True\n assert candidate(event1 = ['00:00', '23:59'],event2 = ['12:00', '12:30']) == True\n assert candidate(event1 = ['01:15', '02:00'],event2 = ['02:00', '03:00']) == True\n assert candidate(event1 = ['09:30', '10:30'],event2 = ['10:00', '11:00']) == True\n assert candidate(event1 = ['05:45', '06:45'],event2 = ['06:45', '07:45']) == True\n assert candidate(event1 = ['08:00', '09:00'],event2 = ['07:00', '08:30']) == True\n assert candidate(event1 = ['23:59', '23:59'],event2 = ['23:59', '23:59']) == True\n assert candidate(event1 = ['13:00', '15:00'],event2 = ['14:00', '16:00']) == True\n assert candidate(event1 = ['12:00', '12:30'],event2 = ['12:15', '12:45']) == True\n assert candidate(event1 = ['01:00', '02:00'],event2 = ['01:20', '03:00']) == True\n assert candidate(event1 = ['13:00', '14:00'],event2 = ['14:00', '15:00']) == True\n assert candidate(event1 = ['09:00', '09:30'],event2 = ['09:30', '10:00']) == True\n assert candidate(event1 = ['16:00', '17:00'],event2 = ['16:30', '17:30']) == True\n assert candidate(event1 = ['12:00', '13:00'],event2 = ['12:30', '13:30']) == True\n assert candidate(event1 = ['13:30', '15:30'],event2 = ['14:00', '16:00']) == True\n assert candidate(event1 = ['08:00', '09:00'],event2 = ['09:00', '10:00']) == True\n assert candidate(event1 = ['12:00', '13:00'],event2 = ['13:00', '14:00']) == True\n assert candidate(event1 = ['00:01', '23:59'],event2 = ['12:00', '12:01']) == True\n assert candidate(event1 = ['12:00', '12:00'],event2 = ['12:00', '12:00']) == True\n assert candidate(event1 = ['22:00', '23:00'],event2 = ['21:30', '22:30']) == True\n assert candidate(event1 = ['00:00', '23:59'],event2 = ['01:00', '02:00']) == True\n assert candidate(event1 = ['00:00', '23:59'],event2 = ['12:00', '13:00']) == True\n assert candidate(event1 = ['05:30', '06:00'],event2 = ['05:45', '06:15']) == True\n assert candidate(event1 = ['01:00', '02:00'],event2 = ['00:59', '01:01']) == True\n assert candidate(event1 = ['08:00', '09:00'],event2 = ['08:00', '08:30']) == True\n assert candidate(event1 = ['23:55', '00:10'],event2 = ['23:45', '00:05']) == False\n assert candidate(event1 = ['09:00', '17:00'],event2 = ['08:30', '09:30']) == True\n assert candidate(event1 = ['14:00', '16:00'],event2 = ['15:30', '17:00']) == True\n assert candidate(event1 = ['15:00', '16:00'],event2 = ['14:00', '15:30']) == True\n assert candidate(event1 = ['14:00', '15:00'],event2 = ['13:00', '14:00']) == True\n assert candidate(event1 = ['23:59', '00:01'],event2 = ['00:00', '00:01']) == False\n assert candidate(event1 = ['00:00', '11:59'],event2 = ['12:00', '23:59']) == False\n assert candidate(event1 = ['09:45', '10:45'],event2 = ['10:30', '11:30']) == True\n assert candidate(event1 = ['05:00', '07:00'],event2 = ['06:00', '06:59']) == True\n assert candidate(event1 = ['23:59', '23:59'],event2 = ['23:59', '00:00']) == False\n assert candidate(event1 = ['08:00', '09:00'],event2 = ['08:00', '08:59']) == True\n assert candidate(event1 = ['07:30', '08:00'],event2 = ['07:45', '08:15']) == True\n assert candidate(event1 = ['09:00', '18:00'],event2 = ['17:59', '18:01']) == True\n assert candidate(event1 = ['06:00', '07:00'],event2 = ['06:00', '06:59']) == True\n assert candidate(event1 = ['00:01', '00:59'],event2 = ['00:30', '01:00']) == True\n assert candidate(event1 = ['23:30', '00:30'],event2 = ['23:00', '23:59']) == False\n assert candidate(event1 = ['09:30', '10:15'],event2 = ['10:00', '10:45']) == True\n assert candidate(event1 = ['13:00', '14:00'],event2 = ['13:45', '14:45']) == True\n assert candidate(event1 = ['11:00', '13:00'],event2 = ['12:30', '14:00']) == True\n assert candidate(event1 = ['14:30', '15:30'],event2 = ['15:00', '16:00']) == True\n assert candidate(event1 = ['20:00', '21:00'],event2 = ['19:00', '20:00']) == True\n assert candidate(event1 = ['11:00', '12:00'],event2 = ['09:00', '10:59']) == False\n assert candidate(event1 = ['11:59', '23:59'],event2 = ['23:59', '00:00']) == False\n assert candidate(event1 = ['09:00', '09:00'],event2 = ['09:00', '09:00']) == True\n assert candidate(event1 = ['08:30', '09:45'],event2 = ['09:30', '10:30']) == True\n assert candidate(event1 = ['07:15', '07:45'],event2 = ['07:45', '08:15']) == True\n assert candidate(event1 = ['09:30', '10:30'],event2 = ['10:00', '10:00']) == True\n assert candidate(event1 = ['00:00', '00:01'],event2 = ['00:00', '00:02']) == True\n assert candidate(event1 = ['18:30', '19:00'],event2 = ['19:00', '19:30']) == True\n assert candidate(event1 = ['14:45', '15:15'],event2 = ['15:15', '15:45']) == True\n assert candidate(event1 = ['17:45', '18:15'],event2 = ['18:15', '18:45']) == True\n assert candidate(event1 = ['03:00', '04:00'],event2 = ['02:30', '03:30']) == True\n assert candidate(event1 = ['01:00', '02:00'],event2 = ['23:59', '01:30']) == False\n assert candidate(event1 = ['18:00', '19:00'],event2 = ['17:30', '18:00']) == True\n assert candidate(event1 = ['08:30', '09:30'],event2 = ['09:00', '09:15']) == True\n assert candidate(event1 = ['08:30', '09:30'],event2 = ['09:00', '09:30']) == True\n assert candidate(event1 = ['08:00', '09:00'],event2 = ['07:59', '08:01']) == True\n assert candidate(event1 = ['14:00', '15:00'],event2 = ['13:59', '14:01']) == True\n assert candidate(event1 = ['11:45', '12:15'],event2 = ['12:15', '12:45']) == True\n assert candidate(event1 = ['05:30', '06:30'],event2 = ['06:20', '07:20']) == True\n assert candidate(event1 = ['00:00', '24:00'],event2 = ['00:00', '24:00']) == True\n assert candidate(event1 = ['13:30', '14:30'],event2 = ['14:30', '15:30']) == True\n assert candidate(event1 = ['08:45', '09:45'],event2 = ['09:45', '10:45']) == True\n assert candidate(event1 = ['13:45', '14:45'],event2 = ['14:45', '15:45']) == True\n assert candidate(event1 = ['00:00', '23:59'],event2 = ['12:30', '13:30']) == True\n assert candidate(event1 = ['13:15', '14:45'],event2 = ['14:00', '15:30']) == True\n assert candidate(event1 = ['09:00', '17:00'],event2 = ['10:00', '15:00']) == True\n assert candidate(event1 = ['06:00', '06:59'],event2 = ['07:00', '08:00']) == False\n assert candidate(event1 = ['22:00', '22:59'],event2 = ['22:59', '23:59']) == True\n assert candidate(event1 = ['11:00', '13:00'],event2 = ['12:00', '14:00']) == True\n assert candidate(event1 = ['17:00', '18:00'],event2 = ['16:30', '17:00']) == True\n assert candidate(event1 = ['03:00', '04:00'],event2 = ['03:59', '04:01']) == True\n assert candidate(event1 = ['06:00', '07:00'],event2 = ['05:59', '06:01']) == True\n assert candidate(event1 = ['23:55', '23:59'],event2 = ['23:56', '00:05']) == False\n assert candidate(event1 = ['23:45', '23:59'],event2 = ['23:50', '00:10']) == False\n assert candidate(event1 = ['15:30', '16:30'],event2 = ['15:00', '15:30']) == True\n assert candidate(event1 = ['09:00', '17:00'],event2 = ['17:00', '18:00']) == True\n assert candidate(event1 = ['11:00', '11:01'],event2 = ['11:00', '11:01']) == True\n assert candidate(event1 = ['09:00', '17:00'],event2 = ['12:00', '13:00']) == True\n assert candidate(event1 = ['11:00', '11:30'],event2 = ['11:30', '12:00']) == True\n assert candidate(event1 = ['05:30', '06:00'],event2 = ['06:00', '06:30']) == True\n assert candidate(event1 = ['05:30', '06:30'],event2 = ['06:29', '07:30']) == True\n assert candidate(event1 = ['09:30', '10:30'],event2 = ['10:00', '10:15']) == True\n assert candidate(event1 = ['00:00', '23:59'],event2 = ['00:00', '23:59']) == True\n assert candidate(event1 = ['11:45', '12:45'],event2 = ['11:30', '11:45']) == True\n assert candidate(event1 = ['15:30', '15:30'],event2 = ['15:30', '15:30']) == True\n assert candidate(event1 = ['12:00', '13:00'],event2 = ['11:00', '12:59']) == True\n assert candidate(event1 = ['14:00', '15:00'],event2 = ['15:00', '16:00']) == True\n assert candidate(event1 = ['21:00', '22:00'],event2 = ['20:00', '21:00']) == True\n assert candidate(event1 = ['19:00', '20:00'],event2 = ['20:00', '21:00']) == True\n assert candidate(event1 = ['08:30', '09:15'],event2 = ['09:15', '10:00']) == True\n assert candidate(event1 = ['06:00', '07:00'],event2 = ['07:00', '08:00']) == True\n assert candidate(event1 = ['18:00', '19:00'],event2 = ['17:30', '18:30']) == True\n assert candidate(event1 = ['01:00', '02:00'],event2 = ['02:01', '03:00']) == False\n assert candidate(event1 = ['09:00', '10:00'],event2 = ['10:00', '11:00']) == True\n assert candidate(event1 = ['00:00', '12:00'],event2 = ['12:00', '23:59']) == True\n assert candidate(event1 = ['23:59', '00:01'],event2 = ['23:58', '00:00']) == False\n assert candidate(event1 = ['00:01', '23:59'],event2 = ['23:59', '00:01']) == True\n assert candidate(event1 = ['10:00', '10:30'],event2 = ['09:59', '10:01']) == True\n assert candidate(event1 = ['00:00', '00:01'],event2 = ['00:01', '00:02']) == True\n assert candidate(event1 = ['11:55', '12:05'],event2 = ['12:00', '12:10']) == True\n assert candidate(event1 = ['12:34', '12:34'],event2 = ['12:34', '12:34']) == True\n"}, "metadata": {"canonical_parameter_names": ["event1", "event2"], "leetcode_dataset_entry_point": "Solution().haveConflict", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean haveConflict(String[] event1, String[] event2) {", "container": "Solution", "callable": "haveConflict", "parameters": [{"name": "event1", "type": "String[]"}, {"name": "event2", "type": "String[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2447, "task_id": "number-of-subarrays-with-gcd-equal-to-k", "difficulty": "Medium", "problem_description": "Given an integer array nums and an integer k, return the number of subarrays of nums where the greatest common divisor of the subarray's elements is k.\nA subarray is a contiguous non-empty sequence of elements within an array.\nThe greatest common divisor of an array is the largest integer that evenly divides all the array elements.\n \nExample 1:\n\nInput: nums = [9,3,1,2,6,3], k = 3\nOutput: 4\nExplanation: The subarrays of nums where 3 is the greatest common divisor of all the subarray's elements are:\n- [9,3,1,2,6,3]\n- [9,3,1,2,6,3]\n- [9,3,1,2,6,3]\n- [9,3,1,2,6,3]\n\nExample 2:\n\nInput: nums = [4], k = 7\nOutput: 0\nExplanation: There are no subarrays of nums where 7 is the greatest common divisor of all the subarray's elements.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i], k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 11\n assert candidate(nums = [7, 14, 21, 28, 35],k = 7) == 11\n assert candidate(nums = [5, 10, 15, 20, 25],k = 5) == 11\n assert candidate(nums = [9, 3, 1, 2, 6, 3],k = 3) == 4\n assert candidate(nums = [2, 4, 6, 8, 10],k = 2) == 11\n assert candidate(nums = [3, 9, 27, 81, 243],k = 3) == 5\n assert candidate(nums = [11, 22, 33, 44, 55],k = 11) == 11\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 11\n assert candidate(nums = [4],k = 7) == 0\n assert candidate(nums = [3, 6, 9, 12, 15],k = 3) == 11\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40],k = 5) == 29\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909],k = 101) == 37\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],k = 101) == 46\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45],k = 5) == 37\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39],k = 3) == 45\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160],k = 8) == 191\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72],k = 8) == 37\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 13) == 46\n assert candidate(nums = [15, 45, 75, 105, 135, 165, 195, 225],k = 15) == 29\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310, 341, 372, 403, 434, 465, 496, 527, 558, 589, 620],k = 31) == 191\n assert candidate(nums = [15, 30, 45, 60, 75, 90],k = 15) == 16\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 13) == 46\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],k = 1) == 5151\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1110, 1221, 1332, 1443, 1554, 1665, 1776, 1887, 1998, 2109, 2220],k = 111) == 191\n assert candidate(nums = [60, 120, 180, 240, 300],k = 60) == 11\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072],k = 256) == 10\n assert candidate(nums = [5, 15, 25, 35, 45, 55],k = 5) == 16\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 = 2) == 301\n assert candidate(nums = [54, 108, 162, 216, 270, 324, 378, 432, 486, 540, 594, 648, 702, 756, 810, 864, 918, 972, 1026, 1080],k = 54) == 191\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100) == 55\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],k = 1) == 45\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153],k = 17) == 37\n assert candidate(nums = [101, 202, 303, 404, 505, 606],k = 101) == 16\n assert candidate(nums = [44, 88, 132, 176, 220, 264, 308, 352, 396, 440, 484, 528, 572, 616, 660, 704, 748, 792, 836, 880, 924, 968, 1012, 1056, 1100],k = 44) == 301\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104],k = 13) == 29\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 46\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],k = 8) == 10\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) == 191\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49],k = 7) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 46\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000],k = 1000000000) == 7\n assert candidate(nums = [60, 120, 180, 240, 300],k = 60) == 11\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 = 1) == 300\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 7) == 46\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336, 357, 378, 399, 420],k = 21) == 191\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) == 191\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1) == 10\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 8) == 13\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108],k = 12) == 37\n assert candidate(nums = [15, 25, 35, 45, 55, 65],k = 5) == 15\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75],k = 5) == 29\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 2) == 46\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 3) == 106\n assert candidate(nums = [987, 654, 321, 987, 654, 321, 987, 654, 321],k = 3) == 36\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121],k = 11) == 56\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170],k = 17) == 46\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 2) == 106\n assert candidate(nums = [81, 54, 27, 9, 3, 1],k = 3) == 5\n assert candidate(nums = [36, 72, 108, 144, 180, 216, 252, 288, 324, 360],k = 36) == 46\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540],k = 60) == 37\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 15) == 46\n assert candidate(nums = [72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408],k = 24) == 105\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 5) == 45\n assert candidate(nums = [45, 90, 135, 180, 225, 270, 315, 360, 405, 450],k = 45) == 46\n assert candidate(nums = [7, 14, 28, 56, 112],k = 7) == 5\n assert candidate(nums = [77, 154, 231, 308, 385, 462, 539, 616, 693, 770, 847, 924, 1001, 1078, 1155, 1232, 1309, 1386, 1463, 1540],k = 77) == 191\n assert candidate(nums = [36, 72, 108, 144, 180, 216, 252, 288, 324, 360],k = 36) == 46\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 46\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 21) == 46\n assert candidate(nums = [123456789, 987654321, 111222333, 222333444, 333444555],k = 9) == 7\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149],k = 1) == 45\n assert candidate(nums = [6, 12, 18, 24, 30],k = 6) == 11\n assert candidate(nums = [8, 12, 16, 20, 24, 28, 32],k = 4) == 21\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],k = 1000) == 11\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 = 5) == 191\n assert candidate(nums = [48, 64, 80, 96, 112, 128, 144, 160, 176, 192],k = 16) == 45\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 21) == 46\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500],k = 25) == 191\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170],k = 17) == 46\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 11) == 46\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == 46\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 = 100) == 191\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420],k = 42) == 46\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024],k = 8) == 8\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 = 5) == 191\n assert candidate(nums = [72, 48, 12, 18, 6, 120],k = 6) == 13\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000],k = 1000000) == 11\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) == 191\n assert candidate(nums = [7, 14, 28, 56, 112, 224],k = 7) == 6\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336],k = 7) == 12\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330, 363, 396, 429, 462, 495],k = 33) == 106\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 125000000) == 4\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024],k = 8) == 8\n assert candidate(nums = [12, 15, 21, 33, 48],k = 3) == 10\n assert candidate(nums = [99, 198, 297, 396, 495, 594, 693, 792],k = 99) == 29\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340],k = 17) == 191\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135],k = 9) == 106\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91],k = 13) == 22\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 7) == 106\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462],k = 42) == 56\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108],k = 9) == 67\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 2) == 1\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48],k = 6) == 29\n assert candidate(nums = [20, 40, 60, 80, 100, 120, 140],k = 20) == 22\n assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == 36\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 46\n assert candidate(nums = [100, 200, 400, 800, 1600, 3200],k = 100) == 6\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 1) == 15\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 15) == 46\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600],k = 60) == 46\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707],k = 101) == 22\n assert candidate(nums = [48, 64, 80, 96, 112, 128, 144, 160, 176, 192],k = 16) == 45\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336, 357, 378, 399, 420],k = 21) == 191\n assert candidate(nums = [21, 14, 42, 84, 28, 56, 112],k = 14) == 9\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 46\n assert candidate(nums = [81, 27, 9, 3, 1],k = 1) == 5\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 2) == 46\n assert candidate(nums = [100, 150, 200, 250, 300, 350],k = 50) == 15\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60],k = 6) == 46\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255],k = 17) == 106\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 62500000) == 5\n assert candidate(nums = [123, 246, 369, 492, 615, 738, 861, 984, 1107, 1230, 1353, 1476, 1599, 1722, 1845, 1968, 2091, 2214, 2337, 2460],k = 123) == 191\n assert candidate(nums = [999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937],k = 999999937) == 55\n assert candidate(nums = [81, 27, 9, 3, 1, 243, 729],k = 3) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().subarrayGCD", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int subarrayGCD(int[] nums, int k) {", "container": "Solution", "callable": "subarrayGCD", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2448, "task_id": "minimum-cost-to-make-array-equal", "difficulty": "Hard", "problem_description": "You are given two 0-indexed arrays nums and cost consisting each of n positive integers.\nYou can do the following operation any number of times:\n\nIncrease or decrease any element of the array nums by 1.\n\nThe cost of doing one operation on the ith element is cost[i].\nReturn the minimum total cost such that all the elements of the array nums become equal.\n \nExample 1:\n\nInput: nums = [1,3,5,2], cost = [2,3,1,14]\nOutput: 8\nExplanation: We can make all the elements equal to 2 in the following way:\n- Increase the 0th element one time. The cost is 2.\n- Decrease the 1st element one time. The cost is 3.\n- Decrease the 2nd element three times. The cost is 1 + 1 + 1 = 3.\nThe total cost is 2 + 3 + 3 = 8.\nIt can be shown that we cannot make the array equal with a smaller cost.\n\nExample 2:\n\nInput: nums = [2,2,2,2,2], cost = [4,2,8,1,3]\nOutput: 0\nExplanation: All the elements are already equal, so no operations are needed.\n\n \nConstraints:\n\nn == nums.length == cost.length\n1 <= n <= 105\n1 <= nums[i], cost[i] <= 106\nTest cases are generated in a way that the output doesn't exceed 253-1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [6, 1, 3, 9, 3],cost = [2, 1, 2, 1, 2]) == 14\n assert candidate(nums = [1, 3, 5, 2],cost = [2, 3, 1, 14]) == 8\n assert candidate(nums = [2, 2, 2, 2, 2],cost = [4, 2, 8, 1, 3]) == 0\n assert candidate(nums = [6, 1, 9],cost = [2, 5, 7]) == 46\n assert candidate(nums = [1, 2, 3],cost = [1, 2, 3]) == 4\n assert candidate(nums = [10, 1, 10],cost = [1, 100, 1]) == 18\n assert candidate(nums = [6, 1, 9, 8, 2],cost = [4, 2, 8, 1, 3]) == 48\n assert candidate(nums = [100000, 100000],cost = [1000000, 1000000]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],cost = [10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [1, 2, 3],cost = [1, 1, 1]) == 2\n assert candidate(nums = [10, 5, 15],cost = [1, 10, 1]) == 15\n assert candidate(nums = [1, 2, 3],cost = [9, 3, 5]) == 13\n assert candidate(nums = [100000, 1000000],cost = [100, 1]) == 900000\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000],cost = [1000000, 1000000, 1000000, 1000000]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],cost = [5, 4, 3, 2, 1]) == 1500\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 3, 8, 6, 2, 7],cost = [100, 200, 300, 400, 500, 600]) == 3900\n assert candidate(nums = [9, 1, 4, 7, 3],cost = [100, 10, 1000, 10000, 100000]) == 41620\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 82\n assert candidate(nums = [5, 3, 8, 1, 9],cost = [10, 20, 30, 40, 50]) == 460\n assert candidate(nums = [5, 4, 3, 2, 1],cost = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [5, 5, 5, 5, 5],cost = [1000000, 1000000, 1000000, 1000000, 1000000]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 250\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995],cost = [1, 2, 3, 4, 5, 6]) == 26\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],cost = [3, 2, 1, 1, 2, 3, 3, 2, 1]) == 12\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 112\n assert candidate(nums = [1, 5, 10, 15, 20],cost = [5, 1, 10, 1, 5]) == 105\n assert candidate(nums = [1, 2, 3, 4, 5],cost = [1, 1, 1, 1, 1000000]) == 10\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],cost = [5, 5, 5, 5, 5]) == 30000\n assert candidate(nums = [1, 5, 7, 9, 11],cost = [1, 10, 100, 1000, 10000]) == 2470\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],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]) == 29\n assert candidate(nums = [1, 1, 1, 1, 1],cost = [1000000, 1000000, 1000000, 1000000, 1000000]) == 0\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000],cost = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],cost = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 49999750\n assert candidate(nums = [9, 1, 4, 6, 2],cost = [5, 3, 8, 6, 7]) == 60\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 390\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 112000\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000],cost = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9],cost = [1, 2, 3, 4, 5]) == 30\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],cost = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 5600\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 102\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],cost = [999, 888, 777, 666, 555]) == 4662000\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],cost = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 11200\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 12\n assert candidate(nums = [999999, 1000000, 999998],cost = [10, 1, 1]) == 2\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 112\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [100, 150, 200, 250, 300],cost = [1, 2, 3, 4, 5]) == 750\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5],cost = [1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(nums = [50, 40, 30, 20, 10],cost = [1, 2, 3, 4, 5]) == 150\n assert candidate(nums = [10, 20, 30, 40, 50],cost = [1, 2, 3, 4, 5]) == 150\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 112\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1],cost = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [3, 1, 2],cost = [5, 10, 15]) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 200\n assert candidate(nums = [1, 2, 2, 3, 4, 5],cost = [1, 1000, 1000, 100, 1, 1]) == 106\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 2500\n assert candidate(nums = [5, 3, 8, 6, 7],cost = [2, 5, 3, 7, 4]) == 27\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1120\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 112000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n assert candidate(nums = [1, 3, 5, 2, 4],cost = [2, 3, 1, 14, 5]) == 18\n assert candidate(nums = [9, 1, 5, 3, 7, 6],cost = [10, 1, 5, 2, 8, 3]) == 47\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],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]) == 2767\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],cost = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 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],cost = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 840\n assert candidate(nums = [123456, 123456, 123456, 123456],cost = [100000, 200000, 300000, 400000]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5],cost = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5]) == 40\n assert candidate(nums = [1, 100000, 50000, 75000, 25000],cost = [1000, 1, 100, 10, 100]) == 8349789\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 720\n assert candidate(nums = [1, 1000000, 500000],cost = [1000000, 1, 1]) == 1499998\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1120\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],cost = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 840\n assert candidate(nums = [7, 7, 7, 7, 7, 7],cost = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],cost = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 101009989899\n assert candidate(nums = [10, 10, 10, 10, 10, 10],cost = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n assert candidate(nums = [100, 200, 300, 400, 500],cost = [10, 20, 30, 40, 50]) == 15000\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250],cost = [1, 2, 4, 8, 16]) == 306250\n assert candidate(nums = [5, 7, 3, 10, 8],cost = [1, 5, 7, 2, 6]) == 42\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11200\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n assert candidate(nums = [1000000, 1, 1000000, 1, 1000000],cost = [1, 1000000, 1, 1000000, 1]) == 2999997\n assert candidate(nums = [5, 3, 8, 10, 1],cost = [1, 2, 3, 4, 5]) == 53\n assert candidate(nums = [123456, 654321, 111111, 222222, 333333],cost = [1000, 2000, 3000, 4000, 5000]) == 1851852000\n assert candidate(nums = [10, 20, 30, 40, 50],cost = [10, 20, 30, 40, 50]) == 1500\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 448\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 112\n assert candidate(nums = [1, 5, 9, 13, 17],cost = [10, 20, 30, 40, 50]) == 600\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],cost = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(nums = [1, 1000000],cost = [100000, 1]) == 999999\n assert candidate(nums = [1, 10, 100, 1000, 10000],cost = [10000, 1000, 100, 10, 1]) == 38889\n"}, "metadata": {"canonical_parameter_names": ["nums", "cost"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minCost(int[] nums, int[] cost) {", "container": "Solution", "callable": "minCost", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "cost", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2449, "task_id": "minimum-number-of-operations-to-make-arrays-similar", "difficulty": "Hard", "problem_description": "You are given two positive integer arrays nums and target, of the same length.\nIn one operation, you can choose any two distinct indices i and j where 0 <= i, j < nums.length and:\n\nset nums[i] = nums[i] + 2 and\nset nums[j] = nums[j] - 2.\n\nTwo arrays are considered to be similar if the frequency of each element is the same.\nReturn the minimum number of operations required to make nums similar to target. The test cases are generated such that nums can always be similar to target.\n \nExample 1:\n\nInput: nums = [8,12,6], target = [2,14,10]\nOutput: 2\nExplanation: It is possible to make nums similar to target in two operations:\n- Choose i = 0 and j = 2, nums = [10,12,4].\n- Choose i = 1 and j = 2, nums = [10,14,2].\nIt can be shown that 2 is the minimum number of operations needed.\n\nExample 2:\n\nInput: nums = [1,2,5], target = [4,1,3]\nOutput: 1\nExplanation: We can make nums similar to target in one operation:\n- Choose i = 1 and j = 2, nums = [1,4,3].\n\nExample 3:\n\nInput: nums = [1,1,1,1,1], target = [1,1,1,1,1]\nOutput: 0\nExplanation: The array nums is already similiar to target.\n\n \nConstraints:\n\nn == nums.length == target.length\n1 <= n <= 105\n1 <= nums[i], target[i] <= 106\nIt is possible to make nums similar to target.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 3, 3, 3],target = [1, 5, 1, 5]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1],target = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [3, 3, 3, 3],target = [5, 1, 5, 1]) == 2\n assert candidate(nums = [100000, 50000, 10000],target = [10000, 50000, 100000]) == 0\n assert candidate(nums = [1000000, 500000, 250000],target = [500000, 250000, 125000]) == 218750\n assert candidate(nums = [4, 6, 8],target = [2, 6, 10]) == 1\n assert candidate(nums = [8, 12, 6],target = [2, 14, 10]) == 2\n assert candidate(nums = [1000000, 500000, 250000],target = [125000, 375000, 875000]) == 93750\n assert candidate(nums = [2, 2, 2, 2, 2, 2],target = [4, 4, 4, 0, 0, 0]) == 3\n assert candidate(nums = [4, 6, 8],target = [2, 4, 6]) == 1\n assert candidate(nums = [1, 2, 5],target = [4, 1, 3]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],target = [5, 15, 25, 35, 45]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9],target = [2, 4, 6, 8, 10]) == 1\n assert candidate(nums = [2, 4, 6, 8],target = [8, 6, 4, 2]) == 0\n assert candidate(nums = [2, 6, 10, 14, 18],target = [4, 8, 12, 16, 20]) == 2\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500],target = [62500, 125000, 250000, 500000, 1000000]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],target = [150, 250, 350, 450, 550]) == 62\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],target = [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]) == 37\n assert candidate(nums = [10, 20, 30, 40, 50, 60],target = [5, 15, 25, 35, 45, 55]) == 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, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],target = [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]) == 12\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],target = [500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 8500, 9500]) == 1250\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]) == 0\n assert candidate(nums = [3, 7, 11, 15, 19, 23],target = [5, 9, 13, 17, 21, 25]) == 3\n assert candidate(nums = [9, 11, 13, 15, 17, 19, 21, 23],target = [7, 13, 19, 25, 31, 37, 43, 49]) == 25\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],target = [1010, 909, 808, 707, 606, 505, 404, 303, 202, 101]) == 0\n assert candidate(nums = [11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = [9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == 5\n assert candidate(nums = [101, 202, 303, 404, 505],target = [103, 204, 305, 406, 507]) == 2\n assert candidate(nums = [1000000, 999998, 999996, 999994, 999992],target = [999999, 999997, 999995, 999993, 999991]) == 1\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]) == 12\n assert candidate(nums = [3, 7, 11, 13, 17],target = [5, 9, 15, 19, 23]) == 5\n assert candidate(nums = [2, 4, 6, 8, 10],target = [1, 3, 5, 7, 9]) == 1\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]) == 12\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]) == 2\n assert candidate(nums = [5, 12, 18, 24, 30, 36],target = [3, 15, 21, 27, 33, 39]) == 13\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]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700],target = [50, 150, 250, 350, 450, 550, 650]) == 87\n assert candidate(nums = [9, 7, 5, 3, 1],target = [2, 4, 6, 8, 10]) == 1\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],target = [50000, 150000, 250000, 350000, 450000]) == 62500\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == 20\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]) == 0\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38],target = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 5\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = [1, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999]) == 2\n assert candidate(nums = [1, 5, 9, 13, 17, 21],target = [3, 7, 11, 15, 19, 23]) == 3\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],target = [1, 9, 17, 25, 33, 41, 49, 57, 65, 73]) == 58\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],target = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63]) == 45\n assert candidate(nums = [2, 4, 6, 8, 10, 12],target = [1, 5, 7, 9, 11, 13]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500],target = [98, 198, 298, 398, 498]) == 2\n assert candidate(nums = [11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = [10, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 2\n assert candidate(nums = [11, 21, 31, 41, 51, 61],target = [9, 19, 29, 39, 49, 59]) == 3\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],target = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38]) == 2\n assert candidate(nums = [2, 4, 6, 8, 10],target = [1, 3, 5, 7, 9]) == 1\n assert candidate(nums = [8, 16, 24, 32, 40, 48],target = [14, 22, 30, 38, 46, 54]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11],target = [2, 4, 6, 8, 10, 12]) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27],target = [5, 8, 11, 14, 17, 20, 23, 26, 29]) == 4\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1563],target = [1562, 3125, 6250, 12500, 25000, 50000, 100000]) == 49218\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22],target = [3, 6, 9, 12, 15, 18, 21, 24]) == 4\n assert candidate(nums = [2, 4, 6, 8, 10, 12],target = [1, 3, 5, 7, 9, 11]) == 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],target = [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]) == 0\n assert candidate(nums = [1000000, 999998, 999996, 999994, 999992, 999990, 999988, 999986, 999984, 999982],target = [999999, 999997, 999995, 999993, 999991, 999989, 999987, 999985, 999983, 999981]) == 2\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]) == 2\n assert candidate(nums = [99, 97, 95, 93, 91, 89, 87],target = [101, 99, 97, 95, 93, 91, 89]) == 3\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 10, 10, 10, 10, 10],target = [10, 10, 10, 10, 10, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],target = [2, 4, 6, 8, 10, 12, 14, 16]) == 2\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],target = [100001, 100003, 100005, 100007, 100009, 100011, 100013, 100015, 100017, 100019]) == 36\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]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],target = [2, 4, 6, 8, 10, 12, 14]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10],target = [10, 8, 6, 4, 2]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]) == 18\n assert candidate(nums = [2, 6, 18, 34, 50],target = [1, 5, 17, 33, 49]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],target = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650, 1750, 1850, 1950]) == 250\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],target = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73]) == 7\n assert candidate(nums = [8, 6, 4, 2, 0],target = [10, 8, 6, 4, 2]) == 2\n assert candidate(nums = [1, 1, 3, 3, 5, 5, 7, 7],target = [2, 2, 4, 4, 6, 6, 8, 8]) == 2\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],target = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73, 78, 83, 88, 93, 98]) == 10\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],target = [1500, 2500, 3500, 4500, 5500]) == 625\n assert candidate(nums = [9, 7, 5, 3, 1],target = [10, 8, 6, 4, 2]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 3\n assert candidate(nums = [11, 17, 23, 29, 31],target = [13, 19, 25, 27, 37]) == 3\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]) == 95\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15],target = [2, 4, 6, 8, 10, 12, 14]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600],target = [150, 250, 350, 450, 550, 650]) == 75\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99],target = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 53\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99],target = [9, 19, 29, 39, 49, 59, 69, 79, 89]) == 53\n assert candidate(nums = [99, 97, 95, 93, 91, 89, 87, 85, 83, 81],target = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119]) == 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = [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]) == 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],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],target = [2, 4, 6, 8, 10, 12, 14, 16]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = [4, 9, 14, 19, 24, 29, 34, 39, 44, 49]) == 12\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]) == 2\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28],target = [2, 6, 10, 14, 18, 22, 26]) == 3\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643],target = [2147483643, 2147483644, 2147483645, 2147483646, 2147483647]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],target = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == 15\n assert candidate(nums = [5, 10, 15, 20, 25, 30],target = [1, 6, 11, 16, 21, 26]) == 6\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63],target = [15, 24, 33, 42, 51, 60, 69]) == 10\n assert candidate(nums = [3, 6, 9, 12, 15, 18],target = [2, 7, 10, 13, 16, 19]) == 5\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],target = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 3\n assert candidate(nums = [3, 5, 7, 9],target = [1, 7, 11, 13]) == 3\n assert candidate(nums = [100, 200, 300, 400, 500],target = [50, 150, 250, 350, 450]) == 62\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 2\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],target = [1, 3, 7, 15, 30, 61, 122, 244, 488, 976, 1953, 3906, 7812, 15625, 31250, 62500, 125000, 250000, 500000, 1000000]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 4\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]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13],target = [1, 4, 6, 8, 10, 12]) == 6\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().makeSimilar", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long makeSimilar(int[] nums, int[] target) {", "container": "Solution", "callable": "makeSimilar", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "target", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2451, "task_id": "odd-string-difference", "difficulty": "Easy", "problem_description": "You are given an array of equal-length strings words. Assume that the length of each string is n.\nEach string words[i] can be converted into a difference integer array difference[i] of length n - 1 where difference[i][j] = words[i][j+1] - words[i][j] where 0 <= j <= n - 2. Note that the difference between two letters is the difference between their positions in the alphabet i.e. the position of 'a' is 0, 'b' is 1, and 'z' is 25.\n\nFor example, for the string \"acb\", the difference integer array is [2 - 0, 1 - 2] = [2, -1].\n\nAll the strings in words have the same difference integer array, except one. You should find that string.\nReturn the string in words that has different difference integer array.\n \nExample 1:\n\nInput: words = [\"adc\",\"wzy\",\"abc\"]\nOutput: \"abc\"\nExplanation: \n- The difference integer array of \"adc\" is [3 - 0, 2 - 3] = [3, -1].\n- The difference integer array of \"wzy\" is [25 - 22, 24 - 25]= [3, -1].\n- The difference integer array of \"abc\" is [1 - 0, 2 - 1] = [1, 1]. \nThe odd array out is [1, 1], so we return the corresponding string, \"abc\".\n\nExample 2:\n\nInput: words = [\"aaa\",\"bob\",\"ccc\",\"ddd\"]\nOutput: \"bob\"\nExplanation: All the integer arrays are [0, 0] except for \"bob\", which corresponds to [13, -13].\n\n \nConstraints:\n\n3 <= words.length <= 100\nn == words[i].length\n2 <= n <= 20\nwords[i] consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['adc', 'wzy', 'abc']) == \"abc\"\n assert candidate(words = ['zzz', 'zyx', 'zwy', 'zvx']) == \"zzz\"\n assert candidate(words = ['zzz', 'zyz', 'zxz', 'wyz']) == \"zzz\"\n assert candidate(words = ['aaa', 'bob', 'ccc', 'ddd']) == \"bob\"\n assert candidate(words = ['aab', 'aac', 'aad', 'abe']) == \"aab\"\n assert candidate(words = ['xyz', 'abc', 'uvw', 'aaa']) == \"aaa\"\n assert candidate(words = ['aaa', 'aaa', 'aab', 'aaa']) == \"aab\"\n assert candidate(words = ['zzz', 'aaa', 'zzz', 'aaa', 'zzz', 'aab']) == \"aab\"\n assert candidate(words = ['xyz', 'uvw', 'rst', 'qpo']) == \"qpo\"\n assert candidate(words = ['aab', 'aac', 'aba', 'aaa']) == \"aab\"\n assert candidate(words = ['qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'cba', 'bac']) == \"yza\"\n assert candidate(words = ['qrst', 'qrsu', 'rstv', 'rstw']) == \"qrst\"\n assert candidate(words = ['qrst', 'qrst', 'qrst', 'qrsu', 'qrst']) == \"qrsu\"\n assert candidate(words = ['abc', 'bcd', 'cde', 'ade']) == \"ade\"\n assert candidate(words = ['aab', 'aac', 'aba', 'aaa', 'aab', 'aac', 'aba', 'aac', 'aba', 'aab', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba']) == \"aaa\"\n assert candidate(words = ['abc', 'bcd', 'cde', 'bce']) == \"bce\"\n assert candidate(words = ['qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza']) == \"yza\"\n assert candidate(words = ['abc', 'bde', 'cef', 'dfg', 'efh', 'fij', 'gjk', 'hkl', 'ilm', 'jmn', 'kno', 'lop', 'mqr', 'nrs', 'ots', 'puv', 'qvw', 'rxy', 'syz', 'tza', 'uab', 'vbc', 'wcd', 'xey', 'yfz', 'zga']) == \"abc\"\n assert candidate(words = ['jkl', 'klm', 'lmn', 'mno', 'jklm']) == \"jklm\"\n assert candidate(words = ['mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'abc', 'bcd', 'cde']) == \"yza\"\n assert candidate(words = ['uvw', 'vwx', 'wxy', 'vxz', 'wyz']) == \"vxz\"\n assert candidate(words = ['xyz', 'wxy', 'vwx', 'uvw', 'tuv', 'stu', 'rst', 'qrs', 'pqr', 'opq', 'nop', 'mno', 'lnm', 'klj', 'ijk', 'hgf', 'fed', 'edc', 'dcb', 'cba', 'bca', 'cab', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'bac']) == \"lnm\"\n assert candidate(words = ['pqr', 'qrs', 'rst', 'uvw', 'vwx', 'wxy', 'xyz', 'xya']) == \"xya\"\n assert candidate(words = ['abcdefg', 'abcdefh', 'abcdefi', 'abcdefj', 'abcdefg']) == \"abcdefh\"\n assert candidate(words = ['aaa', 'abb', 'acc', 'add', 'aee', 'aff', 'agg', 'aeh', 'aei', 'aej', 'aek', 'ael', 'aem', 'aen', 'aeo', 'aep', 'aeq', 'aer', 'aes', 'aet', 'aeu', 'aev', 'aew', 'aex', 'aey', 'aez', 'afa', 'afb', 'afc', 'afd', 'afe', 'aff', 'afg', 'afh']) == \"aaa\"\n assert candidate(words = ['xyz', 'xza', 'ywb', 'ywa']) == \"xyz\"\n assert candidate(words = ['zzz', 'zzy', 'zzx', 'zzw', 'zzv']) == \"zzz\"\n assert candidate(words = ['mnop', 'nqpo', 'opqr', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwz', 'vwxy', 'wxza', 'xyzb', 'yzca', 'zcab', 'cabc', 'abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrt', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwz', 'vwxy', 'wxza', 'xyzb', 'yzca', 'zcab', 'cabc', 'abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno']) == \"nqpo\"\n assert candidate(words = ['aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'bbaacceeddffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'ccaabbeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzz']) == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'geh', 'hif', 'iji', 'jik']) == \"geh\"\n assert candidate(words = ['qwert', 'wertr', 'ertty', 'rtyui', 'tyuio']) == \"qwert\"\n assert candidate(words = ['aaa', 'aab', 'aac', 'aad', 'zaa']) == \"aaa\"\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzza']) == \"zzzzzzzzza\"\n assert candidate(words = ['zzz', 'zyz', 'xyx', 'wxw', 'vuq', 'tsr']) == \"zzz\"\n assert candidate(words = ['mnop', 'mnoq', 'mnop', 'mnoo', 'mnop']) == \"mnoq\"\n assert candidate(words = ['mno', 'nop', 'opo', 'npp', 'mqq']) == \"opo\"\n assert candidate(words = ['aaa', 'aba', 'aca', 'ada', 'aea', 'afa', 'aga', 'aha']) == \"aaa\"\n assert candidate(words = ['mnopqr', 'mnopqs', 'mnopqt', 'mnopqu', 'mnopqv']) == \"mnopqr\"\n assert candidate(words = ['qwe', 'rft', 'sgh', 'tij', 'ukl', 'vmo']) == \"qwe\"\n assert candidate(words = ['abcdef', 'abcefg', 'abcdgg', 'abcdef', 'abcdeg']) == \"abcefg\"\n assert candidate(words = ['abz', 'bca', 'cab', 'bac', 'acb', 'baa', 'aaa', 'aab']) == \"abz\"\n assert candidate(words = ['abz', 'bca', 'cab', 'abc']) == \"abz\"\n assert candidate(words = ['aaa', 'aab', 'aac', 'aad', 'aae', 'aaf', 'aag', 'aah', 'aai', 'aaj', 'aak', 'aal', 'aam', 'aan', 'aao', 'aap', 'aaq', 'aar', 'aas', 'aat', 'aau', 'aav', 'aaw', 'aax', 'aay', 'aaz', 'abb', 'abc']) == \"aaa\"\n assert candidate(words = ['aab', 'aac', 'aab', 'aac', 'aab', 'aac', 'aad', 'aac']) == \"aad\"\n assert candidate(words = ['zzz', 'zyz', 'zyx', 'zzx', 'zyw']) == \"zzz\"\n assert candidate(words = ['uvw', 'uvx', 'uwy', 'uxz']) == \"uvw\"\n assert candidate(words = ['mnop', 'nqpr', 'opqs', 'pqrt']) == \"mnop\"\n assert candidate(words = ['zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzza']) == \"zzzzzzzzzzzzzzzzzzza\"\n assert candidate(words = ['xyz', 'yza', 'zab', 'xba', 'xza']) == \"xyz\"\n assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza']) == \"yza\"\n assert candidate(words = ['mnop', 'mnoq', 'mnop', 'mnop']) == \"mnoq\"\n assert candidate(words = ['pqr', 'qrs', 'rst', 'qst', 'qrt']) == \"qst\"\n assert candidate(words = ['aaa', 'aba', 'aca', 'ada', 'aea']) == \"aaa\"\n assert candidate(words = ['aaa', 'aab', 'aba', 'aca', 'baa']) == \"aaa\"\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxzz']) == \"abcdefghijklmnopqrstuvwxzz\"\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'aefghi']) == \"aefghi\"\n assert candidate(words = ['xyz', 'yza', 'zab', 'abc']) == \"yza\"\n assert candidate(words = ['xyz', 'xwv', 'xut', 'xsr']) == \"xyz\"\n assert candidate(words = ['uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'aaa', 'aab', 'aac', 'aad', 'abe', 'acd']) == \"aaa\"\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn', 'jklmno', 'klmnop', 'lmnopq', 'mnopqr', 'nopqrs', 'opqrst', 'pqrstu', 'qrstuv', 'rstuvw', 'stuvwx', 'tuvwxy', 'uvwxyx', 'vwxyxw', 'wxyxwy', 'xyxwyx', 'yxwyxy']) == \"uvwxyx\"\n assert candidate(words = ['aaaab', 'aaaba', 'aabaa', 'abaaa', 'baaaa']) == \"aaaab\"\n assert candidate(words = ['abcdefghijklmnop', 'bcdefghijklmno', 'cdefghijklmnop', 'dEefghijklmnop', 'efghijklmnopqr', 'fghijklmnopqrs', 'ghijklmnopqrst', 'hijklmnopqrstu', 'ijklmnopqrstuv', 'jklmnopqrstuvw', 'klmnopqrstuvwx', 'lmnopqrstuvwxy', 'mnopqrstuvwxyz']) == \"abcdefghijklmnop\"\n assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'aaa', 'aab', 'aac', 'aad', 'abe']) == \"yza\"\n assert candidate(words = ['zzz', 'zzy', 'zyz', 'yzz', 'zyx', 'yxz', 'xzy', 'xyz', 'yxw', 'xyw', 'xwy', 'ywx', 'wxy', 'wyz', 'xzy', 'xyz', 'xwy', 'ywx', 'wxy', 'wyz', 'xzy', 'xyz', 'xwy', 'ywx']) == \"zzz\"\n assert candidate(words = ['mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyx', 'yzy', 'zzz', 'yzy', 'xyx', 'vwx', 'uvw', 'tuv', 'stu', 'qrs', 'pqr', 'opq', 'nop', 'mno', 'zyz', 'zzz']) == \"zyz\"\n assert candidate(words = ['zzz', 'aaa', 'aab', 'aac', 'aad']) == \"aab\"\n assert candidate(words = ['hello', 'hero', 'helq', 'herl']) == \"hello\"\n assert candidate(words = ['xyz', 'yza', 'zab', 'cab', 'bcd']) == \"yza\"\n assert candidate(words = ['pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'aba', 'bab', 'bba', 'aab', 'aaa', 'aab', 'aba', 'abb', 'abc']) == \"yza\"\n assert candidate(words = ['zzz', 'yyy', 'xxz', 'xxy']) == \"xxz\"\n assert candidate(words = ['xyz', 'xza', 'xya', 'xwa']) == \"xyz\"\n assert candidate(words = ['ghi', 'hij', 'ijk', 'jkl', 'gij']) == \"gij\"\n assert candidate(words = ['pqr', 'qrs', 'rst', 'str']) == \"str\"\n assert candidate(words = ['zxy', 'zyx', 'yxz', 'yzy']) == \"zxy\"\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abcd', 'abcg']) == \"abce\"\n assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'cab', 'bca', 'abc', 'bca', 'cab', 'bac', 'acb', 'baa', 'aaa', 'aab', 'aac', 'aad', 'aba', 'abb', 'abc', 'aca', 'acb', 'acc']) == \"yza\"\n assert candidate(words = ['apple', 'applf', 'applg', 'applh']) == \"apple\"\n assert candidate(words = ['zzz', 'yyz', 'xxz', 'wwz', 'vvz', 'uuz', 'ttz', 'ssz', 'rrz', 'qqz', 'ppz', 'opo', 'ono', 'nnm', 'nml', 'nkl', 'nlj', 'nik', 'ihj', 'igh', 'ifh', 'ieh', 'idh', 'ich', 'ibh', 'iah', 'azg', 'azy', 'ayx', 'axw', 'avv', 'auu', 'att', 'ass', 'arr', 'aqq', 'app', 'aoo', 'ano', 'aml', 'akl', 'ajk', 'aik', 'aih', 'aig', 'aif', 'aie', 'aid', 'aic', 'abh', 'aag', 'aaf', 'aae', 'aad', 'aac', 'aab']) == \"zzz\"\n assert candidate(words = ['qwe', 'rty', 'uio', 'pas', 'qdf']) == \"qwe\"\n assert candidate(words = ['aab', 'aac', 'aad', 'abe', 'bbf', 'ccg', 'ddd']) == \"aab\"\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().oddString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String oddString(String[] words) {", "container": "Solution", "callable": "oddString", "parameters": [{"name": "words", "type": "String[]"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2452, "task_id": "words-within-two-edits-of-dictionary", "difficulty": "Medium", "problem_description": "You are given two string arrays, queries and dictionary. All words in each array comprise of lowercase English letters and have the same length.\nIn one edit you can take a word from queries, and change any letter in it to any other letter. Find all words from queries that, after a maximum of two edits, equal some word from dictionary.\nReturn a list of all words from queries, that match with some word from dictionary after a maximum of two edits. Return the words in the same order they appear in queries.\n \nExample 1:\n\nInput: queries = [\"word\",\"note\",\"ants\",\"wood\"], dictionary = [\"wood\",\"joke\",\"moat\"]\nOutput: [\"word\",\"note\",\"wood\"]\nExplanation:\n- Changing the 'r' in \"word\" to 'o' allows it to equal the dictionary word \"wood\".\n- Changing the 'n' to 'j' and the 't' to 'k' in \"note\" changes it to \"joke\".\n- It would take more than 2 edits for \"ants\" to equal a dictionary word.\n- \"wood\" can remain unchanged (0 edits) and match the corresponding dictionary word.\nThus, we return [\"word\",\"note\",\"wood\"].\n\nExample 2:\n\nInput: queries = [\"yes\"], dictionary = [\"not\"]\nOutput: []\nExplanation:\nApplying any two edits to \"yes\" cannot make it equal to \"not\". Thus, we return an empty array.\n\n \nConstraints:\n\n1 <= queries.length, dictionary.length <= 100\nn == queries[i].length == dictionary[j].length\n1 <= n <= 100\nAll queries[i] and dictionary[j] are composed of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(queries = ['test', 'text', 'sett'],dictionary = ['test', 'text', 'sett', 'best']) == ['test', 'text', 'sett']\n assert candidate(queries = ['abc', 'bcd', 'cde'],dictionary = ['xyz', 'zyx', 'abc']) == ['abc']\n assert candidate(queries = ['apple', 'apply'],dictionary = ['appla', 'apple', 'apply']) == ['apple', 'apply']\n assert candidate(queries = ['test', 'text', 'sett'],dictionary = ['text', 'test', 'sett', 'best']) == ['test', 'text', 'sett']\n assert candidate(queries = ['hello', 'world'],dictionary = ['hallo', 'wurld', 'holdo']) == ['hello', 'world']\n assert candidate(queries = ['word', 'note', 'ants', 'wood'],dictionary = ['wood', 'joke', 'moat']) == ['word', 'note', 'wood']\n assert candidate(queries = ['test', 'sett', 'best'],dictionary = ['rest', 'test', 'best']) == ['test', 'sett', 'best']\n assert candidate(queries = ['abcd', 'abce', 'abcf'],dictionary = ['abef', 'abcf', 'abcd']) == ['abcd', 'abce', 'abcf']\n assert candidate(queries = ['apple', 'apply', 'spoil'],dictionary = ['appla', 'appie', 'spoil']) == ['apple', 'apply', 'spoil']\n assert candidate(queries = ['hello', 'world'],dictionary = ['hallo', 'werld']) == ['hello', 'world']\n assert candidate(queries = ['apple', 'apply', 'happy'],dictionary = ['pally', 'apple', 'happy']) == ['apple', 'apply', 'happy']\n assert candidate(queries = ['test', 'text', 'sett'],dictionary = ['best', 'text', 'west']) == ['test', 'text', 'sett']\n assert candidate(queries = ['apple', 'apply'],dictionary = ['spale', 'spaly']) == ['apple', 'apply']\n assert candidate(queries = ['aabb', 'abab', 'baba'],dictionary = ['aaaa', 'bbbb', 'abab']) == ['aabb', 'abab', 'baba']\n assert candidate(queries = ['yes'],dictionary = ['not']) == []\n assert candidate(queries = ['test'],dictionary = ['tast', 'test', 'sett']) == ['test']\n assert candidate(queries = ['elephant', 'giraffe', 'hippo'],dictionary = ['elefant', 'giraff', 'hippo']) == ['giraffe', 'hippo']\n assert candidate(queries = ['xylophone', 'balloon', 'umbrella'],dictionary = ['xylofune', 'baloone', 'umbrelia', 'xylophine', 'balloon']) == ['xylophone', 'balloon', 'umbrella']\n assert candidate(queries = ['abcdefgh', 'abcdefghi', 'abcdefghj'],dictionary = ['abcdefghj', 'abcdefghi', 'abcdefghk']) == ['abcdefgh', 'abcdefghi', 'abcdefghj']\n assert candidate(queries = ['banana', 'bananb', 'bananc'],dictionary = ['banana', 'bananb', 'bananc', 'banand']) == ['banana', 'bananb', 'bananc']\n assert candidate(queries = ['abcdefgh', 'abcdefgh'],dictionary = ['abcdefgh', 'abcdefgh', 'abcdefgh']) == ['abcdefgh', 'abcdefgh']\n assert candidate(queries = ['algorithm', 'datastructure', 'binarysearch'],dictionary = ['alorithm', 'datstructure', 'binrysearch']) == []\n assert candidate(queries = ['banana', 'ananas'],dictionary = ['banana', 'ananas', 'bandana', 'panama', 'kanana']) == ['banana', 'ananas']\n assert candidate(queries = ['racecar', 'level', 'rotor'],dictionary = ['racecer', 'levek', 'roter']) == ['racecar', 'level', 'rotor']\n assert candidate(queries = ['xylophone', 'clarinet'],dictionary = ['xylophon', 'clarinat', 'xylopane', 'clarinet', 'xylophen']) == ['xylophone', 'clarinet']\n assert candidate(queries = ['abcdef', 'fedcba'],dictionary = ['fedcba', 'abcdefg', 'bacdef']) == ['abcdef', 'fedcba']\n assert candidate(queries = ['abcdefghij', 'klmnopqrst'],dictionary = ['abcdeffhij', 'klmnopqrts', 'abcdefghij']) == ['abcdefghij', 'klmnopqrst']\n assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr'],dictionary = ['abcdeg', 'ghijkm', 'mnopqs']) == ['abcdef', 'ghijkl', 'mnopqr']\n assert candidate(queries = ['abcd', 'abce', 'abcf'],dictionary = ['abcf', 'abcg', 'abcd', 'abch']) == ['abcd', 'abce', 'abcf']\n assert candidate(queries = ['abcdefghij', 'jihgfedcba'],dictionary = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba', 'abcdefghij']) == ['abcdefghij', 'jihgfedcba']\n assert candidate(queries = ['abcd', 'abdc', 'acbd', 'acdb'],dictionary = ['abcd', 'abdc', 'acbd', 'acdb', 'dcba', 'bdca']) == ['abcd', 'abdc', 'acbd', 'acdb']\n assert candidate(queries = ['abcdefgh', 'abcdefghi'],dictionary = ['abcdefgh', 'abcdefghij', 'abcdefghi', 'abcdefghijj']) == ['abcdefgh', 'abcdefghi']\n assert candidate(queries = ['abcdefghij', 'abcdefghij', 'abcdefghij'],dictionary = ['abcdefghij', 'abcdefghik', 'abcdefghil', 'abcdefghim', 'abcdefghin']) == ['abcdefghij', 'abcdefghij', 'abcdefghij']\n assert candidate(queries = ['abcdef', 'ghijkl'],dictionary = ['abchef', 'ghijkl', 'abcdeg', 'ghijkl', 'abcfeg']) == ['abcdef', 'ghijkl']\n assert candidate(queries = ['algorithm', 'data', 'structure'],dictionary = ['algorith', 'datq', 'strcuture']) == ['algorithm', 'data', 'structure']\n assert candidate(queries = ['abcdefghij', 'jihgfedcba'],dictionary = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba']) == ['abcdefghij', 'jihgfedcba']\n assert candidate(queries = ['abcdefghij', 'jihgfedcba'],dictionary = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'abcdefghij']) == ['abcdefghij', 'jihgfedcba']\n assert candidate(queries = ['abcdefgh', 'abceghij', 'abcdefij'],dictionary = ['abcdefgh', 'abceghij', 'abcdefij', 'abcdefgj']) == ['abcdefgh', 'abceghij', 'abcdefij']\n assert candidate(queries = ['testcase', 'unittest', 'performance'],dictionary = ['testcases', 'unitstest', 'performence']) == ['testcase', 'performance']\n assert candidate(queries = ['abcdefghij', 'klmnopqrst', 'uvwxyz'],dictionary = ['abcdefghig', 'klmnopqrsu', 'uvwxyg']) == ['abcdefghij', 'klmnopqrst', 'uvwxyz']\n assert candidate(queries = ['abcde', 'edcba', 'bacde'],dictionary = ['abcde', 'edcba', 'bacde', 'cabed', 'abcde', 'edcba', 'bacde', 'cabed']) == ['abcde', 'edcba', 'bacde']\n assert candidate(queries = ['sequence', 'consequence', 'subsequence'],dictionary = ['sequences', 'consequense', 'subsequense', 'sequence']) == ['sequence', 'consequence', 'subsequence']\n assert candidate(queries = ['abcdef', 'ghijkl'],dictionary = ['abcgef', 'ghikjl', 'abcdef']) == ['abcdef', 'ghijkl']\n assert candidate(queries = ['abcd', 'abce', 'abcf'],dictionary = ['abcf', 'abce', 'abcc']) == ['abcd', 'abce', 'abcf']\n assert candidate(queries = ['programming', 'development', 'debugging'],dictionary = ['proogramming', 'develpopment', 'debguggin']) == []\n assert candidate(queries = ['programming', 'python'],dictionary = ['programmmg', 'pythoon', 'progrqmig']) == ['programming', 'python']\n assert candidate(queries = ['python', 'pyhton', 'pythpn'],dictionary = ['python', 'pyhton', 'pythpn', 'pythun']) == ['python', 'pyhton', 'pythpn']\n assert candidate(queries = ['cat', 'bat', 'rat'],dictionary = ['cap', 'bap', 'rap', 'tap']) == ['cat', 'bat', 'rat']\n assert candidate(queries = ['abcdefghij', 'klmnopqrst'],dictionary = ['abcdefghij', 'klmnopqrts', 'abcdefghik', 'klmnopqrst', 'abcdefghim']) == ['abcdefghij', 'klmnopqrst']\n assert candidate(queries = ['programming', 'programing', 'progrmaing'],dictionary = ['programming', 'programing', 'progrmaing', 'prograaming']) == ['programming', 'programing', 'progrmaing']\n assert candidate(queries = ['kitten', 'sitten', 'bitten'],dictionary = ['sitten', 'kitten', 'biting', 'bitten']) == ['kitten', 'sitten', 'bitten']\n assert candidate(queries = ['test', 'tast', 'rest'],dictionary = ['best', 'rest', 'tast', 'test']) == ['test', 'tast', 'rest']\n assert candidate(queries = ['algorithm', 'data', 'structure'],dictionary = ['algorithim', 'datum', 'struckture']) == ['algorithm', 'data']\n assert candidate(queries = ['apple', 'banana', 'cherry'],dictionary = ['appla', 'banna', 'chhery']) == ['apple', 'banana', 'cherry']\n assert candidate(queries = ['programming', 'coding', 'debugging'],dictionary = ['programing', 'codding', 'debagging']) == ['debugging']\n assert candidate(queries = ['transform', 'transforn', 'tranformt'],dictionary = ['transfarm', 'transform', 'transfurm']) == ['transform', 'transforn']\n assert candidate(queries = ['mississippi', 'delaware', 'rhodeisland'],dictionary = ['mississipp', 'delawere', 'rhodeiland']) == ['mississippi', 'delaware']\n assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx'],dictionary = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx']) == ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx']\n assert candidate(queries = ['hello', 'hallo', 'hxllo'],dictionary = ['hallo', 'hell', 'hxllo', 'hxllx']) == ['hello', 'hallo', 'hxllo']\n assert candidate(queries = ['kitten', 'sitting', 'flask'],dictionary = ['kitchen', 'sitting', 'fask']) == ['kitten', 'sitting']\n assert candidate(queries = ['abcdefghij', 'abcdefghik', 'abcdefghil'],dictionary = ['abcdefghio', 'abcdefghij', 'abcdefghim']) == ['abcdefghij', 'abcdefghik', 'abcdefghil']\n assert candidate(queries = ['qwertyuiop', 'asdfghjklz', 'xcvbnm'],dictionary = ['qwertyuioz', 'asdfghjklx', 'xcvbnml']) == ['qwertyuiop', 'asdfghjklz', 'xcvbnm']\n assert candidate(queries = ['algorithm', 'algorith', 'algoritm'],dictionary = ['algorithm', 'algorith', 'algoritm', 'algorithn', 'aloritum']) == ['algorithm', 'algorith', 'algoritm']\n assert candidate(queries = ['elephant', 'giraffe', 'hippopotamus'],dictionary = ['elephont', 'giraff', 'hippopotamuse', 'elephant']) == ['elephant', 'giraffe', 'hippopotamus']\n assert candidate(queries = ['apple', 'apply', 'pally'],dictionary = ['appel', 'abble', 'appie']) == ['apple', 'apply']\n assert candidate(queries = ['zzzzzz', 'yyyyyy', 'xxxxxx'],dictionary = ['zzzzzz', 'yyyyyy', 'xxxxxx', 'wwwwww', 'vvvvvv', 'uuuuuu', 'tttttt']) == ['zzzzzz', 'yyyyyy', 'xxxxxx']\n assert candidate(queries = ['apple', 'apply', 'pally'],dictionary = ['appla', 'appli', 'apple', 'pally', 'polly']) == ['apple', 'apply', 'pally']\n assert candidate(queries = ['apple', 'apply', 'appla'],dictionary = ['apple', 'apply', 'appel', 'appla']) == ['apple', 'apply', 'appla']\n assert candidate(queries = ['aaaaaa', 'bbbbbb', 'cccccc'],dictionary = ['aaaaab', 'bbbbc', 'cccccd']) == ['aaaaaa', 'bbbbbb', 'cccccc']\n assert candidate(queries = ['kitten', 'sitting'],dictionary = ['sitting', 'kitten', 'bitten', 'biting']) == ['kitten', 'sitting']\n assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],dictionary = ['abcdeg', 'ghijkm', 'mnopqs', 'stuvwx', 'yzabcd']) == ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd']\n assert candidate(queries = ['abcdefgh', 'hgfedcba', 'abcdefgh'],dictionary = ['abcdefgh', 'hgfedcba', 'zyxwvuts', 'qrstuvwx']) == ['abcdefgh', 'hgfedcba', 'abcdefgh']\n assert candidate(queries = ['kitten', 'sitting', 'kitten'],dictionary = ['sitting', 'kitten', 'bitten', 'kettle']) == ['kitten', 'sitting', 'kitten']\n assert candidate(queries = ['abcdefghijk', 'lmnopqrstuv'],dictionary = ['abcdefghij', 'lmnopqrstv', 'abcdefghijk', 'lmnopqrstuv', 'abcdefghikl']) == ['abcdefghijk', 'lmnopqrstuv']\n assert candidate(queries = ['abcdefghij', 'abcdefghij', 'abcdefghij'],dictionary = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == ['abcdefghij', 'abcdefghij', 'abcdefghij']\n assert candidate(queries = ['unbelievable', 'incredible', 'believable'],dictionary = ['unbelieveble', 'incredibile', 'believeble']) == ['unbelievable', 'incredible', 'believable']\n assert candidate(queries = ['abcde', 'fghij', 'klmno'],dictionary = ['abxde', 'fghij', 'klmnp']) == ['abcde', 'fghij', 'klmno']\n assert candidate(queries = ['repetition', 'repetitions', 'repetitive'],dictionary = ['repetion', 'repetitons', 'repetite']) == ['repetition', 'repetitions', 'repetitive']\n assert candidate(queries = ['apple', 'apply', 'appla'],dictionary = ['appel', 'apply', 'ample']) == ['apple', 'apply', 'appla']\n assert candidate(queries = ['abcdefgh', 'abcdefgh', 'abcdefgh'],dictionary = ['abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh']) == ['abcdefgh', 'abcdefgh', 'abcdefgh']\n assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr'],dictionary = ['abcdeg', 'ghikjl', 'mnopqg']) == ['abcdef', 'ghijkl', 'mnopqr']\n assert candidate(queries = ['abcdef', 'abcdeg', 'abcdeh'],dictionary = ['abcdef', 'abcdeg', 'abcdeh', 'abcdei']) == ['abcdef', 'abcdeg', 'abcdeh']\n assert candidate(queries = ['aabbcc', 'ddeeff', 'gghhii'],dictionary = ['aabbcc', 'ddeeff', 'gghhij']) == ['aabbcc', 'ddeeff', 'gghhii']\n assert candidate(queries = ['abcdefgh', 'hgfedcba'],dictionary = ['abcdefgh', 'hgfedcba', 'abcdefgh']) == ['abcdefgh', 'hgfedcba']\n assert candidate(queries = ['kitten', 'sitting', 'flask'],dictionary = ['kitchen', 'kitten', 'flasky']) == ['kitten', 'sitting', 'flask']\n assert candidate(queries = ['cat', 'dog', 'rat'],dictionary = ['bat', 'bag', 'rat', 'tag']) == ['cat', 'dog', 'rat']\n assert candidate(queries = ['abcdef', 'ghijkl'],dictionary = ['fedcba', 'lkjihg', 'abcdeg', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd']) == ['abcdef', 'ghijkl']\n assert candidate(queries = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc'],dictionary = ['aaaaaaaaaa', 'aaaaaaaabb', 'aaaaaaabbb', 'aaaaaabbbb', 'aaaaabbbbb', 'aaaabbbbbb', 'aabbbbbbbb', 'abbbbbbbbb', 'bbbbbbbbbb']) == ['aaaaaaaaaa', 'bbbbbbbbbb']\n assert candidate(queries = ['abcdefghij', 'abcdefghik'],dictionary = ['abcdefghix', 'abcdefghiy', 'abcdefghij']) == ['abcdefghij', 'abcdefghik']\n assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr'],dictionary = ['abcdej', 'ghijkl', 'mnopqr', 'mnopqs', 'mnopqt']) == ['abcdef', 'ghijkl', 'mnopqr']\n assert candidate(queries = ['dictionary', 'queries', 'solution'],dictionary = ['dictionry', 'querries', 'soultion']) == ['dictionary', 'solution']\n assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr'],dictionary = ['abcdef', 'ghijkl', 'mnopqt']) == ['abcdef', 'ghijkl', 'mnopqr']\n assert candidate(queries = ['mississippi', 'mississipp', 'mississippa'],dictionary = ['mississippi', 'mississippa', 'mississippb']) == ['mississippi', 'mississipp', 'mississippa']\n assert candidate(queries = ['abcdefg', 'hijklmn', 'opqrstu'],dictionary = ['abcdefg', 'hijklmn', 'opqrsuv']) == ['abcdefg', 'hijklmn', 'opqrstu']\n assert candidate(queries = ['abcdefgh', 'abcdefgh'],dictionary = ['abcdwxyz', 'abcdefgz', 'abcdefgh']) == ['abcdefgh', 'abcdefgh']\n assert candidate(queries = ['qwerty', 'asdfgh', 'zxcvbn'],dictionary = ['qwerty', 'qwertr', 'asdwgh', 'zxcvbn', 'qwertx']) == ['qwerty', 'asdfgh', 'zxcvbn']\n assert candidate(queries = ['aaaaaa', 'bbbbbb', 'cccccc'],dictionary = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd', 'eeeeee', 'ffffff']) == ['aaaaaa', 'bbbbbb', 'cccccc']\n assert candidate(queries = ['abcdefghij', 'jihgfedcba', 'abcdefghij'],dictionary = ['abcdefghij', 'jihgfedcba', 'abcdefghji', 'jihgfedcbj', 'abcdefghii', 'jihgfedcbi']) == ['abcdefghij', 'jihgfedcba', 'abcdefghij']\n assert candidate(queries = ['abcdefgh', 'abcdefgh'],dictionary = ['abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh']) == ['abcdefgh', 'abcdefgh']\n assert candidate(queries = ['algorithm', 'alorithgm', 'alohrithm'],dictionary = ['algorithm', 'alorithgm', 'alohrithm', 'aloritrhm']) == ['algorithm', 'alorithgm', 'alohrithm']\n assert candidate(queries = ['programming', 'prograiming', 'prograimng'],dictionary = ['programming', 'prograiming', 'prograimng', 'prograimnig']) == ['programming', 'prograiming', 'prograimng']\n assert candidate(queries = ['education', 'educatiom', 'educatiin'],dictionary = ['education', 'educatiom', 'educatiin', 'educatiomn']) == ['education', 'educatiom', 'educatiin']\n assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],dictionary = ['abcdefg', 'ghijklm', 'nopqrs', 'stuvwxy', 'yzabcdf']) == ['abcdef', 'ghijkl', 'stuvwx', 'yzabcd']\n assert candidate(queries = ['compiler', 'comipler', 'comipler'],dictionary = ['compiler', 'comipler', 'compilir', 'comiplir']) == ['compiler', 'comipler', 'comipler']\n assert candidate(queries = ['zzzzz', 'yyyyy', 'xxxxx'],dictionary = ['zzzzz', 'xyzyx', 'zxyxz']) == ['zzzzz']\n assert candidate(queries = ['zxywvutsrqponmlkjihgfedcba'],dictionary = ['zyxwvutsrqponmlkjihgfedcba', 'zxywvutsrqponmlkjihgfedcbb']) == ['zxywvutsrqponmlkjihgfedcba']\n assert candidate(queries = ['programming', 'language'],dictionary = ['progrgmmg', 'langauge', 'programming']) == ['programming', 'language']\n assert candidate(queries = ['apple', 'apply', 'ample'],dictionary = ['ample', 'appli', 'appel']) == ['apple', 'apply', 'ample']\n assert candidate(queries = ['kitten', 'sitting'],dictionary = ['kitten', 'sitting', 'biting', 'kiting', 'kitting']) == ['kitten', 'sitting']\n assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],dictionary = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd']) == ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd']\n assert candidate(queries = ['algorithm', 'algorith', 'algoritm'],dictionary = ['algorithm', 'algorith', 'algoritm', 'algorimt']) == ['algorithm', 'algorith', 'algoritm']\n assert candidate(queries = ['aaaaaa', 'bbbbbb', 'cccccc'],dictionary = ['aabbaa', 'bbccbb', 'ccddcc']) == ['aaaaaa', 'bbbbbb', 'cccccc']\n assert candidate(queries = ['abcdefghij', 'abcdefghij', 'abcdefghij'],dictionary = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == ['abcdefghij', 'abcdefghij', 'abcdefghij']\n assert candidate(queries = ['sunshine', 'rainbow', 'cloud'],dictionary = ['sunshn', 'rainbw', 'clodu']) == ['sunshine', 'rainbow', 'cloud']\n"}, "metadata": {"canonical_parameter_names": ["queries", "dictionary"], "leetcode_dataset_entry_point": "Solution().twoEditWords", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List twoEditWords(String[] queries, String[] dictionary) {", "container": "Solution", "callable": "twoEditWords", "parameters": [{"name": "queries", "type": "String[]"}, {"name": "dictionary", "type": "String[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2453, "task_id": "destroy-sequential-targets", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums consisting of positive integers, representing targets on a number line. You are also given an integer space.\nYou have a machine which can destroy targets. Seeding the machine with some nums[i] allows it to destroy all targets with values that can be represented as nums[i] + c * space, where c is any non-negative integer. You want to destroy the maximum number of targets in nums.\nReturn the minimum value of nums[i] you can seed the machine with to destroy the maximum number of targets.\n \nExample 1:\n\nInput: nums = [3,7,8,1,1,5], space = 2\nOutput: 1\nExplanation: If we seed the machine with nums[3], then we destroy all targets equal to 1,3,5,7,9,... \nIn this case, we would destroy 5 total targets (all except for nums[2]). \nIt is impossible to destroy more than 5 targets, so we return nums[3].\n\nExample 2:\n\nInput: nums = [1,3,5,2,4,6], space = 2\nOutput: 1\nExplanation: Seeding the machine with nums[0], or nums[3] destroys 3 targets. \nIt is not possible to destroy more than 3 targets.\nSince nums[0] is the minimal integer that can destroy 3 targets, we return 1.\n\nExample 3:\n\nInput: nums = [6,2,5], space = 100\nOutput: 2\nExplanation: Whatever initial seed we select, we can only destroy 1 target. The minimal seed is nums[1].\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= space <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],space = 1000000000) == 1000000000\n assert candidate(nums = [1000000000],space = 1000000000) == 1000000000\n assert candidate(nums = [1, 3, 5, 2, 4, 6],space = 2) == 1\n assert candidate(nums = [6, 2, 5],space = 100) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 1) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 1) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],space = 3) == 3\n assert candidate(nums = [7, 14, 21, 28, 35],space = 7) == 7\n assert candidate(nums = [10, 20, 30, 40, 50],space = 10) == 10\n assert candidate(nums = [9, 19, 29, 39, 49],space = 10) == 9\n assert candidate(nums = [3, 7, 8, 1, 1, 5],space = 2) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42],space = 7) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 3) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99],space = 11) == 11\n assert candidate(nums = [9, 18, 27, 36, 45],space = 9) == 9\n assert candidate(nums = [1, 1, 1, 1, 1],space = 1) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30],space = 5) == 5\n assert candidate(nums = [1000000000, 1000000000, 1000000000],space = 1) == 1000000000\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],space = 2) == 2\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],space = 1) == 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],space = 7) == 7\n assert candidate(nums = [100, 103, 106, 109, 112, 115, 118, 121, 124, 127, 130, 133, 136, 139, 142, 145, 148, 151, 154, 157, 160, 163, 166, 169, 172, 175, 178, 181, 184, 187, 190],space = 3) == 100\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],space = 4) == 1\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147],space = 3) == 3\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],space = 7) == 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],space = 2) == 2\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],space = 10) == 5\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],space = 4) == 4\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],space = 4) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],space = 7) == 7\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 109, 118, 127],space = 9) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],space = 100) == 100\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310, 341, 372, 403, 434, 465, 496, 527, 558, 589, 620],space = 31) == 31\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 1) == 1\n assert candidate(nums = [2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102, 112, 122, 132, 142, 152, 162, 172, 182, 192],space = 10) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],space = 3) == 3\n assert candidate(nums = [2, 102, 202, 302, 402, 502, 602, 702, 802, 902, 1002, 1102, 1202, 1302, 1402, 1502, 1602, 1702, 1802, 1902],space = 100) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536],space = 1) == 1\n assert candidate(nums = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901],space = 100) == 1\n assert candidate(nums = [3, 13, 23, 33, 43, 53, 63, 73, 83, 93],space = 10) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],space = 100) == 100\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],space = 15) == 15\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],space = 2) == 2\n assert candidate(nums = [5, 25, 45, 65, 85, 105, 125, 145, 165, 185, 205, 225, 245, 265, 285],space = 20) == 5\n assert candidate(nums = [99, 198, 297, 396, 495, 594, 693, 792, 891, 990, 1089, 1188, 1287, 1386, 1485, 1584, 1683, 1782, 1881, 1980],space = 99) == 99\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 1) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],space = 10) == 10\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],space = 8) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],space = 10) == 10\n assert candidate(nums = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001, 1101, 1201, 1301, 1401],space = 100) == 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],space = 15) == 15\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],space = 2) == 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],space = 4) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],space = 2) == 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],space = 1) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],space = 2) == 2\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000],space = 1000000) == 1000000\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907],space = 3) == 3\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91],space = 9) == 1\n assert candidate(nums = [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],space = 3) == 3\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],space = 7) == 7\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],space = 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],space = 2) == 1\n assert candidate(nums = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001, 1101, 1201, 1301, 1401, 1501, 1601, 1701, 1801, 1901],space = 100) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],space = 10) == 10\n assert candidate(nums = [123456789, 246913578, 370370370, 493827161, 617283952, 740740740, 864256331, 987654321],space = 123456789) == 123456789\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],space = 10) == 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],space = 1) == 1\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999],space = 111111111) == 111111111\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000],space = 1000000000) == 1000000000\n assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96],space = 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],space = 2) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994],space = 1) == 999999994\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195],space = 13) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],space = 2) == 2\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147],space = 6) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],space = 100) == 100\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],space = 111111111) == 111111111\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],space = 7) == 7\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],space = 1000000000) == 1000000000\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],space = 2) == 1\n assert candidate(nums = [2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102, 112, 122, 132, 142, 152, 162, 172, 182, 192, 202],space = 10) == 2\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59],space = 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],space = 5) == 1\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515],space = 101) == 101\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100],space = 9) == 1\n assert candidate(nums = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115],space = 6) == 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],space = 1) == 1\n assert candidate(nums = [2, 12, 22, 32, 42, 52, 62, 72, 82, 92],space = 10) == 2\n assert candidate(nums = [123456789, 246913578, 369270367, 492627156, 615943945],space = 123456789) == 123456789\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],space = 2) == 2\n assert candidate(nums = [10, 19, 28, 37, 46, 55, 64],space = 9) == 10\n assert candidate(nums = [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],space = 3) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],space = 3) == 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],space = 2) == 1\n assert candidate(nums = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],space = 10) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],space = 3) == 3\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],space = 12) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],space = 10) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],space = 2) == 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, 44, 46, 48, 50],space = 2) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],space = 10) == 10\n assert candidate(nums = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191],space = 10) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],space = 13) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],space = 2) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],space = 10) == 10\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],space = 5) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],space = 1) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],space = 100) == 100\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],space = 10) == 5\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],space = 10) == 5\n assert candidate(nums = [6, 18, 30, 42, 54, 66, 78, 90, 102, 114],space = 12) == 6\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41],space = 6) == 5\n assert candidate(nums = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],space = 2) == 12\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],space = 4) == 3\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63],space = 6) == 3\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],space = 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],space = 1) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165],space = 11) == 11\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],space = 10) == 5\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],space = 10) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],space = 5) == 5\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],space = 3) == 999999996\n assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95],space = 3) == 5\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000],space = 125000000) == 125000000\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],space = 11) == 11\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],space = 7) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums", "space"], "leetcode_dataset_entry_point": "Solution().destroyTargets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int destroyTargets(int[] nums, int space) {", "container": "Solution", "callable": "destroyTargets", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "space", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2454, "task_id": "next-greater-element-iv", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array of non-negative integers nums. For each integer in nums, you must find its respective second greater integer.\nThe second greater integer of nums[i] is nums[j] such that:\n\nj > i\nnums[j] > nums[i]\nThere exists exactly one index k such that nums[k] > nums[i] and i < k < j.\n\nIf there is no such nums[j], the second greater integer is considered to be -1.\n\nFor example, in the array [1, 2, 4, 3], the second greater integer of 1 is 4, 2 is 3, and that of 3 and 4 is -1.\n\nReturn an integer array answer, where answer[i] is the second greater integer of nums[i].\n \nExample 1:\n\nInput: nums = [2,4,0,9,6]\nOutput: [9,6,6,-1,-1]\nExplanation:\n0th index: 4 is the first integer greater than 2, and 9 is the second integer greater than 2, to the right of 2.\n1st index: 9 is the first, and 6 is the second integer greater than 4, to the right of 4.\n2nd index: 9 is the first, and 6 is the second integer greater than 0, to the right of 0.\n3rd index: There is no integer greater than 9 to its right, so the second greater integer is considered to be -1.\n4th index: There is no integer greater than 6 to its right, so the second greater integer is considered to be -1.\nThus, we return [9,6,6,-1,-1].\n\nExample 2:\n\nInput: nums = [3,3]\nOutput: [-1,-1]\nExplanation:\nWe return [-1,-1] since neither integer has any integer greater than it.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == [2, 5, 3, 6, 4, 7, 5, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5]) == [2, 5, 5, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1000000000, 0, 1000000000, 0, 1000000000]) == [-1, 1000000000, -1, -1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 8, 5]) == [2, 5, 5, 6, 7, 7, 8, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1]\n assert candidate(nums = [1, 5, 2, 4, 3]) == [2, -1, 3, -1, -1]\n assert candidate(nums = [7, 1, 5, 2, 6, 3, 4, 8, 9]) == [9, 2, 8, 3, 9, 8, 9, -1, -1]\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8]) == [2, 7, 3, 8, 4, -1, -1, -1]\n assert candidate(nums = [3, 3]) == [-1, -1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [2, 3, 4, 5, 6, 7, 8, 9, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 0]) == [2, 5, 5, 6, 7, 8, 9, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [3, 4, 5, -1, -1]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 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]\n assert candidate(nums = [1, 2, 4, 3]) == [4, 3, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 6, 3, 2, 7, 8]) == [7, 8, 8, 8, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == [2, 5, 5, 6, 7, 8, 9, 10, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [2, 4, 0, 9, 6]) == [9, 6, 6, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 3, 1, 2, 4]) == [-1, -1, 4, -1, -1]\n assert candidate(nums = [10, 10, 10, 10, 10]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1]\n assert candidate(nums = [2, 1, 5, 6, 2, 3, 1, 4, 2, 3]) == [6, 6, -1, -1, 4, -1, 2, -1, -1, -1]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 14, 12, 13, 15, 0]) == [2, 14, 3, 14, 4, 14, 5, 14, 11, 14, 12, -1, 15, -1, -1, -1]\n assert candidate(nums = [3, 2, 1, 0, 4, 5, 6, 7, 8, 9]) == [5, 5, 5, 5, 6, 7, 8, 9, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1]\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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10, 14]) == [2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12, 8, 13, 9, 14, 10, -1, -1, -1]\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, 3, 9, 3, 7, 5, 1, 8, 2, 8, 4, 8, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1]) == [5, 5, 9, 9, 6, -1, 5, 7, 7, 9, 7, -1, 8, -1, 4, 8, 4, 9, 6, 7, 4, 7, 7, 7, 7, 9, 9, 9, 8, -1, 8, 8, 8, 9, 9, 7, 7, -1, 8, 9, 7, -1, 5, 8, 8, 2, 9, 4, 9, 6, 9, 7, 4, 7, 7, 7, 7, 9, 9, 9, 8, -1, 8, 8, 8, -1, -1, 7, 7, -1, -1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == [2, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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, 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]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 3, 4, 5, 6, 7, 8, 9, -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, -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]) == [-1, -1, -1, -1, -1, -1, -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, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [-1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -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]) == [-1, -1, 8, 8, 8, 8, 8, 8, 8, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == [2, 5, 3, 6, 4, 7, 5, 8, 6, 9, 7, 10, 8, -1, -1, -1]\n assert candidate(nums = [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]) == [-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, -1, -1, -1]\n assert candidate(nums = [1, 5, 3, 9, 2, 8, 7, 10, 6, 11]) == [3, 8, 8, 11, 7, 11, 11, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1]\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]) == [2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, -1, -1]\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60]) == [30, 40, 20, 50, 30, 60, 40, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 3, 4, 5, 6, 7, 8, 9, -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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 1]) == [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]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-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, 5, 3, 4, 2, 7, 6, 8]) == [3, 6, 7, 6, 6, -1, -1, -1]\n assert candidate(nums = [3, 4, 2, 3, 5, 1, 6, 0, 7, 8, 9]) == [5, 6, 5, 6, 7, 7, 8, 8, 9, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [2, 2, 3, 3, 4, 4, 5, 5, -1, -1]\n assert candidate(nums = [5, 2, 6, 1, 3, 4, 7, 8, 0, 9]) == [7, 3, 8, 4, 7, 8, 9, -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]) == [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, -1, -1]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == [2, 12, 3, 12, 4, 12, 5, 12, 11, 12, 13, 14, 15, -1, -1]\n assert candidate(nums = [2, 1, 3, 4, 2, 3, 4, 1, 5, 6]) == [4, 4, 4, 6, 4, 5, 6, 6, -1, -1]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8]) == [3, 3, 4, 4, 3, 4, 4, 6, 5, 4, 5, 6, 6, 8, 7, 6, 7, 8, -1, -1]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == [5, 5, 9, 9, 6, -1, 5, 7, 7, 9, 7, -1, 8, -1, 4, 8, 4, -1, -1, -1]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2, -1, 2, -1, 2, -1, 2, -1, -1, -1]\n assert candidate(nums = [1, 5, 3, 7, 10, 8, 6, 9, 2, 4]) == [3, 10, 10, 8, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15]) == [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 14, 15, -1, -1]\n assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == [1, -1, 2, -1, 3, -1, 4, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 5, 4, 8, 7, 11, 10, 9, 13, 12, 6, 14, 15, 16, 17, 18, 19, 20]) == [2, 4, 4, 7, 7, 10, 10, 12, 12, 12, 15, 15, 15, 16, 17, 18, 19, 20, -1, -1]\n assert candidate(nums = [1, 5, 3, 2, 4, 7, 6, 8]) == [3, 6, 7, 7, 6, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 8, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == [8, 8, 8, 8, 8, 8, -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]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1]\n assert candidate(nums = [2, 2, 1, 1, 3, 3, 4, 4, 5, 5]) == [3, 3, 3, 3, 4, 4, 5, 5, -1, -1]\n assert candidate(nums = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5]) == [1, 2, 2, 3, 3, 4, 4, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 6, 5, 4, 9, 8, 7, 10]) == [2, 5, 5, 8, 8, 8, -1, -1, -1, -1]\n assert candidate(nums = [8, 1, 5, 2, 6, 3, 7, 4, 9, 0]) == [-1, 2, 7, 3, 9, 4, -1, -1, -1, -1]\n assert candidate(nums = [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]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 8, -1, -1, 9, 8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == [3, 3, -1, 3, 3, -1, 3, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [3, 4, 5, 6, 7, 8, 9, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 7, 6, 5, 9, 8, 10]) == [2, 7, 7, 6, 8, 8, 8, -1, -1, -1]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [8, 1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12]) == [10, 2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12, 8, -1, -1, -1]\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]) == [-1, -1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1]\n assert candidate(nums = [1, 2, 2, 2, 3, 2, 2, 2, 4, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 6]) == [2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, -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]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1]\n assert candidate(nums = [0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == [1, 3, 3, 5, 5, 7, 7, 9, 9, -1, -1]\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [-1, 2, -1, 2, -1, 2, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [2, 4, 4, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1]\n assert candidate(nums = [5, 1, 4, 3, 2, 7, 8, 6, 9, 10]) == [8, 3, 8, 8, 8, 9, 10, 10, -1, -1]\n assert candidate(nums = [3, 5, 4, 7, 6, 8, 10, 9, 11, 12, 13, 14, 15, 16, 17]) == [4, 6, 6, 10, 10, 9, 12, 12, 13, 14, 15, 16, 17, -1, -1]\n assert candidate(nums = [1, 5, 3, 2, 4, 8, 6, 7, 9, 0]) == [3, 6, 8, 8, 6, -1, 9, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1]) == [3, 4, 5, 5, 5, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [2, -1, 3, -1, 4, -1, 5, -1, -1, -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, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, 1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == [4, 5, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, -1, -1]\n assert candidate(nums = [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]) == [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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 0, 9, 0, 9, 0, 9, 0, 9, 0]) == [-1, 9, -1, 9, -1, 9, -1, -1, -1, -1]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1]) == [6, 6, -1, 9, 4, -1, -1, -1, -1]\n assert candidate(nums = [8, 1, 5, 3, 7, 10, 2, 6, 9, 4]) == [9, 3, 10, 10, 9, -1, 9, -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, 1, 2, 3, 4, 5]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, 3, 4, 5, -1, -1]\n assert candidate(nums = [2, 1, 5, 6, 0, 3, 4, 9, 8, 7]) == [6, 6, 9, 8, 4, 9, 8, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 5, 4, 6, 7, 8, 10, 9]) == [2, 4, 4, 7, 7, 8, 10, 9, -1, -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]) == [3, 4, 5, 6, 7, 8, 9, 10, 10, -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 91, 82, 73, 64, 55, 46, 37, 28, 19, 10]) == [30, 40, 50, 60, 70, 80, 90, 100, 91, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == [30, 40, 50, 60, 70, 80, 90, 100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [2, 1, 5, 6, 2, 3, 1, 8]) == [6, 6, 8, -1, 8, -1, -1, -1]\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == [-1, 3, 4, 5, 6, 7, 8, 9, -1, -1, -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, 0, 31, 32, 33, 34, 35]) == [32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 35, -1, -1]\n assert candidate(nums = [3, 5, 2, 6, 1, 7, 4, 8, 0, 9]) == [6, 7, 7, 8, 4, 9, 9, -1, -1, -1]\n assert candidate(nums = [5, 1, 4, 1, 3, 1, 2, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [-1, 3, -1, 2, -1, 6, -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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, 10, 9, 9, 9, 9, 9, 9, 9, 9, -1, -1, 9, 9, 9, 9, 9, 9, 9, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 2, 1, 3, 4, 4, 3, 5, 6, 6, 5, 7, 8, 8, 7, 9]) == [2, 4, 4, 4, 4, 6, 6, 6, 6, 8, 8, 8, 8, -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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [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, -1, -1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1]\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == [3, 4, 2, 5, 3, 6, 4, -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]\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, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, -1, -1]\n assert candidate(nums = [0, 10, 2, 9, 4, 8, 6, 7, 5, 3, 1]) == [2, -1, 4, -1, 6, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 8, 8, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 101, 201, 102, 202, 103, 203, 104, 204]) == [101, 202, 102, 203, 103, 204, 104, -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\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]) == [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, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 3, 2, 4, 6, 1, 7, 8, 9, 10, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [7, 6, 6, 7, 8, 8, 9, 10, 11, 12, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1, -1]\n assert candidate(nums = [50, 24, 54, 32, 54, 68, 27, 89, 10, 70, 29, 33, 63, 96, 99, 78, 76, 65, 84, 88]) == [54, 32, 89, 68, 89, 70, 70, 99, 29, 99, 63, 96, 99, -1, -1, 88, 88, 88, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == [3, 4, 4, -1, -1, 4, 3, 4, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 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]) == [3, 4, 5, 6, 7, 8, 9, 10, -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == [-1, 3, 2, -1, 3, 2, -1, 3, 2, -1, 3, 2, -1, 3, 2, -1, -1, 2, -1, -1, -1]\n assert candidate(nums = [1, 5, 2, 10, 11, 9, 3, 4, 6, 7, 8]) == [2, 11, 11, -1, -1, -1, 6, 7, 8, -1, -1]\n assert candidate(nums = [0, 11, 7, 12, 13, 14, 6, 15, 16, 17, 8, 18, 19, 9, 10, 5, 20, 21, 22, 1]) == [7, 13, 13, 14, 15, 16, 16, 17, 18, 19, 19, 20, 21, 20, 21, 21, 22, -1, -1, -1]\n assert candidate(nums = [1, 10, 8, 7, 6, 5, 4, 3, 2, 1]) == [8, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50]) == [30, 25, 35, 35, -1, -1, -1]\n assert candidate(nums = [1, 2, 4, 3]) == [4, 3, -1, -1]\n assert candidate(nums = [1, 2, 3, 2, 1]) == [3, -1, -1, -1, -1]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 10, 11, 1, 2, 10, 11, 1]) == [11, 11, -1, 10, 11, -1, -1, -1]\n assert candidate(nums = [5, 3, 4, 2, 1]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [1, 100, 80, 60, 40, 20]) == [80, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, 2, 1]) == [-1, -1, -1]\n assert candidate(nums = [1, 5, 2, 5, 4, 7, 3, 6]) == [2, 6, 4, 6, 6, -1, -1, -1]\n assert candidate(nums = [5, 1, 4, 3, 6, 7, 8]) == [7, 3, 7, 7, 8, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9]) == [3, 4, 5, 6, 7, 8, 10, 9, -1, -1]\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1]) == [-1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 10, 11, 12, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 10, 3, 4, 18, 5, 6]) == [3, -1, 18, 5, -1, -1, -1]\n assert candidate(nums = [5, 1, 4, 2, 3]) == [-1, 2, -1, -1, -1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1]\n assert candidate(nums = [1]) == [-1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(nums = [8, 2, 4, 6, 7, 5, 3, 9, 1]) == [-1, 6, 7, 9, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4]) == [2, 7, 3, -1, 4, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == [2, 5, 5, 6, 7, -1, -1]\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8]) == [2, 7, 3, 8, 4, -1, -1, -1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == [2, 3, 4, 5, -1, -1]\n assert candidate(nums = [1, 5, 2, 4, 3, 6, 7, 8, 9, 10]) == [2, 7, 3, 7, 7, 8, 9, 10, -1, -1]\n assert candidate(nums = [1, 2, 0, 3, 0, 4, 0, 5, 0, 6]) == [3, 4, 4, 5, 5, 6, 6, -1, -1, -1]\n assert candidate(nums = [5, 8, 1, 2, 10, 6, 9, 7, 3, 4]) == [10, 9, 10, 6, -1, 7, -1, -1, -1, -1]\n assert candidate(nums = [2, 1]) == [-1, -1]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 100, 100]) == [-1, -1, -1]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 6, 5]) == [2, 6, 6, 5, -1, -1]\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [8, 1, 2, 4, 6, 7, 1, 5]) == [-1, 4, 6, 7, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 4, 3, 5, 6, 7, 8, 9, 10]) == [4, 3, 6, 6, 7, 8, 9, 10, -1, -1]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0]) == [1, -1, 1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == [3, 3, -1, 3, 3, -1, 3, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [3, 4, 5, -1, -1]\n assert candidate(nums = [10, 1, 1, 6, 1, 4, 1, 2, 1, 1, 1, 9, 1, 4, 1, 1, 1, 1, 1, 1]) == [-1, 4, 4, -1, 2, -1, 9, 4, 4, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 3, 1, 2, 4]) == [-1, -1, 4, -1, -1]\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10, 14]) == [2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12, 8, 13, 9, 14, 10, -1, -1, -1]\n assert candidate(nums = [8, 5, 12, 9, 16, 15]) == [9, 9, 15, 15, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10]) == [2, 5, 5, 7, 6, 9, 9, 10, -1, -1]\n assert candidate(nums = [3, 3]) == [-1, -1]\n assert candidate(nums = [5, 8, 4, 5, 3, 5, 10, 15]) == [10, 15, 5, 15, 10, 15, -1, -1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == [-1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [8, 1, 5, 2, 6, 3, 7, 4]) == [-1, 2, 7, 3, -1, 4, -1, -1]\n assert candidate(nums = [7, 1, 5, 2, 6, 4, 3]) == [-1, 2, -1, 4, -1, -1, -1]\n assert candidate(nums = [10, 20, 10, 30, 20, 40]) == [30, 40, 20, -1, -1, -1]\n assert candidate(nums = [1, 2, 3]) == [3, -1, -1]\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6]) == [2, 7, 3, 8, 4, 9, 5, -1, 6, -1, -1]\n assert candidate(nums = [10, 3, 11, 1, 15, 9]) == [15, 15, -1, 9, -1, -1]\n assert candidate(nums = [1, 10, 8, 9, 10, 11, 5, 3, 12, 0]) == [8, 12, 10, 11, 12, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5]) == [2, 5, 5, -1, -1]\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, 1, 1, 1]) == [-1, -1, -1, -1, -1, -1, -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 = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 10, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9]) == [2, 7, 3, 8, 4, 9, 5, -1, -1, -1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == [2, 3, 4, 5, -1, -1]\n assert candidate(nums = [5, 6, 7, 8, 9, 10]) == [7, 8, 9, 10, -1, -1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [2, 3, 4, 5, 6, 7, 8, 9, -1, -1]\n assert candidate(nums = [0, 1, 2, 0, 3, 0, 4]) == [2, 3, 4, 4, -1, -1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2]) == [-1, -1]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == [3, 3, -1, -1, 3, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 4, 7, 8]) == [2, 5, 5, 6, 7, 4, 8, 8, -1, -1]\n assert candidate(nums = [10, 4, 3, 5, 7, 2, 8, 6, 1]) == [-1, 7, 7, 8, -1, 6, -1, -1, -1]\n assert candidate(nums = [10, 5, 1, 6, 2, 7, 3, 8, 4, 9]) == [-1, 7, 2, 8, 3, 9, 4, -1, -1, -1]\n assert candidate(nums = [10, 5, 15, 2, 18]) == [18, 18, -1, -1, -1]\n assert candidate(nums = [1, 2, 0, 3, 0, 4, 0, 5, 0]) == [3, 4, 4, 5, 5, -1, -1, -1, -1]\n assert candidate(nums = [1, 5, 2, 3, 4, 6, 7, 8, 9, 10]) == [2, 7, 4, 6, 7, 8, 9, 10, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5]) == [3, 4, 5, 5, 5, -1, -1]\n assert candidate(nums = [5, 2, 6, 4, 7]) == [7, 4, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 4, 3, 2, 1, 2, 3, 4]) == [2, 5, 3, 6, 6, -1, -1, -1, -1, 4, 3, 4, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 2, 1]) == [2, 5, 5, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 1, 2, 3, 4, 0]) == [-1, 3, 4, -1, -1, -1]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1]) == [1, -1, 1, -1, 1, -1, -1, -1]\n assert candidate(nums = [1, 2, 0, 3, 0, 4, 0, 5]) == [3, 4, 4, 5, 5, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1]\n assert candidate(nums = [10, 20, 15, 30, 25, 40, 35, 50, 45, 60]) == [15, 25, 25, 35, 35, 45, 45, -1, -1, -1]\n assert candidate(nums = [1, 2, 0, 4, 3, 5, 6, 7, 8, 9]) == [4, 3, 3, 6, 6, 7, 8, 9, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [3, 3, 4, 4, 5, 5, -1, -1, -1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [-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]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1]\n assert candidate(nums = [8, 1, 5, 2, 7]) == [-1, 2, -1, -1, -1]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == [2, -1, 2, -1, -1, -1, -1]\n assert candidate(nums = [2, 4, 0, 9, 6]) == [9, 6, 6, -1, -1]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().secondGreaterElement", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] secondGreaterElement(int[] nums) {", "container": "Solution", "callable": "secondGreaterElement", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2455, "task_id": "average-value-of-even-numbers-that-are-divisible-by-three", "difficulty": "Easy", "problem_description": "Given an integer array nums of positive integers, return the average value of all even integers that are divisible by 3.\nNote that the average of n elements is the sum of the n elements divided by n and rounded down to the nearest integer.\n \nExample 1:\n\nInput: nums = [1,3,6,10,12,15]\nOutput: 9\nExplanation: 6 and 12 are even numbers that are divisible by 3. (6 + 12) / 2 = 9.\n\nExample 2:\n\nInput: nums = [1,2,4,7,10]\nOutput: 0\nExplanation: There is no single number that satisfies the requirement, so return 0.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 18\n assert candidate(nums = [3, 9, 15, 21, 27, 33]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12]) == 9\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80]) == 42\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300]) == 165\n assert candidate(nums = [2, 6, 18, 24, 30]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(nums = [4, 8, 16, 20, 24, 28]) == 24\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 18\n assert candidate(nums = [30, 60, 90, 120, 150, 180]) == 105\n assert candidate(nums = [1, 5, 7, 11, 13, 17]) == 0\n assert candidate(nums = [1, 3, 6, 10, 12, 15]) == 9\n assert candidate(nums = [1, 5, 7, 11, 13, 17, 19, 23, 25, 29]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 54\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 12\n assert candidate(nums = [3, 9, 15, 21, 27]) == 0\n assert candidate(nums = [2, 6, 12, 18, 24, 30]) == 18\n assert candidate(nums = [36, 72, 108, 144, 180]) == 108\n assert candidate(nums = [2, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114]) == 60\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == 990\n assert candidate(nums = [1, 2, 4, 7, 10]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 0\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330]) == 198\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 33\n assert candidate(nums = [1, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 0\n assert candidate(nums = [1, 5, 7, 11, 13, 17, 19]) == 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]) == 12\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 24\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57]) == 0\n assert candidate(nums = [3000, 3003, 3006, 3009, 3012, 3015, 3018, 3021, 3024, 3027]) == 3012\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950, 949, 948, 947, 946, 945, 944, 943, 942, 941, 940, 939, 938, 937, 936, 935, 934, 933, 932, 931, 930]) == 963\n assert candidate(nums = [300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360, 366, 372, 378, 384, 390]) == 345\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 600\n assert candidate(nums = [6, 18, 30, 42, 54, 66, 78, 90, 102, 114]) == 60\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550]) == 300\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]) == 51\n assert candidate(nums = [100, 102, 104, 105, 106, 108, 110, 111, 112, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130]) == 114\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 18\n assert candidate(nums = [6, 36, 72, 108, 144, 180, 216, 252, 288, 324, 360, 396, 432, 468, 504]) == 252\n assert candidate(nums = [2, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 33\n assert candidate(nums = [150, 162, 174, 186, 198, 210, 222, 234, 246, 258, 270, 282, 294, 306, 318, 330, 342, 354, 366, 378]) == 264\n assert candidate(nums = [18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150]) == 84\n assert candidate(nums = [24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252]) == 138\n assert candidate(nums = [150, 210, 270, 330, 390, 450, 510, 570, 630, 690, 750, 810, 870, 930, 990]) == 570\n assert candidate(nums = [8, 14, 18, 20, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == 54\n assert candidate(nums = [2, 3, 5, 6, 9, 10, 12, 15, 18, 21, 24, 27, 30]) == 18\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]) == 63\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900, 960]) == 510\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]) == 18\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 525\n assert candidate(nums = [100, 102, 104, 105, 108, 110, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180]) == 141\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 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]) == 0\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, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 18\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]) == 27\n assert candidate(nums = [102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 234, 240]) == 171\n assert candidate(nums = [300, 303, 306, 309, 312, 315, 318, 321, 324, 327, 330, 333, 336, 339, 342, 345, 348, 351, 354, 357]) == 327\n assert candidate(nums = [999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020]) == 1011\n assert candidate(nums = [102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198]) == 150\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147, 153, 159, 165, 171, 177, 183, 189, 195, 201, 207, 213, 219, 225, 231, 237, 243, 249, 255, 261, 267, 273, 279, 285, 291, 297, 303, 309, 315, 321, 327, 333, 339, 345, 351, 357, 363, 369, 375, 381, 387, 393, 399]) == 0\n assert candidate(nums = [102, 204, 306, 408, 510, 612, 714, 816, 918, 1020, 1122, 1224, 1326, 1428, 1530, 1632, 1734, 1836, 1938, 2040]) == 1071\n assert candidate(nums = [600, 600, 600, 600, 600, 600, 600, 600, 600, 600]) == 600\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98]) == 48\n assert candidate(nums = [18, 36, 54, 72, 90, 108, 126, 144, 162, 180, 198, 216, 234, 252, 270, 288, 306, 324, 342, 360]) == 189\n assert candidate(nums = [300, 303, 306, 309, 312, 315, 318, 321, 324, 327, 330, 333, 336, 339, 342, 345, 348, 351, 354, 357, 360, 363, 366, 369, 372]) == 336\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150]) == 78\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == 990\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99]) == 0\n assert candidate(nums = [18, 36, 54, 72, 90, 108, 126, 144, 162, 180, 198, 216, 234, 252, 270, 288, 306, 324, 342, 360, 378, 396, 414, 432, 450, 468, 486, 504, 522, 540, 558, 576, 594, 612, 630, 648, 666, 684, 702, 720, 738, 756, 774, 792, 810, 828, 846, 864, 882, 900, 918, 936, 954, 972, 990, 1008]) == 513\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96]) == 51\n assert candidate(nums = [36, 72, 108, 144, 180, 216, 252, 288, 324, 360]) == 198\n assert candidate(nums = [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]) == 0\n assert candidate(nums = [24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210]) == 117\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]) == 21\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\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970]) == 984\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 33\n assert candidate(nums = [600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638]) == 618\n assert candidate(nums = [123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180]) == 153\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 990\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 18\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]) == 132\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, 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, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150]) == 78\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180]) == 93\n assert candidate(nums = [300, 600, 900, 1200, 1500]) == 900\n assert candidate(nums = [36, 72, 108, 144, 180, 216, 252, 288, 324, 360]) == 198\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57]) == 0\n assert candidate(nums = [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]) == 51\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96]) == 51\n assert candidate(nums = [45, 90, 135, 180, 225, 270, 315, 360, 405, 450, 495, 540, 585, 630, 675, 720, 765, 810, 855, 900]) == 495\n assert candidate(nums = [300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338]) == 318\n assert candidate(nums = [6, 18, 30, 42, 54, 66, 78, 90, 102, 114, 126, 138, 150, 162, 174, 186, 198, 210, 222, 234, 246, 258, 270]) == 138\n assert candidate(nums = [600, 1200, 1800, 2400, 3000, 3600, 4200, 4800, 5400, 6000, 6600, 7200, 7800, 8400, 9000, 9600, 10000]) == 5100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 12\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330, 363, 396, 429, 462, 495, 528, 561, 594, 627, 660]) == 363\n assert candidate(nums = [300, 600, 900, 1200, 1500, 1800, 2100, 2400, 2700, 3000, 3300, 3600, 3900, 4200, 4500]) == 2400\n assert candidate(nums = [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]) == 108\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]) == 27\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, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == 51\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]) == 63\n assert candidate(nums = [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]) == 48\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 100]) == 48\n assert candidate(nums = [27, 54, 81, 108, 135, 162, 189, 216, 243, 270, 297, 324, 351, 378, 405, 432, 459, 486, 513, 540]) == 297\n assert candidate(nums = [3, 5, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]) == 0\n assert candidate(nums = [123, 456, 789, 1023, 1356, 1689, 2013, 2346, 2679, 3003]) == 1386\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 60\n assert candidate(nums = [102, 204, 306, 408, 510, 612, 714, 816, 918, 1020]) == 561\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]) == 0\n assert candidate(nums = [996, 998, 1000, 999, 993, 990, 987, 984, 981, 978, 975, 972, 969, 966, 963, 960, 957, 954, 951, 948]) == 972\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570, 600]) == 315\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == 0\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147]) == 0\n assert candidate(nums = [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]) == 504\n assert candidate(nums = [100, 102, 104, 105, 108, 110, 112, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150]) == 126\n assert candidate(nums = [6, 18, 30, 42, 54, 66, 78, 90, 102, 114, 126, 138, 150, 162, 174, 186, 198, 210, 222, 234, 246, 258, 270, 282, 294, 300, 306, 312, 318, 324, 330]) == 181\n assert candidate(nums = [200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238]) == 219\n assert candidate(nums = [999, 996, 993, 990, 987, 984, 981, 978, 975, 972, 969, 966, 963, 960, 957, 954, 951, 948, 945, 942, 939, 936, 933, 930, 927, 924, 921, 918, 915, 912, 909, 906, 903, 900, 897, 894, 891, 888, 885, 882, 879, 876, 873, 870, 867, 864, 861, 858, 855, 852, 849, 846, 843, 840, 837, 834, 831, 828, 825, 822, 819, 816, 813, 810, 807, 804, 801, 798, 795, 792, 789, 786, 783, 780, 777, 774, 771, 768, 765, 762, 759, 756, 753, 750, 747, 744, 741, 738, 735, 732, 729, 726, 723, 720, 717, 714, 711, 708, 705, 702, 699, 696, 693, 690, 687, 684, 681, 678, 675, 672, 669, 666, 663, 660, 657, 654, 651, 648, 645, 642, 639, 636, 633, 630, 627, 624, 621, 618, 615, 612, 609, 606, 603, 600]) == 798\n assert candidate(nums = [999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015]) == 1008\n assert candidate(nums = [999, 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]) == 930\n assert candidate(nums = [999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008]) == 1005\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().averageValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int averageValue(int[] nums) {", "container": "Solution", "callable": "averageValue", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2456, "task_id": "most-popular-video-creator", "difficulty": "Medium", "problem_description": "You are given two string arrays creators and ids, and an integer array views, all of length n. The ith video on a platform was created by creators[i], has an id of ids[i], and has views[i] views.\nThe popularity of a creator is the sum of the number of views on all of the creator's videos. Find the creator with the highest popularity and the id of their most viewed video.\n\nIf multiple creators have the highest popularity, find all of them.\nIf multiple videos have the highest view count for a creator, find the lexicographically smallest id.\n\nNote: It is possible for different videos to have the same id, meaning that ids do not uniquely identify a video. For example, two videos with the same ID are considered as distinct videos with their own viewcount.\nReturn a 2D array of strings answer where answer[i] = [creatorsi, idi] means that creatorsi has the highest popularity and idi is the id of their most popular video. The answer can be returned in any order.\n \nExample 1:\n\nInput: creators = [\"alice\",\"bob\",\"alice\",\"chris\"], ids = [\"one\",\"two\",\"three\",\"four\"], views = [5,10,5,4]\nOutput: [[\"alice\",\"one\"],[\"bob\",\"two\"]]\nExplanation:\nThe popularity of alice is 5 + 5 = 10.\nThe popularity of bob is 10.\nThe popularity of chris is 4.\nalice and bob are the most popular creators.\nFor bob, the video with the highest view count is \"two\".\nFor alice, the videos with the highest view count are \"one\" and \"three\". Since \"one\" is lexicographically smaller than \"three\", it is included in the answer.\n\nExample 2:\n\nInput: creators = [\"alice\",\"alice\",\"alice\"], ids = [\"a\",\"b\",\"c\"], views = [1,2,2]\nOutput: [[\"alice\",\"b\"]]\nExplanation:\nThe videos with id \"b\" and \"c\" have the highest view count.\nSince \"b\" is lexicographically smaller than \"c\", it is included in the answer.\n\n \nConstraints:\n\nn == creators.length == ids.length == views.length\n1 <= n <= 105\n1 <= creators[i].length, ids[i].length <= 5\ncreators[i] and ids[i] consist only of lowercase English letters.\n0 <= views[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(creators = ['eve', 'eve', 'eve', 'eve'],ids = ['a', 'a', 'b', 'b'],views = [10, 20, 20, 10]) == [['eve', 'a']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'chris'],ids = ['one', 'two', 'three', 'four'],views = [5, 10, 5, 4]) == [['alice', 'one'], ['bob', 'two']]\n assert candidate(creators = ['john', 'john', 'john'],ids = ['x', 'y', 'x'],views = [10, 10, 10]) == [['john', 'x']]\n assert candidate(creators = ['anna', 'bob', 'charlie'],ids = ['a', 'b', 'c'],views = [100, 200, 300]) == [['charlie', 'c']]\n assert candidate(creators = ['alice', 'alice', 'alice'],ids = ['a', 'b', 'c'],views = [1, 2, 2]) == [['alice', 'b']]\n assert candidate(creators = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],ids = ['id', 'id', 'id', 'id', 'id', 'id', 'id', 'id', 'id', 'id'],views = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [['a', 'id']]\n assert candidate(creators = ['alice', 'bob', 'charlie', 'dave', 'eve'],ids = ['a', 'b', 'c', 'd', 'e'],views = [100, 200, 300, 400, 500]) == [['eve', 'e']]\n assert candidate(creators = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank'],ids = ['one', 'two', 'three', 'four', 'five', 'six'],views = [1000, 1000, 1000, 1000, 1000, 1000]) == [['frank', 'five']]\n assert candidate(creators = ['alice', 'alice', 'alice', 'bob', 'bob', 'bob'],ids = ['x', 'y', 'z', 'x', 'y', 'z'],views = [10, 20, 30, 30, 20, 10]) == [['alice', 'z'], ['bob', 'x']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'chris', 'alice'],ids = ['one', 'two', 'three', 'four', 'five'],views = [5, 10, 5, 4, 15]) == [['alice', 'five']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice'],ids = ['one', 'two', 'three', 'four', 'five', 'six'],views = [5, 10, 5, 4, 10, 15]) == [['alice', 'six']]\n assert candidate(creators = ['dave', 'dave', 'dave', 'eve', 'eve', 'eve'],ids = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'delta'],views = [1, 3, 2, 5, 6, 5]) == [['eve', 'epsilon']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'bob', 'charlie', 'charlie'],ids = ['x', 'y', 'z', 'x', 'y', 'z'],views = [100, 200, 100, 300, 150, 150]) == [['bob', 'x']]\n assert candidate(creators = ['george', 'harry', 'george', 'harry', 'george', 'harry'],ids = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr'],views = [100, 200, 100, 200, 150, 150]) == [['harry', 'def']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'bob', 'alice', 'bob', 'alice'],ids = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu'],views = [10, 20, 10, 20, 30, 40, 50]) == [['alice', 'stu']]\n assert candidate(creators = ['dave', 'eve', 'eve', 'eve', 'dave'],ids = ['x', 'y', 'z', 'y', 'x'],views = [30, 20, 30, 40, 10]) == [['eve', 'y']]\n assert candidate(creators = ['alice', 'alice', 'alice', 'alice', 'alice'],ids = ['z', 'y', 'x', 'w', 'v'],views = [5, 5, 5, 5, 5]) == [['alice', 'v']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'bob', 'alice', 'bob'],ids = ['one', 'two', 'three', 'four', 'five', 'six'],views = [5, 15, 10, 10, 5, 5]) == [['bob', 'two']]\n assert candidate(creators = ['alice', 'bob', 'charlie', 'alice', 'bob', 'charlie', 'alice', 'bob', 'charlie'],ids = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9'],views = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [['charlie', 'a9']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice'],ids = ['one', 'two', 'three', 'four', 'five', 'six'],views = [15, 25, 15, 35, 25, 15]) == [['bob', 'five']]\n assert candidate(creators = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'],ids = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],views = [100, 200, 100, 200, 100, 200, 100, 200]) == [['karen', 'b']]\n assert candidate(creators = ['mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike'],ids = ['one', 'two', 'three', 'four', 'five', 'six', 'seven'],views = [10, 20, 30, 40, 50, 60, 70]) == [['mike', 'seven']]\n assert candidate(creators = ['eve', 'eve', 'eve', 'eve', 'eve'],ids = ['a', 'b', 'c', 'd', 'e'],views = [10, 20, 10, 10, 20]) == [['eve', 'b']]\n assert candidate(creators = ['a', 'b', 'a', 'b', 'a', 'b'],ids = ['aaa', 'bbb', 'aaa', 'bbb', 'aaa', 'bbb'],views = [1, 2, 3, 4, 5, 6]) == [['b', 'bbb']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice'],ids = ['one', 'two', 'three', 'four', 'five', 'six'],views = [10, 20, 5, 30, 20, 15]) == [['bob', 'five']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice', 'alice'],ids = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg'],views = [1, 2, 1, 3, 2, 1, 2]) == [['alice', 'ggg']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'chris', 'bob'],ids = ['one', 'two', 'three', 'four', 'five'],views = [5, 15, 5, 4, 15]) == [['bob', 'five']]\n assert candidate(creators = ['rachel', 'sam', 'rachel', 'sam', 'rachel', 'sam'],ids = ['pqr', 'stu', 'vwx', 'yza', 'bcd', 'efg'],views = [5, 5, 5, 5, 5, 5]) == [['rachel', 'bcd'], ['sam', 'efg']]\n assert candidate(creators = ['anna', 'anna', 'anna', 'anna', 'anna', 'anna'],ids = ['x', 'y', 'z', 'x', 'y', 'z'],views = [10, 20, 30, 40, 50, 60]) == [['anna', 'z']]\n assert candidate(creators = ['creatorA', 'creatorB', 'creatorC', 'creatorA', 'creatorB', 'creatorC'],ids = ['videoA', 'videoB', 'videoC', 'videoA', 'videoB', 'videoC'],views = [1000, 2000, 1500, 1000, 2500, 1500]) == [['creatorB', 'videoB']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice'],ids = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff'],views = [1, 2, 3, 4, 5, 6]) == [['alice', 'fffff']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice'],ids = ['x', 'y', 'z', 'a', 'b', 'c'],views = [15, 25, 15, 35, 35, 10]) == [['bob', 'b']]\n assert candidate(creators = ['anna', 'bob', 'charlie', 'dave', 'eve'],ids = ['aaa', 'bbb', 'ccc', 'ddd', 'eee'],views = [100, 200, 300, 400, 500]) == [['eve', 'eee']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'chris', 'bob', 'alice', 'chris', 'eve', 'eve', 'eve'],ids = ['one', 'two', 'three', 'four', 'two', 'six', 'seven', 'eight', 'nine', 'ten'],views = [5, 10, 5, 4, 10, 15, 1, 20, 20, 5]) == [['eve', 'eight']]\n assert candidate(creators = ['frank', 'frank', 'frank', 'frank', 'frank'],ids = ['a', 'b', 'a', 'c', 'b'],views = [100, 200, 300, 100, 200]) == [['frank', 'a']]\n assert candidate(creators = ['anna', 'anna', 'anna', 'bob', 'bob', 'bob', 'charlie', 'charlie', 'charlie'],ids = ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c'],views = [100, 200, 300, 100, 200, 300, 100, 200, 300]) == [['anna', 'c'], ['bob', 'c'], ['charlie', 'c']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'chris', 'bob', 'alice'],ids = ['one', 'two', 'three', 'four', 'two', 'six'],views = [5, 10, 5, 4, 10, 15]) == [['alice', 'six']]\n assert candidate(creators = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],ids = ['a', 'b', 'c', 'd', 'e', 'f', 'g'],views = [10, 10, 10, 10, 10, 10, 10]) == [['eve', 'a']]\n assert candidate(creators = ['alice', 'alice', 'alice', 'alice', 'alice'],ids = ['a', 'a', 'b', 'b', 'c'],views = [10, 10, 20, 20, 30]) == [['alice', 'c']]\n assert candidate(creators = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],ids = ['vid1', 'vid2', 'vid3', 'vid4', 'vid5', 'vid6', 'vid7'],views = [1, 2, 3, 4, 5, 6, 7]) == [['ivan', 'vid7']]\n assert candidate(creators = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve'],ids = ['aaa', 'aab', 'aac', 'aad', 'aae', 'aaf'],views = [10, 10, 10, 10, 10, 10]) == [['eve', 'aaa']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'bob', 'alice', 'bob'],ids = ['a', 'b', 'a', 'b', 'a', 'b'],views = [10, 15, 10, 20, 10, 25]) == [['bob', 'b']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'bob', 'alice', 'bob'],ids = ['a', 'a', 'b', 'b', 'c', 'c'],views = [10, 20, 30, 40, 50, 60]) == [['bob', 'c']]\n assert candidate(creators = ['nina', 'oliver', 'nina', 'oliver', 'nina', 'oliver'],ids = ['x', 'y', 'x', 'y', 'x', 'y'],views = [1000, 1000, 1000, 1000, 1000, 1000]) == [['nina', 'x'], ['oliver', 'y']]\n assert candidate(creators = ['anna', 'bob', 'charlie', 'bob', 'anna'],ids = ['aaa', 'bbb', 'ccc', 'bbb', 'aaa'],views = [150, 250, 350, 250, 150]) == [['bob', 'bbb']]\n assert candidate(creators = ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c'],ids = ['m', 'n', 'o', 'p', 'q', 'r', 's', 't'],views = [100, 200, 150, 300, 400, 400, 500, 600]) == [['b', 'q'], ['c', 't']]\n assert candidate(creators = ['grace', 'heidi', 'grace', 'heidi', 'grace', 'heidi'],ids = ['film1', 'film2', 'film3', 'film4', 'film5', 'film6'],views = [500, 500, 600, 600, 700, 700]) == [['grace', 'film5'], ['heidi', 'film6']]\n assert candidate(creators = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],ids = ['m', 'n', 'm', 'n', 'm', 'n'],views = [10, 20, 10, 20, 10, 20]) == [['ivan', 'n']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'chris', 'chris', 'bob'],ids = ['one', 'two', 'three', 'four', 'five', 'six'],views = [5, 10, 5, 4, 3, 15]) == [['bob', 'six']]\n assert candidate(creators = ['alice', 'alice', 'alice', 'alice', 'alice', 'alice'],ids = ['a', 'b', 'c', 'd', 'e', 'f'],views = [100000, 99999, 99998, 99997, 99996, 99995]) == [['alice', 'a']]\n assert candidate(creators = ['nina', 'nina', 'nina', 'nina', 'nina', 'nina', 'nina'],ids = ['a', 'a', 'b', 'b', 'c', 'c', 'd'],views = [10, 20, 30, 20, 30, 40, 50]) == [['nina', 'd']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice', 'alice'],ids = ['abc', 'bcd', 'abc', 'xyz', 'bcd', 'abc', 'xyz'],views = [10, 20, 10, 30, 20, 10, 30]) == [['alice', 'xyz']]\n assert candidate(creators = ['dave', 'eve', 'frank', 'dave', 'eve', 'frank'],ids = ['alpha', 'beta', 'gamma', 'alpha', 'beta', 'gamma'],views = [10, 20, 10, 5, 25, 15]) == [['eve', 'beta']]\n assert candidate(creators = ['alice', 'bob', 'charlie'],ids = ['aaaaa', 'bbbbb', 'ccccc'],views = [100000, 100000, 100000]) == [['alice', 'aaaaa'], ['bob', 'bbbbb'], ['charlie', 'ccccc']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'chris', 'alice'],ids = ['one', 'two', 'three', 'four', 'five'],views = [5, 10, 15, 4, 10]) == [['alice', 'three']]\n assert candidate(creators = ['alice', 'bob', 'charlie', 'alice', 'bob', 'charlie'],ids = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr'],views = [100, 100, 100, 100, 100, 100]) == [['alice', 'abc'], ['bob', 'def'], ['charlie', 'ghi']]\n assert candidate(creators = ['dave', 'dave', 'dave', 'dave'],ids = ['abc', 'abcd', 'abcde', 'abcdef'],views = [100, 100, 100, 100]) == [['dave', 'abc']]\n assert candidate(creators = ['isaac', 'jack', 'isaac', 'jack', 'isaac', 'jack'],ids = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff'],views = [1, 2, 1, 2, 1, 2]) == [['jack', 'bbb']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'chris', 'bob', 'alice', 'chris'],ids = ['one', 'two', 'three', 'four', 'two', 'six', 'seven'],views = [5, 10, 5, 4, 10, 15, 1]) == [['alice', 'six']]\n assert candidate(creators = ['tom', 'jerry', 'spike', 'tom', 'jerry', 'spike'],ids = ['q', 'w', 'e', 'r', 't', 'y'],views = [100, 200, 150, 100, 200, 150]) == [['jerry', 't']]\n assert candidate(creators = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen'],ids = ['a', 'b', 'c', 'd', 'e', 'f'],views = [1, 2, 3, 4, 5, 6]) == [['karen', 'f']]\n assert candidate(creators = ['anna', 'anna', 'anna', 'anna'],ids = ['aaa', 'bbb', 'aaa', 'bbb'],views = [50, 50, 50, 50]) == [['anna', 'aaa']]\n assert candidate(creators = ['leo', 'leo', 'leo', 'leo', 'leo'],ids = ['z', 'y', 'x', 'w', 'v'],views = [1000, 1000, 1000, 1000, 1000]) == [['leo', 'v']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice', 'alice'],ids = ['x', 'y', 'z', 'x', 'y', 'z', 'x'],views = [10, 20, 10, 30, 20, 10, 10]) == [['alice', 'x'], ['bob', 'y']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice'],ids = ['a', 'b', 'c', 'd', 'e', 'f'],views = [0, 0, 0, 0, 0, 0]) == [['alice', 'a'], ['bob', 'b'], ['charlie', 'd']]\n assert candidate(creators = ['anna', 'bob', 'charlie', 'anna', 'bob'],ids = ['a', 'b', 'c', 'd', 'e'],views = [100, 200, 300, 50, 200]) == [['bob', 'b']]\n assert candidate(creators = ['tom', 'ulysses', 'tom', 'ulysses', 'tom', 'ulysses'],ids = ['hello', 'world', 'hello', 'world', 'hello', 'world'],views = [1000, 2000, 3000, 4000, 5000, 6000]) == [['ulysses', 'world']]\n assert candidate(creators = ['alice', 'bob', 'charlie', 'alice', 'bob', 'charlie'],ids = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff'],views = [1, 1, 1, 1, 1, 1]) == [['alice', 'aaa'], ['bob', 'bbb'], ['charlie', 'ccc']]\n assert candidate(creators = ['anna', 'anna', 'bob', 'bob', 'charlie', 'charlie'],ids = ['a', 'b', 'c', 'd', 'e', 'f'],views = [5, 15, 10, 20, 25, 30]) == [['charlie', 'f']]\n assert candidate(creators = ['nina', 'nina', 'nina', 'nina', 'nina', 'nina', 'nina', 'nina', 'nina', 'nina'],ids = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],views = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [['nina', 'b']]\n assert candidate(creators = ['anna', 'anna', 'anna', 'anna'],ids = ['aaa', 'aab', 'aac', 'aad'],views = [5, 5, 5, 5]) == [['anna', 'aaa']]\n assert candidate(creators = ['peter', 'peter', 'peter', 'peter', 'peter'],ids = ['video1', 'video2', 'video3', 'video4', 'video5'],views = [500, 1000, 1000, 500, 250]) == [['peter', 'video2']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'bob', 'alice', 'bob'],ids = ['a', 'a', 'b', 'b', 'c', 'c'],views = [10, 20, 20, 10, 30, 30]) == [['alice', 'c'], ['bob', 'c']]\n assert candidate(creators = ['alice', 'alice', 'bob', 'bob', 'alice', 'bob'],ids = ['a', 'b', 'c', 'd', 'e', 'f'],views = [10, 20, 30, 30, 40, 10]) == [['alice', 'e'], ['bob', 'c']]\n assert candidate(creators = ['dave', 'dave', 'dave', 'dave'],ids = ['aaa', 'aab', 'aac', 'aad'],views = [1000, 1000, 1000, 1000]) == [['dave', 'aaa']]\n assert candidate(creators = ['alice', 'alice', 'alice', 'bob', 'bob'],ids = ['id1', 'id1', 'id2', 'id2', 'id2'],views = [10, 20, 10, 5, 15]) == [['alice', 'id1']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice'],ids = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig'],views = [100, 120, 100, 130, 120, 100]) == [['alice', 'apple']]\n assert candidate(creators = ['leo', 'mike', 'leo', 'mike', 'leo', 'mike', 'leo', 'mike'],ids = ['video1', 'video2', 'video3', 'video4', 'video5', 'video6', 'video7', 'video8'],views = [100, 200, 100, 200, 100, 200, 100, 200]) == [['mike', 'video2']]\n assert candidate(creators = ['james', 'james', 'james', 'james', 'james', 'james', 'james'],ids = ['v1', 'v1', 'v1', 'v1', 'v1', 'v1', 'v1'],views = [1000, 2000, 3000, 4000, 5000, 6000, 7000]) == [['james', 'v1']]\n assert candidate(creators = ['alice', 'bob', 'charlie', 'bob', 'anna', 'charlie', 'anna', 'bob'],ids = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],views = [100, 200, 300, 200, 100, 300, 100, 200]) == [['bob', 'b'], ['charlie', 'c']]\n assert candidate(creators = ['alice', 'alice', 'bob', 'bob', 'bob'],ids = ['abc', 'def', 'ghi', 'jkl', 'mno'],views = [50, 50, 60, 60, 60]) == [['bob', 'ghi']]\n assert candidate(creators = ['grace', 'heidi', 'grace', 'heidi', 'grace'],ids = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'],views = [500, 500, 400, 300, 500]) == [['grace', 'alpha']]\n assert candidate(creators = ['alice', 'bob', 'bob', 'alice', 'chris'],ids = ['a', 'b', 'c', 'a', 'd'],views = [10, 20, 20, 30, 5]) == [['alice', 'a'], ['bob', 'b']]\n assert candidate(creators = ['dave', 'eve', 'dave', 'eve', 'dave'],ids = ['movie', 'movie', 'series', 'series', 'episode'],views = [100, 100, 200, 200, 50]) == [['dave', 'series']]\n assert candidate(creators = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve'],ids = ['a', 'b', 'c', 'd', 'e', 'f'],views = [5, 10, 15, 20, 25, 30]) == [['eve', 'f']]\n assert candidate(creators = ['karen', 'leo', 'mike', 'leo', 'karen', 'mike'],ids = ['a', 'b', 'c', 'd', 'e', 'f'],views = [30, 40, 30, 40, 30, 40]) == [['leo', 'b']]\n assert candidate(creators = ['eve', 'eve', 'eve', 'eve', 'eve'],ids = ['x', 'y', 'z', 'x', 'y'],views = [10, 20, 30, 10, 20]) == [['eve', 'z']]\n assert candidate(creators = ['jane', 'jane', 'jane', 'jane', 'jane', 'jane'],ids = ['one', 'two', 'three', 'four', 'five', 'six'],views = [10, 10, 10, 10, 10, 10]) == [['jane', 'five']]\n assert candidate(creators = ['dave', 'eve', 'frank', 'dave', 'eve', 'frank'],ids = ['m', 'n', 'o', 'p', 'q', 'r'],views = [100, 200, 150, 250, 175, 225]) == [['eve', 'n'], ['frank', 'r']]\n assert candidate(creators = ['eve', 'eve', 'eve', 'eve', 'eve'],ids = ['x', 'y', 'z', 'x', 'y'],views = [10, 20, 10, 20, 10]) == [['eve', 'x']]\n assert candidate(creators = ['creator1', 'creator2', 'creator1', 'creator2', 'creator3'],ids = ['video1', 'video2', 'video3', 'video4', 'video5'],views = [100000, 100000, 100000, 100000, 100000]) == [['creator1', 'video1'], ['creator2', 'video2']]\n assert candidate(creators = ['anna', 'anna', 'anna', 'bob', 'bob'],ids = ['a', 'b', 'c', 'a', 'b'],views = [100, 100, 150, 200, 200]) == [['bob', 'a']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice', 'alice'],ids = ['one', 'two', 'three', 'four', 'five', 'six', 'seven'],views = [5, 10, 5, 4, 10, 5, 10]) == [['alice', 'seven']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'bob', 'alice'],ids = ['x', 'y', 'z', 'x', 'y'],views = [10, 20, 10, 20, 30]) == [['alice', 'y']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'bob', 'alice', 'bob', 'alice', 'bob'],ids = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'],views = [1, 2, 3, 4, 5, 6, 7, 8]) == [['bob', 'a']]\n assert candidate(creators = ['mike', 'mike', 'mike', 'mike', 'mike', 'mike'],ids = ['same', 'same', 'same', 'same', 'same', 'same'],views = [5, 5, 5, 5, 5, 5]) == [['mike', 'same']]\n assert candidate(creators = ['x', 'y', 'z', 'x', 'y', 'z'],ids = ['a', 'b', 'c', 'a', 'b', 'c'],views = [10, 10, 10, 20, 20, 20]) == [['x', 'a'], ['y', 'b'], ['z', 'c']]\n assert candidate(creators = ['peter', 'quinn', 'peter', 'quinn', 'peter', 'quinn'],ids = ['zero', 'one', 'zero', 'one', 'zero', 'one'],views = [500, 600, 700, 800, 900, 1000]) == [['quinn', 'one']]\n assert candidate(creators = ['anna', 'anna', 'anna', 'anna', 'anna'],ids = ['z', 'y', 'x', 'w', 'v'],views = [5, 5, 5, 5, 5]) == [['anna', 'v']]\n assert candidate(creators = ['anna', 'bob', 'charlie', 'anna', 'bob', 'anna'],ids = ['x', 'y', 'z', 'x', 'y', 'z'],views = [100, 200, 300, 150, 250, 50]) == [['bob', 'y']]\n assert candidate(creators = ['z', 'z', 'z', 'y', 'y', 'y', 'x', 'x', 'x'],ids = ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c'],views = [100, 200, 150, 300, 400, 400, 500, 600, 650]) == [['x', 'c']]\n assert candidate(creators = ['alice', 'bob', 'alice', 'charlie', 'bob', 'alice'],ids = ['abc', 'bcd', 'cba', 'xyz', 'zyx', 'bac'],views = [50, 75, 50, 100, 75, 50]) == [['alice', 'abc'], ['bob', 'bcd']]\n"}, "metadata": {"canonical_parameter_names": ["creators", "ids", "views"], "leetcode_dataset_entry_point": "Solution().mostPopularCreator", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List> mostPopularCreator(String[] creators, String[] ids, int[] views) {", "container": "Solution", "callable": "mostPopularCreator", "parameters": [{"name": "creators", "type": "String[]"}, {"name": "ids", "type": "String[]"}, {"name": "views", "type": "int[]"}], "return_type": "List>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2457, "task_id": "minimum-addition-to-make-integer-beautiful", "difficulty": "Medium", "problem_description": "You are given two positive integers n and target.\nAn integer is considered beautiful if the sum of its digits is less than or equal to target.\nReturn the minimum non-negative integer x such that n + x is beautiful. The input will be generated such that it is always possible to make n beautiful.\n \nExample 1:\n\nInput: n = 16, target = 6\nOutput: 4\nExplanation: Initially n is 16 and its digit sum is 1 + 6 = 7. After adding 4, n becomes 20 and digit sum becomes 2 + 0 = 2. It can be shown that we can not make n beautiful with adding non-negative integer less than 4.\n\nExample 2:\n\nInput: n = 467, target = 6\nOutput: 33\nExplanation: Initially n is 467 and its digit sum is 4 + 6 + 7 = 17. After adding 33, n becomes 500 and digit sum becomes 5 + 0 + 0 = 5. It can be shown that we can not make n beautiful with adding non-negative integer less than 33.\n\nExample 3:\n\nInput: n = 1, target = 1\nOutput: 0\nExplanation: Initially n is 1 and its digit sum is 1, which is already smaller than or equal to target.\n\n \nConstraints:\n\n1 <= n <= 1012\n1 <= target <= 150\nThe input will be generated such that it is always possible to make n beautiful.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1000000000000,target = 1) == 0\n assert candidate(n = 1,target = 1) == 0\n assert candidate(n = 99999,target = 5) == 1\n assert candidate(n = 8888,target = 32) == 0\n assert candidate(n = 888888888,target = 24) == 1111112\n assert candidate(n = 467,target = 6) == 33\n assert candidate(n = 123456789,target = 30) == 11\n assert candidate(n = 123456789,target = 10) == 543211\n assert candidate(n = 999,target = 27) == 0\n assert candidate(n = 56789,target = 25) == 11\n assert candidate(n = 123,target = 6) == 0\n assert candidate(n = 1000000000,target = 1) == 0\n assert candidate(n = 999,target = 15) == 1\n assert candidate(n = 123456789,target = 20) == 3211\n assert candidate(n = 999999999,target = 10) == 1\n assert candidate(n = 1001,target = 1) == 8999\n assert candidate(n = 999999999999,target = 1) == 1\n assert candidate(n = 16,target = 6) == 4\n assert candidate(n = 111111111,target = 9) == 0\n assert candidate(n = 35791113151719,target = 30) == 6848281\n assert candidate(n = 12345678910111213,target = 50) == 787\n assert candidate(n = 100000000000,target = 1) == 0\n assert candidate(n = 88888888888,target = 10) == 1111111112\n assert candidate(n = 987654321098,target = 50) == 2\n assert candidate(n = 100,target = 1) == 0\n assert candidate(n = 345678901234567890,target = 100) == 0\n assert candidate(n = 888888888888,target = 24) == 1111111112\n assert candidate(n = 101010101010,target = 15) == 0\n assert candidate(n = 234567890123,target = 30) == 109877\n assert candidate(n = 666666666666,target = 42) == 333334\n assert candidate(n = 9876543210987654321,target = 100) == 0\n assert candidate(n = 1234567890,target = 15) == 432110\n assert candidate(n = 1234567890123456789,target = 50) == 6543211\n assert candidate(n = 54321,target = 15) == 0\n assert candidate(n = 987654321098765432,target = 50) == 1234568\n assert candidate(n = 1234567890,target = 18) == 32110\n assert candidate(n = 2222222222222222222,target = 50) == 0\n assert candidate(n = 111111111111111111,target = 9) == 8888888889\n assert candidate(n = 888888888888888,target = 35) == 11111111112\n assert candidate(n = 555555555,target = 15) == 4444445\n assert candidate(n = 4567891234567890,target = 75) == 110\n assert candidate(n = 888888888888,target = 60) == 11112\n assert candidate(n = 1999999999,target = 10) == 1\n assert candidate(n = 567890123456,target = 75) == 0\n assert candidate(n = 9876543210,target = 30) == 3456790\n assert candidate(n = 9876543210,target = 50) == 0\n assert candidate(n = 555555555555555555,target = 75) == 4445\n assert candidate(n = 999999999,target = 1) == 1\n assert candidate(n = 987654321098,target = 27) == 345678902\n assert candidate(n = 500000000000,target = 5) == 0\n assert candidate(n = 123456789123456789,target = 75) == 11\n assert candidate(n = 222222222222222,target = 25) == 778\n assert candidate(n = 3333333333333333333,target = 30) == 6666666667\n assert candidate(n = 987654321,target = 10) == 12345679\n assert candidate(n = 999999999999,target = 10) == 1\n assert candidate(n = 1999999999999,target = 150) == 0\n assert candidate(n = 1000000000001,target = 2) == 0\n assert candidate(n = 1111111111111111111,target = 20) == 0\n assert candidate(n = 888888888888,target = 35) == 11111112\n assert candidate(n = 876543210,target = 10) == 23456790\n assert candidate(n = 999,target = 2) == 1\n assert candidate(n = 999999999999999999,target = 5) == 1\n assert candidate(n = 99999999999,target = 9) == 1\n assert candidate(n = 999999999,target = 45) == 1\n assert candidate(n = 505050505050505050,target = 45) == 0\n assert candidate(n = 598765432109,target = 30) == 34567891\n assert candidate(n = 1234567890123456789,target = 45) == 9876543211\n assert candidate(n = 1234567890123456789,target = 100) == 0\n assert candidate(n = 9000000000009,target = 18) == 0\n assert candidate(n = 599999999999999999,target = 5) == 400000000000000001\n assert candidate(n = 9876543210987654321,target = 50) == 12345679\n assert candidate(n = 123456789012,target = 45) == 988\n assert candidate(n = 12345678901234567890,target = 100) == 0\n assert candidate(n = 987654321,target = 20) == 2345679\n assert candidate(n = 54321,target = 8) == 5679\n assert candidate(n = 111111111111111,target = 14) == 89\n assert candidate(n = 112233445566778899,target = 60) == 1101\n assert candidate(n = 100100100100,target = 3) == 899900\n assert candidate(n = 1999999999999999999,target = 90) == 1\n assert candidate(n = 888888888,target = 7) == 111111112\n assert candidate(n = 4321,target = 4) == 5679\n assert candidate(n = 999999999999,target = 2) == 1\n assert candidate(n = 999999999999999999,target = 100) == 1\n assert candidate(n = 599599599,target = 25) == 400401\n assert candidate(n = 567890123456,target = 30) == 9876544\n assert candidate(n = 54321,target = 5) == 45679\n assert candidate(n = 5000000000,target = 5) == 0\n assert candidate(n = 99998,target = 4) == 2\n assert candidate(n = 246813579111357,target = 50) == 643\n assert candidate(n = 888888888,target = 15) == 11111112\n assert candidate(n = 567890123456789,target = 50) == 43211\n assert candidate(n = 888888888,target = 10) == 11111112\n assert candidate(n = 1111111111111111111,target = 150) == 0\n assert candidate(n = 1000000000001,target = 1) == 8999999999999\n assert candidate(n = 1,target = 2) == 0\n assert candidate(n = 111111111111,target = 12) == 0\n assert candidate(n = 999999999999999999,target = 81) == 1\n assert candidate(n = 222222222222,target = 24) == 0\n assert candidate(n = 987654321,target = 25) == 345679\n assert candidate(n = 1999999999999999,target = 18) == 1\n assert candidate(n = 1000000000000000000,target = 1) == 0\n assert candidate(n = 2222222222222222222,target = 40) == 0\n assert candidate(n = 333333333333,target = 30) == 667\n"}, "metadata": {"canonical_parameter_names": ["n", "target"], "leetcode_dataset_entry_point": "Solution().makeIntegerBeautiful", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long makeIntegerBeautiful(long n, int target) {", "container": "Solution", "callable": "makeIntegerBeautiful", "parameters": [{"name": "n", "type": "long"}, {"name": "target", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2458, "task_id": "height-of-binary-tree-after-subtree-removal-queries", "difficulty": "Hard", "problem_description": "You are given the root of a binary tree with n nodes. Each node is assigned a unique value from 1 to n. You are also given an array queries of size m.\nYou have to perform m independent queries on the tree where in the ith query you do the following:\n\nRemove the subtree rooted at the node with the value queries[i] from the tree. It is guaranteed that queries[i] will not be equal to the value of the root.\n\nReturn an array answer of size m where answer[i] is the height of the tree after performing the ith query.\nNote:\n\nThe queries are independent, so the tree returns to its initial state after each query.\nThe height of a tree is the number of edges in the longest simple path from the root to some node in the tree.\n\n \nExample 1:\n\n\nInput: root = [1,3,4,2,null,6,5,null,null,null,null,null,7], queries = [4]\nOutput: [2]\nExplanation: The diagram above shows the tree after removing the subtree rooted at node with value 4.\nThe height of the tree is 2 (The path 1 -> 3 -> 2).\n\nExample 2:\n\n\nInput: root = [5,8,9,2,1,3,7,4,6], queries = [3,2,4,8]\nOutput: [3,2,3,2]\nExplanation: We have the following queries:\n- Removing the subtree rooted at node with value 3. The height of the tree becomes 3 (The path 5 -> 8 -> 2 -> 4).\n- Removing the subtree rooted at node with value 2. The height of the tree becomes 2 (The path 5 -> 8 -> 1).\n- Removing the subtree rooted at node with value 4. The height of the tree becomes 3 (The path 5 -> 8 -> 2 -> 6).\n- Removing the subtree rooted at node with value 8. The height of the tree becomes 2 (The path 5 -> 9 -> 3).\n\n \nConstraints:\n\nThe number of nodes in the tree is n.\n2 <= n <= 105\n1 <= Node.val <= n\nAll the values in the tree are unique.\nm == queries.length\n1 <= m <= min(n, 104)\n1 <= queries[i] <= n\nqueries[i] != root.val\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([5, 8, 9, 2, 1, 3, 7, 4, 6]),queries = [3, 2, 4, 8]) == [3, 2, 3, 2]\n assert candidate(root = tree_node([1, 3, 4, 2, None, 6, 5, None, None, None, None, None, 7]),queries = [4]) == [2]\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),queries = [2, 4, 6, 8, 10, 12, 14]) == [0, 2, 4, 6, 8, 10, 12]\n assert candidate(root = tree_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]),queries = [16, 21, 26, 31, 1]) == [4, 4, 4, 4, 0]\n assert candidate(root = tree_node([1, 2, None, 3, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),queries = [4, 5, 8, 10]) == [5, 5, 5, 5]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, None, 10, None, None, None, 11, None, 12, None, None, 13, None, None, None, 14, None, 15]),queries = [13, 8, 2, 7, 15]) == [5, 5, 3, 5, 5]\n assert candidate(root = tree_node([7, 3, 9, 2, 4, 8, 10, None, None, 5, 6, None, 9, None, None, 11, None, 12]),queries = [4, 9, 7, 10, 11, 3, 8]) == [3, 4, 0, 4, 4, 3, 4]\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),queries = [2, 6, 12, 15]) == [0, 4, 10, 13]\n assert candidate(root = tree_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]),queries = [35, 20, 10, 5, 1, 30, 40, 50]) == [5, 5, 5, 5, 0, 5, 5, 5]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),queries = [16, 17, 18, 19, 20]) == [4, 4, 4, 4, 4]\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 4, 5, 4, 5, 4, 5, 4, 5, 4]\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9]),queries = [4, 5, 6, 7, 8, 9]) == [4, 4, 4, 4, 4, 4]\n assert candidate(root = tree_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]),queries = [30, 20, 10, 35, 40, 25, 50]) == [5, 5, 5, 5, 5, 5, 5]\n assert candidate(root = tree_node([5, 1, 4, None, 2, None, 3, None, None, 6, 7]),queries = [1, 4, 7, 6]) == [3, 2, 3, 3]\n assert candidate(root = tree_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]),queries = [10, 20, 30, 40]) == [5, 5, 5, 5]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, 8, 9, None, None, 10, 11, 12, 13, None, None, None, None, None, 14, 15, 16, None, 17, None, None, None, None, None, None, 18, None, None, None, None, None, 19]),queries = [10, 5, 18, 4, 15, 6, 16]) == [6, 4, 5, 6, 6, 6, 6]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),queries = [10, 5, 12, 1, 15]) == [3, 3, 3, 0, 3]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),queries = [8, 12, 5, 1]) == [3, 3, 3, 0]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),queries = [5, 12, 18, 20, 10]) == [4, 4, 4, 4, 4]\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),queries = [6, 4, 8, 10]) == [4, 4, 4, 4]\n assert candidate(root = tree_node([6, 2, 8, 0, 4, 7, 9, None, None, 3, 5]),queries = [0, 5, 9, 2, 8]) == [3, 3, 3, 2, 3]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),queries = [16, 9, 12, 20]) == [4, 4, 4, 4]\n assert candidate(root = tree_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]),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, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [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]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),queries = [8, 5, 12, 3]) == [3, 3, 3, 3]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),queries = [4, 10, 14, 7, 3]) == [3, 3, 3, 3, 3]\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),queries = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, None, 1, None, None, None, 7]),queries = [1, 7, 3, 6]) == [2, 3, 1, 4]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [3, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),queries = [4, 6, 10, 2, 8]) == [1, 3, 7, 1, 5]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),queries = [15, 8, 12, 4, 1]) == [3, 3, 3, 3, 0]\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),queries = [4, 7, 10]) == [2, 5, 8]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),queries = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(root = tree_node([6, 3, 9, 2, 5, 8, 10, 1, 4, 7, 11, 12]),queries = [6, 9, 3, 10, 2]) == [0, 3, 3, 3, 3]\n assert candidate(root = tree_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]),queries = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),queries = [8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(root = tree_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]),queries = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(root = tree_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]),queries = [16, 20, 25, 10, 5, 15]) == [4, 4, 4, 4, 4, 4]\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),queries = [5, 7, 9, 10]) == [3, 5, 7, 8]\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),queries = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(root = tree_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]),queries = [15, 20, 25, 30]) == [4, 4, 4, 4]\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9]),queries = [2, 5, 8, 9]) == [4, 4, 4, 4]\n"}, "metadata": {"canonical_parameter_names": ["root", "queries"], "leetcode_dataset_entry_point": "Solution().treeQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2460, "task_id": "apply-operations-to-an-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array nums of size n consisting of non-negative integers.\nYou need to apply n - 1 operations to this array where, in the ith operation (0-indexed), you will apply the following on the ith element of nums:\n\nIf nums[i] == nums[i + 1], then multiply nums[i] by 2 and set nums[i + 1] to 0. Otherwise, you skip this operation.\n\nAfter performing all the operations, shift all the 0's to the end of the array.\n\nFor example, the array [1,0,2,0,0,1] after shifting all its 0's to the end, is [1,2,1,0,0,0].\n\nReturn the resulting array.\nNote that the operations are applied sequentially, not all at once.\n \nExample 1:\n\nInput: nums = [1,2,2,1,1,0]\nOutput: [1,4,2,0,0,0]\nExplanation: We do the following operations:\n- i = 0: nums[0] and nums[1] are not equal, so we skip this operation.\n- i = 1: nums[1] and nums[2] are equal, we multiply nums[1] by 2 and change nums[2] to 0. The array becomes [1,4,0,1,1,0].\n- i = 2: nums[2] and nums[3] are not equal, so we skip this operation.\n- i = 3: nums[3] and nums[4] are equal, we multiply nums[3] by 2 and change nums[4] to 0. The array becomes [1,4,0,2,0,0].\n- i = 4: nums[4] and nums[5] are equal, we multiply nums[4] by 2 and change nums[5] to 0. The array becomes [1,4,0,2,0,0].\nAfter that, we shift the 0's to the end, which gives the array [1,4,2,0,0,0].\n\nExample 2:\n\nInput: nums = [0,1]\nOutput: [1,0]\nExplanation: No operation can be applied, we just shift the 0 to the end.\n\n \nConstraints:\n\n2 <= nums.length <= 2000\n0 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [6, 5, 4, 3, 2, 1]) == [6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 2, 3, 2]) == [1, 2, 3, 2, 3, 2]\n assert candidate(nums = [2, 2, 0, 0, 1, 1, 1]) == [4, 2, 1, 0, 0, 0, 0]\n assert candidate(nums = [10, 10, 0, 0, 10, 10, 10]) == [20, 20, 10, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 3, 3, 2, 2, 1]) == [1, 6, 3, 4, 1, 0, 0]\n assert candidate(nums = [1, 2, 3, 2, 1, 2]) == [1, 2, 3, 2, 1, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\n assert candidate(nums = [10, 10, 0, 0, 10, 10, 0, 0, 10, 10]) == [20, 20, 20, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 3, 3, 2, 2, 1, 1, 0, 0]) == [1, 6, 3, 4, 2, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 1]) == [1, 0]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [2, 2, 2, 2, 2, 2]) == [4, 4, 4, 0, 0, 0]\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == [1, 1, 1, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == [1, 2, 3, 4, 5, 6]\n assert candidate(nums = [10, 10, 20, 20, 30, 30]) == [20, 40, 60, 0, 0, 0]\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000, 1000, 0, 0, 1000, 1000]) == [2000, 2000, 0, 0, 0, 0]\n assert candidate(nums = [1, 0, 2, 0, 0, 1]) == [1, 2, 1, 0, 0, 0]\n assert candidate(nums = [1, 1, 0, 0, 1, 1]) == [2, 2, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == [10, 10, 10, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 0, 0, 0, 0, 0, 0]) == [10, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 2, 1, 1, 0]) == [1, 4, 2, 0, 0, 0]\n assert candidate(nums = [6, 6, 5, 5, 4, 4]) == [12, 10, 8, 0, 0, 0]\n assert candidate(nums = [2, 2, 0, 0, 1, 1]) == [4, 2, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == [1, 4, 6, 8, 10, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == [2, 2, 2, 0, 0, 0]\n assert candidate(nums = [0, 2, 2, 0, 0, 3, 3, 0, 0, 4, 4]) == [4, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [2, 2, 2, 2, 2]) == [4, 4, 2, 0, 0]\n assert candidate(nums = [2, 2, 0, 0, 2, 2]) == [4, 4, 0, 0, 0, 0]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 0, 0, 0]) == [20, 20, 20, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]\n assert candidate(nums = [10, 10, 10, 10, 10, 0, 0, 0, 0, 0]) == [20, 20, 10, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [2, 4, 4, 6, 6, 3, 0, 0, 0, 0, 0]\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 = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0]) == [100, 100, 100, 100, 100, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 20, 20, 10, 10, 20, 20]) == [10, 40, 20, 40, 0, 0, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\n assert candidate(nums = [999, 999, 0, 999, 999, 999, 0, 0, 999, 999, 999]) == [1998, 1998, 999, 1998, 999, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [6, 6, 0, 6, 0, 6, 0, 6, 6, 6, 0, 6, 6, 0]) == [12, 6, 6, 12, 6, 12, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 2, 2, 1, 1]) == [1, 4, 1, 6, 4, 2, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == [2, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [500, 500, 1000, 1000, 500, 500, 0, 0, 0, 0]) == [1000, 2000, 1000, 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]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0]) == [1, 1, 1, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 0, 5, 5, 0, 0, 5, 5, 5, 0]) == [5, 10, 10, 5, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == [20, 40, 60, 80, 100, 0, 0, 0, 0, 0]\n assert candidate(nums = [2, 2, 0, 0, 2, 2, 0, 0, 2, 2]) == [4, 4, 4, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 4, 3, 2, 1]\n assert candidate(nums = [1000, 1000, 999, 999, 888, 888, 777, 777]) == [2000, 1998, 1776, 1554, 0, 0, 0, 0]\n assert candidate(nums = [2, 2, 0, 2, 2, 0, 2, 2, 0, 2]) == [4, 4, 4, 2, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [1, 4, 6, 3, 8, 8, 0, 0, 0, 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]\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 2, 6, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [3, 3, 3, 0, 3, 3, 0, 0, 3, 3, 3, 0]) == [6, 3, 6, 6, 3, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == [2, 1, 4, 2, 6, 3, 0, 0, 0]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 2, 2, 2, 2, 2, 5, 5]) == [10, 5, 4, 4, 2, 10, 0, 0, 0, 0]\n assert candidate(nums = [6, 6, 6, 6, 0, 0, 0, 0, 6, 6]) == [12, 12, 12, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == [2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [3, 3, 3, 0, 3, 3, 0, 0, 3, 3, 3, 0, 3, 0, 3]) == [6, 3, 6, 6, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == [2000, 2000, 2000, 2000, 2000, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [2, 4, 6, 8, 10, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 10, 9, 10, 9, 10, 9, 10, 9, 10]) == [9, 10, 9, 10, 9, 10, 9, 10, 9, 10]\n assert candidate(nums = [999, 0, 999, 0, 999, 0, 999, 0, 999, 0]) == [999, 999, 999, 999, 999, 0, 0, 0, 0, 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]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2]) == [4, 2, 4, 2, 4, 2, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 0, 10, 10, 0, 10, 0, 10, 10, 10]) == [10, 20, 10, 20, 10, 0, 0, 0, 0, 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]\n assert candidate(nums = [1, 2, 2, 1, 1, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0]) == [1, 4, 2, 2, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == [1, 2, 3, 2, 1, 2, 3, 2, 1]\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [18, 18, 18, 18, 18, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 0, 0, 5, 5, 5, 0]) == [10, 10, 5, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1]) == [2, 2, 2, 0, 0, 0, 0, 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]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0]) == [1, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32]) == [1, 4, 8, 16, 32, 32, 0, 0, 0, 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]\n assert candidate(nums = [3, 0, 3, 3, 0, 0, 3, 3, 0, 3]) == [3, 6, 6, 3, 0, 0, 0, 0, 0, 0]\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == [2, 2, 1, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == [2000, 2000, 2000, 2000, 0, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0]) == [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000, 1000, 0, 0, 1000, 1000, 1000, 0, 0, 1000]) == [2000, 2000, 1000, 1000, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [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, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0]\n assert candidate(nums = [5, 5, 0, 0, 5, 5, 0, 0, 5, 5]) == [10, 10, 10, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [2, 2, 2, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0, 0, 0, 0]) == [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0, 0, 0, 0]\n assert candidate(nums = [9, 9, 0, 0, 9, 0, 9, 9, 9, 0, 9, 9, 0, 9, 9, 9, 0, 9, 9, 9]) == [18, 9, 18, 9, 18, 18, 9, 18, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1]) == [1, 4, 2, 2, 1, 4, 2, 2, 4, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40]) == [20, 40, 60, 80, 0, 0, 0, 0]\n assert candidate(nums = [0, 1, 1, 2, 2, 0, 3, 3, 0, 4, 4, 0]) == [2, 4, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0]\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]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 0, 0, 0]) == [2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [7, 0, 7, 0, 7, 0, 7, 0, 7, 0]) == [7, 7, 7, 7, 7, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 0, 10, 0, 10, 0, 10, 0, 10]) == [10, 10, 10, 10, 10, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 0, 5, 5, 0, 0, 5, 5]) == [10, 5, 10, 10, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 0, 0, 5, 5, 5, 5]) == [10, 10, 10, 10, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [8, 8, 8, 0, 8, 8, 0, 8, 8, 8]) == [16, 8, 16, 16, 8, 0, 0, 0, 0, 0]\n assert candidate(nums = [7, 7, 7, 7, 0, 0, 0, 0, 7, 7]) == [14, 14, 14, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [2, 2, 2, 2, 2, 0, 0, 0, 0, 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]\n assert candidate(nums = [100, 200, 200, 100, 100, 200, 200, 100]) == [100, 400, 200, 400, 100, 0, 0, 0]\n assert candidate(nums = [5, 5, 0, 5, 5, 5, 0, 0, 5, 5]) == [10, 10, 5, 10, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == [2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000, 1000, 0, 500, 500, 0, 250, 250, 0]) == [2000, 1000, 500, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == [2, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4]) == [2, 4, 2, 6, 8, 8, 0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().applyOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] applyOperations(int[] nums) {", "container": "Solution", "callable": "applyOperations", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2461, "task_id": "maximum-sum-of-distinct-subarrays-with-length-k", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k. Find the maximum subarray sum of all the subarrays of nums that meet the following conditions:\n\nThe length of the subarray is k, and\nAll the elements of the subarray are distinct.\n\nReturn the maximum subarray sum of all the subarrays that meet the conditions. If no subarray meets the conditions, return 0.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,5,4,2,9,9,9], k = 3\nOutput: 15\nExplanation: The subarrays of nums with length 3 are:\n- [1,5,4] which meets the requirements and has a sum of 10.\n- [5,4,2] which meets the requirements and has a sum of 11.\n- [4,2,9] which meets the requirements and has a sum of 15.\n- [2,9,9] which does not meet the requirements because the element 9 is repeated.\n- [9,9,9] which does not meet the requirements because the element 9 is repeated.\nWe return 15 because it is the maximum subarray sum of all the subarrays that meet the conditions\n\nExample 2:\n\nInput: nums = [4,4,4], k = 3\nOutput: 0\nExplanation: The subarrays of nums with length 3 are:\n- [4,4,4] which does not meet the requirements because the element 4 is repeated.\nWe return 0 because no subarrays meet the conditions.\n\n \nConstraints:\n\n1 <= k <= nums.length <= 105\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 5\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 3) == 24\n assert candidate(nums = [1, 2, 2, 1, 3, 4, 5, 6],k = 4) == 18\n assert candidate(nums = [1, 2, 2, 3, 4, 5],k = 4) == 14\n assert candidate(nums = [1, 2, 2, 1, 3, 4, 5, 6, 7, 8],k = 4) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],k = 1) == 50\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1],k = 6) == 45\n assert candidate(nums = [10, 20, 30, 40, 50],k = 5) == 150\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == 30\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 40\n assert candidate(nums = [1, 5, 4, 2, 9, 9, 9],k = 3) == 15\n assert candidate(nums = [4, 4, 4],k = 3) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 3) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],k = 4) == 140\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [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 = 4) == 34\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],k = 5) == 450\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11],k = 5) == 0\n assert candidate(nums = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2],k = 5) == 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 = 5) == 0\n assert candidate(nums = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7],k = 8) == 44\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 = 6) == 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],k = 10) == 55\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 = 7) == 0\n assert candidate(nums = [1, 2, 3, 2, 4, 5, 6, 5, 7, 8, 9],k = 4) == 29\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 = 10) == 300\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) == 465\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) == 155\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 5) == 499990\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) == 0\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 15) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [3, 1, 2, 3, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 155\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 15) == 1200\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],k = 5) == 40\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 4) == 22\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 = 8) == 442\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],k = 50) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 3) == 0\n assert candidate(nums = [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 = 7) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5],k = 10) == 5500\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) == 345\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) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 9) == 45\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 5) == 499990\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 2) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 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],k = 20) == 210\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8],k = 5) == 35\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 = 10) == 155\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\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 = 5) == 0\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],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 = 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, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35],k = 20) == 510\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],k = 10) == 155\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11],k = 6) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 5) == 45\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],k = 5) == 35\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 5, 4, 7, 8, 9, 8, 7, 10, 11, 12, 11, 10],k = 7) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 34\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],k = 5) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [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],k = 11) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == 35\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 5) == 6500\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) == 0\n assert candidate(nums = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 8) == 84\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) == 255\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == 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],k = 5) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 84\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 4) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 550\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 = 15) == 270\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 5, 5, 5, 5],k = 4) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 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],k = 10) == 155\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 = 3) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == 35\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 4000\n assert candidate(nums = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 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 = 3) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 9, 10],k = 5) == 35\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 = 10) == 55\n assert candidate(nums = [3, 3, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 6) == 57\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5],k = 7) == 42\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 15],k = 4) == 54\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumSubarraySum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumSubarraySum(int[] nums, int k) {", "container": "Solution", "callable": "maximumSubarraySum", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2462, "task_id": "total-cost-to-hire-k-workers", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array costs where costs[i] is the cost of hiring the ith worker.\nYou are also given two integers k and candidates. We want to hire exactly k workers according to the following rules:\n\nYou will run k sessions and hire exactly one worker in each session.\nIn each hiring session, choose the worker with the lowest cost from either the first candidates workers or the last candidates workers. Break the tie by the smallest index.\n\t\nFor example, if costs = [3,2,7,7,1,2] and candidates = 2, then in the first hiring session, we will choose the 4th worker because they have the lowest cost [3,2,7,7,1,2].\nIn the second hiring session, we will choose 1st worker because they have the same lowest cost as 4th worker but they have the smallest index [3,2,7,7,2]. Please note that the indexing may be changed in the process.\n\n\nIf there are fewer than candidates workers remaining, choose the worker with the lowest cost among them. Break the tie by the smallest index.\nA worker can only be chosen once.\n\nReturn the total cost to hire exactly k workers.\n \nExample 1:\n\nInput: costs = [17,12,10,2,7,2,11,20,8], k = 3, candidates = 4\nOutput: 11\nExplanation: We hire 3 workers in total. The total cost is initially 0.\n- In the first hiring round we choose the worker from [17,12,10,2,7,2,11,20,8]. The lowest cost is 2, and we break the tie by the smallest index, which is 3. The total cost = 0 + 2 = 2.\n- In the second hiring round we choose the worker from [17,12,10,7,2,11,20,8]. The lowest cost is 2 (index 4). The total cost = 2 + 2 = 4.\n- In the third hiring round we choose the worker from [17,12,10,7,11,20,8]. The lowest cost is 7 (index 3). The total cost = 4 + 7 = 11. Notice that the worker with index 3 was common in the first and last four workers.\nThe total hiring cost is 11.\n\nExample 2:\n\nInput: costs = [1,2,4,1], k = 3, candidates = 3\nOutput: 4\nExplanation: We hire 3 workers in total. The total cost is initially 0.\n- In the first hiring round we choose the worker from [1,2,4,1]. The lowest cost is 1, and we break the tie by the smallest index, which is 0. The total cost = 0 + 1 = 1. Notice that workers with index 1 and 2 are common in the first and last 3 workers.\n- In the second hiring round we choose the worker from [2,4,1]. The lowest cost is 1 (index 2). The total cost = 1 + 1 = 2.\n- In the third hiring round there are less than three candidates. We choose the worker from the remaining workers [2,4]. The lowest cost is 2 (index 0). The total cost = 2 + 2 = 4.\nThe total hiring cost is 4.\n\n \nConstraints:\n\n1 <= costs.length <= 105 \n1 <= costs[i] <= 105\n1 <= k, candidates <= costs.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(costs = [10, 10, 10, 10, 10],k = 4,candidates = 2) == 40\n assert candidate(costs = [10, 10, 10, 10, 10],k = 5,candidates = 5) == 50\n assert candidate(costs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5,candidates = 5) == 10\n assert candidate(costs = [5, 4, 3, 2, 1],k = 5,candidates = 1) == 15\n assert candidate(costs = [5, 4, 3, 2, 1],k = 3,candidates = 1) == 6\n assert candidate(costs = [5, 5, 5, 5],k = 2,candidates = 2) == 10\n assert candidate(costs = [10, 20, 30, 40, 50],k = 5,candidates = 5) == 150\n assert candidate(costs = [17, 12, 10, 2, 7, 2, 11, 20, 8],k = 3,candidates = 4) == 11\n assert candidate(costs = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 10,candidates = 10) == 90\n assert candidate(costs = [3, 2, 7, 7, 1, 2],k = 2,candidates = 2) == 3\n assert candidate(costs = [10, 20, 30, 40, 50],k = 2,candidates = 3) == 30\n assert candidate(costs = [1, 2, 4, 1],k = 3,candidates = 3) == 4\n assert candidate(costs = [10, 20, 30, 40, 50],k = 3,candidates = 1) == 60\n assert candidate(costs = [5, 4, 3, 2, 1],k = 2,candidates = 1) == 3\n assert candidate(costs = [25, 15, 30, 20, 10],k = 4,candidates = 2) == 70\n assert candidate(costs = [31, 25, 72, 79, 74],k = 3,candidates = 2) == 128\n assert candidate(costs = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5,candidates = 3) == 150\n assert candidate(costs = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 7,candidates = 3) == 280\n assert candidate(costs = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9,candidates = 4) == 45\n assert candidate(costs = [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],k = 15,candidates = 15) == 300\n assert candidate(costs = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100],k = 6,candidates = 4) == 210\n assert candidate(costs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,candidates = 4) == 55\n assert candidate(costs = [1, 3, 2, 4, 5, 7, 6, 8, 10, 9, 11, 13, 12, 14, 15],k = 8,candidates = 4) == 36\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,candidates = 3) == 5\n assert candidate(costs = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15,candidates = 6) == 80\n assert candidate(costs = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 10,candidates = 3) == 955\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,candidates = 6) == 55\n assert candidate(costs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15,candidates = 8) == 120\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10,candidates = 5) == 31\n assert candidate(costs = [10, 20, 30, 15, 25, 5, 40, 35, 2, 1],k = 5,candidates = 3) == 33\n assert candidate(costs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,candidates = 2) == 55\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,candidates = 5) == 10\n assert candidate(costs = [9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9],k = 10,candidates = 5) == 26\n assert candidate(costs = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 7,candidates = 3) == 28\n assert candidate(costs = [50, 20, 30, 10, 40, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10,candidates = 4) == 550\n assert candidate(costs = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 10,candidates = 5) == 110\n assert candidate(costs = [5, 3, 8, 6, 2, 7, 4, 1, 10, 15, 20, 25, 30],k = 8,candidates = 4) == 36\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6,candidates = 5) == 210\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 7,candidates = 8) == 2800\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10,candidates = 5) == 55\n assert candidate(costs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,candidates = 10) == 55\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7,candidates = 4) == 280\n assert candidate(costs = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],k = 15,candidates = 7) == 255\n assert candidate(costs = [5, 3, 8, 6, 2, 7, 4, 1],k = 4,candidates = 4) == 10\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15,candidates = 4) == 120\n assert candidate(costs = [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],k = 15,candidates = 10) == 1200\n assert candidate(costs = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7,candidates = 5) == 280\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5,candidates = 3) == 150\n assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 7,candidates = 5) == 280\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5,candidates = 3) == 150\n assert candidate(costs = [2, 1, 3, 4, 5, 6, 7, 8, 9],k = 5,candidates = 2) == 15\n assert candidate(costs = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],k = 8,candidates = 5) == 19\n assert candidate(costs = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 5,candidates = 2) == 15000\n assert candidate(costs = [50, 40, 30, 20, 10, 1, 2, 3, 4, 5],k = 5,candidates = 2) == 15\n assert candidate(costs = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10,candidates = 6) == 550\n assert candidate(costs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20,candidates = 10) == 400\n assert candidate(costs = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 5,candidates = 2) == 150000\n assert candidate(costs = [30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165],k = 10,candidates = 5) == 305\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,candidates = 5) == 55\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,candidates = 1) == 10\n assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5,candidates = 2) == 50\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7,candidates = 6) == 280\n assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15,candidates = 7) == 205\n assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10,candidates = 5) == 100\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10,candidates = 5) == 55\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7,candidates = 5) == 280\n assert candidate(costs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8,candidates = 5) == 36\n assert candidate(costs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 10,candidates = 6) == 110\n assert candidate(costs = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 12],k = 6,candidates = 4) == 21\n assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5,candidates = 2) == 50\n assert candidate(costs = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 15,candidates = 7) == 12222222\n assert candidate(costs = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 10,candidates = 1) == 5500\n assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5,candidates = 2) == 150\n assert candidate(costs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,candidates = 5) == 15\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5,candidates = 3) == 150\n assert candidate(costs = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 5,candidates = 2) == 18\n assert candidate(costs = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 10,candidates = 5) == 550000\n assert candidate(costs = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2],k = 10,candidates = 5) == 23\n assert candidate(costs = [5, 1, 4, 2, 3],k = 3,candidates = 1) == 9\n assert candidate(costs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,candidates = 5) == 55\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,candidates = 5) == 55\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,candidates = 5) == 10\n assert candidate(costs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15,candidates = 6) == 120\n assert candidate(costs = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 10,candidates = 10) == 1000\n assert candidate(costs = [5, 3, 8, 6, 2, 7, 4, 1],k = 4,candidates = 2) == 10\n assert candidate(costs = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 7,candidates = 4) == 700\n assert candidate(costs = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],k = 8,candidates = 4) == 19\n assert candidate(costs = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50],k = 5,candidates = 3) == 75\n assert candidate(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, 27, 28, 29, 30],k = 25,candidates = 5) == 325\n assert candidate(costs = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3,candidates = 2) == 6\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,candidates = 2) == 10\n assert candidate(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],k = 15,candidates = 10) == 120\n assert candidate(costs = [50, 40, 30, 20, 10, 10, 20, 30, 40, 50],k = 5,candidates = 5) == 90\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,candidates = 3) == 1500\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15,candidates = 5) == 15\n assert candidate(costs = [8, 6, 4, 2, 0, 0, 2, 4, 6, 8, 8, 6, 4, 2, 0, 0, 2, 4, 6, 8],k = 5,candidates = 2) == 12\n assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5,candidates = 4) == 150\n assert candidate(costs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10,candidates = 5) == 275\n assert candidate(costs = [1, 3, 2, 4, 5, 7, 6, 9, 8, 10, 12, 11, 14, 13, 15, 17, 16, 19, 18, 20],k = 10,candidates = 5) == 55\n"}, "metadata": {"canonical_parameter_names": ["costs", "k", "candidates"], "leetcode_dataset_entry_point": "Solution().totalCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long totalCost(int[] costs, int k, int candidates) {", "container": "Solution", "callable": "totalCost", "parameters": [{"name": "costs", "type": "int[]"}, {"name": "k", "type": "int"}, {"name": "candidates", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2463, "task_id": "minimum-total-distance-traveled", "difficulty": "Hard", "problem_description": "There are some robots and factories on the X-axis. You are given an integer array robot where robot[i] is the position of the ith robot. You are also given a 2D integer array factory where factory[j] = [positionj, limitj] indicates that positionj is the position of the jth factory and that the jth factory can repair at most limitj robots.\nThe positions of each robot are unique. The positions of each factory are also unique. Note that a robot can be in the same position as a factory initially.\nAll the robots are initially broken; they keep moving in one direction. The direction could be the negative or the positive direction of the X-axis. When a robot reaches a factory that did not reach its limit, the factory repairs the robot, and it stops moving.\nAt any moment, you can set the initial direction of moving for some robot. Your target is to minimize the total distance traveled by all the robots.\nReturn the minimum total distance traveled by all the robots. The test cases are generated such that all the robots can be repaired.\nNote that\n\nAll robots move at the same speed.\nIf two robots move in the same direction, they will never collide.\nIf two robots move in opposite directions and they meet at some point, they do not collide. They cross each other.\nIf a robot passes by a factory that reached its limits, it crosses it as if it does not exist.\nIf the robot moved from a position x to a position y, the distance it moved is |y - x|.\n\n \nExample 1:\n\n\nInput: robot = [0,4,6], factory = [[2,2],[6,2]]\nOutput: 4\nExplanation: As shown in the figure:\n- The first robot at position 0 moves in the positive direction. It will be repaired at the first factory.\n- The second robot at position 4 moves in the negative direction. It will be repaired at the first factory.\n- The third robot at position 6 will be repaired at the second factory. It does not need to move.\nThe limit of the first factory is 2, and it fixed 2 robots.\nThe limit of the second factory is 2, and it fixed 1 robot.\nThe total distance is |2 - 0| + |2 - 4| + |6 - 6| = 4. It can be shown that we cannot achieve a better total distance than 4.\n\nExample 2:\n\n\nInput: robot = [1,-1], factory = [[-2,1],[2,1]]\nOutput: 2\nExplanation: As shown in the figure:\n- The first robot at position 1 moves in the positive direction. It will be repaired at the second factory.\n- The second robot at position -1 moves in the negative direction. It will be repaired at the first factory.\nThe limit of the first factory is 1, and it fixed 1 robot.\nThe limit of the second factory is 1, and it fixed 1 robot.\nThe total distance is |2 - 1| + |(-2) - (-1)| = 2. It can be shown that we cannot achieve a better total distance than 2.\n\n \nConstraints:\n\n1 <= robot.length, factory.length <= 100\nfactory[j].length == 2\n-109 <= robot[i], positionj <= 109\n0 <= limitj <= robot.length\nThe input will be generated such that it is always possible to repair every robot.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(robot = [5, 1, 3],factory = [[2, 3]]) == 5\n assert candidate(robot = [5, 5, 5, 5],factory = [[5, 4]]) == 0\n assert candidate(robot = [-3, 0, 3],factory = [[-2, 1], [2, 1], [5, 2]]) == 5\n assert candidate(robot = [-1, -3, 2, 4, 5],factory = [[-2, 1], [2, 2], [6, 2]]) == 7\n assert candidate(robot = [-5, -2, 0, 2, 5],factory = [[-3, 2], [1, 3]]) == 9\n assert candidate(robot = [5, 8, 15],factory = [[10, 2], [16, 1]]) == 8\n assert candidate(robot = [10, 20, 30, 40],factory = [[5, 2], [15, 2], [25, 2]]) == 30\n assert candidate(robot = [-10, 0, 10],factory = [[-5, 1], [0, 2], [5, 1]]) == 10\n assert candidate(robot = [5, 2, -5],factory = [[-2, 2], [2, 2]]) == 6\n assert candidate(robot = [10, -10, 0],factory = [[0, 3]]) == 20\n assert candidate(robot = [0, 4, 6],factory = [[2, 2], [6, 2]]) == 4\n assert candidate(robot = [3, 7, 12, 15],factory = [[2, 3], [10, 2]]) == 13\n assert candidate(robot = [-3, 0, 3],factory = [[-2, 1], [2, 2]]) == 4\n assert candidate(robot = [1, -1],factory = [[-2, 1], [2, 1]]) == 2\n assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-15, 2], [0, 1], [15, 2]]) == 20\n assert candidate(robot = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],factory = [[-5, 2], [-15, 2], [-25, 2], [-35, 2], [-45, 2], [-55, 2], [-65, 2], [-75, 2], [-85, 2], [-95, 2]]) == 50\n assert candidate(robot = [-15, -10, -5, 0, 5, 10, 15],factory = [[-12, 2], [-7, 2], [-2, 2], [3, 2], [8, 2], [13, 2]]) == 15\n assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[5, 3], [10, 4], [15, 3]]) == 45\n assert candidate(robot = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],factory = [[2, 2], [5, 2], [8, 2]]) == inf\n assert candidate(robot = [-1, -2, -3, -4, -5],factory = [[-10, 3], [0, 2], [10, 1]]) == 21\n assert candidate(robot = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],factory = [[5, 3], [15, 3], [25, 3], [35, 3], [45, 3], [55, 3], [65, 3], [75, 3], [85, 3], [95, 3], [105, 3], [115, 3], [125, 3], [135, 3]]) == 75\n assert candidate(robot = [0, 2, 4, 6, 8, 10],factory = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1]]) == 6\n assert candidate(robot = [100, 200, 300, 400, 500],factory = [[50, 1], [150, 2], [250, 2], [350, 2], [450, 1], [550, 1]]) == 250\n assert candidate(robot = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],factory = [[0, 2], [6, 3], [12, 3], [18, 2]]) == 16\n assert candidate(robot = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],factory = [[0, 5], [5, 5]]) == 20\n assert candidate(robot = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],factory = [[-3, 3], [0, 4], [3, 3]]) == 12\n assert candidate(robot = [-10, -5, 0, 5, 10, 15, 20, 25, 30, 35],factory = [[-7, 2], [2, 3], [17, 2], [32, 2]]) == inf\n assert candidate(robot = [-5, 0, 5, 10, 15, 20, 25, 30, 35, 40],factory = [[-10, 2], [5, 3], [20, 3], [35, 2]]) == 50\n assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[0, 2], [4, 2], [8, 2], [12, 2]]) == inf\n assert candidate(robot = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],factory = [[5, 3], [15, 3], [25, 3]]) == inf\n assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[0, 3], [5, 4], [10, 3]]) == 13\n assert candidate(robot = [-100, -50, 0, 50, 100],factory = [[-75, 2], [-25, 1], [25, 1], [75, 2]]) == 125\n assert candidate(robot = [10, 20, 30, 40, 50, 60, 70, 80, 90],factory = [[0, 3], [10, 3], [20, 3], [30, 3], [40, 3], [50, 3], [60, 3], [70, 3], [80, 3], [90, 3]]) == 0\n assert candidate(robot = [-2, -1, 0, 1, 2, 3, 4],factory = [[-3, 2], [0, 3], [3, 2]]) == 7\n assert candidate(robot = [-2, -1, 0, 1, 2],factory = [[-3, 1], [-1, 1], [1, 1], [3, 1]]) == inf\n assert candidate(robot = [-10, -5, 0, 5, 10, 15, 20],factory = [[-20, 1], [-10, 2], [0, 3], [10, 2], [20, 1]]) == 15\n assert candidate(robot = [-100, -50, 0, 50, 100],factory = [[-75, 2], [0, 2], [75, 2]]) == 100\n assert candidate(robot = [-100, -50, 0, 50, 100, 150],factory = [[-75, 3], [25, 2], [125, 2]]) == 150\n assert candidate(robot = [-100, -50, 0, 50, 100, 150, 200],factory = [[-75, 2], [-25, 2], [25, 2], [75, 2], [125, 2], [175, 2]]) == 175\n assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],factory = [[0, 5], [5, 5], [10, 5], [15, 5]]) == 60\n assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-15, 1], [-5, 2], [5, 3], [15, 1]]) == 25\n assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9],factory = [[2, 3], [5, 3], [8, 3]]) == 6\n assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-15, 2], [0, 3], [15, 2]]) == 20\n assert candidate(robot = [100, 200, 300, 400, 500],factory = [[50, 2], [150, 1], [250, 2], [350, 1], [450, 1]]) == 250\n assert candidate(robot = [1, 3, 5, 7, 9, 11],factory = [[2, 2], [6, 2], [10, 2]]) == 6\n assert candidate(robot = [1, 3, 5, 7, 9],factory = [[2, 2], [4, 2], [6, 2], [8, 2], [10, 1]]) == 5\n assert candidate(robot = [10, 20, 30, 40, 50, 60],factory = [[15, 2], [35, 2], [55, 2]]) == 30\n assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],factory = [[2, 3], [6, 3], [10, 3], [14, 3]]) == inf\n assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-15, 2], [-5, 3], [5, 2], [15, 1]]) == 25\n assert candidate(robot = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],factory = [[0, 10]]) == 10\n assert candidate(robot = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10],factory = [[-105, 2], [-95, 2], [-85, 2], [-75, 2], [-65, 2], [-55, 2], [-45, 2], [-35, 2], [-25, 2], [-15, 2]]) == 50\n assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[0, 10]]) == 55\n assert candidate(robot = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],factory = [[10, 2], [20, 2], [30, 2], [40, 2]]) == inf\n assert candidate(robot = [10, 20, 30, 40],factory = [[15, 2], [25, 2], [35, 2]]) == 20\n assert candidate(robot = [-10, -5, 0, 5, 10, 15, 20],factory = [[-7, 2], [-2, 2], [3, 2], [8, 2]]) == 35\n assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-15, 2], [0, 3], [15, 1]]) == 25\n assert candidate(robot = [-20, -15, -10, -5, 0, 5, 10, 15, 20],factory = [[-15, 2], [-10, 2], [-5, 2], [0, 2], [5, 2], [10, 2], [15, 2]]) == 10\n assert candidate(robot = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],factory = [[-6, 3], [0, 5], [6, 3]]) == 18\n assert candidate(robot = [1, 3, 5, 7, 9],factory = [[2, 1], [4, 1], [6, 1], [8, 1]]) == inf\n assert candidate(robot = [-5, -3, -1, 1, 3, 5],factory = [[-10, 1], [-5, 2], [0, 3], [5, 2], [10, 1]]) == 6\n assert candidate(robot = [-5, -3, -1, 1, 3, 5, 7, 9],factory = [[-4, 1], [0, 3], [4, 2]]) == inf\n assert candidate(robot = [1, 3, 5, 7, 9],factory = [[0, 2], [4, 2], [8, 2]]) == 5\n assert candidate(robot = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],factory = [[3, 3], [9, 3], [15, 3], [21, 3]]) == 25\n assert candidate(robot = [10, 10, 10, 10],factory = [[10, 1], [10, 1], [10, 1], [10, 1]]) == 0\n assert candidate(robot = [1, 4, 7, 10, 13, 16, 19, 22, 25],factory = [[3, 3], [9, 3], [15, 3], [21, 3]]) == 16\n assert candidate(robot = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],factory = [[5, 2], [15, 2], [25, 2], [35, 2], [45, 2], [55, 2], [65, 2], [75, 2], [85, 2], [95, 2]]) == 50\n assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[0, 2], [5, 3], [10, 5]]) == 16\n assert candidate(robot = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],factory = [[150, 3], [500, 4], [850, 3]]) == 900\n assert candidate(robot = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],factory = [[-5, 5], [0, 5], [5, 5]]) == 25\n assert candidate(robot = [-5, 0, 5, 10, 15, 20],factory = [[-10, 1], [0, 3], [10, 2], [20, 1]]) == 15\n assert candidate(robot = [-50, -25, 0, 25, 50],factory = [[-75, 3], [0, 2], [75, 1]]) == 125\n assert candidate(robot = [-10, -5, 0, 5, 10],factory = [[-15, 2], [-10, 1], [0, 3], [10, 2], [15, 1]]) == 10\n assert candidate(robot = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],factory = [[0, 5], [5, 5], [10, 5], [15, 5]]) == 40\n assert candidate(robot = [-100, -200, -300, -400, -500],factory = [[-50, 2], [-150, 1], [-250, 2], [-350, 1], [-450, 1]]) == 250\n assert candidate(robot = [-100, -50, 0, 50, 100],factory = [[-75, 1], [-25, 1], [25, 1], [75, 1]]) == inf\n assert candidate(robot = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10],factory = [[-95, 2], [-85, 2], [-75, 2], [-65, 2], [-55, 2], [-45, 2], [-35, 2], [-25, 2], [-15, 2], [-5, 2]]) == 50\n assert candidate(robot = [-100, -50, 0, 50, 100],factory = [[-75, 2], [-25, 2], [25, 2], [75, 1]]) == 125\n assert candidate(robot = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],factory = [[-10, 6], [0, 5]]) == 60\n assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[0, 5], [10, 5]]) == 25\n assert candidate(robot = [-10, -5, 0, 5, 10, 15, 20, 25],factory = [[-15, 2], [0, 3], [15, 3], [25, 1]]) == 25\n assert candidate(robot = [100, 200, 300, 400, 500],factory = [[50, 1], [150, 2], [250, 2], [350, 1], [450, 1]]) == 250\n assert candidate(robot = [-10, -5, 0, 5, 10, 15],factory = [[-8, 2], [2, 3], [12, 2]]) == 15\n assert candidate(robot = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],factory = [[-5, 5], [5, 5]]) == 50\n assert candidate(robot = [0, 10, 20, 30, 40, 50, 60],factory = [[5, 3], [15, 3], [25, 3], [35, 3], [45, 3]]) == 45\n assert candidate(robot = [-1, 0, 1],factory = [[-2, 1], [2, 1], [0, 1]]) == 2\n assert candidate(robot = [-9, -6, -3, 0, 3, 6, 9],factory = [[-8, 2], [-2, 2], [2, 2], [8, 1]]) == 12\n assert candidate(robot = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],factory = [[0, 5], [10, 5], [20, 5]]) == 26\n assert candidate(robot = [0, 10, 20, 30, 40, 50, 60],factory = [[5, 1], [15, 2], [25, 2], [35, 1], [45, 2], [55, 1]]) == 35\n assert candidate(robot = [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[-4, 3], [2, 4], [7, 3], [11, 3]]) == 22\n assert candidate(robot = [-1, -2, -3, -4, -5],factory = [[-3, 3], [0, 2]]) == 6\n assert candidate(robot = [0, 2, 4, 6, 8, 10, 12],factory = [[1, 2], [5, 2], [9, 2], [13, 1]]) == 7\n assert candidate(robot = [100, 200, 300, 400, 500],factory = [[50, 1], [150, 1], [250, 1], [350, 1], [450, 1]]) == 250\n assert candidate(robot = [-5, -3, -1, 1, 3, 5],factory = [[-10, 1], [-6, 2], [-2, 2], [2, 2], [6, 1]]) == 6\n assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[5, 5], [15, 5]]) == 45\n assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-25, 2], [-15, 3], [-5, 2], [5, 3], [15, 2], [25, 1]]) == 25\n assert candidate(robot = [-50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50],factory = [[-60, 3], [-40, 4], [-20, 4], [0, 4], [20, 4], [40, 3]]) == 60\n assert candidate(robot = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],factory = [[0, 2], [4, 2], [8, 2], [12, 2], [16, 2]]) == 20\n assert candidate(robot = [1, 3, 5, 7, 9],factory = [[0, 3], [6, 2], [12, 1]]) == 9\n assert candidate(robot = [-100, -50, 0, 50, 100],factory = [[-150, 2], [-100, 2], [-50, 2], [0, 2], [50, 2], [100, 2], [150, 2]]) == 0\n assert candidate(robot = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],factory = [[0, 2], [5, 2], [10, 2], [15, 2], [20, 2]]) == 14\n"}, "metadata": {"canonical_parameter_names": ["robot", "factory"], "leetcode_dataset_entry_point": "Solution().minimumTotalDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumTotalDistance(List robot, int[][] factory) {", "container": "Solution", "callable": "minimumTotalDistance", "parameters": [{"name": "robot", "type": "List"}, {"name": "factory", "type": "int[][]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2465, "task_id": "number-of-distinct-averages", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums of even length.\nAs long as nums is not empty, you must repetitively:\n\nFind the minimum number in nums and remove it.\nFind the maximum number in nums and remove it.\nCalculate the average of the two removed numbers.\n\nThe average of two numbers a and b is (a + b) / 2.\n\nFor example, the average of 2 and 3 is (2 + 3) / 2 = 2.5.\n\nReturn the number of distinct averages calculated using the above process.\nNote that when there is a tie for a minimum or maximum number, any can be removed.\n \nExample 1:\n\nInput: nums = [4,1,4,0,3,5]\nOutput: 2\nExplanation:\n1. Remove 0 and 5, and the average is (0 + 5) / 2 = 2.5. Now, nums = [4,1,4,3].\n2. Remove 1 and 4. The average is (1 + 4) / 2 = 2.5, and nums = [4,3].\n3. Remove 3 and 4, and the average is (3 + 4) / 2 = 3.5.\nSince there are 2 distinct numbers among 2.5, 2.5, and 3.5, we return 2.\n\nExample 2:\n\nInput: nums = [1,100]\nOutput: 1\nExplanation:\nThere is only one average to be calculated after removing 1 and 100, so we return 1.\n\n \nConstraints:\n\n2 <= nums.length <= 100\nnums.length is even.\n0 <= nums[i] <= 100\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 = [50, 50, 50, 50]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 2, 3, 4]) == 1\n assert candidate(nums = [0, 100, 50, 50, 25, 75]) == 1\n assert candidate(nums = [1, 100]) == 1\n assert candidate(nums = [4, 1, 4, 0, 3, 5]) == 2\n assert candidate(nums = [5, 5, 5, 5]) == 1\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6]) == 1\n assert candidate(nums = [99, 1, 98, 2, 97, 3]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [6, 6, 6, 6, 6, 6]) == 1\n assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4]) == 1\n assert candidate(nums = [1, 3, 2, 4, 6, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 1\n assert candidate(nums = [100, 0, 50, 50, 25, 75, 20, 80]) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [0, 100, 50, 50]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 1\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 1\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 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, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50]) == 1\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93]) == 1\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6]) == 6\n assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == 1\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 1\n assert candidate(nums = [25, 75, 20, 80, 15, 85, 10, 90, 5, 95]) == 1\n assert candidate(nums = [33, 33, 33, 67, 67, 67]) == 1\n assert candidate(nums = [12, 34, 56, 78, 90, 24, 46, 68]) == 1\n assert candidate(nums = [0, 100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93]) == 1\n assert candidate(nums = [5, 8, 13, 21, 34, 55, 89, 144]) == 4\n assert candidate(nums = [1, 1, 1, 99, 99, 99, 2, 2, 2, 98, 98, 98]) == 1\n assert candidate(nums = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5, 105, 94, 84, 74, 64, 54, 44, 34]) == 2\n assert candidate(nums = [0, 1, 2, 99, 98, 97, 96, 95]) == 2\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 1\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5]) == 1\n assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96, 5, 95]) == 1\n assert candidate(nums = [1, 1, 1, 1, 100, 100, 100, 100]) == 1\n assert candidate(nums = [23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(nums = [88, 92, 77, 65, 99, 100, 42, 33, 21, 11, 55, 66, 78, 89, 90, 91]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == 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 = [1, 2, 3, 3, 2, 1, 4, 5, 5, 4, 6, 7, 7, 6, 8, 9, 9, 8]) == 1\n assert candidate(nums = [5, 25, 15, 35, 45, 55, 65, 75, 85, 95, 105, 115]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 1\n assert candidate(nums = [40, 20, 60, 80, 100, 0, 50, 30, 90, 70]) == 2\n assert candidate(nums = [100, 0, 100, 0, 100, 0, 100, 0]) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10]) == 2\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 15, 35, 55, 75]) == 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]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 1\n assert candidate(nums = [100, 0, 50, 50, 25, 75, 20, 80]) == 1\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 1\n assert candidate(nums = [23, 45, 12, 67, 89, 34, 56, 78, 90, 10]) == 2\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1\n assert candidate(nums = [99, 88, 77, 66, 55, 44, 33, 22, 11, 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1\n assert candidate(nums = [2, 3, 1, 4, 6, 5, 8, 7]) == 1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 1\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, 5, 5]) == 1\n assert candidate(nums = [8, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [100, 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]) == 1\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 1\n assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10, 90]) == 1\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 100, 90, 80, 70, 60, 55]) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92]) == 1\n assert candidate(nums = [50, 1, 50, 2, 50, 3, 50, 4]) == 4\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8]) == 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 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 1\n assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96]) == 1\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 1\n assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4]) == 1\n assert candidate(nums = [9, 2, 5, 7, 3, 8, 10, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 100, 100, 100, 100, 50, 50, 50, 50]) == 2\n assert candidate(nums = [49, 51, 24, 76, 38, 62, 19, 81, 9, 90]) == 2\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 1\n assert candidate(nums = [0, 100, 50, 51, 49, 52, 48, 53, 47, 54]) == 2\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 3\n assert candidate(nums = [25, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 27, 28, 28, 28, 28]) == 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\n assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10]) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30]) == 2\n assert candidate(nums = [50, 20, 30, 10, 40, 60, 80, 70]) == 1\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]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 1\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]) == 1\n assert candidate(nums = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0]) == 1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 1\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().distinctAverages", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int distinctAverages(int[] nums) {", "container": "Solution", "callable": "distinctAverages", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2466, "task_id": "count-ways-to-build-good-strings", "difficulty": "Medium", "problem_description": "Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at each step perform either of the following:\n\nAppend the character '0' zero times.\nAppend the character '1' one times.\n\nThis can be performed any number of times.\nA good string is a string constructed by the above process having a length between low and high (inclusive).\nReturn the number of different good strings that can be constructed satisfying these properties. Since the answer can be large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: low = 3, high = 3, zero = 1, one = 1\nOutput: 8\nExplanation: \nOne possible valid good string is \"011\". \nIt can be constructed as follows: \"\" -> \"0\" -> \"01\" -> \"011\". \nAll binary strings from \"000\" to \"111\" are good strings in this example.\n\nExample 2:\n\nInput: low = 2, high = 3, zero = 1, one = 2\nOutput: 5\nExplanation: The good strings are \"00\", \"11\", \"000\", \"110\", and \"011\".\n\n \nConstraints:\n\n1 <= low <= high <= 105\n1 <= zero, one <= low\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(low = 5,high = 7,zero = 1,one = 1) == 224\n assert candidate(low = 100,high = 200,zero = 10,one = 20) == 28513\n assert candidate(low = 1,high = 5,zero = 2,one = 3) == 5\n assert candidate(low = 5,high = 10,zero = 2,one = 4) == 16\n assert candidate(low = 10,high = 15,zero = 3,one = 2) == 93\n assert candidate(low = 5,high = 5,zero = 2,one = 3) == 2\n assert candidate(low = 5,high = 10,zero = 3,one = 4) == 8\n assert candidate(low = 1,high = 5,zero = 1,one = 1) == 62\n assert candidate(low = 5,high = 5,zero = 2,one = 2) == 0\n assert candidate(low = 4,high = 6,zero = 2,one = 2) == 12\n assert candidate(low = 4,high = 4,zero = 2,one = 2) == 4\n assert candidate(low = 2,high = 3,zero = 1,one = 2) == 5\n assert candidate(low = 3,high = 7,zero = 3,one = 3) == 6\n assert candidate(low = 50000,high = 50000,zero = 5000,one = 5000) == 1024\n assert candidate(low = 7,high = 9,zero = 3,one = 2) == 12\n assert candidate(low = 50,high = 100,zero = 5,one = 7) == 177635\n assert candidate(low = 4,high = 6,zero = 2,one = 3) == 5\n assert candidate(low = 6,high = 10,zero = 2,one = 3) == 21\n assert candidate(low = 20,high = 25,zero = 5,one = 6) == 17\n assert candidate(low = 10,high = 15,zero = 2,one = 2) == 224\n assert candidate(low = 10,high = 100,zero = 5,one = 7) == 178096\n assert candidate(low = 4,high = 8,zero = 2,one = 2) == 28\n assert candidate(low = 6,high = 10,zero = 3,one = 4) == 8\n assert candidate(low = 5,high = 10,zero = 2,one = 3) == 23\n assert candidate(low = 20,high = 30,zero = 3,one = 5) == 283\n assert candidate(low = 1,high = 5,zero = 1,one = 5) == 6\n assert candidate(low = 3,high = 9,zero = 2,one = 2) == 28\n assert candidate(low = 1,high = 10,zero = 1,one = 1) == 2046\n assert candidate(low = 1,high = 5,zero = 2,one = 2) == 6\n assert candidate(low = 10,high = 15,zero = 3,one = 4) == 23\n assert candidate(low = 10,high = 15,zero = 5,one = 6) == 5\n assert candidate(low = 10,high = 15,zero = 4,one = 5) == 9\n assert candidate(low = 5,high = 7,zero = 2,one = 3) == 7\n assert candidate(low = 10,high = 15,zero = 2,one = 3) == 93\n assert candidate(low = 10,high = 10,zero = 3,one = 4) == 3\n assert candidate(low = 10,high = 15,zero = 1,one = 1) == 64512\n assert candidate(low = 2,high = 5,zero = 1,one = 3) == 10\n assert candidate(low = 10,high = 10,zero = 5,one = 5) == 4\n assert candidate(low = 50,high = 100,zero = 10,one = 15) == 444\n assert candidate(low = 3,high = 3,zero = 1,one = 1) == 8\n assert candidate(low = 10,high = 15,zero = 5,one = 5) == 12\n assert candidate(low = 6,high = 8,zero = 4,one = 5) == 1\n assert candidate(low = 1,high = 4,zero = 1,one = 1) == 30\n assert candidate(low = 1,high = 100,zero = 1,one = 1) == 952742561\n assert candidate(low = 1,high = 100,zero = 25,one = 25) == 30\n"}, "metadata": {"canonical_parameter_names": ["low", "high", "zero", "one"], "leetcode_dataset_entry_point": "Solution().countGoodStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countGoodStrings(int low, int high, int zero, int one) {", "container": "Solution", "callable": "countGoodStrings", "parameters": [{"name": "low", "type": "int"}, {"name": "high", "type": "int"}, {"name": "zero", "type": "int"}, {"name": "one", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2467, "task_id": "most-profitable-path-in-a-tree", "difficulty": "Medium", "problem_description": "There is an undirected tree with n nodes labeled from 0 to n - 1, 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.\nAt every node i, there is a gate. You are also given an array of even integers amount, where amount[i] represents:\n\nthe price needed to open the gate at node i, if amount[i] is negative, or,\nthe cash reward obtained on opening the gate at node i, otherwise.\n\nThe game goes on as follows:\n\nInitially, Alice is at node 0 and Bob is at node bob.\nAt every second, Alice and Bob each move to an adjacent node. Alice moves towards some leaf node, while Bob moves towards node 0.\nFor every node along their path, Alice and Bob either spend money to open the gate at that node, or accept the reward. Note that:\n\t\nIf the gate is already open, no price will be required, nor will there be any cash reward.\nIf Alice and Bob reach the node simultaneously, they share the price/reward for opening the gate there. In other words, if the price to open the gate is c, then both Alice and Bob pay c / 2 each. Similarly, if the reward at the gate is c, both of them receive c / 2 each.\n\n\nIf Alice reaches a leaf node, she stops moving. Similarly, if Bob reaches node 0, he stops moving. Note that these events are independent of each other.\n\nReturn the maximum net income Alice can have if she travels towards the optimal leaf node.\n \nExample 1:\n\n\nInput: edges = [[0,1],[1,2],[1,3],[3,4]], bob = 3, amount = [-2,4,2,-4,6]\nOutput: 6\nExplanation: \nThe above diagram represents the given tree. The game goes as follows:\n- Alice is initially on node 0, Bob on node 3. They open the gates of their respective nodes.\n Alice's net income is now -2.\n- Both Alice and Bob move to node 1. \n  Since they reach here simultaneously, they open the gate together and share the reward.\n  Alice's net income becomes -2 + (4 / 2) = 0.\n- Alice moves on to node 3. Since Bob already opened its gate, Alice's income remains unchanged.\n  Bob moves on to node 0, and stops moving.\n- Alice moves on to node 4 and opens the gate there. Her net income becomes 0 + 6 = 6.\nNow, neither Alice nor Bob can make any further moves, and the game ends.\nIt is not possible for Alice to get a higher net income.\n\nExample 2:\n\n\nInput: edges = [[0,1]], bob = 1, amount = [-7280,2350]\nOutput: -7280\nExplanation: \nAlice follows the path 0->1 whereas Bob follows the path 1->0.\nThus, Alice opens the gate at node 0 only. Hence, her net income is -7280. \n\n \nConstraints:\n\n2 <= n <= 105\nedges.length == n - 1\nedges[i].length == 2\n0 <= ai, bi < n\nai != bi\nedges represents a valid tree.\n1 <= bob < n\namount.length == n\namount[i] is an even integer in the range [-104, 104].\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],bob = 3,amount = [10, 10, 10, 10, 10, 10, 10]) == 30\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],bob = 5,amount = [100, -50, -25, 200, -300, 150]) == 250\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],bob = 7,amount = [100, 200, -300, 400, -500, 600, -700, 800]) == 400\n assert candidate(edges = [[0, 1], [1, 2], [2, 3]],bob = 2,amount = [1, 2, 3, 4]) == 6\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],bob = 5,amount = [-10, -10, -10, -10, -10, -10]) == -30\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],bob = 4,amount = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 130\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [2, 4], [4, 5]],bob = 5,amount = [1, 2, 3, 4, 5, 6]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],bob = 4,amount = [-1, -2, -3, -4, -5, -6, -7]) == -2\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],bob = 8,amount = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5]) == -8\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [3, 4]],bob = 3,amount = [-2, 4, 2, -4, 6]) == 6\n assert candidate(edges = [[0, 1]],bob = 1,amount = [-7280, 2350]) == -7280\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],bob = 5,amount = [-5, 2, -3, 4, -1, 6, -7]) == 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]],bob = 11,amount = [-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]) == -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, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22]],bob = 16,amount = [-100, 200, -300, 400, -500, 600, -700, 800, -900, 1000, -1100, 1200, -1300, 1400, -1500, 1600, -1700, 1800, -1900, 2000, -2100, 2200, -2300]) == 2600\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]],bob = 9,amount = [1, 1, 1, 1, 1, 1, 1, 1, 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(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],bob = 7,amount = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11]) == -3\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],bob = 7,amount = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11]) == 6\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]],bob = 5,amount = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140]) == -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]],bob = 7,amount = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13]) == -3\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]],bob = 20,amount = [-500, 500, -400, 400, -300, 300, -200, 200, -100, 100, 0, -100, 100, -200, 200, -300, 300, -400, 400, -500, 500, -600, 600, -700, 700, -800, 800, -900, 900, -1000]) == 1000\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], [4, 13], [4, 14], [5, 15], [5, 16], [5, 17], [6, 18], [6, 19], [6, 20]],bob = 18,amount = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000, 1100]) == 1100\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]],bob = 18,amount = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22]) == -5\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]],bob = 29,amount = [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]) == 380\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]],bob = 21,amount = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21]) == 22\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]],bob = 20,amount = [1000, -2000, 3000, -4000, 5000, -6000, 7000, -8000, 9000, -10000, 11000, -12000, 13000, -14000, 15000, -16000, 17000, -18000, 19000, -20000]) == 500\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]],bob = 10,amount = [-100, -200, 300, 400, -500, 600, -700, 800, -900, 1000, -1100, 1200, -1300, -1400, -1500]) == 1050\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]],bob = 15,amount = [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]) == -1100\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], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],bob = 15,amount = [-1000, 500, -250, 100, -200, 150, -50, 20, -10, 20, -15, 5, -5, 2, -1, -3, 7, -8, 9, -12, 11, -14, 13, -16, 15, -18, 17]) == -450\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]],bob = 9,amount = [-10, -20, -30, 15, 25, -5, -15, 5, 20, -35, 40, -45, 50]) == 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]],bob = 26,amount = [-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]) == 360\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], [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]],bob = 13,amount = [1000, -500, 250, -100, 200, -150, 50, -50, 20, -10, 20, -15, 5, -5, 2, -1, -3, 7, -8, 9, -12, 11, -14, 13, -16, 15, -18, 17, -20, 21, -22, -23, -24]) == 1270\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]],bob = 11,amount = [-5, 3, -7, 2, 4, -10, 6, -8, -9, 12, -15, 14]) == 10\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]],bob = 18,amount = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000]) == -5000\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]],bob = 22,amount = [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]) == 53\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]],bob = 31,amount = [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]) == 200\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]],bob = 13,amount = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15]) == 14\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],bob = 7,amount = [100, -50, 25, -10, 20, -15, 5, -5, -2, -3, -7]) == 130\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]],bob = 12,amount = [1000, -500, 250, -100, 200, -150, 50, -50, 20, -10, 20, -15, 5, -5, 2, -1, -3, 7]) == 1302\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]],bob = 14,amount = [-50, 50, -40, 40, -30, 30, -20, 20, -10, 10, 0, -10, 10, -20, 20, -30]) == 20\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]],bob = 12,amount = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 47\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]],bob = 18,amount = [10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130, -140, -150, -160, -170, -180, -190, -200]) == 150\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]],bob = 22,amount = [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]) == 360\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]],bob = 12,amount = [100, -50, 30, -20, 25, -40, 15, 60, -60, 45, -35, 20, -80, 70, 90, -100]) == 190\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]],bob = 10,amount = [-10, 15, 20, -25, 30, -35, 40, -45, 50, -55, 60, -65, 70, -75, 80]) == 130\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]],bob = 24,amount = [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]) == 225\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]],bob = 11,amount = [10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130]) == 150\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]],bob = 15,amount = [-10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200, 210, -220]) == 310\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]],bob = 10,amount = [10, -2, -3, -4, -5, 6, 7, -8, -9, -10, 12, -11]) == 11\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]],bob = 11,amount = [-100, 50, -25, 10, -20, 15, -5, 2, -1, -3, 7, -8, 9, -12]) == -38\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]],bob = 12,amount = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130]) == -40\n"}, "metadata": {"canonical_parameter_names": ["edges", "bob", "amount"], "leetcode_dataset_entry_point": "Solution().mostProfitablePath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int mostProfitablePath(int[][] edges, int bob, int[] amount) {", "container": "Solution", "callable": "mostProfitablePath", "parameters": [{"name": "edges", "type": "int[][]"}, {"name": "bob", "type": "int"}, {"name": "amount", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2468, "task_id": "split-message-based-on-limit", "difficulty": "Hard", "problem_description": "You are given a string, message, and a positive integer, limit.\nYou must split message into one or more parts based on limit. Each resulting part should have the suffix \"\", where \"b\" is to be replaced with the total number of parts and \"a\" is to be replaced with the index of the part, starting from 1 and going up to b. Additionally, the length of each resulting part (including its suffix) should be equal to limit, except for the last part whose length can be at most limit.\nThe resulting parts should be formed such that when their suffixes are removed and they are all concatenated in order, they should be equal to message. Also, the result should contain as few parts as possible.\nReturn the parts message would be split into as an array of strings. If it is impossible to split message as required, return an empty array.\n \nExample 1:\n\nInput: message = \"this is really a very awesome message\", limit = 9\nOutput: [\"thi<1/14>\",\"s i<2/14>\",\"s r<3/14>\",\"eal<4/14>\",\"ly <5/14>\",\"a v<6/14>\",\"ery<7/14>\",\" aw<8/14>\",\"eso<9/14>\",\"me<10/14>\",\" m<11/14>\",\"es<12/14>\",\"sa<13/14>\",\"ge<14/14>\"]\nExplanation:\nThe first 9 parts take 3 characters each from the beginning of message.\nThe next 5 parts take 2 characters each to finish splitting message. \nIn this example, each part, including the last, has length 9. \nIt can be shown it is not possible to split message into less than 14 parts.\n\nExample 2:\n\nInput: message = \"short message\", limit = 15\nOutput: [\"short mess<1/2>\",\"age<2/2>\"]\nExplanation:\nUnder the given constraints, the string can be split into two parts: \n- The first part comprises of the first 10 characters, and has a length 15.\n- The next part comprises of the last 3 characters, and has a length 8.\n\n \nConstraints:\n\n1 <= message.length <= 104\nmessage consists only of lowercase English letters and ' '.\n1 <= limit <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(message = \"abcdefghij\",limit = 3) == []\n assert candidate(message = \"abc\",limit = 5) == []\n assert candidate(message = \"short message\",limit = 15) == ['short mess<1/2>', 'age<2/2>']\n assert candidate(message = \"hello world\",limit = 10) == ['hello<1/3>', ' worl<2/3>', 'd<3/3>']\n assert candidate(message = \"abcd efgh ijkl mnop qrst uvwx yz\",limit = 10) == ['abcd <1/7>', 'efgh <2/7>', 'ijkl <3/7>', 'mnop <4/7>', 'qrst <5/7>', 'uvwx <6/7>', 'yz<7/7>']\n assert candidate(message = \"a\",limit = 5) == []\n assert candidate(message = \"a quick brown fox jumps over the lazy dog\",limit = 10) == ['a qui<1/9>', 'ck br<2/9>', 'own f<3/9>', 'ox ju<4/9>', 'mps o<5/9>', 'ver t<6/9>', 'he la<7/9>', 'zy do<8/9>', 'g<9/9>']\n assert candidate(message = \"abcdefghij\",limit = 7) == ['ab<1/5>', 'cd<2/5>', 'ef<3/5>', 'gh<4/5>', 'ij<5/5>']\n assert candidate(message = \"python programming is fun\",limit = 20) == ['python programm<1/2>', 'ing is fun<2/2>']\n assert candidate(message = \"this is really a very awesome message\",limit = 9) == ['thi<1/14>', 's i<2/14>', 's r<3/14>', 'eal<4/14>', 'ly <5/14>', 'a v<6/14>', 'ery<7/14>', ' aw<8/14>', 'eso<9/14>', 'me<10/14>', ' m<11/14>', 'es<12/14>', 'sa<13/14>', 'ge<14/14>']\n assert candidate(message = \"ab\",limit = 5) == []\n assert candidate(message = \"a quick brown fox jumps over the lazy dog\",limit = 5) == []\n assert candidate(message = \"hello world\",limit = 20) == ['hello world<1/1>']\n assert candidate(message = \"abcdefghijabcdefghijabcdefghij\",limit = 12) == ['abcdefg<1/5>', 'hijabcd<2/5>', 'efghija<3/5>', 'bcdefgh<4/5>', 'ij<5/5>']\n assert candidate(message = \"abcdefg\",limit = 3) == []\n assert candidate(message = \"one two three four five six seven eight nine ten\",limit = 12) == ['one two<1/7>', ' three <2/7>', 'four fi<3/7>', 've six <4/7>', 'seven e<5/7>', 'ight ni<6/7>', 'ne ten<7/7>']\n assert candidate(message = \"abcdefghijabcdefghij\",limit = 10) == ['abcde<1/4>', 'fghij<2/4>', 'abcde<3/4>', 'fghij<4/4>']\n assert candidate(message = \"abcd\",limit = 5) == []\n assert candidate(message = \"anotherlongermessageforcomplextesting\",limit = 18) == ['anotherlonger<1/3>', 'messageforcom<2/3>', 'plextesting<3/3>']\n assert candidate(message = \"testing testing testing testing testing testing testing testing testing testing\",limit = 20) == ['testing testing<1/6>', ' testing testin<2/6>', 'g testing testi<3/6>', 'ng testing test<4/6>', 'ing testing tes<5/6>', 'ting<6/6>']\n assert candidate(message = \"abcd efgh ijkl mnop qrst uvwx yz\",limit = 8) == ['ab<1/23>', 'cd<2/23>', ' e<3/23>', 'fg<4/23>', 'h <5/23>', 'ij<6/23>', 'kl<7/23>', ' m<8/23>', 'no<9/23>', 'p<10/23>', ' <11/23>', 'q<12/23>', 'r<13/23>', 's<14/23>', 't<15/23>', ' <16/23>', 'u<17/23>', 'v<18/23>', 'w<19/23>', 'x<20/23>', ' <21/23>', 'y<22/23>', 'z<23/23>']\n assert candidate(message = \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\",limit = 25) == ['Lorem ipsum dolor s<1/13>', 'it amet, consectetu<2/13>', 'r adipiscing elit, <3/13>', 'sed do eiusmod temp<4/13>', 'or incididunt ut la<5/13>', 'bore et dolore magn<6/13>', 'a aliqua. Ut enim a<7/13>', 'd minim veniam, qui<8/13>', 's nostrud exercitat<9/13>', 'ion ullamco labori<10/13>', 's nisi ut aliquip <11/13>', 'ex ea commodo cons<12/13>', 'equat.<13/13>']\n assert candidate(message = \"123456789012345678901234567890123456789012345678901234567890\",limit = 25) == ['12345678901234567890<1/3>', '12345678901234567890<2/3>', '12345678901234567890<3/3>']\n assert candidate(message = \"one two three four five six seven eight nine ten\",limit = 5) == []\n assert candidate(message = \"shortmessage\",limit = 20) == ['shortmessage<1/1>']\n assert candidate(message = \"split this into as few parts as possible\",limit = 21) == ['split this into <1/3>', 'as few parts as <2/3>', 'possible<3/3>']\n assert candidate(message = \"boundarytest12345boundarytest12345boundarytest12345boundarytest12345boundarytest12345boundarytest12345\",limit = 10) == ['boun<1/31>', 'dary<2/31>', 'test<3/31>', '1234<4/31>', '5bou<5/31>', 'ndar<6/31>', 'ytes<7/31>', 't123<8/31>', '45bo<9/31>', 'und<10/31>', 'ary<11/31>', 'tes<12/31>', 't12<13/31>', '345<14/31>', 'bou<15/31>', 'nda<16/31>', 'ryt<17/31>', 'est<18/31>', '123<19/31>', '45b<20/31>', 'oun<21/31>', 'dar<22/31>', 'yte<23/31>', 'st1<24/31>', '234<25/31>', '5bo<26/31>', 'und<27/31>', 'ary<28/31>', 'tes<29/31>', 't12<30/31>', '345<31/31>']\n assert candidate(message = \"repeated repeated repeated repeated repeated repeated repeated repeated\",limit = 25) == ['repeated repeated re<1/4>', 'peated repeated repe<2/4>', 'ated repeated repeat<3/4>', 'ed repeated<4/4>']\n assert candidate(message = \"this is a very long message that needs to be split into multiple parts to fit the limit\",limit = 10) == ['this<1/26>', ' is <2/26>', 'a ve<3/26>', 'ry l<4/26>', 'ong <5/26>', 'mess<6/26>', 'age <7/26>', 'that<8/26>', ' nee<9/26>', 'ds <10/26>', 'to <11/26>', 'be <12/26>', 'spl<13/26>', 'it <14/26>', 'int<15/26>', 'o m<16/26>', 'ult<17/26>', 'ipl<18/26>', 'e p<19/26>', 'art<20/26>', 's t<21/26>', 'o f<22/26>', 'it <23/26>', 'the<24/26>', ' li<25/26>', 'mit<26/26>']\n assert candidate(message = \"this is a repeated message this is a repeated message this is a repeated message\",limit = 15) == ['this is a <1/8>', 'repeated m<2/8>', 'essage thi<3/8>', 's is a rep<4/8>', 'eated mess<5/8>', 'age this i<6/8>', 's a repeat<7/8>', 'ed message<8/8>']\n assert candidate(message = \"spaces between words\",limit = 20) == ['spaces <1/3>', ' between <2/3>', ' words<3/3>']\n assert candidate(message = \"boundary boundary boundary boundary boundary boundary boundary boundary boundary boundary boundary boundary\",limit = 30) == ['boundary boundary boundar<1/5>', 'y boundary boundary bound<2/5>', 'ary boundary boundary bou<3/5>', 'ndary boundary boundary b<4/5>', 'oundary<5/5>']\n assert candidate(message = \"singleword\",limit = 12) == ['singlew<1/2>', 'ord<2/2>']\n assert candidate(message = \"a quick brown fox jumps over the lazy dog a quick brown fox jumps over the lazy dog\",limit = 15) == ['a quick br<1/9>', 'own fox ju<2/9>', 'mps over t<3/9>', 'he lazy do<4/9>', 'g a quick <5/9>', 'brown fox <6/9>', 'jumps over<7/9>', ' the lazy <8/9>', 'dog<9/9>']\n assert candidate(message = \"one two three four five six seven eight nine ten eleven twelve thirteen\",limit = 11) == ['one t<1/16>', 'wo th<2/16>', 'ree f<3/16>', 'our f<4/16>', 'ive s<5/16>', 'ix se<6/16>', 'ven e<7/16>', 'ight <8/16>', 'nine <9/16>', 'ten <10/16>', 'elev<11/16>', 'en t<12/16>', 'welv<13/16>', 'e th<14/16>', 'irte<15/16>', 'en<16/16>']\n assert candidate(message = \"a\",limit = 1) == []\n assert candidate(message = \"singlewordwithoutspaces\",limit = 25) == ['singlewordwithoutspa<1/2>', 'ces<2/2>']\n assert candidate(message = \"abcdefghijklmnopqrstuvwxyz\",limit = 5) == []\n assert candidate(message = \"Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects.\",limit = 30) == ['Python is a high-level, <1/13>', 'interpreted, general-pur<2/13>', 'pose programming languag<3/13>', 'e. Its design philosophy<4/13>', ' emphasizes code readabi<5/13>', 'lity with the use of sig<6/13>', 'nificant indentation. It<7/13>', 's language constructs an<8/13>', 'd object-oriented approa<9/13>', 'ch aim to help programm<10/13>', 'ers write clear, logica<11/13>', 'l code for small and la<12/13>', 'rge-scale projects.<13/13>']\n assert candidate(message = \"one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty\",limit = 22) == ['one two three fou<1/8>', 'r five six seven <2/8>', 'eight nine ten el<3/8>', 'even twelve thirt<4/8>', 'een fourteen fift<5/8>', 'een sixteen seven<6/8>', 'teen eighteen nin<7/8>', 'eteen twenty<8/8>']\n assert candidate(message = \"1234567890 1234567890 1234567890 1234567890 1234567890\",limit = 25) == ['1234567890 123456789<1/3>', '0 1234567890 1234567<2/3>', '890 1234567890<3/3>']\n assert candidate(message = \"a very very very very very very very very very very very long message that needs to be split into multiple parts\",limit = 18) == ['a very very v<1/9>', 'ery very very<2/9>', ' very very ve<3/9>', 'ry very very <4/9>', 'very long mes<5/9>', 'sage that nee<6/9>', 'ds to be spli<7/9>', 't into multip<8/9>', 'le parts<9/9>']\n assert candidate(message = \"hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello\",limit = 5) == []\n assert candidate(message = \"veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongmessage\",limit = 25) == ['veryveryveryveryvery<1/6>', 'veryveryveryveryvery<2/6>', 'veryveryveryveryvery<3/6>', 'veryveryveryveryvery<4/6>', 'veryveryveryveryvery<5/6>', 'longmessage<6/6>']\n assert candidate(message = \"samecharssamecharssamecharssamecharssamecharssamechars\",limit = 10) == ['same<1/15>', 'char<2/15>', 'ssam<3/15>', 'echa<4/15>', 'rssa<5/15>', 'mech<6/15>', 'arss<7/15>', 'amec<8/15>', 'hars<9/15>', 'sam<10/15>', 'ech<11/15>', 'ars<12/15>', 'sam<13/15>', 'ech<14/15>', 'ars<15/15>']\n assert candidate(message = \"The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog\",limit = 30) == ['The quick brown fox jumps<1/4>', ' over the lazy dog The qu<2/4>', 'ick brown fox jumps over <3/4>', 'the lazy dog<4/4>']\n assert candidate(message = \"The quick brown fox jumps over the lazy dog multiple times in order to make the string longer and more complex.\",limit = 30) == ['The quick brown fox jumps<1/5>', ' over the lazy dog multip<2/5>', 'le times in order to make<3/5>', ' the string longer and mo<4/5>', 're complex.<5/5>']\n assert candidate(message = \"1234567890123456789012345678901234567890\",limit = 10) == ['12345<1/8>', '67890<2/8>', '12345<3/8>', '67890<4/8>', '12345<5/8>', '67890<6/8>', '12345<7/8>', '67890<8/8>']\n assert candidate(message = \"short\",limit = 5) == []\n assert candidate(message = \"manywordsbutnospacesmanywordsbutnospacesmanywordsbutnospacesmanywordsbutnospaces\",limit = 20) == ['manywordsbutnos<1/6>', 'pacesmanywordsb<2/6>', 'utnospacesmanyw<3/6>', 'ordsbutnospaces<4/6>', 'manywordsbutnos<5/6>', 'paces<6/6>']\n assert candidate(message = \"this message has a very specific requirement for splitting\",limit = 18) == ['this message <1/5>', 'has a very sp<2/5>', 'ecific requir<3/5>', 'ement for spl<4/5>', 'itting<5/5>']\n assert candidate(message = \"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\",limit = 20) == ['123456789012345<1/7>', '678901234567890<2/7>', '123456789012345<3/7>', '678901234567890<4/7>', '123456789012345<5/7>', '678901234567890<6/7>', '1234567890<7/7>']\n assert candidate(message = \"the quick brown fox jumps over the lazy dog the quick brown fox jumps over the lazy dog the quick brown fox jumps over the lazy dog\",limit = 25) == ['the quick brown fox <1/7>', 'jumps over the lazy <2/7>', 'dog the quick brown <3/7>', 'fox jumps over the l<4/7>', 'azy dog the quick br<5/7>', 'own fox jumps over t<6/7>', 'he lazy dog<7/7>']\n assert candidate(message = \"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\",limit = 4) == []\n assert candidate(message = \"short\",limit = 10) == ['short<1/1>']\n assert candidate(message = \"single\",limit = 6) == ['s<1/6>', 'i<2/6>', 'n<3/6>', 'g<4/6>', 'l<5/6>', 'e<6/6>']\n assert candidate(message = \"singlewordwithoutspaces\",limit = 10) == ['singl<1/5>', 'eword<2/5>', 'witho<3/5>', 'utspa<4/5>', 'ces<5/5>']\n assert candidate(message = \"a quick brown fox jumps over the lazy dog\",limit = 12) == ['a quick<1/6>', ' brown <2/6>', 'fox jum<3/6>', 'ps over<4/6>', ' the la<5/6>', 'zy dog<6/6>']\n assert candidate(message = \"one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty\",limit = 20) == ['one two three f<1/9>', 'our five six se<2/9>', 'ven eight nine <3/9>', 'ten eleven twel<4/9>', 've thirteen fou<5/9>', 'rteen fifteen s<6/9>', 'ixteen seventee<7/9>', 'n eighteen nine<8/9>', 'teen twenty<9/9>']\n assert candidate(message = \"boundary boundary boundary boundary boundary boundary boundary boundary boundary\",limit = 20) == ['boundary bounda<1/6>', 'ry boundary bou<2/6>', 'ndary boundary <3/6>', 'boundary bounda<4/6>', 'ry boundary bou<5/6>', 'ndary<6/6>']\n assert candidate(message = \"boundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundary\",limit = 30) == ['boundaryboundaryboundaryb<1/5>', 'oundaryboundaryboundarybo<2/5>', 'undaryboundaryboundarybou<3/5>', 'ndaryboundaryboundaryboun<4/5>', 'daryboundaryboundary<5/5>']\n assert candidate(message = \"repeated repeated repeated repeated repeated repeated repeated repeated\",limit = 12) == ['repeat<1/13>', 'ed rep<2/13>', 'eated <3/13>', 'repeat<4/13>', 'ed rep<5/13>', 'eated <6/13>', 'repeat<7/13>', 'ed rep<8/13>', 'eated <9/13>', 'repea<10/13>', 'ted r<11/13>', 'epeat<12/13>', 'ed<13/13>']\n assert candidate(message = \"this is a very long message that needs to be split into several parts to meet the limit constraint\",limit = 15) == ['this is a<1/12>', ' very lon<2/12>', 'g message<3/12>', ' that nee<4/12>', 'ds to be <5/12>', 'split int<6/12>', 'o several<7/12>', ' parts to<8/12>', ' meet the<9/12>', ' limit c<10/12>', 'onstrain<11/12>', 't<12/12>']\n assert candidate(message = \"a quick brown fox jumps over the lazy dog\",limit = 11) == ['a quic<1/7>', 'k brow<2/7>', 'n fox <3/7>', 'jumps <4/7>', 'over t<5/7>', 'he laz<6/7>', 'y dog<7/7>']\n assert candidate(message = \"a quick brown fox jumps over the lazy dog\",limit = 15) == ['a quick br<1/5>', 'own fox ju<2/5>', 'mps over t<3/5>', 'he lazy do<4/5>', 'g<5/5>']\n assert candidate(message = \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\",limit = 25) == ['Lorem ipsum dolor si<1/7>', 't amet, consectetur <2/7>', 'adipiscing elit. Sed<3/7>', ' do eiusmod tempor i<4/7>', 'ncididunt ut labore <5/7>', 'et dolore magna aliq<6/7>', 'ua.<7/7>']\n assert candidate(message = \"shortmsg\",limit = 12) == ['shortms<1/2>', 'g<2/2>']\n assert candidate(message = \"this is another test case with a longer message that needs to be split into multiple parts to see how the function handles it\",limit = 18) == ['this is anot<1/11>', 'her test cas<2/11>', 'e with a lon<3/11>', 'ger message <4/11>', 'that needs t<5/11>', 'o be split i<6/11>', 'nto multiple<7/11>', ' parts to se<8/11>', 'e how the fu<9/11>', 'nction hand<10/11>', 'les it<11/11>']\n assert candidate(message = \"a\",limit = 3) == []\n assert candidate(message = \"spaces in the message should be handled correctly\",limit = 15) == ['spaces <1/7>', 'in the <2/7>', ' message<3/7>', ' should<4/7>', ' be <5/7>', 'handled <6/7>', ' correctly<7/7>']\n assert candidate(message = \"splitting this message into parts is challenging\",limit = 15) == ['splitting <1/5>', 'this messa<2/5>', 'ge into pa<3/5>', 'rts is cha<4/5>', 'llenging<5/5>']\n assert candidate(message = \"another example with a bit more text to ensure the splitting algorithm works correctly\",limit = 20) == ['another example<1/6>', ' with a bit mor<2/6>', 'e text to ensur<3/6>', 'e the splitting<4/6>', ' algorithm work<5/6>', 's correctly<6/6>']\n assert candidate(message = \"Lorem ipsum dolor sit amet, consectetur adipiscing elit\",limit = 25) == ['Lorem ipsum dolor si<1/3>', 't amet, consectetur <2/3>', 'adipiscing elit<3/3>']\n assert candidate(message = \"this is a very very very very very very very very very very very very very very very very very very very very very very very very very very very long message indeed\",limit = 20) == ['this is a very<1/12>', ' very very ver<2/12>', 'y very very ve<3/12>', 'ry very very v<4/12>', 'ery very very <5/12>', 'very very very<6/12>', ' very very ver<7/12>', 'y very very ve<8/12>', 'ry very very v<9/12>', 'ery very very<10/12>', ' very long me<11/12>', 'ssage indeed<12/12>']\n assert candidate(message = \"edgecase\",limit = 8) == ['edg<1/3>', 'eca<2/3>', 'se<3/3>']\n assert candidate(message = \"this is a test to see if the solution can handle edge cases\",limit = 23) == ['this is a test to <1/4>', 'see if the solutio<2/4>', 'n can handle edge <3/4>', 'cases<4/4>']\n assert candidate(message = \"a very long message that needs to be split into many parts to test the solution thoroughly\",limit = 12) == ['a very<1/17>', ' long <2/17>', 'messag<3/17>', 'e that<4/17>', ' needs<5/17>', ' to be<6/17>', ' split<7/17>', ' into <8/17>', 'many p<9/17>', 'arts <10/17>', 'to te<11/17>', 'st th<12/17>', 'e sol<13/17>', 'ution<14/17>', ' thor<15/17>', 'oughl<16/17>', 'y<17/17>']\n assert candidate(message = \"this is a very very long message that needs to be split into multiple parts to fit the limit\",limit = 15) == ['this is a<1/11>', ' very ver<2/11>', 'y long me<3/11>', 'ssage tha<4/11>', 't needs t<5/11>', 'o be spli<6/11>', 't into mu<7/11>', 'ltiple pa<8/11>', 'rts to fi<9/11>', 't the li<10/11>', 'mit<11/11>']\n assert candidate(message = \"short\",limit = 100) == ['short<1/1>']\n assert candidate(message = \"boundarycase123456789012345678901234567890\",limit = 21) == ['boundarycase1234<1/3>', '5678901234567890<2/3>', '1234567890<3/3>']\n assert candidate(message = \"this is an extremely long message that needs to be split into several parts to fit the given limit\",limit = 12) == ['this i<1/18>', 's an e<2/18>', 'xtreme<3/18>', 'ly lon<4/18>', 'g mess<5/18>', 'age th<6/18>', 'at nee<7/18>', 'ds to <8/18>', 'be spl<9/18>', 'it in<10/18>', 'to se<11/18>', 'veral<12/18>', ' part<13/18>', 's to <14/18>', 'fit t<15/18>', 'he gi<16/18>', 'ven l<17/18>', 'imit<18/18>']\n"}, "metadata": {"canonical_parameter_names": ["message", "limit"], "leetcode_dataset_entry_point": "Solution().splitMessage", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String[] splitMessage(String message, int limit) {", "container": "Solution", "callable": "splitMessage", "parameters": [{"name": "message", "type": "String"}, {"name": "limit", "type": "int"}], "return_type": "String[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2469, "task_id": "convert-the-temperature", "difficulty": "Easy", "problem_description": "You are given a non-negative floating point number rounded to two decimal places celsius, that denotes the temperature in Celsius.\nYou should convert Celsius into Kelvin and Fahrenheit and return it as an array ans = [kelvin, fahrenheit].\nReturn the array ans. Answers within 10-5 of the actual answer will be accepted.\nNote that:\n\nKelvin = Celsius + 273.15\nFahrenheit = Celsius * 1.80 + 32.00\n\n \nExample 1:\n\nInput: celsius = 36.50\nOutput: [309.65000,97.70000]\nExplanation: Temperature at 36.50 Celsius converted in Kelvin is 309.65 and converted in Fahrenheit is 97.70.\n\nExample 2:\n\nInput: celsius = 122.11\nOutput: [395.26000,251.79800]\nExplanation: Temperature at 122.11 Celsius converted in Kelvin is 395.26 and converted in Fahrenheit is 251.798.\n\n \nConstraints:\n\n0 <= celsius <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(celsius = 122.11) == [395.26, 251.798]\n assert candidate(celsius = 1000.0) == [1273.15, 1832.0]\n assert candidate(celsius = 0.0) == [273.15, 32.0]\n assert candidate(celsius = 500.0) == [773.15, 932.0]\n assert candidate(celsius = 100.0) == [373.15, 212.0]\n assert candidate(celsius = 500.75) == [773.9, 933.35]\n assert candidate(celsius = 36.5) == [309.65, 97.7]\n assert candidate(celsius = 25.0) == [298.15, 77.0]\n assert candidate(celsius = 273.15) == [546.3, 523.67]\n assert candidate(celsius = 42.876543) == [316.02654299999995, 109.1777774]\n assert candidate(celsius = 12.34) == [285.48999999999995, 54.212]\n assert candidate(celsius = 37.0) == [310.15, 98.60000000000001]\n assert candidate(celsius = 25.55555) == [298.70554999999996, 77.99999]\n assert candidate(celsius = 150.75) == [423.9, 303.35]\n assert candidate(celsius = -0.01) == [273.14, 31.982]\n assert candidate(celsius = 234.56) == [507.71, 454.208]\n assert candidate(celsius = 750.5) == [1023.65, 1382.9]\n assert candidate(celsius = 77.77777) == [350.92777, 171.999986]\n assert candidate(celsius = 456.78) == [729.93, 854.204]\n assert candidate(celsius = 750.25) == [1023.4, 1382.45]\n assert candidate(celsius = 999.0) == [1272.15, 1830.2]\n assert candidate(celsius = 499.99) == [773.14, 931.9820000000001]\n assert candidate(celsius = 60.0) == [333.15, 140.0]\n assert candidate(celsius = 23.45) == [296.59999999999997, 74.21000000000001]\n assert candidate(celsius = 450.0) == [723.15, 842.0]\n assert candidate(celsius = 150.67) == [423.81999999999994, 303.20599999999996]\n assert candidate(celsius = 1.0) == [274.15, 33.8]\n assert candidate(celsius = 500.01) == [773.16, 932.018]\n assert candidate(celsius = 800.25) == [1073.4, 1472.45]\n assert candidate(celsius = 550.89) == [824.04, 1023.602]\n assert candidate(celsius = 999.99) == [1273.1399999999999, 1831.982]\n assert candidate(celsius = 1.23456) == [274.38455999999996, 34.222208]\n assert candidate(celsius = 0.99) == [274.14, 33.782]\n assert candidate(celsius = 678.9) == [952.05, 1254.02]\n assert candidate(celsius = 300.12) == [573.27, 572.216]\n assert candidate(celsius = 0.01) == [273.15999999999997, 32.018]\n assert candidate(celsius = 777.77) == [1050.92, 1431.986]\n assert candidate(celsius = 89.67) == [362.82, 193.406]\n assert candidate(celsius = 150.0) == [423.15, 302.0]\n"}, "metadata": {"canonical_parameter_names": ["celsius"], "leetcode_dataset_entry_point": "Solution().convertTemperature", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public double[] convertTemperature(double celsius) {", "container": "Solution", "callable": "convertTemperature", "parameters": [{"name": "celsius", "type": "double"}], "return_type": "double[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2470, "task_id": "number-of-subarrays-with-lcm-equal-to-k", "difficulty": "Medium", "problem_description": "Given an integer array nums and an integer k, return the number of subarrays of nums where the least common multiple of the subarray's elements is k.\nA subarray is a contiguous non-empty sequence of elements within an array.\nThe least common multiple of an array is the smallest positive integer that is divisible by all the array elements.\n \nExample 1:\n\nInput: nums = [3,6,2,7,1], k = 6\nOutput: 4\nExplanation: The subarrays of nums where 6 is the least common multiple of all the subarray's elements are:\n- [3,6,2,7,1]\n- [3,6,2,7,1]\n- [3,6,2,7,1]\n- [3,6,2,7,1]\n\nExample 2:\n\nInput: nums = [3], k = 2\nOutput: 0\nExplanation: There are no subarrays of nums where 2 is the least common multiple of all the subarray's elements.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i], k <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7],k = 7) == 15\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 15\n assert candidate(nums = [7, 3, 9, 12, 15],k = 60) == 1\n assert candidate(nums = [3, 6, 2, 7, 1],k = 6) == 4\n assert candidate(nums = [100, 100, 100],k = 100) == 6\n assert candidate(nums = [7, 7, 7, 7],k = 7) == 10\n assert candidate(nums = [10, 5, 6, 20, 12],k = 60) == 7\n assert candidate(nums = [5, 10, 15, 20, 25],k = 60) == 3\n assert candidate(nums = [5, 10, 15],k = 30) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 0\n assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 15\n assert candidate(nums = [1, 2, 3, 4, 5],k = 60) == 3\n assert candidate(nums = [3],k = 2) == 0\n assert candidate(nums = [2, 4, 6, 8, 10],k = 20) == 0\n assert candidate(nums = [2, 4, 8, 16],k = 16) == 4\n assert candidate(nums = [6, 12, 18, 24],k = 72) == 3\n assert candidate(nums = [2, 3, 5, 7, 11],k = 2310) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 12) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 312) == 0\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512],k = 512) == 7\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384],k = 4096) == 3\n assert candidate(nums = [5, 10, 15, 20, 25],k = 150) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2520) == 12\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],k = 18) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 120) == 7\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13],k = 13) == 28\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230],k = 46) == 2\n assert candidate(nums = [11, 22, 33, 44, 55],k = 2310) == 0\n assert candidate(nums = [3, 9, 27, 81, 243],k = 243) == 5\n assert candidate(nums = [11, 22, 33, 44, 55],k = 132) == 3\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 78) == 3\n assert candidate(nums = [4, 8, 16, 32, 64, 128],k = 128) == 6\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40],k = 420) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],k = 200) == 2\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 540) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 420) == 0\n assert candidate(nums = [3, 9, 27, 81, 243],k = 81) == 4\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 55\n assert candidate(nums = [2, 3, 5, 7, 11, 13],k = 30030) == 1\n assert candidate(nums = [7, 14, 21, 28, 35],k = 42) == 2\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],k = 1680) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 60) == 7\n assert candidate(nums = [6, 12, 18, 24, 30],k = 360) == 3\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 110) == 1\n assert candidate(nums = [7, 14, 28, 42, 56],k = 168) == 4\n assert candidate(nums = [30, 60, 90, 120, 150],k = 150) == 1\n assert candidate(nums = [6, 12, 3, 18, 9],k = 36) == 4\n assert candidate(nums = [10, 15, 30, 60, 120, 240],k = 120) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 5) == 21\n assert candidate(nums = [4, 6, 12, 15, 30, 60],k = 60) == 12\n assert candidate(nums = [9, 18, 27, 36, 45],k = 1620) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19],k = 9699690) == 1\n assert candidate(nums = [4, 8, 12, 16, 20],k = 480) == 0\n assert candidate(nums = [1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031],k = 1046527167431103520) == 0\n assert candidate(nums = [5, 15, 25, 35, 45],k = 525) == 2\n assert candidate(nums = [100, 200, 300, 400, 500],k = 60000) == 0\n assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640],k = 640) == 8\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1024) == 0\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 42) == 2\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187],k = 43046721) == 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 = 232792560) == 22\n assert candidate(nums = [3, 5, 15, 45, 60, 90],k = 90) == 1\n assert candidate(nums = [9, 18, 27, 36, 45],k = 54) == 2\n assert candidate(nums = [7, 14, 28, 56, 112],k = 112) == 5\n assert candidate(nums = [7, 14, 21, 28, 35],k = 14) == 2\n assert candidate(nums = [2, 4, 6, 8, 12],k = 24) == 7\n assert candidate(nums = [50, 100, 150, 200, 250, 300],k = 1500) == 1\n assert candidate(nums = [5, 10, 15, 20, 25],k = 60) == 3\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290],k = 29) == 1\n assert candidate(nums = [4, 8, 12, 16, 20],k = 240) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 24) == 3\n assert candidate(nums = [21, 28, 35, 42, 49],k = 4620) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66],k = 27720) == 0\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190],k = 380) == 1\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],k = 1046527167431103520) == 0\n assert candidate(nums = [7, 14, 28, 49, 98],k = 196) == 6\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170],k = 34) == 2\n assert candidate(nums = [21, 28, 35, 42, 49, 56, 63, 70],k = 42) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 420) == 7\n assert candidate(nums = [7, 14, 28, 56, 112],k = 56) == 4\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 1\n assert candidate(nums = [9, 27, 81, 243, 729],k = 6561) == 0\n assert candidate(nums = [6, 9, 12, 15, 18],k = 180) == 5\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 90) == 1\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95],k = 1155) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 660) == 7\n assert candidate(nums = [7, 14, 21, 28, 35],k = 420) == 3\n assert candidate(nums = [25, 50, 75, 100, 125],k = 250) == 0\n assert candidate(nums = [25, 50, 75, 100, 125, 150],k = 15000) == 0\n assert candidate(nums = [6, 12, 18, 24, 30],k = 36) == 2\n assert candidate(nums = [4, 9, 16, 25, 36, 49, 64, 81, 100],k = 14400) == 0\n assert candidate(nums = [6, 12, 18, 24, 30],k = 360) == 3\n assert candidate(nums = [2, 4, 6, 8, 12],k = 12) == 3\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 1320) == 0\n assert candidate(nums = [4, 8, 12, 16, 20],k = 240) == 3\n assert candidate(nums = [2, 4, 6, 8, 12, 24],k = 24) == 13\n assert candidate(nums = [12, 15, 20, 25, 30],k = 300) == 5\n assert candidate(nums = [100, 150, 200, 250, 300],k = 300) == 2\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117],k = 312) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12],k = 12) == 3\n assert candidate(nums = [9, 18, 27, 36, 45],k = 54) == 2\n assert candidate(nums = [21, 35, 105, 210, 315, 420, 630],k = 630) == 5\n assert candidate(nums = [6, 8, 12, 24, 36],k = 24) == 7\n assert candidate(nums = [3, 9, 27, 81],k = 81) == 4\n assert candidate(nums = [13, 26, 39, 52, 65],k = 780) == 3\n assert candidate(nums = [3, 5, 15, 25, 75],k = 75) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 30) == 1\n assert candidate(nums = [17, 34, 51, 68, 85],k = 102) == 2\n assert candidate(nums = [8, 16, 24, 32, 40],k = 480) == 3\n assert candidate(nums = [8, 12, 16, 24, 32],k = 48) == 5\n assert candidate(nums = [5, 10, 15, 20, 25],k = 100) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 6469693230) == 1\n assert candidate(nums = [3, 9, 27, 81, 243, 729],k = 729) == 6\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600],k = 60) == 1\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 840) == 0\n assert candidate(nums = [8, 12, 24, 36, 48, 60, 72],k = 72) == 4\n assert candidate(nums = [12, 15, 20, 25, 30],k = 600) == 0\n assert candidate(nums = [4, 8, 12, 16, 20],k = 24) == 2\n assert candidate(nums = [9, 18, 27, 36, 45, 54],k = 54) == 3\n assert candidate(nums = [100, 200, 300, 400, 500],k = 100) == 1\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370],k = 370) == 1\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310],k = 62) == 2\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 105) == 0\n assert candidate(nums = [12, 15, 20, 25, 30],k = 60) == 3\n assert candidate(nums = [7, 14, 28, 56, 112],k = 112) == 5\n assert candidate(nums = [7, 14, 28, 35, 42],k = 42) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().subarrayLCM", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int subarrayLCM(int[] nums, int k) {", "container": "Solution", "callable": "subarrayLCM", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2471, "task_id": "minimum-number-of-operations-to-sort-a-binary-tree-by-level", "difficulty": "Medium", "problem_description": "You are given the root of a binary tree with unique values.\nIn one operation, you can choose any two nodes at the same level and swap their values.\nReturn the minimum number of operations needed to make the values at each level sorted in a strictly increasing order.\nThe level of a node is the number of edges along the path between it and the root node.\n \nExample 1:\n\n\nInput: root = [1,4,3,7,6,8,5,null,null,null,null,9,null,10]\nOutput: 3\nExplanation:\n- Swap 4 and 3. The 2nd level becomes [3,4].\n- Swap 7 and 5. The 3rd level becomes [5,6,8,7].\n- Swap 8 and 7. The 3rd level becomes [5,6,7,8].\nWe used 3 operations so return 3.\nIt can be proven that 3 is the minimum number of operations needed.\n\nExample 2:\n\n\nInput: root = [1,3,2,7,6,5,4]\nOutput: 3\nExplanation:\n- Swap 3 and 2. The 2nd level becomes [2,3].\n- Swap 7 and 4. The 3rd level becomes [4,6,5,7].\n- Swap 6 and 5. The 3rd level becomes [4,5,6,7].\nWe used 3 operations so return 3.\nIt can be proven that 3 is the minimum number of operations needed.\n\nExample 3:\n\n\nInput: root = [1,2,3,4,5,6]\nOutput: 0\nExplanation: Each level is already sorted in increasing order so return 0.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 105].\n1 <= Node.val <= 105\nAll the values of the tree are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([2, 3, 1])) == 1\n assert candidate(root = tree_node([1, 3, 2, 7, 6, 5, 4])) == 3\n assert candidate(root = tree_node([5, 6, 7, 8, 9, 10, 11])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6])) == 0\n assert candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 4\n assert candidate(root = tree_node([5, 3, 8, 1, 4, None, 7])) == 0\n assert candidate(root = tree_node([1, 4, 3, 7, 6, 8, 5, None, None, None, None, 9, None, 10])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 14])) == 1\n assert candidate(root = tree_node([1, 3, 2, 6, 5, 4, 7, 9, 8, 13, 12, 11, 10, 15, 14])) == 6\n assert candidate(root = tree_node([30, 15, 45, 7, 22, 37, 52, 3, 11, 18, 26, 32, 40, 46, 54, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28, 29, 31, 33, 34, 35, 36, 38, 39, 41, 42, 43, 44, 47, 48, 49, 50, 51, 53, 55, 56, 57, 58, 59, 60])) == 0\n assert candidate(root = tree_node([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])) == 19\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 18, 22, 28, 32, 38, 1, 4, 6, 8, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 49])) == 0\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 17, 22, 27, 32, 37, 1, 3, 4, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38])) == 0\n assert candidate(root = tree_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])) == 0\n assert candidate(root = tree_node([1, 3, 2, 4, 6, 5, 9, 8, 10, 13, 15, 14, 12, 16, 18, 17, 19, 21, 23, 22, 20, 24, 26, 25, 27, 29, 31, 30, 32, 34, 33, 35, 37, 36, 38, 40, 39, 41, 43, 42, 44, 46, 45, 47, 49, 48, 50])) == 14\n assert candidate(root = tree_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14])) == 7\n assert candidate(root = tree_node([99, 49, 149, 24, 74, 124, 174, 12, 36, 58, 66, 92, 112, 134, 158, 188, 204, 6, 18, 28, 42, 52, 54, 62, 80, 88, 100, 108, 120, 132, 142, 152, 168, 176, 192, 200, 208, 216, 224, 3, 9, 15, 21, 27, 33, 39, 45, 48, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147, 153, 159, 165, 171, 177, 183, 189, 195, 201, 207, 213, 219, 225])) == 38\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15])) == 0\n assert candidate(root = tree_node([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])) == 24\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9, None, None, None, None, None, 10, 11])) == 0\n assert candidate(root = tree_node([2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 1\n assert candidate(root = tree_node([1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8, None, None, None, None, None, None, None, None, 16, 17])) == 9\n assert candidate(root = tree_node([5, 4, 3, 2, 1, None, None, 0])) == 2\n assert candidate(root = tree_node([1, 5, 2, 9, 7, 6, 3, 12, 10, 11, 14, 8, 13, 4, 15])) == 8\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 35, 60, 90, 110, 140, 160, 190, 5, 15, 25, 40, 55, 70, 80, 95, 105, 130, 135, 155, 165, 180, 185, 195, 200])) == 0\n assert candidate(root = tree_node([5, 3, 8, 1, 4, 6, 10, None, 2, None, None, 7, 9, 11, 12, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 13, 14])) == 0\n assert candidate(root = tree_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])) == 0\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])) == 0\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 35, 65, 85, 115, 145, 165, 185, 5, 15, 20, 30, 40, 55, 60, 70, 80, 90, 105, 110, 130, 140, 150, 160, 170, 180, 190])) == 0\n assert candidate(root = tree_node([15, 10, 20, 5, 12, 17, 25, 3, 7, 11, 13, 16, 18, 22, 28, 2, 4, 6, 8, 9, 10.5, 11.5, 12.5, 14, 15, 16.5, 17.5, 19, 21, 23, 24, 26, 27, 29, 30])) == 0\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180, 5, 15, 20, 28, 40, 55, 65, 72, 78, 85, 95, 105, 115, 130, 135, 145, 155, 165, 175, 185, 190, 200])) == 0\n assert candidate(root = tree_node([30, 15, 45, 7, 22, 37, 52, 3, 11, 18, 27, 32, 42, 47, 57, 1, 5, 8, 10, 14, 17, 20, 25, 26, 31, 35, 40, 41, 46, 48, 53, 55, 56, 59, 60])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, None, 6, 7, None, None, 8, None, None, 9, 10])) == 0\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15, 0, 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])) == 0\n assert candidate(root = tree_node([15, 12, 18, 9, 13, 16, 20, 6, 10, 14, 15, 17, 19, 21, None, None, None, None, None, None, None, 22])) == 0\n assert candidate(root = tree_node([50, 20, 30, 10, 40, 25, 35, 5, 15, 32, 38, 22, 28, 33, 37, 1, 9, 11, 14, 18, 21, 24, 27, 29, 31, 34, 36, 39, 42, 45, 48, 2, 6, 7, 8, 12, 13, 16, 17, 19, 23, 26, 30, 41, 43, 44, 46, 47, 49, 51])) == 6\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 17, 22, 27, 32, 37, 1, 3, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38])) == 0\n assert candidate(root = tree_node([2, 3, 4, 6, 5, 7, 8, 9, 11, 10, 13, 12, 15, 14, 16])) == 4\n assert candidate(root = tree_node([1, 2, 3, None, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 0\n assert candidate(root = tree_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])) == 0\n assert candidate(root = tree_node([15, 10, 25, 5, 13, 20, 30, 3, 7, 11, 14, 17, 23, 28, 32, 1, 4, 6, 8, 12, 16, 18, 22, 26, 31, 33])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 0\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 130, 160, 180, 5, 15, 20, 35, 65, 70, 85, 105, 120, 135, 155, 170, 185, 190, 195, 200])) == 0\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 13, 17, 23, 27, 33, 37, None, 6, 8, 12, 14, 18, 22, 26, 28, 32, 34, 38, 40])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 0\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15, None, 16])) == 0\n assert candidate(root = tree_node([2, 3, 1, None, 4, 5, None, 7, 6, None, None, 9, 8, None, None, None, 10, 11, None, None, None, None, 12, 13, None, None, None, None, None, None, None, None, 14, 15])) == 3\n assert candidate(root = tree_node([1, 3, 2, 6, 5, 4, 7, 8, 9, 11, 10, 13, 12, 15, 14])) == 5\n assert candidate(root = tree_node([3, 1, 2, 6, 5, 4, 7, 10, 9, 12, 11, 14, 13, 16, 15])) == 5\n assert candidate(root = tree_node([25, 20, 30, 15, 22, 28, 32, 10, 17, 21, 23, 27, 31, 35, 40])) == 0\n assert candidate(root = tree_node([1, 3, 2, 7, 6, 5, 4, 15, 14, 13, 12, 11, 10, 9, 8, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16])) == 15\n assert candidate(root = tree_node([1, 3, 2, 5, 4, 7, 6, None, None, 8, 9, None, None, 10, 11])) == 3\n assert candidate(root = tree_node([20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 9\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 15, 14, 13, 12, 11, 10, 9, 8])) == 4\n assert candidate(root = tree_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])) == 0\n assert candidate(root = tree_node([30, 20, 50, 10, 25, 40, 60, 5, 15, 22, 28, 35, 45, 55, 65, 1, 8, 12, 18, 21, 26, 30, 34, 38, 42, 48, 52, 58, 62, 67, 70])) == 0\n assert candidate(root = tree_node([6, 3, 10, 1, 5, 8, 12, 2, 4, 7, 9, 11, 13, None, None, None, None, None, None, None, 14])) == 0\n assert candidate(root = tree_node([15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 7\n assert candidate(root = tree_node([1, 3, 2, 6, 5, 4, None, None, None, None, None, 7, 8, 9, 10])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, 16, 17])) == 0\n assert candidate(root = tree_node([5, 9, 3, 11, 6, 7, 8, None, 12, 10, None, None, 13, None, None, 14])) == 5\n assert candidate(root = tree_node([1, 3, 2, 6, 5, 4, 7, 9, 8, 11, 10, 13, 12, 15, 14])) == 6\n assert candidate(root = tree_node([1, 3, 2, 6, 5, 4, 7, 9, 8, 13, 12, 11, 10, 15, 14, 16, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29, 32, 31, 34, 33, 36, 35, 38, 37, 40, 39])) == 17\n assert candidate(root = tree_node([15, 10, 20, 5, 12, 16, 25, 3, 8, 11, 14, 17, 23, 26, 30])) == 0\n assert candidate(root = tree_node([64, 32, 96, 16, 48, 68, 112, 8, 24, 36, 44, 56, 60, 72, 80, 92, 104, 116, 128, 4, 12, 20, 28, 32, 38, 42, 50, 54, 62, 66, 74, 78, 84, 88, 96, 100, 108, 112, 120, 124, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236, 240, 244, 248, 252, 256])) == 12\n assert candidate(root = tree_node([32, 16, 48, 8, 24, 36, 56, 4, 12, 20, 28, 32, 40, 44, 52, 58, 62, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 59, 61, 63, 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, 60, 62, 63])) == 45\n assert candidate(root = tree_node([25, 15, 35, 10, 20, 30, 40, 5, 12, 18, 22, 28, 32, 38, 42, None, 6, 8, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 49])) == 0\n assert candidate(root = tree_node([1, 3, 2, 7, 6, 5, 4, 15, 14, 13, 12, 11, 10, 9, 8, 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])) == 7\n assert candidate(root = tree_node([42, 21, 63, 10, 31, 53, 74, 5, 15, 25, 35, 45, 50, 60, 70, 1, 7, 12, 18, 23, 28, 33, 38, 43, 48, 55, 58, 65, 68, 72, 73, 76, 77, 78, 79])) == 0\n assert candidate(root = tree_node([31, 24, 27, 18, 22, 25, 29, 16, 19, 21, 23, 26, 28, 30, 32])) == 0\n assert candidate(root = tree_node([25, 15, 35, 10, 20, 30, 40, 5, 12, 18, 22, 28, 38, 45, 50, 1, 6, 8, 11, 14, 17, 19, 21, 23, 26, 29, 31, 34, 37, 39, 42, 44, 47, 49, 52])) == 0\n assert candidate(root = tree_node([7, 4, 10, 2, 5, 8, 12, None, 3, 6, 9, 11, 13, None, None, None, None, None, None, None, 15])) == 0\n assert candidate(root = tree_node([32, 16, 48, 8, 24, 36, 56, 4, 12, 20, 28, 32, 40, 44, 52, 60, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62])) == 15\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 0\n assert candidate(root = tree_node([15, 11, 20, 9, 13, 18, 22, 7, 10, 12, 14, 16, 19, 21, 23, 5, 8, None, 1, None, None, None, None, None, None, None, None, 6, 4, None, None, None, None, None, None, None, None, None, None, None])) == 2\n assert candidate(root = tree_node([1, 3, 2, None, 6, 5, 4, None, None, None, None, 8, 7, None, 10, 9])) == 4\n assert candidate(root = tree_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])) == 0\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7, 11, 13, None, None, None, 8])) == 1\n assert candidate(root = tree_node([7, 3, 11, 1, 5, 9, 13, None, 2, 4, 6, 8, 10, 12, 14, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == 0\n assert candidate(root = tree_node([100, 90, 110, 80, 95, 105, 120, 70, 85, 93, 97, 103, 115, 117, 130, 60, 75, 83, 88, 92, 96, 101, 104, 108, 112, 116, 125, 127, 132])) == 0\n assert candidate(root = tree_node([2, 3, 1, 5, 4, 8, 7, 11, 10, 9, 12, 15, 14, 13, 16])) == 5\n assert candidate(root = tree_node([5, 2, 7, 1, 4, 6, 8, 3, None, None, None, None, None, None, 9])) == 0\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 62, 88, 6, 18, 30, 40, 55, 60, 70, 92, 3, 9, 15, 21, 27, 35, 38, 45, 50, 58, 65, 68, 74, 80, 90, 95])) == 0\n assert candidate(root = tree_node([25, 15, 35, 10, 20, 30, 40, 5, 12, 18, 22, 28, 32, 38, 42, None, 7, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, None, 1, 6, None, 8, 9, 14, 16, None, None, None, 24, 26, None, 36, 38, None, 44, 46, None, None, None, None, 45, 47, None, None, 48, 49, None, 50, 51, None, 52, 53, None, 54, 55, None, 56, 57, None, 58, 59, None, 60])) == 1\n assert candidate(root = tree_node([20, 15, 25, 10, 17, 22, 30, 5, 12, 16, 18, 21, 24, 28, 32, 1, 6, 9, 11, 13, 14, 19, 23, 27, 29, 31, 33])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 0\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7, 16, 8, 25, 18])) == 3\n assert candidate(root = tree_node([10, 20, 5, None, 15, 17, 7, None, None, None, None, 16, None, 6])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, 8, 9, 10, 11, 12, 13])) == 0\n assert candidate(root = tree_node([1, 3, 2, 7, 6, 5, 4, 15, 14, 13, 12, 11, 10, 9, 8, 23, 22, 21, 20, 19, 18, 17, 16])) == 11\n assert candidate(root = tree_node([2, 1, 5, 10, 3, 7, 6, 15, 12, 8, 9, 11, None, 14, 13, 20, None, 18, 16, 17, 19, 22, 21])) == 11\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15, 0, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 0\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 37, 1, 4, 6, 8, 11, 13, 14, 16, 18, 19, 21, 23, 24, 26, 28, 29, 31, 33, 34, 36, 38])) == 0\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180, 5, 15, 20, 35, 40, 55, 65, 70, 85, 90, 105, 115, 135, 145, 155, 175, 185])) == 0\n assert candidate(root = tree_node([5, 15, 3, 10, 1, 20, 8, None, 9, 4, None, None, None, None, 14, None, None, 7, 11, 6, None, None, 13, 12, None, None, None, None, 16, 18, None, None, 17, 19])) == 8\n assert candidate(root = tree_node([1, 3, 2, 4, 6, 5, 7, 9, 8, 11, 10, 13, 12, 15, 14])) == 6\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2472, "task_id": "maximum-number-of-non-overlapping-palindrome-substrings", "difficulty": "Hard", "problem_description": "You are given a string s and a positive integer k.\nSelect a set of non-overlapping substrings from the string s that satisfy the following conditions:\n\nThe length of each substring is at least k.\nEach substring is a palindrome.\n\nReturn the maximum number of substrings in an optimal selection.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"abaccdbbd\", k = 3\nOutput: 2\nExplanation: We can select the substrings underlined in s = \"abaccdbbd\". Both \"aba\" and \"dbbd\" are palindromes and have a length of at least k = 3.\nIt can be shown that we cannot find a selection with more than two valid substrings.\n\nExample 2:\n\nInput: s = \"adbcda\", k = 2\nOutput: 0\nExplanation: There is no palindrome substring of length at least 2 in the string.\n\n \nConstraints:\n\n1 <= k <= s.length <= 2000\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"racecar\",k = 2) == 1\n assert candidate(s = \"mnoonm\",k = 2) == 1\n assert candidate(s = \"zzzzzz\",k = 1) == 6\n assert candidate(s = \"abcde\",k = 3) == 0\n assert candidate(s = \"abcdeedcba\",k = 2) == 1\n assert candidate(s = \"zz\",k = 1) == 2\n assert candidate(s = \"adbcda\",k = 2) == 0\n assert candidate(s = \"\",k = 1) == 0\n assert candidate(s = \"abcde\",k = 1) == 5\n assert candidate(s = \"aaaaa\",k = 2) == 2\n assert candidate(s = \"racecar\",k = 3) == 1\n assert candidate(s = \"abbaeaeabba\",k = 3) == 3\n assert candidate(s = \"abbaabba\",k = 3) == 2\n assert candidate(s = \"noonhighnoon\",k = 4) == 2\n assert candidate(s = \"abacdfgdcaba\",k = 3) == 2\n assert candidate(s = \"aaaa\",k = 2) == 2\n assert candidate(s = \"a\",k = 1) == 1\n assert candidate(s = \"abcdedcba\",k = 5) == 1\n assert candidate(s = \"racecarannakayak\",k = 3) == 3\n assert candidate(s = \"abcba\",k = 5) == 1\n assert candidate(s = \"abaccdbbd\",k = 3) == 2\n assert candidate(s = \"abbaeae\",k = 2) == 2\n assert candidate(s = \"z\",k = 1) == 1\n assert candidate(s = \"aaabaaaabaaaa\",k = 5) == 2\n assert candidate(s = \"levellevellevel\",k = 5) == 3\n assert candidate(s = \"abcabcabcabc\",k = 3) == 0\n assert candidate(s = \"ababababa\",k = 3) == 3\n assert candidate(s = \"abcbaabccba\",k = 3) == 2\n assert candidate(s = \"level\",k = 5) == 1\n assert candidate(s = \"xyxxyxyxyx\",k = 1) == 10\n assert candidate(s = \"aabbaaabbbaaaa\",k = 2) == 6\n assert candidate(s = \"ababababababab\",k = 2) == 4\n assert candidate(s = \"rotorreferredder\",k = 4) == 3\n assert candidate(s = \"popopopopopop\",k = 3) == 4\n assert candidate(s = \"abaaaaba\",k = 4) == 1\n assert candidate(s = \"xyxzyzyzyxzyx\",k = 3) == 3\n assert candidate(s = \"madamimadam\",k = 2) == 3\n assert candidate(s = \"aaaaaaaaaaaaaaaaaa\",k = 10) == 1\n assert candidate(s = \"abbaabbaabba\",k = 4) == 3\n assert candidate(s = \"aabbccddeeff\",k = 2) == 6\n assert candidate(s = \"rotor\",k = 5) == 1\n assert candidate(s = \"abcddcbaabcddcba\",k = 6) == 2\n assert candidate(s = \"palindromemordnilap\",k = 6) == 1\n assert candidate(s = \"aabbccddeeefffggghhhiii\",k = 4) == 0\n assert candidate(s = \"xyxzyzyzxzyxzyx\",k = 3) == 3\n assert candidate(s = \"aaaaaaaabaaaa\",k = 5) == 2\n assert candidate(s = \"levelracecaraabba\",k = 4) == 3\n assert candidate(s = \"racecarannakayak\",k = 5) == 2\n assert candidate(s = \"abccbaabccba\",k = 3) == 2\n assert candidate(s = \"abcabcabcabcabcabcabc\",k = 3) == 0\n assert candidate(s = \"abcdedcbaedcbba\",k = 5) == 1\n assert candidate(s = \"noonnoonnoon\",k = 3) == 3\n assert candidate(s = \"abbaaccddccaaabbbcccdd\",k = 3) == 5\n assert candidate(s = \"abcbabcba\",k = 5) == 1\n assert candidate(s = \"aabbabbaaabbabba\",k = 4) == 3\n assert candidate(s = \"abbaaccddccbaabba\",k = 3) == 3\n assert candidate(s = \"abbaacccbaaabbcc\",k = 3) == 3\n assert candidate(s = \"civiccivic\",k = 4) == 2\n assert candidate(s = \"aaabaaaacaaaaaa\",k = 3) == 4\n assert candidate(s = \"abracadabra\",k = 3) == 1\n assert candidate(s = \"abcdcbaabcdcba\",k = 5) == 2\n assert candidate(s = \"xyzyzyzyzyzyzyzy\",k = 2) == 5\n assert candidate(s = \"madamracecarlevel\",k = 5) == 3\n assert candidate(s = \"xyxzyzyzyzxzyzyx\",k = 3) == 5\n assert candidate(s = \"bananaabacaxxx\",k = 3) == 3\n assert candidate(s = \"noonnoonnoon\",k = 4) == 3\n assert candidate(s = \"abcdefghij\",k = 3) == 0\n assert candidate(s = \"zzzzyyyyxxxx\",k = 4) == 3\n assert candidate(s = \"aaaabbbbccccdddd\",k = 4) == 4\n assert candidate(s = \"civicracecardeified\",k = 3) == 3\n assert candidate(s = \"aabbccddeeffgg\",k = 2) == 7\n assert candidate(s = \"madamimadam\",k = 5) == 2\n assert candidate(s = \"aaaabaaaabaaaaabaaabaaa\",k = 2) == 9\n assert candidate(s = \"racecar\",k = 6) == 1\n assert candidate(s = \"xyxxyxyxyxyx\",k = 2) == 4\n assert candidate(s = \"abcbabcba\",k = 3) == 2\n assert candidate(s = \"abcabcabcabc\",k = 1) == 12\n assert candidate(s = \"abcdefgfedcba\",k = 7) == 1\n assert candidate(s = \"mamadadadadammadam\",k = 3) == 5\n assert candidate(s = \"madamimadam\",k = 3) == 3\n assert candidate(s = \"babaddabba\",k = 3) == 2\n assert candidate(s = \"aabbabaaaabbabaab\",k = 3) == 4\n assert candidate(s = \"babbbabbbab\",k = 3) == 3\n assert candidate(s = \"aabaaaabbbaaa\",k = 3) == 4\n assert candidate(s = \"aabbaabbaaabbbaabbaab\",k = 3) == 4\n assert candidate(s = \"abccbaabc\",k = 4) == 1\n assert candidate(s = \"abracadabra\",k = 5) == 0\n assert candidate(s = \"abbaabbaabba\",k = 2) == 5\n assert candidate(s = \"aaaaaabbbbbbaaaaaabbbbb\",k = 5) == 4\n assert candidate(s = \"abcbaabababaabcba\",k = 3) == 4\n assert candidate(s = \"abcabcabc\",k = 2) == 0\n assert candidate(s = \"abccbaabcabcabcabcba\",k = 5) == 2\n assert candidate(s = \"abccbaabcba\",k = 5) == 2\n assert candidate(s = \"mississippi\",k = 3) == 2\n assert candidate(s = \"abbaabbabbaabb\",k = 2) == 6\n assert candidate(s = \"abcdefedcba\",k = 5) == 1\n assert candidate(s = \"abcdefghihgfedcba\",k = 7) == 1\n assert candidate(s = \"noonmoonnoonmoon\",k = 4) == 2\n assert candidate(s = \"abcdefedcbafedcbabcdef\",k = 5) == 2\n assert candidate(s = \"abbaabba\",k = 2) == 3\n assert candidate(s = \"deeeeinedede\",k = 4) == 2\n assert candidate(s = \"abcdedcba\",k = 4) == 1\n assert candidate(s = \"aabbccddeeeffgg\",k = 2) == 7\n assert candidate(s = \"abcdedcbaabacdfgdcaba\",k = 5) == 1\n assert candidate(s = \"zzzzyyyxxxwwvvuuttssrrqqppoonnmmlkkjjiihhggffeeddccbbaaa\",k = 4) == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 2) == 26\n assert candidate(s = \"aaaaabbbaaaaa\",k = 4) == 3\n assert candidate(s = \"abacabadabacaba\",k = 4) == 2\n assert candidate(s = \"madamimadam\",k = 4) == 2\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().maxPalindromes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxPalindromes(String s, int k) {", "container": "Solution", "callable": "maxPalindromes", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2475, "task_id": "number-of-unequal-triplets-in-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array of positive integers nums. Find the number of triplets (i, j, k) that meet the following conditions:\n\n0 <= i < j < k < nums.length\nnums[i], nums[j], and nums[k] are pairwise distinct.\n\t\nIn other words, nums[i] != nums[j], nums[i] != nums[k], and nums[j] != nums[k].\n\n\n\nReturn the number of triplets that meet the conditions.\n \nExample 1:\n\nInput: nums = [4,4,2,4,3]\nOutput: 3\nExplanation: The following triplets meet the conditions:\n- (0, 2, 4) because 4 != 2 != 3\n- (1, 2, 4) because 4 != 2 != 3\n- (2, 3, 4) because 2 != 4 != 3\nSince there are 3 triplets, we return 3.\nNote that (2, 0, 4) is not a valid triplet because 2 > 0.\n\nExample 2:\n\nInput: nums = [1,1,1,1,1]\nOutput: 0\nExplanation: No triplets meet the conditions so we return 0.\n\n \nConstraints:\n\n3 <= 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]) == 20\n assert candidate(nums = [1, 2, 2, 3, 4]) == 7\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7]) == 96\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 120\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 120\n assert candidate(nums = [4, 4, 2, 4, 3]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 120\n assert candidate(nums = [999, 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]) == 4495\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1140\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60]) == 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]) == 960\n assert candidate(nums = [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]) == 3584\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]) == 19600\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0]) == 960\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, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 15000\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 252\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 225\n assert candidate(nums = [5, 1, 4, 1, 2, 1, 5, 2, 5, 4, 5, 2, 1, 4, 2, 1, 5, 4, 2, 1, 5, 4, 2, 1, 4, 2, 1, 5, 4, 2]) == 1680\n assert candidate(nums = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300]) == 64\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 960\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 253\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 455\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9]) == 125\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]) == 1331\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 960\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3]) == 243\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 80\n assert candidate(nums = [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 = [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]) == 2912\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, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 2940\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1140\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 84\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 960\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 80\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 64\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 960\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, 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]) == 76048\n assert candidate(nums = [5, 5, 5, 1, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 118\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 455\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 88\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 640\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 6, 7, 8, 9, 10]) == 444\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]) == 161700\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 11, 12]) == 820\n assert candidate(nums = [2, 1, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 343\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 1140\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1140\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 80\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10]) == 2530\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]) == 0\n assert candidate(nums = [100, 200, 100, 200, 300, 400, 500, 300, 200, 100]) == 68\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\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]) == 4060\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]) == 4060\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 50\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 0\n assert candidate(nums = [50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57]) == 448\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1140\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]) == 2300\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500]) == 390\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7]) == 96\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 455\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 270\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1140\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 455\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]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().unequalTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int unequalTriplets(int[] nums) {", "container": "Solution", "callable": "unequalTriplets", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2476, "task_id": "closest-nodes-queries-in-a-binary-search-tree", "difficulty": "Medium", "problem_description": "You are given the root of a binary search tree and an array queries of size n consisting of positive integers.\nFind a 2D array answer of size n where answer[i] = [mini, maxi]:\n\nmini is the largest value in the tree that is smaller than or equal to queries[i]. If a such value does not exist, add -1 instead.\nmaxi is the smallest value in the tree that is greater than or equal to queries[i]. If a such value does not exist, add -1 instead.\n\nReturn the array answer.\n \nExample 1:\n\n\nInput: root = [6,2,13,1,4,9,15,null,null,null,null,null,null,14], queries = [2,5,16]\nOutput: [[2,2],[4,6],[15,-1]]\nExplanation: We answer the queries in the following way:\n- The largest number that is smaller or equal than 2 in the tree is 2, and the smallest number that is greater or equal than 2 is still 2. So the answer for the first query is [2,2].\n- The largest number that is smaller or equal than 5 in the tree is 4, and the smallest number that is greater or equal than 5 is 6. So the answer for the second query is [4,6].\n- The largest number that is smaller or equal than 16 in the tree is 15, and the smallest number that is greater or equal than 16 does not exist. So the answer for the third query is [15,-1].\n\nExample 2:\n\n\nInput: root = [4,null,9], queries = [3]\nOutput: [[-1,4]]\nExplanation: The largest number that is smaller or equal to 3 in the tree does not exist, and the smallest number that is greater or equal to 3 is 4. So the answer for the query is [-1,4].\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [2, 105].\n1 <= Node.val <= 106\nn == queries.length\n1 <= n <= 105\n1 <= queries[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([6, 2, 13, 1, 4, 9, 15, None, None, None, None, None, None, 14]),queries = [2, 5, 16]) == [[2, 2], [4, 6], [15, -1]]\n assert candidate(root = tree_node([4, None, 9]),queries = [3]) == [[-1, 4]]\n assert candidate(root = tree_node([7, 5, 9, 3, 6, 8, 10, 2, 4, None, None, None, None, None, None]),queries = [3, 7, 10, 1, 8]) == [[3, 3], [7, 7], [10, 10], [-1, 2], [8, 8]]\n assert candidate(root = tree_node([50, 25, 75, 10, 30, 60, 90, 5, 15, 28, 35, 55, 65, 85, 95, 1, 9, 20, 27, 33, 52, 58, 63, 67, 82, 88, 93, 98]),queries = [20, 50, 60, 70, 80, 90]) == [[15, 27], [35, 63], [35, 63], [65, 93], [75, 98], [90, 90]]\n assert candidate(root = tree_node([5, 3, 7, 2, 4, 6, 8]),queries = [0, 9, 1, 8, 6, 3, 7, 4, 2, 5]) == [[-1, 2], [8, -1], [-1, 2], [8, 8], [6, 6], [3, 3], [7, 7], [4, 4], [2, 2], [5, 5]]\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, None, 6, 8, 11, 13, None, None, 16, 19]),queries = [1, 4, 7, 9, 10, 15, 17, 20]) == [[1, 16], [3, 5], [7, 7], [8, 10], [10, 10], [15, 15], [15, 18], [18, -1]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 18, 23, 27, 32, 38, 2, 4, 6, 8, 11, 14, 16, 19, 22, 24, 26, 28, 31, 33, 36, 39]),queries = [1, 4, 9, 12, 17, 21, 28, 34, 37, 40]) == [[-1, 2], [4, 4], [8, 10], [11, 13], [16, 18], [20, 22], [28, 28], [33, 35], [36, 38], [39, -1]]\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 12, 14, 17, 19]),queries = [2, 9, 20, 11, 7]) == [[1, 3], [8, 10], [19, -1], [10, 12], [7, 7]]\n assert candidate(root = tree_node([2, 1, 3, None, None, 4, 5]),queries = [1, 2, 3, 4, 5, 0, 6]) == [[1, 1], [2, 2], [2, 4], [3, 4], [5, 5], [-1, 1], [5, -1]]\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15]),queries = [0, 1, 3, 7, 15, 16]) == [[-1, 1], [1, 1], [3, 3], [7, 7], [15, 15], [15, -1]]\n assert candidate(root = tree_node([7, 3, 15, None, None, 9, 20, None, None, 8, 11, 18, 25, None, None, 17, 19, 23, 27, None, None, None, None, 22, 24, 26, 28]),queries = [2, 5, 10, 13, 16, 21, 29, 30]) == [[-1, 3], [3, 7], [9, 15], [9, 15], [15, 17], [8, 22], [11, -1], [11, -1]]\n assert candidate(root = tree_node([15, 7, 20, 3, 11, 17, 25, 1, 5, 9, 13, 16, 18, 22, 27, None, None, None, None, 4, 6, 8, 10, 12, None, None, 14, None, None, None, None, 19, 21, 23, 24, 26, 28, 29, 30]),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]) == [[1, 1], [1, 3], [3, 3], [3, 5], [5, 5], [5, 7], [4, 7], [4, 21], [6, 21], [6, 24], [8, 24], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [8, 28], [27, 28], [27, -1], [27, -1], [27, -1]]\n assert candidate(root = tree_node([8, 3, 10, 1, 6, None, 14, None, None, 4, 7, 13]),queries = [2, 4, 6, 8, 10, 12, 14, 16]) == [[1, 3], [4, 4], [6, 6], [8, 8], [10, 10], [10, 13], [14, 14], [14, -1]]\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 90, 110, 140, 160, 190, 5, 15, 35, 45, 55, 65, 85, 95, 105, 115, 135, 145, 155, 165, 185, 195]),queries = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 25, 45, 65, 85, 105, 125, 145, 165, 185]) == [[10, 10], [25, 35], [50, 50], [65, 75], [90, 90], [110, 110], [125, 135], [150, 150], [165, 175], [190, 190], [195, -1], [25, 25], [45, 45], [65, 65], [85, 85], [105, 105], [125, 125], [145, 145], [165, 165], [185, 185]]\n assert candidate(root = tree_node([3, 1, 5, None, 2, 4, None]),queries = [0, 1, 2, 3, 4, 5, 6]) == [[-1, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [5, -1]]\n assert candidate(root = tree_node([10, 5, 15, 2, 7, None, 18, None, None, 6, 8]),queries = [4, 7, 12, 18, 20]) == [[2, 5], [7, 7], [10, 15], [18, 18], [18, -1]]\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 12, 14, 17, 20]),queries = [1, 10, 20, 16, 25]) == [[1, 1], [10, 10], [20, 20], [15, 17], [20, -1]]\n assert candidate(root = tree_node([50, 25, 75, 10, 35, 65, 85, 5, 15, 30, 40, 60, 70, 80, 90, 1, 7, 12, 20, 28, 33, 38, 55, 63, 68, 73, 82, 88, 93, 98]),queries = [3, 15, 28, 40, 55, 63, 73, 82, 88, 93]) == [[1, 5], [15, 15], [28, 28], [40, 40], [50, 63], [60, 68], [70, 82], [80, 93], [85, 98], [90, -1]]\n assert candidate(root = tree_node([7, 3, 15, 1, 5, 9, 20, None, None, 2, 6, 8, 12, None, None, None, None, 11, 13]),queries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == [[-1, 1], [1, 1], [1, 3], [2, 3], [2, 5], [5, 5], [6, 11], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [12, 13], [12, 15], [15, 15], [15, 20], [15, 20], [15, 20], [15, 20], [20, 20], [20, -1]]\n assert candidate(root = tree_node([15, 10, 20, 8, 12, 18, 25, 7, 9, 11, 13, 17, 19, 23, 27, 6, 14, 16, 21, 22, 24, 26, 28, 30]),queries = [5, 15, 20, 30, 35]) == [[-1, 6], [9, 21], [9, 21], [27, -1], [27, -1]]\n assert candidate(root = tree_node([10, None, 20, None, 30, None, 40, None, 50]),queries = [5, 15, 25, 35, 45, 55]) == [[-1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, -1]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 18, 23, 27, 32, 37, 1, None, None, None, None, 11, None, None, 17, None, None, 22, None, 26, None, 31, 33, None, None, None, None, None, None, None, 4]),queries = [0, 1, 3, 29, 36, 40]) == [[-1, 33], [1, 33], [2, 5], [22, 30], [31, -1], [31, -1]]\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 18, 30, 43, 55, 68, 82, 93, 3, 9, 15, 21, 28, 35, 40, 47, 52, 58, 65, 70, 78, 85, 90, 96]),queries = [20, 45, 50, 80, 95, 100]) == [[18, 21], [43, 47], [50, 50], [78, 82], [93, 96], [96, -1]]\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),queries = [1, 3, 5, 7, 9, 11]) == [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [10, -1]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 13, 17, 23, 27, 33, 37]),queries = [10, 14, 18, 22, 26, 30]) == [[10, 10], [13, 15], [17, 20], [20, 23], [25, 27], [30, 30]]\n assert candidate(root = tree_node([12, 5, 18, 2, 9, 15, 20, 1, 3, 7, 11, 13, 17, 19, 22]),queries = [6, 12, 23, 0]) == [[5, 7], [12, 12], [22, -1], [-1, 1]]\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15]),queries = [0, 2, 5, 8, 10, 13, 16]) == [[-1, 1], [2, 2], [5, 5], [8, 8], [10, 10], [13, 13], [15, -1]]\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15]),queries = [3, 7, 11, 15, 18, 2]) == [[3, 3], [7, 7], [11, 11], [15, 15], [15, -1], [2, 2]]\n assert candidate(root = tree_node([7, 3, 15, 1, 5, 9, 20, None, None, 2, 6, 8, 12, 18, 25, None, None, None, None, 4, None, None, None, None, 10, None, 11, None, None, None, None, 13, None, None, None, 16, None, 19, None, None, None, 21, None, 23, None, None, None, 26, None, None, None, 28, None, 30]),queries = [1, 7, 14, 24, 30, 31]) == [[1, 1], [4, 8], [12, 15], [11, -1], [11, -1], [11, -1]]\n assert candidate(root = tree_node([7, 3, 15, None, 4, 9, 20, None, None, 5, 10, 16, 22]),queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == [[-1, 3], [-1, 3], [3, 3], [4, 4], [4, 7], [4, 7], [5, 7], [5, 9], [9, 9], [10, 10], [10, 15], [10, 15], [10, 15], [10, 15], [15, 15], [16, 16], [16, 20], [16, 20], [16, 20], [20, 20], [20, 22], [22, 22], [22, -1]]\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 18, 31, 43, 56, 68, 81, 93, 3, 9, 15, 21, 28, 34, 40, 48, 52, 59, 65, 72, 76, 84, 89, 95]),queries = [5, 20, 35, 50, 65, 80, 95, 100]) == [[3, 6], [18, 21], [34, 37], [50, 50], [65, 65], [76, 81], [95, 95], [95, -1]]\n assert candidate(root = tree_node([100000, 50000, 150000, 25000, 75000, 125000, 175000, 12500, 37500, 62500, 87500, 112500, 137500, 162500, 187500, 6250, 18750, 28125, 43750, 53125, 68750, 78125, 93750, 103125, 118750, 128125, 143750, 153125, 168750, 178125, 193750, 203125]),queries = [50000, 75000, 125000, 150000, 175000, 200000, 250000]) == [[50000, 50000], [75000, 75000], [125000, 125000], [150000, 150000], [175000, 175000], [193750, -1], [193750, -1]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 12, 18, 23, 28, 33, 38]),queries = [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]) == [[-1, 1], [1, 1], [1, 5], [1, 5], [1, 5], [5, 5], [5, 7], [7, 7], [7, 10], [7, 10], [10, 10], [10, 12], [12, 12], [12, 15], [12, 15], [15, 15], [15, 18], [15, 18], [18, 18], [18, 20], [20, 20], [20, 23], [20, 23], [23, 23], [23, 25], [25, 25], [25, 28], [25, 28], [28, 28], [28, 30], [30, 30], [30, 33], [30, 33], [33, 33], [33, 35], [35, 35], [35, 38], [35, 38], [38, 38], [38, -1], [38, -1]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, None, None, 12, 17, 22, 28, None, None, None, None, None, 13, 16]),queries = [3, 10, 14, 25, 29, 35, 40]) == [[-1, 5], [10, 10], [12, 15], [25, 25], [28, 30], [35, 35], [35, -1]]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),queries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [[-1, 8], [1, 8], [1, 12], [3, 12], [3, 14], [3, 14], [3, 14], [7, 14], [7, 15], [7, 15], [7, 15], [7, 15], [7, 15], [7, 15], [7, 15], [15, 15], [15, -1]]\n assert candidate(root = tree_node([8, 3, 10, 1, 5, 9, 12, None, 4, 7, None, None, None, 11, 13]),queries = [6, 10, 17, 0]) == [[5, 8], [10, 10], [13, -1], [-1, 1]]\n assert candidate(root = tree_node([5, 3, 7, 2, 4, 6, 8, 1]),queries = [1, 2, 3, 4, 5, 6, 7, 8]) == [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, 4, None, None, 11, 13, None, None, None, None, 2, None, None]),queries = [1, 6, 14, 19]) == [[1, 1], [5, 7], [13, 15], [18, -1]]\n assert candidate(root = tree_node([50, 25, 75, 10, 35, 60, 85, 5, 15, 30, 40, 55, 65, 80, 90, 3, 7, 12, 18, 28, 33, 45, 52, 58, 63, 72, 78, 83, 88, 93, 97]),queries = [20, 60, 95, 45, 80]) == [[18, 25], [60, 63], [90, 97], [40, 52], [80, 83]]\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18]),queries = [1, 3, 5, 7, 10, 15, 18, 20]) == [[-1, 3], [3, 3], [5, 5], [7, 7], [10, 10], [15, 15], [18, 18], [18, -1]]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),queries = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 16]) == [[15, 15], [7, 15], [7, 15], [7, 15], [7, 15], [7, 15], [7, 15], [7, 15], [7, 14], [3, 14], [3, 14], [3, 14], [3, 12], [1, 12], [1, 8], [-1, 8], [15, -1]]\n assert candidate(root = tree_node([15, 10, 20, 5, 12, None, 25, 3, 7, None, 13, None, None, 14, 18]),queries = [9, 15, 21, 11]) == [[3, 18], [15, 15], [20, 25], [10, 12]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 2, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38]),queries = [1, 9, 11, 19, 21, 29, 31, 39]) == [[-1, 2], [8, 10], [10, 12], [18, 20], [20, 22], [28, 30], [30, 32], [38, -1]]\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15]),queries = [0, 8, 16, 18, 5]) == [[-1, 1], [8, 8], [15, -1], [15, -1], [5, 5]]\n assert candidate(root = tree_node([50, 25, 75, 10, 35, 60, 85, 5, 15, 30, 40, 55, 65, 80, 90, 2, 7, 12, 17, 27, 37, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92]),queries = [1, 20, 39, 51, 66, 78, 89, 95]) == [[-1, 2], [17, 25], [35, 47], [50, 57], [65, 72], [77, 80], [87, 90], [92, -1]]\n assert candidate(root = tree_node([50, 25, 75, 10, 35, 60, 85, 5, 15, 30, 40, 55, 65, 80, 90]),queries = [24, 26, 49, 51, 54, 56, 79, 81, 84, 86, 91, 95, 100]) == [[15, 25], [25, 30], [40, 50], [50, 55], [50, 55], [55, 60], [75, 80], [80, 85], [80, 85], [85, 90], [90, -1], [90, -1], [90, -1]]\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, None, 1]),queries = [2, 5, 10, 0]) == [[2, 2], [5, 5], [6, -1], [-1, 1]]\n assert candidate(root = tree_node([15, 10, 20, 5, 12, 18, 25, 3, 7, 11, 13, 16, 19, 22, 28, 1, 4, 6, 8, 9, 10.14, 17, 21, 23, 27, 29]),queries = [1, 15, 25, 13, 22, 28, 30, 0, 16]) == [[1, 1], [15, 21], [18, 29], [13, 17], [18, 29], [18, 29], [28, -1], [-1, 1], [16, 23]]\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 17, 19]),queries = [2, 9, 14, 20, 16]) == [[1, 3], [8, 10], [13, 15], [19, -1], [15, 17]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 2, 4, 6, 8, 11, 12, 14, 16, 18, 19, 21, 22, 24, 26, 28, 29, 31, 32, 34, 36, 38, 39, 40]),queries = [1, 9, 11, 14, 16, 19, 21, 24, 26, 29, 31, 34, 36, 39, 40]) == [[-1, 31], [7, 40], [11, 11], [14, 15], [16, 17], [16, 20], [18, 23], [24, 30], [24, 33], [24, 33], [24, 33], [26, 35], [28, 37], [29, -1], [29, -1]]\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 17, 19]),queries = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [[-1, 1], [1, 3], [4, 4], [6, 6], [8, 8], [10, 10], [12, 12], [13, 15], [15, 17], [18, 18], [19, -1]]\n assert candidate(root = tree_node([50, 25, 75, 10, 30, 60, 80, 5, 15, 27, 35, 55, 65, 70, 85, None, None, None, None, 12, None, None, 26, None, None, 53, 57, None, None, 63, 67, None, None, None, None, None, 73, None, 82, 90]),queries = [1, 20, 40, 50, 58, 68, 88, 100]) == [[-1, 5], [15, 25], [26, 50], [50, 50], [57, 82], [57, 82], [67, -1], [67, -1]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 17, 22, 27, 32, 37, 1, 3, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38]),queries = [1, 9, 19, 29, 39]) == [[1, 1], [8, 10], [18, 20], [28, 30], [38, -1]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 17, 22, 27, 32, 37, 1, 3, 6, 8, 11, 14, 16, 18, 21, 23, 24, 26, 28, 31, 33, 34, 36, 38, 39, 40]),queries = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42]) == [[-1, 36], [1, 38], [1, 38], [6, 38], [8, 8], [10, 10], [12, 12], [14, 14], [16, 16], [18, 18], [20, 20], [22, 22], [24, 25], [26, 27], [28, 30], [28, 32], [31, 32], [31, 35], [33, 37], [34, -1], [34, -1], [34, -1]]\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 190]),queries = [99, 101, 50, 150, 26]) == [[80, 100], [100, 110], [50, 50], [150, 150], [25, 30]]\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 90, 110, 140, 160, 190, 5, 15, 35, 45, 55, 65, 85, 95, 105, 115, 135, 145, 155, 165, 185, 195]),queries = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210]) == [[10, 10], [25, 35], [50, 50], [65, 75], [90, 90], [110, 110], [125, 135], [150, 150], [165, 175], [190, 190], [195, -1]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 2, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38]),queries = [1, 38, 19, 21, 30]) == [[-1, 2], [38, 38], [18, 20], [20, 22], [30, 30]]\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),queries = [0, 15, 16, 7, 8]) == [[-1, 8], [15, 15], [15, -1], [7, 14], [7, 15]]\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 18, 25]),queries = [4, 8, 10, 12, 17, 21]) == [[4, 4], [8, 8], [10, 10], [12, 12], [15, 18], [20, 25]]\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 18, 31, 43, 56, 68, 81, 93]),queries = [20, 30, 40, 50, 60, 70, 80, 90, 100]) == [[18, 25], [25, 31], [37, 43], [50, 50], [56, 62], [68, 75], [75, 81], [87, 93], [93, -1]]\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 63, 87, 6, 18, 30, 44, 56, 70, 80, 94, 3, 9, 15, 24, 27, 33, 39, 42, 48, 52, 60, 67, 69, 72, 77, 78, 83, 88, 92, 96, None, None, None, None, None, 10, None, None, None, None, None, 20, None, 26, None, None, 31, None, 35, None, None, None, None, 40, 43, 46, 47, None, None, None, 50, 54, 55, None, 58, 59, None, None, None, 62, None, 64, None, None, None, None, 66, None, 71, 73, None, 74, 75, None, None, 79, None, 81, None, 82, None, None, 85, 86, None, 89, None, 90, None, 91, None, None, 93, None, 95, 97, None, None, None, None, None, None, None, 98, None, 99, None, None, None, 100]),queries = [23, 50, 75, 99, 101]) == [[3, 50], [50, 50], [62, 89], [89, 100], [78, -1]]\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180, 5, 15, 27, 35, 55, 65, 77, 85, 105, 115, 135, 145, 155, 165, 175, 185]),queries = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200]) == [[15, 25], [35, 50], [60, 60], [80, 80], [100, 100], [115, 125], [140, 140], [160, 160], [180, 180], [185, -1]]\n assert candidate(root = tree_node([20, 15, 25, 10, 17, 22, 30, 5, 12, 16, 18, 21, 23, 28, 35, 2, 7, None, 11, 13, None, None, None, None, None, 27, 29, 33, 36, None, None, 32, 34, None, None, None, None, 31, None, None, None, None, 37]),queries = [19, 25, 31, 36, 40]) == [[18, 20], [22, 27], [29, 37], [29, 37], [35, -1]]\n assert candidate(root = tree_node([8, 3, 10, None, 6, 9, 12, None, None, 5, 7]),queries = [2, 8, 11, 13]) == [[-1, 3], [5, 8], [10, 12], [12, -1]]\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 17, 22, 27, 32, 37]),queries = [1, 5, 10, 15, 20, 25, 30, 35, 40]) == [[-1, 2], [5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [37, -1]]\n"}, "metadata": {"canonical_parameter_names": ["root", "queries"], "leetcode_dataset_entry_point": "Solution().closestNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2477, "task_id": "minimum-fuel-cost-to-report-to-the-capital", "difficulty": "Medium", "problem_description": "There is a tree (i.e., a connected, undirected graph with no cycles) structure country network consisting of n cities numbered from 0 to n - 1 and exactly n - 1 roads. The capital city is city 0. You are given a 2D integer array roads where roads[i] = [ai, bi] denotes that there exists a bidirectional road connecting cities ai and bi.\nThere is a meeting for the representatives of each city. The meeting is in the capital city.\nThere is a car in each city. You are given an integer seats that indicates the number of seats in each car.\nA representative can use the car in their city to travel or change the car and ride with another representative. The cost of traveling between two cities is one liter of fuel.\nReturn the minimum number of liters of fuel to reach the capital city.\n \nExample 1:\n\n\nInput: roads = [[0,1],[0,2],[0,3]], seats = 5\nOutput: 3\nExplanation: \n- Representative1 goes directly to the capital with 1 liter of fuel.\n- Representative2 goes directly to the capital with 1 liter of fuel.\n- Representative3 goes directly to the capital with 1 liter of fuel.\nIt costs 3 liters of fuel at minimum. \nIt can be proven that 3 is the minimum number of liters of fuel needed.\n\nExample 2:\n\n\nInput: roads = [[3,1],[3,2],[1,0],[0,4],[0,5],[4,6]], seats = 2\nOutput: 7\nExplanation: \n- Representative2 goes directly to city 3 with 1 liter of fuel.\n- Representative2 and representative3 go together to city 1 with 1 liter of fuel.\n- Representative2 and representative3 go together to the capital with 1 liter of fuel.\n- Representative1 goes directly to the capital with 1 liter of fuel.\n- Representative5 goes directly to the capital with 1 liter of fuel.\n- Representative6 goes directly to city 4 with 1 liter of fuel.\n- Representative4 and representative6 go together to the capital with 1 liter of fuel.\nIt costs 7 liters of fuel at minimum. \nIt can be proven that 7 is the minimum number of liters of fuel needed.\n\nExample 3:\n\n\nInput: roads = [], seats = 1\nOutput: 0\nExplanation: No representatives need to travel to the capital city.\n\n \nConstraints:\n\n1 <= n <= 105\nroads.length == n - 1\nroads[i].length == 2\n0 <= ai, bi < n\nai != bi\nroads represents a valid tree.\n1 <= seats <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],seats = 4) == 6\n assert candidate(roads = [[0, 1], [0, 2], [0, 3]],seats = 5) == 3\n assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4]],seats = 3) == 5\n assert candidate(roads = [],seats = 1) == 0\n assert candidate(roads = [[3, 1], [3, 2], [1, 0], [0, 4], [0, 5], [4, 6]],seats = 2) == 7\n assert candidate(roads = [[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]],seats = 8) == 28\n assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [6, 8], [6, 9]],seats = 3) == 11\n assert candidate(roads = [[0, 1], [0, 2], [2, 3], [2, 4], [4, 5], [4, 6], [6, 7], [6, 8], [8, 9], [8, 10], [10, 11]],seats = 2) == 21\n assert candidate(roads = [[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]],seats = 4) == 15\n assert candidate(roads = [[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]],seats = 6) == 31\n assert candidate(roads = [[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]],seats = 5) == 34\n assert candidate(roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],seats = 10) == 9\n assert candidate(roads = [[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]],seats = 5) == 53\n assert candidate(roads = [[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]],seats = 12) == 45\n assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],seats = 3) == 12\n assert candidate(roads = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7], [6, 8], [6, 9], [7, 10], [7, 11]],seats = 4) == 16\n assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 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], [10, 25], [11, 26], [11, 27], [11, 28], [12, 29], [12, 30], [12, 31], [13, 32], [13, 33], [13, 34], [14, 35], [14, 36], [15, 37], [15, 38], [16, 39], [16, 40]],seats = 2) == 84\n assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],seats = 3) == 12\n assert candidate(roads = [[0, 1], [1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 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], [10, 25], [11, 26], [11, 27], [11, 28], [12, 29], [12, 30], [12, 31]],seats = 3) == 53\n assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12]],seats = 7) == 12\n assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],seats = 5) == 13\n assert candidate(roads = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],seats = 4) == 8\n assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],seats = 4) == 11\n assert candidate(roads = [[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]],seats = 6) == 29\n assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [15, 21], [16, 22], [17, 23], [18, 24], [19, 25], [20, 26], [21, 27], [22, 28], [23, 29], [24, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36]],seats = 8) == 42\n assert candidate(roads = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7]],seats = 3) == 10\n assert candidate(roads = [[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]],seats = 5) == 16\n assert candidate(roads = [[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]],seats = 4) == 32\n assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],seats = 4) == 15\n assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],seats = 6) == 11\n assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],seats = 2) == 12\n assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],seats = 5) == 11\n assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [5, 15], [5, 16], [5, 17]],seats = 10) == 18\n assert candidate(roads = [[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]],seats = 9) == 44\n assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 10], [10, 11], [11, 12], [12, 13], [13, 14]],seats = 3) == 25\n assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [15, 21], [16, 22], [17, 23], [18, 24], [19, 25], [20, 26], [21, 27], [22, 28], [23, 29], [24, 30]],seats = 7) == 33\n assert candidate(roads = [[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]],seats = 8) == 36\n assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [11, 27], [11, 28], [12, 29], [12, 30]],seats = 8) == 33\n assert candidate(roads = [[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]],seats = 7) == 29\n assert candidate(roads = [[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]],seats = 6) == 32\n assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24], [9, 25], [9, 26], [10, 27], [10, 28], [10, 29]],seats = 10) == 31\n assert candidate(roads = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [6, 7], [7, 8]],seats = 4) == 10\n assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15]],seats = 4) == 18\n assert candidate(roads = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [7, 10], [7, 11], [8, 12], [8, 13], [9, 14], [9, 15]],seats = 6) == 18\n assert candidate(roads = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6]],seats = 3) == 8\n assert candidate(roads = [[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]],seats = 6) == 32\n assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],seats = 5) == 11\n assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [5, 16], [5, 17], [5, 18], [6, 19], [6, 20], [6, 21], [7, 22], [7, 23], [7, 24], [8, 25], [8, 26], [8, 27], [9, 28], [9, 29], [9, 30]],seats = 9) == 32\n assert candidate(roads = [[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]],seats = 5) == 19\n assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],seats = 2) == 25\n assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [5, 8], [6, 9], [6, 10]],seats = 5) == 11\n assert candidate(roads = [[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]],seats = 9) == 35\n assert candidate(roads = [[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]],seats = 5) == 14\n assert candidate(roads = [[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]],seats = 2) == 225\n assert candidate(roads = [[0, 1], [1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 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], [10, 24], [11, 25], [11, 26]],seats = 6) == 33\n assert candidate(roads = [[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]],seats = 7) == 27\n assert candidate(roads = [[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]],seats = 7) == 36\n assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],seats = 2) == 30\n assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 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], [10, 25], [11, 26], [11, 27], [11, 28], [12, 29], [12, 30], [12, 31], [13, 32], [13, 33], [13, 34], [14, 35], [14, 36], [15, 37], [15, 38], [16, 39], [16, 40], [17, 41], [17, 42], [18, 43], [18, 44], [19, 45], [19, 46], [20, 47], [20, 48], [21, 49], [21, 50], [22, 51], [22, 52], [23, 53], [23, 54], [23, 55], [24, 56], [24, 57], [25, 58], [25, 59]],seats = 4) == 88\n assert candidate(roads = [[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]],seats = 6) == 16\n assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [5, 16], [5, 17], [5, 18], [6, 19], [6, 20], [6, 21]],seats = 8) == 22\n assert candidate(roads = [[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]],seats = 6) == 24\n assert candidate(roads = [[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]],seats = 4) == 19\n assert candidate(roads = [[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]],seats = 5) == 26\n assert candidate(roads = [[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]],seats = 2) == 64\n"}, "metadata": {"canonical_parameter_names": ["roads", "seats"], "leetcode_dataset_entry_point": "Solution().minimumFuelCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumFuelCost(int[][] roads, int seats) {", "container": "Solution", "callable": "minimumFuelCost", "parameters": [{"name": "roads", "type": "int[][]"}, {"name": "seats", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2478, "task_id": "number-of-beautiful-partitions", "difficulty": "Hard", "problem_description": "You are given a string s that consists of the digits '1' to '9' and two integers k and minLength.\nA partition of s is called beautiful if:\n\ns is partitioned into k non-intersecting substrings.\nEach substring has a length of at least minLength.\nEach substring starts with a prime digit and ends with a non-prime digit. Prime digits are '2', '3', '5', and '7', and the rest of the digits are non-prime.\n\nReturn the number of beautiful partitions of s. Since the answer may be very large, return it modulo 109 + 7.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"23542185131\", k = 3, minLength = 2\nOutput: 3\nExplanation: There exists three ways to create a beautiful partition:\n\"2354 | 218 | 5131\"\n\"2354 | 21851 | 31\"\n\"2354218 | 51 | 31\"\n\nExample 2:\n\nInput: s = \"23542185131\", k = 3, minLength = 3\nOutput: 1\nExplanation: There exists one way to create a beautiful partition: \"2354 | 218 | 5131\".\n\nExample 3:\n\nInput: s = \"3312958\", k = 3, minLength = 1\nOutput: 1\nExplanation: There exists one way to create a beautiful partition: \"331 | 29 | 58\".\n\n \nConstraints:\n\n1 <= k, minLength <= s.length <= 1000\ns consists of the digits '1' to '9'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"52372938462673572\",k = 4,minLength = 2) == 0\n assert candidate(s = \"33333\",k = 1,minLength = 1) == 0\n assert candidate(s = \"23542185131\",k = 3,minLength = 3) == 1\n assert candidate(s = \"3312958\",k = 3,minLength = 1) == 1\n assert candidate(s = \"253179\",k = 2,minLength = 1) == 1\n assert candidate(s = \"72531\",k = 1,minLength = 5) == 1\n assert candidate(s = \"357291\",k = 2,minLength = 2) == 0\n assert candidate(s = \"22354\",k = 1,minLength = 1) == 1\n assert candidate(s = \"23542185131\",k = 3,minLength = 2) == 3\n assert candidate(s = \"77777\",k = 5,minLength = 1) == 0\n assert candidate(s = \"75319\",k = 1,minLength = 5) == 1\n assert candidate(s = \"22222\",k = 5,minLength = 1) == 0\n assert candidate(s = \"2375193\",k = 2,minLength = 2) == 0\n assert candidate(s = \"3572935729\",k = 5,minLength = 2) == 0\n assert candidate(s = \"23751\",k = 2,minLength = 1) == 0\n assert candidate(s = \"2222222222\",k = 5,minLength = 1) == 0\n assert candidate(s = \"2233445566778899\",k = 2,minLength = 4) == 2\n assert candidate(s = \"7223357\",k = 2,minLength = 1) == 0\n assert candidate(s = \"23759237592375923759\",k = 5,minLength = 4) == 0\n assert candidate(s = \"35757575757575\",k = 7,minLength = 1) == 0\n assert candidate(s = \"2354218513197531\",k = 4,minLength = 3) == 2\n assert candidate(s = \"317317317317317317317317317317\",k = 8,minLength = 2) == 0\n assert candidate(s = \"353535353535353535353535\",k = 10,minLength = 2) == 0\n assert candidate(s = \"2357235723572357235723572357\",k = 10,minLength = 2) == 0\n assert candidate(s = \"23572357235723572357235723572357235723\",k = 10,minLength = 4) == 0\n assert candidate(s = \"235423542354\",k = 3,minLength = 2) == 1\n assert candidate(s = \"373737373737373737373737\",k = 10,minLength = 2) == 0\n assert candidate(s = \"2354218513123542185131\",k = 5,minLength = 2) == 35\n assert candidate(s = \"75319284628462846284\",k = 4,minLength = 3) == 4\n assert candidate(s = \"331295833129583312958331295833129583312958\",k = 10,minLength = 3) == 110\n assert candidate(s = \"77777777777777777777777777777777777777\",k = 5,minLength = 1) == 0\n assert candidate(s = \"235711317113\",k = 3,minLength = 3) == 0\n assert candidate(s = \"23542185131\",k = 5,minLength = 1) == 0\n assert candidate(s = \"2233335555777711112222333355557777\",k = 6,minLength = 2) == 0\n assert candidate(s = \"2333353333533337333313333\",k = 7,minLength = 2) == 0\n assert candidate(s = \"23572357235723572357235723572357235723\",k = 15,minLength = 5) == 0\n assert candidate(s = \"235723572357235723572357235723572357\",k = 15,minLength = 2) == 0\n assert candidate(s = \"23547186918691869\",k = 4,minLength = 2) == 0\n assert candidate(s = \"331295897531\",k = 4,minLength = 1) == 1\n assert candidate(s = \"22222222222222222222\",k = 10,minLength = 2) == 0\n assert candidate(s = \"7777777777777777777777777777\",k = 8,minLength = 3) == 0\n assert candidate(s = \"235723572357\",k = 6,minLength = 2) == 0\n assert candidate(s = \"235235235235235235\",k = 7,minLength = 3) == 0\n assert candidate(s = \"733733733733733733733733\",k = 10,minLength = 2) == 0\n assert candidate(s = \"2375913759231\",k = 4,minLength = 2) == 0\n assert candidate(s = \"222333444555666777888999\",k = 3,minLength = 3) == 1\n assert candidate(s = \"735235235235235235\",k = 7,minLength = 2) == 0\n assert candidate(s = \"252525252525252525252525\",k = 10,minLength = 2) == 0\n assert candidate(s = \"223542185131223542185131223542185131\",k = 9,minLength = 3) == 1\n assert candidate(s = \"732519753189273189\",k = 4,minLength = 3) == 0\n assert candidate(s = \"233757537537537537537\",k = 8,minLength = 3) == 0\n assert candidate(s = \"22222222222222222222222222222222222222\",k = 15,minLength = 1) == 0\n assert candidate(s = \"222333555777111222333\",k = 7,minLength = 2) == 0\n assert candidate(s = \"735218513735218513735218513735\",k = 7,minLength = 3) == 0\n assert candidate(s = \"272727272727\",k = 6,minLength = 1) == 0\n assert candidate(s = \"23572357235723572357\",k = 5,minLength = 2) == 0\n assert candidate(s = \"222333555777111\",k = 4,minLength = 3) == 0\n assert candidate(s = \"37537537537537\",k = 6,minLength = 3) == 0\n assert candidate(s = \"22335577112233557711\",k = 6,minLength = 2) == 0\n assert candidate(s = \"2573197319731973197319\",k = 9,minLength = 2) == 0\n assert candidate(s = \"2354218513171925235729\",k = 6,minLength = 3) == 0\n assert candidate(s = \"232323232323232323232323\",k = 10,minLength = 2) == 0\n assert candidate(s = \"222333555777111222333555777111\",k = 4,minLength = 3) == 0\n assert candidate(s = \"753197531975319753\",k = 10,minLength = 2) == 0\n assert candidate(s = \"33333333333333333333333333333333333333\",k = 10,minLength = 1) == 0\n assert candidate(s = \"2323232323232323\",k = 8,minLength = 2) == 0\n assert candidate(s = \"33333333333333\",k = 5,minLength = 2) == 0\n assert candidate(s = \"33129583312958331295833129583312958331\",k = 10,minLength = 3) == 15\n assert candidate(s = \"373737373737\",k = 6,minLength = 1) == 0\n assert candidate(s = \"2233557711886644\",k = 6,minLength = 1) == 0\n assert candidate(s = \"235476918235476918235476918\",k = 6,minLength = 3) == 1\n assert candidate(s = \"333222111777555333222111\",k = 9,minLength = 2) == 0\n assert candidate(s = \"29292929292929\",k = 3,minLength = 3) == 3\n assert candidate(s = \"7235719753197532\",k = 5,minLength = 2) == 0\n assert candidate(s = \"35235235235235235235235235235\",k = 10,minLength = 3) == 0\n assert candidate(s = \"333555777222444666888999\",k = 5,minLength = 2) == 0\n assert candidate(s = \"373737373737373737\",k = 5,minLength = 3) == 0\n assert candidate(s = \"222333555777111222333555777111\",k = 6,minLength = 3) == 0\n assert candidate(s = \"23572357235723\",k = 1,minLength = 1) == 0\n assert candidate(s = \"23571113171923293137414347\",k = 10,minLength = 2) == 0\n assert candidate(s = \"22222222222222\",k = 2,minLength = 5) == 0\n assert candidate(s = \"23751937519375193\",k = 5,minLength = 2) == 0\n assert candidate(s = \"235421851312354218513123542185\",k = 6,minLength = 4) == 0\n assert candidate(s = \"22222222222222222222222222222222222222\",k = 20,minLength = 1) == 0\n assert candidate(s = \"27272727272727272727272727272\",k = 8,minLength = 2) == 0\n assert candidate(s = \"2222222222222222222222222222\",k = 12,minLength = 1) == 0\n assert candidate(s = \"753753753753753753753753753753753753753753\",k = 15,minLength = 5) == 0\n assert candidate(s = \"235421851312354218513123542185131\",k = 6,minLength = 2) == 462\n assert candidate(s = \"52373197357537325\",k = 5,minLength = 1) == 0\n assert candidate(s = \"23232323232323232323232323\",k = 10,minLength = 2) == 0\n assert candidate(s = \"222333555777222333555777222333555777\",k = 6,minLength = 4) == 0\n assert candidate(s = \"23542185131973\",k = 4,minLength = 2) == 0\n assert candidate(s = \"375375375375\",k = 5,minLength = 2) == 0\n assert candidate(s = \"75319753197531975319753197531975\",k = 8,minLength = 4) == 0\n assert candidate(s = \"3257113257113257113257\",k = 10,minLength = 2) == 0\n assert candidate(s = \"223355771199\",k = 6,minLength = 2) == 0\n assert candidate(s = \"375375375375375375375375375375\",k = 7,minLength = 4) == 0\n assert candidate(s = \"23572357235723\",k = 2,minLength = 5) == 0\n assert candidate(s = \"2354218513123542185131\",k = 6,minLength = 2) == 21\n assert candidate(s = \"23572357235723572357235723572357235723\",k = 15,minLength = 3) == 0\n assert candidate(s = \"3572535725357\",k = 5,minLength = 1) == 0\n assert candidate(s = \"2357135713571357\",k = 7,minLength = 2) == 0\n assert candidate(s = \"22223333555577772222\",k = 4,minLength = 5) == 0\n assert candidate(s = \"53725372537253725372537253725372\",k = 10,minLength = 3) == 0\n assert candidate(s = \"257357257357\",k = 4,minLength = 2) == 0\n assert candidate(s = \"2197531975319753\",k = 8,minLength = 3) == 0\n assert candidate(s = \"2357235723572357\",k = 1,minLength = 15) == 0\n assert candidate(s = \"23542185131719\",k = 5,minLength = 2) == 1\n assert candidate(s = \"57575757575757575757575757575\",k = 6,minLength = 4) == 0\n assert candidate(s = \"22335577223355772233\",k = 6,minLength = 1) == 0\n assert candidate(s = \"2357235723572357235723572357\",k = 7,minLength = 5) == 0\n assert candidate(s = \"37531975319753197537531975319753\",k = 12,minLength = 2) == 0\n assert candidate(s = \"25252525252525\",k = 5,minLength = 2) == 0\n assert candidate(s = \"21212121212121\",k = 3,minLength = 2) == 15\n assert candidate(s = \"2357198462357\",k = 4,minLength = 2) == 0\n assert candidate(s = \"235723572357235723572357\",k = 10,minLength = 2) == 0\n assert candidate(s = \"23232323232323232323232323232323\",k = 10,minLength = 2) == 0\n"}, "metadata": {"canonical_parameter_names": ["s", "k", "minLength"], "leetcode_dataset_entry_point": "Solution().beautifulPartitions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int beautifulPartitions(String s, int k, int minLength) {", "container": "Solution", "callable": "beautifulPartitions", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}, {"name": "minLength", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2481, "task_id": "minimum-cuts-to-divide-a-circle", "difficulty": "Easy", "problem_description": "A valid cut in a circle can be:\n\nA cut that is represented by a straight line that touches two points on the edge of the circle and passes through its center, or\nA cut that is represented by a straight line that touches one point on the edge of the circle and its center.\n\nSome valid and invalid cuts are shown in the figures below.\n\nGiven the integer n, return the minimum number of cuts needed to divide a circle into n equal slices.\n \nExample 1:\n\n\nInput: n = 4\nOutput: 2\nExplanation: \nThe above figure shows how cutting the circle twice through the middle divides it into 4 equal slices.\n\nExample 2:\n\n\nInput: n = 3\nOutput: 3\nExplanation:\nAt least 3 cuts are needed to divide the circle into 3 equal slices. \nIt can be shown that less than 3 cuts cannot result in 3 slices of equal size and shape.\nAlso note that the first cut will not divide the circle into distinct parts.\n\n \nConstraints:\n\n1 <= n <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 3\n assert candidate(n = 100) == 50\n assert candidate(n = 4) == 2\n assert candidate(n = 99) == 99\n assert candidate(n = 17) == 17\n assert candidate(n = 2) == 1\n assert candidate(n = 1) == 0\n assert candidate(n = 50) == 25\n assert candidate(n = 7) == 7\n assert candidate(n = 10) == 5\n assert candidate(n = 5) == 5\n assert candidate(n = 97) == 97\n assert candidate(n = 61) == 61\n assert candidate(n = 49) == 49\n assert candidate(n = 12) == 6\n assert candidate(n = 21) == 21\n assert candidate(n = 60) == 30\n assert candidate(n = 30) == 15\n assert candidate(n = 40) == 20\n assert candidate(n = 64) == 32\n assert candidate(n = 33) == 33\n assert candidate(n = 37) == 37\n assert candidate(n = 16) == 8\n assert candidate(n = 23) == 23\n assert candidate(n = 73) == 73\n assert candidate(n = 42) == 21\n assert candidate(n = 90) == 45\n assert candidate(n = 8) == 4\n assert candidate(n = 79) == 79\n assert candidate(n = 89) == 89\n assert candidate(n = 75) == 75\n assert candidate(n = 32) == 16\n assert candidate(n = 20) == 10\n assert candidate(n = 19) == 19\n assert candidate(n = 91) == 91\n assert candidate(n = 81) == 81\n assert candidate(n = 11) == 11\n assert candidate(n = 15) == 15\n assert candidate(n = 85) == 85\n assert candidate(n = 41) == 41\n assert candidate(n = 9) == 9\n assert candidate(n = 6) == 3\n assert candidate(n = 13) == 13\n assert candidate(n = 25) == 25\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numberOfCuts", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfCuts(int n) {", "container": "Solution", "callable": "numberOfCuts", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2482, "task_id": "difference-between-ones-and-zeros-in-row-and-column", "difficulty": "Medium", "problem_description": "You are given a 0-indexed m x n binary matrix grid.\nA 0-indexed m x n difference matrix diff is created with the following procedure:\n\nLet the number of ones in the ith row be onesRowi.\nLet the number of ones in the jth column be onesColj.\nLet the number of zeros in the ith row be zerosRowi.\nLet the number of zeros in the jth column be zerosColj.\ndiff[i][j] = onesRowi + onesColj - zerosRowi - zerosColj\n\nReturn the difference matrix diff.\n \nExample 1:\n\n\nInput: grid = [[0,1,1],[1,0,1],[0,0,1]]\nOutput: [[0,0,4],[0,0,4],[-2,-2,2]]\nExplanation:\n- diff[0][0] = onesRow0 + onesCol0 - zerosRow0 - zerosCol0 = 2 + 1 - 1 - 2 = 0 \n- diff[0][1] = onesRow0 + onesCol1 - zerosRow0 - zerosCol1 = 2 + 1 - 1 - 2 = 0 \n- diff[0][2] = onesRow0 + onesCol2 - zerosRow0 - zerosCol2 = 2 + 3 - 1 - 0 = 4 \n- diff[1][0] = onesRow1 + onesCol0 - zerosRow1 - zerosCol0 = 2 + 1 - 1 - 2 = 0 \n- diff[1][1] = onesRow1 + onesCol1 - zerosRow1 - zerosCol1 = 2 + 1 - 1 - 2 = 0 \n- diff[1][2] = onesRow1 + onesCol2 - zerosRow1 - zerosCol2 = 2 + 3 - 1 - 0 = 4 \n- diff[2][0] = onesRow2 + onesCol0 - zerosRow2 - zerosCol0 = 1 + 1 - 2 - 2 = -2\n- diff[2][1] = onesRow2 + onesCol1 - zerosRow2 - zerosCol1 = 1 + 1 - 2 - 2 = -2\n- diff[2][2] = onesRow2 + onesCol2 - zerosRow2 - zerosCol2 = 1 + 3 - 2 - 0 = 2\n\nExample 2:\n\n\nInput: grid = [[1,1,1],[1,1,1]]\nOutput: [[5,5,5],[5,5,5]]\nExplanation:\n- diff[0][0] = onesRow0 + onesCol0 - zerosRow0 - zerosCol0 = 3 + 2 - 0 - 0 = 5\n- diff[0][1] = onesRow0 + onesCol1 - zerosRow0 - zerosCol1 = 3 + 2 - 0 - 0 = 5\n- diff[0][2] = onesRow0 + onesCol2 - zerosRow0 - zerosCol2 = 3 + 2 - 0 - 0 = 5\n- diff[1][0] = onesRow1 + onesCol0 - zerosRow1 - zerosCol0 = 3 + 2 - 0 - 0 = 5\n- diff[1][1] = onesRow1 + onesCol1 - zerosRow1 - zerosCol1 = 3 + 2 - 0 - 0 = 5\n- diff[1][2] = onesRow1 + onesCol2 - zerosRow1 - zerosCol2 = 3 + 2 - 0 - 0 = 5\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 105\n1 <= m * n <= 105\ngrid[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0]]) == [[1, -1, 1, -1], [1, -1, 1, -1], [1, -1, 1, -1]]\n assert candidate(grid = [[0, 1, 1], [1, 0, 1], [0, 0, 1]]) == [[0, 0, 4], [0, 0, 4], [-2, -2, 2]]\n assert candidate(grid = [[1, 0], [0, 1]]) == [[0, 0], [0, 0]]\n assert candidate(grid = [[1]]) == [[2]]\n assert candidate(grid = [[0]]) == [[-2]]\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 0, 0]]) == [[1, 1, -1, -1], [1, 1, -1, -1], [1, 1, -1, -1]]\n assert candidate(grid = [[1, 1, 1], [1, 1, 1]]) == [[5, 5, 5], [5, 5, 5]]\n assert candidate(grid = [[0, 0, 0], [0, 0, 0]]) == [[-5, -5, -5], [-5, -5, -5]]\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]]) == [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [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, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == [[-2, -2, -4, -2, -2], [-2, -2, -4, -2, -2], [-4, -4, -6, -4, -4], [-2, -2, -4, -2, -2], [-2, -2, -4, -2, -2]]\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]]) == [[2, 2, 2, 0, 0], [0, 0, 0, -2, -2], [2, 2, 2, 0, 0], [0, 0, 0, -2, -2], [2, 2, 2, 0, 0]]\n assert candidate(grid = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 0], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0], [0, 0, 1, 1, 1]]) == [[-2, -2, 0, 0, -2], [-2, -2, 0, 0, -2], [-2, -2, 0, 0, -2], [0, 0, 2, 2, 0], [0, 0, 2, 2, 0]]\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == [[8, 4, 4, 8], [4, 0, 0, 4], [4, 0, 0, 4], [8, 4, 4, 8]]\n assert candidate(grid = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [[-5, -5, -5, -5, -5], [5, 5, 5, 5, 5], [-1, -1, -1, -1, -1], [1, 1, 1, 1, 1]]\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]]) == [[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], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [[6, 4, 6, 4, 6], [-4, -6, -4, -6, -4], [2, 0, 2, 0, 2], [0, -2, 0, -2, 0], [2, 0, 2, 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]]) == [[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, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1], [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]]) == [[-6, -6, -6, 0, 0, 0, -6, -6, -6], [-6, -6, -6, 0, 0, 0, -6, -6, -6], [-6, -6, -6, 0, 0, 0, -6, -6, -6], [0, 0, 0, 6, 6, 6, 0, 0, 0], [0, 0, 0, 6, 6, 6, 0, 0, 0], [0, 0, 0, 6, 6, 6, 0, 0, 0], [-6, -6, -6, 0, 0, 0, -6, -6, -6], [-6, -6, -6, 0, 0, 0, -6, -6, -6], [-6, -6, -6, 0, 0, 0, -6, -6, -6]]\n assert candidate(grid = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == [[-5, -5, -5, -5, -5], [5, 5, 5, 5, 5], [-5, -5, -5, -5, -5], [5, 5, 5, 5, 5]]\n assert candidate(grid = [[1, 0, 0, 1], [1, 1, 0, 0], [0, 0, 1, 1], [0, 1, 1, 0]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n assert candidate(grid = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 1, 0, 1, 1]]) == [[-1, -1, -1, 1, -1], [1, 1, 1, 3, 1], [1, 1, 1, 3, 1], [1, 1, 1, 3, 1]]\n assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 0, 0], [1, 1, 1, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [-4, -4, -4, -4], [4, 4, 4, 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]]) == [[-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(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == [[2, 2, 2, 2, 2, 2], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [-2, -2, -2, -2, -2, -2], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]\n assert candidate(grid = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0], [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]]\n assert candidate(grid = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1], [0, 1, 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]]\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]]) == [[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(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 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(grid = [[1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 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(grid = [[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 1]]) == [[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, 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]]) == [[-12, -4, -8, -8, -4, -12], [-4, 4, 0, 0, 4, -4], [-8, 0, -4, -4, 0, -8], [-8, 0, -4, -4, 0, -8], [-4, 4, 0, 0, 4, -4], [-12, -4, -8, -8, -4, -12]]\n assert candidate(grid = [[1, 0, 0, 1], [0, 1, 1, 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]]\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [[-2, 0, -2, 0, -2], [0, 2, 0, 2, 0], [-2, 0, -2, 0, -2]]\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0]]) == [[1, 1, 1], [-1, -1, -1], [1, 1, 1], [-1, -1, -1]]\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]]) == [[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(grid = [[1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 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]]\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, 1, 1, 1]]) == [[2, 2, 2, 2, 2], [0, 0, 0, 0, 0], [2, 2, 2, 2, 2], [0, 0, 0, 0, 0], [6, 6, 6, 6, 6]]\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n assert candidate(grid = [[0, 1, 0, 1, 1], [1, 0, 1, 0, 0], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0]]) == [[1, 1, 1, 1, 1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [1, 1, 1, 1, 1]]\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == [[-7, -7, -7, -7], [-7, -7, -7, -7], [-7, -7, -7, -7]]\n assert candidate(grid = [[1, 1, 0, 0, 1], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0]]) == [[2, 2, 2, 0, 2], [2, 2, 2, 0, 2], [2, 2, 2, 0, 2], [0, 0, 0, -2, 0], [2, 2, 2, 0, 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, 1, 1, 1, 1], [-1, -1, -1, -1, -1], [1, 1, 1, 1, 1], [-1, -1, -1, -1, -1]]\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[-9, -9, -9, -9, -9], [-9, -9, -9, -9, -9], [-9, -9, -9, -9, -9], [-9, -9, -9, -9, -9]]\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, 1, 1, 1, 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(grid = [[0, 0, 1, 1], [1, 0, 0, 1], [1, 1, 0, 0]]) == [[1, -1, -1, 1], [1, -1, -1, 1], [1, -1, -1, 1]]\n assert candidate(grid = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [0, 0, 0, 0, 0]]) == [[0, 0, 0, 0, 0], [-2, -2, -2, -2, -2], [-2, -2, -2, -2, -2], [0, 0, 0, 0, 0], [-6, -6, -6, -6, -6]]\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == [[5, 5, 5, 5, 5], [-5, -5, -5, -5, -5], [5, 5, 5, 5, 5], [-5, -5, -5, -5, -5]]\n assert candidate(grid = [[0, 0, 0, 1], [1, 1, 1, 0], [0, 1, 0, 1]]) == [[-3, -1, -3, -1], [1, 3, 1, 3], [-1, 1, -1, 1]]\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == [[-4, -4, -4, -4], [-4, -4, -4, -4], [-4, -4, -4, -4], [-4, -4, -4, -4]]\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n assert candidate(grid = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 1, 0, 1], [0, 1, 0, 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(grid = [[1, 1, 0, 0, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 1, 0], [1, 0, 0, 1, 1]]) == [[2, 0, 0, 2, 2], [2, 0, 0, 2, 2], [0, -2, -2, 0, 0], [0, -2, -2, 0, 0], [2, 0, 0, 2, 2]]\n assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\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]]) == [[-3, 1, 1, -3, 1, 1, -3], [-1, 3, 3, -1, 3, 3, -1], [-1, 3, 3, -1, 3, 3, -1], [-3, 1, 1, -3, 1, 1, -3], [-1, 3, 3, -1, 3, 3, -1], [-1, 3, 3, -1, 3, 3, -1]]\n assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == [[-1, 1, -1, 1], [-1, 1, -1, 1], [-1, 1, -1, 1]]\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 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]]) == [[-1, -1, -1, -1, -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(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]]) == [[0, 0, 0, 0, 0, 0, 0, 0], [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, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 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(grid = [[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1]]) == [[-4, -4, -6, -6, -4, -4], [-4, -4, -6, -6, -4, -4], [-6, -6, -8, -8, -6, -6], [-6, -6, -8, -8, -6, -6], [-4, -4, -6, -6, -4, -4], [-4, -4, -6, -6, -4, -4]]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == [[8, 8, 8, 8], [8, 8, 8, 8], [8, 8, 8, 8], [8, 8, 8, 8]]\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [[2, 0, 2, 0, 2], [0, -2, 0, -2, 0], [2, 0, 2, 0, 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]]) == [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]\n assert candidate(grid = [[0, 0, 1, 1, 0], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1]]) == [[-2, -2, 0, 0, -2], [-2, -2, 0, 0, -2], [0, 0, 2, 2, 0], [-2, -2, 0, 0, -2], [0, 0, 2, 2, 0]]\n assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 0, 1], [1, 1, 1, 1]]) == [[0, 0, 0, 2], [0, 0, 0, 2], [-2, -2, -2, 0], [4, 4, 4, 6]]\n assert candidate(grid = [[1, 0, 1, 1, 0], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1]]) == [[2, 0, 2, 2, 0], [0, -2, 0, 0, -2], [2, 0, 2, 2, 0], [0, -2, 0, 0, -2], [2, 0, 2, 2, 0]]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().onesMinusZeros", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] onesMinusZeros(int[][] grid) {", "container": "Solution", "callable": "onesMinusZeros", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2483, "task_id": "minimum-penalty-for-a-shop", "difficulty": "Medium", "problem_description": "You are given the customer visit log of a shop represented by a 0-indexed string customers consisting only of characters 'N' and 'Y':\n\nif the ith character is 'Y', it means that customers come at the ith hour\nwhereas 'N' indicates that no customers come at the ith hour.\n\nIf the shop closes at the jth hour (0 <= j <= n), the penalty is calculated as follows:\n\nFor every hour when the shop is open and no customers come, the penalty increases by 1.\nFor every hour when the shop is closed and customers come, the penalty increases by 1.\n\nReturn the earliest hour at which the shop must be closed to incur a minimum penalty.\nNote that if a shop closes at the jth hour, it means the shop is closed at the hour j.\n \nExample 1:\n\nInput: customers = \"YYNY\"\nOutput: 2\nExplanation: \n- Closing the shop at the 0th hour incurs in 1+1+0+1 = 3 penalty.\n- Closing the shop at the 1st hour incurs in 0+1+0+1 = 2 penalty.\n- Closing the shop at the 2nd hour incurs in 0+0+0+1 = 1 penalty.\n- Closing the shop at the 3rd hour incurs in 0+0+1+1 = 2 penalty.\n- Closing the shop at the 4th hour incurs in 0+0+1+0 = 1 penalty.\nClosing the shop at 2nd or 4th hour gives a minimum penalty. Since 2 is earlier, the optimal closing time is 2.\n\nExample 2:\n\nInput: customers = \"NNNNN\"\nOutput: 0\nExplanation: It is best to close the shop at the 0th hour as no customers arrive.\nExample 3:\n\nInput: customers = \"YYYY\"\nOutput: 4\nExplanation: It is best to close the shop at the 4th hour as customers arrive at each hour.\n\n \nConstraints:\n\n1 <= customers.length <= 105\ncustomers consists only of characters 'Y' and 'N'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(customers = \"YNYNYN\") == 1\n assert candidate(customers = \"YNNYNYYNYN\") == 1\n assert candidate(customers = \"NNYNNYNNYNNYNN\") == 0\n assert candidate(customers = \"YYYYNNYYYYNNYYYYNNYYYYNNNN\") == 22\n assert candidate(customers = \"YNYYYYYYNY\") == 8\n assert candidate(customers = \"YNYYYYNNYY\") == 6\n assert candidate(customers = \"NYYNNYNY\") == 3\n assert candidate(customers = \"YNYNNYNYYN\") == 1\n assert candidate(customers = \"NYYYYYNNNYYYYYYYYYYNNNNN\") == 19\n assert candidate(customers = \"YNYNYNYNYN\") == 1\n assert candidate(customers = \"YNYNYNYNYNYN\") == 1\n assert candidate(customers = \"NNNNN\") == 0\n assert candidate(customers = \"YYYYYYYYYY\") == 10\n assert candidate(customers = \"YYYYYYYYYYYY\") == 12\n assert candidate(customers = \"NNNNNNNNNNNN\") == 0\n assert candidate(customers = \"NNYNNYNYN\") == 0\n assert candidate(customers = \"NYNNNNNNYN\") == 0\n assert candidate(customers = \"NNNNNNNNNN\") == 0\n assert candidate(customers = \"YYNY\") == 2\n assert candidate(customers = \"YYYYNNNNYYYY\") == 4\n assert candidate(customers = \"NYYNNYNYNNY\") == 3\n assert candidate(customers = \"NYNYNYNYNYNY\") == 0\n assert candidate(customers = \"NYNYNYNYNY\") == 0\n assert candidate(customers = \"YYYY\") == 4\n assert candidate(customers = \"YNYYYYYYNYYN\") == 11\n assert candidate(customers = \"YNNYYNYY\") == 8\n assert candidate(customers = \"YYYYYNNNNNYYYYYY\") == 16\n assert candidate(customers = \"YNNYNYY\") == 1\n assert candidate(customers = \"NNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"YYYYNNYNNYNNYNNY\") == 4\n assert candidate(customers = \"NNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYY\") == 46\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNN\") == 48\n assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNY\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYY\") == 20\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYY\") == 0\n assert candidate(customers = \"NYNYNYNYNNYNNYNN\") == 0\n assert candidate(customers = \"YYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYY\") == 6\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNNNN\") == 94\n assert candidate(customers = \"YNYYYYYYYYNYNYYYYYYYYNYNYYYYYYYYNYNYYYYYYYYNYNYYYYYYYY\") == 54\n assert candidate(customers = \"YYNNYNYNYNYNYNYNYNYN\") == 2\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"NYNNYYNYNNYYNYNNYYNY\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 94\n assert candidate(customers = \"YYYYNNYYYNYYNNYYNNYYNYNNYYNYNYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNYNYNYNNYYNNYYNNYYNNYYNYNYNYNNYYNNYYNNYYNNYYNYNYNY\") == 12\n assert candidate(customers = \"YYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNN\") == 2\n assert candidate(customers = \"YYYYYNNNNNYYYYYNNNNNYYYYYNNNNNYYYYYNNNNN\") == 5\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNN\") == 94\n assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 0\n assert candidate(customers = \"YNNYNYYNYYNNYNNYNYYN\") == 10\n assert candidate(customers = \"YYYYYNNYYYYNNYYY\") == 16\n assert candidate(customers = \"YYNNYYNNYYNNYY\") == 2\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 92\n assert candidate(customers = \"NYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 94\n assert candidate(customers = \"YYYYYYYYYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYY\") == 10\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"YYNYYNYNYYNNYY\") == 10\n assert candidate(customers = \"NYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYY\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYY\") == 16\n assert candidate(customers = \"NYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNY\") == 78\n assert candidate(customers = \"NYNYNYNYNYNYNYNY\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 88\n assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 1\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNN\") == 94\n assert candidate(customers = \"YYYYNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNY\") == 4\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"YYYYNNNNYYYYNNNN\") == 4\n assert candidate(customers = \"YYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYY\") == 41\n assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYN\") == 1\n assert candidate(customers = \"NYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYY\") == 3\n assert candidate(customers = \"NNNNNYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 94\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYY\") == 20\n assert candidate(customers = \"YYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYY\") == 2\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNN\") == 94\n assert candidate(customers = \"NYNYNNYNYNYNYNNYNYNNYNYNYNNYNYNNYNYNNYNY\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 64\n assert candidate(customers = \"NYNYNYNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNY\") == 0\n assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNNYYYN\") == 41\n assert candidate(customers = \"NYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYN\") == 93\n assert candidate(customers = \"NYNNYNYNNYNYNNYNYNNYNYNNYNYNNYNYNNYNYNNYNYNNYNYNNYNYNNYN\") == 0\n assert candidate(customers = \"NNNNNNNNYYYYYYYY\") == 0\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"NNYNNYNNYNNYNNYY\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNN\") == 52\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 44\n assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNNNNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"NNYYNNNNYYNNYYYYNYYY\") == 20\n assert candidate(customers = \"NYNNYNYYNNYNYYNNYNYYNNYNYYNNYNYYNNYNYYNN\") == 0\n assert candidate(customers = \"NNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNN\") == 0\n assert candidate(customers = \"YNNYYNYYNNYYNYYNNYYNYYNNYYNYYNNYYNYYNNYYNYYNN\") == 43\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNN\") == 94\n assert candidate(customers = \"NNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNN\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 104\n assert candidate(customers = \"YYYYYNNNNNNNNNNN\") == 5\n assert candidate(customers = \"YYYYYNNYNYNYNYNN\") == 5\n assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 1\n assert candidate(customers = \"NNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNN\") == 0\n assert candidate(customers = \"YYYYYYYYYYNNNNNNNN\") == 10\n assert candidate(customers = \"YYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYY\") == 6\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"YYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNNY\") == 2\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYYYYYYYY\") == 0\n assert candidate(customers = \"YYYYNNYYYNYYYYNNYYYNYYYYNNYYYNYYYYNNYYYNYYYYNNYYYNYYYY\") == 54\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"YYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNN\") == 2\n assert candidate(customers = \"YYYYNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 108\n assert candidate(customers = \"YYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYYYYY\") == 96\n assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 0\n assert candidate(customers = \"YNYNYNYNYNYNYNYN\") == 1\n assert candidate(customers = \"NYNYYNNYNYNYYNNYNYNY\") == 5\n assert candidate(customers = \"NNYNYNYNYNYNYNYN\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 54\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNN\") == 94\n assert candidate(customers = \"YYNNYYYYYYNNYYYYYYNNYYYYYYNNYYYYYYNNYYYYYY\") == 42\n assert candidate(customers = \"NYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNY\") == 39\n assert candidate(customers = \"NNNNNYYYYYYYNNNN\") == 12\n assert candidate(customers = \"YYYYYNNNNYYYYYYYYYNNNNNNNYYYYYYYYYNNNNNYYY\") == 34\n assert candidate(customers = \"YYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNN\") == 10\n assert candidate(customers = \"YNNNNYNNYNYNYNYNNYNNYNNYNYNNYNNYNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNY\") == 1\n assert candidate(customers = \"YYNYNYNYNYNNYNNY\") == 2\n assert candidate(customers = \"NYYYYYYYYYNNNNNNNNNN\") == 10\n assert candidate(customers = \"NNNNNNYYYYYYYYYYYYYY\") == 20\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNNNNNN\") == 94\n assert candidate(customers = \"NNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYY\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 40\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNN\") == 94\n assert candidate(customers = \"YYNNYYNNYYNN\") == 2\n assert candidate(customers = \"NNYNYNYNYNYNYNNY\") == 0\n assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYN\") == 1\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNN\") == 94\n assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 1\n assert candidate(customers = \"YYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNN\") == 10\n assert candidate(customers = \"NYYYYYYYYYYYNN\") == 12\n assert candidate(customers = \"NNYYYYNNYYYYNNYYYYNNYYYYNNYYYYNNYYYYNNYYYY\") == 42\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNN\") == 94\n assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYN\") == 1\n assert candidate(customers = \"NNNNYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 24\n assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 1\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"YYYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYY\") == 4\n assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 0\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNN\") == 88\n assert candidate(customers = \"YYYNYYNYYYNYYNNYYYYNYYYYNYNYNYYYYYYYYYYYYNNNYNYNYYNNYNN\") == 41\n assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 70\n assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n assert candidate(customers = \"NNNNNNNNNYYYYYYYYYYNNNNNNNNNYYYYYYYYYYNNNNNNNNNYYYYYYYYYYNNNNNNNNNYYYYYYYYYY\") == 76\n assert candidate(customers = \"YYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYY\") == 2\n assert candidate(customers = \"NYNNNYNNNYNNNY\") == 0\n assert candidate(customers = \"NYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNNYY\") == 39\n assert candidate(customers = \"NNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNN\") == 0\n assert candidate(customers = \"YYYYYYYYYYNNNNNNNNNN\") == 10\n assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYYYYYYYY\") == 0\n"}, "metadata": {"canonical_parameter_names": ["customers"], "leetcode_dataset_entry_point": "Solution().bestClosingTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int bestClosingTime(String customers) {", "container": "Solution", "callable": "bestClosingTime", "parameters": [{"name": "customers", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2484, "task_id": "count-palindromic-subsequences", "difficulty": "Hard", "problem_description": "Given a string of digits s, return the number of palindromic subsequences of s having length 5. Since the answer may be very large, return it modulo 109 + 7.\nNote:\n\nA string is palindromic if it reads the same forward and backward.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n\n \nExample 1:\n\nInput: s = \"103301\"\nOutput: 2\nExplanation: \nThere are 6 possible subsequences of length 5: \"10330\",\"10331\",\"10301\",\"10301\",\"13301\",\"03301\". \nTwo of them (both equal to \"10301\") are palindromic.\n\nExample 2:\n\nInput: s = \"0000000\"\nOutput: 21\nExplanation: All 21 subsequences are \"00000\", which is palindromic.\n\nExample 3:\n\nInput: s = \"9999900000\"\nOutput: 2\nExplanation: The only two palindromic subsequences are \"99999\" and \"00000\".\n\n \nConstraints:\n\n1 <= s.length <= 104\ns consists of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"100100100\") == 34\n assert candidate(s = \"9876543210\") == 0\n assert candidate(s = \"54321012345\") == 30\n assert candidate(s = \"12345678900987654321\") == 240\n assert candidate(s = \"00000000000000000000\") == 15504\n assert candidate(s = \"122112211\") == 33\n assert candidate(s = \"1234567890\") == 0\n assert candidate(s = \"123454321\") == 14\n assert candidate(s = \"0000000\") == 21\n assert candidate(s = \"103301\") == 2\n assert candidate(s = \"98765432100123456789\") == 240\n assert candidate(s = \"1234321234321\") == 109\n assert candidate(s = \"1111111111\") == 252\n assert candidate(s = \"0123456789\") == 0\n assert candidate(s = \"012343210\") == 14\n assert candidate(s = \"1232123212\") == 39\n assert candidate(s = \"1001001001\") == 80\n assert candidate(s = \"5555555555\") == 252\n assert candidate(s = \"1010101010\") == 68\n assert candidate(s = \"1221221221\") == 80\n assert candidate(s = \"1234567890987654321\") == 204\n assert candidate(s = \"0101010101\") == 68\n assert candidate(s = \"1212121212\") == 68\n assert candidate(s = \"9999900000\") == 2\n assert candidate(s = \"000000111111000000\") == 2868\n assert candidate(s = \"123454321123454321\") == 364\n assert candidate(s = \"1234567898765432123456789876543212345678987654321\") == 24502\n assert candidate(s = \"22233322233322233322\") == 3990\n assert candidate(s = \"54321098765432109876543210987654321054321\") == 7758\n assert candidate(s = \"1122334455667788998877665544332211\") == 5056\n assert candidate(s = \"98765432112345678998765432100\") == 672\n assert candidate(s = \"89098098098098098098\") == 1848\n assert candidate(s = \"12345678901234567890123456789012345678901234567890\") == 18100\n assert candidate(s = \"1232123212321232123212321\") == 7180\n assert candidate(s = \"12345543211234554321\") == 580\n assert candidate(s = \"12345123451234512345123451234512345\") == 12425\n assert candidate(s = \"10101010101010101010101010\") == 16588\n assert candidate(s = \"987654321012345678909876543210123456789\") == 5433\n assert candidate(s = \"90123456789012345678901234567890123456789\") == 6346\n assert candidate(s = \"010101010101010101\") == 2184\n assert candidate(s = \"098765432109876543210987654321098765432109876543210\") == 21210\n assert candidate(s = \"1234567898765432121234567898765432121\") == 5455\n assert candidate(s = \"112233445544332211\") == 576\n assert candidate(s = \"987654321000123456789\") == 285\n assert candidate(s = \"987654321000000000000000000000000000000009876543210\") == 281976\n assert candidate(s = \"987654321098765432109876543210987654321098765432109876543210\") == 49200\n assert candidate(s = \"1122334455443322112233445544332211\") == 12024\n assert candidate(s = \"0000011111222223333344444555554444433333222221111100000\") == 138761\n assert candidate(s = \"987654321123456789876543210011223344556677889987654321\") == 31546\n assert candidate(s = \"98765432101234567898\") == 253\n assert candidate(s = \"10101010101010101010101\") == 8701\n assert candidate(s = \"5555555555555555555555555555555555555555\") == 658008\n assert candidate(s = \"01020304050607080901\") == 918\n assert candidate(s = \"123456789098765432101234567890\") == 978\n assert candidate(s = \"123456789000000000987654321\") == 1374\n assert candidate(s = \"1234567890123456789012345678901234567890\") == 5040\n assert candidate(s = \"000111222333444555444333222111000\") == 9840\n assert candidate(s = \"999888777666555444333222111000\") == 0\n assert candidate(s = \"99999000001111122222333334444455555444443333322222111110000099999\") == 237888\n assert candidate(s = \"11223344556677889900998877665544332211\") == 7266\n assert candidate(s = \"111111111111111111111111111111111111111111111111111\") == 2349060\n assert candidate(s = \"00000100001000010000100000\") == 37118\n assert candidate(s = \"111000111000111000111000111000111\") == 61584\n assert candidate(s = \"99999888887777766666555554444433333222221111100000\") == 10\n assert candidate(s = \"9876543210012345678998765432100123456789\") == 5910\n assert candidate(s = \"1234567898765432112345678987654321\") == 3320\n assert candidate(s = \"12211221122112211\") == 1574\n assert candidate(s = \"543210000012345\") == 121\n assert candidate(s = \"12211221122112211221\") == 3916\n assert candidate(s = \"67890098766789009876\") == 580\n assert candidate(s = \"9876543210987654321098765432109876543210\") == 5040\n assert candidate(s = \"1111100000111110000011111000001111100000\") == 146008\n assert candidate(s = \"98765432101234567899876543210123456789\") == 4794\n assert candidate(s = \"00000111110000011111\") == 2004\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010\") == 3501456\n assert candidate(s = \"111222333222111222333\") == 1470\n assert candidate(s = \"00000000001111111111000000000\") == 38880\n assert candidate(s = \"111110000000000000000000000000000000000000000000000\") == 1370755\n assert candidate(s = \"123456789876543210123456789\") == 624\n assert candidate(s = \"1234543216789876123454321\") == 942\n assert candidate(s = \"9876543210012345678998765432100123456789987654321\") == 17193\n assert candidate(s = \"11001100110011001100\") == 3656\n assert candidate(s = \"11100011100011100011\") == 3990\n assert candidate(s = \"99999000009999900000\") == 2004\n assert candidate(s = \"10010010010010010010\") == 4535\n assert candidate(s = \"11112222333322221111\") == 2736\n assert candidate(s = \"1232112321123211232112321123211232112321\") == 85128\n assert candidate(s = \"987654321987654321987654321\") == 576\n assert candidate(s = \"121212121212121212121212121212121212121212121212\") == 429088\n assert candidate(s = \"12345678909876543211234567890987654321\") == 4794\n assert candidate(s = \"1221122112211\") == 331\n assert candidate(s = \"99999888887777766666\") == 4\n assert candidate(s = \"123456789012345678901234567890123456789012345678901234567890\") == 49200\n assert candidate(s = \"111222333444555444333222111\") == 4974\n assert candidate(s = \"123454321123454321123454321\") == 3470\n assert candidate(s = \"0123456789876543210123456789876543210\") == 4385\n assert candidate(s = \"99999999999999999\") == 6188\n assert candidate(s = \"567899876567899876\") == 324\n assert candidate(s = \"000111222333444555666777888999888777666555444333222111000\") == 58374\n assert candidate(s = \"001122334455667788990000000000000000000000000000\") == 149310\n assert candidate(s = \"555555555555555555555555555\") == 80730\n assert candidate(s = \"1232123212321232123212321232123212321232\") == 91158\n assert candidate(s = \"543210123456789876543210\") == 399\n assert candidate(s = \"123211232112321123211232112321\") == 18456\n assert candidate(s = \"123456789098765432101234567890987654321\") == 5433\n assert candidate(s = \"90909090909090909090\") == 3936\n assert candidate(s = \"000011110000111100001111\") == 8368\n assert candidate(s = \"12345678909876543210\") == 204\n assert candidate(s = \"10101010101010101010101010101010101010101\") == 189202\n assert candidate(s = \"123456789098765432121234567890\") == 995\n assert candidate(s = \"987654321012345678987654321\") == 624\n assert candidate(s = \"10101010101010101\") == 1652\n assert candidate(s = \"0000000000111111111122222222223333333333\") == 1008\n assert candidate(s = \"11223344556677889998877665544332211\") == 5544\n assert candidate(s = \"55555555555555555555\") == 15504\n assert candidate(s = \"123456789987654321123456789\") == 672\n assert candidate(s = \"123321123321123321\") == 946\n assert candidate(s = \"10101010101010101010101010101010\") == 50624\n assert candidate(s = \"1001001001001001001001001\") == 15330\n assert candidate(s = \"01234567899876543210\") == 240\n assert candidate(s = \"123456789876543210000000000000000000\") == 11768\n assert candidate(s = \"1111222233334444555566667777888899990000\") == 0\n assert candidate(s = \"12345678987654321012345678987654321\") == 3568\n assert candidate(s = \"54321234554321234554\") == 698\n assert candidate(s = \"999999000000999999000000999999000000999999\") == 227796\n assert candidate(s = \"12345678900987654321001234567890\") == 1528\n assert candidate(s = \"90807060505060708090\") == 1254\n assert candidate(s = \"123454321123454321123454321123454321\") == 16368\n assert candidate(s = \"0123456789876543210123456789\") == 688\n assert candidate(s = \"98765432101020304050607080908070605040302010\") == 33248\n assert candidate(s = \"12345432112345432112\") == 698\n assert candidate(s = \"1001001001001001001001001001001001001001001001001\") == 564020\n assert candidate(s = \"00112233445566778899\") == 0\n assert candidate(s = \"987654321000000000000000000000000000123456789\") == 108195\n assert candidate(s = \"34554334554334554334\") == 1720\n assert candidate(s = \"100000000000000000000000000000000000000001\") == 667888\n assert candidate(s = \"1234567890098765432112345678900987654321\") == 5910\n assert candidate(s = \"01010101010101010101\") == 3936\n assert candidate(s = \"12345678900987654321000123456789\") == 1645\n assert candidate(s = \"00000111112222233333444445555566666777778888899999\") == 10\n assert candidate(s = \"010101010101010\") == 819\n assert candidate(s = \"10101010101010101010\") == 3936\n assert candidate(s = \"12345678901234567890123456789012345678901234567890123456789\") == 46090\n assert candidate(s = \"9876543210012345678909876543210\") == 1230\n assert candidate(s = \"54321098765432109876543210987654321\") == 2925\n assert candidate(s = \"000000000000000000000000000000000000000000000000001\") == 2118760\n assert candidate(s = \"111222333444555666777888999000999888777666555444333222111\") == 58374\n assert candidate(s = \"0123456789876543210\") == 204\n assert candidate(s = \"20202020202020202020\") == 3936\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countPalindromes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countPalindromes(String s) {", "container": "Solution", "callable": "countPalindromes", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2485, "task_id": "find-the-pivot-integer", "difficulty": "Easy", "problem_description": "Given a positive integer n, find the pivot integer x such that:\n\nThe sum of all elements between 1 and x inclusively equals the sum of all elements between x and n inclusively.\n\nReturn the pivot integer x. If no such integer exists, return -1. It is guaranteed that there will be at most one pivot index for the given input.\n \nExample 1:\n\nInput: n = 8\nOutput: 6\nExplanation: 6 is the pivot integer since: 1 + 2 + 3 + 4 + 5 + 6 = 6 + 7 + 8 = 21.\n\nExample 2:\n\nInput: n = 1\nOutput: 1\nExplanation: 1 is the pivot integer since: 1 = 1.\n\nExample 3:\n\nInput: n = 4\nOutput: -1\nExplanation: It can be proved that no such integer exist.\n\n \nConstraints:\n\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 6\n assert candidate(n = 3) == -1\n assert candidate(n = 4) == -1\n assert candidate(n = 1) == 1\n assert candidate(n = 1000) == -1\n assert candidate(n = 10) == -1\n assert candidate(n = 625) == -1\n assert candidate(n = 576) == -1\n assert candidate(n = 729) == -1\n assert candidate(n = 144) == -1\n assert candidate(n = 49) == 35\n assert candidate(n = 12) == -1\n assert candidate(n = 900) == -1\n assert candidate(n = 324) == -1\n assert candidate(n = 100) == -1\n assert candidate(n = 50) == -1\n assert candidate(n = 5) == -1\n assert candidate(n = 841) == -1\n assert candidate(n = 289) == -1\n assert candidate(n = 550) == -1\n assert candidate(n = 99) == -1\n assert candidate(n = 64) == -1\n assert candidate(n = 17) == -1\n assert candidate(n = 484) == -1\n assert candidate(n = 2) == -1\n assert candidate(n = 225) == -1\n assert candidate(n = 784) == -1\n assert candidate(n = 250) == -1\n assert candidate(n = 999) == -1\n assert candidate(n = 35) == -1\n assert candidate(n = 169) == -1\n assert candidate(n = 75) == -1\n assert candidate(n = 256) == -1\n assert candidate(n = 36) == -1\n assert candidate(n = 529) == -1\n assert candidate(n = 20) == -1\n assert candidate(n = 676) == -1\n assert candidate(n = 81) == -1\n assert candidate(n = 48) == -1\n assert candidate(n = 325) == -1\n assert candidate(n = 15) == -1\n assert candidate(n = 441) == -1\n assert candidate(n = 961) == -1\n assert candidate(n = 400) == -1\n assert candidate(n = 196) == -1\n assert candidate(n = 9) == -1\n assert candidate(n = 121) == -1\n assert candidate(n = 361) == -1\n assert candidate(n = 700) == -1\n assert candidate(n = 500) == -1\n assert candidate(n = 7) == -1\n assert candidate(n = 25) == -1\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().pivotInteger", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int pivotInteger(int n) {", "container": "Solution", "callable": "pivotInteger", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2486, "task_id": "append-characters-to-string-to-make-subsequence", "difficulty": "Medium", "problem_description": "You are given two strings s and t consisting of only lowercase English letters.\nReturn the minimum number of characters that need to be appended to the end of s so that t becomes a subsequence of s.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n \nExample 1:\n\nInput: s = \"coaching\", t = \"coding\"\nOutput: 4\nExplanation: Append the characters \"ding\" to the end of s so that s = \"coachingding\".\nNow, t is a subsequence of s (\"coachingding\").\nIt can be shown that appending any 3 characters to the end of s will never make t a subsequence.\n\nExample 2:\n\nInput: s = \"abcde\", t = \"a\"\nOutput: 0\nExplanation: t is already a subsequence of s (\"abcde\").\n\nExample 3:\n\nInput: s = \"z\", t = \"abcde\"\nOutput: 5\nExplanation: Append the characters \"abcde\" to the end of s so that s = \"zabcde\".\nNow, t is a subsequence of s (\"zabcde\").\nIt can be shown that appending any 4 characters to the end of s will never make t a subsequence.\n\n \nConstraints:\n\n1 <= s.length, t.length <= 105\ns and t consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefgh\",t = \"ghijkl\") == 4\n assert candidate(s = \"ababab\",t = \"bbba\") == 1\n assert candidate(s = \"abcd\",t = \"xyz\") == 3\n assert candidate(s = \"aaaa\",t = \"a\") == 0\n assert candidate(s = \"abcd\",t = \"dbca\") == 3\n assert candidate(s = \"aabbcc\",t = \"abc\") == 0\n assert candidate(s = \"aaaaa\",t = \"a\") == 0\n assert candidate(s = \"abcd\",t = \"abcde\") == 1\n assert candidate(s = \"ababab\",t = \"bbbb\") == 1\n assert candidate(s = \"ab\",t = \"abc\") == 1\n assert candidate(s = \"abcdefgh\",t = \"efghij\") == 2\n assert candidate(s = \"hello\",t = \"oleh\") == 3\n assert candidate(s = \"abcd\",t = \"\") == 0\n assert candidate(s = \"abcde\",t = \"a\") == 0\n assert candidate(s = \"abcd\",t = \"abdc\") == 1\n assert candidate(s = \"abcd\",t = \"abcd\") == 0\n assert candidate(s = \"z\",t = \"abcde\") == 5\n assert candidate(s = \"\",t = \"abc\") == 3\n assert candidate(s = \"abcabc\",t = \"abc\") == 0\n assert candidate(s = \"hello\",t = \"ole\") == 2\n assert candidate(s = \"abcdefgh\",t = \"efgh\") == 0\n assert candidate(s = \"a\",t = \"b\") == 1\n assert candidate(s = \"coaching\",t = \"coding\") == 4\n assert candidate(s = \"abc\",t = \"\") == 0\n assert candidate(s = \"xyz\",t = \"xyza\") == 1\n assert candidate(s = \"xyz\",t = \"xyz\") == 0\n assert candidate(s = \"\",t = \"abcd\") == 4\n assert candidate(s = \"abcd\",t = \"efgh\") == 4\n assert candidate(s = \"aaaa\",t = \"aa\") == 0\n assert candidate(s = \"complex\",t = \"cmpx\") == 0\n assert candidate(s = \"abcabcabcabcabcabc\",t = \"abcabcabcabcabcd\") == 1\n assert candidate(s = \"thisisaverylongstring\",t = \"thisstring\") == 0\n assert candidate(s = \"hellothere\",t = \"lohere\") == 0\n assert candidate(s = \"ababababab\",t = \"bababa\") == 0\n assert candidate(s = \"xyzxyzxyzxyzxyz\",t = \"xyzyzyzyzyzyzyz\") == 4\n assert candidate(s = \"abcdabcdabcd\",t = \"dcba\") == 1\n assert candidate(s = \"abcabcabcabc\",t = \"abacaba\") == 0\n assert candidate(s = \"thefastbrownfoxjumpsoverthelazydog\",t = \"quickbrownfox\") == 13\n assert candidate(s = \"abcdefghijk\",t = \"acegik\") == 0\n assert candidate(s = \"abcde\",t = \"cbad\") == 3\n assert candidate(s = \"abracadabra\",t = \"bracadabr\") == 0\n assert candidate(s = \"longstringwithvariouscharacters\",t = \"string\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 24\n assert candidate(s = \"sequence\",t = \"subsequence\") == 9\n assert candidate(s = \"abcabcabcabc\",t = \"cccc\") == 0\n assert candidate(s = \"longerstring\",t = \"string\") == 0\n assert candidate(s = \"aaaabbbbcccc\",t = \"abcabc\") == 3\n assert candidate(s = \"abcdef\",t = \"fghijk\") == 5\n assert candidate(s = \"abcdef\",t = \"defghijk\") == 5\n assert candidate(s = \"abcdexyz\",t = \"dezy\") == 1\n assert candidate(s = \"xyzxyzxyz\",t = \"zyxzyxzyx\") == 5\n assert candidate(s = \"abababababababab\",t = \"abab\") == 0\n assert candidate(s = \"kglvkyeavnnrdq\",t = \"lky\") == 0\n assert candidate(s = \"abcabcabcabc\",t = \"abcdabcdabcd\") == 9\n assert candidate(s = \"abcdefghij\",t = \"hijjiklmn\") == 6\n assert candidate(s = \"overlaplaplap\",t = \"laplaplaplap\") == 3\n assert candidate(s = \"xyxyxyxyxy\",t = \"xyyx\") == 0\n assert candidate(s = \"hello\",t = \"heoo\") == 1\n assert candidate(s = \"abcde\",t = \"edcba\") == 4\n assert candidate(s = \"randomstring\",t = \"stringrandom\") == 6\n assert candidate(s = \"\",t = \"a\") == 1\n assert candidate(s = \"mississippi\",t = \"pis\") == 1\n assert candidate(s = \"abcdabcdabcd\",t = \"abcabcabc\") == 0\n assert candidate(s = \"sequencealignment\",t = \"seqaln\") == 0\n assert candidate(s = \"testtesttest\",t = \"testset\") == 0\n assert candidate(s = \"mississippi\",t = \"pippi\") == 3\n assert candidate(s = \"mississippi\",t = \"issip\") == 0\n assert candidate(s = \"sequencealignment\",t = \"quencal\") == 0\n assert candidate(s = \"\",t = \"\") == 0\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 9\n assert candidate(s = \"programming\",t = \"gram\") == 0\n assert candidate(s = \"abcdef\",t = \"fedcba\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"xyzuvw\") == 3\n assert candidate(s = \"abacabadabacaba\",t = \"abcd\") == 0\n assert candidate(s = \"mississippi\",t = \"issi\") == 0\n assert candidate(s = \"aaaaabbbbbcccccdddddeeeee\",t = \"abcde\") == 0\n assert candidate(s = \"longstringwithrandomcharacters\",t = \"lgrmc\") == 0\n assert candidate(s = \"zzzzzzzzzz\",t = \"abcdefghij\") == 10\n assert candidate(s = \"patternmatching\",t = \"ternat\") == 0\n assert candidate(s = \"aabbaabbccddeeff\",t = \"abcdeff\") == 0\n assert candidate(s = \"abcde\",t = \"abcdeabcde\") == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"uniquecharacters\",t = \"charactersunique\") == 6\n assert candidate(s = \"programming\",t = \"progmin\") == 0\n assert candidate(s = \"subsequence\",t = \"subs\") == 0\n assert candidate(s = \"hellothere\",t = \"othertimes\") == 5\n assert candidate(s = \"aaaaaa\",t = \"aabbcc\") == 4\n assert candidate(s = \"abcde\",t = \"efghij\") == 5\n assert candidate(s = \"mississippi\",t = \"isip\") == 0\n assert candidate(s = \"abcdefabcdef\",t = \"fedcbafedcba\") == 10\n assert candidate(s = \"longerstringwithcharacters\",t = \"stringcharacters\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"short\",t = \"longerstring\") == 12\n assert candidate(s = \"abcabcabcabcabc\",t = \"abcabcabc\") == 0\n assert candidate(s = \"abababababababab\",t = \"zzzzyyyyxxxxwwwwvvvvuuuuttttrrrrqqqqpppplllloooonnnnmmmkkkkjjjjiiiihhhhhggggggfffffeeeeeddddccccbbbbbaaaa\") == 105\n assert candidate(s = \"overlappingcharacters\",t = \"lap\") == 0\n assert candidate(s = \"sequence\",t = \"quen\") == 0\n assert candidate(s = \"abcdefghij\",t = \"zzzzzzzzzz\") == 10\n assert candidate(s = \"aaaaabbbbb\",t = \"abababab\") == 6\n assert candidate(s = \"abcdefgh\",t = \"ihgfedcba\") == 9\n assert candidate(s = \"thisisaverylongstring\",t = \"isaverylong\") == 0\n assert candidate(s = \"programming\",t = \"gramming\") == 0\n assert candidate(s = \"longeststring\",t = \"tiny\") == 1\n assert candidate(s = \"xyz\",t = \"zyxzyxzyx\") == 8\n assert candidate(s = \"abcdeabcdeabcde\",t = \"abcdee\") == 0\n assert candidate(s = \"abracadabra\",t = \"acadabra\") == 0\n assert candidate(s = \"mississippi\",t = \"ppip\") == 1\n assert candidate(s = \"onetwothreefourfive\",t = \"owhfv\") == 0\n assert candidate(s = \"aaaaaa\",t = \"bbbbb\") == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzzyyxwwvvuutsrrqppoonnmlkkjjiihhggffeeddccbbaa\") == 45\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaaab\") == 1\n assert candidate(s = \"abcdefghij\",t = \"hijjiklm\") == 5\n assert candidate(s = \"example\",t = \"ample\") == 0\n assert candidate(s = \"hello\",t = \"lelo\") == 3\n assert candidate(s = \"abcabcabcabc\",t = \"abcabcabcabcabcabc\") == 6\n assert candidate(s = \"characters\",t = \"char\") == 0\n assert candidate(s = \"aaaabbbbcccc\",t = \"abc\") == 0\n assert candidate(s = \"aaaaaaaaaa\",t = \"aaaabbbbcccc\") == 8\n assert candidate(s = \"xyzuvw\",t = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"xyz\",t = \"wxyzyxwxyzyx\") == 12\n assert candidate(s = \"abcabcabcabcabc\",t = \"abcbcabcbcabcbca\") == 3\n assert candidate(s = \"randomstring\",t = \"random\") == 0\n assert candidate(s = \"abcdefghiklmnopqrstuvwxyz\",t = \"mnopqrstuvwxyz\") == 0\n assert candidate(s = \"aabacadaea\",t = \"abcde\") == 0\n assert candidate(s = \"aaaaaa\",t = \"aaaaaab\") == 1\n assert candidate(s = \"sequence\",t = \"seq\") == 0\n assert candidate(s = \"repeatedcharactersrepeatedcharacters\",t = \"characterscharacterscharacters\") == 10\n assert candidate(s = \"abcdefghij\",t = \"hijjijk\") == 4\n assert candidate(s = \"abacabadabacaba\",t = \"abcabcabc\") == 1\n assert candidate(s = \"xyzabc\",t = \"uvwabc\") == 6\n assert candidate(s = \"alibabacloud\",t = \"aliloud\") == 0\n assert candidate(s = \"aaaabbbbcccc\",t = \"bbcccaaa\") == 3\n assert candidate(s = \"aaaaabbbbbcccc\",t = \"abcabc\") == 3\n assert candidate(s = \"hello\",t = \"olelh\") == 4\n assert candidate(s = \"abcdefg\",t = \"agh\") == 1\n assert candidate(s = \"abcdefghijkllkjihgfedcba\",t = \"abcdefghijkllkjihgfedcba\") == 0\n assert candidate(s = \"overlappingoverlapping\",t = \"lapover\") == 0\n assert candidate(s = \"a\",t = \"\") == 0\n assert candidate(s = \"abcabcabcabcabc\",t = \"aabbaabbaabbaabb\") == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"xyzzyxzyxzyz\",t = \"xyzxyz\") == 0\n assert candidate(s = \"hellotherehellothere\",t = \"helloothere\") == 0\n assert candidate(s = \"abcdefghij\",t = \"hijjikl\") == 4\n assert candidate(s = \"abacabadabacaba\",t = \"badaba\") == 0\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxyyyzzz\",t = \"zzzyyxxwwvvuuuttrrssqqppoonnmmlkkjjiihhgggfffeeeddccbbaaa\") == 54\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvut\") == 6\n assert candidate(s = \"abcdefghij\",t = \"hijjik\") == 3\n assert candidate(s = \"aabbccddeeffgg\",t = \"abcdefg\") == 0\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\") == 10\n assert candidate(s = \"abcdefghij\",t = \"acegik\") == 1\n assert candidate(s = \"racecar\",t = \"racecar\") == 0\n assert candidate(s = \"abracadabra\",t = \"abcde\") == 1\n assert candidate(s = \"abcdefghij\",t = \"abcdefghij\") == 0\n"}, "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().appendCharacters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int appendCharacters(String s, String t) {", "container": "Solution", "callable": "appendCharacters", "parameters": [{"name": "s", "type": "String"}, {"name": "t", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2487, "task_id": "remove-nodes-from-linked-list", "difficulty": "Medium", "problem_description": "You are given the head of a linked list.\nRemove every node which has a node with a greater value anywhere to the right side of it.\nReturn the head of the modified linked list.\n \nExample 1:\n\n\nInput: head = [5,2,13,3,8]\nOutput: [13,8]\nExplanation: The nodes that should be removed are 5, 2 and 3.\n- Node 13 is to the right of node 5.\n- Node 13 is to the right of node 2.\n- Node 8 is to the right of node 3.\n\nExample 2:\n\nInput: head = [1,1,1,1]\nOutput: [1,1,1,1]\nExplanation: Every node has value 1, so no nodes are removed.\n\n \nConstraints:\n\nThe number of the nodes in the given list is in the range [1, 105].\n1 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1])), list_node([5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([8, 9, 7, 6, 5])), list_node([9, 7, 6, 5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5])), list_node([5]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50])), list_node([50]))\n assert is_same_list(candidate(head = list_node([9, 7, 6, 5, 4])), list_node([9, 7, 6, 5, 4]))\n assert is_same_list(candidate(head = list_node([10, 5, 20, 3])), list_node([20, 3]))\n assert is_same_list(candidate(head = list_node([10, 5, 8, 9, 2])), list_node([10, 9, 2]))\n assert is_same_list(candidate(head = list_node([10, 5, 3, 20, 2])), list_node([20, 2]))\n assert is_same_list(candidate(head = list_node([10, 5, 20, 3, 8])), list_node([20, 8]))\n assert is_same_list(candidate(head = list_node([5])), list_node([5]))\n assert is_same_list(candidate(head = list_node([50, 40, 30, 20, 10])), list_node([50, 40, 30, 20, 10]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1])), list_node([1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([3, 2, 1])), list_node([3, 2, 1]))\n assert is_same_list(candidate(head = list_node([9, 7, 5, 3, 1])), list_node([9, 7, 5, 3, 1]))\n assert is_same_list(candidate(head = list_node([1, 9, 1, 9, 1])), list_node([9, 9, 1]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6])), list_node([10, 9, 8, 7, 6]))\n assert is_same_list(candidate(head = list_node([6, 7, 8, 9, 10])), list_node([10]))\n assert is_same_list(candidate(head = list_node([5, 2, 13, 3, 8])), list_node([13, 8]))\n assert is_same_list(candidate(head = list_node([3, 2, 6, 5, 4, 7, 8, 1])), list_node([8, 1]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 1])), list_node([10, 1]))\n assert is_same_list(candidate(head = list_node([100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 10, 20, 30, 40, 50])), list_node([100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 50]))\n assert is_same_list(candidate(head = list_node([10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90])), list_node([100, 90]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9])), list_node([9]))\n assert is_same_list(candidate(head = list_node([5, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 2, 4, 5, 3, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([10, 10]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10])), list_node([100, 90, 80, 70, 60, 50, 40, 30, 20, 10]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10])), list_node([10]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11])), list_node([11]))\n assert is_same_list(candidate(head = list_node([10, 5, 20, 30, 5, 10, 15, 5, 25, 30])), list_node([30, 30]))\n assert is_same_list(candidate(head = list_node([100, 90, 80, 70, 60, 50, 40, 30, 20, 10])), list_node([100, 90, 80, 70, 60, 50, 40, 30, 20, 10]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15])), list_node([15]))\n assert is_same_list(candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8])), list_node([9, 8]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 6, 7, 8, 9, 10])), list_node([10]))\n assert is_same_list(candidate(head = list_node([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100])), list_node([100, 100]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([10]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10])), list_node([10, 10]))\n assert is_same_list(candidate(head = list_node([1, 10, 2, 9, 3, 8, 4, 7, 5, 6])), list_node([10, 9, 8, 7, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10])), list_node([10, 10, 10, 10, 10, 10, 10, 10, 10, 10]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1])), list_node([10, 1]))\n assert is_same_list(candidate(head = list_node([1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5])), list_node([9, 8, 7, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5]))\n assert is_same_list(candidate(head = list_node([15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([30, 25, 20, 15, 10, 5, 30, 25, 20, 15, 10, 5])), list_node([30, 30, 25, 20, 15, 10, 5]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 10, 6, 7, 8, 9])), list_node([10, 9]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1])), list_node([6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 5, 5, 5])), list_node([6, 6, 6, 6, 6, 5, 5, 5]))\n assert is_same_list(candidate(head = list_node([1000, 900, 800, 700, 600, 500, 400, 300, 200, 100])), list_node([1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]))\n assert is_same_list(candidate(head = list_node([3, 7, 2, 8, 10, 5, 6, 12])), list_node([12]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91])), list_node([100, 99, 98, 97, 96, 95, 94, 93, 92, 91]))\n assert is_same_list(candidate(head = list_node([2, 3, 1, 5, 4, 7, 6, 9, 8, 11, 10])), list_node([11, 10]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])), list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]))\n assert is_same_list(candidate(head = list_node([5, 7, 5, 8, 6, 9, 7, 10, 8, 11, 9, 12, 10, 13, 11])), list_node([13, 11]))\n assert is_same_list(candidate(head = list_node([10, 20, 15, 30, 25, 40, 35, 50, 45, 60])), list_node([60]))\n assert is_same_list(candidate(head = list_node([1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 25, 35, 45, 55])), list_node([55]))\n assert is_same_list(candidate(head = list_node([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([100000, 1, 2, 3, 4, 5, 99999])), list_node([100000, 99999]))\n assert is_same_list(candidate(head = list_node([1, 10, 1, 10, 1, 10, 1, 10, 1, 10])), list_node([10, 10, 10, 10, 10]))\n assert is_same_list(candidate(head = list_node([1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11])), list_node([11]))\n assert is_same_list(candidate(head = list_node([2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1])), list_node([3, 3, 3, 3, 3, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 10, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60, 7, 70, 8, 80, 9, 90, 10, 100])), list_node([100]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10])), list_node([10, 10, 10, 10, 10]))\n assert is_same_list(candidate(head = list_node([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])), list_node([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]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1])), list_node([3, 3, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([10, 9, 10, 8, 11, 7, 12, 6, 13, 5, 14, 4, 15, 3, 16, 2, 17, 1])), list_node([17, 1]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])), list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]))\n assert is_same_list(candidate(head = list_node([100, 200, 300, 250, 200, 150, 100, 50, 1])), list_node([300, 250, 200, 150, 100, 50, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 15, 25, 30, 5, 35, 40, 45, 50])), list_node([50]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 25, 35, 40, 38, 45, 42, 48, 47, 50])), list_node([50]))\n assert is_same_list(candidate(head = list_node([3, 7, 2, 9, 8, 10, 6])), list_node([10, 6]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 11, 6, 5, 4, 3, 2, 1])), list_node([11, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 2, 1])), list_node([5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([5, 9, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4])), list_node([20, 4]))\n assert is_same_list(candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995])), list_node([100000, 99999, 99998, 99997, 99996, 99995]))\n assert is_same_list(candidate(head = list_node([10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11])), list_node([11]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 10])), list_node([10]))\n assert is_same_list(candidate(head = list_node([1000, 900, 1001, 800, 1002, 700, 1003, 600, 1004, 500, 1005, 400, 1006, 300, 1007, 200, 1008, 100])), list_node([1008, 100]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15, 20, 20, 20, 20, 20])), list_node([20, 20, 20, 20, 20]))\n assert is_same_list(candidate(head = list_node([3, 2, 1, 10, 9, 8, 7, 6, 5, 4])), list_node([10, 9, 8, 7, 6, 5, 4]))\n assert is_same_list(candidate(head = list_node([1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 10])), list_node([10]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10])), list_node([10, 10, 10, 10, 10, 10, 10, 10, 10, 10]))\n assert is_same_list(candidate(head = list_node([1, 100000, 2, 200000, 3, 300000, 4, 400000, 5, 500000])), list_node([500000]))\n assert is_same_list(candidate(head = list_node([1, 1, 9, 9, 2, 2, 8, 8, 3, 3, 7, 7, 4, 4, 6, 6, 5, 5])), list_node([9, 9, 8, 8, 7, 7, 6, 6, 5, 5]))\n assert is_same_list(candidate(head = list_node([5, 10, 5, 15, 5, 20, 5, 25, 5, 30])), list_node([30]))\n assert is_same_list(candidate(head = list_node([10, 1, 10, 2, 10, 3, 10, 4, 10, 5, 10, 6, 10, 7, 10, 8, 10, 9, 10, 11])), list_node([11]))\n assert is_same_list(candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991])), list_node([100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]))\n assert is_same_list(candidate(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([20]))\n assert is_same_list(candidate(head = list_node([1, 9, 2, 8, 3, 7, 4, 6, 5])), list_node([9, 8, 7, 6, 5]))\n assert is_same_list(candidate(head = list_node([1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2])), list_node([2, 2, 2, 2, 2, 2]))\n assert is_same_list(candidate(head = list_node([100, 50, 150, 200, 100, 250, 200])), list_node([250, 200]))\n assert is_same_list(candidate(head = list_node([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2])), list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([100000, 10]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 10, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([20]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 10, 20, 30, 40])), list_node([105, 40]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 25, 35, 45, 15, 25])), list_node([50, 45, 25]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100])), list_node([100]))\n assert is_same_list(candidate(head = list_node([10, 9, 11, 10, 12, 11, 13, 12])), list_node([13, 12]))\n assert is_same_list(candidate(head = list_node([3, 2, 1, 4, 5, 6, 7, 8, 9, 10])), list_node([10]))\n assert is_same_list(candidate(head = list_node([50, 50, 50, 50, 50, 49, 48, 47, 46, 45])), list_node([50, 50, 50, 50, 50, 49, 48, 47, 46, 45]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 10, 6, 5, 4, 3, 2, 1, 11])), list_node([11]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4])), list_node([10, 9, 8, 7, 6, 5, 4]))\n assert is_same_list(candidate(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([25]))\n assert is_same_list(candidate(head = list_node([3, 4, 2, 5, 1, 6, 7])), list_node([7]))\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().removeNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {", "container": "Solution", "callable": "ListNode", "parameters": [], "return_type": "class ListNode {\n * int val;\n * ListNode next;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2488, "task_id": "count-subarrays-with-median-k", "difficulty": "Hard", "problem_description": "You are given an array nums of size n consisting of distinct integers from 1 to n and a positive integer k.\nReturn the number of non-empty subarrays in nums that have a median equal to k.\nNote:\n\nThe median of an array is the middle element after sorting the array in ascending order. If the array is of even length, the median is the left middle element.\n\n\t\nFor example, the median of [2,3,1,4] is 2, and the median of [8,4,3,5,1] is 4.\n\n\nA subarray is a contiguous part of an array.\n\n \nExample 1:\n\nInput: nums = [3,2,1,4,5], k = 4\nOutput: 3\nExplanation: The subarrays that have a median equal to 4 are: [4], [4,5] and [1,4,5].\n\nExample 2:\n\nInput: nums = [2,3,1], k = 3\nOutput: 1\nExplanation: [3] is the only subarray that has a median equal to 3.\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\n1 <= nums[i], k <= n\nThe integers in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 1],k = 3) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n assert candidate(nums = [5, 1, 4, 3, 2],k = 3) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 4) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 9\n assert candidate(nums = [3, 2, 1, 4, 5],k = 4) == 3\n assert candidate(nums = [7, 5, 3, 1, 2, 4, 6],k = 4) == 4\n assert candidate(nums = [5, 4, 3, 2, 1],k = 3) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 5) == 13\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12],k = 15) == 16\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4],k = 5) == 4\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) == 30\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 = 15) == 21\n assert candidate(nums = [8, 6, 4, 2, 1, 3, 5, 7, 9],k = 5) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10],k = 5) == 7\n assert candidate(nums = [1, 3, 2, 6, 5, 4, 8, 7, 9],k = 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, 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 = 27) == 47\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) == 30\n assert candidate(nums = [5, 2, 8, 3, 9, 4, 10, 1, 6, 7],k = 5) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 15) == 15\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 11\n assert candidate(nums = [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],k = 25) == 25\n assert candidate(nums = [4, 3, 2, 1, 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) == 50\n assert candidate(nums = [15, 20, 10, 25, 5, 1, 6, 11, 16, 21, 26, 30, 3, 8, 13, 18, 23, 28, 2, 7, 12, 17, 22, 27, 29, 4, 9, 14, 19, 24],k = 15) == 17\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16, 21, 30, 22, 29, 23, 28, 24, 27, 25, 26, 31, 40, 32, 39, 33, 38, 34, 37, 35, 36, 41, 50, 42, 49, 43, 48, 44, 47, 45, 46],k = 25) == 54\n assert candidate(nums = [5, 10, 4, 3, 8, 7, 9, 2, 6, 1],k = 5) == 7\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 2, 6, 10, 14, 18, 22, 26, 30, 3, 7, 11, 15, 19, 23, 27, 28, 4, 8, 12, 16, 20, 24],k = 15) == 87\n assert candidate(nums = [4, 1, 5, 3, 2, 7, 6, 8, 9, 10],k = 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],k = 10) == 20\n assert candidate(nums = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],k = 5) == 14\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 = 13) == 25\n assert candidate(nums = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 10) == 3\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9],k = 5) == 3\n assert candidate(nums = [25, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 25) == 2\n assert candidate(nums = [25, 20, 15, 10, 5, 1, 6, 11, 16, 21, 26, 30, 3, 8, 13, 18, 23, 28, 2, 7, 12, 17, 22, 27, 29, 4, 9, 14, 19, 24],k = 15) == 24\n assert candidate(nums = [3, 1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20],k = 10) == 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],k = 11) == 19\n assert candidate(nums = [4, 1, 5, 3, 2, 6, 8, 7, 9, 10],k = 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],k = 25) == 11\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(nums = [5, 1, 3, 2, 4, 8, 6, 7, 9, 10],k = 6) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 5) == 13\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 = 15) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 11) == 9\n assert candidate(nums = [1, 13, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12, 14, 15, 16, 17, 18, 19, 20, 3],k = 10) == 24\n assert candidate(nums = [5, 1, 4, 2, 3, 8, 6, 7, 10, 9],k = 5) == 3\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 21) == 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],k = 11) == 19\n assert candidate(nums = [5, 3, 1, 2, 4, 6, 7, 8, 9, 10],k = 6) == 9\n assert candidate(nums = [5, 1, 9, 3, 7, 8, 2, 6, 4, 10],k = 5) == 8\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],k = 15) == 44\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) == 20\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 7\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 15\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10],k = 7) == 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 = 19) == 20\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 = 12) == 17\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],k = 5) == 3\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 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],k = 25) == 25\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 6, 4, 10],k = 5) == 7\n assert candidate(nums = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8],k = 8) == 15\n assert candidate(nums = [12, 14, 10, 15, 13, 11, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 9\n assert candidate(nums = [1, 11, 5, 9, 7, 2, 6, 3, 8, 10, 4],k = 6) == 25\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 = 21) == 19\n assert candidate(nums = [15, 20, 25, 10, 5, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 50) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 9\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 = 5) == 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],k = 22) == 19\n assert candidate(nums = [3, 6, 1, 8, 5, 2, 9, 4, 7],k = 5) == 19\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 28\n assert candidate(nums = [3, 1, 4, 2, 5],k = 3) == 3\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 15\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 11) == 25\n assert candidate(nums = [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],k = 25) == 35\n assert candidate(nums = [2, 1, 5, 3, 4, 6, 7, 8, 9, 10],k = 5) == 7\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10],k = 5) == 6\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countSubarrays(int[] nums, int k) {", "container": "Solution", "callable": "countSubarrays", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2490, "task_id": "circular-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces.\n\nFor example, \"Hello World\", \"HELLO\", \"hello world hello world\" are all sentences.\n\nWords consist of only uppercase and lowercase English letters. Uppercase and lowercase English letters are considered different.\nA sentence is circular if:\n\nThe last character of each word in the sentence is equal to the first character of its next word.\nThe last character of the last word is equal to the first character of the first word.\n\nFor example, \"leetcode exercises sound delightful\", \"eetcode\", \"leetcode eats soul\" are all circular sentences. However, \"Leetcode is cool\", \"happy Leetcode\", \"Leetcode\" and \"I like Leetcode\" are not circular sentences.\nGiven a string sentence, return true if it is circular. Otherwise, return false.\n \nExample 1:\n\nInput: sentence = \"leetcode exercises sound delightful\"\nOutput: true\nExplanation: The words in sentence are [\"leetcode\", \"exercises\", \"sound\", \"delightful\"].\n- leetcode's last character is equal to exercises's first character.\n- exercises's last character is equal to sound's first character.\n- sound's last character is equal to delightful's first character.\n- delightful's last character is equal to leetcode's first character.\nThe sentence is circular.\nExample 2:\n\nInput: sentence = \"eetcode\"\nOutput: true\nExplanation: The words in sentence are [\"eetcode\"].\n- eetcode's last character is equal to eetcode's first character.\nThe sentence is circular.\nExample 3:\n\nInput: sentence = \"Leetcode is cool\"\nOutput: false\nExplanation: The words in sentence are [\"Leetcode\", \"is\", \"cool\"].\n- Leetcode's last character is not equal to is's first character.\nThe sentence is not circular.\n \nConstraints:\n\n1 <= sentence.length <= 500\nsentence consist of only lowercase and uppercase English letters and spaces.\nThe words in sentence are separated by a single space.\nThere are no leading or trailing spaces.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"sentence ence sent\") == False\n assert candidate(sentence = \"hello olleh\") == True\n assert candidate(sentence = \"Aa Aa\") == False\n assert candidate(sentence = \"ab ba\") == True\n assert candidate(sentence = \"a\") == True\n assert candidate(sentence = \"Leetcode is cool\") == False\n assert candidate(sentence = \"b\") == True\n assert candidate(sentence = \"A aA A\") == False\n assert candidate(sentence = \"abcd dcba\") == True\n assert candidate(sentence = \"circular rular circul\") == False\n assert candidate(sentence = \"Zz zZ\") == True\n assert candidate(sentence = \"abc cba\") == True\n assert candidate(sentence = \"a a a a\") == True\n assert candidate(sentence = \"example ample exa\") == False\n assert candidate(sentence = \"A a A\") == False\n assert candidate(sentence = \"Zz\") == False\n assert candidate(sentence = \"eetcode\") == True\n assert candidate(sentence = \"abc cab bca\") == True\n assert candidate(sentence = \"abc bca cab\") == False\n assert candidate(sentence = \"B ba B\") == False\n assert candidate(sentence = \"leetcode exercises sound delightful\") == True\n assert candidate(sentence = \"b b b\") == True\n assert candidate(sentence = \"a b c a\") == False\n assert candidate(sentence = \"A a\") == False\n assert candidate(sentence = \"test tset\") == True\n assert candidate(sentence = \"aba\") == True\n assert candidate(sentence = \"mnopqr stuvwx yzab cd efgh ijklm nopqr\") == False\n assert candidate(sentence = \"world dlrow\") == True\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyz zabcdefghijklmnopqrstuvwxy\") == False\n assert candidate(sentence = \"No lemon no melon\") == False\n assert candidate(sentence = \"Anna\") == False\n assert candidate(sentence = \"Able was I ere I saw Elba Able\") == False\n assert candidate(sentence = \"Was it a car or a cat I saw saw I tac a ro rac a si taW taW\") == False\n assert candidate(sentence = \"Madam In Eden Im Adam\") == False\n assert candidate(sentence = \"Circular logic confuses brains sourcing smiles\") == False\n assert candidate(sentence = \"Rotation noitator tor\") == False\n assert candidate(sentence = \"noon moon moon\") == False\n assert candidate(sentence = \"peep peep\") == True\n assert candidate(sentence = \"b aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa b\") == False\n assert candidate(sentence = \"Noon neons number nicely\") == False\n assert candidate(sentence = \"Madam madam madam\") == False\n assert candidate(sentence = \"refer level civic civic civic level refer\") == False\n assert candidate(sentence = \"xyyx xxyy\") == False\n assert candidate(sentence = \"kayak kayak kayak kayak\") == True\n assert candidate(sentence = \"rotor racecar level deed civic\") == False\n assert candidate(sentence = \"stats tacocat stats\") == False\n assert candidate(sentence = \"racecar civic madam\") == False\n assert candidate(sentence = \"Step on no pets no step on no pets\") == False\n assert candidate(sentence = \"Able was I I saw Elba Elba saw I I was Able\") == False\n assert candidate(sentence = \"tacocat\") == True\n assert candidate(sentence = \"a quick brown fox jumps over lazy a\") == False\n assert candidate(sentence = \"zoo online one nice Easter egg\") == False\n assert candidate(sentence = \"Word dOrw\") == False\n assert candidate(sentence = \"deed deed\") == True\n assert candidate(sentence = \"daemon daemon\") == False\n assert candidate(sentence = \"Palindrome emordnilaP\") == True\n assert candidate(sentence = \"madam racecar civic\") == False\n assert candidate(sentence = \"Circular arular ci\") == False\n assert candidate(sentence = \"Madam adaM\") == False\n assert candidate(sentence = \"A Santa at NASA\") == False\n assert candidate(sentence = \"sun sets slowly on nosy wonks\") == False\n assert candidate(sentence = \"madam racecar level deed civic kayak rotor\") == False\n assert candidate(sentence = \"abcde edcba\") == True\n assert candidate(sentence = \"Nested edset n\") == False\n assert candidate(sentence = \"kayak kayak\") == True\n assert candidate(sentence = \"Nurses run Nurses\") == False\n assert candidate(sentence = \"Programming gnostic stem ngram minnow winnow now\") == False\n assert candidate(sentence = \"rotor rotor\") == True\n assert candidate(sentence = \"redivider\") == True\n assert candidate(sentence = \"racecar civic level deed\") == False\n assert candidate(sentence = \"Abba aaaa aa a\") == False\n assert candidate(sentence = \"xylophone elephant monkey keen\") == False\n assert candidate(sentence = \"xyzzyx\") == True\n assert candidate(sentence = \"circularloop loop\") == False\n assert candidate(sentence = \"Alaska Kansas suck slyly yelling nasty nasty yaks yak salty knapsack sacks sacks sky kayak kayak kayak\") == False\n assert candidate(sentence = \"x y z x\") == False\n assert candidate(sentence = \"programming is simply programming\") == False\n assert candidate(sentence = \"zoo omega meal alpha\") == False\n assert candidate(sentence = \"Loop opLo\") == False\n assert candidate(sentence = \"Startling lightning bugs ignited giants\") == False\n assert candidate(sentence = \"xylophone one love evolution nation\") == False\n assert candidate(sentence = \"deed deed deed\") == True\n assert candidate(sentence = \"Palindrome emordnilaP laP\") == False\n assert candidate(sentence = \"noon odd level civic civic civic level odd noon\") == False\n assert candidate(sentence = \"Was it a car or a cat I saw Was\") == False\n assert candidate(sentence = \"Reflection noitcifilr\") == False\n assert candidate(sentence = \"ab ba ac ca\") == True\n assert candidate(sentence = \"racecar racecar\") == True\n assert candidate(sentence = \"abracadabra arachnophobia\") == True\n assert candidate(sentence = \"repaper repaper repaper\") == True\n assert candidate(sentence = \"Complex xs w x\") == False\n assert candidate(sentence = \"abcd defg ghij jkla\") == True\n assert candidate(sentence = \"Interstellar rstellar inter\") == False\n assert candidate(sentence = \"reviled devil level deed vile derevered\") == False\n assert candidate(sentence = \"Fascinating ideas inspire amazing minds\") == False\n assert candidate(sentence = \"Alphabet tebahpla A\") == False\n assert candidate(sentence = \"Unique new weird weed nude euqinu\") == False\n assert candidate(sentence = \"Wow wow\") == False\n assert candidate(sentence = \"tortoise einstein noodles stein snot not ossetia\") == False\n assert candidate(sentence = \"rotor kayak rotor\") == False\n assert candidate(sentence = \"kayak kayak kayak kayak kayak\") == True\n assert candidate(sentence = \"zebra apple orange night eagle\") == False\n assert candidate(sentence = \"Zebra apple orange elephant\") == False\n assert candidate(sentence = \"redder redder\") == True\n assert candidate(sentence = \"No lemon no melon no lemon no melon\") == False\n assert candidate(sentence = \"xylophone elephant monkey keen noodle leet teex\") == False\n assert candidate(sentence = \"Anna civic radar level rotor\") == False\n assert candidate(sentence = \"zoo omega anna apple\") == False\n assert candidate(sentence = \"Detartrated dater dated\") == False\n assert candidate(sentence = \"xylophone excellent noodles seen\") == False\n assert candidate(sentence = \"Madam madam\") == False\n assert candidate(sentence = \"level level\") == True\n assert candidate(sentence = \"abracadabra aracnidae earthworms mammals sloths\") == False\n assert candidate(sentence = \"level level level level\") == True\n assert candidate(sentence = \"Wow wow wow\") == False\n assert candidate(sentence = \"palindrome emordnilap\") == True\n assert candidate(sentence = \"Was it a car or a cat I saw seen saw I tac a ro rac a ti saw\") == False\n assert candidate(sentence = \"a aa aaa aaaa\") == True\n assert candidate(sentence = \"xylophone objective elegant elegant not\") == False\n assert candidate(sentence = \"b b b b b\") == True\n assert candidate(sentence = \"XYlophone emotion motion nation\") == False\n assert candidate(sentence = \"Zoos own cozy zones\") == False\n assert candidate(sentence = \"deified deified deified deified\") == True\n assert candidate(sentence = \"Was it a car or a cat I saw\") == False\n assert candidate(sentence = \"Zebra apple apple orange onion nginx\") == False\n assert candidate(sentence = \"cycle ycle c\") == False\n assert candidate(sentence = \"Wow\") == False\n assert candidate(sentence = \"Programming gamifies lessons yielding successes\") == False\n assert candidate(sentence = \"Rhythms mesmerize symphonies\") == False\n assert candidate(sentence = \"Madam Ada\") == False\n assert candidate(sentence = \"Madam Arora teaches malayalam Madam\") == False\n assert candidate(sentence = \"Rotator taro Rotator\") == False\n assert candidate(sentence = \"a a a a a a a a a a a a\") == True\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(sentence = \"Civic civic\") == False\n assert candidate(sentence = \"repaper deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed\") == False\n assert candidate(sentence = \"kayak civic deed level odd noon\") == False\n assert candidate(sentence = \"Madam Arora teaches malayalam\") == False\n assert candidate(sentence = \"noon odd level deed civic kayak\") == False\n assert candidate(sentence = \"giraffe elephant noodle leet teex xxyy\") == False\n assert candidate(sentence = \"Echo Charlie Hotel Hotel Echo\") == False\n assert candidate(sentence = \"racecar madam rotator\") == False\n assert candidate(sentence = \"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\") == False\n assert candidate(sentence = \"solo ollas solar lassos\") == False\n assert candidate(sentence = \"madamrefer\") == False\n assert candidate(sentence = \"civic racecar level madam deed rotator redivider\") == False\n assert candidate(sentence = \"Tactocat civic\") == False\n assert candidate(sentence = \"Xylophones yield xenial xylophiles\") == False\n assert candidate(sentence = \"civic deed level civic civic\") == False\n assert candidate(sentence = \"Underground neutergnu\") == False\n assert candidate(sentence = \"rotor\") == True\n assert candidate(sentence = \"racecar\") == True\n assert candidate(sentence = \"singleword\") == False\n assert candidate(sentence = \"zoo ooz zoo\") == False\n assert candidate(sentence = \"redder redivider redivider\") == True\n assert candidate(sentence = \"xylophone one phone nova ava axolotl talontax\") == False\n assert candidate(sentence = \"ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az\") == False\n assert candidate(sentence = \"kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak\") == True\n assert candidate(sentence = \"a aa aaaa a\") == True\n assert candidate(sentence = \"Mushroom nrooms moss stamper reaper\") == False\n assert candidate(sentence = \"daemon nomad\") == True\n assert candidate(sentence = \"AbCd DeFg GhIj JkLa\") == False\n assert candidate(sentence = \"level deed deed level\") == False\n assert candidate(sentence = \"Stressed desserts\") == False\n assert candidate(sentence = \"stats stats\") == True\n assert candidate(sentence = \"A Santa at NASA A\") == False\n assert candidate(sentence = \"civic madam racecar\") == False\n assert candidate(sentence = \"repaper repaper\") == True\n assert candidate(sentence = \"Palindrome emordnilaP el\") == False\n assert candidate(sentence = \"Able was I I saw Elba\") == False\n assert candidate(sentence = \"Programming ngRams Make sense\") == False\n assert candidate(sentence = \"Mimi\") == False\n assert candidate(sentence = \"rotor rotor rotor\") == True\n assert candidate(sentence = \"rotor rotor rotor rotor\") == True\n assert candidate(sentence = \"A Toyota tacoma玛 its a Toyota tacoma玛\") == False\n assert candidate(sentence = \"rotator rotator\") == True\n assert candidate(sentence = \"No lemon no melon No\") == False\n assert candidate(sentence = \"Step on no pets\") == False\n assert candidate(sentence = \"A Santa at NASA at a Santa A\") == False\n assert candidate(sentence = \"Was it a car or a cat I saw saw I tac a ro rac a si taW\") == False\n assert candidate(sentence = \"a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa a\") == True\n assert candidate(sentence = \"redivider deified civic level rotator deed madam racecar\") == False\n assert candidate(sentence = \"a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa\") == True\n assert candidate(sentence = \"level level level\") == True\n assert candidate(sentence = \"deified deified\") == True\n assert candidate(sentence = \"Circular larriuC\") == False\n assert candidate(sentence = \"Symmetry try sym\") == False\n assert candidate(sentence = \"redivider redivider\") == True\n assert candidate(sentence = \"banana apple orange emitter\") == False\n assert candidate(sentence = \"reviled devil\") == False\n assert candidate(sentence = \"abracadabra arachnid did deep peeled Elba bar\") == False\n assert candidate(sentence = \"civic deed civic deed\") == False\n assert candidate(sentence = \"Wow kayak wow wow wow wow wow\") == False\n assert candidate(sentence = \"Anna annA\") == True\n assert candidate(sentence = \"Never odd or even\") == False\n assert candidate(sentence = \"Nurses run\") == False\n assert candidate(sentence = \"aaaaa aaaaa aaaaa\") == True\n assert candidate(sentence = \"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\") == False\n assert candidate(sentence = \"Zebra apple orchid night eagle\") == False\n assert candidate(sentence = \"repaid diaper\") == True\n assert candidate(sentence = \"Abc bcd def efg gfa\") == False\n assert candidate(sentence = \"Abc cba abc\") == False\n assert candidate(sentence = \"a a a a a a a a a a\") == True\n assert candidate(sentence = \"banana apple orange nice East West\") == False\n assert candidate(sentence = \"Python nohtyP\") == True\n assert candidate(sentence = \"Palindrome emordnilaP ndromePal\") == False\n assert candidate(sentence = \"a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a\") == True\n assert candidate(sentence = \"Cycle elc yc\") == False\n assert candidate(sentence = \"algorithm nom alg\") == False\n assert candidate(sentence = \"Anna annA annA\") == False\n assert candidate(sentence = \"Twisted tales weave intricate stories\") == False\n assert candidate(sentence = \"civic civic civic\") == True\n assert candidate(sentence = \"Rotor rotor\") == False\n assert candidate(sentence = \"Zoology yggdrasill lloisgoy zoo\") == False\n assert candidate(sentence = \"coding ngoding going on\") == False\n assert candidate(sentence = \"repaid repaid\") == False\n assert candidate(sentence = \"Data analytics sscientist teach harsh\") == False\n assert candidate(sentence = \"AB BA CA\") == False\n assert candidate(sentence = \"Mamad Madam Damda\") == False\n assert candidate(sentence = \"abacabadabacaba\") == True\n"}, "metadata": {"canonical_parameter_names": ["sentence"], "leetcode_dataset_entry_point": "Solution().isCircularSentence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isCircularSentence(String sentence) {", "container": "Solution", "callable": "isCircularSentence", "parameters": [{"name": "sentence", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2491, "task_id": "divide-players-into-teams-of-equal-skill", "difficulty": "Medium", "problem_description": "You are given a positive integer array skill of even length n where skill[i] denotes the skill of the ith player. Divide the players into n / 2 teams of size 2 such that the total skill of each team is equal.\nThe chemistry of a team is equal to the product of the skills of the players on that team.\nReturn the sum of the chemistry of all the teams, or return -1 if there is no way to divide the players into teams such that the total skill of each team is equal.\n \nExample 1:\n\nInput: skill = [3,2,5,1,3,4]\nOutput: 22\nExplanation: \nDivide the players into the following teams: (1, 5), (2, 4), (3, 3), where each team has a total skill of 6.\nThe sum of the chemistry of all the teams is: 1 * 5 + 2 * 4 + 3 * 3 = 5 + 8 + 9 = 22.\n\nExample 2:\n\nInput: skill = [3,4]\nOutput: 12\nExplanation: \nThe two players form a team with a total skill of 7.\nThe chemistry of the team is 3 * 4 = 12.\n\nExample 3:\n\nInput: skill = [1,1,2,3]\nOutput: -1\nExplanation: \nThere is no way to divide the players into teams such that the total skill of each team is equal.\n\n \nConstraints:\n\n2 <= skill.length <= 105\nskill.length is even.\n1 <= skill[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(skill = [1, 1000, 1, 1000, 1, 1000, 1, 1000]) == 4000\n assert candidate(skill = [1, 1, 2, 2, 3, 3, 4, 4]) == 20\n assert candidate(skill = [1, 1, 2, 3]) == -1\n assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8]) == 60\n assert candidate(skill = [5, 5, 5, 5, 5, 5]) == 75\n assert candidate(skill = [15, 15, 15, 15, 15, 15, 15, 15]) == 900\n assert candidate(skill = [3, 4]) == 12\n assert candidate(skill = [2, 3, 3, 2, 2, 3]) == 18\n assert candidate(skill = [4, 4, 4, 4]) == 32\n assert candidate(skill = [3, 2, 5, 1, 3, 4]) == 22\n assert candidate(skill = [10, 10, 10, 10]) == 200\n assert candidate(skill = [1000, 1000, 1, 1, 2, 2]) == -1\n assert candidate(skill = [1, 2, 3, 4, 5, 6]) == 28\n assert candidate(skill = [1, 2, 3, 3, 2, 1]) == 10\n assert candidate(skill = [1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 4000\n assert candidate(skill = [10, 20, 30, 40, 50, 60]) == 2800\n assert candidate(skill = [500, 500, 500, 500, 500, 500, 500, 500]) == 1000000\n assert candidate(skill = [1, 3, 5, 7, 9, 11]) == 73\n assert candidate(skill = [1000, 1, 999, 2, 500, 501]) == 253498\n assert candidate(skill = [500, 500, 1, 999, 2, 998, 3, 997]) == 255986\n assert candidate(skill = [1, 2, 3, 6, 4, 5]) == 28\n assert candidate(skill = [250, 750, 500, 500, 750, 250, 500, 500]) == 875000\n assert candidate(skill = [1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(skill = [1, 1000, 500, 500, 250, 750, 100, 900]) == -1\n assert candidate(skill = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500]) == 350000\n assert candidate(skill = [1, 999, 2, 998, 3, 997, 4, 996, 5, 995, 6, 994, 7, 993, 8, 992, 9, 991, 10, 990]) == 54615\n assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 182\n assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 18200\n assert candidate(skill = [1, 999, 3, 997, 5, 995, 7, 993, 9, 991, 11, 989, 13, 987, 15, 985]) == 63320\n assert candidate(skill = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 512\n assert candidate(skill = [200, 300, 200, 300, 200, 300, 200, 300]) == 240000\n assert candidate(skill = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 728\n assert candidate(skill = [333, 667, 333, 667, 333, 667, 333, 667, 333, 667, 333, 667, 333, 667, 333, 667]) == 1776888\n assert candidate(skill = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(skill = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 252\n assert candidate(skill = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 14960\n assert candidate(skill = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6]) == 20909\n assert candidate(skill = [10, 1, 5, 15, 7, 3, 9, 11]) == -1\n assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11000\n assert candidate(skill = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == 1512\n assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 40800\n assert candidate(skill = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 216\n assert candidate(skill = [2, 8, 3, 7, 4, 6, 5, 5]) == 86\n assert candidate(skill = [333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348]) == 927352\n assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 182\n assert candidate(skill = [23, 42, 31, 57, 5, 19, 6, 49, 12, 35, 29, 10, 50, 40, 21, 33]) == -1\n assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80]) == 6000\n assert candidate(skill = [10, 20, 30, 40, 50, 60, 10, 20, 30, 40, 50, 60]) == 5600\n assert candidate(skill = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 5000\n assert candidate(skill = [8, 1, 8, 1, 8, 1, 8, 1]) == 32\n assert candidate(skill = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200]) == -1\n assert candidate(skill = [250, 250, 500, 500, 750, 750, 1000, 1000]) == 1250000\n assert candidate(skill = [300, 700, 200, 800, 100, 900, 400, 600, 500, 500]) == 950000\n assert candidate(skill = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 1250000\n assert candidate(skill = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 200\n assert candidate(skill = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 441\n assert candidate(skill = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 20000\n assert candidate(skill = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 6000\n assert candidate(skill = [123, 321, 213, 312, 132, 231, 213, 132]) == -1\n assert candidate(skill = [6, 3, 9, 2, 8, 4, 5, 7, 1, 10, 11, 12, 13, 14, 15, 16]) == 408\n assert candidate(skill = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 3080\n assert candidate(skill = [8, 6, 4, 2, 10, 12, 14, 16, 18, 20]) == 440\n assert candidate(skill = [1, 1000, 2, 999, 3, 998, 4, 997]) == 9980\n assert candidate(skill = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 84\n assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 18200\n assert candidate(skill = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 110\n assert candidate(skill = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 84\n assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 770\n assert candidate(skill = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 1500000\n assert candidate(skill = [499, 501, 498, 502, 497, 503, 496, 504]) == 999970\n assert candidate(skill = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16]) == 408\n assert candidate(skill = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 5994\n assert candidate(skill = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 7992\n assert candidate(skill = [5, 1, 4, 3, 2, 6]) == 28\n assert candidate(skill = [333, 333, 333, 333, 334, 334, 334, 334]) == 444888\n assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 770\n assert candidate(skill = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == 500000\n assert candidate(skill = [10, 10, 10, 10, 10, 10, 10, 10]) == 400\n assert candidate(skill = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 510\n assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 77000\n assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11000\n assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 408\n assert candidate(skill = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 384\n assert candidate(skill = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 335\n assert candidate(skill = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 14985\n assert candidate(skill = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10]) == 54615\n assert candidate(skill = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n assert candidate(skill = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == 375000\n assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 280\n assert candidate(skill = [1, 999, 2, 998, 3, 997, 4, 996, 5, 995]) == 14945\n assert candidate(skill = [100, 200, 300, 400, 100, 200, 300, 400, 500, 600, 500, 600]) == 560000\n assert candidate(skill = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 110\n assert candidate(skill = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 490\n assert candidate(skill = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 2000000\n assert candidate(skill = [15, 16, 15, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 1820\n assert candidate(skill = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 600\n assert candidate(skill = [100, 200, 300, 400, 500, 600, 700, 800]) == 600000\n assert candidate(skill = [999, 1, 999, 1, 999, 1, 999, 1]) == 3996\n assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 110\n assert candidate(skill = [600, 400, 600, 400, 600, 400, 600, 400, 600, 400, 600, 400]) == 1440000\n assert candidate(skill = [1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000]) == 5000\n assert candidate(skill = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n assert candidate(skill = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 288\n assert candidate(skill = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 8000\n assert candidate(skill = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 220\n assert candidate(skill = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(skill = [1, 9, 1, 9, 1, 9, 1, 9]) == 36\n assert candidate(skill = [300, 700, 200, 800, 400, 600, 100, 900, 500, 500, 400, 600]) == 1190000\n assert candidate(skill = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 335\n assert candidate(skill = [150, 250, 150, 250, 150, 250, 150, 250, 150, 250]) == 187500\n assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 22000\n assert candidate(skill = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 200\n assert candidate(skill = [1000, 1, 999, 2, 998, 3, 997, 4]) == 9980\n assert candidate(skill = [8, 1, 5, 3, 4, 7, 2, 6, 9, 10, 12, 11]) == 182\n assert candidate(skill = [10, 1, 10, 1, 10, 1, 10, 1]) == 40\n assert candidate(skill = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 125\n assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 40800\n assert candidate(skill = [5, 5, 5, 5, 5, 5, 5, 5]) == 100\n assert candidate(skill = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 20000\n assert candidate(skill = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 40\n assert candidate(skill = [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]) == -1\n assert candidate(skill = [250, 750, 250, 750, 250, 750, 250, 750, 250, 750, 250, 750, 250, 750, 250, 750]) == 1500000\n"}, "metadata": {"canonical_parameter_names": ["skill"], "leetcode_dataset_entry_point": "Solution().dividePlayers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long dividePlayers(int[] skill) {", "container": "Solution", "callable": "dividePlayers", "parameters": [{"name": "skill", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2492, "task_id": "minimum-score-of-a-path-between-two-cities", "difficulty": "Medium", "problem_description": "You are given a positive integer n representing n cities numbered from 1 to n. You are also given a 2D array roads where roads[i] = [ai, bi, distancei] indicates that there is a bidirectional road between cities ai and bi with a distance equal to distancei. The cities graph is not necessarily connected.\nThe score of a path between two cities is defined as the minimum distance of a road in this path.\nReturn the minimum possible score of a path between cities 1 and n.\nNote:\n\nA path is a sequence of roads between two cities.\nIt is allowed for a path to contain the same road multiple times, and you can visit cities 1 and n multiple times along the path.\nThe test cases are generated such that there is at least one path between 1 and n.\n\n \nExample 1:\n\n\nInput: n = 4, roads = [[1,2,9],[2,3,6],[2,4,5],[1,4,7]]\nOutput: 5\nExplanation: The path from city 1 to 4 with the minimum score is: 1 -> 2 -> 4. The score of this path is min(9,5) = 5.\nIt can be shown that no other path has less score.\n\nExample 2:\n\n\nInput: n = 4, roads = [[1,2,2],[1,3,4],[3,4,7]]\nOutput: 2\nExplanation: The path from city 1 to 4 with the minimum score is: 1 -> 2 -> 1 -> 3 -> 4. The score of this path is min(2,2,4,7) = 2.\n\n \nConstraints:\n\n2 <= n <= 105\n1 <= roads.length <= 105\nroads[i].length == 3\n1 <= ai, bi <= n\nai != bi\n1 <= distancei <= 104\nThere are no repeated edges.\nThere is at least one path between 1 and n.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,roads = [[1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [1, 5, 30]]) == 10\n assert candidate(n = 6,roads = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]]) == 1\n assert candidate(n = 4,roads = [[1, 2, 2], [1, 3, 4], [3, 4, 7]]) == 2\n assert candidate(n = 5,roads = [[1, 2, 10], [2, 3, 5], [3, 4, 2], [4, 5, 1]]) == 1\n assert candidate(n = 3,roads = [[1, 2, 5], [2, 3, 10], [1, 3, 7]]) == 5\n assert candidate(n = 6,roads = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [1, 6, 1]]) == 1\n assert candidate(n = 3,roads = [[1, 2, 1], [2, 3, 2], [1, 3, 3]]) == 1\n assert candidate(n = 4,roads = [[1, 2, 9], [2, 3, 6], [2, 4, 5], [1, 4, 7]]) == 5\n assert candidate(n = 3,roads = [[1, 2, 3], [2, 3, 1]]) == 1\n assert candidate(n = 5,roads = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 1], [1, 5, 2]]) == 1\n assert candidate(n = 6,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [1, 6, 60]]) == 10\n assert candidate(n = 9,roads = [[1, 2, 2], [2, 3, 4], [3, 4, 6], [4, 5, 8], [5, 6, 10], [6, 7, 12], [7, 8, 14], [8, 9, 16], [1, 9, 18], [2, 8, 20], [3, 7, 22], [4, 6, 24], [5, 9, 26], [1, 5, 28], [2, 6, 30], [3, 9, 32], [1, 7, 34], [2, 9, 36], [1, 4, 38], [1, 3, 40], [1, 6, 42]]) == 2\n assert candidate(n = 7,roads = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 6], [7, 1, 7], [2, 5, 8], [3, 6, 9]]) == 1\n assert candidate(n = 9,roads = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [1, 3, 2], [3, 5, 3], [5, 7, 4], [7, 9, 5]]) == 1\n assert candidate(n = 15,roads = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300], [14, 15, 1400], [1, 15, 50]]) == 50\n assert candidate(n = 10,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [1, 5, 15], [5, 9, 25]]) == 10\n assert candidate(n = 7,roads = [[1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [1, 3, 5], [3, 5, 5], [5, 7, 5], [1, 4, 5], [4, 6, 5], [2, 4, 5], [3, 6, 5], [1, 6, 5], [2, 5, 5], [3, 7, 5]]) == 5\n assert candidate(n = 20,roads = [[1, 2, 20], [1, 3, 19], [2, 3, 18], [2, 4, 17], [3, 5, 16], [4, 5, 15], [5, 6, 14], [6, 7, 13], [7, 8, 12], [8, 9, 11], [9, 10, 10], [10, 11, 9], [11, 12, 8], [12, 13, 7], [13, 14, 6], [14, 15, 5], [15, 16, 4], [16, 17, 3], [17, 18, 2], [18, 19, 1], [19, 20, 20]]) == 1\n assert candidate(n = 10,roads = [[1, 2, 10], [1, 3, 5], [2, 4, 1], [2, 5, 8], [3, 6, 3], [4, 7, 2], [5, 8, 4], [6, 9, 6], [7, 10, 7], [8, 10, 9], [1, 10, 12]]) == 1\n assert candidate(n = 6,roads = [[1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 1, 1], [2, 6, 10]]) == 1\n assert candidate(n = 12,roads = [[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], [1, 12, 1], [2, 10, 2], [4, 11, 3]]) == 1\n assert candidate(n = 15,roads = [[1, 2, 2], [2, 3, 4], [3, 4, 5], [4, 5, 1], [1, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [9, 10, 7], [10, 11, 8], [11, 12, 9], [12, 13, 10], [13, 14, 11], [14, 15, 12]]) == 1\n assert candidate(n = 8,roads = [[1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 1, 9], [1, 3, 10], [2, 4, 11], [3, 5, 12], [4, 6, 13], [5, 7, 14], [6, 8, 15], [1, 4, 16], [2, 5, 17], [3, 6, 18], [4, 7, 19], [5, 8, 20], [1, 5, 21], [2, 6, 22], [3, 7, 23], [4, 8, 24]]) == 2\n assert candidate(n = 15,roads = [[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], [1, 15, 15]]) == 1\n assert candidate(n = 8,roads = [[1, 2, 100], [2, 3, 101], [3, 4, 102], [4, 5, 103], [5, 6, 104], [6, 7, 105], [7, 8, 106], [8, 1, 1], [2, 8, 200], [3, 7, 300]]) == 1\n assert candidate(n = 8,roads = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 6], [7, 8, 7], [1, 8, 10], [2, 7, 8], [3, 6, 9], [4, 5, 11]]) == 1\n assert candidate(n = 6,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [1, 6, 5]]) == 5\n assert candidate(n = 6,roads = [[1, 3, 10], [1, 4, 20], [3, 4, 15], [4, 6, 30], [6, 5, 25], [5, 2, 5]]) == 5\n assert candidate(n = 7,roads = [[1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [1, 7, 5], [1, 3, 5], [3, 5, 5], [5, 7, 5]]) == 5\n assert candidate(n = 8,roads = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 1, 800], [1, 4, 150], [2, 5, 250], [3, 6, 350], [4, 7, 450], [5, 8, 550], [6, 1, 650], [7, 2, 750], [8, 3, 850]]) == 100\n assert candidate(n = 10,roads = [[1, 2, 5], [2, 3, 3], [3, 4, 7], [4, 5, 2], [5, 6, 6], [6, 7, 8], [7, 8, 4], [8, 9, 9], [9, 10, 1], [1, 10, 11], [2, 4, 12], [3, 5, 13], [4, 6, 14], [5, 7, 15], [6, 8, 16], [7, 9, 17], [8, 10, 18], [9, 1, 19], [10, 2, 20]]) == 1\n assert candidate(n = 5,roads = [[1, 2, 1000], [2, 3, 999], [3, 4, 998], [4, 5, 997], [1, 3, 996], [2, 4, 995], [3, 5, 994], [1, 4, 993], [2, 5, 992], [1, 5, 991]]) == 991\n assert candidate(n = 7,roads = [[1, 2, 2], [2, 3, 5], [3, 4, 7], [4, 5, 3], [5, 6, 8], [6, 7, 1], [1, 7, 6], [2, 6, 4], [3, 5, 9], [1, 5, 10]]) == 1\n assert candidate(n = 15,roads = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 5], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [1, 15, 20]]) == 1\n assert candidate(n = 8,roads = [[1, 2, 50], [2, 3, 40], [3, 4, 30], [4, 5, 20], [5, 6, 10], [6, 7, 5], [7, 8, 1], [8, 1, 30], [2, 4, 25], [4, 6, 15], [6, 8, 5]]) == 1\n assert candidate(n = 10,roads = [[1, 2, 5], [1, 3, 2], [2, 4, 3], [3, 4, 1], [4, 5, 6], [5, 6, 4], [6, 7, 9], [7, 8, 8], [8, 9, 7], [9, 10, 10]]) == 1\n assert candidate(n = 10,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [1, 5, 15], [2, 6, 25], [3, 7, 35], [4, 8, 45]]) == 10\n assert candidate(n = 8,roads = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 1, 8], [1, 3, 9], [2, 4, 10], [3, 5, 11], [4, 6, 12], [5, 7, 13], [6, 8, 14]]) == 1\n assert candidate(n = 9,roads = [[1, 2, 15], [1, 4, 10], [2, 3, 5], [2, 5, 3], [3, 6, 7], [4, 5, 2], [4, 7, 6], [5, 8, 4], [6, 9, 8], [7, 8, 1], [8, 9, 9]]) == 1\n assert candidate(n = 6,roads = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [1, 6, 6], [1, 3, 7], [2, 4, 8], [3, 5, 9]]) == 1\n assert candidate(n = 7,roads = [[1, 2, 7], [1, 3, 15], [2, 3, 6], [2, 4, 9], [3, 5, 12], [4, 5, 10], [4, 6, 11], [5, 6, 8], [5, 7, 3], [6, 7, 2]]) == 2\n assert candidate(n = 7,roads = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [1, 7, 7], [2, 4, 8], [3, 5, 9]]) == 1\n assert candidate(n = 7,roads = [[1, 2, 5], [2, 3, 4], [3, 4, 6], [4, 5, 3], [5, 6, 2], [6, 7, 8], [1, 7, 7]]) == 2\n assert candidate(n = 20,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140], [15, 16, 150], [16, 17, 160], [17, 18, 170], [18, 19, 180], [19, 20, 190], [1, 20, 5]]) == 5\n assert candidate(n = 6,roads = [[1, 2, 5], [2, 3, 2], [3, 4, 8], [4, 5, 3], [5, 6, 1], [1, 6, 4]]) == 1\n assert candidate(n = 9,roads = [[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, 3, 10], [2, 4, 11], [3, 5, 12], [4, 6, 13], [5, 7, 14], [6, 8, 15], [7, 9, 16], [8, 1, 17], [9, 2, 18]]) == 1\n assert candidate(n = 10,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [1, 10, 5]]) == 5\n assert candidate(n = 6,roads = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [1, 6, 150], [1, 4, 250], [3, 6, 350], [2, 5, 450]]) == 100\n assert candidate(n = 8,roads = [[1, 2, 6], [2, 3, 3], [3, 4, 9], [4, 5, 4], [5, 6, 5], [6, 7, 2], [7, 8, 7], [8, 1, 8]]) == 2\n assert candidate(n = 10,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [1, 10, 1]]) == 1\n assert candidate(n = 10,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90]]) == 10\n assert candidate(n = 12,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [1, 12, 5]]) == 5\n assert candidate(n = 6,roads = [[1, 2, 5], [2, 3, 3], [3, 4, 7], [4, 5, 2], [5, 6, 4], [6, 1, 6], [1, 3, 10], [2, 4, 1], [3, 5, 8], [4, 6, 9], [5, 1, 7], [6, 2, 11]]) == 1\n assert candidate(n = 15,roads = [[1, 2, 10], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 1], [8, 9, 2], [9, 10, 3], [10, 11, 4], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 1, 15]]) == 1\n assert candidate(n = 7,roads = [[1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 5, 1], [5, 6, 1], [6, 7, 2], [1, 7, 5], [2, 7, 6], [3, 7, 7]]) == 1\n assert candidate(n = 12,roads = [[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, 1, 12], [1, 3, 3], [3, 5, 5], [5, 7, 7], [7, 9, 9], [9, 11, 11], [2, 4, 4], [4, 6, 6], [6, 8, 8], [8, 10, 10], [10, 12, 12]]) == 1\n assert candidate(n = 6,roads = [[1, 2, 100], [1, 3, 200], [2, 4, 300], [3, 5, 400], [4, 5, 500], [5, 6, 600], [2, 6, 700], [1, 4, 800], [3, 6, 900]]) == 100\n assert candidate(n = 15,roads = [[1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75], [15, 1, 80], [1, 3, 85], [3, 5, 90], [5, 7, 95], [7, 9, 100], [9, 11, 105], [11, 13, 110], [13, 15, 115], [2, 4, 120], [4, 6, 125], [6, 8, 130], [8, 10, 135], [10, 12, 140], [12, 14, 145], [14, 2, 150], [1, 4, 155], [4, 7, 160], [7, 10, 165], [10, 13, 170], [13, 1, 175], [2, 5, 180], [5, 8, 185], [8, 11, 190], [11, 14, 195], [14, 1, 200]]) == 10\n assert candidate(n = 10,roads = [[1, 2, 10], [1, 3, 9], [2, 4, 8], [2, 5, 7], [3, 5, 6], [4, 6, 5], [5, 6, 4], [6, 7, 3], [7, 8, 2], [8, 9, 1], [9, 10, 1]]) == 1\n assert candidate(n = 8,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [1, 8, 80], [2, 5, 90], [3, 6, 100], [4, 7, 110]]) == 10\n assert candidate(n = 10,roads = [[1, 2, 9], [2, 3, 6], [3, 4, 5], [4, 5, 7], [5, 6, 8], [6, 7, 4], [7, 8, 2], [8, 9, 1], [9, 10, 3], [10, 1, 10]]) == 1\n assert candidate(n = 20,roads = [[1, 2, 20], [2, 3, 19], [3, 4, 18], [4, 5, 17], [5, 6, 16], [6, 7, 15], [7, 8, 14], [8, 9, 13], [9, 10, 12], [10, 11, 11], [11, 12, 10], [12, 13, 9], [13, 14, 8], [14, 15, 7], [15, 16, 6], [16, 17, 5], [17, 18, 4], [18, 19, 3], [19, 20, 2], [20, 1, 1]]) == 1\n assert candidate(n = 8,roads = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 1], [5, 6, 2], [6, 7, 6], [7, 8, 5], [8, 1, 7]]) == 1\n assert candidate(n = 20,roads = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300], [14, 15, 1400], [15, 16, 1500], [16, 17, 1600], [17, 18, 1700], [18, 19, 1800], [19, 20, 1900], [20, 1, 2000], [1, 3, 2100], [3, 5, 2200], [5, 7, 2300], [7, 9, 2400], [9, 11, 2500], [11, 13, 2600], [13, 15, 2700], [15, 17, 2800], [17, 19, 2900], [19, 1, 3000], [2, 4, 3100], [4, 6, 3200], [6, 8, 3300], [8, 10, 3400], [10, 12, 3500], [12, 14, 3600], [14, 16, 3700], [16, 18, 3800], [18, 20, 3900], [1, 4, 4000], [4, 7, 4100], [7, 10, 4200], [10, 13, 4300], [13, 16, 4400], [16, 19, 4500], [19, 2, 4600], [2, 5, 4700], [5, 8, 4800], [8, 11, 4900], [11, 14, 5000], [14, 17, 5100], [17, 20, 5200], [20, 1, 5300]]) == 100\n assert candidate(n = 15,roads = [[1, 2, 15], [2, 3, 14], [3, 4, 13], [4, 5, 12], [5, 6, 11], [6, 7, 10], [7, 8, 9], [8, 9, 8], [9, 10, 7], [10, 11, 6], [11, 12, 5], [12, 13, 4], [13, 14, 3], [14, 15, 2], [1, 15, 1], [2, 14, 16], [3, 13, 17], [4, 12, 18], [5, 11, 19], [6, 10, 20], [7, 9, 21]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["n", "roads"], "leetcode_dataset_entry_point": "Solution().minScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minScore(int n, int[][] roads) {", "container": "Solution", "callable": "minScore", "parameters": [{"name": "n", "type": "int"}, {"name": "roads", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2493, "task_id": "divide-nodes-into-the-maximum-number-of-groups", "difficulty": "Hard", "problem_description": "You are given a positive integer n representing the number of nodes in an undirected graph. The nodes are labeled from 1 to n.\nYou are also given a 2D integer array edges, where edges[i] = [ai, bi] indicates that there is a bidirectional edge between nodes ai and bi. Notice that the given graph may be disconnected.\nDivide the nodes of the graph into m groups (1-indexed) such that:\n\nEach node in the graph belongs to exactly one group.\nFor every pair of nodes in the graph that are connected by an edge [ai, bi], if ai belongs to the group with index x, and bi belongs to the group with index y, then |y - x| = 1.\n\nReturn the maximum number of groups (i.e., maximum m) into which you can divide the nodes. Return -1 if it is impossible to group the nodes with the given conditions.\n \nExample 1:\n\n\nInput: n = 6, edges = [[1,2],[1,4],[1,5],[2,6],[2,3],[4,6]]\nOutput: 4\nExplanation: As shown in the image we:\n- Add node 5 to the first group.\n- Add node 1 to the second group.\n- Add nodes 2 and 4 to the third group.\n- Add nodes 3 and 6 to the fourth group.\nWe can see that every edge is satisfied.\nIt can be shown that that if we create a fifth group and move any node from the third or fourth group to it, at least on of the edges will not be satisfied.\n\nExample 2:\n\nInput: n = 3, edges = [[1,2],[2,3],[3,1]]\nOutput: -1\nExplanation: If we add node 1 to the first group, node 2 to the second group, and node 3 to the third group to satisfy the first two edges, we can see that the third edge will not be satisfied.\nIt can be shown that no grouping is possible.\n\n \nConstraints:\n\n1 <= n <= 500\n1 <= edges.length <= 104\nedges[i].length == 2\n1 <= ai, bi <= n\nai != bi\nThere is at most one edge between any pair of vertices.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 1], [4, 5]]) == -1\n assert candidate(n = 4,edges = [[1, 2], [3, 4]]) == 4\n assert candidate(n = 6,edges = [[1, 2], [1, 4], [1, 5], [2, 6], [2, 3], [4, 6]]) == 4\n assert candidate(n = 3,edges = [[1, 2], [2, 3], [3, 1]]) == -1\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 5\n assert candidate(n = 7,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == -1\n assert candidate(n = 4,edges = [[1, 2]]) == 4\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 3\n assert candidate(n = 7,edges = [[1, 2], [2, 3], [4, 5], [5, 6], [6, 7]]) == 7\n assert candidate(n = 4,edges = [[1, 2], [2, 3]]) == 4\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [1, 5]]) == 3\n assert candidate(n = 5,edges = [[1, 2], [3, 4]]) == 5\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10]]) == -1\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [1, 10]]) == 8\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [1, 6], [10, 11]]) == -1\n assert candidate(n = 50,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [26, 27], [27, 28], [28, 29], [29, 30], [30, 26], [31, 32], [32, 33], [33, 34], [34, 35], [35, 31], [36, 37], [37, 38], [38, 39], [39, 40], [40, 36], [41, 42], [42, 43], [43, 44], [44, 45], [45, 41], [46, 47], [47, 48], [48, 49], [49, 50], [50, 46]]) == -1\n assert candidate(n = 18,edges = [[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, 1], [1, 10], [10, 18]]) == -1\n assert candidate(n = 16,edges = [[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]]) == 16\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21]]) == -1\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7], [13, 14], [14, 15], [15, 13]]) == -1\n assert candidate(n = 25,edges = [[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], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25]]) == 25\n assert candidate(n = 15,edges = [[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], [1, 15]]) == -1\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [26, 27], [27, 28], [28, 29], [29, 30], [30, 26], [1, 6], [11, 16], [21, 26]]) == -1\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 5], [1, 5], [2, 6], [3, 7], [4, 8]]) == 4\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]]) == 12\n assert candidate(n = 16,edges = [[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\n assert candidate(n = 20,edges = [[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, 1]]) == 11\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == 7\n assert candidate(n = 15,edges = [[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(n = 6,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == -1\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 5], [5, 6], [6, 7], [7, 8]]) == -1\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16]]) == -1\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [26, 27], [27, 28], [28, 29], [29, 30], [30, 26]]) == -1\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 6\n assert candidate(n = 30,edges = [[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\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 1], [8, 2]]) == 6\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 10\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 6]]) == -1\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 9], [2, 8], [3, 7], [4, 6]]) == -1\n assert candidate(n = 20,edges = [[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(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 13], [13, 10], [14, 15], [15, 14]]) == -1\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 6], [13, 14], [14, 15]]) == -1\n assert candidate(n = 10,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 10\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7]]) == 8\n assert candidate(n = 20,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 20\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1]]) == 7\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [11, 12], [12, 13], [13, 14], [14, 15], [1, 11], [5, 15]]) == 11\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12]]) == 6\n assert candidate(n = 10,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [2, 3], [4, 5], [6, 7], [8, 9]]) == 10\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 12]]) == 7\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]]) == 4\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11]]) == -1\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10]]) == 8\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]) == -1\n assert candidate(n = 40,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [26, 27], [27, 28], [28, 29], [29, 30], [30, 26], [31, 32], [32, 33], [33, 34], [34, 35], [35, 31], [36, 37], [37, 38], [38, 39], [39, 40], [40, 36]]) == -1\n assert candidate(n = 16,edges = [[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, 1]]) == 9\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10]]) == 6\n assert candidate(n = 18,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 13], [13, 10], [14, 15], [15, 16], [16, 17], [17, 14], [18, 1]]) == -1\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8]]) == -1\n assert candidate(n = 25,edges = [[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, 1]]) == -1\n assert candidate(n = 15,edges = [[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], [1, 15]]) == 12\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [1, 6], [11, 16]]) == -1\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15]]) == 8\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7], [13, 14], [14, 15], [15, 16], [16, 13], [17, 18], [18, 19], [19, 20], [20, 17]]) == 14\n assert candidate(n = 25,edges = [[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, 1], [1, 11], [10, 18], [15, 25]]) == -1\n assert candidate(n = 22,edges = [[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, 1]]) == 12\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 12]]) == 7\n assert candidate(n = 18,edges = [[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]]) == 18\n assert candidate(n = 20,edges = [[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, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12]]) == 11\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [26, 27], [27, 28], [28, 29], [29, 30], [30, 26]]) == -1\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 6]]) == -1\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(n = 20,edges = [[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, 1], [1, 11]]) == -1\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == 5\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 6\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == -1\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [1, 4], [2, 5], [3, 6], [7, 10], [8, 11], [9, 12]]) == -1\n assert candidate(n = 30,edges = [[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, 1]]) == 16\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 2]]) == 8\n assert candidate(n = 18,edges = [[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], [1, 18]]) == 10\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().magnificentSets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int magnificentSets(int n, int[][] edges) {", "container": "Solution", "callable": "magnificentSets", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2496, "task_id": "maximum-value-of-a-string-in-an-array", "difficulty": "Easy", "problem_description": "The value of an alphanumeric string can be defined as:\n\nThe numeric representation of the string in base 10, if it comprises of digits only.\nThe length of the string, otherwise.\n\nGiven an array strs of alphanumeric strings, return the maximum value of any string in strs.\n \nExample 1:\n\nInput: strs = [\"alic3\",\"bob\",\"3\",\"4\",\"00000\"]\nOutput: 5\nExplanation: \n- \"alic3\" consists of both letters and digits, so its value is its length, i.e. 5.\n- \"bob\" consists only of letters, so its value is also its length, i.e. 3.\n- \"3\" consists only of digits, so its value is its numeric equivalent, i.e. 3.\n- \"4\" also consists only of digits, so its value is 4.\n- \"00000\" consists only of digits, so its value is 0.\nHence, the maximum value is 5, of \"alic3\".\n\nExample 2:\n\nInput: strs = [\"1\",\"01\",\"001\",\"0001\"]\nOutput: 1\nExplanation: \nEach string in the array has value 1. Hence, we return 1.\n\n \nConstraints:\n\n1 <= strs.length <= 100\n1 <= strs[i].length <= 9\nstrs[i] consists of only lowercase English letters and digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(strs = ['xyz', 'xyzz', 'xyzzz', 'xyzzzz']) == 6\n assert candidate(strs = ['a1', 'b2', 'c3', '1a', '2b', '3c']) == 2\n assert candidate(strs = ['abc', '123', 'a1b2c3', '000']) == 123\n assert candidate(strs = ['123456789', '987654321', '111111111', '222222222', '333333333']) == 987654321\n assert candidate(strs = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 1\n assert candidate(strs = ['alic3', 'bob', '3', '4', '00000']) == 5\n assert candidate(strs = ['abc', '123', 'abcd', '4567', '89']) == 4567\n assert candidate(strs = ['a', 'b', 'c', '1', '2', '3', '10', '11', '12']) == 12\n assert candidate(strs = ['987654321', 'abcdefg', 'hijklmn', '000000000']) == 987654321\n assert candidate(strs = ['987', '654', '321', '0', 'abcdefg']) == 987\n assert candidate(strs = ['1', '01', '001', '0001']) == 1\n assert candidate(strs = ['abc', '123', 'a1b2', '11111', 'zzzzz']) == 11111\n assert candidate(strs = ['hello', 'world', 'python', 'code']) == 6\n assert candidate(strs = ['111', '222', '333', '4444']) == 4444\n assert candidate(strs = ['000', '0000', '00000', '000000', '0000000']) == 0\n assert candidate(strs = ['98765', '4321', '11111', '222']) == 98765\n assert candidate(strs = ['abc', '123', 'def456', '7890']) == 7890\n assert candidate(strs = ['abc', '123', 'a1b2c3', '111111111']) == 111111111\n assert candidate(strs = ['a', 'b', 'c', 'd']) == 1\n assert candidate(strs = ['99999', '88888', '77777', '66666', '55555', '44444', '33333', '22222', '11111', '00000']) == 99999\n assert candidate(strs = ['1', '01', '001', '0001', '00001', '000001', '0000001', '00000001', '000000001']) == 1\n assert candidate(strs = ['123', '456', '789', 'abc', 'def', 'ghi', '1', '2', '3', '4', '5', '6', '7', '8', '9']) == 789\n assert candidate(strs = ['987654321', '123456789', 'abcdefghi', 'jklmnopqr', '000000000', '111111111', '222222222']) == 987654321\n assert candidate(strs = ['a1b2c3d4e', '111111111', 'fgh', '5678', 'ijklmno']) == 111111111\n assert candidate(strs = ['987', '654', '321', '000', '00', '0', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yz123']) == 987\n assert candidate(strs = ['abc', 'defg', 'hijkl', 'mnopqr', 'stuvwx', 'yz123', '456789', '000000000']) == 456789\n assert candidate(strs = ['0', '00', '000', '0000', '00000', '1', '01', '001', '0001']) == 1\n assert candidate(strs = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8', 'i9', 'j10', 'k11', 'l12', 'm13', 'n14', 'o15']) == 3\n assert candidate(strs = ['abcdefg', 'hijklmn', '0000000', '1234567', '890', 'opqrstu', 'vwxyz', '98765', '43210', '00001']) == 1234567\n assert candidate(strs = ['123abc', '456def', '789ghi', '0', '1', '2', '3', '4', '5']) == 6\n assert candidate(strs = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8', 'i9', 'j0']) == 2\n assert candidate(strs = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8', 'i9', 'j0', 'a1b2', 'c3d4', 'e5f6', 'g7h8', 'i9j0']) == 4\n assert candidate(strs = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8', 'i9', 'j0']) == 2\n assert candidate(strs = ['a', '1', 'ab', '12', 'abc', '123', 'abcd', '1234', 'abcde', '12345']) == 12345\n assert candidate(strs = ['1a2b3c4d5e6f7g8h9i0j', 'a1b2c3d4e5f6g7h8i9j01', 'abcde', '12345', 'fghij', '67890', 'klmno', '1234', 'pqrst', '5678', 'uvwxy', '90123', 'z']) == 90123\n assert candidate(strs = ['abc123', '456', 'def', '7890', 'ghi789']) == 7890\n assert candidate(strs = ['123', 'abc1', '234', 'bcd2', '345', 'cde3', '456', 'def4', '567', 'efg5']) == 567\n assert candidate(strs = ['abc123', 'def', 'ghi', '4567', '89', '0', 'abcdefg', 'hijklmn']) == 4567\n assert candidate(strs = ['abc123', '123abc', 'abc1', 'a1b2c3', '123456789']) == 123456789\n assert candidate(strs = ['123abc', '456def', '789ghi', 'abc123def', '456ghi789', '000abc123', '123456789', 'abcdef000']) == 123456789\n assert candidate(strs = ['a1', 'b2', 'c3', '1a', '2b', '3c', '10a', '20b', '30c']) == 3\n assert candidate(strs = ['abc123', 'def456', 'ghi789', 'jkl012', 'mno345', 'pqr678', 'stu901', 'vwx234', 'yz567', '0abc', '1def', '2ghi', '3jkl', '4mno', '5pqr', '6stu', '7vwx', '8yz', '9abc']) == 6\n assert candidate(strs = ['00001', '00002', '00003', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']) == 10\n assert candidate(strs = ['zzzzz', '00000', '11111', '22222', '33333', '44444']) == 44444\n assert candidate(strs = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyz', '0123456', '7890123', '4567890', '1234567', '8901234', '5678901']) == 8901234\n assert candidate(strs = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yz', '123456', '789012', '345678', '901234', '567890']) == 901234\n assert candidate(strs = ['1a', '2b', '3c', '4d', '5e', '6f', '7g', '8h', '9i', '0j']) == 2\n assert candidate(strs = ['a1b2c3', 'd4e5f6', 'g7h8i9', '00001', '0002', '03', '40', '500', '6000', '70000', '800000', '9000000', 'abcdefgh', 'ijklmnop', 'qrstuvwxyz']) == 9000000\n assert candidate(strs = ['0', '00', '000', '0000', '00000', '000000', '0000000', '00000000', '1', '2', '3', '4', '5', '6', '7', '8', '9']) == 9\n assert candidate(strs = ['987654321', '87654321', '7654321', '654321', '54321', '4321', '321', '21', '1', '0', 'a1b2c3d4e5f6g7h8i9j0']) == 987654321\n assert candidate(strs = ['00000000', '00000001', '00000010', '00000100', '00001000', '00010000', '00100000', '01000000', '10000000']) == 10000000\n assert candidate(strs = ['1234567', 'abcdefg', '7654321', 'gfedcba', '123abc', 'abc123', 'abc123abc', '123abc123', 'abc', '123', '1', 'a', '000', '999']) == 7654321\n assert candidate(strs = ['abcde123', '123abcde', 'abcd1234', '1234abcd', '11111111', '22222222', '33333333', '44444444', '55555555', '66666666', '77777777', '88888888', '99999999', '00000000']) == 99999999\n assert candidate(strs = ['00001', '00010', '00100', '01000', '10000', 'abcde', 'fghij', 'klmno', 'pqrst']) == 10000\n assert candidate(strs = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yz01', '2345', '6789', '0000', '1111', '2222', '3333', '4444', '5555', '6666', '7777', '8888', '9999']) == 9999\n assert candidate(strs = ['abc123', 'def', 'ghi456', '789', '012345678']) == 12345678\n assert candidate(strs = ['a1b', 'b2c', 'c3d', 'd4e', 'e5f', 'f6g', 'g7h', 'h8i', 'i9j', 'j0a', '1a2', '2b3', '3c4', '4d5', '5e6', '6f7', '7g8', '8h9', '9i0', '0j1']) == 3\n assert candidate(strs = ['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']) == 1\n assert candidate(strs = ['123', 'abc', '456', 'def', '789', 'ghi', '12', 'ab', '34', 'cd', '56', 'ef', '78', 'gh', '90', 'ij']) == 789\n assert candidate(strs = ['abc123', 'def456', '789', 'ghi', '012', 'jklmno789']) == 789\n assert candidate(strs = ['abcd123', 'efgh456', 'ijkl789', 'mnop000', 'qrst111', 'uvwx222', 'yz333', '444abc', '555def', '666ghi']) == 7\n assert candidate(strs = ['zzzzz', '99999', 'abcd', '00000', '123456789']) == 123456789\n assert candidate(strs = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi']) == 9\n assert candidate(strs = ['zzzz', 'aaaa', '123456789', 'abcdefghi', '000000000', '987654321']) == 987654321\n assert candidate(strs = ['987654321', 'abcdefghi', '123abc', '0', 'mnopqrstu']) == 987654321\n assert candidate(strs = ['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', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 30\n assert candidate(strs = ['111111111', 'abcdefghij', '987654321', '1234567890', '0000000001']) == 1234567890\n assert candidate(strs = ['999', '888', '777', '666', '555', '444', '333', '222', '111', '000']) == 999\n assert candidate(strs = ['abc1', 'def2', 'ghi3', '4', '5', '6', '7', '8', '9', '000000000', 'zzzzzzzzz', '111111111', '222222222', '333333333', '444444444', '555555555', '666666666', '777777777', '888888888', '999999999']) == 999999999\n assert candidate(strs = ['999', '1000', '0000999', '01000', 'abcde12345', '12345abcde', 'zzzzz', '99999', '000000000']) == 99999\n assert candidate(strs = ['123abc456', 'abc123def', '456def123', 'abcdef', '123456', '654321', 'abcdefg', 'hijklmn', 'opqrstu', '456789', '012345', '6543210', '0000000', '9999999', 'abcdef1', '1abcdef', 'a1b2c3d', 'd3c2b1a', '123456789', '987654321']) == 987654321\n assert candidate(strs = ['abcd', '1234', 'efgh', '5678', 'ijkl', '9012', 'mnop', '3456', 'qrst', '7890']) == 9012\n assert candidate(strs = ['abc123', 'def456', 'ghi789', '123456', '123456789']) == 123456789\n assert candidate(strs = ['zzz', 'zzzz', 'zzzzz', 'zzzzzz', 'zzzzzzz', 'zzzzzzzz', 'zzzzzzzzz', 'zzzzzzzzzz']) == 10\n assert candidate(strs = ['00001', '000002', '0000003', 'abc1', 'def2', 'ghi3', '1234', '4321', 'mnopq12345', '543210']) == 543210\n assert candidate(strs = ['zzz', '999', 'zzz999', '999zzz', 'zzz99', '99zzz', 'zz99', '99zz', 'z9', '9z', 'z', '9', '000000', '111111']) == 111111\n assert candidate(strs = ['123abc', 'abc123', '12345', '54321', 'abcde']) == 54321\n assert candidate(strs = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyz01', '2345678', '000000000', '123456789']) == 123456789\n assert candidate(strs = ['1', '01', '001', '0001', '00001', '000001', '0000001', '00000001', '000000001', '0000000001', '00000000001', '000000000001', '0000000000001', '00000000000001']) == 1\n assert candidate(strs = ['0', '00', '000', '0000', '00000', '000000', '0000000', '00000000', '1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000']) == 100000000\n assert candidate(strs = ['12345', '1234a', '54321', 'a1b2c3', '000000001']) == 54321\n assert candidate(strs = ['a1b2c3', '123abc', 'abc123', '007', '0x123', '999999', '123456789', 'abcdefghi']) == 123456789\n assert candidate(strs = ['abc123', '123abc', 'abc', '123', '000123', '123000']) == 123000\n assert candidate(strs = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', '11111', '22222', '33333', '44444', '55555']) == 55555\n assert candidate(strs = ['abcdef', '1', '0000001', '234567', 'ghijklm', '00000', 'nopqr', '00000000', '98765']) == 234567\n assert candidate(strs = ['xyz', '123', '456', '789', '000', '111', 'abc123', 'def456', 'ghi789']) == 789\n assert candidate(strs = ['a1b2c3', 'd4e5f6', 'g7h8i9', 'j0k1l2', 'm3n4o5', 'p6q7r8', 's9t0u1', 'v2w3x4', 'y5z6a7', 'b8c9d0']) == 6\n assert candidate(strs = ['a1b2c3', 'd4e5f6', 'g7h8i9', '01234', '56789', 'abcdefg', 'hijklmn', 'opqrstu', 'vwxyz01', '23456789']) == 23456789\n assert candidate(strs = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8', 'i9', '10', '11', '12', '13', '14', '15']) == 15\n assert candidate(strs = ['zzz', 'yyy', 'xxx', 'www', 'vvv', 'uuu', 'ttt', 'sss', 'rrr', 'qqq', 'ppp', 'ooo', 'nnn', 'mmm', 'lll', 'kkk', 'jjj', 'iii', 'hhh', 'ggg', 'fff', 'eee', 'ddd', 'ccc', 'bbb', 'aaa', '123456789', '987654321']) == 987654321\n assert candidate(strs = ['a1b2c3', '1a2b3c', 'abc123', '123abc', 'abc', '123', 'a1b2', '1a2b', 'ab12', '12ab', 'a1', '1a', 'a', '1']) == 123\n assert candidate(strs = ['0', '00', '000', '0000', '00000', '000000', '0000000', '00000000', '000000000']) == 0\n assert candidate(strs = ['abc', '123', '456', 'def', '789', 'ghi', '012', '345', '678', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz1']) == 789\n assert candidate(strs = ['abcdef', '123456', 'abcdefg', '1234567', 'abcdefgh', '12345678', 'abcdefghi', '123456789', 'abcdefghij']) == 123456789\n assert candidate(strs = ['abcdef', 'ghijkl', 'mnopqr', '123456', '789012', '321098', 'abcdefg', 'hijklmn', 'opqrstu', '456789', '012345', '654321']) == 789012\n assert candidate(strs = ['1234', '4321', '1111', '2222', '3333', '0000', '999', '8888', '77777', '666666']) == 666666\n assert candidate(strs = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '10', '20', '30', '40', '50']) == 50\n assert candidate(strs = ['a1b2c3', '1a2b3c', 'abc12', '12abc', 'a1b2', '1a2b', 'abc1', '1abc', 'a1', '1a', 'a', '1']) == 6\n assert candidate(strs = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno']) == 15\n assert candidate(strs = ['zzz', 'zzz9', 'zzz99', '9zzz', '99zzz', '999zz', 'zzz999', 'zzz9999', 'zzz99999']) == 8\n assert candidate(strs = ['zzzzzzzz', 'aaaaaaaa', '11111111', '22222222', '33333333', '44444444', '55555555', '66666666', '77777777', '88888888', '99999999', '12345678', '87654321', 'abcd1234', '4321dcba']) == 99999999\n assert candidate(strs = ['1a', '2b', '3c', '4d', '5e', '6f', '7g', '8h', '9i', '0j', '001', '002', '003', '004', '005', '006', '007', '008', '009', '000']) == 9\n assert candidate(strs = ['abc123', '123abc', 'abc', '123', '000000000', '999999999']) == 999999999\n assert candidate(strs = ['000000001', '00000002', '00000003', 'abcde', 'fghij', 'klmno', '6789', '987654321', '000000000']) == 987654321\n assert candidate(strs = ['0000000', '0000001', '0000002', '0000003', '0000004', '0000005', '0000006', '0000007', '0000008', '0000009']) == 9\n assert candidate(strs = ['a1b2c3', 'd4e5f6', 'g7h8i9', '10', '11', '12', '13', '14', '15']) == 15\n assert candidate(strs = ['a1b2c3', 'd4e5f6', 'g7h8i9', '00000', '987654321', '111111111']) == 987654321\n assert candidate(strs = ['00123', '000045', '0000067', '123', '4567', '89012']) == 89012\n assert candidate(strs = ['9876543210', '876543210', '76543210', '6543210', '543210', '43210', '3210', '210', '10', '0', 'abcdefghijklmnopqrstuvwxyz']) == 9876543210\n"}, "metadata": {"canonical_parameter_names": ["strs"], "leetcode_dataset_entry_point": "Solution().maximumValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumValue(String[] strs) {", "container": "Solution", "callable": "maximumValue", "parameters": [{"name": "strs", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2497, "task_id": "maximum-star-sum-of-a-graph", "difficulty": "Medium", "problem_description": "There is an undirected graph consisting of n nodes numbered from 0 to n - 1. You are given a 0-indexed integer array vals of length n where vals[i] denotes the value of the ith node.\nYou are also given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai and bi.\nA star graph is a subgraph of the given graph having a center node containing 0 or more neighbors. In other words, it is a subset of edges of the given graph such that there exists a common node for all edges.\nThe image below shows star graphs with 3 and 4 neighbors respectively, centered at the blue node.\n\nThe star sum is the sum of the values of all the nodes present in the star graph.\nGiven an integer k, return the maximum star sum of a star graph containing at most k edges.\n \nExample 1:\n\n\nInput: vals = [1,2,3,4,10,-10,-20], edges = [[0,1],[1,2],[1,3],[3,4],[3,5],[3,6]], k = 2\nOutput: 16\nExplanation: The above diagram represents the input graph.\nThe star graph with the maximum star sum is denoted by blue. It is centered at 3 and includes its neighbors 1 and 4.\nIt can be shown it is not possible to get a star graph with a sum greater than 16.\n\nExample 2:\n\nInput: vals = [-5], edges = [], k = 0\nOutput: -5\nExplanation: There is only one possible star graph, which is node 0 itself.\nHence, we return -5.\n\n \nConstraints:\n\nn == vals.length\n1 <= n <= 105\n-104 <= vals[i] <= 104\n0 <= edges.length <= min(n * (n - 1) / 2, 105)\nedges[i].length == 2\n0 <= ai, bi <= n - 1\nai != bi\n0 <= k <= n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(vals = [5, -2, 3, 1],edges = [[0, 1], [0, 2], [0, 3]],k = 3) == 9\n assert candidate(vals = [1, 2, 3],edges = [[0, 1], [1, 2]],k = 0) == 3\n assert candidate(vals = [1, 2, 3, 4, 10, -10, -20],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [3, 6]],k = 2) == 16\n assert candidate(vals = [100, 200, 300, 400, 500],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 4) == 1200\n assert candidate(vals = [-5],edges = [],k = 0) == -5\n assert candidate(vals = [5, 6, 7, 8, 9],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],k = 3) == 29\n assert candidate(vals = [1, 2, 3],edges = [[0, 1], [1, 2]],k = 0) == 3\n assert candidate(vals = [1, 3, -2, 5],edges = [[0, 1], [1, 2], [2, 3]],k = 1) == 5\n assert candidate(vals = [1, -1, 1, -1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 1) == 1\n assert candidate(vals = [100, 200, 300, 400, 500],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],k = 5) == 1200\n assert candidate(vals = [-1, -2, -3, -4, -5],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 2) == -1\n assert candidate(vals = [1, 2, 3],edges = [[0, 1], [1, 2]],k = 1) == 5\n assert candidate(vals = [5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3]],k = 3) == 15\n assert candidate(vals = [100, -200, 300, 400, -500],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 1) == 700\n assert candidate(vals = [10, -10, 20, -20, 30, -30],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == 30\n assert candidate(vals = [5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 0]],k = 3) == 15\n assert candidate(vals = [-10, -20, -30, -40],edges = [[0, 1], [1, 2], [2, 3]],k = 1) == -10\n assert candidate(vals = [5, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [0, 3], [0, 4]],k = 3) == 20\n assert candidate(vals = [10, -1, 2, 3, -4],edges = [[0, 1], [0, 2], [0, 3], [0, 4]],k = 2) == 15\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 3\n assert candidate(vals = [10, 20, 30, -40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2]],k = 3) == 110\n assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]],k = 5) == 350\n assert candidate(vals = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 3) == -1\n assert candidate(vals = [100, 200, 300, 400, 500, 600],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == 1500\n assert candidate(vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]],k = 4) == 0\n assert candidate(vals = [100, 200, 300, 400, 500],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [2, 3], [3, 4]],k = 4) == 1500\n assert candidate(vals = [5, -1, 3, 9, 2, -6, 7],edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 6]],k = 3) == 13\n assert candidate(vals = [100, -50, 20, -10, 5],edges = [[0, 1], [0, 2], [0, 3], [0, 4]],k = 3) == 125\n assert candidate(vals = [-5, -3, -10, -4, -1],edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4]],k = 2) == -1\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 10) == 27\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 3\n assert candidate(vals = [-10, 20, -30, 40, -50, 60],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]],k = 4) == 70\n assert candidate(vals = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2]],k = 3) == 140\n assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 270\n assert candidate(vals = [5, -1, 3, 7, 9, -2],edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 4], [4, 5]],k = 3) == 19\n assert candidate(vals = [10, 20, 30, 40, 50],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]],k = 2) == 120\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 5) == 6\n assert candidate(vals = [-10, -20, -30, -40, -50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],k = 2) == -10\n assert candidate(vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 5) == 0\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],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]],k = 7) == 42\n assert candidate(vals = [5, -3, 8, 0, 2],edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4]],k = 3) == 13\n assert candidate(vals = [5, 1, 3, 7, 9, 2, 8, 6],edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],k = 3) == 20\n assert candidate(vals = [10, 20, 30, 40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4]],k = 2) == 120\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 5) == 3\n assert candidate(vals = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 3) == -10\n assert candidate(vals = [-10, -20, -30, -40, -50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],k = 4) == -10\n assert candidate(vals = [5, 15, 25, 35, 45, 55],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]],k = 4) == 135\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],k = 3) == 24\n assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],k = 2) == 210\n assert candidate(vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 2) == 0\n assert candidate(vals = [10000, -10000, 5000, -5000, 2500, -2500],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 3) == 10000\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 4) == 35\n assert candidate(vals = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 2], [1, 3], [4, 6], [5, 7], [8, 0], [9, 1], [2, 4], [3, 5], [6, 8], [7, 9]],k = 3) == 12\n assert candidate(vals = [100, 200, 300, 400, 500],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],k = 5) == 1200\n assert candidate(vals = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 3) == 2700\n assert candidate(vals = [100, -50, 20, -30, 60, 10],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 4], [3, 5]],k = 3) == 180\n assert candidate(vals = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 10) == 27000\n assert candidate(vals = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],k = 3) == -10\n assert candidate(vals = [5, -5, 15, -15, 25, -25],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]],k = 4) == 25\n assert candidate(vals = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000, 7000, -7000, 8000, -8000, 9000, -9000, 10000, -10000],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [12, 14], [13, 15], [16, 18], [17, 19]],k = 4) == 19000\n assert candidate(vals = [100, 200, 300, 400, 500, 600, 700, 800, 900],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],k = 5) == 2400\n assert candidate(vals = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 9) == 50\n assert candidate(vals = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],edges = [],k = 3) == -1\n assert candidate(vals = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 50\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 5) == 41\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [4, 9]],k = 4) == 21\n assert candidate(vals = [-10, 20, 30, -40, 50, -60],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]],k = 4) == 50\n assert candidate(vals = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [4, 5]],k = 3) == 130\n assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [],k = 4) == 100\n assert candidate(vals = [100, -100, 200, -200, 300, -300],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 3], [1, 4], [2, 5]],k = 4) == 500\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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]],k = 10) == 3\n assert candidate(vals = [1, -1, 1, -1, 1, -1, 1, -1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]],k = 3) == 2\n assert candidate(vals = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],k = 1) == 5000\n assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]],k = 2) == 270\n assert candidate(vals = [-10, -20, -30, -40, -50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [1, 3], [2, 4]],k = 3) == -10\n assert candidate(vals = [5, -1, 2, 4, 6, -3],edges = [[0, 1], [0, 2], [0, 3], [1, 2], [2, 3], [3, 4], [4, 5]],k = 3) == 17\n assert candidate(vals = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 10) == 500\n assert candidate(vals = [100, 200, 300, 400, 500],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 0) == 500\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 0) == 10\n assert candidate(vals = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]],k = 4) == 12\n assert candidate(vals = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 3) == -1\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],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, 0]],k = 7) == 42\n assert candidate(vals = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 6) == 24\n assert candidate(vals = [-10, -20, -30, -40, -50, -60],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 0) == -10\n assert candidate(vals = [10000, -10000, 5000, -5000, 2500, -2500, 1250, -1250, 625, -625],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 4) == 10000\n assert candidate(vals = [-1000, -2000, -3000, -4000, -5000],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 3) == -1000\n assert candidate(vals = [-10, 20, 30, -40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 2], [1, 3]],k = 2) == 50\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 9]],k = 2) == 21\n assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 3) == 270\n assert candidate(vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 0\n assert candidate(vals = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],k = 4) == 25\n assert candidate(vals = [10, 20, 30, 40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3]],k = 3) == 140\n assert candidate(vals = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],k = 5) == 12\n assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 4) == 5\n assert candidate(vals = [10, -10, 20, -20, 30, -30, 40, -40],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [0, 2], [1, 3], [4, 6], [5, 7]],k = 2) == 70\n assert candidate(vals = [10, -5, 20, 0, 15],edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4]],k = 3) == 35\n assert candidate(vals = [50, 30, 10, -10, -30, -50, -70, 90, 110],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [1, 3], [2, 4], [5, 7]],k = 6) == 250\n assert candidate(vals = [5, 15, 25, 35, 45, 55, 65],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6], [0, 3], [1, 4], [2, 5]],k = 5) == 190\n assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 7], [7, 8], [8, 9]],k = 5) == 320\n assert candidate(vals = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],edges = [],k = 2) == -1\n assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 10) == 270\n assert candidate(vals = [5, 10, 15, 20, 25, 30],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]],k = 2) == 75\n assert candidate(vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 3) == 0\n assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [],k = 5) == 10\n assert candidate(vals = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 5000\n assert candidate(vals = [-10000, 10000, -9000, 9000, -8000, 8000, -7000, 7000, -6000, 6000],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 2) == 10000\n assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],k = 5) == 310\n"}, "metadata": {"canonical_parameter_names": ["vals", "edges", "k"], "leetcode_dataset_entry_point": "Solution().maxStarSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxStarSum(int[] vals, int[][] edges, int k) {", "container": "Solution", "callable": "maxStarSum", "parameters": [{"name": "vals", "type": "int[]"}, {"name": "edges", "type": "int[][]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2498, "task_id": "frog-jump-ii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array stones sorted in strictly increasing order representing the positions of stones in a river.\nA frog, initially on the first stone, wants to travel to the last stone and then return to the first stone. However, it can jump to any stone at most once.\nThe length of a jump is the absolute difference between the position of the stone the frog is currently on and the position of the stone to which the frog jumps.\n\nMore formally, if the frog is at stones[i] and is jumping to stones[j], the length of the jump is |stones[i] - stones[j]|.\n\nThe cost of a path is the maximum length of a jump among all jumps in the path.\nReturn the minimum cost of a path for the frog.\n \nExample 1:\n\n\nInput: stones = [0,2,5,6,7]\nOutput: 5\nExplanation: The above figure represents one of the optimal paths the frog can take.\nThe cost of this path is 5, which is the maximum length of a jump.\nSince it is not possible to achieve a cost of less than 5, we return it.\n\nExample 2:\n\n\nInput: stones = [0,3,9]\nOutput: 9\nExplanation: \nThe frog can jump directly to the last stone and come back to the first stone. \nIn this case, the length of each jump will be 9. The cost for the path will be max(9, 9) = 9.\nIt can be shown that this is the minimum achievable cost.\n\n \nConstraints:\n\n2 <= stones.length <= 105\n0 <= stones[i] <= 109\nstones[0] == 0\nstones is sorted in a strictly increasing order.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [0, 10, 15, 20, 25]) == 15\n assert candidate(stones = [0, 1, 2, 3, 4, 5]) == 2\n assert candidate(stones = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(stones = [0, 2, 5, 6, 7]) == 5\n assert candidate(stones = [0, 1, 3, 6, 10, 15]) == 9\n assert candidate(stones = [0, 5, 10, 15, 20, 25, 30]) == 10\n assert candidate(stones = [0, 3, 9]) == 9\n assert candidate(stones = [0, 10, 15, 25, 30]) == 15\n assert candidate(stones = [0, 10, 20, 30, 40]) == 20\n assert candidate(stones = [0, 1, 3, 5, 7, 9]) == 4\n assert candidate(stones = [0, 1, 3, 5, 10]) == 7\n assert candidate(stones = [0, 100, 200, 300, 400]) == 200\n assert candidate(stones = [0, 9, 20, 33, 48, 65, 84, 105, 128, 153, 180, 209, 240, 273, 308, 345, 384, 425, 468, 513, 560, 609, 660, 713, 768, 825]) == 112\n assert candidate(stones = [0, 5, 14, 27, 44, 65, 90, 121, 158, 201, 250]) == 92\n assert candidate(stones = [0, 1, 4, 10, 22, 46, 94, 190, 382, 766, 1534, 3070, 6142, 12286]) == 9216\n assert candidate(stones = [0, 11, 24, 39, 56, 75, 96, 119, 144, 171, 200, 231, 264, 300, 339, 380, 423, 468, 515, 564, 615, 668, 723, 780, 840, 903, 968, 1035, 1104, 1175]) == 140\n assert candidate(stones = [0, 3, 8, 16, 28, 44, 63, 85, 110, 138, 169, 203, 240, 279, 321]) == 81\n assert candidate(stones = [0, 1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106, 121, 137, 154, 172, 191, 211, 232, 254, 277, 301, 326, 352, 379]) == 53\n assert candidate(stones = [0, 100, 250, 450, 700, 1000, 1350, 1750, 2200, 2700]) == 950\n assert candidate(stones = [0, 10, 25, 45, 70, 100, 140, 185, 240, 305, 380, 470, 575, 695, 830, 980]) == 285\n assert candidate(stones = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 6144\n assert candidate(stones = [0, 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, 67108863, 134217727, 268435455, 536870911, 1073741823]) == 805306368\n assert candidate(stones = [0, 5, 15, 30, 50, 75, 105, 140, 180, 225]) == 85\n assert candidate(stones = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383]) == 12288\n assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]) == 17\n assert candidate(stones = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 6144\n assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462, 506, 552, 600]) == 94\n assert candidate(stones = [0, 1, 4, 10, 19, 31, 46, 64, 85, 109, 136]) == 51\n assert candidate(stones = [0, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176, 210, 247, 287, 330]) == 83\n assert candidate(stones = [0, 2, 4, 7, 11, 16, 22]) == 11\n assert candidate(stones = [0, 10, 15, 25, 35, 50, 75, 110, 150, 200, 260, 330, 410, 500, 600, 710, 830, 960, 1100, 1250, 1410, 1580, 1760, 1950, 2150, 2360, 2580, 2810, 3050, 3300, 3560, 3830, 4110, 4400, 4700, 5010, 5330, 5660, 6000, 6350, 6710, 7080, 7460, 7850, 8250, 8660, 9080, 9510, 9950, 10400, 10860, 11330, 11810, 12300, 12800, 13310, 13830, 14360, 14900, 15450, 16010, 16580, 17160, 17750, 18350, 18960, 19580, 20210, 20850, 21500, 22160, 22830, 23510, 24200, 24900, 25610, 26330, 27060, 27800, 28550, 29310, 30080, 30860, 31650, 32450, 33260, 34080, 34910, 35750, 36600, 37460, 38330, 39210, 40100, 41000, 41910, 42830, 43760, 44700, 45650, 46610, 47580, 48560, 49550, 50550, 51560, 52580, 53610, 54650, 55700, 56760, 57830, 58910, 60000]) == 2170\n assert candidate(stones = [0, 1, 5, 14, 29, 50, 81, 122, 173, 234, 305, 386, 477, 578, 689, 810, 941, 1082, 1233, 1394, 1565, 1746, 1937, 2148, 2379, 2620, 2871, 3132, 3403, 3684, 3975, 4276, 4587, 4908, 5239, 5580, 5931, 6292, 6663, 7044, 7435, 7836, 8247, 8668, 9099, 9540, 9991, 10452, 10923, 11404, 11895, 12406, 12937, 13488, 14059, 14640, 15231, 15832, 16443, 17064, 17695, 18336, 18987, 19648, 20320]) == 1333\n assert candidate(stones = [0, 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, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647]) == 1610612736\n assert candidate(stones = [0, 4, 9, 16, 25, 36, 49, 64, 81, 100]) == 36\n assert candidate(stones = [0, 3, 9, 18, 30, 45, 63, 84, 108, 135, 165, 198, 234, 273, 315, 360, 408, 459, 513, 570]) == 111\n assert candidate(stones = [0, 3, 7, 12, 20, 30, 45, 65, 90]) == 45\n assert candidate(stones = [0, 2, 7, 15, 26, 39, 54, 71, 90, 111, 134, 159]) == 48\n assert candidate(stones = [0, 3, 8, 15, 24, 35, 48, 63, 80, 99, 120, 143, 168, 195, 224]) == 56\n assert candidate(stones = [0, 5, 10, 20, 35, 55, 80, 110, 145, 185, 230, 280, 335, 395, 460, 530, 605, 685, 770, 860, 955, 1055, 1160, 1270, 1385, 1505, 1630, 1760, 1895, 2035]) == 275\n assert candidate(stones = [0, 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728, 2197, 2744, 3375, 4096]) == 1352\n assert candidate(stones = [0, 5, 14, 27, 42, 60, 81, 105]) == 45\n assert candidate(stones = [0, 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]) == 200\n assert candidate(stones = [0, 8, 18, 30, 44, 60, 78, 98, 120, 144, 170, 198, 228, 260, 294, 330, 368, 408, 450, 494, 540]) == 90\n assert candidate(stones = [0, 3, 8, 15, 25, 38, 54, 73]) == 35\n assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380]) == 74\n assert candidate(stones = [0, 5, 12, 20, 28, 36, 45, 55, 66, 78, 90]) == 24\n assert candidate(stones = [0, 10, 30, 60, 100, 150, 210, 280, 360, 450, 550, 660, 780, 910, 1050, 1200]) == 290\n assert candidate(stones = [0, 6, 14, 24, 36, 50, 66, 84, 104, 126, 150, 176, 204, 234, 266, 300, 336]) == 70\n assert candidate(stones = [0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65]) == 21\n assert candidate(stones = [0, 2, 8, 12, 15, 20, 25, 30]) == 10\n assert candidate(stones = [0, 1, 5, 14, 28, 47, 71, 100, 134, 173, 217, 266, 320, 379, 443, 512, 586, 665, 749, 834, 922, 1015, 1113, 1216]) == 201\n assert candidate(stones = [0, 2, 5, 8, 13, 21, 28, 35, 40]) == 15\n assert candidate(stones = [0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90]) == 25\n assert candidate(stones = [0, 1, 5, 11, 19, 29, 41, 55, 71, 89, 109, 131, 155, 181, 209, 239, 271, 305, 341, 379, 419, 461, 505, 551, 600, 651, 704, 759, 817, 877, 940, 1005, 1072, 1141, 1212, 1285, 1360, 1437, 1516, 1597, 1680, 1765, 1852, 1941, 2032, 2125, 2220, 2317, 2416, 2517, 2620, 2725, 2832, 2941, 3052, 3165, 3280, 3400, 3523, 3648, 3775, 3904, 4035, 4168, 4303, 4440, 4580, 4722, 4867, 5014, 5163, 5314, 5467, 5622, 5779, 5938, 6099, 6262, 6427, 6594, 6763, 6934, 7107, 7282, 7459, 7638, 7819, 8002, 8187, 8374, 8563, 8754, 8947, 9142, 9339, 9538, 9739, 9942]) == 404\n assert candidate(stones = [0, 3, 7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273, 307, 343, 381, 421, 463, 507, 553, 601]) == 94\n assert candidate(stones = [0, 2, 5, 9, 14, 20, 27, 35, 44]) == 17\n assert candidate(stones = [0, 2, 6, 18, 54, 162, 486, 1458, 4374, 13122, 39366, 118098, 354294, 1062882, 3188646, 9565938, 28697814, 86093442, 258280326, 774840978, 2324522934]) == 2066242608\n assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 19\n assert candidate(stones = [0, 3, 8, 15, 24, 35, 48, 63, 80, 99, 120, 143, 168, 195, 224, 255, 288, 323, 360, 400]) == 77\n assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156]) == 46\n assert candidate(stones = [0, 1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106, 121, 137, 154, 172]) == 35\n assert candidate(stones = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 384\n assert candidate(stones = [0, 10, 30, 60, 100, 150, 210, 280, 360, 450, 550, 660, 780, 910, 1050]) == 270\n assert candidate(stones = [0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == 100\n assert candidate(stones = [0, 5, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 390, 455, 525]) == 135\n assert candidate(stones = [0, 10, 25, 40, 55, 70, 85, 100, 120, 140, 160, 180, 200]) == 40\n assert candidate(stones = [0, 10, 25, 45, 70, 100, 135, 175, 220, 270, 325]) == 105\n assert candidate(stones = [0, 5, 11, 18, 26, 35, 45, 56, 68, 81, 95, 110, 126, 143, 161, 180, 200]) == 39\n assert candidate(stones = [0, 1, 3, 7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273, 307, 343, 381]) == 74\n assert candidate(stones = [0, 1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106, 121, 137, 154, 172, 191, 211, 232, 254, 277, 301, 326, 352, 379, 407, 436, 466, 497, 529, 562, 596, 631, 667, 704, 742, 781, 821, 862, 904, 947, 991, 1036, 1082, 1129, 1177, 1226, 1276, 1327, 1379, 1432, 1486, 1541, 1597, 1654, 1712, 1771, 1831, 1892, 1954, 2017, 2081, 2146, 2212, 2279, 2347, 2416, 2486, 2557, 2629, 2702, 2776, 2851, 2927, 3004, 3082, 3161, 3241, 3322, 3404, 3487, 3571, 3656, 3742, 3829, 3917, 4006, 4096, 4187, 4279, 4372, 4466, 4561, 4657, 4754, 4852, 4951, 5051]) == 199\n assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 39\n assert candidate(stones = [0, 2, 7, 17, 32, 52, 77, 107, 142, 182, 227, 277, 332, 392]) == 115\n assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380]) == 74\n assert candidate(stones = [0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90, 104]) == 27\n assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]) == 17\n assert candidate(stones = [0, 1, 5, 14, 29, 49, 74, 104, 139, 179, 218]) == 79\n assert candidate(stones = [0, 5, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 390]) == 115\n assert candidate(stones = [0, 1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969, 1140, 1330]) == 361\n assert candidate(stones = [0, 7, 16, 27, 40, 55, 72, 91, 112, 135, 160, 187, 216, 247, 280, 315, 352, 391, 432, 475]) == 84\n assert candidate(stones = [0, 10, 21, 33, 46, 60, 75, 91, 108, 126, 145, 165, 186, 208, 231, 255, 280, 306, 333, 361, 390, 420, 451, 483, 516]) == 65\n assert candidate(stones = [0, 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]) == 63\n assert candidate(stones = [0, 1, 4, 10, 19, 31, 46, 64, 85, 109, 136, 166, 200]) == 64\n assert candidate(stones = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 76\n assert candidate(stones = [0, 1, 4, 10, 15, 23, 30, 35]) == 15\n assert candidate(stones = [0, 1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106, 121, 137, 154, 172, 191, 211, 232, 254, 277, 301, 326, 352, 379, 407, 436, 466, 497, 529, 562, 596, 631, 667, 704, 742, 781, 821, 862, 904, 947, 991]) == 87\n assert candidate(stones = [0, 10, 25, 45, 70, 100, 135, 175, 220, 270]) == 95\n assert candidate(stones = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 6\n assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462, 506, 552, 600]) == 94\n assert candidate(stones = [0, 3, 7, 14, 22, 31, 40, 50, 60, 70]) == 20\n assert candidate(stones = [0, 1, 4, 8, 15, 23, 36, 55, 89, 144]) == 89\n assert candidate(stones = [0, 5, 13, 24, 37, 52, 69, 88, 109, 132, 157, 184, 213, 244, 277, 312, 349, 388, 429]) == 80\n assert candidate(stones = [0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368]) == 28657\n assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420]) == 78\n assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190]) == 37\n assert candidate(stones = [0, 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]) == 124\n assert candidate(stones = [0, 2, 6, 14, 25, 40, 58, 79, 103, 130, 160, 193, 230, 270, 315]) == 85\n assert candidate(stones = [0, 1, 4, 9, 16, 25, 36, 49, 64]) == 28\n assert candidate(stones = [0, 2, 5, 7, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 10\n assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28]) == 13\n assert candidate(stones = [0, 1, 5, 14, 29, 49, 74, 104, 139, 179, 218, 258, 300, 344, 391, 441, 494, 550, 610, 674, 742, 815, 893, 976]) == 161\n assert candidate(stones = [0, 5, 15, 30, 50, 75, 105, 140, 180]) == 75\n assert candidate(stones = [0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90, 104, 119, 135, 152, 170, 189, 209, 230, 252, 275, 299, 324, 350, 377, 405, 434, 464, 495]) == 61\n assert candidate(stones = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]) == 44\n assert candidate(stones = [0, 5, 11, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 20\n assert candidate(stones = [0, 3, 8, 14, 21, 29, 38, 48, 59, 71, 84, 98]) == 27\n assert candidate(stones = [0, 10, 22, 36, 52, 70, 90, 112, 136, 162, 190, 220, 252, 286]) == 66\n"}, "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().maxJump", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxJump(int[] stones) {", "container": "Solution", "callable": "maxJump", "parameters": [{"name": "stones", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2499, "task_id": "minimum-total-cost-to-make-arrays-unequal", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2, of equal length n.\nIn one operation, you can swap the values of any two indices of nums1. The cost of this operation is the sum of the indices.\nFind the minimum total cost of performing the given operation any number of times such that nums1[i] != nums2[i] for all 0 <= i <= n - 1 after performing all the operations.\nReturn the minimum total cost such that nums1 and nums2 satisfy the above condition. In case it is not possible, return -1.\n \nExample 1:\n\nInput: nums1 = [1,2,3,4,5], nums2 = [1,2,3,4,5]\nOutput: 10\nExplanation: \nOne of the ways we can perform the operations is:\n- Swap values at indices 0 and 3, incurring cost = 0 + 3 = 3. Now, nums1 = [4,2,3,1,5]\n- Swap values at indices 1 and 2, incurring cost = 1 + 2 = 3. Now, nums1 = [4,3,2,1,5].\n- Swap values at indices 0 and 4, incurring cost = 0 + 4 = 4. Now, nums1 =[5,3,2,1,4].\nWe can see that for each index i, nums1[i] != nums2[i]. The cost required here is 10.\nNote that there are other ways to swap values, but it can be proven that it is not possible to obtain a cost less than 10.\n\nExample 2:\n\nInput: nums1 = [2,2,2,1,3], nums2 = [1,2,2,3,3]\nOutput: 10\nExplanation: \nOne of the ways we can perform the operations is:\n- Swap values at indices 2 and 3, incurring cost = 2 + 3 = 5. Now, nums1 = [2,2,1,2,3].\n- Swap values at indices 1 and 4, incurring cost = 1 + 4 = 5. Now, nums1 = [2,3,1,2,2].\nThe total cost needed here is 10, which is the minimum possible.\n\nExample 3:\n\nInput: nums1 = [1,2,2], nums2 = [1,2,2]\nOutput: -1\nExplanation: \nIt can be shown that it is not possible to satisfy the given conditions irrespective of the number of operations we perform.\nHence, we return -1.\n\n \nConstraints:\n\nn == nums1.length == nums2.length\n1 <= n <= 105\n1 <= nums1[i], nums2[i] <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == 2\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [6, 7, 8, 9, 10]) == 2\n assert candidate(nums1 = [1, 2, 2],nums2 = [1, 2, 2]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2]) == 0\n assert candidate(nums1 = [1, 2],nums2 = [2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == -1\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2],nums2 = [1, 1, 1, 2, 2, 2]) == 15\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [1, 1, 2, 2, 3, 3]) == 15\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == 1\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 2, 2, 2]) == 0\n assert candidate(nums1 = [5, 1, 3, 2, 4],nums2 = [4, 2, 1, 3, 5]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 2\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]) == -1\n assert candidate(nums1 = [5, 3, 1],nums2 = [4, 3, 2]) == 1\n assert candidate(nums1 = [5, 3, 2, 4, 1],nums2 = [5, 4, 1, 3, 2]) == 1\n assert candidate(nums1 = [1, 1, 2, 2],nums2 = [2, 2, 1, 1]) == 0\n assert candidate(nums1 = [1, 1, 2, 2, 3],nums2 = [1, 1, 2, 2, 3]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 10\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [9, 7, 5, 3, 1]) == 2\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 2\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 1, 2]) == 0\n assert candidate(nums1 = [5, 3, 3, 2, 1],nums2 = [5, 4, 4, 1, 2]) == 1\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]) == 0\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 0\n assert candidate(nums1 = [1],nums2 = [1]) == -1\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1]) == -1\n assert candidate(nums1 = [2, 2, 2, 1, 3],nums2 = [1, 2, 2, 3, 3]) == 10\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 2, 1, 2, 3, 4, 3, 4, 5, 6]) == 22\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 10]) == 18\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [3, 2, 1, 6, 5, 4, 9, 8, 11, 10]) == 21\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums1 = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3],nums2 = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 19\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(nums1 = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],nums2 = [1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6]) == 15\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums1 = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],nums2 = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 9]) == 36\n assert candidate(nums1 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 105\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 105\n assert candidate(nums1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3]) == 44\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3],nums2 = [2, 2, 2, 1, 1, 1, 3, 3, 3]) == 24\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\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]) == 0\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],nums2 = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5]) == 40\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 4, 4]) == 41\n assert candidate(nums1 = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(nums1 = [2, 3, 4, 5, 6, 1],nums2 = [6, 1, 2, 3, 4, 5]) == 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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 1, 9]) == 28\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],nums2 = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7]) == 0\n assert candidate(nums1 = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10],nums2 = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 35\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 105\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 101\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums1 = [5, 1, 3, 2, 4, 6, 7, 8, 9, 10],nums2 = [10, 5, 4, 3, 2, 1, 8, 7, 6, 9]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 2]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == 0\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 9\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4],nums2 = [1, 3, 3, 2, 2, 5, 5]) == 1\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]) == 45\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],nums2 = [6, 2, 1, 3, 3, 4, 4, 5, 5, 1]) == 34\n assert candidate(nums1 = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7]) == 3\n assert candidate(nums1 = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 9\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 2, 1, 2, 3, 4, 3, 4, 5, 6]) == 22\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 45\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],nums2 = [6, 2, 2, 6, 6, 2, 2, 6, 6, 2, 2]) == 6\n assert candidate(nums1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 66\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 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]) == 45\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -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],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == -1\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]) == 0\n assert candidate(nums1 = [7, 7, 8, 8, 9, 9, 10, 10],nums2 = [8, 8, 7, 7, 10, 10, 9, 9]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],nums2 = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 12\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4],nums2 = [4, 4, 4, 3, 3, 3, 2, 2, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 11]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 20\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 10\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [2, 2, 1, 1, 4, 4, 3, 3, 5, 5]) == 18\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 0\n assert candidate(nums1 = [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],nums2 = [1, 1, 1, 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]) == 511\n assert candidate(nums1 = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 42\n assert candidate(nums1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],nums2 = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [4, 5, 4, 3, 2, 1, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3],nums2 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3]) == 45\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, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 190\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 45\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9]) == 28\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 0\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, 2, 3, 3, 4, 4, 5, 5, 6],nums2 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 45\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 9\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 36\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 0\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 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == 90\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minimumTotalCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumTotalCost(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "minimumTotalCost", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2500, "task_id": "delete-greatest-value-in-each-row", "difficulty": "Easy", "problem_description": "You are given an m x n matrix grid consisting of positive integers.\nPerform the following operation until grid becomes empty:\n\nDelete the element with the greatest value from each row. If multiple such elements exist, delete any of them.\nAdd the maximum of deleted elements to the answer.\n\nNote that the number of columns decreases by one after each operation.\nReturn the answer after performing the operations described above.\n \nExample 1:\n\n\nInput: grid = [[1,2,4],[3,3,1]]\nOutput: 8\nExplanation: The diagram above shows the removed values in each step.\n- In the first operation, we remove 4 from the first row and 3 from the second row (notice that, there are two cells with value 3 and we can remove any of them). We add 4 to the answer.\n- In the second operation, we remove 2 from the first row and 3 from the second row. We add 3 to the answer.\n- In the third operation, we remove 1 from the first row and 1 from the second row. We add 1 to the answer.\nThe final answer = 4 + 3 + 1 = 8.\n\nExample 2:\n\n\nInput: grid = [[10]]\nOutput: 10\nExplanation: The diagram above shows the removed values in each step.\n- In the first operation, we remove 10 from the first row. We add 10 to the answer.\nThe final answer = 10.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 50\n1 <= grid[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 24\n assert candidate(grid = [[5, 1, 3], [4, 2, 6], [7, 8, 9]]) == 24\n assert candidate(grid = [[5, 1, 3], [9, 3, 5], [7, 6, 2]]) == 18\n assert candidate(grid = [[10]]) == 10\n assert candidate(grid = [[1, 2, 4], [3, 3, 1]]) == 8\n assert candidate(grid = [[5, 3], [9, 7], [2, 6]]) == 16\n assert candidate(grid = [[1, 3, 5, 7], [2, 4, 6, 8]]) == 20\n assert candidate(grid = [[5, 3], [9, 7]]) == 16\n assert candidate(grid = [[1, 3, 5, 7], [10, 8, 6, 4]]) == 28\n assert candidate(grid = [[1, 2], [3, 4], [5, 6]]) == 11\n assert candidate(grid = [[2, 2, 2], [2, 2, 2], [2, 2, 2]]) == 6\n assert candidate(grid = [[100, 100], [100, 100], [100, 100]]) == 200\n assert candidate(grid = [[1, 3, 5], [2, 4, 6], [3, 6, 9], [4, 8, 12]]) == 24\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) == 51\n assert candidate(grid = [[50, 49, 48, 47], [46, 45, 44, 43], [42, 41, 40, 39], [38, 37, 36, 35]]) == 194\n assert candidate(grid = [[45, 23, 67, 89, 12], [90, 34, 56, 78, 10], [11, 13, 15, 17, 19], [21, 22, 24, 25, 26]]) == 279\n assert candidate(grid = [[3, 1, 4, 1, 5, 9], [2, 6, 5, 3, 5, 9], [8, 9, 7, 9, 3, 2], [4, 5, 6, 8, 0, 1]]) == 38\n assert candidate(grid = [[4, 8, 12, 16, 20], [3, 7, 11, 15, 19], [2, 6, 10, 14, 18], [1, 5, 9, 13, 17]]) == 60\n assert candidate(grid = [[23, 34, 45, 56], [12, 23, 34, 45], [56, 67, 78, 89], [90, 10, 20, 30]]) == 291\n assert candidate(grid = [[7, 8, 9], [4, 5, 6], [1, 2, 3], [7, 8, 9], [4, 5, 6], [1, 2, 3]]) == 24\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, 1, 3, 5, 7, 9], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]]) == 165\n assert candidate(grid = [[1, 3, 5, 7, 9], [10, 8, 6, 4, 2], [11, 13, 15, 17, 19], [20, 18, 16, 14, 12]]) == 80\n assert candidate(grid = [[50, 45, 40], [35, 30, 25], [20, 15, 10], [5, 10, 15], [20, 25, 30]]) == 135\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [60, 70, 80, 90, 100], [100, 90, 80, 70, 60]]) == 400\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 55\n assert candidate(grid = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86]]) == 490\n assert candidate(grid = [[24, 17, 56, 38, 45], [89, 21, 37, 62, 11], [48, 93, 71, 19, 81], [25, 76, 53, 90, 32]]) == 318\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 6, 2, 5, 3, 4]]) == 21\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [25, 75, 25, 75, 25], [75, 25, 75, 25, 75]]) == 275\n assert candidate(grid = [[4, 2, 9, 1], [8, 5, 6, 7], [3, 11, 12, 10]]) == 38\n assert candidate(grid = [[20, 5, 15], [10, 10, 30], [40, 25, 5]]) == 75\n assert candidate(grid = [[23, 54, 76], [34, 56, 23], [89, 12, 45], [56, 78, 90]]) == 224\n assert candidate(grid = [[45, 12, 67, 34], [89, 23, 56, 78], [90, 45, 34, 12], [78, 90, 45, 67]]) == 280\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 42\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 5, 2, 4, 3], [3, 4, 5, 1, 2]]) == 15\n assert candidate(grid = [[100, 90, 80], [70, 60, 50], [40, 30, 20], [10, 5, 1]]) == 270\n assert candidate(grid = [[7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7], [2, 1, 3, 4, 6, 5, 7], [3, 4, 5, 6, 7, 1, 2]]) == 28\n assert candidate(grid = [[3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1], [6, 6, 6, 6, 6, 6]]) == 36\n assert candidate(grid = [[9, 7, 5, 3], [8, 6, 4, 2], [7, 5, 3, 1]]) == 24\n assert candidate(grid = [[45, 55, 65], [35, 45, 55], [25, 35, 45], [15, 25, 35]]) == 165\n assert candidate(grid = [[4, 1, 7], [8, 2, 6], [3, 9, 5], [5, 3, 8]]) == 18\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 65\n assert candidate(grid = [[23, 34, 45, 56], [56, 45, 34, 23], [23, 45, 56, 34], [34, 56, 23, 45]]) == 158\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [10, 8, 6, 4, 2], [9, 7, 5, 3, 1]]) == 30\n assert candidate(grid = [[1, 5, 3], [2, 8, 7], [4, 6, 9], [11, 13, 12]]) == 36\n assert candidate(grid = [[30, 20, 10], [60, 50, 40], [90, 80, 70], [120, 110, 100]]) == 330\n assert candidate(grid = [[15, 25, 35, 45, 55, 65, 75, 85, 95], [95, 85, 75, 65, 55, 45, 35, 25, 15], [10, 20, 30, 40, 50, 60, 70, 80, 90]]) == 495\n assert candidate(grid = [[1, 100, 1], [100, 1, 100], [1, 100, 1], [100, 1, 100]]) == 201\n assert candidate(grid = [[50, 49, 48], [47, 46, 45], [44, 43, 42], [41, 40, 39]]) == 147\n assert candidate(grid = [[3, 1, 2], [6, 5, 4], [9, 8, 7], [12, 11, 10]]) == 33\n assert candidate(grid = [[50, 40, 30], [40, 30, 20], [30, 20, 10], [20, 10, 5]]) == 120\n assert candidate(grid = [[10], [20], [30], [40], [50], [60]]) == 60\n assert candidate(grid = [[42, 24, 36, 18, 72], [54, 12, 60, 84, 30], [90, 45, 15, 75, 60]]) == 288\n assert candidate(grid = [[100, 99, 98, 97], [96, 95, 94, 93], [92, 91, 90, 89], [88, 87, 86, 85]]) == 394\n assert candidate(grid = [[100, 90, 80], [70, 60, 50], [40, 30, 20], [10, 20, 30]]) == 270\n assert candidate(grid = [[9, 1, 5, 3], [4, 8, 2, 7], [6, 10, 1, 12]]) == 30\n assert candidate(grid = [[25, 15, 35, 5], [10, 45, 55, 20], [50, 30, 60, 40]]) == 180\n assert candidate(grid = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86]]) == 490\n assert candidate(grid = [[15, 20, 25, 30], [35, 40, 45, 50], [55, 60, 65, 70], [75, 80, 85, 90], [95, 100, 105, 110]]) == 410\n assert candidate(grid = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [7, 5, 3, 1, 9]]) == 25\n assert candidate(grid = [[99, 98, 97, 96], [95, 94, 93, 92], [91, 90, 89, 88]]) == 390\n assert candidate(grid = [[10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45]]) == 105\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6]]) == 40\n assert candidate(grid = [[1, 99, 2, 98], [3, 97, 4, 96], [5, 95, 6, 94], [7, 93, 8, 92]]) == 212\n assert candidate(grid = [[50, 40, 30], [20, 10, 0], [80, 70, 60], [100, 90, 120]]) == 310\n assert candidate(grid = [[100, 99, 98], [97, 96, 95], [94, 93, 92], [91, 90, 89]]) == 297\n assert candidate(grid = [[5, 1, 9, 2], [8, 6, 3, 7], [4, 10, 1, 11]]) == 30\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 45\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 39\n assert candidate(grid = [[100, 50, 25, 10], [90, 60, 40, 30], [80, 70, 35, 15], [75, 65, 55, 45]]) == 270\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [60, 70, 80, 90, 100]]) == 400\n assert candidate(grid = [[9, 5, 1, 7], [8, 4, 2, 6], [3, 11, 10, 12]]) == 36\n assert candidate(grid = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6]]) == 11\n assert candidate(grid = [[47, 83, 29], [91, 7, 36], [42, 54, 67], [22, 88, 15]]) == 187\n assert candidate(grid = [[99, 98, 97], [96, 95, 94], [93, 92, 91], [90, 89, 88], [87, 86, 85]]) == 294\n assert candidate(grid = [[1, 10, 100, 1000], [1000, 100, 10, 1], [1, 1000, 10, 100], [10, 100, 1000, 1]]) == 1111\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [5, 1, 2, 3, 4]]) == 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], [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]]) == 55\n assert candidate(grid = [[100, 1, 2, 3], [3, 2, 1, 100], [100, 100, 1, 1], [1, 100, 100, 100]]) == 301\n assert candidate(grid = [[7, 5, 3, 1], [8, 6, 4, 2], [9, 7, 5, 3], [10, 8, 6, 4]]) == 28\n assert candidate(grid = [[15, 20, 25, 30], [10, 15, 20, 25], [5, 10, 15, 20], [1, 5, 10, 15]]) == 90\n assert candidate(grid = [[7, 3, 5, 9], [1, 4, 8, 2], [6, 10, 12, 11]]) == 39\n assert candidate(grid = [[15, 14, 13, 12, 11], [10, 9, 8, 7, 6], [5, 4, 3, 2, 1]]) == 65\n assert candidate(grid = [[100, 1, 2, 3, 4], [99, 5, 6, 7, 8], [98, 9, 10, 11, 12], [97, 13, 14, 15, 16]]) == 158\n assert candidate(grid = [[42, 23, 65, 12, 34], [56, 78, 90, 23, 45], [89, 12, 34, 56, 78]]) == 292\n assert candidate(grid = [[10, 15, 5, 20], [12, 18, 8, 6], [7, 11, 13, 19]]) == 53\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7]]) == 57\n assert candidate(grid = [[42, 42, 42, 42], [42, 42, 42, 42], [42, 42, 42, 42], [42, 42, 42, 42]]) == 168\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 2, 4, 6], [6, 4, 2, 5, 3, 1]]) == 21\n assert candidate(grid = [[100, 1, 2, 3], [4, 100, 5, 6], [7, 8, 100, 9], [10, 11, 12, 100]]) == 133\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 30, 50, 20, 40], [20, 40, 10, 50, 30]]) == 150\n assert candidate(grid = [[33, 54, 21, 45], [11, 99, 32, 16], [82, 76, 41, 53], [65, 29, 37, 44]]) == 269\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().deleteGreatestValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int deleteGreatestValue(int[][] grid) {", "container": "Solution", "callable": "deleteGreatestValue", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2501, "task_id": "longest-square-streak-in-an-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums. A subsequence of nums is called a square streak if:\n\nThe length of the subsequence is at least 2, and\nafter sorting the subsequence, each element (except the first element) is the square of the previous number.\n\nReturn the length of the longest square streak in nums, or return -1 if there is no square streak.\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 = [4,3,6,16,8,2]\nOutput: 3\nExplanation: Choose the subsequence [4,16,2]. After sorting it, it becomes [2,4,16].\n- 4 = 2 * 2.\n- 16 = 4 * 4.\nTherefore, [4,16,2] is a square streak.\nIt can be shown that every subsequence of length 4 is not a square streak.\n\nExample 2:\n\nInput: nums = [2,3,5,6,7]\nOutput: -1\nExplanation: There is no square streak in nums so return -1.\n\n \nConstraints:\n\n2 <= nums.length <= 105\n2 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 16, 256, 65536]) == 4\n assert candidate(nums = [2, 4, 16, 256, 65536, 4294967296]) == 6\n assert candidate(nums = [6, 36, 1296, 46656]) == 3\n assert candidate(nums = [2, 8, 128, 32768, 1073741824]) == 2\n assert candidate(nums = [2, 3, 5, 6, 7]) == -1\n assert candidate(nums = [4, 16, 256, 65536, 2]) == 5\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50]) == -1\n assert candidate(nums = [2, 4, 16, 256, 65536]) == 5\n assert candidate(nums = [3, 9, 81, 6561, 43046721]) == 5\n assert candidate(nums = [4, 3, 6, 16, 8, 2]) == 3\n assert candidate(nums = [7, 49, 2401, 117649]) == 3\n assert candidate(nums = [10, 100, 10000, 1000000]) == 3\n assert candidate(nums = [1024, 32, 2, 4, 16, 64, 256]) == 4\n assert candidate(nums = [5, 25, 625, 390625]) == 4\n assert candidate(nums = [4, 16, 64, 256, 1024, 4096]) == 3\n assert candidate(nums = [3, 9, 27, 81, 243, 729]) == 3\n assert candidate(nums = [2, 8, 16, 256, 65536]) == 3\n assert candidate(nums = [16, 256, 65536, 4294967296, 1853020188851841, 340282366920938463463374607431768211456, 115792089237316195423570985008687907853269984665640564039457584007913129639935]) == 4\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147]) == 4\n assert candidate(nums = [2, 8, 64, 4096, 268435456, 18446744073709551616]) == 3\n assert candidate(nums = [49, 7, 343, 49, 2401, 7, 16807, 49, 117649, 7, 823543, 49, 5764801, 7, 40353607, 49, 282475249, 7, 1977326743, 49, 13841287201, 7, 96889010407, 49, 678223072849, 7, 4747561509943, 49, 33232930569601, 7, 23298085122481, 49]) == 5\n assert candidate(nums = [4, 16, 256, 65536, 4294967296, 18446744073709551616]) == 6\n assert candidate(nums = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249, 1977326743]) == 4\n assert candidate(nums = [18, 324, 5832, 104976, 1889568, 34012224, 612220032, 11019960576]) == 4\n assert candidate(nums = [3, 9, 81, 6561, 43046721, 1853020188851841, 34336838202925124947563293856264306533189122528]) == 6\n assert candidate(nums = [2, 4, 16, 256, 65536, 4294967296]) == 6\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125, 6103515625, 30517578125, 152587890625, 762939453125, 3814697265625, 19073486328125, 95367431640625]) == 5\n assert candidate(nums = [10, 100, 10000, 100000000, 10000000000000000, 10000000000000000000000000000000000000000]) == 5\n assert candidate(nums = [5, 25, 625, 15625, 390625, 9765625, 244140625, 6103515625]) == 4\n assert candidate(nums = [9, 81, 6561, 43046721, 3486784401, 298023223876953125]) == 4\n assert candidate(nums = [9, 81, 729, 6561, 59049, 531441, 4782969, 43046721, 387420489, 3486784401, 31381059609, 282429536481, 2541865828329, 22876792454961, 205891132094649, 1853020188851841]) == 5\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 25, 36, 49, 64, 81, 100]) == 3\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 100000000, 10000000000]) == 4\n assert candidate(nums = [18446744073709551616, 4294967296, 65536, 256, 16, 4, 2]) == 7\n assert candidate(nums = [9, 81, 6561, 43046721, 1853020188851841, 340282366920938463463374607431768211456]) == 5\n assert candidate(nums = [10, 100, 1000, 10000, 100000]) == 3\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]) == 5\n assert candidate(nums = [2, 4, 16, 256, 65536, 4294967296, 18446744073709551616]) == 7\n assert candidate(nums = [6, 36, 216, 1296, 7776, 46656, 279936, 1679616]) == 4\n assert candidate(nums = [11, 121, 14641, 214358881, 45990409362201]) == 4\n assert candidate(nums = [36, 1296, 1679616, 2821109907456, 79228162514264337593543950336, 62771017353866807638357894232076608]) == 4\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000]) == 3\n assert candidate(nums = [19, 361, 130321, 4782969, 22876792454961, 548038686029443521]) == 3\n assert candidate(nums = [12, 144, 20736, 46656, 6912, 1679616]) == 3\n assert candidate(nums = [3, 9, 81, 6561, 43046721, 1853020188851841]) == 6\n assert candidate(nums = [17, 289, 83521, 2313441, 622613961, 1683778291601]) == 3\n assert candidate(nums = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801]) == 4\n assert candidate(nums = [11, 121, 1331, 14641, 161051, 1771561, 19487171, 214358881, 2357947691]) == 4\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467, 3486784401]) == 5\n assert candidate(nums = [1024, 1048576, 1073741824, 1125899906842624, 1180591620717411303424, 1237940039285380274899124223]) == 2\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125]) == 3\n assert candidate(nums = [36, 6, 64, 8, 441, 21, 729, 27, 841, 29, 14641, 121, 20736, 144, 361, 19, 9216, 96, 28561, 169, 262144, 512, 44929, 211, 676, 26, 116964, 342, 1399681, 1183, 1900496, 1376]) == 2\n assert candidate(nums = [13, 169, 28561, 762798901, 60195114596394835600098356205041393082552613772399]) == 3\n assert candidate(nums = [13, 169, 2197, 28561, 371293, 4826809, 62748517, 815730721]) == 4\n assert candidate(nums = [4, 16, 256, 65536, 4294967296, 18446744073709551616, 340282366920938463463374607431768211456, 115792089237316195423570985008687907853269984665640564039457584007913129639935]) == 7\n assert candidate(nums = [9, 81, 6561, 43046721, 3486784401, 12157665459056928801]) == 4\n assert candidate(nums = [16, 256, 4096, 65536, 1048576, 16777216, 268435456, 4294967296, 70368744177664]) == 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, 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 = [9, 81, 729, 6561, 59049, 531441, 4782969, 43046721, 387420489]) == 4\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 10000000000000000]) == 5\n assert candidate(nums = [6, 36, 216, 1296, 7776, 46656, 279936, 1679616, 10077696, 60466176]) == 4\n assert candidate(nums = [8, 64, 4096, 262144, 68719476736, 4722366482869645213696]) == 3\n assert candidate(nums = [19, 361, 6859, 130321, 2476099, 47045881, 874185679, 16581375061]) == 3\n assert candidate(nums = [7, 49, 2401, 117649, 678223072849, 466777725390625]) == 3\n assert candidate(nums = [9, 81, 729, 6561, 59049, 531441, 4782969, 43046721, 387420489, 3486784401]) == 4\n assert candidate(nums = [65536, 4294967296, 1853020188851841, 340282366920938463463374607431768211456]) == 2\n assert candidate(nums = [13, 169, 28561, 371293, 4826809, 62748517, 815730721]) == 4\n assert candidate(nums = [6, 36, 1296, 1679616, 2821109907456, 79228162514264337593543950336]) == 5\n assert candidate(nums = [15, 225, 50625, 11390625, 244140625, 572897625]) == 3\n assert candidate(nums = [14, 196, 38416, 7056, 2744, 250881]) == 3\n assert candidate(nums = [15, 225, 50625, 12355269, 298023223875]) == 3\n assert candidate(nums = [2, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 4\n assert candidate(nums = [13, 169, 21904, 28561, 371293, 4826809]) == 3\n assert candidate(nums = [7, 49, 2401, 117649, 678223072849, 45927731638840625]) == 3\n assert candidate(nums = [15, 225, 3375, 50625, 759375, 11390625, 170859375, 2562890625]) == 4\n assert candidate(nums = [3, 9, 81, 6561, 43046721, 1853020188851841, 340282366920938463463374607431768211456]) == 6\n assert candidate(nums = [5, 25, 625, 390625, 152587890625, 23283064365386962890625]) == 6\n assert candidate(nums = [4, 16, 256, 65536, 4294967296]) == 5\n assert candidate(nums = [9, 81, 6561, 43046721, 1853020188851841]) == 5\n assert candidate(nums = [10, 100, 10000, 1000000, 100000000, 10000000000]) == 4\n assert candidate(nums = [5, 25, 625, 390625, 152587890625, 23283064365386962890625]) == 6\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625]) == 4\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 5\n assert candidate(nums = [2, 4, 16, 256, 65536, 4294967296, 18446744073709551616, 340282366920938463463374607431768211456]) == 8\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 4\n assert candidate(nums = [2, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 3\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]) == -1\n assert candidate(nums = [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]) == 3\n assert candidate(nums = [6, 36, 216, 1296, 7776, 46656, 279936, 1679616, 10077696, 60466176, 362797056]) == 4\n assert candidate(nums = [5, 25, 625, 390625, 152587890625, 23283064365386962890625, 538616925802715445220184583530610353693349111790527]) == 6\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000]) == 3\n assert candidate(nums = [11, 121, 1331, 14641, 161051, 1771561, 19487171, 214358881]) == 4\n assert candidate(nums = [20, 400, 8000, 160000, 3200000, 64000000, 1280000000]) == 3\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 5\n assert candidate(nums = [5, 25, 625, 15625, 390625, 9765625, 244140625]) == 4\n assert candidate(nums = [11, 121, 14641, 161051, 1771561, 19487171]) == 3\n assert candidate(nums = [17, 289, 4913, 83521, 1419857, 24137569, 410338673, 6975757441]) == 4\n assert candidate(nums = [6, 36, 1296, 1679616, 2821109907456, 79228162514264337593543950336, 6277101735386680763835789423207666416102355466476034710497251820920982220576]) == 5\n assert candidate(nums = [3, 9, 81, 6561, 43046721, 1853020188851841, 340282366920938463463374607431768211456, 115792089237316195423570985008687907853269984665640564039457584007913129639935]) == 6\n assert candidate(nums = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249]) == 4\n assert candidate(nums = [16, 256, 65536, 4294967296, 18446744073709551616, 340282366920938463463374607431768211456]) == 6\n assert candidate(nums = [10, 100, 10000, 100000000, 100000000000000]) == 4\n assert candidate(nums = [4, 16, 256, 65536, 4294967296, 18446744073709551616, 340282366920938463463374607431768211456]) == 7\n assert candidate(nums = [17, 289, 83521, 1419857, 24137569, 410338673, 6934883201]) == 3\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]) == -1\n assert candidate(nums = [2, 4, 16, 256, 65536, 4294967296, 1853020188851841]) == 6\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125, 6103515625, 30517578125, 152587890625, 762939453125, 3814697265625, 19073486328125, 95367431640625, 476837158203125, 2384185791015625, 11920928955078125, 59604644775390625, 298023223876953125]) == 5\n assert candidate(nums = [2, 8, 64, 4096, 16777216, 268435456, 72057594037927936]) == 4\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125]) == 4\n assert candidate(nums = [20, 400, 160000, 6400000000, 4096000000000000000]) == 3\n assert candidate(nums = [19, 361, 6859, 130321, 2476099, 47045881, 893871739]) == 3\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467]) == 5\n assert candidate(nums = [1024, 1048576, 1073741824, 1125899906842624, 1180591620717411303424]) == 2\n assert candidate(nums = [20, 400, 160000, 64000000, 25600000000, 102400000000000]) == 4\n assert candidate(nums = [12, 144, 1728, 20736, 248832, 2985984, 35831808, 429981696, 5159779152]) == 4\n assert candidate(nums = [11, 121, 14641, 214358881, 4649045866111264426084416985653148820512509312121]) == 4\n assert candidate(nums = [12, 144, 20736, 429981696, 182687704666496, 334701674048290625]) == 4\n assert candidate(nums = [6, 36, 1296, 1679616, 2821109907456, 7947285970054539449220034116900182130081723854656]) == 5\n assert candidate(nums = [7, 49, 2401, 117649, 678223072849, 459277370827617192641, 210034733148169022307920962229505349708994574401]) == 3\n assert candidate(nums = [16, 256, 65536, 4294967296, 18446744073709551616, 340282366920938463463374607431768211456]) == 6\n assert candidate(nums = [10000, 100000000, 100000000000000, 10000000000000000000000, 1000000000000000000000000000000]) == 2\n assert candidate(nums = [15, 225, 3375, 50625, 759375, 11390625, 170859375, 2562890625]) == 4\n assert candidate(nums = [10, 100, 10000, 1000000, 100000000, 10000000000, 1000000000000, 100000000000000, 10000000000000000]) == 5\n assert candidate(nums = [14, 196, 2744, 38416, 537824, 7529536, 105413504, 1475789056]) == 4\n assert candidate(nums = [2, 4, 16, 256, 65536, 4294967296, 18446744073709551616]) == 7\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 4294967296]) == 6\n assert candidate(nums = [18, 324, 104976, 1062882, 193491763, 351861792832]) == 3\n assert candidate(nums = [10, 100, 10000, 1000000, 100000000, 10000000000]) == 4\n assert candidate(nums = [100, 10000, 100000000, 100000000000000, 10000000000000000000000]) == 3\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestSquareStreak", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestSquareStreak(int[] nums) {", "container": "Solution", "callable": "longestSquareStreak", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2503, "task_id": "maximum-number-of-points-from-grid-queries", "difficulty": "Hard", "problem_description": "You are given an m x n integer matrix grid and an array queries of size k.\nFind an array answer of size k such that for each integer queries[i] you start in the top left cell of the matrix and repeat the following process:\n\nIf queries[i] is strictly greater than the value of the current cell that you are in, then you get one point if it is your first time visiting this cell, and you can move to any adjacent cell in all 4 directions: up, down, left, and right.\nOtherwise, you do not get any points, and you end this process.\n\nAfter the process, answer[i] is the maximum number of points you can get. Note that for each query you are allowed to visit the same cell multiple times.\nReturn the resulting array answer.\n \nExample 1:\n\n\nInput: grid = [[1,2,3],[2,5,7],[3,5,1]], queries = [5,6,2]\nOutput: [5,8,1]\nExplanation: The diagrams above show which cells we visit to get points for each query.\nExample 2:\n\n\nInput: grid = [[5,2,1],[1,1,2]], queries = [3]\nOutput: [0]\nExplanation: We can not get any points because the value of the top left cell is already greater than or equal to 3.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n2 <= m, n <= 1000\n4 <= m * n <= 105\nk == queries.length\n1 <= k <= 104\n1 <= grid[i][j], queries[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],queries = [2, 3]) == [9, 9]\n assert candidate(grid = [[1, 2, 3], [2, 5, 7], [3, 5, 1]],queries = [5, 6, 2]) == [5, 8, 1]\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],queries = [1, 2, 3]) == [0, 9, 9]\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],queries = [15, 25, 35, 45, 55, 65, 75, 85, 95]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(grid = [[3, 3, 3], [3, 3, 3], [3, 3, 3]],queries = [2, 4, 6]) == [0, 9, 9]\n assert candidate(grid = [[1, 10], [10, 1]],queries = [5, 15]) == [1, 4]\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],queries = [4, 5, 6]) == [0, 0, 9]\n assert candidate(grid = [[4, 5, 6], [7, 8, 9], [10, 11, 12]],queries = [10, 15, 20]) == [6, 9, 9]\n assert candidate(grid = [[5, 2, 1], [1, 1, 2]],queries = [3]) == [0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],queries = [1, 2, 3]) == [0, 16, 16]\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],queries = [15, 45, 75]) == [1, 4, 7]\n assert candidate(grid = [[4, 4, 4], [4, 4, 4], [4, 4, 4]],queries = [4]) == [0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],queries = [2, 2, 2]) == [12, 12, 12]\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],queries = [15, 35, 65, 95]) == [1, 3, 6, 9]\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],queries = [2]) == [9]\n assert candidate(grid = [[1000000, 1000000], [1000000, 1000000]],queries = [1000000, 999999]) == [0, 0]\n assert candidate(grid = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]],queries = [10, 15, 20]) == [9, 14, 19]\n assert candidate(grid = [[100000, 1, 100000, 1, 100000], [1, 100000, 1, 100000, 1], [100000, 1, 100000, 1, 100000], [1, 100000, 1, 100000, 1], [100000, 1, 100000, 1, 100000]],queries = [1, 100000, 100001]) == [0, 0, 25]\n assert candidate(grid = [[1000000, 1000000, 1000000], [1000000, 1, 1000000], [1000000, 1000000, 1000000]],queries = [1000000, 999999]) == [0, 0]\n assert candidate(grid = [[9, 8, 7, 6], [2, 1, 3, 4], [5, 10, 11, 12], [13, 14, 15, 16]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(grid = [[1000000]],queries = [500000, 1000000, 1500000]) == [0, 0, 1]\n assert candidate(grid = [[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]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]) == [0, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81]\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]],queries = [1, 5, 10, 15, 20, 25, 30]) == [0, 4, 9, 14, 19, 24, 29]\n assert candidate(grid = [[1, 2, 3], [2, 5, 7], [3, 5, 1], [1, 2, 3], [2, 5, 7]],queries = [5, 6, 2, 8, 10]) == [10, 13, 1, 15, 15]\n assert candidate(grid = [[5, 5, 5, 5], [5, 1, 1, 5], [5, 1, 1, 5], [5, 5, 5, 5]],queries = [1, 2, 3, 4, 5, 6]) == [0, 0, 0, 0, 0, 16]\n assert candidate(grid = [[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]],queries = [2, 4, 6]) == [1, 25, 25]\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]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [4, 9, 14, 19, 24, 29, 34, 39, 44, 49]\n assert candidate(grid = [[50, 40, 30, 20, 10], [51, 41, 31, 21, 11], [52, 42, 32, 22, 12], [53, 43, 33, 23, 13], [54, 44, 34, 24, 14]],queries = [25, 35, 45, 55]) == [0, 0, 0, 25]\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]],queries = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [14, 24, 34, 44, 50, 50, 50, 50, 50, 50]\n assert candidate(grid = [[2, 1, 3, 1, 2], [1, 2, 1, 2, 1], [3, 1, 2, 1, 3], [1, 2, 1, 2, 1], [2, 1, 3, 1, 2]],queries = [1, 2, 3, 4]) == [0, 0, 21, 25]\n assert candidate(grid = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]],queries = [25, 50, 75, 100]) == [4, 9, 14, 16]\n assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],queries = [5, 10, 15]) == [0, 9, 9]\n assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]],queries = [1, 5, 10, 15, 20, 25]) == [0, 4, 9, 14, 19, 24]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]],queries = [3, 4, 5, 6]) == [2, 3, 16, 20]\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 2], [2, 1, 2, 2, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 2, 2, 1, 2], [2, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2]],queries = [1, 2, 3]) == [0, 0, 49]\n assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 3, 6, 9, 12, 14, 15, 15, 15]\n assert candidate(grid = [[1, 3, 1, 4, 2], [3, 2, 4, 1, 3], [1, 4, 2, 3, 1], [2, 3, 1, 2, 4]],queries = [5, 3, 6, 2]) == [20, 1, 20, 1]\n assert candidate(grid = [[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]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 3, 6, 9, 12, 15, 18, 21, 24, 27]\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]],queries = [1, 3, 5, 7, 9]) == [0, 3, 10, 19, 24]\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 9, 9, 9, 10], [10, 9, 8, 9, 10], [10, 9, 9, 9, 10], [10, 10, 10, 10, 10]],queries = [10, 9, 8, 7]) == [0, 0, 0, 0]\n assert candidate(grid = [[5, 6, 7, 8], [4, 3, 2, 1], [12, 13, 14, 15], [9, 10, 11, 16]],queries = [3, 5, 7, 9, 11, 13, 15, 17]) == [0, 0, 6, 8, 8, 12, 14, 16]\n assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [6, 16, 26, 36, 46], [11, 21, 31, 41, 51]],queries = [10, 20, 30, 40, 50, 60]) == [0, 8, 13, 18, 23, 25]\n assert candidate(grid = [[5, 2, 1, 4, 3, 2, 1], [4, 3, 2, 1, 4, 3, 2], [3, 2, 1, 2, 3, 2, 1], [2, 1, 2, 3, 2, 1, 2], [1, 2, 3, 2, 1, 2, 3]],queries = [3, 4, 5, 6]) == [0, 0, 0, 35]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 1, 2, 3, 9], [9, 4, 5, 6, 9], [9, 7, 8, 9, 9], [9, 9, 9, 9, 9]],queries = [1, 5, 10]) == [0, 0, 25]\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50]],queries = [25, 35, 45, 55]) == [2, 15, 20, 25]\n assert candidate(grid = [[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 = [6, 7, 8]) == [0, 0, 25]\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]],queries = [1, 2, 3, 4]) == [0, 16, 24, 25]\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]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [25, 24, 22, 19, 15, 10, 6, 3, 1, 0]\n assert candidate(grid = [[7, 7, 7, 7], [7, 7, 7, 7], [7, 7, 7, 7], [7, 7, 7, 7]],queries = [5, 6, 8]) == [0, 0, 16]\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10]],queries = [15, 10, 5, 1]) == [20, 19, 0, 0]\n assert candidate(grid = [[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]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [25, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[50, 40, 30, 20, 10], [45, 35, 25, 15, 5], [40, 30, 20, 10, 0], [35, 25, 15, 5, 45], [30, 20, 10, 0, 50]],queries = [10, 25, 40, 50]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1], [1, 10, 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]) == [0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 1], [1, 2, 3, 4, 5, 6, 7, 6, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8, 3, 1], [1, 2, 3, 4, 5, 6, 7, 6, 5, 1], [1, 2, 3, 4, 3, 2, 3, 4, 5, 1]],queries = [2, 3, 5, 7, 8, 10]) == [28, 47, 81, 96, 99, 100]\n assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [2, 3, 4, 5, 1], [6, 7, 8, 9, 10]],queries = [1, 3, 5, 7, 9, 11]) == [0, 2, 4, 12, 16, 20]\n assert candidate(grid = [[2, 3, 2], [3, 2, 3], [2, 3, 2], [3, 2, 3], [2, 3, 2]],queries = [2, 3, 4, 5, 6, 7]) == [0, 1, 15, 15, 15, 15]\n assert candidate(grid = [[3, 3, 3, 3], [3, 1, 1, 3], [3, 1, 1, 3], [3, 3, 3, 3]],queries = [1, 2, 4, 5]) == [0, 0, 16, 16]\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]],queries = [10, 5, 1, 15]) == [25, 10, 0, 25]\n assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]],queries = [1, 2, 3, 4, 5, 6, 7, 8]) == [0, 1, 3, 6, 9, 12, 14, 15]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],queries = [10, 15, 20]) == [9, 14, 15]\n assert candidate(grid = [[1000000, 999999], [999998, 1000000], [999997, 999996]],queries = [1000000, 999999, 999998, 999997]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]],queries = [5, 10, 15, 20]) == [4, 9, 14, 15]\n assert candidate(grid = [[5, 4, 3, 2, 1], [6, 5, 4, 3, 2], [7, 6, 5, 4, 3], [8, 7, 6, 5, 4], [9, 8, 7, 6, 5]],queries = [5, 10, 15, 20]) == [0, 25, 25, 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]],queries = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [25, 0, 25, 0, 25, 0, 25, 0, 25, 0, 25, 0, 25, 0, 25, 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, 1, 1, 1, 1, 1]],queries = [1, 2, 3]) == [0, 30, 30]\n assert candidate(grid = [[5, 1, 2, 3, 4], [4, 5, 6, 7, 8], [3, 4, 5, 6, 7], [2, 3, 4, 5, 6], [1, 2, 3, 4, 5]],queries = [6, 5, 4, 3, 2, 1]) == [19, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 1], [1, 2, 3, 4, 5, 5, 5, 5, 5, 4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 5, 6, 6, 6, 5, 4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 5, 6, 6, 6, 5, 4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 5, 5, 5, 5, 5, 4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 1, 1], [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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]) == [0, 69, 111, 145, 170, 186, 194]\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, 2, 3, 4, 5, 6, 7, 8, 9, 10]],queries = [5, 10, 15]) == [4, 27, 30]\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], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1]],queries = [1, 2, 3]) == [0, 1, 36]\n assert candidate(grid = [[1, 3, 2, 4, 3], [2, 4, 3, 5, 4], [3, 5, 4, 6, 5], [4, 6, 5, 7, 6], [5, 7, 6, 8, 7]],queries = [2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 6, 12, 17, 21, 24, 25]\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10]],queries = [6, 10, 15, 20]) == [10, 18, 20, 20]\n assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16]],queries = [5, 10, 15, 20]) == [4, 9, 14, 19]\n assert candidate(grid = [[1, 3, 1, 4, 1], [2, 2, 4, 2, 4], [3, 5, 3, 5, 3], [4, 4, 5, 4, 4], [1, 1, 1, 1, 1]],queries = [2, 5, 7, 10]) == [1, 22, 25, 25]\n assert candidate(grid = [[1, 2, 3], [2, 1, 2], [3, 2, 1], [2, 1, 2], [1, 2, 3]],queries = [2, 3, 4]) == [1, 12, 15]\n assert candidate(grid = [[5, 2, 1, 2, 5], [1, 5, 2, 5, 1], [2, 1, 5, 1, 2], [5, 2, 1, 2, 5]],queries = [3, 4, 6, 7]) == [0, 0, 20, 20]\n assert candidate(grid = [[1, 5, 3, 8, 7], [2, 6, 4, 9, 8], [3, 7, 5, 10, 9], [4, 8, 6, 11, 10], [5, 9, 7, 12, 11]],queries = [1, 4, 7, 10, 13]) == [0, 3, 11, 20, 25]\n assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]],queries = [5, 15, 25, 30]) == [4, 14, 24, 25]\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]],queries = [6, 12, 18]) == [13, 25, 25]\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]],queries = [2, 3, 4]) == [16, 24, 25]\n assert candidate(grid = [[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]],queries = [2, 4, 6, 8, 10]) == [1, 25, 25, 25, 25]\n assert candidate(grid = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]],queries = [2, 3, 4]) == [20, 32, 36]\n assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]],queries = [2, 4, 6, 8, 10]) == [1, 12, 16, 16, 16]\n assert candidate(grid = [[1, 3, 5, 7], [2, 4, 6, 8], [3, 5, 7, 9], [4, 6, 8, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 4, 6, 8, 10, 12, 14, 15]\n assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]],queries = [2, 4, 6, 8]) == [1, 6, 11, 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], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],queries = [15, 25, 35]) == [14, 24, 30]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1000000, 1, 1], [1, 1, 1000000, 1], [1, 1, 1, 1]],queries = [1, 1000000, 1000001]) == [0, 14, 16]\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [5, 6, 7, 8, 9], [0, 1, 2, 3, 4], [9, 8, 7, 6, 5]],queries = [5, 10, 15]) == [0, 25, 25]\n assert candidate(grid = [[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 1, 4, 1, 5, 9, 2, 6, 5], [2, 7, 1, 8, 2, 8, 1, 8, 2, 8, 4, 5, 9, 0, 4, 5, 2, 3, 5, 3, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6], [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, 5, 8, 2, 0]],queries = [10, 20, 30, 40, 50]) == [93, 93, 93, 93, 93]\n assert candidate(grid = [[5, 3, 8, 6], [3, 4, 1, 5], [6, 1, 4, 3], [8, 5, 3, 7]],queries = [4, 6, 8, 10]) == [0, 11, 14, 16]\n assert candidate(grid = [[3, 3, 3, 3, 3], [3, 2, 2, 2, 3], [3, 2, 1, 2, 3], [3, 2, 2, 2, 3], [3, 3, 3, 3, 3]],queries = [1, 2, 3, 4]) == [0, 0, 0, 25]\n assert candidate(grid = [[1, 1, 1, 1000], [1, 1, 1000, 1], [1, 1000, 1, 1], [1000, 1, 1, 1]],queries = [500, 1001]) == [6, 16]\n assert candidate(grid = [[1, 10, 100], [10, 100, 1000], [100, 1000, 10000]],queries = [500, 50, 5]) == [6, 3, 1]\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 1, 2, 4, 6, 9, 11, 14, 16, 19, 21, 23, 24, 25, 25]\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]],queries = [90, 80, 70]) == [0, 0, 0]\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]],queries = [1, 2, 3, 4, 5]) == [0, 10, 20, 30, 40]\n assert candidate(grid = [[1, 10, 3, 10, 5], [10, 9, 8, 7, 10], [6, 10, 2, 10, 4], [10, 10, 10, 10, 10], [5, 10, 7, 10, 9]],queries = [1, 5, 10, 15]) == [0, 1, 1, 25]\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]],queries = [5, 10, 15]) == [10, 23, 25]\n assert candidate(grid = [[1000000, 999999, 999998], [999997, 999996, 999995], [999994, 999993, 999992]],queries = [999999, 999998, 999997, 999996, 999995, 999994]) == [0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[3, 2, 2, 3], [3, 1, 1, 3], [3, 2, 2, 3], [3, 3, 3, 3]],queries = [2, 4, 6, 8]) == [0, 16, 16, 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, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],queries = [1, 2, 3]) == [0, 40, 40]\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]],queries = [5, 15, 25, 35]) == [4, 14, 24, 34]\n assert candidate(grid = [[3, 1, 4, 1, 5, 9], [2, 6, 5, 3, 5, 9], [5, 8, 9, 7, 9, 3], [2, 8, 8, 4, 1, 9]],queries = [10, 20, 30, 40, 50]) == [24, 24, 24, 24, 24]\n"}, "metadata": {"canonical_parameter_names": ["grid", "queries"], "leetcode_dataset_entry_point": "Solution().maxPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] maxPoints(int[][] grid, int[] queries) {", "container": "Solution", "callable": "maxPoints", "parameters": [{"name": "grid", "type": "int[][]"}, {"name": "queries", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2506, "task_id": "count-pairs-of-similar-strings", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string array words.\nTwo strings are similar if they consist of the same characters.\n\nFor example, \"abca\" and \"cba\" are similar since both consist of characters 'a', 'b', and 'c'.\nHowever, \"abacba\" and \"bcfd\" are not similar since they do not consist of the same characters.\n\nReturn the number of pairs (i, j) such that 0 <= i < j <= word.length - 1 and the two strings words[i] and words[j] are similar.\n \nExample 1:\n\nInput: words = [\"aba\",\"aabb\",\"abcd\",\"bac\",\"aabc\"]\nOutput: 2\nExplanation: There are 2 pairs that satisfy the conditions:\n- i = 0 and j = 1 : both words[0] and words[1] only consist of characters 'a' and 'b'. \n- i = 3 and j = 4 : both words[3] and words[4] only consist of characters 'a', 'b', and 'c'. \n\nExample 2:\n\nInput: words = [\"aabb\",\"ab\",\"ba\"]\nOutput: 3\nExplanation: There are 3 pairs that satisfy the conditions:\n- i = 0 and j = 1 : both words[0] and words[1] only consist of characters 'a' and 'b'. \n- i = 0 and j = 2 : both words[0] and words[2] only consist of characters 'a' and 'b'.\n- i = 1 and j = 2 : both words[1] and words[2] only consist of characters 'a' and 'b'.\n\nExample 3:\n\nInput: words = [\"nba\",\"cba\",\"dba\"]\nOutput: 0\nExplanation: Since there does not exist any pair that satisfies the conditions, we return 0.\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 100\nwords[i] consist of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['aabbcc', 'abc', 'ab', 'a', 'b', 'c']) == 1\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'aab', 'aba', 'baa']) == 3\n assert candidate(words = ['aabbcc', 'abc', 'aabb', 'aaabbbcc', 'abcabc']) == 6\n assert candidate(words = ['a', 'b', 'c', 'd', 'e']) == 0\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'abc', 'abc']) == 1\n assert candidate(words = ['abcd', 'bcad', 'cabd', 'dabc']) == 6\n assert candidate(words = ['nba', 'cba', 'dba']) == 0\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']) == 15\n assert candidate(words = ['abcd', 'dcba', 'abdc', 'badc']) == 6\n assert candidate(words = ['aabb', 'ab', 'ba']) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl']) == 0\n assert candidate(words = ['aa', 'bb', 'cc', 'abc', 'cba', 'bca']) == 3\n assert candidate(words = ['a', 'b', 'c', 'd']) == 0\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 0\n assert candidate(words = ['abc', 'abc', 'abc', 'abc']) == 6\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd']) == 10\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'aaa']) == 1\n assert candidate(words = ['abc', 'def', 'ghi']) == 0\n assert candidate(words = ['aba', 'aabb', 'abcd', 'bac', 'aabc']) == 2\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno']) == 0\n assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba']) == 15\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'aabbcc', 'bbaacc', 'ccbaab', 'aabbbc']) == 45\n assert candidate(words = ['abcde', 'edcba', 'abc', 'bca', 'cab', 'deabc']) == 6\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba']) == 6\n assert candidate(words = ['aabbcc', 'abcabc', 'bcaabc', 'cababc', 'bcabac']) == 10\n assert candidate(words = ['aabbccddeeff', 'ffeeddccbbaa', 'abcdef', 'fedcba', 'efabcd', 'fedcba', 'abcdefg', 'gfedcba', 'hijklm', 'mlkjih']) == 17\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb', 'aabbc', 'bbaac', 'ccaab', 'aaabb', 'aabbb', 'abbbb', 'bbbbb']) == 18\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']) == 0\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj']) == 0\n assert candidate(words = ['abcdefg', 'gfedcba', 'ghijklm', 'mlkjihg', 'nopqrst', 'tsrqpon', 'vwxyz', 'zyxwv', 'abcdabcd', 'efghijkl', 'mnopqrstuvw', 'xyzzyxwv', 'utsrqponmlkjihgfedcba']) == 6\n assert candidate(words = ['hello', 'olleh', 'world', 'dlrow', 'python', 'nohtyp', 'java', 'avaj', 'algorithm', 'mhtirogla', 'data', 'tatad', 'structure', 'erutcurts', 'example', 'elpmaxe', 'test', 'tset', 'code', 'edoc', 'challenge', 'egnellahc', 'interview', 'weivretni']) == 12\n assert candidate(words = ['xyzxyzxyz', 'zyxzyxzyx', 'yzxyzxyz', 'zyxyzxyz', 'xzyzxzyx', 'xyzzyxzyx', 'zyxzyxzyx', 'xyzzyxzyx', 'xzyzxzyx', 'xyzxyzxyz']) == 45\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'aaaaa', 'bbbbb']) == 2\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abdg', 'abdh', 'abei', 'abdj', 'abcd', 'abcd']) == 3\n assert candidate(words = ['aabbcc', 'abc', 'ab', 'a', 'b', 'c', 'abcde', 'edcba', 'fghij', 'jihgf', 'mnopq', 'qpomn']) == 4\n assert candidate(words = ['abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'abcd', 'acdb', 'bdac', 'bcda', 'dabc', 'adcb', 'cdba', 'bacd', 'abcd', 'bcad']) == 105\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'abcd', 'abcd', 'dcba', 'dcba', 'abcd']) == 45\n assert candidate(words = ['xyz', 'zyx', 'abc', 'cab', 'bac', 'xyz', 'zyx']) == 9\n assert candidate(words = ['aaaa', 'aabb', 'abab', 'abba', 'baba', 'bbaa', 'baab', 'abab', 'aabb', 'abba']) == 36\n assert candidate(words = ['abc', 'bca', 'cab', 'xyz', 'zyx', 'yzx']) == 6\n assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'bc', 'cb', 'bd', 'db', 'cd', 'dc']) == 6\n assert candidate(words = ['abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij']) == 0\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'xzy', 'yxz', 'zxy', 'xyzz', 'yzzx', 'zzxy', 'zzzx', 'zxzy', 'xzyz']) == 55\n assert candidate(words = ['unique', 'ueinque', 'qneuie', 'neiqueu', 'ienquue', 'enuiqueu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu']) == 1431\n assert candidate(words = ['aaa', 'aa', 'a', 'b', 'bb', 'bbb', 'bbbb', 'bbbbb']) == 13\n assert candidate(words = ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']) == 276\n assert candidate(words = ['pqrst', 'rstqp', 'qrstp', 'srtpq', 'tsrqp', 'tspqr', 'pqrst', 'rstqp', 'qrstp', 'srtpq', 'tsrqp', 'tspqr']) == 66\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca']) == 45\n assert candidate(words = ['abc', 'abd', 'abe', 'abf', 'abg', 'abh', 'abi', 'abj', 'abk', 'abl', 'abm', 'abn', 'abo', 'abp', 'abq', 'abr', 'abs', 'abt', 'abu', 'abv', 'abw', 'abx', 'aby', 'abz']) == 0\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba']) == 15\n assert candidate(words = ['xyz', 'zyx', 'zyx', 'xyz', 'yxxz', 'zyxz', 'xzyz', 'yxzz', 'zxzy', 'zyzz', 'zzzy', 'zyyz', 'zyzx', 'xzyz', 'zzyx', 'zyxz', 'zyzx', 'zyxz', 'zyzx', 'zyxz', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx']) == 744\n assert candidate(words = ['abcdefg', 'gfedcba', 'hijklmn', 'nmkljih', 'opqrstu', 'utsrqpo', 'vwxyz', 'zyxwv', 'abcdefg', 'gfedcba', 'hijklmn', 'nmkljih', 'opqrstu', 'utsrqpo', 'vwxyz', 'zyxwv']) == 24\n assert candidate(words = ['abc', 'bca', 'cab', 'xyz', 'zyx', 'yxz']) == 6\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', 'aaab', 'bbba', 'ccca', 'ddda', 'eeea', 'fffa', 'ggga', 'hhha', 'iiia', 'jjja', 'kkka', 'llla', 'mmma', 'nnna', 'oooo', 'pppa', 'qqqa', 'rrra', 'sssa', 'ttta', 'uuua', 'vvva', 'wwwa', 'xxxa', 'yyya', 'zzza', 'aab', 'bba', 'cca', 'dda', 'eea', 'ffa', 'gga', 'hha', 'iaa', 'jaa', 'kaa', 'laa', 'maa', 'naa', 'oaa', 'paa', 'qaa', 'raa', 'saa', 'taa', 'uaa', 'vaa', 'waa', 'xaa', 'yaa', 'zaa', 'aabbb', 'bbbaa', 'cccaa', 'dddaa', 'eeeea', 'ffffa', 'gggga', 'hhhaa', 'iiiia', 'jjjaa', 'kkkaa', 'lllaa', 'mmmia', 'nnnaa', 'ooooo', 'pppaa', 'qqqaa', 'rrraa', 'ssaaa', 'tttaa', 'uuuaa', 'vvvaa', 'wwwaa', 'xxxaa', 'yyaaa', 'zzzaa']) == 85\n assert candidate(words = ['abacabadabacaba', 'bacbacbacbacbac', 'cabacabacabacab', 'abcabcabcabcabc', 'bcbcbcbcbcbcb', 'cbcbcbcbcbcbc']) == 4\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'abc', 'bca', 'cab', 'abc', 'bca', 'cab']) == 15\n assert candidate(words = ['aaaa', 'aaab', 'aaba', 'abaa', 'baaa', 'bbaa', 'bbba', 'bbbb']) == 15\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyzabcdefghijkl']) == 3\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abdg', 'abdh', 'abdi', 'abdj', 'abcd']) == 1\n assert candidate(words = ['aabbcc', 'abcabc', 'bcaabc', 'cababc', 'aabbcc', 'bbaacc', 'ccbaab']) == 21\n assert candidate(words = ['xyz', 'zyx', 'yxz', 'zxy', 'xzy', 'yzx']) == 15\n assert candidate(words = ['xyz', 'zyx', 'yxz', 'xzy', 'yzx', 'zxy', 'abc', 'bca', 'cab', 'aaa', 'bbb', 'ccc', 'aba', 'bab', 'aab', 'abb', 'baa', 'bba', 'abb', 'aab', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 55\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'xzy', 'yxz', 'zxy', 'zyxw', 'wxyz']) == 16\n assert candidate(words = ['mnop', 'mnopqr', 'mnopqrs', 'mnopqrst', 'mnopqrstuv', 'mnopqrstuvw', 'mnopqrstuvwx', 'mnopqrstuvwxy', 'mnopqrstuvwxyz']) == 0\n assert candidate(words = ['abcabc', 'bcabc', 'cabc', 'abc', 'bca', 'cab', 'aabbcc', 'bbccaa', 'ccaabb']) == 36\n assert candidate(words = ['abcde', 'edcba', 'bcdea', 'deabc', 'cdeab']) == 10\n assert candidate(words = ['abcdef', 'fedcba', 'ghijkl', 'lkjhgf', 'mnopqr', 'rqponm', 'stuvwx', 'xwvuts', 'yz', 'zy']) == 4\n assert candidate(words = ['pqr', 'qrp', 'prq', 'rpq', 'rqp', 'pqr', 'abc', 'cab', 'bac', 'abcde', 'edcba', 'fghij', 'jihgf', 'mnopq', 'qpomn']) == 21\n assert candidate(words = ['abc', 'abcd', 'abce', 'abcf', 'abcg', 'abch', 'abci', 'abcj', 'abck', 'abcl', 'abcm', 'abcn', 'abco', 'abcp', 'abcq', 'abcr', 'abcs', 'abct', 'abcu', 'abcv', 'abcw', 'abcx', 'abcy', 'abcz']) == 0\n assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'bc', 'cb', 'bd', 'db', 'cd', 'dc', 'abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'acbd', 'cadb', 'abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'acbd', 'cadb']) == 97\n assert candidate(words = ['abcabcabc', 'bcbcbcbc', 'cacacac', 'abababab', 'babababa', 'acacacac', 'abcabcabc', 'bcbcbcbc', 'cacacac', 'abababab']) == 8\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'zyx']) == 0\n assert candidate(words = ['abcdabcdabcdabcdabcdabcdabcdabcd', 'bcadbcadbcadbcadbcadbcadbcadbcad', 'cdabcdabcdabcdabcdabcdabcdabcdabc', 'dcbadcbadcbadcbadcbadcbadcbadcba', 'abcdabcdabcdabcdabcdabcdabcdabcde']) == 6\n assert candidate(words = ['apple', 'pale', 'pplea', 'elppa', 'ppale', 'pleap']) == 15\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj']) == 0\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba']) == 276\n assert candidate(words = ['mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq', 'mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq', 'mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq']) == 153\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == 0\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'uvw', 'rst', 'qpo', 'nml', 'kji', 'fed', 'cba', 'zyx', 'wvu', 'tsr', 'pon', 'mlk', 'jih', 'gf', 'de', 'abc']) == 6\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']) == 0\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'abc', 'bca', 'cab', 'aab', 'aba', 'baa', 'bbc', 'bcb', 'cbb', 'acc', 'cac', 'cca']) == 12\n assert candidate(words = ['abcdef', 'fedcba', 'bcdefa', 'defabc', 'efabcd', 'fabcde', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'uvw', 'rst', 'qpo', 'nml', 'kji', 'fed', 'cba', 'zyx', 'wvu', 'tsr', 'pon', 'mlk', 'jih', 'gf', 'de', 'abc']) == 21\n assert candidate(words = ['abcde', 'edcba', 'fghij', 'jihgf', 'abcde', 'edcba']) == 7\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz']) == 45\n assert candidate(words = ['aabbcc', 'abcabc', 'ababab', 'acacac', 'bcbcbc', 'bacbac', 'cabcab', 'abcabcabc', 'xyzxyzxyz', 'zyxzyxzyx']) == 11\n assert candidate(words = ['abcdefg', 'gfedcba', 'fedcbag', 'bagfedc', 'abcdefg', 'gfedcba', 'fedcbag', 'bagfedc', 'abcdefg', 'gfedcba']) == 45\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba']) == 15\n assert candidate(words = ['abcdef', 'fedcba', 'defabc', 'cabfed', 'bcadef', 'fedcba', 'abcdef', 'abcdef']) == 28\n assert candidate(words = ['abcde', 'edcba', 'cdeab', 'decba', 'bacde', 'ecbad', 'abcd', 'dcba', 'abc', 'bca', 'cab', 'acb', 'bac', 'cba', 'a', 'b', 'c', 'd', 'e']) == 31\n assert candidate(words = ['aabbcc', 'aabbc', 'aabc', 'abc', 'ab', 'a', 'b', 'bb', 'bbb', 'bbbb', 'bbbbb', 'bbbbb', 'bbbb', 'bbb', 'bb', 'b']) == 51\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == 3403\n assert candidate(words = ['ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak', 'al', 'am', 'an', 'ao', 'ap', 'aq', 'ar', 'as', 'at', 'au', 'av', 'aw', 'ax', 'ay', 'az']) == 0\n assert candidate(words = ['xyz', 'yzx', 'zxy', 'zyx', 'yxz', 'xzy', 'abc', 'cab', 'bca']) == 18\n assert candidate(words = ['abc', 'abcabc', 'abcabcabc', 'abcabcabcabc', 'abcabcabcabcabc', 'abcabcabcabcabcabc', 'abcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabc']) == 28\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']) == 26\n assert candidate(words = ['test', 'sett', 'stet', 'tset', 'ttes', 'etts', 'etst', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste']) == 3828\n assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'bc', 'cb', 'bd', 'db', 'cd', 'dc', 'abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'abcd', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'ab', 'ba', 'ac', 'ca', 'ad', 'da', 'bc', 'cb', 'bd', 'db', 'cd', 'dc', 'abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'abcd']) == 117\n assert candidate(words = ['aaaa', 'aaab', 'aaba', 'aabb', 'abaa', 'abab', 'abba', 'abbb', 'baaa', 'baab', 'baba', 'babb', 'bbaa', 'bbab', 'bbba', 'bbbb']) == 91\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'aabbcc', 'ddeeff', 'gghhiijj', 'kkllmm', 'nnoopp', 'qqrrss', 'ttuuvv', 'wwxxyy', 'zz', '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']) == 3\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccbbaa', 'aabbcc', 'bbaacc', 'ccbbaa', 'aabbbc', 'bbaacc', 'ccbbaa', 'aabbbc', 'bbaacc', 'ccbbaa']) == 66\n assert candidate(words = ['hello', 'olleh', 'ohell', 'loleh', 'ehlol', 'llohe', 'world', 'dlrow', 'owrld', 'rldwo', 'ldwor', 'dworld', 'wolrd', 'orldw', 'lrwod', 'rwdol', 'dlorw', 'lorwd', 'rowdl', 'owrld', 'dlrow', 'world', 'dlrow', 'owrld', 'rldwo', 'ldwor', 'dworld', 'wolrd', 'orldw', 'lrwod', 'rwdol', 'dlorw', 'lorwd', 'rowdl', 'owrld', 'dlrow', 'world', 'dlrow', 'owrld', 'rldwo', 'ldwor', 'dworld', 'wolrd', 'orldw', 'lrwod', 'rwdol', 'dlorw', 'lorwd', 'rowdl', 'owrld']) == 961\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().similarPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int similarPairs(String[] words) {", "container": "Solution", "callable": "similarPairs", "parameters": [{"name": "words", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2507, "task_id": "smallest-value-after-replacing-with-sum-of-prime-factors", "difficulty": "Medium", "problem_description": "You are given a positive integer n.\nContinuously replace n with the sum of its prime factors.\n\nNote that if a prime factor divides n multiple times, it should be included in the sum as many times as it divides n.\n\nReturn the smallest value n will take on.\n \nExample 1:\n\nInput: n = 15\nOutput: 5\nExplanation: Initially, n = 15.\n15 = 3 * 5, so replace n with 3 + 5 = 8.\n8 = 2 * 2 * 2, so replace n with 2 + 2 + 2 = 6.\n6 = 2 * 3, so replace n with 2 + 3 = 5.\n5 is the smallest value n will take on.\n\nExample 2:\n\nInput: n = 3\nOutput: 3\nExplanation: Initially, n = 3.\n3 is the smallest value n will take on.\n\n \nConstraints:\n\n2 <= n <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 3\n assert candidate(n = 15) == 5\n assert candidate(n = 100) == 5\n assert candidate(n = 44) == 5\n assert candidate(n = 28) == 11\n assert candidate(n = 97) == 97\n assert candidate(n = 99999) == 31\n assert candidate(n = 729) == 5\n assert candidate(n = 12345) == 5\n assert candidate(n = 49) == 5\n assert candidate(n = 104) == 19\n assert candidate(n = 841) == 31\n assert candidate(n = 987654) == 5\n assert candidate(n = 1009) == 1009\n assert candidate(n = 60) == 7\n assert candidate(n = 6857) == 6857\n assert candidate(n = 72) == 7\n assert candidate(n = 13195) == 11\n assert candidate(n = 225) == 5\n assert candidate(n = 720) == 19\n assert candidate(n = 128) == 5\n assert candidate(n = 1024) == 5\n assert candidate(n = 100000) == 7\n assert candidate(n = 789) == 11\n assert candidate(n = 2048) == 13\n assert candidate(n = 999) == 7\n assert candidate(n = 2310) == 11\n assert candidate(n = 65536) == 7\n assert candidate(n = 169) == 5\n assert candidate(n = 256) == 5\n assert candidate(n = 77) == 5\n assert candidate(n = 81) == 7\n assert candidate(n = 104729) == 104729\n assert candidate(n = 97531) == 67\n assert candidate(n = 99998) == 5\n assert candidate(n = 1234) == 619\n assert candidate(n = 3125) == 7\n assert candidate(n = 8898) == 7\n assert candidate(n = 510510) == 31\n assert candidate(n = 121) == 13\n assert candidate(n = 1234567) == 1237\n assert candidate(n = 500) == 19\n assert candidate(n = 54321) == 5\n assert candidate(n = 600851475143) == 13\n assert candidate(n = 84) == 5\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().smallestValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int smallestValue(int n) {", "container": "Solution", "callable": "smallestValue", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2508, "task_id": "add-edges-to-make-degrees-of-all-nodes-even", "difficulty": "Hard", "problem_description": "There is an undirected graph consisting of n nodes numbered from 1 to n. You are given the integer n and a 2D array edges where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi. The graph can be disconnected.\nYou can add at most two additional edges (possibly none) to this graph so that there are no repeated edges and no self-loops.\nReturn true if it is possible to make the degree of each node in the graph even, otherwise return false.\nThe degree of a node is the number of edges connected to it.\n \nExample 1:\n\n\nInput: n = 5, edges = [[1,2],[2,3],[3,4],[4,2],[1,4],[2,5]]\nOutput: true\nExplanation: The above diagram shows a valid way of adding an edge.\nEvery node in the resulting graph is connected to an even number of edges.\n\nExample 2:\n\n\nInput: n = 4, edges = [[1,2],[3,4]]\nOutput: true\nExplanation: The above diagram shows a valid way of adding two edges.\nExample 3:\n\n\nInput: n = 4, edges = [[1,2],[1,3],[1,4]]\nOutput: false\nExplanation: It is not possible to obtain a valid graph with adding at most 2 edges.\n \nConstraints:\n\n3 <= n <= 105\n2 <= edges.length <= 105\nedges[i].length == 2\n1 <= ai, bi <= n\nai != bi\nThere are no repeated edges.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [1, 4]]) == False\n assert candidate(n = 7,edges = [[1, 2], [3, 4], [5, 6], [6, 7]]) == False\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == True\n assert candidate(n = 4,edges = [[1, 2], [3, 4]]) == True\n assert candidate(n = 6,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == True\n assert candidate(n = 8,edges = [[1, 2], [3, 4], [5, 6], [7, 8]]) == False\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 2], [1, 4], [2, 5]]) == True\n assert candidate(n = 7,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == True\n assert candidate(n = 8,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [5, 7]]) == True\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == True\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10]]) == True\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 3], [4, 6], [7, 9]]) == False\n assert candidate(n = 14,edges = [[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], [1, 5], [2, 6], [3, 7], [4, 8], [9, 11], [10, 12], [13, 1]]) == False\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [4, 6]]) == True\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 1]]) == True\n assert candidate(n = 13,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 1], [2, 13], [4, 13], [6, 13], [8, 13], [10, 13], [12, 13]]) == False\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 7], [8, 9], [10, 11]]) == True\n assert candidate(n = 7,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 4], [1, 4], [2, 5], [3, 6]]) == False\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == True\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 9], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15], [8, 9]]) == False\n assert candidate(n = 14,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [6, 14], [7, 14]]) == False\n assert candidate(n = 15,edges = [[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, 1]]) == True\n assert candidate(n = 10,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 3], [2, 4], [5, 7], [6, 8], [7, 9], [8, 10]]) == True\n assert candidate(n = 14,edges = [[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]]) == True\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21]]) == True\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [8, 9], [1, 4], [2, 5], [3, 6]]) == False\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 13], [8, 9], [10, 11], [12, 13]]) == True\n assert candidate(n = 20,edges = [[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, 1]]) == True\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == True\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 9], [2, 4], [3, 5], [6, 8]]) == False\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [3, 7], [4, 7], [5, 6]]) == True\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == True\n assert candidate(n = 13,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [1, 3], [2, 4], [5, 7], [6, 8], [9, 11], [10, 12]]) == False\n assert candidate(n = 14,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 11], [1, 12], [2, 13], [3, 14], [4, 6], [5, 7]]) == False\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == True\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [10, 11], [11, 12], [12, 13], [13, 9], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 9], [7, 10], [8, 11]]) == True\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20]]) == False\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 13], [13, 10], [14, 15], [15, 14]]) == True\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10]]) == True\n assert candidate(n = 10,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == False\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == False\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 5], [2, 6], [3, 7], [4, 8], [9, 12]]) == False\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4], [5, 8]]) == True\n assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == True\n assert candidate(n = 20,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == False\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1]]) == True\n assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [1, 11]]) == True\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == True\n assert candidate(n = 14,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 6]]) == True\n assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 1]]) == True\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8]]) == True\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [1, 8]]) == True\n assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [1, 11], [2, 5], [3, 7], [4, 8]]) == False\n assert candidate(n = 18,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18]]) == False\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [5, 7]]) == True\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == True\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11]]) == True\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == False\n assert candidate(n = 16,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [1, 3], [1, 5], [1, 7], [1, 9], [1, 11], [1, 13], [1, 15]]) == False\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6]]) == True\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6]]) == True\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10]]) == True\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 4], [2, 5], [3, 6]]) == False\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13]]) == True\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 8]]) == True\n assert candidate(n = 16,edges = [[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, 1]]) == True\n assert candidate(n = 9,edges = [[1, 2], [3, 4], [5, 6], [7, 8]]) == False\n assert candidate(n = 14,edges = [[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]]) == True\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [1, 16], [2, 17], [3, 18], [4, 19], [5, 20]]) == False\n assert candidate(n = 7,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 5]]) == True\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [9, 10]]) == False\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [2, 4], [5, 7], [6, 8]]) == False\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8]]) == True\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 5], [2, 6], [3, 4], [7, 10]]) == False\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == True\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == True\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == True\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 12], [12, 9]]) == True\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 3], [3, 5], [5, 7], [7, 9]]) == True\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == True\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 10]]) == True\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [1, 4], [2, 5], [3, 6]]) == False\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().isPossible", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isPossible(int n, List> edges) {", "container": "Solution", "callable": "isPossible", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "List>"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2509, "task_id": "cycle-length-queries-in-a-tree", "difficulty": "Hard", "problem_description": "You are given an integer n. There is a complete binary tree with 2n - 1 nodes. The root of that tree is the node with the value 1, and every node with a value val in the range [1, 2n - 1 - 1] has two children where:\n\nThe left node has the value 2 * val, and\nThe right node has the value 2 * val + 1.\n\nYou are also given a 2D integer array queries of length m, where queries[i] = [ai, bi]. For each query, solve the following problem:\n\nAdd an edge between the nodes with values ai and bi.\nFind the length of the cycle in the graph.\nRemove the added edge between nodes with values ai and bi.\n\nNote that:\n\nA cycle is a path that starts and ends at the same node, and each edge in the path is visited only once.\nThe length of a cycle is the number of edges visited in the cycle.\nThere could be multiple edges between two nodes in the tree after adding the edge of the query.\n\nReturn an array answer of length m where answer[i] is the answer to the ith query.\n \nExample 1:\n\n\nInput: n = 3, queries = [[5,3],[4,7],[2,3]]\nOutput: [4,5,3]\nExplanation: The diagrams above show the tree of 23 - 1 nodes. Nodes colored in red describe the nodes in the cycle after adding the edge.\n- After adding the edge between nodes 3 and 5, the graph contains a cycle of nodes [5,2,1,3]. Thus answer to the first query is 4. We delete the added edge and process the next query.\n- After adding the edge between nodes 4 and 7, the graph contains a cycle of nodes [4,2,1,3,7]. Thus answer to the second query is 5. We delete the added edge and process the next query.\n- After adding the edge between nodes 2 and 3, the graph contains a cycle of nodes [2,1,3]. Thus answer to the third query is 3. We delete the added edge.\n\nExample 2:\n\n\nInput: n = 2, queries = [[1,2]]\nOutput: [2]\nExplanation: The diagram above shows the tree of 22 - 1 nodes. Nodes colored in red describe the nodes in the cycle after adding the edge.\n- After adding the edge between nodes 1 and 2, the graph contains a cycle of nodes [2,1]. Thus answer for the first query is 2. We delete the added edge.\n\n \nConstraints:\n\n2 <= n <= 30\nm == queries.length\n1 <= m <= 105\nqueries[i].length == 2\n1 <= ai, bi <= 2n - 1\nai != bi\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,queries = [[31, 15], [10, 18], [9, 20]]) == [2, 6, 6]\n assert candidate(n = 3,queries = [[5, 3], [4, 7], [2, 3]]) == [4, 5, 3]\n assert candidate(n = 5,queries = [[15, 7], [10, 14], [3, 12]]) == [2, 7, 3]\n assert candidate(n = 30,queries = [[1073741823, 1], [536870912, 2], [268435456, 4]]) == [30, 29, 27]\n assert candidate(n = 4,queries = [[8, 4], [7, 3], [1, 14]]) == [2, 2, 4]\n assert candidate(n = 4,queries = [[1, 15], [14, 2], [12, 10], [6, 3]]) == [4, 5, 7, 2]\n assert candidate(n = 2,queries = [[1, 2]]) == [2]\n assert candidate(n = 5,queries = [[3, 15], [16, 7], [8, 9]]) == [3, 7, 3]\n assert candidate(n = 6,queries = [[32, 1], [16, 15], [8, 7], [4, 3], [2, 1]]) == [6, 8, 6, 4, 2]\n assert candidate(n = 4,queries = [[8, 4], [6, 10], [5, 9]]) == [2, 6, 4]\n assert candidate(n = 19,queries = [[262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767], [8192, 16383], [4096, 8191], [2048, 4095], [1024, 2047], [512, 1023], [256, 511], [128, 255], [64, 127], [32, 63], [16, 31], [8, 15], [4, 7], [2, 3]]) == [37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3]\n assert candidate(n = 10,queries = [[511, 1], [256, 2], [128, 4], [64, 8], [32, 16], [16, 32], [8, 64], [4, 128], [2, 256], [1, 511], [511, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1], [511, 510], [510, 509], [509, 508], [508, 507], [507, 506], [506, 505]]) == [9, 8, 6, 4, 2, 2, 4, 6, 8, 9, 17, 2, 2, 2, 2, 2, 2, 2, 2, 3, 5, 3, 7, 3, 5]\n assert candidate(n = 18,queries = [[131071, 1], [65536, 2], [32768, 4], [16384, 8], [8192, 16], [4096, 32], [2048, 64], [1024, 128], [512, 256], [256, 512], [128, 1024], [64, 2048], [32, 4096], [16, 8192], [8, 16384], [4, 32768], [2, 65536], [1, 131071]]) == [17, 16, 14, 12, 10, 8, 6, 4, 2, 2, 4, 6, 8, 10, 12, 14, 16, 17]\n assert candidate(n = 20,queries = [[1048575, 1], [524288, 2], [262144, 4], [131072, 8], [65536, 16], [32768, 32], [16384, 64], [8192, 128], [4096, 256], [2048, 512], [1024, 1024], [512, 2048], [256, 4096], [128, 8192], [64, 16384], [32, 32768], [16, 65536], [8, 131072], [4, 262144], [2, 524288], [1, 1048575]]) == [20, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20]\n assert candidate(n = 15,queries = [[32767, 16384], [8192, 4096], [2048, 1024], [512, 256], [128, 64]]) == [29, 2, 2, 2, 2]\n assert candidate(n = 25,queries = [[33554432, 67108864], [16777216, 33554431], [8388608, 16777215], [4194304, 8388607]]) == [2, 49, 47, 45]\n assert candidate(n = 10,queries = [[1023, 1], [512, 2], [256, 3], [128, 4], [64, 5], [32, 6], [16, 7], [8, 8], [4, 9], [2, 10]]) == [10, 9, 10, 6, 7, 8, 7, 1, 2, 3]\n assert candidate(n = 22,queries = [[4194303, 2097152], [2097151, 1048576], [1048575, 524288], [524287, 262144], [262143, 131072], [131071, 65536], [65535, 32768], [32767, 16384], [16383, 8192]]) == [43, 41, 39, 37, 35, 33, 31, 29, 27]\n assert candidate(n = 25,queries = [[33554431, 16777216], [16777216, 8388608], [8388608, 4194304], [4194304, 2097152], [2097152, 1048576], [1048576, 524288], [524288, 262144], [262144, 131072], [131072, 65536], [65536, 32768], [32768, 16384], [16384, 8192], [8192, 4096], [4096, 2048], [2048, 1024], [1024, 512], [512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1]]) == [49, 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(n = 20,queries = [[1048575, 524288], [524287, 262144], [262143, 131072], [131071, 65536], [65535, 32768]]) == [39, 37, 35, 33, 31]\n assert candidate(n = 15,queries = [[16383, 1], [8192, 3], [4096, 7], [2048, 15], [1024, 31]]) == [14, 15, 15, 15, 15]\n assert candidate(n = 12,queries = [[4095, 1], [2047, 2], [1023, 4], [511, 8], [255, 16], [127, 32], [63, 64], [31, 128], [15, 256], [7, 512], [3, 1024], [1, 2048], [4094, 4095], [2046, 2047], [1022, 1023], [510, 511], [254, 255], [126, 127], [62, 63], [30, 31], [14, 15], [6, 7], [2, 3], [1, 2], [4093, 1], [2045, 2], [1021, 4], [509, 8], [253, 16], [125, 32], [61, 64], [30, 128], [14, 256], [6, 512], [2, 1024], [1, 2048]]) == [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 10, 12]\n assert candidate(n = 15,queries = [[16384, 32767], [8192, 16383], [4096, 8191], [2048, 4095], [1024, 2047], [512, 1023]]) == [29, 27, 25, 23, 21, 19]\n assert candidate(n = 10,queries = [[511, 256], [1023, 512], [768, 384], [255, 128], [127, 64]]) == [17, 19, 2, 15, 13]\n assert candidate(n = 10,queries = [[1023, 511], [511, 255], [255, 127], [127, 63], [63, 31], [31, 15], [15, 7], [7, 3], [3, 1]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 10,queries = [[512, 1], [256, 2], [128, 4], [64, 8], [32, 16], [16, 32], [8, 64], [4, 128], [2, 256], [1, 512]]) == [10, 8, 6, 4, 2, 2, 4, 6, 8, 10]\n assert candidate(n = 20,queries = [[1048576, 1], [524288, 2], [262144, 4], [131072, 8], [65536, 16], [32768, 32], [16384, 64], [8192, 128], [4096, 256], [2048, 512], [1024, 1024], [512, 2048], [256, 4096], [128, 8192], [64, 16384], [32, 32768], [16, 65536], [8, 131072], [4, 262144], [2, 524288]]) == [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(n = 12,queries = [[4095, 2048], [2048, 1024], [1024, 512], [512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1], [4095, 2047], [2047, 2046], [2046, 2045], [2045, 2044], [2044, 2043], [2043, 2042], [2042, 2041], [2041, 2040], [2040, 2039], [2039, 2038], [2038, 2037], [2037, 2036], [2036, 2035], [2035, 2034], [2034, 2033], [2033, 2032], [2032, 2031]]) == [23, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 5, 3, 7, 3, 5, 3, 9, 3, 5, 3, 7, 3, 5, 3, 11]\n assert candidate(n = 10,queries = [[512, 256], [1024, 513], [128, 64], [2048, 1025], [4096, 2049]]) == [2, 4, 2, 4, 4]\n assert candidate(n = 15,queries = [[16383, 1], [8191, 2], [4095, 4], [2047, 8], [1023, 16], [511, 32], [255, 64], [127, 128], [63, 256], [31, 512], [15, 1024], [7, 2048], [3, 4096], [1, 8192], [16382, 16383], [8190, 8191], [4094, 4095], [2046, 2047], [1022, 1023], [510, 511], [254, 255], [126, 127], [62, 63], [30, 31], [14, 15], [6, 7], [2, 3], [1, 2]]) == [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]\n assert candidate(n = 18,queries = [[131072, 65536], [262144, 131073], [32768, 16384], [524288, 262145], [1048576, 524289]]) == [2, 4, 2, 4, 4]\n assert candidate(n = 20,queries = [[1048575, 1], [524288, 2], [262144, 4], [131072, 8], [65536, 16], [32768, 32], [16384, 64], [8192, 128], [4096, 256], [2048, 512]]) == [20, 19, 17, 15, 13, 11, 9, 7, 5, 3]\n assert candidate(n = 17,queries = [[65535, 32768], [16384, 8192], [4096, 2048], [1024, 512], [256, 128], [64, 32], [16, 8], [4, 2], [2, 1], [65535, 1], [32768, 2], [16384, 4], [8192, 8], [4096, 16], [2048, 32], [1024, 64], [512, 128]]) == [31, 2, 2, 2, 2, 2, 2, 2, 2, 16, 15, 13, 11, 9, 7, 5, 3]\n assert candidate(n = 12,queries = [[4095, 1], [2048, 3], [1024, 7], [512, 15], [256, 31], [128, 63], [64, 127], [32, 255], [16, 511], [8, 1023], [4, 2047], [2, 4095]]) == [12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\n assert candidate(n = 15,queries = [[16384, 8192], [32768, 16385], [4096, 2048], [65536, 32769], [131072, 65537]]) == [2, 4, 2, 4, 4]\n assert candidate(n = 20,queries = [[1048575, 524288], [2097151, 1048576], [3145727, 1572864], [4194303, 2097152], [524287, 262144]]) == [39, 41, 42, 43, 37]\n assert candidate(n = 27,queries = [[134217727, 67108864], [67108863, 33554432], [33554431, 16777216], [16777215, 8388608], [8388607, 4194304], [4194303, 2097152], [2097151, 1048576], [1048575, 524288], [524287, 262144], [262143, 131072], [131071, 65536], [65535, 32768], [32767, 16384], [16383, 8192], [8191, 4096], [4095, 2048], [2047, 1024], [1023, 512], [511, 256], [255, 128], [127, 64], [63, 32], [31, 16], [15, 8], [7, 4], [3, 2], [1, 2]]) == [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, 2]\n assert candidate(n = 25,queries = [[16777215, 8388608], [4194304, 2097152], [2097152, 1048576], [1048576, 524288], [524288, 262144], [262144, 131072], [131072, 65536], [65536, 32768], [32768, 16384], [16384, 8192]]) == [47, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 18,queries = [[131071, 65536], [32768, 16384], [8192, 4096], [2048, 1024], [512, 256], [128, 64], [32, 16], [8, 4], [2, 1], [131071, 1], [65536, 2], [32768, 4], [16384, 8]]) == [33, 2, 2, 2, 2, 2, 2, 2, 2, 17, 16, 14, 12]\n assert candidate(n = 25,queries = [[33554431, 16777216], [16777215, 8388608], [8388607, 4194304], [4194303, 2097152], [2097151, 1048576]]) == [49, 47, 45, 43, 41]\n assert candidate(n = 14,queries = [[8192, 4096], [16384, 8193], [2048, 1024], [32768, 16385], [65536, 32769]]) == [2, 4, 2, 4, 4]\n assert candidate(n = 19,queries = [[262144, 131072], [524288, 262145], [65536, 32768], [1048576, 524289], [2097152, 1048577]]) == [2, 4, 2, 4, 4]\n assert candidate(n = 10,queries = [[511, 256], [128, 64], [32, 16], [8, 4], [4, 2], [2, 1], [128, 1], [256, 32], [511, 64]]) == [17, 2, 2, 2, 2, 2, 8, 4, 15]\n assert candidate(n = 25,queries = [[33554431, 16777216], [8388608, 4194304], [2097152, 1048576], [524288, 262144], [131072, 65536]]) == [49, 2, 2, 2, 2]\n assert candidate(n = 20,queries = [[524288, 262144], [1048576, 524289], [131072, 65536], [2097152, 1048577], [4194304, 2097153]]) == [2, 4, 2, 4, 4]\n assert candidate(n = 12,queries = [[2048, 1024], [4096, 2049], [512, 256], [8192, 4097], [16384, 8193]]) == [2, 4, 2, 4, 4]\n assert candidate(n = 12,queries = [[4095, 2048], [8191, 4096], [12287, 6144], [16383, 8192], [2047, 1024]]) == [23, 25, 26, 27, 21]\n assert candidate(n = 15,queries = [[16383, 1], [8192, 2], [4096, 4], [2048, 8], [1024, 16], [512, 32], [256, 64], [128, 128]]) == [14, 13, 11, 9, 7, 5, 3, 1]\n assert candidate(n = 20,queries = [[524287, 262144], [131072, 65536], [32768, 16384], [8192, 4096], [2048, 1024], [512, 256], [128, 64], [32, 16], [8, 4]]) == [37, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 8,queries = [[127, 1], [63, 2], [31, 4], [15, 8], [7, 16], [3, 32], [1, 64], [126, 127], [62, 63], [30, 31], [14, 15], [6, 7], [2, 3], [1, 2], [125, 127], [61, 63], [29, 31], [13, 15], [5, 7], [1, 3], [124, 127], [60, 63], [28, 31], [12, 15], [4, 7], [0, 3], [123, 127], [59, 63], [27, 31], [11, 15], [3, 7], [1, 3]]) == [7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 2, 5, 5, 5, 5, 5, 2, 5, 5, 5, 5, 5, 3, 7, 7, 7, 7, 2, 2]\n assert candidate(n = 15,queries = [[16383, 1], [8192, 2], [4096, 4], [2048, 8], [1024, 16], [512, 32], [256, 64], [128, 128], [64, 256], [32, 512], [16, 1024], [8, 2048], [4, 4096], [2, 8192], [1, 16383]]) == [14, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 13, 14]\n assert candidate(n = 25,queries = [[16777216, 8388608], [8388608, 4194304], [4194304, 2097152], [2097152, 1048576], [1048576, 524288]]) == [2, 2, 2, 2, 2]\n assert candidate(n = 20,queries = [[1048575, 1], [524288, 2], [262144, 4], [131072, 8], [65536, 16]]) == [20, 19, 17, 15, 13]\n assert candidate(n = 18,queries = [[262143, 131072], [131071, 65536], [65535, 32768], [32767, 16384], [16383, 8192], [8191, 4096], [4095, 2048], [2047, 1024], [1023, 512]]) == [35, 33, 31, 29, 27, 25, 23, 21, 19]\n assert candidate(n = 25,queries = [[33554432, 16777216], [67108864, 33554433], [8388608, 4194304], [134217728, 67108865]]) == [2, 4, 2, 4]\n assert candidate(n = 18,queries = [[131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767], [8192, 16383], [4096, 8191], [2048, 4095], [1024, 2047]]) == [35, 33, 31, 29, 27, 25, 23, 21]\n assert candidate(n = 25,queries = [[33554431, 16777216], [16777215, 8388608], [8388607, 4194304], [4194303, 2097152], [2097151, 1048576]]) == [49, 47, 45, 43, 41]\n assert candidate(n = 18,queries = [[262143, 1], [131072, 3], [65536, 7], [32768, 15], [16384, 31], [8192, 63], [4096, 127], [2048, 255], [1024, 511], [512, 1023], [256, 2047], [128, 4095], [64, 8191], [32, 16383], [16, 32767], [8, 65535], [4, 131071], [2, 262143]]) == [18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(n = 28,queries = [[268435455, 1], [134217728, 2], [67108864, 4], [33554432, 8], [16777216, 16], [8388608, 32], [4194304, 64], [2097152, 128], [1048576, 256], [524288, 512], [262144, 1024], [131072, 2048], [65536, 4096], [32768, 8192], [16384, 16384], [8192, 32768], [4096, 65536], [2048, 131072], [1024, 262144], [512, 524288], [256, 1048576], [128, 2097152], [64, 4194304], [32, 8388608], [16, 16777216], [8, 33554432], [4, 67108864], [2, 134217728]]) == [28, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]\n assert candidate(n = 15,queries = [[16383, 16384], [8192, 12287], [4096, 6143], [2048, 8192], [1024, 4096]]) == [28, 25, 23, 3, 3]\n assert candidate(n = 22,queries = [[2097152, 4194303], [1048576, 2097151], [524288, 1048575], [262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767]]) == [43, 41, 39, 37, 35, 33, 31, 29]\n assert candidate(n = 25,queries = [[33554431, 1], [16777216, 2], [8388608, 4], [4194304, 8], [2097152, 16], [1048576, 32], [524288, 64], [262144, 128], [131072, 256], [65536, 512], [32768, 1024], [16384, 2048], [8192, 4096], [4096, 8192], [2048, 16384], [1024, 32768], [512, 65536], [256, 131072], [128, 262144], [64, 524288], [32, 1048576], [16, 2097152], [8, 4194304], [4, 8388608], [2, 16777216]]) == [25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]\n assert candidate(n = 20,queries = [[524288, 1048575], [262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535]]) == [39, 37, 35, 33, 31]\n assert candidate(n = 16,queries = [[65535, 32768], [32767, 16384], [16383, 8192], [8191, 4096], [4095, 2048], [2047, 1024], [1023, 512], [511, 256], [255, 128], [127, 64], [63, 32], [31, 16], [15, 8], [7, 4], [3, 2], [1, 2]]) == [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 2]\n assert candidate(n = 15,queries = [[16383, 8192], [4096, 2048], [1024, 512], [256, 128], [64, 32], [16, 8], [4, 2], [2, 1]]) == [27, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 12,queries = [[2048, 4095], [1024, 2047], [512, 1023], [256, 511], [128, 255], [64, 127], [32, 63], [16, 31], [8, 15], [4, 7]]) == [23, 21, 19, 17, 15, 13, 11, 9, 7, 5]\n assert candidate(n = 10,queries = [[511, 256], [255, 128], [127, 64], [63, 32], [31, 16], [15, 8], [7, 4], [3, 2], [1, 2]]) == [17, 15, 13, 11, 9, 7, 5, 3, 2]\n assert candidate(n = 10,queries = [[512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 20,queries = [[524288, 1048575], [262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767]]) == [39, 37, 35, 33, 31, 29]\n assert candidate(n = 15,queries = [[16383, 1], [32767, 16384], [49151, 8192], [65535, 4096], [8191, 2048]]) == [14, 29, 27, 28, 24]\n"}, "metadata": {"canonical_parameter_names": ["n", "queries"], "leetcode_dataset_entry_point": "Solution().cycleLengthQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] cycleLengthQueries(int n, int[][] queries) {", "container": "Solution", "callable": "cycleLengthQueries", "parameters": [{"name": "n", "type": "int"}, {"name": "queries", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2511, "task_id": "maximum-enemy-forts-that-can-be-captured", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array forts of length n representing the positions of several forts. forts[i] can be -1, 0, or 1 where:\n\n-1 represents there is no fort at the ith position.\n0 indicates there is an enemy fort at the ith position.\n1 indicates the fort at the ith the position is under your command.\n\nNow you have decided to move your army from one of your forts at position i to an empty position j such that:\n\n0 <= i, j <= n - 1\nThe army travels over enemy forts only. Formally, for all k where min(i,j) < k < max(i,j), forts[k] == 0.\n\nWhile moving the army, all the enemy forts that come in the way are captured.\nReturn the maximum number of enemy forts that can be captured. In case it is impossible to move your army, or you do not have any fort under your command, return 0.\n \nExample 1:\n\nInput: forts = [1,0,0,-1,0,0,0,0,1]\nOutput: 4\nExplanation:\n- Moving the army from position 0 to position 3 captures 2 enemy forts, at 1 and 2.\n- Moving the army from position 8 to position 3 captures 4 enemy forts.\nSince 4 is the maximum number of enemy forts that can be captured, we return 4.\n\nExample 2:\n\nInput: forts = [0,0,1,-1]\nOutput: 0\nExplanation: Since no enemy fort can be captured, 0 is returned.\n\n \nConstraints:\n\n1 <= forts.length <= 1000\n-1 <= forts[i] <= 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(forts = [1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(forts = [-1, 0, 0, 0, 0, 1]) == 4\n assert candidate(forts = [0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, -1]) == 2\n assert candidate(forts = [1, -1]) == 0\n assert candidate(forts = [0, 0, 0, 0, 0]) == 0\n assert candidate(forts = [-1]) == 0\n assert candidate(forts = [0]) == 0\n assert candidate(forts = [1, 0, -1, 0, 1, 0, -1]) == 1\n assert candidate(forts = [0, 0, 0, 0]) == 0\n assert candidate(forts = [0, 1, 0, -1, 0]) == 1\n assert candidate(forts = [1, -1, 1, -1, 1, -1]) == 0\n assert candidate(forts = [-1, 1, -1, 1, -1, 1]) == 0\n assert candidate(forts = [0, 0, 1, -1]) == 0\n assert candidate(forts = [0, 1, 0, -1, 0, 1, 0]) == 1\n assert candidate(forts = [1, 1, 1, -1, -1, -1, 1]) == 0\n assert candidate(forts = [-1, 0, -1, 0, 1, 0, 1]) == 1\n assert candidate(forts = [1, 0, 0, 0, 0, -1]) == 4\n assert candidate(forts = [1, 0, 1, 0, -1, 0, -1]) == 1\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 1]) == 6\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, -1]) == 6\n assert candidate(forts = [1, 0, 0, -1, 0, 0, 0, 0, 1]) == 4\n assert candidate(forts = [1, 0, 0, 0, 0, 0, -1]) == 5\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(forts = [1]) == 0\n assert candidate(forts = [1, 1, -1, -1, 1, 1]) == 0\n assert candidate(forts = [-1, 0, -1, 0, 1, 0, -1]) == 1\n assert candidate(forts = [1, -1, 1, -1, 1]) == 0\n assert candidate(forts = [-1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, -1]) == 1\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [-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, -1]) == 0\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, 0, -1]) == 3\n assert candidate(forts = [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\n assert candidate(forts = [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\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [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, -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]) == 43\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 13\n assert candidate(forts = [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, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 43\n assert candidate(forts = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1]) == 3\n assert candidate(forts = [-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]) == 4\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n assert candidate(forts = [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]) == 0\n assert candidate(forts = [0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1]) == 5\n assert candidate(forts = [-1, 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]) == 2\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [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, -1, 0, 0, 0, 0, 0, 1]) == 43\n assert candidate(forts = [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, -1]) == 29\n assert candidate(forts = [-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, -1]) == 0\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1]) == 5\n assert candidate(forts = [-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]) == 5\n assert candidate(forts = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 0, 1]) == 4\n assert candidate(forts = [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, -1]) == 50\n assert candidate(forts = [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, -1]) == 71\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [-1, 0, 0, 0, 0, 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]) == 7\n assert candidate(forts = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 1\n assert candidate(forts = [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, -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, 1, 0, 0, 0, 0, 0, -1]) == 43\n assert candidate(forts = [-1, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 1, 0]) == 4\n assert candidate(forts = [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]) == 7\n assert candidate(forts = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]) == 8\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 1, -1]) == 4\n assert candidate(forts = [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]) == 0\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [-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, 1, 0, 0, 0, 0, 0, -1]) == 43\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]) == 6\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 1]) == 2\n assert candidate(forts = [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 8\n assert candidate(forts = [-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, 1]) == 77\n assert candidate(forts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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\n assert candidate(forts = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n assert candidate(forts = [-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, -1]) == 0\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n assert candidate(forts = [-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, -1]) == 0\n assert candidate(forts = [1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1]) == 3\n assert candidate(forts = [1, 0, 0, -1, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, -1]) == 4\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, -1, 0, 0, 1, 0, 0, -1, 0, 0, 1, 0, 0, -1]) == 2\n assert candidate(forts = [1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1]) == 10\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 10\n assert candidate(forts = [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, -1]) == 56\n assert candidate(forts = [-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]) == 0\n assert candidate(forts = [-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, -1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 12\n assert candidate(forts = [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]) == 0\n assert candidate(forts = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1]) == 2\n assert candidate(forts = [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, 1]) == 0\n assert candidate(forts = [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]) == 5\n assert candidate(forts = [0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1]) == 5\n"}, "metadata": {"canonical_parameter_names": ["forts"], "leetcode_dataset_entry_point": "Solution().captureForts", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int captureForts(int[] forts) {", "container": "Solution", "callable": "captureForts", "parameters": [{"name": "forts", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2512, "task_id": "reward-top-k-students", "difficulty": "Medium", "problem_description": "You are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively. Note that no word is both positive and negative.\nInitially every student has 0 points. Each positive word in a feedback report increases the points of a student by 3, whereas each negative word decreases the points by 1.\nYou are given n feedback reports, represented by a 0-indexed string array report and a 0-indexed integer array student_id, where student_id[i] represents the ID of the student who has received the feedback report report[i]. The ID of each student is unique.\nGiven an integer k, return the top k students after ranking them in non-increasing order by their points. In case more than one student has the same points, the one with the lower ID ranks higher.\n \nExample 1:\n\nInput: positive_feedback = [\"smart\",\"brilliant\",\"studious\"], negative_feedback = [\"not\"], report = [\"this student is studious\",\"the student is smart\"], student_id = [1,2], k = 2\nOutput: [1,2]\nExplanation: \nBoth the students have 1 positive feedback and 3 points but since student 1 has a lower ID he ranks higher.\n\nExample 2:\n\nInput: positive_feedback = [\"smart\",\"brilliant\",\"studious\"], negative_feedback = [\"not\"], report = [\"this student is not studious\",\"the student is smart\"], student_id = [1,2], k = 2\nOutput: [2,1]\nExplanation: \n- The student with ID 1 has 1 positive feedback and 1 negative feedback, so he has 3-1=2 points. \n- The student with ID 2 has 1 positive feedback, so he has 3 points. \nSince student 2 has more points, [2,1] is returned.\n\n \nConstraints:\n\n1 <= positive_feedback.length, negative_feedback.length <= 104\n1 <= positive_feedback[i].length, negative_feedback[j].length <= 100\nBoth positive_feedback[i] and negative_feedback[j] consists of lowercase English letters.\nNo word is present in both positive_feedback and negative_feedback.\nn == report.length == student_id.length\n1 <= n <= 104\nreport[i] consists of lowercase English letters and spaces ' '.\nThere is a single space between consecutive words of report[i].\n1 <= report[i].length <= 100\n1 <= student_id[i] <= 109\nAll the values of student_id[i] are unique.\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(positive_feedback = ['smart', 'brilliant', 'studious'],negative_feedback = ['not'],report = ['this student is studious', 'the student is smart'],student_id = [1, 2],k = 2) == [1, 2]\n assert candidate(positive_feedback = ['good', 'excellent'],negative_feedback = ['bad', 'poor'],report = ['the student is good and excellent', 'the student is bad but tries'],student_id = [3, 4],k = 1) == [3]\n assert candidate(positive_feedback = ['smart', 'brilliant', 'studious'],negative_feedback = ['not'],report = ['this student is not studious', 'the student is smart'],student_id = [1, 2],k = 2) == [2, 1]\n assert candidate(positive_feedback = ['good', 'excellent'],negative_feedback = ['bad', 'poor'],report = ['the student is good', 'the student is excellent', 'the student is bad', 'the student is poor'],student_id = [101, 102, 103, 104],k = 2) == [101, 102]\n assert candidate(positive_feedback = ['good', 'excellent'],negative_feedback = ['bad', 'poor'],report = ['the student is good and excellent', 'the student is bad'],student_id = [3, 4],k = 1) == [3]\n assert candidate(positive_feedback = ['outstanding'],negative_feedback = ['poor'],report = ['the student is outstanding', 'the student is poor', 'the student is not poor'],student_id = [100, 200, 300],k = 3) == [100, 200, 300]\n assert candidate(positive_feedback = ['good', 'great'],negative_feedback = ['average', 'terrible'],report = ['average performance', 'good work but could be better', 'terrible experience'],student_id = [301, 302, 303],k = 2) == [302, 301]\n assert candidate(positive_feedback = ['kind', 'friendly'],negative_feedback = ['rude', 'mean'],report = ['the student is kind', 'the student is mean'],student_id = [7, 8],k = 2) == [7, 8]\n assert candidate(positive_feedback = ['hardworking', 'diligent'],negative_feedback = ['lazy', 'slacker'],report = ['the student is hardworking', 'the student is diligent', 'the student is lazy', 'the student is slacker'],student_id = [501, 502, 503, 504],k = 3) == [501, 502, 503]\n assert candidate(positive_feedback = ['hardworking', 'dedicated'],negative_feedback = ['lazy', 'inattentive'],report = ['the student is hardworking and dedicated', 'the student is lazy'],student_id = [10, 20],k = 1) == [10]\n assert candidate(positive_feedback = ['helpful', 'efficient'],negative_feedback = ['lazy', 'inefficient'],report = ['the student is helpful', 'the student is lazy'],student_id = [5, 6],k = 2) == [5, 6]\n assert candidate(positive_feedback = ['excellent', 'outstanding'],negative_feedback = ['poor', 'bad'],report = ['very poor performance', 'outstanding in every aspect'],student_id = [201, 202],k = 2) == [202, 201]\n assert candidate(positive_feedback = ['adept', 'proficient'],negative_feedback = ['incompetent', 'unskilled'],report = ['the student is adept', 'the student is proficient', 'the student is incompetent', 'the student is unskilled'],student_id = [701, 702, 703, 704],k = 4) == [701, 702, 703, 704]\n assert candidate(positive_feedback = ['excellent'],negative_feedback = ['terrible'],report = ['the student is excellent', 'the student is terrible', 'the student is terrible but excellent'],student_id = [5, 15, 25],k = 2) == [5, 25]\n assert candidate(positive_feedback = ['outstanding', 'great'],negative_feedback = ['average', 'poor'],report = ['the student is average', 'the student is outstanding'],student_id = [5, 6],k = 2) == [6, 5]\n assert candidate(positive_feedback = ['hardworking', 'dedicated'],negative_feedback = ['lazy', 'slacking'],report = ['the student is lazy', 'the student is dedicated and hardworking'],student_id = [7, 8],k = 2) == [8, 7]\n assert candidate(positive_feedback = ['hardworking', 'dedicated'],negative_feedback = ['lazy', 'careless'],report = ['the student is hardworking and dedicated', 'the student is lazy but smart'],student_id = [101, 102],k = 1) == [101]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'great'],negative_feedback = ['bad', 'poor', 'terrible'],report = ['the student is excellent and great', 'the student is poor', 'the student is excellent but terrible'],student_id = [5, 3, 8],k = 2) == [5, 8]\n assert candidate(positive_feedback = ['efficient', 'productive', 'organized'],negative_feedback = ['disorganized', 'inefficient', 'unproductive'],report = ['the student is efficient and organized', 'the student is disorganized and inefficient', 'the student is productive'],student_id = [3001, 3002, 3003],k = 1) == [3001]\n assert candidate(positive_feedback = ['knowledgeable', 'informed', 'learned'],negative_feedback = ['ignorant', 'uninformed', 'naive'],report = ['the student is knowledgeable', 'the student is uninformed', 'the student is ignorant and naive'],student_id = [4001, 4002, 4003],k = 2) == [4001, 4002]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'impressive'],negative_feedback = ['poor', 'mediocre', 'inadequate'],report = ['the student is excellent and impressive', 'the student is mediocre', 'the student is excellent but also poor'],student_id = [1001, 1002, 1003],k = 3) == [1001, 1003, 1002]\n assert candidate(positive_feedback = ['innovative', 'creative', 'inspiring'],negative_feedback = ['dull', 'boring', 'unoriginal'],report = ['the student is innovative and creative', 'the student is unoriginal', 'the student is inspiring but also unoriginal'],student_id = [2001, 2002, 2003],k = 2) == [2001, 2003]\n assert candidate(positive_feedback = ['innovative', 'creative', 'original'],negative_feedback = ['conventional', 'boring', 'predictable'],report = ['the student is conventional and boring', 'the student is creative and innovative', 'the student is original but not always predictable', 'the student is predictable but hardworking'],student_id = [5001, 5002, 5003, 5004],k = 2) == [5002, 5003]\n assert candidate(positive_feedback = ['knowledgeable', 'wise', 'informed'],negative_feedback = ['ignorant', 'naive', 'uninformed'],report = ['the student is knowledgeable and wise', 'the student is ignorant and naive', 'the student is informed and smart'],student_id = [4001, 4002, 4003],k = 2) == [4001, 4003]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'slow', 'inconsistent'],report = ['the student is efficient', 'the student is productive', 'the student is focused'],student_id = [9001, 9002, 9003],k = 2) == [9001, 9002]\n assert candidate(positive_feedback = ['curious', 'inquisitive', 'investigative'],negative_feedback = ['ignorant', 'uninterested', 'apathetic'],report = ['the student is curious and inquisitive', 'the student is ignorant and uninterested', 'the student is investigative but needs rest'],student_id = [999, 998, 997],k = 3) == [999, 997, 998]\n assert candidate(positive_feedback = ['leader', 'motivator', 'captain'],negative_feedback = ['follower', 'lazy', 'unmotivated'],report = ['the student is leader and motivator', 'the student is follower and lazy', 'the student is captain but tired'],student_id = [777, 778, 779],k = 1) == [777]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'remarkable'],negative_feedback = ['poor', 'mediocre', 'inadequate'],report = ['the student was excellent and outstanding', 'the student was not excellent but remarkable', 'the student was poor and mediocre'],student_id = [1001, 1002, 1003],k = 3) == [1001, 1002, 1003]\n assert candidate(positive_feedback = ['outstanding', 'excellent', 'remarkable'],negative_feedback = ['poor', 'bad', 'mediocre'],report = ['the student is outstanding and excellent', 'the student is mediocre', 'the student is poor'],student_id = [1001, 1002, 1003],k = 2) == [1001, 1002]\n assert candidate(positive_feedback = ['persevering', 'determined', 'resilient'],negative_feedback = ['quitter', 'defeated', 'weak'],report = ['the student is persevering', 'the student is determined', 'the student is resilient', 'the student is a quitter', 'the student is defeated', 'the student is weak'],student_id = [3001, 3002, 3003, 3004, 3005, 3006],k = 4) == [3001, 3002, 3003, 3004]\n assert candidate(positive_feedback = ['reliable', 'trustworthy', 'dependable'],negative_feedback = ['unreliable', 'dishonest', 'untrustworthy'],report = ['the student is reliable and dependable', 'the student is unreliable and dishonest', 'the student is trustworthy but late'],student_id = [10, 20, 30],k = 1) == [10]\n assert candidate(positive_feedback = ['inspired', 'motivated', 'eager'],negative_feedback = ['disinterested', 'apathetic', 'unmotivated'],report = ['the student is inspired and eager', 'the student is disinterested', 'the student is motivated', 'the student is apathetic', 'the student is unmotivated'],student_id = [6001, 6002, 6003, 6004, 6005],k = 4) == [6001, 6003, 6002, 6004]\n assert candidate(positive_feedback = ['innovative', 'creative', 'resourceful'],negative_feedback = ['lazy', 'disorganized', 'unfocused'],report = ['the student is innovative and creative', 'the student is lazy', 'the student is disorganized', 'the student is resourceful'],student_id = [2001, 2002, 2003, 2004],k = 3) == [2001, 2004, 2002]\n assert candidate(positive_feedback = ['helpful', 'cooperative', 'supportive'],negative_feedback = ['unhelpful', 'selfish', 'uncooperative'],report = ['the student is helpful and cooperative', 'the student is selfish and unhelpful', 'the student is supportive but mediocre'],student_id = [201, 202, 203],k = 3) == [201, 203, 202]\n assert candidate(positive_feedback = ['honest', 'truthful', 'sincere'],negative_feedback = ['liar', 'deceptive', 'dishonest'],report = ['the student is honest and truthful', 'the student is liar and deceptive', 'the student is sincere but sometimes forgetful'],student_id = [888, 887, 886],k = 2) == [888, 886]\n assert candidate(positive_feedback = ['innovative', 'creative', 'inspiring'],negative_feedback = ['unoriginal', 'boring', 'stupid'],report = ['the student is innovative and creative', 'the student is unoriginal and stupid', 'the student is inspiring'],student_id = [1001, 1002, 1003],k = 2) == [1001, 1003]\n assert candidate(positive_feedback = ['kind', 'polite', 'considerate'],negative_feedback = ['rude', 'impolite'],report = ['the student is kind and polite', 'the student is impolite', 'the student is rude', 'the student is considerate', 'the student is impolite but kind'],student_id = [101, 102, 103, 104, 105],k = 4) == [101, 104, 105, 102]\n assert candidate(positive_feedback = ['helpful', 'supportive', 'collaborative'],negative_feedback = ['unfriendly', 'rude', 'impolite'],report = ['helpful and supportive', 'the student is rude', 'collaborative efforts', 'impolite behavior noted', 'supportive actions'],student_id = [4001, 4002, 4003, 4004, 4005],k = 4) == [4001, 4003, 4005, 4002]\n assert candidate(positive_feedback = ['helpful', 'generous', 'compassionate'],negative_feedback = ['selfish', 'greedy', 'harsh'],report = ['the student is generous and helpful', 'the student is harsh', 'the student is greedy'],student_id = [2001, 2002, 2003],k = 3) == [2001, 2002, 2003]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'perfect'],negative_feedback = ['bad', 'poor', 'mediocre'],report = ['this is an excellent report', 'the student is poor', 'outstanding performance', 'mediocre work'],student_id = [1001, 1002, 1003, 1004],k = 2) == [1001, 1003]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'exceptional'],negative_feedback = ['poor', 'mediocre', 'bad'],report = ['the student is excellent and outstanding', 'the student is mediocre and bad', 'the student is exceptional'],student_id = [5, 6, 7],k = 2) == [5, 7]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'slow', 'inconsistent'],report = ['the student is efficient and productive', 'the student is productive and focused', 'the student is productive but inconsistent'],student_id = [6001, 6002, 6003],k = 2) == [6001, 6002]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'brilliant'],negative_feedback = ['poor', 'bad', 'terrible'],report = ['the student is excellent and outstanding', 'the student is brilliant', 'the student is poor but not bad', 'the student is terrible'],student_id = [10, 20, 30, 40],k = 3) == [10, 20, 40]\n assert candidate(positive_feedback = ['helpful', 'cooperative'],negative_feedback = ['selfish', 'unhelpful'],report = ['the student is helpful and cooperative', 'the student is selfish', 'the student is unhelpful', 'the student is helpful but unhelpful'],student_id = [100, 101, 102, 103],k = 2) == [100, 103]\n assert candidate(positive_feedback = ['efficient', 'resourceful', 'innovative'],negative_feedback = ['inefficient', 'wasteful', 'unproductive'],report = ['the student is inefficient and wasteful', 'the student is resourceful and innovative', 'the student is productive but not very innovative'],student_id = [2001, 2002, 2003],k = 3) == [2002, 2003, 2001]\n assert candidate(positive_feedback = ['dynamic', 'engaged', 'motivated'],negative_feedback = ['disinterested', 'unmotivated', 'apathetic'],report = ['dynamic performance', 'disinterested in work', 'engaged', 'apathetic attitude', 'motivated', 'dynamic'],student_id = [5001, 5002, 5003, 5004, 5005, 5006],k = 5) == [5001, 5003, 5005, 5006, 5002]\n assert candidate(positive_feedback = ['outstanding', 'excellent', 'genius'],negative_feedback = ['poor', 'dull', 'lazy'],report = ['the student is brilliant and excellent', 'the student is lazy but smart', 'the student is outstanding'],student_id = [501, 502, 503],k = 3) == [501, 503, 502]\n assert candidate(positive_feedback = ['efficient', 'productive', 'effective'],negative_feedback = ['lazy', 'inefficient', 'unproductive'],report = ['the student is lazy and inefficient', 'the student is productive and efficient', 'the student is effective but tired'],student_id = [301, 302, 303],k = 2) == [302, 303]\n assert candidate(positive_feedback = ['creative', 'innovative', 'resourceful'],negative_feedback = ['dull', 'boring', 'stagnant'],report = ['the student is innovative', 'the student is dull', 'the student is resourceful', 'the student is boring'],student_id = [3001, 3002, 3003, 3004],k = 2) == [3001, 3003]\n assert candidate(positive_feedback = ['helpful', 'compassionate', 'generous'],negative_feedback = ['selfish', 'greedy', 'cruel'],report = ['the student is helpful and compassionate', 'the student is generous', 'the student is selfish', 'the student is greedy', 'the student is cruel', 'the student is generous and helpful'],student_id = [4001, 4002, 4003, 4004, 4005, 4006],k = 5) == [4001, 4006, 4002, 4003, 4004]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'slow', 'inconsistent'],report = ['the student is efficient', 'the student is productive and focused', 'the student is unfocused and slow'],student_id = [2001, 2002, 2003],k = 2) == [2002, 2001]\n assert candidate(positive_feedback = ['eloquent', 'articulate', 'persuasive'],negative_feedback = ['confused', 'incoherent', 'unclear'],report = ['the student was eloquent and articulate', 'the student was unclear', 'the student was incoherent but tried his best'],student_id = [4001, 4002, 4003],k = 3) == [4001, 4002, 4003]\n assert candidate(positive_feedback = ['efficient', 'effective', 'productive'],negative_feedback = ['unproductive', 'slow', 'ineffective'],report = ['efficiency was very high', 'the work was slow', 'productive', 'ineffective methods used', 'effective results achieved'],student_id = [3001, 3002, 3003, 3004, 3005],k = 3) == [3003, 3005, 3001]\n assert candidate(positive_feedback = ['leader', 'motivator', 'teamplayer'],negative_feedback = ['coward', 'antisocial', 'uncooperative'],report = ['the student is a teamplayer and leader', 'the student is antisocial and coward', 'the student is cooperative and motivator'],student_id = [2001, 2002, 2003],k = 3) == [2001, 2003, 2002]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'slow', 'inconsistent'],report = ['the student is efficient and productive', 'the student is productive but unfocused', 'the student is productive and focused'],student_id = [8001, 8002, 8003],k = 2) == [8001, 8003]\n assert candidate(positive_feedback = ['resilient', 'strong', 'enduring'],negative_feedback = ['fragile', 'weak', 'endless'],report = ['the student is resilient and strong', 'the student is fragile and weak', 'the student is enduring'],student_id = [5001, 5002, 5003],k = 3) == [5001, 5003, 5002]\n assert candidate(positive_feedback = ['ambitious', 'aspirational', 'driven'],negative_feedback = ['unambitious', 'disinterested', 'apathetic'],report = ['the student is ambitious', 'the student is disinterested', 'the student is driven but also apathetic'],student_id = [5001, 5002, 5003],k = 2) == [5001, 5003]\n assert candidate(positive_feedback = ['curious', 'inquisitive', 'seeking'],negative_feedback = ['apathetic', 'indifferent', 'uninterested'],report = ['the student was curious and inquisitive', 'the student was uninterested', 'the student was apathetic but showed improvement'],student_id = [5001, 5002, 5003],k = 3) == [5001, 5002, 5003]\n assert candidate(positive_feedback = ['leader', 'initiative', 'confidence'],negative_feedback = ['follower', 'shy', 'insecure'],report = ['the student is a leader and takes initiative', 'the student is shy and insecure', 'the student is confident and proactive', 'the student is a follower but eager to learn'],student_id = [6001, 6002, 6003, 6004],k = 1) == [6001]\n assert candidate(positive_feedback = ['innovative', 'creative', 'brilliant'],negative_feedback = ['incompetent', 'lazy', 'unhelpful'],report = ['the student showed innovative thinking', 'incompetent work was submitted', 'lazy performance', 'creative solutions provided'],student_id = [2001, 2002, 2003, 2004],k = 3) == [2001, 2004, 2002]\n assert candidate(positive_feedback = ['disciplined', 'focused', 'organized'],negative_feedback = ['disorganized', 'distracted', 'undisciplined'],report = ['the student is disciplined and organized', 'the student is distracted and disorganized', 'the student is focused but forgetful'],student_id = [1001, 1002, 1003],k = 3) == [1001, 1003, 1002]\n assert candidate(positive_feedback = ['compassionate', 'empathetic', 'sympathetic'],negative_feedback = ['cruel', 'heartless', 'unfeeling'],report = ['the student is compassionate and empathetic', 'the student is cruel and heartless', 'the student is sympathetic but needs rest'],student_id = [666, 667, 668],k = 3) == [666, 668, 667]\n assert candidate(positive_feedback = ['proactive', 'initiative', 'leader'],negative_feedback = ['passive', 'follower', 'inactive'],report = ['the student is proactive', 'the student is passive', 'the student is initiative', 'the student is follower', 'the student is leader', 'the student is inactive'],student_id = [8001, 8002, 8003, 8004, 8005, 8006],k = 3) == [8001, 8003, 8005]\n assert candidate(positive_feedback = ['efficient', 'effective', 'productive'],negative_feedback = ['inefficient', 'lazy', 'slow'],report = ['the student is very efficient', 'the student is lazy and inefficient', 'the student is slow but effective'],student_id = [3001, 3002, 3003],k = 2) == [3001, 3003]\n assert candidate(positive_feedback = ['friendly', 'helpful'],negative_feedback = ['rude', 'mean', 'unkind'],report = ['the student is friendly and helpful', 'the student is unkind', 'the student is mean', 'the student is rude'],student_id = [15, 20, 25, 30],k = 2) == [15, 20]\n assert candidate(positive_feedback = ['ambitious', 'determined', 'persistent'],negative_feedback = ['procrastinator', 'inconsistent', 'lazy'],report = ['the student is ambitious and determined', 'the student is persistent', 'the student is a procrastinator', 'the student is inconsistent', 'the student is lazy but persistent'],student_id = [1001, 1002, 1003, 1004, 1005],k = 4) == [1001, 1002, 1005, 1003]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'slow', 'inconsistent'],report = ['the student is productive', 'the student is focused', 'the student is efficient'],student_id = [10001, 10002, 10003],k = 2) == [10001, 10002]\n assert candidate(positive_feedback = ['innovative', 'creative', 'resourceful'],negative_feedback = ['mediocre', 'unoriginal', 'unresourceful'],report = ['the student is innovative', 'the student is creative and resourceful', 'the student is mediocre', 'the student is unoriginal', 'the student is unresourceful', 'the student is innovative and unresourceful'],student_id = [5001, 5002, 5003, 5004, 5005, 5006],k = 2) == [5002, 5001]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'distraught', 'inefficient'],report = ['the student is efficient', 'the student is unfocused', 'the student is productive', 'the student is distracted'],student_id = [5001, 5002, 5003, 5004],k = 3) == [5001, 5003, 5004]\n assert candidate(positive_feedback = ['proactive', 'ambitious', 'determined'],negative_feedback = ['lazy', 'apathetic', 'indifferent'],report = ['the student is proactive and ambitious', 'the student is lazy and apathetic', 'the student is determined and works hard', 'the student is indifferent but willing to try'],student_id = [4001, 4002, 4003, 4004],k = 3) == [4001, 4003, 4004]\n assert candidate(positive_feedback = ['innovative', 'creative', 'ingenious'],negative_feedback = ['incompetent', 'dull', 'inept'],report = ['the student is incompetent and dull', 'the student is creative and innovative', 'the student is inept but tries hard'],student_id = [150, 151, 152],k = 2) == [151, 152]\n assert candidate(positive_feedback = ['ingenious', 'creative', 'resourceful'],negative_feedback = ['uncreative', 'inefficient', 'unproductive'],report = ['the student is ingenious and creative', 'the student is unproductive', 'the student is resourceful but inefficient'],student_id = [3001, 3002, 3003],k = 1) == [3001]\n assert candidate(positive_feedback = ['diligent', 'persevering', 'tenacious'],negative_feedback = ['lazy', 'indolent', 'procrastinating'],report = ['the student is diligent and persevering', 'the student is indolent', 'the student is tenacious but lazy'],student_id = [7001, 7002, 7003],k = 2) == [7001, 7003]\n assert candidate(positive_feedback = ['hardworking', 'dedicated', 'persistent'],negative_feedback = ['lazy', 'careless', 'unreliable'],report = ['the student is hardworking and dedicated', 'the student is lazy', 'the student is careless', 'the student is unreliable', 'the student is persistent but careless'],student_id = [201, 202, 203, 204, 205],k = 3) == [201, 205, 202]\n assert candidate(positive_feedback = ['motivated', 'driven'],negative_feedback = ['apathetic', 'indifferent'],report = ['the student is motivated', 'the student is driven', 'the student is apathetic', 'the student is indifferent', 'the student is motivated but apathetic', 'the student is driven but indifferent'],student_id = [9001, 9002, 9003, 9004, 9005, 9006],k = 3) == [9001, 9002, 9005]\n assert candidate(positive_feedback = ['smart', 'brilliant', 'studious'],negative_feedback = ['not', 'lazy', 'careless'],report = ['this student is not studious', 'the student is smart', 'the student is lazy but brilliant', 'the student is careless'],student_id = [1, 2, 3, 4],k = 3) == [2, 1, 3]\n assert candidate(positive_feedback = ['outstanding', 'excellent', 'remarkable'],negative_feedback = ['poor', 'bad', 'mediocre'],report = ['the student is outstanding and excellent', 'the student is mediocre', 'the student is poor'],student_id = [1001, 1002, 1003],k = 2) == [1001, 1002]\n assert candidate(positive_feedback = ['cooperative', 'collaborative', 'teamplayer'],negative_feedback = ['uncooperative', 'selfish', 'individualistic'],report = ['the student is cooperative', 'the student is uncooperative', 'the student is collaborative', 'the student is selfish', 'the student is teamplayer', 'the student is individualistic'],student_id = [7001, 7002, 7003, 7004, 7005, 7006],k = 2) == [7001, 7003]\n assert candidate(positive_feedback = ['attentive', 'focused', 'detail-oriented'],negative_feedback = ['distracted', 'careless', 'negligent'],report = ['the student is attentive and focused', 'the student is negligent but eager to learn', 'the student is attentive and detail-oriented but sometimes careless'],student_id = [3001, 3002, 3003],k = 1) == [3001]\n assert candidate(positive_feedback = ['curious', 'knowledgeable', 'inquisitive'],negative_feedback = ['ignorant', 'naive', 'uninformed'],report = ['the student is curious', 'the student is knowledgeable', 'the student is inquisitive', 'the student is ignorant', 'the student is naive', 'the student is uninformed', 'the student is curious and knowledgeable'],student_id = [5001, 5002, 5003, 5004, 5005, 5006, 5007],k = 3) == [5007, 5001, 5002]\n assert candidate(positive_feedback = ['perseverant', 'determined', 'ambitious'],negative_feedback = ['lazy', 'indifferent', 'apathetic'],report = ['the student is perseverant and ambitious', 'the student is lazy', 'the student is indifferent', 'the student is apathetic'],student_id = [4001, 4002, 4003, 4004],k = 1) == [4001]\n assert candidate(positive_feedback = ['outstanding', 'excellent', 'impressive'],negative_feedback = ['poor', 'bad', 'mediocre'],report = ['the student is poor but trying hard', 'the student is excellent and impressive', 'the student is mediocre but not bad'],student_id = [1001, 1002, 1003],k = 2) == [1002, 1001]\n"}, "metadata": {"canonical_parameter_names": ["positive_feedback", "negative_feedback", "report", "student_id", "k"], "leetcode_dataset_entry_point": "Solution().topStudents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List topStudents(String[] positive_feedback, String[] negative_feedback, String[] report, int[] student_id, int k) {", "container": "Solution", "callable": "topStudents", "parameters": [{"name": "positive_feedback", "type": "String[]"}, {"name": "negative_feedback", "type": "String[]"}, {"name": "report", "type": "String[]"}, {"name": "student_id", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2513, "task_id": "minimize-the-maximum-of-two-arrays", "difficulty": "Medium", "problem_description": "We have two arrays arr1 and arr2 which are initially empty. You need to add positive integers to them such that they satisfy all the following conditions:\n\narr1 contains uniqueCnt1 distinct positive integers, each of which is not divisible by divisor1.\narr2 contains uniqueCnt2 distinct positive integers, each of which is not divisible by divisor2.\nNo integer is present in both arr1 and arr2.\n\nGiven divisor1, divisor2, uniqueCnt1, and uniqueCnt2, return the minimum possible maximum integer that can be present in either array.\n \nExample 1:\n\nInput: divisor1 = 2, divisor2 = 7, uniqueCnt1 = 1, uniqueCnt2 = 3\nOutput: 4\nExplanation: \nWe can distribute the first 4 natural numbers into arr1 and arr2.\narr1 = [1] and arr2 = [2,3,4].\nWe can see that both arrays satisfy all the conditions.\nSince the maximum value is 4, we return it.\n\nExample 2:\n\nInput: divisor1 = 3, divisor2 = 5, uniqueCnt1 = 2, uniqueCnt2 = 1\nOutput: 3\nExplanation: \nHere arr1 = [1,2], and arr2 = [3] satisfy all conditions.\nSince the maximum value is 3, we return it.\nExample 3:\n\nInput: divisor1 = 2, divisor2 = 4, uniqueCnt1 = 8, uniqueCnt2 = 2\nOutput: 15\nExplanation: \nHere, the final possible arrays can be arr1 = [1,3,5,7,9,11,13,15], and arr2 = [2,6].\nIt can be shown that it is not possible to obtain a lower maximum satisfying all conditions. \n\n \nConstraints:\n\n2 <= divisor1, divisor2 <= 105\n1 <= uniqueCnt1, uniqueCnt2 < 109\n2 <= uniqueCnt1 + uniqueCnt2 <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(divisor1 = 2,divisor2 = 7,uniqueCnt1 = 1,uniqueCnt2 = 3) == 4\n assert candidate(divisor1 = 2,divisor2 = 4,uniqueCnt1 = 8,uniqueCnt2 = 2) == 15\n assert candidate(divisor1 = 100,divisor2 = 101,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200019803\n assert candidate(divisor1 = 100,divisor2 = 200,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 201005025\n assert candidate(divisor1 = 5,divisor2 = 10,uniqueCnt1 = 5,uniqueCnt2 = 5) == 11\n assert candidate(divisor1 = 7,divisor2 = 11,uniqueCnt1 = 10,uniqueCnt2 = 10) == 20\n assert candidate(divisor1 = 7,divisor2 = 13,uniqueCnt1 = 10,uniqueCnt2 = 10) == 20\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 2,uniqueCnt2 = 1) == 3\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 5,uniqueCnt2 = 6) == 11\n assert candidate(divisor1 = 7,divisor2 = 11,uniqueCnt1 = 3,uniqueCnt2 = 7) == 10\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100454545\n assert candidate(divisor1 = 89,divisor2 = 97,uniqueCnt1 = 60000000,uniqueCnt2 = 40000000) == 100011584\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 20,uniqueCnt2 = 25) == 45\n assert candidate(divisor1 = 23,divisor2 = 29,uniqueCnt1 = 50000000,uniqueCnt2 = 30000000) == 80120120\n assert candidate(divisor1 = 13,divisor2 = 19,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200813008\n assert candidate(divisor1 = 2,divisor2 = 3,uniqueCnt1 = 999999999,uniqueCnt2 = 1) == 1999999997\n assert candidate(divisor1 = 100000,divisor2 = 10000,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100001000\n assert candidate(divisor1 = 100000,divisor2 = 200000,uniqueCnt1 = 1000000,uniqueCnt2 = 500000) == 1500007\n assert candidate(divisor1 = 30,divisor2 = 42,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100478468\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 10000000,uniqueCnt2 = 20000000) == 30136363\n assert candidate(divisor1 = 45,divisor2 = 18,uniqueCnt1 = 200000000,uniqueCnt2 = 300000000) == 505617977\n assert candidate(divisor1 = 5,divisor2 = 7,uniqueCnt1 = 1,uniqueCnt2 = 999999999) == 1166666665\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 250000000,uniqueCnt2 = 250000000) == 502272727\n assert candidate(divisor1 = 61,divisor2 = 71,uniqueCnt1 = 70000000,uniqueCnt2 = 30000000) == 100023094\n assert candidate(divisor1 = 12,divisor2 = 18,uniqueCnt1 = 1000,uniqueCnt2 = 1000) == 2057\n assert candidate(divisor1 = 2,divisor2 = 5,uniqueCnt1 = 500000000,uniqueCnt2 = 499999999) == 1111111109\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 5,uniqueCnt2 = 8) == 14\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 300000000,uniqueCnt2 = 200000000) == 545454545\n assert candidate(divisor1 = 10000,divisor2 = 20000,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100005000\n assert candidate(divisor1 = 8,divisor2 = 12,uniqueCnt1 = 40000000,uniqueCnt2 = 60000000) == 104347826\n assert candidate(divisor1 = 99999,divisor2 = 99998,uniqueCnt1 = 100000,uniqueCnt2 = 100000) == 200000\n assert candidate(divisor1 = 50000,divisor2 = 100000,uniqueCnt1 = 10000000,uniqueCnt2 = 10000000) == 20000200\n assert candidate(divisor1 = 29,divisor2 = 41,uniqueCnt1 = 60000000,uniqueCnt2 = 40000000) == 100084175\n assert candidate(divisor1 = 15,divisor2 = 20,uniqueCnt1 = 75000000,uniqueCnt2 = 25000000) == 101694915\n assert candidate(divisor1 = 19,divisor2 = 23,uniqueCnt1 = 150000000,uniqueCnt2 = 150000000) == 300688073\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 107142857\n assert candidate(divisor1 = 50000,divisor2 = 75000,uniqueCnt1 = 60000000,uniqueCnt2 = 40000000) == 100000666\n assert candidate(divisor1 = 20,divisor2 = 30,uniqueCnt1 = 500000000,uniqueCnt2 = 400000000) == 915254237\n assert candidate(divisor1 = 6,divisor2 = 8,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 104347826\n assert candidate(divisor1 = 100000,divisor2 = 50000,uniqueCnt1 = 50000000,uniqueCnt2 = 40000000) == 90000900\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 75000000,uniqueCnt2 = 25000000) == 103448275\n assert candidate(divisor1 = 100000,divisor2 = 100000,uniqueCnt1 = 450000000,uniqueCnt2 = 450000000) == 900009000\n assert candidate(divisor1 = 7,divisor2 = 14,uniqueCnt1 = 900000000,uniqueCnt2 = 900000000) == 1938461538\n assert candidate(divisor1 = 23,divisor2 = 37,uniqueCnt1 = 50000000,uniqueCnt2 = 49999999) == 100117646\n assert candidate(divisor1 = 99999,divisor2 = 100001,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100000000\n assert candidate(divisor1 = 23,divisor2 = 37,uniqueCnt1 = 45000000,uniqueCnt2 = 55000000) == 100117647\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 100,uniqueCnt2 = 150) == 251\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 214285714\n assert candidate(divisor1 = 1000,divisor2 = 500,uniqueCnt1 = 40000000,uniqueCnt2 = 60000000) == 100100100\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 100000000,uniqueCnt2 = 99999999) == 218181817\n assert candidate(divisor1 = 5,divisor2 = 7,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 102941176\n assert candidate(divisor1 = 17,divisor2 = 31,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 106249998\n assert candidate(divisor1 = 99998,divisor2 = 99999,uniqueCnt1 = 100000,uniqueCnt2 = 100000) == 200000\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 100000000,uniqueCnt2 = 1) == 111111111\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 218181818\n assert candidate(divisor1 = 6,divisor2 = 8,uniqueCnt1 = 75000000,uniqueCnt2 = 25000000) == 104347826\n assert candidate(divisor1 = 77,divisor2 = 42,uniqueCnt1 = 500,uniqueCnt2 = 500) == 1002\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 20000000,uniqueCnt2 = 15000000) == 35246478\n assert candidate(divisor1 = 7,divisor2 = 14,uniqueCnt1 = 25000000,uniqueCnt2 = 25000000) == 53846153\n assert candidate(divisor1 = 15,divisor2 = 25,uniqueCnt1 = 80000000,uniqueCnt2 = 70000000) == 152027027\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 99999999,uniqueCnt2 = 99999999) == 201408448\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 100,uniqueCnt2 = 200) == 321\n assert candidate(divisor1 = 25,divisor2 = 40,uniqueCnt1 = 100,uniqueCnt2 = 150) == 251\n assert candidate(divisor1 = 100001,divisor2 = 100003,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200000000\n assert candidate(divisor1 = 6,divisor2 = 9,uniqueCnt1 = 15,uniqueCnt2 = 20) == 37\n assert candidate(divisor1 = 6,divisor2 = 9,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 105882352\n assert candidate(divisor1 = 23,divisor2 = 31,uniqueCnt1 = 200000000,uniqueCnt2 = 300000000) == 500702247\n assert candidate(divisor1 = 5,divisor2 = 6,uniqueCnt1 = 1000000,uniqueCnt2 = 500000) == 1551724\n assert candidate(divisor1 = 67,divisor2 = 89,uniqueCnt1 = 400000000,uniqueCnt2 = 400000000) == 800134183\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 200000000,uniqueCnt2 = 1) == 219999999\n assert candidate(divisor1 = 37,divisor2 = 41,uniqueCnt1 = 9876543,uniqueCnt2 = 1234567) == 11118439\n assert candidate(divisor1 = 7,divisor2 = 13,uniqueCnt1 = 300000000,uniqueCnt2 = 300000000) == 606666666\n assert candidate(divisor1 = 5,divisor2 = 7,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 124999998\n assert candidate(divisor1 = 97,divisor2 = 101,uniqueCnt1 = 1000000,uniqueCnt2 = 500000) == 1500153\n assert candidate(divisor1 = 10000,divisor2 = 100000,uniqueCnt1 = 90000000,uniqueCnt2 = 10000000) == 100001000\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 5,uniqueCnt2 = 10) == 15\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 100000000,uniqueCnt2 = 200000000) == 310344827\n assert candidate(divisor1 = 100000,divisor2 = 200000,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100000500\n assert candidate(divisor1 = 77,divisor2 = 42,uniqueCnt1 = 33000000,uniqueCnt2 = 66000000) == 99214750\n assert candidate(divisor1 = 6,divisor2 = 8,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 119999998\n assert candidate(divisor1 = 5,divisor2 = 10,uniqueCnt1 = 50,uniqueCnt2 = 50) == 111\n assert candidate(divisor1 = 101,divisor2 = 103,uniqueCnt1 = 1000000,uniqueCnt2 = 1000000) == 2000192\n assert candidate(divisor1 = 23,divisor2 = 31,uniqueCnt1 = 50000000,uniqueCnt2 = 30000000) == 80112359\n assert candidate(divisor1 = 11,divisor2 = 22,uniqueCnt1 = 100000000,uniqueCnt2 = 1) == 109999999\n assert candidate(divisor1 = 11,divisor2 = 22,uniqueCnt1 = 300000000,uniqueCnt2 = 300000000) == 628571428\n assert candidate(divisor1 = 23,divisor2 = 29,uniqueCnt1 = 100000,uniqueCnt2 = 100000) == 200300\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 100000000,uniqueCnt2 = 50000000) == 160714285\n assert candidate(divisor1 = 5,divisor2 = 3,uniqueCnt1 = 100,uniqueCnt2 = 150) == 267\n assert candidate(divisor1 = 7,divisor2 = 11,uniqueCnt1 = 10000000,uniqueCnt2 = 10000000) == 20263157\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 250000000,uniqueCnt2 = 250000000) == 545454545\n assert candidate(divisor1 = 8,divisor2 = 9,uniqueCnt1 = 2000000,uniqueCnt2 = 3000000) == 5070422\n assert candidate(divisor1 = 100000,divisor2 = 99999,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200000000\n assert candidate(divisor1 = 10,divisor2 = 25,uniqueCnt1 = 50000000,uniqueCnt2 = 100000000) == 153061224\n assert candidate(divisor1 = 5,divisor2 = 15,uniqueCnt1 = 100000000,uniqueCnt2 = 50000000) == 160714285\n assert candidate(divisor1 = 5,divisor2 = 10,uniqueCnt1 = 50000000,uniqueCnt2 = 49999999) == 111111109\n assert candidate(divisor1 = 100000,divisor2 = 200000,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200001000\n assert candidate(divisor1 = 100000,divisor2 = 200000,uniqueCnt1 = 100000000,uniqueCnt2 = 50000000) == 150000750\n assert candidate(divisor1 = 2,divisor2 = 3,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 239999999\n assert candidate(divisor1 = 2,divisor2 = 4,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 199999997\n assert candidate(divisor1 = 17,divisor2 = 29,uniqueCnt1 = 150000000,uniqueCnt2 = 150000000) == 300609756\n assert candidate(divisor1 = 9,divisor2 = 12,uniqueCnt1 = 250000000,uniqueCnt2 = 250000000) == 514285714\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 300000000,uniqueCnt2 = 200000000) == 502272727\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 500000000,uniqueCnt2 = 400000000) == 964285714\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200909090\n assert candidate(divisor1 = 71,divisor2 = 73,uniqueCnt1 = 10000000,uniqueCnt2 = 10000000) == 20003859\n assert candidate(divisor1 = 99,divisor2 = 101,uniqueCnt1 = 200000000,uniqueCnt2 = 300000000) == 500050010\n assert candidate(divisor1 = 3,divisor2 = 6,uniqueCnt1 = 100,uniqueCnt2 = 200) == 359\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 80000000,uniqueCnt2 = 20000000) == 103448275\n"}, "metadata": {"canonical_parameter_names": ["divisor1", "divisor2", "uniqueCnt1", "uniqueCnt2"], "leetcode_dataset_entry_point": "Solution().minimizeSet", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimizeSet(int divisor1, int divisor2, int uniqueCnt1, int uniqueCnt2) {", "container": "Solution", "callable": "minimizeSet", "parameters": [{"name": "divisor1", "type": "int"}, {"name": "divisor2", "type": "int"}, {"name": "uniqueCnt1", "type": "int"}, {"name": "uniqueCnt2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2515, "task_id": "shortest-distance-to-target-string-in-a-circular-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed circular string array words and a string target. A circular array means that the array's end connects to the array's beginning.\n\nFormally, the next element of words[i] is words[(i + 1) % n] and the previous element of words[i] is words[(i - 1 + n) % n], where n is the length of words.\n\nStarting from startIndex, you can move to either the next word or the previous word with 1 step at a time.\nReturn the shortest distance needed to reach the string target. If the string target does not exist in words, return -1.\n \nExample 1:\n\nInput: words = [\"hello\",\"i\",\"am\",\"leetcode\",\"hello\"], target = \"hello\", startIndex = 1\nOutput: 1\nExplanation: We start from index 1 and can reach \"hello\" by\n- moving 3 units to the right to reach index 4.\n- moving 2 units to the left to reach index 4.\n- moving 4 units to the right to reach index 0.\n- moving 1 unit to the left to reach index 0.\nThe shortest distance to reach \"hello\" is 1.\n\nExample 2:\n\nInput: words = [\"a\",\"b\",\"leetcode\"], target = \"leetcode\", startIndex = 0\nOutput: 1\nExplanation: We start from index 0 and can reach \"leetcode\" by\n- moving 2 units to the right to reach index 3.\n- moving 1 unit to the left to reach index 3.\nThe shortest distance to reach \"leetcode\" is 1.\nExample 3:\n\nInput: words = [\"i\",\"eat\",\"leetcode\"], target = \"ate\", startIndex = 0\nOutput: -1\nExplanation: Since \"ate\" does not exist in words, we return -1.\n\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 100\nwords[i] and target consist of only lowercase English letters.\n0 <= startIndex < words.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'def', 'ghi'],target = \"xyz\",startIndex = 1) == -1\n assert candidate(words = ['apple', 'banana', 'cherry', 'date'],target = \"banana\",startIndex = 2) == 1\n assert candidate(words = ['cat', 'dog', 'bird', 'fish'],target = \"cat\",startIndex = 3) == 1\n assert candidate(words = ['dog', 'cat', 'bat'],target = \"dog\",startIndex = 2) == 1\n assert candidate(words = ['hello', 'i', 'am', 'leetcode', 'hello'],target = \"hello\",startIndex = 1) == 1\n assert candidate(words = ['a', 'a', 'a', 'a'],target = \"a\",startIndex = 0) == 0\n assert candidate(words = ['a', 'b', 'c', 'd'],target = \"a\",startIndex = 3) == 1\n assert candidate(words = ['a', 'b', 'leetcode'],target = \"leetcode\",startIndex = 0) == 1\n assert candidate(words = ['dog', 'cat', 'bat'],target = \"rat\",startIndex = 1) == -1\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"one\",startIndex = 3) == 1\n assert candidate(words = ['red', 'blue', 'green'],target = \"yellow\",startIndex = 1) == -1\n assert candidate(words = ['i', 'eat', 'leetcode'],target = \"ate\",startIndex = 0) == -1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"five\",startIndex = 3) == 1\n assert candidate(words = ['apple', 'banana', 'cherry'],target = \"banana\",startIndex = 2) == 1\n assert candidate(words = ['z', 'y', 'x', 'w', 'v'],target = \"v\",startIndex = 4) == 0\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"five\",startIndex = 0) == 1\n assert candidate(words = ['red', 'blue', 'green'],target = \"green\",startIndex = 1) == 1\n assert candidate(words = ['abc', 'def', 'ghi'],target = \"def\",startIndex = 1) == 0\n assert candidate(words = ['red', 'blue', 'green'],target = \"blue\",startIndex = 1) == 0\n assert candidate(words = ['a', 'a', 'a', 'a'],target = \"b\",startIndex = 0) == -1\n assert candidate(words = ['a', 'a', 'a', 'a', 'a'],target = \"a\",startIndex = 2) == 0\n assert candidate(words = ['dog', 'cat', 'bird'],target = \"fish\",startIndex = 1) == -1\n assert candidate(words = ['sun', 'moon', 'star'],target = \"planet\",startIndex = 1) == -1\n assert candidate(words = ['a', 'b', 'c', 'd'],target = \"d\",startIndex = 2) == 1\n assert candidate(words = ['a', 'b', 'c', 'd'],target = \"b\",startIndex = 2) == 1\n assert candidate(words = ['rotate', 'me', 'around', 'and', 'around', 'again', 'rotate'],target = \"around\",startIndex = 0) == 2\n assert candidate(words = ['x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g'],target = \"d\",startIndex = 0) == 4\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"five\",startIndex = 0) == 4\n assert candidate(words = ['zebra', 'yak', 'xylophone', 'wolf', 'vulture'],target = \"wolf\",startIndex = 1) == 2\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"mno\",startIndex = 0) == 4\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],target = \"e\",startIndex = 8) == 4\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'galaxy'],target = \"galaxy\",startIndex = 3) == 3\n assert candidate(words = ['same', 'words', 'here', 'are', 'same', 'words'],target = \"words\",startIndex = 2) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"seven\",startIndex = 4) == 2\n assert candidate(words = ['hello', 'world', 'hello', 'world', 'hello', 'world'],target = \"hello\",startIndex = 4) == 0\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"date\",startIndex = 0) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"mno\",startIndex = 6) == 2\n assert candidate(words = ['repeat', 'this', 'sentence', 'repeat', 'this', 'sentence'],target = \"sentence\",startIndex = 3) == 1\n assert candidate(words = ['search', 'for', 'this', 'word', 'in', 'this', 'circular', 'array'],target = \"this\",startIndex = 4) == 1\n assert candidate(words = ['single'],target = \"single\",startIndex = 0) == 0\n assert candidate(words = ['car', 'bus', 'bike', 'train', 'truck', 'van'],target = \"van\",startIndex = 3) == 2\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'red', 'blue', 'green', 'yellow'],target = \"yellow\",startIndex = 2) == 1\n assert candidate(words = ['unique', 'words', 'only', 'here'],target = \"only\",startIndex = 1) == 1\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink'],target = \"purple\",startIndex = 1) == 3\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"one\",startIndex = 9) == 1\n assert candidate(words = ['water', 'fire', 'earth', 'air', 'ice', 'steam', 'cloud'],target = \"cloud\",startIndex = 3) == 3\n assert candidate(words = ['hello', 'world', 'python', 'code', 'challenge'],target = \"python\",startIndex = 3) == 1\n assert candidate(words = ['algorithm', 'data', 'structures', 'algorithm', 'data'],target = \"structures\",startIndex = 0) == 2\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"five\",startIndex = 8) == 4\n assert candidate(words = ['python', 'java', 'c', 'cpp', 'ruby', 'swift', 'go'],target = \"cpp\",startIndex = 5) == 2\n assert candidate(words = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],target = \"y\",startIndex = 5) == 1\n assert candidate(words = ['dog', 'cat', 'mouse', 'rat', 'elephant', 'giraffe', 'hippo'],target = \"elephant\",startIndex = 2) == 2\n assert candidate(words = ['orange', 'peach', 'plum', 'grape', 'kiwi'],target = \"peach\",startIndex = 3) == 2\n assert candidate(words = ['last', 'element', 'is', 'the', 'target'],target = \"target\",startIndex = 3) == 1\n assert candidate(words = ['cat', 'dog', 'fish', 'bird', 'elephant', 'antelope', 'hippo'],target = \"hippo\",startIndex = 2) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"vwx\",startIndex = 4) == 3\n assert candidate(words = ['loop', 'around', 'this', 'circular', 'array'],target = \"array\",startIndex = 1) == 2\n assert candidate(words = ['circular', 'array', 'test', 'case', 'example', 'circular'],target = \"example\",startIndex = 4) == 0\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't'],target = \"p\",startIndex = 15) == 0\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"seven\",startIndex = 7) == 1\n assert candidate(words = ['a', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'],target = \"lazy\",startIndex = 3) == 4\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa'],target = \"aaaaaa\",startIndex = 1) == 4\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"ten\",startIndex = 2) == 3\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy', 'universe', 'comet'],target = \"moon\",startIndex = 4) == 3\n assert candidate(words = ['python', 'java', 'c', 'c++', 'javascript', 'go', 'ruby'],target = \"ruby\",startIndex = 3) == 3\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'hello', 'world'],target = \"programming\",startIndex = 4) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"two\",startIndex = 8) == 3\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'is', 'fun'],target = \"programming\",startIndex = 2) == 1\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy', 'universe', 'sun', 'moon'],target = \"galaxy\",startIndex = 6) == 2\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'purple', 'orange', 'pink'],target = \"pink\",startIndex = 6) == 0\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'hello'],target = \"programming\",startIndex = 2) == 1\n assert candidate(words = ['mango', 'banana', 'mango', 'banana', 'mango'],target = \"banana\",startIndex = 0) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"four\",startIndex = 7) == 4\n assert candidate(words = ['hello', 'world', 'this', 'is', 'a', 'circular', 'array'],target = \"is\",startIndex = 5) == 2\n assert candidate(words = ['ocean', 'lake', 'river', 'pond', 'creek', 'stream', 'flood', 'bay', 'harbor', 'gulf'],target = \"stream\",startIndex = 5) == 0\n assert candidate(words = ['dog', 'cat', 'bird', 'fish', 'dog', 'cat', 'bird', 'fish'],target = \"fish\",startIndex = 7) == 0\n assert candidate(words = ['banana', 'apple', 'orange', 'grape', 'banana', 'apple', 'orange', 'grape'],target = \"orange\",startIndex = 5) == 1\n assert candidate(words = ['longwordthatwillnotmatch', 'anotherlongword', 'yetanotherlongword', 'stillanotherlongword'],target = \"nonexistent\",startIndex = 1) == -1\n assert candidate(words = ['algorithm', 'data', 'structure', 'algorithm', 'data', 'structure'],target = \"structure\",startIndex = 2) == 0\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven'],target = \"four\",startIndex = 6) == 3\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy'],target = \"galaxy\",startIndex = 2) == 2\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'purple', 'orange'],target = \"blue\",startIndex = 5) == 2\n assert candidate(words = ['x', 'y', 'z', 'a', 'b', 'c', 'd', 'e'],target = \"d\",startIndex = 7) == 1\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa'],target = \"delta\",startIndex = 8) == 5\n assert candidate(words = ['x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g'],target = \"d\",startIndex = 9) == 3\n assert candidate(words = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],target = \"y\",startIndex = 4) == 0\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"date\",startIndex = 5) == 2\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"banana\",startIndex = 6) == 2\n assert candidate(words = ['find', 'the', 'shortest', 'distance', 'in', 'a', 'circular', 'array'],target = \"distance\",startIndex = 5) == 2\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"banana\",startIndex = 5) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"mno\",startIndex = 5) == 1\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'code', 'hello'],target = \"code\",startIndex = 3) == 1\n assert candidate(words = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply', 'waldo', 'fred', 'plugh', 'xyzzy', 'thud'],target = \"garply\",startIndex = 10) == 3\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"banana\",startIndex = 4) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"mno\",startIndex = 7) == 3\n assert candidate(words = ['aardvark', 'anteater', 'armadillo', 'baboon', 'badger', 'bat', 'bear', 'beaver', 'bison', 'boar'],target = \"badger\",startIndex = 9) == 5\n assert candidate(words = ['cat', 'dog', 'fish', 'bird', 'ant'],target = \"ant\",startIndex = 2) == 2\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat'],target = \"repeat\",startIndex = 5) == 0\n assert candidate(words = ['red', 'green', 'blue', 'yellow', 'orange', 'purple'],target = \"green\",startIndex = 5) == 2\n assert candidate(words = ['algorithm', 'data', 'structures', 'algorithm', 'data', 'structures'],target = \"data\",startIndex = 3) == 1\n assert candidate(words = ['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'],target = \"m\",startIndex = 10) == 5\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj'],target = \"jjj\",startIndex = 9) == 0\n assert candidate(words = ['longerword', 'stringexample', 'anotherexample', 'yetanother', 'finalword'],target = \"anotherexample\",startIndex = 1) == 1\n assert candidate(words = ['complex', 'circular', 'array', 'problem', 'solution'],target = \"complex\",startIndex = 3) == 2\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"vwx\",startIndex = 8) == 1\n assert candidate(words = ['loop', 'circle', 'ring', 'cycle', 'wheel', 'orbit', 'oval'],target = \"oval\",startIndex = 3) == 3\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"grape\",startIndex = 1) == 2\n assert candidate(words = ['repeated', 'words', 'are', 'repeated', 'here', 'repeated'],target = \"repeated\",startIndex = 2) == 1\n assert candidate(words = ['hello', 'world', 'hello', 'python', 'world'],target = \"python\",startIndex = 2) == 1\n assert candidate(words = ['leetcode', 'problem', 'solving', 'leetcode', 'problem'],target = \"solving\",startIndex = 4) == 2\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'],target = \"z\",startIndex = 0) == 1\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy', 'universe'],target = \"planet\",startIndex = 0) == 3\n assert candidate(words = ['zebra', 'yak', 'xylophone', 'wolf', 'unicorn', 'tiger', 'snake'],target = \"yak\",startIndex = 6) == 2\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"seven\",startIndex = 1) == 5\n assert candidate(words = ['cat', 'dog', 'fish', 'bird', 'elephant', 'tiger', 'lion', 'bear'],target = \"fish\",startIndex = 6) == 4\n assert candidate(words = ['circular', 'array', 'example', 'circular'],target = \"example\",startIndex = 2) == 0\n assert candidate(words = ['hello', 'world', 'leetcode', 'python', 'hello'],target = \"python\",startIndex = 0) == 2\n assert candidate(words = ['car', 'bike', 'truck', 'motorcycle', 'bus', 'train', 'boat', 'plane'],target = \"plane\",startIndex = 6) == 1\n assert candidate(words = ['unique', 'words', 'here', 'only', 'once'],target = \"once\",startIndex = 2) == 2\n assert candidate(words = ['coding', 'is', 'fun', 'coding', 'is', 'great'],target = \"great\",startIndex = 3) == 2\n assert candidate(words = ['find', 'me', 'if', 'you', 'can'],target = \"can\",startIndex = 3) == 1\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"vwx\",startIndex = 5) == 2\n assert candidate(words = ['abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij'],target = \"abcdefghij\",startIndex = 5) == 1\n assert candidate(words = ['repeat', 'this', 'is', 'a', 'test', 'repeat'],target = \"test\",startIndex = 4) == 0\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"planet\",startIndex = 0) == 1\n assert candidate(words = ['sun', 'moon', 'star'],target = \"planet\",startIndex = 0) == -1\n assert candidate(words = ['sun', 'moon', 'star', 'sky'],target = \"star\",startIndex = 3) == 1\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"planet\",startIndex = 2) == 1\n assert candidate(words = ['find', 'me', 'in', 'the', 'list'],target = \"list\",startIndex = 0) == 1\n assert candidate(words = ['flower', 'grass', 'tree', 'bush'],target = \"bush\",startIndex = 2) == 1\n assert candidate(words = ['xyz', 'uvw', 'rst', 'qpo'],target = \"rst\",startIndex = 3) == 1\n assert candidate(words = ['unique', 'words', 'here'],target = \"words\",startIndex = 1) == 0\n assert candidate(words = ['aaa', 'bbb', 'ccc'],target = \"aaa\",startIndex = 1) == 1\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl'],target = \"def\",startIndex = 3) == 2\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"two\",startIndex = 4) == 2\n assert candidate(words = ['up', 'down', 'left', 'right'],target = \"up\",startIndex = 1) == 1\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'],target = \"beta\",startIndex = 3) == 2\n assert candidate(words = ['dog', 'cat', 'mouse'],target = \"elephant\",startIndex = 1) == -1\n assert candidate(words = ['foo', 'bar', 'baz'],target = \"foo\",startIndex = 1) == 1\n assert candidate(words = ['dog', 'cat', 'bat'],target = \"mouse\",startIndex = 1) == -1\n assert candidate(words = ['sun', 'moon', 'star', 'sky'],target = \"moon\",startIndex = 3) == 2\n assert candidate(words = ['coding', 'is', 'fun', 'coding'],target = \"fun\",startIndex = 1) == 1\n assert candidate(words = ['zebra', 'giraffe', 'elephant'],target = \"hippo\",startIndex = 1) == -1\n assert candidate(words = ['red', 'blue', 'green', 'red'],target = \"red\",startIndex = 3) == 0\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"three\",startIndex = 0) == 2\n assert candidate(words = ['cat', 'dog', 'bird'],target = \"dog\",startIndex = 2) == 1\n assert candidate(words = ['cup', 'bottle', 'spoon', 'knife', 'cup'],target = \"spoon\",startIndex = 4) == 2\n assert candidate(words = ['dog', 'cat', 'bird', 'fish'],target = \"elephant\",startIndex = 1) == -1\n assert candidate(words = ['unique'],target = \"unique\",startIndex = 0) == 0\n assert candidate(words = ['hello', 'world', 'hello'],target = \"world\",startIndex = 2) == 1\n assert candidate(words = ['car', 'bike', 'bus', 'train', 'boat'],target = \"plane\",startIndex = 1) == -1\n assert candidate(words = ['red', 'green', 'blue', 'yellow'],target = \"blue\",startIndex = 1) == 1\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],target = \"blue\",startIndex = 0) == 1\n assert candidate(words = ['one', 'two', 'three'],target = \"four\",startIndex = 1) == -1\n assert candidate(words = ['python', 'java', 'c', 'c++', 'ruby'],target = \"java\",startIndex = 2) == 1\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],target = \"blue\",startIndex = 2) == 1\n assert candidate(words = ['xyz', 'uvw', 'rst', 'qpo'],target = \"qpo\",startIndex = 3) == 0\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"planet\",startIndex = 1) == 2\n assert candidate(words = ['python', 'java', 'c++', 'ruby'],target = \"python\",startIndex = 3) == 1\n assert candidate(words = ['fast', 'slow', 'quick'],target = \"quick\",startIndex = 1) == 1\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl'],target = \"abc\",startIndex = 3) == 1\n assert candidate(words = ['start', 'middle', 'end'],target = \"end\",startIndex = 0) == 1\n assert candidate(words = ['sun', 'moon', 'star'],target = \"planet\",startIndex = 2) == -1\n assert candidate(words = ['loop', 'start', 'end', 'loop'],target = \"loop\",startIndex = 2) == 1\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'purple'],target = \"green\",startIndex = 4) == 2\n assert candidate(words = ['car', 'bus', 'train', 'plane'],target = \"train\",startIndex = 3) == 1\n assert candidate(words = ['red', 'green', 'blue', 'yellow', 'black'],target = \"red\",startIndex = 4) == 1\n assert candidate(words = ['house', 'car', 'tree', 'road', 'house'],target = \"road\",startIndex = 0) == 2\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"six\",startIndex = 0) == -1\n assert candidate(words = ['zebra', 'giraffe', 'elephant', 'lion'],target = \"elephant\",startIndex = 1) == 1\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"three\",startIndex = 3) == 1\n assert candidate(words = ['car', 'bus', 'train'],target = \"train\",startIndex = 2) == 0\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"one\",startIndex = 2) == 2\n assert candidate(words = ['car', 'bike', 'train', 'bus'],target = \"bike\",startIndex = 3) == 2\n assert candidate(words = ['sun', 'moon', 'star'],target = \"star\",startIndex = 1) == 1\n assert candidate(words = ['search', 'this', 'array', 'for', 'target'],target = \"target\",startIndex = 2) == 2\n assert candidate(words = ['foo', 'bar', 'baz'],target = \"foo\",startIndex = 2) == 1\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],target = \"a\",startIndex = 4) == 1\n assert candidate(words = ['start', 'middle', 'end'],target = \"start\",startIndex = 2) == 1\n assert candidate(words = ['house', 'building', 'apartment'],target = \"house\",startIndex = 1) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"one\",startIndex = 3) == 2\n assert candidate(words = ['up', 'down', 'left', 'right'],target = \"left\",startIndex = 3) == 1\n assert candidate(words = ['dog', 'cat', 'bird', 'fish'],target = \"dog\",startIndex = 3) == 1\n assert candidate(words = ['dog', 'cat', 'bat', 'rat'],target = \"rat\",startIndex = 3) == 0\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"three\",startIndex = 3) == 1\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl'],target = \"def\",startIndex = 2) == 1\n assert candidate(words = ['dog', 'cat', 'bird', 'fish'],target = \"fish\",startIndex = 3) == 0\n assert candidate(words = ['hello', 'world', 'hello'],target = \"world\",startIndex = 0) == 1\n assert candidate(words = ['coding', 'is', 'fun'],target = \"fun\",startIndex = 2) == 0\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"five\",startIndex = 2) == -1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six'],target = \"three\",startIndex = 0) == 2\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"four\",startIndex = 0) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"one\",startIndex = 2) == 2\n assert candidate(words = ['dog', 'cat', 'bat', 'rat'],target = \"bat\",startIndex = 3) == 1\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"moon\",startIndex = 0) == 1\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'repeat'],target = \"repeat\",startIndex = 2) == 0\n assert candidate(words = ['unique', 'words', 'only', 'here'],target = \"only\",startIndex = 0) == 2\n assert candidate(words = ['dog', 'cat', 'bat'],target = \"bat\",startIndex = 1) == 1\n assert candidate(words = ['sun', 'moon', 'star', 'sky'],target = \"moon\",startIndex = 0) == 1\n assert candidate(words = ['python', 'java', 'c++'],target = \"ruby\",startIndex = 1) == -1\n assert candidate(words = ['cat', 'dog', 'bird', 'fish'],target = \"dog\",startIndex = 2) == 1\n assert candidate(words = ['sun', 'moon', 'star'],target = \"moon\",startIndex = 2) == 1\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],target = \"green\",startIndex = 0) == 2\n assert candidate(words = ['apple', 'banana', 'cherry', 'date'],target = \"banana\",startIndex = 3) == 2\n assert candidate(words = ['car', 'bike', 'train'],target = \"bus\",startIndex = 1) == -1\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy'],target = \"star\",startIndex = 3) == 1\n assert candidate(words = ['red', 'blue', 'green', 'red'],target = \"blue\",startIndex = 2) == 1\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry'],target = \"banana\",startIndex = 3) == 2\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"five\",startIndex = 0) == -1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"three\",startIndex = 0) == 2\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry'],target = \"banana\",startIndex = 2) == 1\n assert candidate(words = ['test', 'case', 'test'],target = \"test\",startIndex = 2) == 0\n assert candidate(words = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge'],target = \"qux\",startIndex = 5) == 2\n assert candidate(words = ['hello', 'hello', 'hello'],target = \"hello\",startIndex = 1) == 0\n assert candidate(words = ['a', 'a', 'a', 'a'],target = \"a\",startIndex = 2) == 0\n assert candidate(words = ['red', 'blue', 'green'],target = \"blue\",startIndex = 0) == 1\n assert candidate(words = ['left', 'right', 'up', 'down'],target = \"up\",startIndex = 1) == 1\n assert candidate(words = ['zebra', 'yak', 'antelope'],target = \"antelope\",startIndex = 1) == 1\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],target = \"d\",startIndex = 2) == 1\n assert candidate(words = ['cat', 'dog', 'elephant', 'cat'],target = \"elephant\",startIndex = 1) == 1\n assert candidate(words = ['repeat', 'repeat', 'repeat'],target = \"repeat\",startIndex = 2) == 0\n assert candidate(words = ['north', 'south', 'east', 'west'],target = \"north\",startIndex = 3) == 1\n assert candidate(words = ['zebra', 'elephant', 'tiger', 'lion', 'giraffe'],target = \"tiger\",startIndex = 4) == 2\n assert candidate(words = ['loop', 'around', 'the', 'circular', 'array'],target = \"around\",startIndex = 2) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"six\",startIndex = 2) == -1\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"planet\",startIndex = 3) == 0\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"one\",startIndex = 4) == 1\n assert candidate(words = ['test', 'case', 'test'],target = \"test\",startIndex = 1) == 1\n assert candidate(words = ['up', 'down', 'left', 'right'],target = \"up\",startIndex = 3) == 1\n assert candidate(words = ['unique', 'words', 'only', 'here'],target = \"words\",startIndex = 3) == 2\n assert candidate(words = ['repeat', 'repeat', 'repeat'],target = \"repeat\",startIndex = 1) == 0\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta'],target = \"gamma\",startIndex = 2) == 0\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"star\",startIndex = 3) == 1\n assert candidate(words = ['left', 'right', 'up', 'down'],target = \"up\",startIndex = 3) == 1\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"four\",startIndex = 3) == 0\n assert candidate(words = ['z', 'y', 'x', 'w', 'v'],target = \"x\",startIndex = 4) == 2\n assert candidate(words = ['a', 'a', 'a', 'a', 'a'],target = \"b\",startIndex = 0) == -1\n assert candidate(words = ['red', 'green', 'blue'],target = \"blue\",startIndex = 1) == 1\n assert candidate(words = ['search', 'for', 'the', 'target'],target = \"search\",startIndex = 3) == 1\n assert candidate(words = ['car', 'bus', 'train'],target = \"train\",startIndex = 1) == 1\n assert candidate(words = ['happy', 'sad', 'mad'],target = \"mad\",startIndex = 0) == 1\n assert candidate(words = ['dog', 'cat', 'bird', 'fish', 'dog'],target = \"fish\",startIndex = 0) == 2\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno'],target = \"ghi\",startIndex = 3) == 1\n assert candidate(words = ['red', 'blue', 'green'],target = \"blue\",startIndex = 2) == 1\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'],target = \"zeta\",startIndex = 2) == -1\n assert candidate(words = ['repeat', 'repeat', 'repeat'],target = \"repeat\",startIndex = 0) == 0\n assert candidate(words = ['python', 'java', 'c', 'c++'],target = \"java\",startIndex = 2) == 1\n"}, "metadata": {"canonical_parameter_names": ["words", "target", "startIndex"], "leetcode_dataset_entry_point": "Solution().closestTarget", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int closestTarget(String[] words, String target, int startIndex) {", "container": "Solution", "callable": "closestTarget", "parameters": [{"name": "words", "type": "String[]"}, {"name": "target", "type": "String"}, {"name": "startIndex", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2516, "task_id": "take-k-of-each-character-from-left-and-right", "difficulty": "Medium", "problem_description": "You are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k. Each minute, you may take either the leftmost character of s, or the rightmost character of s.\nReturn the minimum number of minutes needed for you to take at least k of each character, or return -1 if it is not possible to take k of each character.\n \nExample 1:\n\nInput: s = \"aabaaaacaabc\", k = 2\nOutput: 8\nExplanation: \nTake three characters from the left of s. You now have two 'a' characters, and one 'b' character.\nTake five characters from the right of s. You now have four 'a' characters, two 'b' characters, and two 'c' characters.\nA total of 3 + 5 = 8 minutes is needed.\nIt can be proven that 8 is the minimum number of minutes needed.\n\nExample 2:\n\nInput: s = \"a\", k = 1\nOutput: -1\nExplanation: It is not possible to take one 'b' or 'c' so return -1.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of only the letters 'a', 'b', and 'c'.\n0 <= k <= s.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abacbacbacb\",k = 2) == 6\n assert candidate(s = \"baccbaccbacc\",k = 2) == 6\n assert candidate(s = \"abcabcabcabcabc\",k = 3) == 9\n assert candidate(s = \"aabbaacc\",k = 2) == 6\n assert candidate(s = \"\",k = 0) == 0\n assert candidate(s = \"abc\",k = 0) == 0\n assert candidate(s = \"abcabcabcabcabcabc\",k = 3) == 9\n assert candidate(s = \"cccbbaaaa\",k = 2) == 7\n assert candidate(s = \"abacbcabc\",k = 0) == 0\n assert candidate(s = \"ccccccc\",k = 2) == -1\n assert candidate(s = \"aabbbccc\",k = 2) == 6\n assert candidate(s = \"aaaabbbbcccc\",k = 4) == 12\n assert candidate(s = \"aabaaaacaabc\",k = 2) == 8\n assert candidate(s = \"abcabcabc\",k = 1) == 3\n assert candidate(s = \"abcabcabc\",k = 3) == 9\n assert candidate(s = \"ccccccc\",k = 3) == -1\n assert candidate(s = \"a\",k = 1) == -1\n assert candidate(s = \"cccaaaabbb\",k = 2) == 7\n assert candidate(s = \"aabbcc\",k = 1) == 4\n assert candidate(s = \"aaabbbccc\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"ccccccbbbaaa\",k = 3) == 9\n assert candidate(s = \"abacbacbacb\",k = 3) == 9\n assert candidate(s = \"aabbccaaabbcc\",k = 2) == 6\n assert candidate(s = \"abacbacbacbac\",k = 2) == 6\n assert candidate(s = \"baacababacbacbacbacbacb\",k = 3) == 9\n assert candidate(s = \"ababababababcabcabc\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 5) == 15\n assert candidate(s = \"bababababababa\",k = 5) == -1\n assert candidate(s = \"aaaabbbbccccaaaabbbbccccaaaabbbbcccc\",k = 4) == 12\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"bbbbbaaaaaccccaaaabbbbccccaaaa\",k = 5) == 18\n assert candidate(s = \"aabbbbccccaa\",k = 2) == 8\n assert candidate(s = \"abacabacabc\",k = 2) == 6\n assert candidate(s = \"aabacbacbacbac\",k = 3) == 9\n assert candidate(s = \"aabaaaabbbcccaabbcccaabbccc\",k = 3) == 9\n assert candidate(s = \"aabbbcccaaa\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 6) == 18\n assert candidate(s = \"ccccbbbaaaa\",k = 3) == 10\n assert candidate(s = \"bbbbbcccccc\",k = 2) == -1\n assert candidate(s = \"cccaaaabbbccc\",k = 3) == 9\n assert candidate(s = \"abcbaabcbaabcba\",k = 2) == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbcccccccc\",k = 4) == 16\n assert candidate(s = \"abacbacbacbacbacbacbacbacb\",k = 3) == 9\n assert candidate(s = \"ccbbbaaa\",k = 2) == 6\n assert candidate(s = \"aabbccaaaabbcc\",k = 3) == 10\n assert candidate(s = \"abccbaabccba\",k = 2) == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbcccccc\",k = 5) == 16\n assert candidate(s = \"baccbaabccba\",k = 2) == 6\n assert candidate(s = \"abcabcabcabcabcabcabc\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabc\",k = 2) == 6\n assert candidate(s = \"cccccccccccccccccc\",k = 5) == -1\n assert candidate(s = \"cccccccccccaabbbbbb\",k = 3) == -1\n assert candidate(s = \"abacabacabac\",k = 3) == 11\n assert candidate(s = \"abacabaacaba\",k = 3) == -1\n assert candidate(s = \"aabbbcccbbbcccaaa\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"abccbaabcbaabc\",k = 3) == 9\n assert candidate(s = \"ccccccbbbbaaa\",k = 2) == 7\n assert candidate(s = \"aaaaabbbbbcccc\",k = 1) == 6\n assert candidate(s = \"aaaaaaabbbccc\",k = 2) == 7\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 5) == 15\n assert candidate(s = \"aaabbbcccbbbcccaaaccc\",k = 4) == 14\n assert candidate(s = \"cccbbbbaaa\",k = 2) == 7\n assert candidate(s = \"aabbccabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"aabaaaacaabc\",k = 5) == -1\n assert candidate(s = \"aabccbaabccbaabccba\",k = 3) == 9\n assert candidate(s = \"bbbbbbbccccaaa\",k = 2) == 7\n assert candidate(s = \"aaabbbcccaaa\",k = 2) == 8\n assert candidate(s = \"bbbaaabbbcccaaa\",k = 2) == 7\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",k = 3) == 9\n assert candidate(s = \"abacbacbacbacbacbac\",k = 5) == 15\n assert candidate(s = \"aabaaabccbbccaa\",k = 3) == 10\n assert candidate(s = \"bacbacbacbacbac\",k = 4) == 12\n assert candidate(s = \"ccccaaabbb\",k = 2) == 7\n assert candidate(s = \"acbbacaabcbab\",k = 2) == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 3) == 9\n assert candidate(s = \"abababababababababcabcabcabc\",k = 4) == 12\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\",k = 3) == -1\n assert candidate(s = \"abababababababababababababababababababababababab\",k = 5) == -1\n assert candidate(s = \"ccbaabacabcabcabcabcabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"acbacbacbacbacbac\",k = 2) == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 10) == 30\n assert candidate(s = \"cccccccccccccccccccccccccccccccccccccccccccccc\",k = 15) == -1\n assert candidate(s = \"cccbaaaaabbccc\",k = 3) == 11\n assert candidate(s = \"aababababababababababababa\",k = 2) == -1\n assert candidate(s = \"aabbcccaabbcccaabbccc\",k = 5) == 16\n assert candidate(s = \"ccababacabac\",k = 2) == 6\n assert candidate(s = \"aabbaabbaabbaabbcc\",k = 4) == -1\n assert candidate(s = \"ccbacababacba\",k = 4) == 12\n assert candidate(s = \"aabaaaabbbcccaabbcccaabbccc\",k = 4) == 14\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\",k = 5) == 15\n assert candidate(s = \"cccccccccbaaaabbbccc\",k = 3) == 9\n assert candidate(s = \"bbaaccaabbbb\",k = 2) == 6\n assert candidate(s = \"abacbacbacbacbac\",k = 4) == 12\n assert candidate(s = \"caacbbacabcabc\",k = 2) == 6\n assert candidate(s = \"aabbccbaaabbccbaaabbcc\",k = 2) == 6\n assert candidate(s = \"cccccccccccbcccccccccc\",k = 3) == -1\n assert candidate(s = \"aabbcc\",k = 0) == 0\n assert candidate(s = \"cabcabcabcabcabcabcabcabcabcabcabc\",k = 5) == 15\n assert candidate(s = \"aabcaabcbaabcbaabcba\",k = 4) == 16\n assert candidate(s = \"ccccccbbbaaaaaaacccccccbbbaaaaaa\",k = 4) == 16\n assert candidate(s = \"abacabadabacaba\",k = 3) == -1\n assert candidate(s = \"bcccccccccccba\",k = 3) == -1\n assert candidate(s = \"aaabbbccc\",k = 0) == 0\n assert candidate(s = \"bcbcbcbcbcbc\",k = 2) == -1\n assert candidate(s = \"abcabcabcabcabcabc\",k = 2) == 6\n assert candidate(s = \"bacbacbacbacbacbacbacbacbacbacbacbac\",k = 4) == 12\n assert candidate(s = \"cccccccccccccccccccccccccc\",k = 10) == -1\n assert candidate(s = \"aabbbcccddd\",k = 1) == 7\n assert candidate(s = \"ccbaabccbaabccba\",k = 3) == 9\n assert candidate(s = \"ababababababababababababababababababababababababab\",k = 6) == -1\n assert candidate(s = \"ccccccaaaabbbb\",k = 2) == 8\n assert candidate(s = \"ccccbbbbaaaaccccbbaaaccccbbaa\",k = 4) == 12\n assert candidate(s = \"aabaaaacaabc\",k = 3) == -1\n assert candidate(s = \"bbbbbbbaaaaaaaccccccc\",k = 3) == 13\n assert candidate(s = \"cacacacacacaca\",k = 2) == -1\n assert candidate(s = \"bbacccbaaa\",k = 2) == 6\n assert candidate(s = \"bbbaaacccbbbaaacccbbbaaacccbbbaaaccc\",k = 3) == 9\n assert candidate(s = \"aabaaaacaabcbbbccc\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"aabccccbaa\",k = 1) == 4\n assert candidate(s = \"aaaaabbbbbccccc\",k = 2) == 9\n assert candidate(s = \"abacabadabacabadabacabad\",k = 4) == -1\n assert candidate(s = \"ccccbbbaaa\",k = 2) == 7\n assert candidate(s = \"aaaaaaaaaaa\",k = 1) == -1\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabac\",k = 5) == 19\n assert candidate(s = \"aabbcc\",k = 2) == 6\n assert candidate(s = \"aabcaaacbbacabcabc\",k = 4) == 12\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().takeCharacters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int takeCharacters(String s, int k) {", "container": "Solution", "callable": "takeCharacters", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2517, "task_id": "maximum-tastiness-of-candy-basket", "difficulty": "Medium", "problem_description": "You are given an array of positive integers price where price[i] denotes the price of the ith candy and a positive integer k.\nThe store sells baskets of k distinct candies. The tastiness of a candy basket is the smallest absolute difference of the prices of any two candies in the basket.\nReturn the maximum tastiness of a candy basket.\n \nExample 1:\n\nInput: price = [13,5,1,8,21,2], k = 3\nOutput: 8\nExplanation: Choose the candies with the prices [13,5,21].\nThe tastiness of the candy basket is: min(|13 - 5|, |13 - 21|, |5 - 21|) = min(8, 8, 16) = 8.\nIt can be proven that 8 is the maximum tastiness that can be achieved.\n\nExample 2:\n\nInput: price = [1,3,1], k = 2\nOutput: 2\nExplanation: Choose the candies with the prices [1,3].\nThe tastiness of the candy basket is: min(|1 - 3|) = min(2) = 2.\nIt can be proven that 2 is the maximum tastiness that can be achieved.\n\nExample 3:\n\nInput: price = [7,7,7,7], k = 2\nOutput: 0\nExplanation: Choosing any two distinct candies from the candies we have will result in a tastiness of 0.\n\n \nConstraints:\n\n2 <= k <= price.length <= 105\n1 <= price[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(price = [1000000000, 1, 2, 3, 4, 5],k = 3) == 4\n assert candidate(price = [1000000000, 1, 1000000000, 1, 1000000000],k = 3) == 0\n assert candidate(price = [10, 20, 30, 40, 50],k = 3) == 20\n assert candidate(price = [13, 5, 1, 8, 21, 2],k = 3) == 8\n assert candidate(price = [1, 1000000000, 2, 999999999],k = 2) == 999999999\n assert candidate(price = [7, 7, 7, 7],k = 2) == 0\n assert candidate(price = [50, 50, 50, 50, 50, 50],k = 2) == 0\n assert candidate(price = [1, 3, 1],k = 2) == 2\n assert candidate(price = [10, 20, 30, 40, 50],k = 4) == 10\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 2\n assert candidate(price = [100000000, 100000001, 100000002, 100000003, 100000004, 100000005, 100000006, 100000007, 100000008, 100000009],k = 5) == 2\n assert candidate(price = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 2) == 0\n assert candidate(price = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50],k = 3) == 200\n assert candidate(price = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 0\n assert candidate(price = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 20\n assert candidate(price = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 5) == 6\n assert candidate(price = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 6) == 100\n assert candidate(price = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],k = 6) == 18\n assert candidate(price = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 10) == 2\n assert candidate(price = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 2\n assert candidate(price = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997],k = 5) == 1\n assert candidate(price = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 9) == 20\n assert candidate(price = [100, 102, 105, 108, 110, 120, 130, 140, 150],k = 4) == 10\n assert candidate(price = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 6) == 63\n assert candidate(price = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],k = 6) == 987\n assert candidate(price = [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, 101, 105, 109, 113, 117],k = 10) == 12\n assert candidate(price = [500000000, 400000000, 300000000, 200000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1],k = 4) == 100000000\n assert candidate(price = [1000000000, 1, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10],k = 5) == 999999\n assert candidate(price = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],k = 6) == 30\n assert candidate(price = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 8) == 6\n assert candidate(price = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],k = 5) == 2\n assert candidate(price = [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],k = 6) == 1\n assert candidate(price = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],k = 5) == 2\n assert candidate(price = [987654321, 987654322, 987654323, 987654324, 987654325, 987654326, 987654327, 987654328, 987654329, 987654330],k = 7) == 1\n assert candidate(price = [1, 1000000000, 2, 999999999, 3, 999999998],k = 3) == 2\n assert candidate(price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 20\n assert candidate(price = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 2) == 1\n assert candidate(price = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 4\n assert candidate(price = [500000000, 1000000000, 1500000000, 2000000000, 2500000000, 3000000000],k = 3) == 1000000000\n assert candidate(price = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 4\n assert candidate(price = [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 = 6) == 1\n assert candidate(price = [999999999, 1, 1000000000, 2, 999999998, 3],k = 3) == 2\n assert candidate(price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 10\n assert candidate(price = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],k = 7) == 12\n assert candidate(price = [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],k = 12) == 6\n assert candidate(price = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 5) == 2\n assert candidate(price = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 4\n assert candidate(price = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005, 500000006, 500000007, 500000008, 500000009],k = 3) == 4\n assert candidate(price = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 4) == 1\n assert candidate(price = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 5) == 999999\n assert candidate(price = [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],k = 20) == 1\n assert candidate(price = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 8) == 200\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 1\n assert candidate(price = [1000000000, 1, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1],k = 6) == 99999\n assert candidate(price = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 0\n assert candidate(price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 20\n assert candidate(price = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300],k = 8) == 40\n assert candidate(price = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000],k = 5) == 200000000\n assert candidate(price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 12) == 10\n assert candidate(price = [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) == 2\n assert candidate(price = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(price = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 7) == 15\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 2\n assert candidate(price = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 2\n assert candidate(price = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996],k = 5) == 2\n assert candidate(price = [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) == 2\n assert candidate(price = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000],k = 5) == 200000000\n assert candidate(price = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 1\n assert candidate(price = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 5) == 999999\n assert candidate(price = [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) == 4\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 2\n assert candidate(price = [5, 8, 12, 17, 22, 28, 33, 39, 44, 50],k = 5) == 11\n assert candidate(price = [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],k = 15) == 200\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 2\n assert candidate(price = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],k = 2) == 1\n assert candidate(price = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 10) == 2047\n assert candidate(price = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],k = 10) == 8\n assert candidate(price = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6],k = 4) == 1\n assert candidate(price = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 15) == 2\n assert candidate(price = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 7) == 100\n assert candidate(price = [524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 5) == 65535\n"}, "metadata": {"canonical_parameter_names": ["price", "k"], "leetcode_dataset_entry_point": "Solution().maximumTastiness", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumTastiness(int[] price, int k) {", "container": "Solution", "callable": "maximumTastiness", "parameters": [{"name": "price", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2518, "task_id": "number-of-great-partitions", "difficulty": "Hard", "problem_description": "You are given an array nums consisting of positive integers and an integer k.\nPartition the array into two ordered groups such that each element is in exactly one group. A partition is called great if the sum of elements of each group is greater than or equal to k.\nReturn the number of distinct great partitions. Since the answer may be too large, return it modulo 109 + 7.\nTwo partitions are considered distinct if some element nums[i] is in different groups in the two partitions.\n \nExample 1:\n\nInput: nums = [1,2,3,4], k = 4\nOutput: 6\nExplanation: The great partitions are: ([1,2,3], [4]), ([1,3], [2,4]), ([1,4], [2,3]), ([2,3], [1,4]), ([2,4], [1,3]) and ([4], [1,2,3]).\n\nExample 2:\n\nInput: nums = [3,3,3], k = 4\nOutput: 0\nExplanation: There are no great partitions for this array.\n\nExample 3:\n\nInput: nums = [6,6], k = 2\nOutput: 2\nExplanation: We can either put nums[0] in the first partition or in the second partition.\nThe great partitions will be ([6], [6]) and ([6], [6]).\n\n \nConstraints:\n\n1 <= nums.length, k <= 1000\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40],k = 50) == 2\n assert candidate(nums = [1, 1, 1, 1],k = 2) == 6\n assert candidate(nums = [2, 4, 6, 8, 10],k = 11) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 252\n assert candidate(nums = [6, 6],k = 2) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],k = 600) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 826\n assert candidate(nums = [3, 3, 3],k = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 252\n assert candidate(nums = [1000, 1000, 1000],k = 1) == 6\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 20\n assert candidate(nums = [1, 3, 5, 7, 9],k = 15) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 15) == 20\n assert candidate(nums = [999, 999, 999, 999, 999],k = 2500) == 0\n assert candidate(nums = [1, 2, 3, 4],k = 4) == 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],k = 20) == 1039850\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 = 20) == 0\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 = 1500) == 0\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],k = 5000) == 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 = 5) == 1036184\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 150) == 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, 210, 220, 230, 240, 250],k = 1250) == 23074264\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 = 300) == 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 200) == 259246959\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],k = 2500) == 912\n assert candidate(nums = [100, 200, 300, 400, 500],k = 700) == 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],k = 2) == 1048534\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 = 1000) == 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 = 750) == 774794\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 1000) == 1048534\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 45) == 252\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 166910\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) == 184756\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],k = 1500) == 9026504\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 5000) == 14372\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999],k = 5000000000) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1500) == 826\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) == 1036184\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980],k = 9800) == 184756\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],k = 2) == 67049447\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000],k = 4000) == 0\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 100) == 17728\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 50) == 786\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 900) == 0\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 = 400) == 682822\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 20) == 519388\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 500) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 450) == 0\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 2400) == 252\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 50) == 63526\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999],k = 3000000000) == 0\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 2500) == 236\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 = 5000) == 590560\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2500) == 236\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 252\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],k = 1000000) == 0\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981],k = 15000) == 0\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],k = 1250) == 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 = 5) == 73677955\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 45000) == 0\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 5000) == 252\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 = 50) == 73688469\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 35) == 252\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999],k = 10000000000) == 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 = 100) == 68359565\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 150) == 826\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509],k = 2500) == 252\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 25) == 236\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 150) == 826\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 = 200) == 533906260\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 826\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 = 2500) == 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 = 100) == 996110\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 582\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981],k = 5000) == 1005176\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 = 10000) == 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 = 200) == 7930\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) == 1047834\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 250) == 236\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 40) == 31912\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 = 50) == 33505686\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 50) == 28886\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 = 1000000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 30) == 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, 42, 44, 46, 48, 50],k = 300) == 9026504\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3000) == 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) == 1047962\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 1000) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 146086846\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999],k = 10000000000) == 0\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],k = 4950) == 252\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],k = 200) == 295936\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 800) == 0\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 500) == 184756\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 = 100) == 1010582\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 700) == 0\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 = 1000) == 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],k = 25) == 73677955\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 = 1000) == 166910\n assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],k = 1000) == 582\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countPartitions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countPartitions(int[] nums, int k) {", "container": "Solution", "callable": "countPartitions", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2520, "task_id": "count-the-digits-that-divide-a-number", "difficulty": "Easy", "problem_description": "Given an integer num, return the number of digits in num that divide num.\nAn integer val divides nums if nums % val == 0.\n \nExample 1:\n\nInput: num = 7\nOutput: 1\nExplanation: 7 divides itself, hence the answer is 1.\n\nExample 2:\n\nInput: num = 121\nOutput: 2\nExplanation: 121 is divisible by 1, but not 2. Since 1 occurs twice as a digit, we return 2.\n\nExample 3:\n\nInput: num = 1248\nOutput: 4\nExplanation: 1248 is divisible by all of its digits, hence the answer is 4.\n\n \nConstraints:\n\n1 <= num <= 109\nnum does not contain 0 as one of its digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 111111111) == 9\n assert candidate(num = 666) == 3\n assert candidate(num = 999) == 3\n assert candidate(num = 222) == 3\n assert candidate(num = 1122) == 4\n assert candidate(num = 123456789) == 3\n assert candidate(num = 4488) == 4\n assert candidate(num = 444) == 3\n assert candidate(num = 555) == 3\n assert candidate(num = 1248) == 4\n assert candidate(num = 13579) == 1\n assert candidate(num = 888) == 3\n assert candidate(num = 333) == 3\n assert candidate(num = 2222) == 4\n assert candidate(num = 987654321) == 3\n assert candidate(num = 7) == 1\n assert candidate(num = 1111) == 4\n assert candidate(num = 121) == 2\n assert candidate(num = 111) == 3\n assert candidate(num = 777) == 3\n assert candidate(num = 2244) == 4\n assert candidate(num = 357) == 2\n assert candidate(num = 3366) == 4\n assert candidate(num = 222222222) == 9\n assert candidate(num = 369125874) == 5\n assert candidate(num = 555666777) == 0\n assert candidate(num = 555555555) == 9\n assert candidate(num = 888888888) == 9\n assert candidate(num = 975318642) == 5\n assert candidate(num = 1111111111) == 10\n assert candidate(num = 222333444555666777888999) == 3\n assert candidate(num = 32481632) == 5\n assert candidate(num = 889977) == 0\n assert candidate(num = 777777777) == 9\n assert candidate(num = 1357913579) == 2\n assert candidate(num = 199919991) == 3\n assert candidate(num = 248163264128) == 9\n assert candidate(num = 111222333) == 6\n assert candidate(num = 666666666) == 9\n assert candidate(num = 135792468) == 7\n assert candidate(num = 222444666) == 6\n assert candidate(num = 333333333) == 9\n assert candidate(num = 595959) == 0\n assert candidate(num = 1352468) == 3\n assert candidate(num = 272727272) == 5\n assert candidate(num = 135791357) == 2\n assert candidate(num = 363636363) == 5\n assert candidate(num = 31313) == 2\n assert candidate(num = 333666999) == 6\n assert candidate(num = 555555555555555555) == 18\n assert candidate(num = 333366669999) == 8\n assert candidate(num = 7654321) == 1\n assert candidate(num = 82436) == 2\n assert candidate(num = 135) == 3\n assert candidate(num = 488848884) == 3\n assert candidate(num = 363636) == 6\n assert candidate(num = 1122334455) == 6\n assert candidate(num = 478915) == 2\n assert candidate(num = 246813579) == 3\n assert candidate(num = 24682468) == 4\n assert candidate(num = 864213579) == 3\n assert candidate(num = 333999) == 6\n assert candidate(num = 1133557799) == 2\n assert candidate(num = 369258147) == 3\n assert candidate(num = 111222333444555666777888999) == 9\n assert candidate(num = 899999999) == 0\n assert candidate(num = 29876) == 2\n assert candidate(num = 468297351) == 3\n assert candidate(num = 56324) == 2\n assert candidate(num = 199199199) == 3\n assert candidate(num = 975319753) == 1\n assert candidate(num = 112233) == 4\n assert candidate(num = 112233445566778899) == 6\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().countDigits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countDigits(int num) {", "container": "Solution", "callable": "countDigits", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2521, "task_id": "distinct-prime-factors-of-product-of-array", "difficulty": "Medium", "problem_description": "Given an array of positive integers nums, return the number of distinct prime factors in the product of the elements of nums.\nNote that:\n\nA number greater than 1 is called prime if it is divisible by only 1 and itself.\nAn integer val1 is a factor of another integer val2 if val2 / val1 is an integer.\n\n \nExample 1:\n\nInput: nums = [2,4,3,7,10,6]\nOutput: 4\nExplanation:\nThe product of all the elements in nums is: 2 * 4 * 3 * 7 * 10 * 6 = 10080 = 25 * 32 * 5 * 7.\nThere are 4 distinct prime factors so we return 4.\n\nExample 2:\n\nInput: nums = [2,4,8,16]\nOutput: 1\nExplanation:\nThe product of all the elements in nums is: 2 * 4 * 8 * 16 = 1024 = 210.\nThere is 1 distinct prime factor so we return 1.\n\n \nConstraints:\n\n1 <= nums.length <= 104\n2 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 200, 300, 400]) == 3\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [256, 512, 1024, 2048]) == 1\n assert candidate(nums = [1000, 500, 250, 125]) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13]) == 6\n assert candidate(nums = [60, 120, 180, 240, 300]) == 3\n assert candidate(nums = [31, 37, 41, 43, 47, 53]) == 6\n assert candidate(nums = [2, 4, 3, 7, 10, 6]) == 4\n assert candidate(nums = [29, 31, 37, 41]) == 4\n assert candidate(nums = [1000, 500, 250, 125]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50]) == 3\n assert candidate(nums = [100, 200, 300]) == 3\n assert candidate(nums = [2, 4, 8, 16]) == 1\n assert candidate(nums = [997, 991, 983, 977, 971]) == 5\n assert candidate(nums = [3, 5, 7, 11, 13]) == 5\n assert candidate(nums = [60, 120, 180, 240]) == 3\n assert candidate(nums = [49, 49, 49, 49]) == 1\n assert candidate(nums = [999, 1000]) == 4\n assert candidate(nums = [7, 14, 21, 28, 35]) == 4\n assert candidate(nums = [31, 31, 31, 31, 31]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 10\n assert candidate(nums = [5, 10, 15, 20]) == 3\n assert candidate(nums = [3, 9, 27, 81]) == 1\n assert candidate(nums = [2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [61, 67, 71, 73, 79, 83, 89, 97]) == 8\n assert candidate(nums = [15, 21, 27, 33, 39]) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 4\n assert candidate(nums = [17, 19, 23, 29, 31, 37, 41]) == 7\n assert candidate(nums = [1023, 2046, 3069, 4092, 5115]) == 5\n assert candidate(nums = [111, 222, 333, 444, 555]) == 4\n assert candidate(nums = [15, 21, 35, 55, 77, 105]) == 4\n assert candidate(nums = [221, 247, 299, 323, 377, 413]) == 7\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 1\n assert candidate(nums = [1009, 1013, 1019, 1021, 1031]) == 5\n assert candidate(nums = [84, 90, 120, 140, 182]) == 5\n assert candidate(nums = [987, 1597, 2584, 4181, 6765]) == 12\n assert candidate(nums = [50, 75, 100, 125, 150]) == 3\n assert candidate(nums = [60, 105, 140, 210, 231]) == 5\n assert candidate(nums = [101, 103, 107, 109, 113, 127]) == 6\n assert candidate(nums = [210, 154, 90]) == 5\n assert candidate(nums = [29, 31, 37, 41, 43]) == 5\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == 20\n assert candidate(nums = [19, 23, 29, 31, 37, 41, 43, 47]) == 8\n assert candidate(nums = [123, 456, 789, 101112, 131415]) == 9\n assert candidate(nums = [36, 45, 60, 72, 84, 90]) == 4\n assert candidate(nums = [121, 143, 169, 187, 221]) == 3\n assert candidate(nums = [100, 200, 300, 400, 500]) == 3\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384]) == 1\n assert candidate(nums = [13195, 206772, 3249006, 5125130]) == 12\n assert candidate(nums = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 9\n assert candidate(nums = [500, 700, 900, 1100, 1300, 1500]) == 6\n assert candidate(nums = [2310, 30030, 510510, 9699690]) == 8\n assert candidate(nums = [123, 456, 789, 101112]) == 7\n assert candidate(nums = [121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 8\n assert candidate(nums = [60, 84, 90, 120, 180, 240]) == 4\n assert candidate(nums = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000]) == 4\n assert candidate(nums = [30, 45, 60, 75, 90]) == 3\n assert candidate(nums = [29, 31, 37, 41, 43, 47]) == 6\n assert candidate(nums = [840, 945, 1260, 1575]) == 4\n assert candidate(nums = [98, 112, 147, 196, 294]) == 3\n assert candidate(nums = [961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975]) == 19\n assert candidate(nums = [231, 308, 396, 462]) == 4\n assert candidate(nums = [987, 654, 321, 876, 543, 210]) == 9\n assert candidate(nums = [231, 462, 693, 924, 1155]) == 5\n assert candidate(nums = [1024, 512, 256, 128]) == 1\n assert candidate(nums = [8, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102]) == 7\n assert candidate(nums = [49, 64, 81, 100, 121, 144, 169, 196, 225]) == 6\n assert candidate(nums = [128, 256, 512, 1024, 2048]) == 1\n assert candidate(nums = [17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 10\n assert candidate(nums = [30, 42, 60, 70, 105]) == 4\n assert candidate(nums = [19, 31, 37, 41, 43, 47, 53, 59]) == 8\n assert candidate(nums = [25, 49, 121, 169, 289, 361]) == 6\n assert candidate(nums = [729, 512, 343, 243, 125]) == 4\n assert candidate(nums = [1024, 2048, 4096, 8192]) == 1\n assert candidate(nums = [169, 441, 729, 1089, 1369]) == 5\n assert candidate(nums = [15, 21, 33, 55, 77]) == 4\n assert candidate(nums = [997, 991, 983, 977, 971, 967, 953, 947, 941, 937]) == 10\n assert candidate(nums = [1000, 500, 250, 125, 62, 31]) == 3\n assert candidate(nums = [171, 195, 221, 255, 285, 323]) == 5\n assert candidate(nums = [18, 30, 45, 60, 75]) == 3\n assert candidate(nums = [81, 125, 243, 343, 625]) == 3\n assert candidate(nums = [840, 924, 1008, 1092, 1176, 1260]) == 6\n assert candidate(nums = [37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == 3\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]) == 25\n assert candidate(nums = [210, 231, 273, 308, 330, 364]) == 6\n assert candidate(nums = [60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 8\n assert candidate(nums = [60, 105, 140, 210, 300]) == 4\n assert candidate(nums = [97, 101, 103, 107, 109, 113]) == 6\n assert candidate(nums = [81, 243, 729, 2187, 6561]) == 1\n assert candidate(nums = [2310, 5005, 7735, 1155]) == 7\n assert candidate(nums = [840, 1260, 720, 5040]) == 4\n assert candidate(nums = [65, 130, 260, 520, 1040, 2080]) == 3\n assert candidate(nums = [256, 512, 1024, 2048, 4096]) == 1\n assert candidate(nums = [83, 89, 97, 101, 103, 107, 109, 113, 127, 131]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700]) == 4\n assert candidate(nums = [123, 456, 789, 1011, 1213]) == 7\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31]) == 8\n assert candidate(nums = [8192, 16384, 32768, 65536]) == 1\n assert candidate(nums = [3125, 625, 125, 25]) == 1\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192]) == 1\n assert candidate(nums = [97, 98, 99, 100, 101]) == 7\n assert candidate(nums = [89, 107, 127, 137, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229]) == 20\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 5\n assert candidate(nums = [504, 1008, 2016, 4032]) == 3\n assert candidate(nums = [1023, 500, 729]) == 5\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11]) == 5\n assert candidate(nums = [60, 84, 90, 120, 210]) == 4\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 10\n assert candidate(nums = [49, 64, 81, 100, 121, 144]) == 5\n assert candidate(nums = [997, 991, 983, 977, 971]) == 5\n assert candidate(nums = [30030, 30030, 30030, 30030, 30030]) == 6\n assert candidate(nums = [12, 15, 21, 28, 45]) == 4\n assert candidate(nums = [55, 77, 91, 1001, 1365]) == 5\n assert candidate(nums = [625, 1250, 2500, 5000, 10000]) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().distinctPrimeFactors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int distinctPrimeFactors(int[] nums) {", "container": "Solution", "callable": "distinctPrimeFactors", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2522, "task_id": "partition-string-into-substrings-with-values-at-most-k", "difficulty": "Medium", "problem_description": "You are given a string s consisting of digits from 1 to 9 and an integer k.\nA partition of a string s is called good if:\n\nEach digit of s is part of exactly one substring.\nThe value of each substring is less than or equal to k.\n\nReturn the minimum number of substrings in a good partition of s. If no good partition of s exists, return -1.\nNote that:\n\nThe value of a string is its result when interpreted as an integer. For example, the value of \"123\" is 123 and the value of \"1\" is 1.\nA substring is a contiguous sequence of characters within a string.\n\n \nExample 1:\n\nInput: s = \"165462\", k = 60\nOutput: 4\nExplanation: We can partition the string into substrings \"16\", \"54\", \"6\", and \"2\". Each substring has a value less than or equal to k = 60.\nIt can be shown that we cannot partition the string into less than 4 substrings.\n\nExample 2:\n\nInput: s = \"238182\", k = 5\nOutput: -1\nExplanation: There is no good partition for this string.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns[i] is a digit from '1' to '9'.\n1 <= k <= 109\n\n \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"473289651\",k = 10) == 9\n assert candidate(s = \"2222222222222222222\",k = 2) == 19\n assert candidate(s = \"987654321\",k = 10) == 9\n assert candidate(s = \"999\",k = 1000) == 1\n assert candidate(s = \"999999999\",k = 999999999) == 1\n assert candidate(s = \"999999999\",k = 1000) == 3\n assert candidate(s = \"47328165\",k = 100) == 4\n assert candidate(s = \"99999\",k = 100000) == 1\n assert candidate(s = \"1\",k = 1) == 1\n assert candidate(s = \"1111111111\",k = 1) == 10\n assert candidate(s = \"987654321\",k = 987654321) == 1\n assert candidate(s = \"123456789\",k = 9) == 9\n assert candidate(s = \"9\",k = 8) == -1\n assert candidate(s = \"823847291\",k = 823) == 4\n assert candidate(s = \"456\",k = 100) == 2\n assert candidate(s = \"555555555\",k = 55) == 5\n assert candidate(s = \"111111111\",k = 1) == 9\n assert candidate(s = \"987654321\",k = 50) == 7\n assert candidate(s = \"238182\",k = 5) == -1\n assert candidate(s = \"123\",k = 3) == 3\n assert candidate(s = \"165462\",k = 60) == 4\n assert candidate(s = \"123456789101112131415\",k = 1000) == 7\n assert candidate(s = \"88888888888888888888\",k = 888) == 7\n assert candidate(s = \"11111111111111111111\",k = 11) == 10\n assert candidate(s = \"8888888888888888888888888888888888\",k = 1000) == 12\n assert candidate(s = \"1234567891011121314151617181920\",k = 10) == 30\n assert candidate(s = \"123456789\",k = 987654321) == 1\n assert candidate(s = \"1919191919191919191919191919191919191919191919\",k = 19) == 23\n assert candidate(s = \"987654321\",k = 250) == 5\n assert candidate(s = \"123456789987654321\",k = 9999) == 5\n assert candidate(s = \"5678956789567895678956789\",k = 10000) == 7\n assert candidate(s = \"12345678901234567890123456789012345678901234567890\",k = 123456789) == 6\n assert candidate(s = \"9999999999999999999\",k = 1000000000) == 3\n assert candidate(s = \"1212121212121212121\",k = 12) == 10\n assert candidate(s = \"123123123123123123123123123123123123123123123123\",k = 123) == 16\n assert candidate(s = \"876543219876543219\",k = 50000) == 4\n assert candidate(s = \"5555555555555555555555555555555\",k = 555) == 11\n assert candidate(s = \"9999999999999999999\",k = 999999999) == 3\n assert candidate(s = \"1\",k = 9) == 1\n assert candidate(s = \"77777777777777777777777777777777777777777777\",k = 777777) == 8\n assert candidate(s = \"9999999999999999999\",k = 10) == 19\n assert candidate(s = \"135792468\",k = 100) == 5\n assert candidate(s = \"987654321123456789987654321\",k = 98765) == 6\n assert candidate(s = \"99999999999999999999999999999999999999999999\",k = 999999999) == 5\n assert candidate(s = \"33333333333333333333333333333333333333333333\",k = 333) == 15\n assert candidate(s = \"102030405060708090\",k = 100) == 9\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",k = 10) == 99\n assert candidate(s = \"123456789987654321\",k = 123456789) == 3\n assert candidate(s = \"987654321\",k = 987654320) == 2\n assert candidate(s = \"123456789123456789123456789\",k = 123456789) == 3\n assert candidate(s = \"7777777777777777777\",k = 50) == 19\n assert candidate(s = \"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\",k = 999999999) == 12\n assert candidate(s = \"246813579\",k = 1000) == 3\n assert candidate(s = \"19191919191919191919\",k = 19) == 10\n assert candidate(s = \"3333333333333333333\",k = 33333) == 4\n assert candidate(s = \"3333333333333333333\",k = 333) == 7\n assert candidate(s = \"55555555555555555555555555555555555555555555\",k = 55555) == 9\n assert candidate(s = \"3333333333333333333333333333333333\",k = 33) == 17\n assert candidate(s = \"321321321321321321321\",k = 321) == 7\n assert candidate(s = \"111222333444555666777888999\",k = 333) == 12\n assert candidate(s = \"1357924680135792468\",k = 1000) == 6\n assert candidate(s = \"1234567891011121314151617181920\",k = 1) == -1\n assert candidate(s = \"1111111111111111111111111111111111111111111111\",k = 1) == 46\n assert candidate(s = \"87654321\",k = 543) == 4\n assert candidate(s = \"987654321\",k = 100) == 5\n assert candidate(s = \"505050505050505050505050505050505050505050505050\",k = 505) == 13\n assert candidate(s = \"91827364510987654321\",k = 1000) == 7\n assert candidate(s = \"123456789123456789123456789123456789123456789\",k = 123456789) == 5\n assert candidate(s = \"1234567890123456789\",k = 123456789) == 2\n assert candidate(s = \"88888888888888888888888888888888888888888888\",k = 88888888) == 6\n assert candidate(s = \"99999999999999999999\",k = 10) == 20\n assert candidate(s = \"135792468\",k = 10) == 9\n assert candidate(s = \"1111111111111111111\",k = 1) == 19\n assert candidate(s = \"111111111111111111111111111111111111111111111111\",k = 1) == 48\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",k = 111) == 33\n assert candidate(s = \"1234567890987654321\",k = 12345) == 5\n assert candidate(s = \"9999999999999999999\",k = 1000) == 7\n assert candidate(s = \"1231231231231231231\",k = 123123) == 4\n assert candidate(s = \"1919191919191919191919191919191919191919191919\",k = 20) == 23\n assert candidate(s = \"99999999999999999999\",k = 999999999) == 3\n assert candidate(s = \"1010101010101010101\",k = 101) == 5\n assert candidate(s = \"987654321987654321987654321987654321987654321\",k = 987654321) == 5\n assert candidate(s = \"98765432109876543210987654321098765432109876543210\",k = 987654321) == 6\n assert candidate(s = \"9283746554321\",k = 10000) == 4\n assert candidate(s = \"123456789\",k = 123456789) == 1\n assert candidate(s = \"99999999999999999999999999999999999999999999999\",k = 999999999) == 6\n assert candidate(s = \"1234567891011121314151617181920\",k = 150) == 14\n assert candidate(s = \"987654321\",k = 500) == 4\n assert candidate(s = \"55555555555555555555555555555555555555555555555\",k = 60) == 24\n assert candidate(s = \"123456789\",k = 8) == -1\n assert candidate(s = \"987654321\",k = 999999999) == 1\n assert candidate(s = \"1999999999999999999999999999999999\",k = 1000000000) == 4\n assert candidate(s = \"1234567891011121314151617181920\",k = 100) == 15\n assert candidate(s = \"77777777777777777777777777777777777777777777777\",k = 77) == 24\n assert candidate(s = \"123456789\",k = 89) == 5\n assert candidate(s = \"3333333333333333333\",k = 33) == 10\n assert candidate(s = \"123456789\",k = 5) == -1\n assert candidate(s = \"8888888888888888888\",k = 9) == 19\n assert candidate(s = \"123456789123456789\",k = 1000000000) == 2\n assert candidate(s = \"11111111111111111111111111111111111111111111\",k = 111111111) == 5\n assert candidate(s = \"246813579\",k = 250) == 4\n assert candidate(s = \"123456789101112131415\",k = 100) == 10\n assert candidate(s = \"98765432187654321\",k = 1000) == 6\n assert candidate(s = \"1234567891011121314151617181920\",k = 99) == 15\n assert candidate(s = \"55555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555\",k = 555) == 33\n assert candidate(s = \"54321\",k = 5) == 5\n assert candidate(s = \"543215432154321\",k = 543) == 5\n assert candidate(s = \"9876543210987654321\",k = 100000) == 4\n assert candidate(s = \"112233445566778899112233445566778899112233\",k = 112233) == 8\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().minimumPartition", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumPartition(String s, int k) {", "container": "Solution", "callable": "minimumPartition", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2523, "task_id": "closest-prime-numbers-in-range", "difficulty": "Medium", "problem_description": "Given two positive integers left and right, find the two integers num1 and num2 such that:\n\nleft <= num1 < num2 <= right .\nBoth num1 and num2 are prime numbers.\nnum2 - num1 is the minimum amongst all other pairs satisfying the above conditions.\n\nReturn the positive integer array ans = [num1, num2]. If there are multiple pairs satisfying these conditions, return the one with the smallest num1 value. If no such numbers exist, return [-1, -1].\n \nExample 1:\n\nInput: left = 10, right = 19\nOutput: [11,13]\nExplanation: The prime numbers between 10 and 19 are 11, 13, 17, and 19.\nThe closest gap between any pair is 2, which can be achieved by [11,13] or [17,19].\nSince 11 is smaller than 17, we return the first pair.\n\nExample 2:\n\nInput: left = 4, right = 6\nOutput: [-1,-1]\nExplanation: There exists only one prime number in the given range, so the conditions cannot be satisfied.\n\n \nConstraints:\n\n1 <= left <= right <= 106\n\n \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(left = 500,right = 550) == [521, 523]\n assert candidate(left = 1000,right = 1100) == [1019, 1021]\n assert candidate(left = 10000,right = 10020) == [10007, 10009]\n assert candidate(left = 1000,right = 1010) == [-1, -1]\n assert candidate(left = 999983,right = 999999) == [-1, -1]\n assert candidate(left = 20,right = 30) == [23, 29]\n assert candidate(left = 100,right = 110) == [101, 103]\n assert candidate(left = 500,right = 600) == [521, 523]\n assert candidate(left = 1,right = 10) == [2, 3]\n assert candidate(left = 7,right = 11) == [7, 11]\n assert candidate(left = 500,right = 520) == [503, 509]\n assert candidate(left = 30,right = 50) == [41, 43]\n assert candidate(left = 5000,right = 6000) == [5009, 5011]\n assert candidate(left = 100000,right = 100010) == [-1, -1]\n assert candidate(left = 500,right = 510) == [503, 509]\n assert candidate(left = 1000,right = 1020) == [1009, 1013]\n assert candidate(left = 100000,right = 100020) == [100003, 100019]\n assert candidate(left = 500000,right = 500010) == [-1, -1]\n assert candidate(left = 999950,right = 1000000) == [999959, 999961]\n assert candidate(left = 10000,right = 10010) == [10007, 10009]\n assert candidate(left = 4,right = 6) == [-1, -1]\n assert candidate(left = 104743,right = 104759) == [104743, 104759]\n assert candidate(left = 1,right = 1) == [-1, -1]\n assert candidate(left = 999900,right = 1000000) == [999959, 999961]\n assert candidate(left = 10,right = 19) == [11, 13]\n assert candidate(left = 5000,right = 5500) == [5009, 5011]\n assert candidate(left = 100000,right = 100100) == [100043, 100049]\n assert candidate(left = 999990,right = 1000000) == [-1, -1]\n assert candidate(left = 100000,right = 100001) == [-1, -1]\n assert candidate(left = 800000,right = 810000) == [800117, 800119]\n assert candidate(left = 500000,right = 510000) == [500111, 500113]\n assert candidate(left = 200000,right = 210000) == [200381, 200383]\n assert candidate(left = 1,right = 29) == [2, 3]\n assert candidate(left = 999979,right = 1000037) == [999979, 999983]\n assert candidate(left = 1000000,right = 1000010) == [-1, -1]\n assert candidate(left = 5000,right = 5010) == [5003, 5009]\n assert candidate(left = 300000,right = 310000) == [300149, 300151]\n assert candidate(left = 104740,right = 104760) == [104743, 104759]\n assert candidate(left = 100000,right = 100050) == [100043, 100049]\n assert candidate(left = 140000,right = 150000) == [140069, 140071]\n assert candidate(left = 800,right = 850) == [809, 811]\n assert candidate(left = 1000000,right = 1000006) == [-1, -1]\n assert candidate(left = 541,right = 547) == [541, 547]\n assert candidate(left = 1487,right = 1600) == [1487, 1489]\n assert candidate(left = 700000,right = 700100) == [700079, 700081]\n assert candidate(left = 100,right = 200) == [101, 103]\n assert candidate(left = 50000,right = 50100) == [50021, 50023]\n assert candidate(left = 999000,right = 999100) == [999023, 999029]\n assert candidate(left = 200000,right = 200100) == [200029, 200033]\n assert candidate(left = 999983,right = 999983) == [-1, -1]\n assert candidate(left = 999950,right = 1000050) == [999959, 999961]\n assert candidate(left = 300000,right = 300050) == [300017, 300023]\n assert candidate(left = 100000,right = 101000) == [100151, 100153]\n assert candidate(left = 50000,right = 51000) == [50021, 50023]\n assert candidate(left = 600000,right = 600010) == [-1, -1]\n assert candidate(left = 200000,right = 201000) == [200381, 200383]\n assert candidate(left = 14,right = 16) == [-1, -1]\n assert candidate(left = 900000,right = 910000) == [900089, 900091]\n assert candidate(left = 10000,right = 10050) == [10007, 10009]\n assert candidate(left = 999983,right = 1000033) == [999983, 1000003]\n assert candidate(left = 1,right = 100) == [2, 3]\n assert candidate(left = 3000,right = 3010) == [-1, -1]\n assert candidate(left = 600000,right = 600100) == [600071, 600073]\n assert candidate(left = 987654,right = 987700) == [987659, 987697]\n assert candidate(left = 123456,right = 123556) == [123491, 123493]\n assert candidate(left = 2,right = 3) == [2, 3]\n assert candidate(left = 770000,right = 770100) == [770039, 770041]\n assert candidate(left = 100000,right = 110000) == [100151, 100153]\n assert candidate(left = 5000,right = 5100) == [5009, 5011]\n assert candidate(left = 800000,right = 800100) == [800053, 800057]\n assert candidate(left = 2,right = 5) == [2, 3]\n assert candidate(left = 1000000,right = 1000050) == [1000037, 1000039]\n assert candidate(left = 14,right = 20) == [17, 19]\n assert candidate(left = 50000,right = 50010) == [-1, -1]\n assert candidate(left = 345678,right = 345778) == [345731, 345733]\n assert candidate(left = 654321,right = 654421) == [654343, 654349]\n assert candidate(left = 200000,right = 200050) == [200029, 200033]\n assert candidate(left = 999990,right = 999998) == [-1, -1]\n assert candidate(left = 300000,right = 300100) == [300017, 300023]\n assert candidate(left = 500000,right = 500100) == [500029, 500041]\n assert candidate(left = 100000,right = 100500) == [100151, 100153]\n assert candidate(left = 987654,right = 987754) == [987697, 987713]\n assert candidate(left = 1,right = 1000000) == [2, 3]\n assert candidate(left = 700000,right = 710000) == [700079, 700081]\n assert candidate(left = 950,right = 1000) == [967, 971]\n assert candidate(left = 2,right = 2) == [-1, -1]\n assert candidate(left = 500000,right = 501000) == [500111, 500113]\n assert candidate(left = 560030,right = 560050) == [560039, 560047]\n assert candidate(left = 3,right = 5) == [3, 5]\n assert candidate(left = 800000,right = 800200) == [800117, 800119]\n assert candidate(left = 200,right = 300) == [227, 229]\n assert candidate(left = 999990,right = 1000010) == [-1, -1]\n assert candidate(left = 1487,right = 1601) == [1487, 1489]\n assert candidate(left = 1000000,right = 1000100) == [1000037, 1000039]\n assert candidate(left = 150000,right = 150100) == [150089, 150091]\n"}, "metadata": {"canonical_parameter_names": ["left", "right"], "leetcode_dataset_entry_point": "Solution().closestPrimes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] closestPrimes(int left, int right) {", "container": "Solution", "callable": "closestPrimes", "parameters": [{"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2525, "task_id": "categorize-box-according-to-criteria", "difficulty": "Easy", "problem_description": "Given four integers length, width, height, and mass, representing the dimensions and mass of a box, respectively, return a string representing the category of the box.\n\nThe box is \"Bulky\" if:\n\n\t\nAny of the dimensions of the box is greater or equal to 104.\nOr, the volume of the box is greater or equal to 109.\n\n\nIf the mass of the box is greater or equal to 100, it is \"Heavy\".\nIf the box is both \"Bulky\" and \"Heavy\", then its category is \"Both\".\nIf the box is neither \"Bulky\" nor \"Heavy\", then its category is \"Neither\".\nIf the box is \"Bulky\" but not \"Heavy\", then its category is \"Bulky\".\nIf the box is \"Heavy\" but not \"Bulky\", then its category is \"Heavy\".\n\nNote that the volume of the box is the product of its length, width and height.\n \nExample 1:\n\nInput: length = 1000, width = 35, height = 700, mass = 300\nOutput: \"Heavy\"\nExplanation: \nNone of the dimensions of the box is greater or equal to 104. \nIts volume = 24500000 <= 109. So it cannot be categorized as \"Bulky\".\nHowever mass >= 100, so the box is \"Heavy\".\nSince the box is not \"Bulky\" but \"Heavy\", we return \"Heavy\".\nExample 2:\n\nInput: length = 200, width = 50, height = 800, mass = 50\nOutput: \"Neither\"\nExplanation: \nNone of the dimensions of the box is greater or equal to 104.\nIts volume = 8 * 106 <= 109. So it cannot be categorized as \"Bulky\".\nIts mass is also less than 100, so it cannot be categorized as \"Heavy\" either. \nSince its neither of the two above categories, we return \"Neither\".\n \nConstraints:\n\n1 <= length, width, height <= 105\n1 <= mass <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(length = 100000,width = 100000,height = 100000,mass = 1000) == \"Both\"\n assert candidate(length = 10000,width = 10,height = 10,mass = 1) == \"Bulky\"\n assert candidate(length = 5000,width = 2000,height = 1000,mass = 50) == \"Bulky\"\n assert candidate(length = 5000,width = 2000,height = 1000,mass = 200) == \"Both\"\n assert candidate(length = 10000,width = 10000,height = 10000,mass = 1000) == \"Both\"\n assert candidate(length = 200,width = 50,height = 800,mass = 50) == \"Neither\"\n assert candidate(length = 10000,width = 10,height = 10,mass = 10) == \"Bulky\"\n assert candidate(length = 9999,width = 9999,height = 9999,mass = 100) == \"Both\"\n assert candidate(length = 1000,width = 35,height = 700,mass = 300) == \"Heavy\"\n assert candidate(length = 10,width = 10,height = 10,mass = 100) == \"Heavy\"\n assert candidate(length = 10000,width = 10000,height = 1,mass = 100) == \"Both\"\n assert candidate(length = 5000,width = 5000,height = 5000,mass = 1) == \"Bulky\"\n assert candidate(length = 10000,width = 1,height = 1,mass = 100) == \"Both\"\n assert candidate(length = 1000,width = 1000,height = 1000,mass = 1000) == \"Both\"\n assert candidate(length = 1,width = 1,height = 1,mass = 1) == \"Neither\"\n assert candidate(length = 10000,width = 10000,height = 10000,mass = 10000) == \"Both\"\n assert candidate(length = 9999,width = 9999,height = 9999,mass = 99) == \"Bulky\"\n assert candidate(length = 1000,width = 1000,height = 10,mass = 1000) == \"Heavy\"\n assert candidate(length = 10000,width = 10000,height = 10000,mass = 100) == \"Both\"\n assert candidate(length = 5000,width = 2000,height = 1,mass = 99) == \"Neither\"\n assert candidate(length = 10000,width = 10,height = 10,mass = 5) == \"Bulky\"\n assert candidate(length = 1,width = 10000,height = 1,mass = 1) == \"Bulky\"\n assert candidate(length = 1000,width = 1000,height = 1000,mass = 999) == \"Both\"\n assert candidate(length = 1,width = 100000,height = 1,mass = 1000) == \"Both\"\n assert candidate(length = 10,width = 2,height = 50000,mass = 500) == \"Both\"\n assert candidate(length = 10,width = 1000,height = 1000,mass = 100) == \"Heavy\"\n assert candidate(length = 1000,width = 10000,height = 10000,mass = 1000) == \"Both\"\n assert candidate(length = 1000,width = 10000,height = 10000,mass = 1000000) == \"Both\"\n assert candidate(length = 10000,width = 10000,height = 10000,mass = 1) == \"Bulky\"\n assert candidate(length = 1,width = 1,height = 100000,mass = 100) == \"Both\"\n assert candidate(length = 10000,width = 10000,height = 10000,mass = 99) == \"Bulky\"\n assert candidate(length = 100000,width = 10,height = 1,mass = 100) == \"Both\"\n assert candidate(length = 10000,width = 10000,height = 1000,mass = 100) == \"Both\"\n assert candidate(length = 1,width = 100000,height = 10,mass = 100) == \"Both\"\n assert candidate(length = 1000,width = 1000,height = 1000,mass = 10000000) == \"Both\"\n assert candidate(length = 10000,width = 10000,height = 1,mass = 999) == \"Both\"\n assert candidate(length = 10000,width = 9999,height = 10000,mass = 100) == \"Both\"\n assert candidate(length = 10000,width = 10000,height = 10,mass = 1000) == \"Both\"\n assert candidate(length = 1,width = 1,height = 100000,mass = 1000) == \"Both\"\n assert candidate(length = 1,width = 10000,height = 1,mass = 100) == \"Both\"\n assert candidate(length = 10000,width = 10000,height = 1000,mass = 1000000) == \"Both\"\n assert candidate(length = 500,width = 500,height = 500,mass = 500) == \"Heavy\"\n assert candidate(length = 9999,width = 9999,height = 9999,mass = 101) == \"Both\"\n assert candidate(length = 1000,width = 1000,height = 1000,mass = 101) == \"Both\"\n assert candidate(length = 1000,width = 1000,height = 1000,mass = 100) == \"Both\"\n assert candidate(length = 9999,width = 9999,height = 10,mass = 99) == \"Neither\"\n assert candidate(length = 1000,width = 10,height = 1000,mass = 100) == \"Heavy\"\n assert candidate(length = 1,width = 10000,height = 10000,mass = 1) == \"Bulky\"\n assert candidate(length = 2,width = 50000,height = 10,mass = 500) == \"Both\"\n assert candidate(length = 103,width = 103,height = 103,mass = 99) == \"Neither\"\n assert candidate(length = 1,width = 1,height = 10000,mass = 100) == \"Both\"\n assert candidate(length = 10000,width = 10000,height = 1,mass = 1) == \"Bulky\"\n assert candidate(length = 1,width = 10000,height = 10000,mass = 1000) == \"Both\"\n assert candidate(length = 10000,width = 10000,height = 1000,mass = 1000) == \"Both\"\n assert candidate(length = 1,width = 1,height = 1000000000,mass = 1) == \"Bulky\"\n assert candidate(length = 100000,width = 1,height = 1,mass = 1) == \"Bulky\"\n assert candidate(length = 10,width = 10000,height = 10000,mass = 1000) == \"Both\"\n assert candidate(length = 1000,width = 1000,height = 1,mass = 99) == \"Neither\"\n assert candidate(length = 500,width = 2000,height = 1000,mass = 300) == \"Both\"\n assert candidate(length = 100,width = 100,height = 100,mass = 1000000) == \"Heavy\"\n assert candidate(length = 1,width = 10000,height = 10000,mass = 100) == \"Both\"\n assert candidate(length = 10000,width = 1,height = 10000,mass = 1) == \"Bulky\"\n assert candidate(length = 9999,width = 10000,height = 10000,mass = 99) == \"Bulky\"\n assert candidate(length = 10000,width = 1,height = 1,mass = 1) == \"Bulky\"\n assert candidate(length = 1000,width = 1000,height = 1000,mass = 100000) == \"Both\"\n assert candidate(length = 10000,width = 10000,height = 9999,mass = 100) == \"Both\"\n assert candidate(length = 1000,width = 1000,height = 1000,mass = 1000000) == \"Both\"\n assert candidate(length = 1,width = 1000,height = 1000,mass = 99) == \"Neither\"\n assert candidate(length = 10000,width = 1,height = 10000,mass = 100) == \"Both\"\n assert candidate(length = 1000,width = 1000,height = 1000,mass = 10000) == \"Both\"\n assert candidate(length = 500,width = 500,height = 500,mass = 150) == \"Heavy\"\n assert candidate(length = 9999,width = 9999,height = 10000,mass = 99) == \"Bulky\"\n assert candidate(length = 100000,width = 1,height = 1,mass = 100) == \"Both\"\n assert candidate(length = 1000,width = 1000,height = 1000,mass = 99) == \"Bulky\"\n assert candidate(length = 5000,width = 2000,height = 1000,mass = 99) == \"Bulky\"\n assert candidate(length = 9999,width = 10000,height = 10000,mass = 100) == \"Both\"\n assert candidate(length = 100,width = 100000,height = 1,mass = 1) == \"Bulky\"\n assert candidate(length = 50000,width = 2,height = 10,mass = 500) == \"Both\"\n assert candidate(length = 1000,width = 1000,height = 10,mass = 100) == \"Heavy\"\n assert candidate(length = 1,width = 1,height = 1,mass = 99) == \"Neither\"\n assert candidate(length = 10000,width = 1,height = 1,mass = 1000) == \"Both\"\n assert candidate(length = 1,width = 10000,height = 1,mass = 1000) == \"Both\"\n assert candidate(length = 10000,width = 1,height = 1,mass = 99) == \"Bulky\"\n assert candidate(length = 1,width = 1,height = 10000,mass = 1000) == \"Both\"\n assert candidate(length = 10000,width = 100,height = 10,mass = 100) == \"Both\"\n assert candidate(length = 50000,width = 1,height = 1,mass = 1) == \"Bulky\"\n assert candidate(length = 10,width = 10,height = 10,mass = 1000) == \"Heavy\"\n assert candidate(length = 5000,width = 5000,height = 5000,mass = 50) == \"Bulky\"\n assert candidate(length = 1,width = 10000,height = 1,mass = 99) == \"Bulky\"\n assert candidate(length = 1,width = 1,height = 10000,mass = 1) == \"Bulky\"\n assert candidate(length = 10000,width = 1000,height = 10000,mass = 1000000) == \"Both\"\n assert candidate(length = 100,width = 100,height = 100,mass = 100) == \"Heavy\"\n assert candidate(length = 5000,width = 5000,height = 5000,mass = 100) == \"Both\"\n assert candidate(length = 1,width = 100000,height = 1,mass = 100) == \"Both\"\n assert candidate(length = 1,width = 10000,height = 10000,mass = 99) == \"Bulky\"\n assert candidate(length = 100000,width = 1,height = 1,mass = 1000) == \"Both\"\n assert candidate(length = 10000,width = 10,height = 10,mass = 50) == \"Bulky\"\n assert candidate(length = 9999,width = 9999,height = 9999,mass = 9999) == \"Both\"\n assert candidate(length = 1000,width = 1,height = 1000,mass = 99) == \"Neither\"\n assert candidate(length = 1,width = 1,height = 1,mass = 1000) == \"Heavy\"\n assert candidate(length = 10000,width = 9999,height = 9999,mass = 99) == \"Bulky\"\n assert candidate(length = 1,width = 1,height = 100000,mass = 1) == \"Bulky\"\n assert candidate(length = 10000,width = 1000,height = 10000,mass = 1000) == \"Both\"\n assert candidate(length = 10,width = 1,height = 100000,mass = 100) == \"Both\"\n assert candidate(length = 1,width = 100000,height = 1,mass = 1) == \"Bulky\"\n assert candidate(length = 500,width = 500,height = 500,mass = 100) == \"Heavy\"\n assert candidate(length = 9999,width = 9999,height = 1000,mass = 999) == \"Both\"\n assert candidate(length = 1,width = 1,height = 10000,mass = 99) == \"Bulky\"\n assert candidate(length = 10000,width = 10000,height = 10000,mass = 101) == \"Both\"\n assert candidate(length = 1,width = 1,height = 1,mass = 100) == \"Heavy\"\n assert candidate(length = 9999,width = 9999,height = 1,mass = 100) == \"Heavy\"\n assert candidate(length = 9999,width = 10000,height = 9999,mass = 99) == \"Bulky\"\n assert candidate(length = 10000,width = 10,height = 10000,mass = 1000) == \"Both\"\n assert candidate(length = 999,width = 999,height = 999,mass = 999) == \"Heavy\"\n"}, "metadata": {"canonical_parameter_names": ["length", "width", "height", "mass"], "leetcode_dataset_entry_point": "Solution().categorizeBox", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String categorizeBox(int length, int width, int height, int mass) {", "container": "Solution", "callable": "categorizeBox", "parameters": [{"name": "length", "type": "int"}, {"name": "width", "type": "int"}, {"name": "height", "type": "int"}, {"name": "mass", "type": "int"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2527, "task_id": "find-xor-beauty-of-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums.\nThe effective value of three indices i, j, and k is defined as ((nums[i] | nums[j]) & nums[k]).\nThe xor-beauty of the array is the XORing of the effective values of all the possible triplets of indices (i, j, k) where 0 <= i, j, k < n.\nReturn the xor-beauty of nums.\nNote that:\n\nval1 | val2 is bitwise OR of val1 and val2.\nval1 & val2 is bitwise AND of val1 and val2.\n\n \nExample 1:\n\nInput: nums = [1,4]\nOutput: 5\nExplanation: \nThe triplets and their corresponding effective values are listed below:\n- (0,0,0) with effective value ((1 | 1) & 1) = 1\n- (0,0,1) with effective value ((1 | 1) & 4) = 0\n- (0,1,0) with effective value ((1 | 4) & 1) = 1\n- (0,1,1) with effective value ((1 | 4) & 4) = 4\n- (1,0,0) with effective value ((4 | 1) & 1) = 1\n- (1,0,1) with effective value ((4 | 1) & 4) = 4\n- (1,1,0) with effective value ((4 | 4) & 1) = 0\n- (1,1,1) with effective value ((4 | 4) & 4) = 4 \nXor-beauty of array will be bitwise XOR of all beauties = 1 ^ 0 ^ 1 ^ 4 ^ 1 ^ 4 ^ 0 ^ 4 = 5.\nExample 2:\n\nInput: nums = [15,45,20,2,34,35,5,44,32,30]\nOutput: 34\nExplanation: The xor-beauty of the given array is 34.\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, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 14\n assert candidate(nums = [15, 45, 20, 2, 34, 35, 5, 44, 32, 30]) == 34\n assert candidate(nums = [1, 4]) == 5\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 26\n assert candidate(nums = [2, 3, 5, 7, 11]) == 8\n assert candidate(nums = [2, 4, 8, 16, 32]) == 62\n assert candidate(nums = [7, 14, 21, 28, 35]) == 35\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000]) == 801260736\n assert candidate(nums = [7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777]) == 446738358\n assert candidate(nums = [31, 14, 7, 3, 1]) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 0\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 1]) == 630827518\n assert candidate(nums = [1000000007, 1000000006, 1000000005, 1000000004, 1000000003, 1000000002, 1000000001, 1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993]) == 999999992\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 588\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642, 2147483641, 2147483640, 2147483639, 2147483638]) == 1\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 262136\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 699050\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303]) == 1430257664\n assert candidate(nums = [135792468, 246813579, 357924681, 468135792, 579246813, 681357924, 789246813, 892468135, 924681357, 24681357, 46813579, 68135792, 81357924, 13579246, 35792468, 57924681, 79246813, 92468135]) == 753001139\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216]) == 33553408\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [123456789, 987654321, 456789123, 321987654, 789123456]) == 445095137\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 31\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 = [987654321, 876543219, 765432198, 654321987, 543219876, 432198765, 321987654, 219876543, 198765432, 98765432, 8765432, 765432, 65432, 5432, 432, 32, 2, 1]) == 759310468\n assert candidate(nums = [531911163, 381216167, 84627534, 595912280, 691055427, 374083484, 163888428, 741109182, 830024027, 981830112]) == 1055643324\n assert candidate(nums = [123456789, 987654321, 246813579, 864209753, 135792468, 753951876, 321654987, 654987321, 987321654]) == 715524962\n assert candidate(nums = [1098765432, 2098765431, 3098765430, 4098765429, 5098765428, 6098765427, 7098765426, 8098765425, 9098765424, 1198765423, 2198765422, 3198765421, 4198765420, 5198765419, 6198765418]) == 11462454905\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1047552\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 111213141516171819, 222324252627282930, 333435363738394041, 444546474849505152, 555657585960616263]) == 550309707244680156\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 974967\n assert candidate(nums = [1000000007, 1000000009, 1000000011, 1000000013, 1000000015]) == 1000000007\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004]) == 1000000004\n assert candidate(nums = [987654321, 876543219, 765432198, 654321987, 543219876, 432198765, 321987654, 219876543, 198765432]) == 674225103\n assert candidate(nums = [987654321, 876543219, 765432109, 654321099, 543210989, 432109879, 321098769, 210987659, 109876549, 98765439]) == 553747934\n assert candidate(nums = [12345, 67890, 13579, 24680, 97531, 86420, 75310, 64200, 53100, 42000, 31000, 20000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000]) == 49509\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 682\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 8184\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [13, 29, 47, 61, 73, 89, 101, 127, 149, 167]) == 58\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111, 9999999, 8888888, 7777777, 6666666, 5555555, 4444444, 3333333, 2222222, 1111111, 999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 596022080\n assert candidate(nums = [233, 344, 567, 789, 901, 123, 456, 789, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 433\n assert candidate(nums = [5, 17, 34, 68, 136, 272, 544, 1088, 2176, 4352]) == 7690\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579]) == 992719227\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888]) == 596034980\n assert candidate(nums = [987654321, 987654320, 987654319, 987654318, 987654317, 987654316, 987654315, 987654314, 987654313, 987654312]) == 1\n assert candidate(nums = [1000000007, 999999937, 899999937, 799999937, 699999937, 599999937, 499999937, 399999937, 299999937, 199999937]) == 6360006\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071]) == 1431699455\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930, 313233, 343536, 373839, 404142, 434445]) == 211634\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 42\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000, 10000000000]) == 1848004096\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 32767\n assert candidate(nums = [1000000007, 999999937, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 503538630\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216]) == 33554431\n assert candidate(nums = [89, 67, 45, 23, 1, 24, 46, 68, 90, 11, 33, 55, 77, 99, 22, 44, 66, 88, 10, 30]) == 14\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930]) == 524095\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151]) == 1432354815\n assert candidate(nums = [7, 5, 3, 1, 9, 11, 13, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [13, 27, 41, 55, 69, 83, 97, 111, 125, 139, 153, 167, 181, 195, 209]) == 127\n assert candidate(nums = [17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 69\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 682\n assert candidate(nums = [255, 511, 767, 1023, 1279, 1535, 1791, 2047, 2303, 2559]) == 256\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543]) == 618827735\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 2096128\n assert candidate(nums = [135792468, 246813579, 357924681, 468135792, 579246813, 681357924, 792468135, 813579246, 924681357]) == 710527387\n assert candidate(nums = [123456789, 987654321, 111222333, 444555666, 777888999]) == 252083948\n assert candidate(nums = [13, 29, 47, 61, 73, 89, 101, 113, 131, 137, 151, 163, 173, 191, 197, 211, 223, 229, 233, 239]) == 0\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000]) == 9566005760\n assert candidate(nums = [987654321, 987654322, 987654323, 987654324, 987654325, 987654326, 987654327, 987654328, 987654329]) == 987654321\n assert candidate(nums = [1099511627776, 549755813888, 274877906944, 137438953472, 68719476736, 34359738368, 17179869184, 8589934592, 4294967296, 2147483648]) == 2196875771904\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1]) == 170\n assert candidate(nums = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005, 500000006, 500000007, 500000008, 500000009]) == 1\n assert candidate(nums = [123456789, 234567891, 345678912, 456789123, 567891234, 678912345, 789123456, 891234567, 912345678, 123456789]) == 662886050\n assert candidate(nums = [234567890, 345678901, 456789012, 567890123, 678901234, 789012345]) == 619883187\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43]) == 47\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [123456789, 987654321, 1122334455, 5544332211]) == 5185673440\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]) == 0\n assert candidate(nums = [101010101, 202020202, 303030303, 404040404, 505050505, 606060606, 707070707, 808080808, 909090909]) == 372268965\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2047\n assert candidate(nums = [1048575, 2097150, 3145725, 4194300, 5242875, 6291450, 7340025, 8388500, 9437075, 10485650]) == 1048685\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 1112131415]) == 2036495916\n assert candidate(nums = [1337, 2674, 4011, 5348, 6685, 8022, 9359, 10696, 12033, 13370]) == 1843\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 630827519\n assert candidate(nums = [999999937, 999999938, 999999939, 999999940, 999999941, 999999942, 999999943, 999999944, 999999945, 999999946]) == 11\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2047\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 = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543, 98765432]) == 553747887\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000]) == 1041115904\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 503538687\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().xorBeauty", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int xorBeauty(int[] nums) {", "container": "Solution", "callable": "xorBeauty", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2528, "task_id": "maximize-the-minimum-powered-city", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array stations of length n, where stations[i] represents the number of power stations in the ith city.\nEach power station can provide power to every city in a fixed range. In other words, if the range is denoted by r, then a power station at city i can provide power to all cities j such that |i - j| <= r and 0 <= i, j <= n - 1.\n\nNote that |x| denotes absolute value. For example, |7 - 5| = 2 and |3 - 10| = 7.\n\nThe power of a city is the total number of power stations it is being provided power from.\nThe government has sanctioned building k more power stations, each of which can be built in any city, and have the same range as the pre-existing ones.\nGiven the two integers r and k, return the maximum possible minimum power of a city, if the additional power stations are built optimally.\nNote that you can build the k power stations in multiple cities.\n \nExample 1:\n\nInput: stations = [1,2,4,5,0], r = 1, k = 2\nOutput: 5\nExplanation: \nOne of the optimal ways is to install both the power stations at city 1. \nSo stations will become [1,4,4,5,0].\n- City 0 is provided by 1 + 4 = 5 power stations.\n- City 1 is provided by 1 + 4 + 4 = 9 power stations.\n- City 2 is provided by 4 + 4 + 5 = 13 power stations.\n- City 3 is provided by 5 + 4 = 9 power stations.\n- City 4 is provided by 5 + 0 = 5 power stations.\nSo the minimum power of a city is 5.\nSince it is not possible to obtain a larger power, we return 5.\n\nExample 2:\n\nInput: stations = [4,4,4,4], r = 0, k = 3\nOutput: 4\nExplanation: \nIt can be proved that we cannot make the minimum power of a city greater than 4.\n\n \nConstraints:\n\nn == stations.length\n1 <= n <= 105\n0 <= stations[i] <= 105\n0 <= r <= n - 1\n0 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stations = [1, 2, 4, 5, 0],r = 1,k = 2) == 5\n assert candidate(stations = [0, 0, 0, 0, 0],r = 2,k = 5) == 5\n assert candidate(stations = [0, 0, 0, 0, 0],r = 2,k = 10) == 10\n assert candidate(stations = [1, 3, 5, 7, 9],r = 2,k = 5) == 14\n assert candidate(stations = [3, 3, 3, 3, 3],r = 1,k = 5) == 8\n assert candidate(stations = [10, 20, 30, 40, 50],r = 3,k = 20) == 120\n assert candidate(stations = [1, 0, 1, 0, 1, 0, 1],r = 2,k = 3) == 3\n assert candidate(stations = [0, 0, 0, 0],r = 2,k = 5) == 5\n assert candidate(stations = [1, 0, 0, 0, 1],r = 2,k = 2) == 3\n assert candidate(stations = [0, 0, 0, 0],r = 2,k = 10) == 10\n assert candidate(stations = [10, 20, 30, 40, 50],r = 3,k = 100) == 200\n assert candidate(stations = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],r = 3,k = 15) == 27\n assert candidate(stations = [5, 5, 5, 5, 5],r = 2,k = 5) == 20\n assert candidate(stations = [10, 20, 30, 40, 50],r = 2,k = 10) == 70\n assert candidate(stations = [1, 0, 3, 0, 2],r = 2,k = 3) == 7\n assert candidate(stations = [4, 4, 4, 4],r = 0,k = 3) == 4\n assert candidate(stations = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],r = 3,k = 15) == 27\n assert candidate(stations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],r = 5,k = 150) == 360\n assert candidate(stations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],r = 5,k = 300) == 480\n assert candidate(stations = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],r = 4,k = 10) == 5\n assert candidate(stations = [8, 9, 8, 9, 8, 9, 8, 9, 8, 9],r = 1,k = 10) == 22\n assert candidate(stations = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],r = 5,k = 100) == 68\n assert candidate(stations = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],r = 1,k = 4) == 2\n assert candidate(stations = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],r = 9,k = 20) == 20\n assert candidate(stations = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],r = 0,k = 5) == 1\n assert candidate(stations = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],r = 4,k = 25) == 12\n assert candidate(stations = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],r = 1,k = 50) == 37\n assert candidate(stations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],r = 5,k = 300) == 405\n assert candidate(stations = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],r = 5,k = 30) == 45\n assert candidate(stations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],r = 0,k = 50) == 36\n assert candidate(stations = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],r = 4,k = 20) == 10\n assert candidate(stations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],r = 1,k = 500) == 262\n assert candidate(stations = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],r = 1,k = 50) == 25\n assert candidate(stations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],r = 5,k = 5000) == 7100\n assert candidate(stations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],r = 3,k = 150) == 185\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],r = 4,k = 50) == 52\n assert candidate(stations = [1, 3, 0, 2, 5, 4, 2, 1, 0, 5],r = 2,k = 10) == 10\n assert candidate(stations = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],r = 2,k = 50000) == 41500\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],r = 1,k = 45) == 25\n assert candidate(stations = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],r = 10,k = 50) == 61\n assert candidate(stations = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],r = 5,k = 10) == 11\n assert candidate(stations = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0],r = 3,k = 50) == 35\n assert candidate(stations = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],r = 5,k = 1000000) == 1600000\n assert candidate(stations = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],r = 4,k = 30) == 60\n assert candidate(stations = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],r = 3,k = 50) == 40\n assert candidate(stations = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],r = 4,k = 100) == 60\n assert candidate(stations = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],r = 2,k = 10) == 5\n assert candidate(stations = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],r = 9,k = 10) == 15\n assert candidate(stations = [1, 0, 0, 0, 0, 1],r = 2,k = 3) == 2\n assert candidate(stations = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0],r = 2,k = 10) == 12\n assert candidate(stations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],r = 2,k = 100) == 145\n assert candidate(stations = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],r = 1,k = 5) == 2\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],r = 10,k = 500) == 566\n assert candidate(stations = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],r = 3,k = 150) == 250\n assert candidate(stations = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],r = 6,k = 10) == 6\n assert candidate(stations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],r = 4,k = 1000) == 900\n assert candidate(stations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],r = 4,k = 250) == 400\n assert candidate(stations = [50, 40, 30, 20, 10],r = 1,k = 50) == 80\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],r = 5,k = 150) == 138\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],r = 3,k = 100) == 80\n assert candidate(stations = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],r = 2,k = 60) == 120\n assert candidate(stations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],r = 4,k = 500) == 2000\n assert candidate(stations = [100000, 0, 100000, 0, 100000, 0, 100000],r = 3,k = 500000) == 700000\n assert candidate(stations = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],r = 4,k = 30) == 37\n assert candidate(stations = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],r = 5,k = 5000) == 11000\n assert candidate(stations = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],r = 2,k = 50) == 39\n assert candidate(stations = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],r = 1,k = 10) == 13\n assert candidate(stations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],r = 4,k = 250) == 400\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],r = 0,k = 45) == 10\n assert candidate(stations = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],r = 1,k = 10) == 3\n assert candidate(stations = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],r = 2,k = 25) == 18\n assert candidate(stations = [100, 0, 100, 0, 100],r = 2,k = 50) == 250\n assert candidate(stations = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],r = 1,k = 100) == 125\n assert candidate(stations = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],r = 4,k = 10) == 10\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],r = 2,k = 20) == 26\n assert candidate(stations = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],r = 5,k = 100) == 350\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],r = 7,k = 100) == 134\n assert candidate(stations = [90, 80, 70, 60, 50, 40, 30, 20, 10, 0],r = 3,k = 100) == 160\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],r = 1,k = 100) == 40\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],r = 1,k = 10) == 12\n assert candidate(stations = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],r = 2,k = 30) == 28\n assert candidate(stations = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],r = 3,k = 5) == 3\n assert candidate(stations = [5, 15, 25, 35, 45, 55],r = 1,k = 100) == 110\n assert candidate(stations = [1, 0, 0, 0, 1],r = 2,k = 3) == 4\n assert candidate(stations = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],r = 8,k = 20) == 19\n assert candidate(stations = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],r = 1,k = 10) == 2\n assert candidate(stations = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],r = 4,k = 20000) == 35000\n assert candidate(stations = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],r = 1,k = 5) == 8\n assert candidate(stations = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],r = 4,k = 50) == 25\n assert candidate(stations = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],r = 3,k = 30) == 33\n assert candidate(stations = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],r = 3,k = 150) == 125\n assert candidate(stations = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],r = 2,k = 20) == 26\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],r = 4,k = 20) == 35\n assert candidate(stations = [0, 0, 0, 0, 0, 0],r = 1,k = 10) == 5\n assert candidate(stations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],r = 5,k = 200) == 305\n assert candidate(stations = [1, 0, 0, 0, 1],r = 2,k = 2) == 3\n assert candidate(stations = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],r = 2,k = 20) == 10\n assert candidate(stations = [9, 7, 5, 3, 1, 0, 2, 4, 6, 8],r = 4,k = 25) == 35\n assert candidate(stations = [1, 3, 2, 5, 7, 8, 6, 4, 9, 0],r = 2,k = 10) == 14\n assert candidate(stations = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],r = 5,k = 20) == 20\n assert candidate(stations = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],r = 1,k = 5) == 2\n assert candidate(stations = [10, 20, 30, 40, 50, 40, 30, 20, 10],r = 2,k = 50) == 85\n assert candidate(stations = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],r = 5,k = 20) == 43\n assert candidate(stations = [100, 0, 100, 0, 100, 0, 100],r = 2,k = 200) == 300\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],r = 5,k = 25) == 46\n assert candidate(stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],r = 3,k = 100) == 73\n assert candidate(stations = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0],r = 4,k = 100) == 300\n assert candidate(stations = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50],r = 3,k = 100) == 190\n assert candidate(stations = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],r = 0,k = 500) == 100\n assert candidate(stations = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],r = 9,k = 50) == 35\n assert candidate(stations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],r = 4,k = 500) == 2000\n assert candidate(stations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],r = 5,k = 2000) == 4100\n assert candidate(stations = [1, 3, 2, 5, 4, 6, 7, 8, 9, 0],r = 2,k = 20) == 21\n assert candidate(stations = [0, 0, 0, 0, 0],r = 1,k = 5) == 2\n assert candidate(stations = [9, 8, 7, 6, 5, 4, 3, 2, 1],r = 3,k = 25) == 32\n assert candidate(stations = [1, 3, 2, 1, 4, 1, 2, 3],r = 2,k = 5) == 8\n assert candidate(stations = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],r = 9,k = 20) == 20\n assert candidate(stations = [1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000],r = 1,k = 10000) == 3751\n"}, "metadata": {"canonical_parameter_names": ["stations", "r", "k"], "leetcode_dataset_entry_point": "Solution().maxPower", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxPower(int[] stations, int r, int k) {", "container": "Solution", "callable": "maxPower", "parameters": [{"name": "stations", "type": "int[]"}, {"name": "r", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2529, "task_id": "maximum-count-of-positive-integer-and-negative-integer", "difficulty": "Easy", "problem_description": "Given an array nums sorted in non-decreasing order, return the maximum between the number of positive integers and the number of negative integers.\n\nIn other words, if the number of positive integers in nums is pos and the number of negative integers is neg, then return the maximum of pos and neg.\n\nNote that 0 is neither positive nor negative.\n \nExample 1:\n\nInput: nums = [-2,-1,-1,1,2,3]\nOutput: 3\nExplanation: There are 3 positive integers and 3 negative integers. The maximum count among them is 3.\n\nExample 2:\n\nInput: nums = [-3,-2,-1,0,0,1,2]\nOutput: 3\nExplanation: There are 2 positive integers and 3 negative integers. The maximum count among them is 3.\n\nExample 3:\n\nInput: nums = [5,20,66,1314]\nOutput: 4\nExplanation: There are 4 positive integers and 0 negative integers. The maximum count among them is 4.\n\n \nConstraints:\n\n1 <= nums.length <= 2000\n-2000 <= nums[i] <= 2000\nnums is sorted in a non-decreasing order.\n\n \nFollow up: Can you solve the problem in O(log(n)) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [-2, -1, -1, 1, 2, 3]) == 3\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0]) == 10\n assert candidate(nums = [5, 20, 66, 1314]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [-1000, -500, -250, -100, -50, -25, -10, -5, -2, -1, 0, 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000]) == 10\n assert candidate(nums = [-10, -5, -1, -1, 0, 0, 1, 2, 3, 5, 10]) == 5\n assert candidate(nums = [-5, -3, -1, 0, 2, 4, 6]) == 3\n assert candidate(nums = [-5, -4, -3, -2, -1]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [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 = [-5, -3, -1, 0, 1, 2, 4]) == 3\n assert candidate(nums = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000]) == 7\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-1000, -500, 0, 500, 1000]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [-3, -2, -1, 0, 0, 1, 2]) == 3\n assert candidate(nums = [-10, -5, -1, 0, 1, 5, 10]) == 3\n assert candidate(nums = [-2000, -1000, -500, -250, -100, -50, -25, -10, -5, -2, -1, 0, 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 1500, 2000]) == 12\n assert candidate(nums = [-5, -4, -3, 0, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [-10, -5, -1, -1, 0, 0, 1, 2, 3, 5]) == 4\n assert candidate(nums = [-1, 0, 1]) == 1\n assert candidate(nums = [-1, 0, 1]) == 1\n assert candidate(nums = [-2, -2, -2, 0, 1, 1, 1]) == 3\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]) == 1\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = [-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 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [-2000, -1999, -1998, -1997, -1996, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == 10\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\n assert candidate(nums = [-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, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 50\n assert candidate(nums = [-2000, -1500, -1000, -500, -250, -125, -62, -31, -15, -7, -3, -1, 0, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000, 1500, 2000]) == 12\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\n assert candidate(nums = [-1000, -900, -800, -700, -600, -500, -400, -300, -200, -100, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [-1500, -1000, -500, -100, -10, -1, 0, 1, 10, 100, 500, 1000, 1500]) == 6\n assert candidate(nums = [-100, -50, -25, -10, -5, 0, 5, 10, 25, 50, 100]) == 5\n assert candidate(nums = [-100, -50, -25, -10, -5, 0, 5, 10, 25, 50, 100, 150, 175, 190, 195, 200]) == 10\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, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000]) == 7\n assert candidate(nums = [-1500, -1250, -1000, -750, -500, -250, 0, 250, 500, 750, 1000, 1250, 1500]) == 6\n assert candidate(nums = [-2000, 0, 2000]) == 1\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, 0, 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]) == 51\n assert candidate(nums = [-1000, -500, -250, -125, -62, -31, -15, -7, -3, -1, 0, 0, 0, 0, 0, 0, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]) == 10\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, 0, 95, 96, 97, 98, 99, 100]) == 6\n assert candidate(nums = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [-1000, -500, -250, -100, -50, -25, -10, -5, -2, -1, 0, 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000]) == 10\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 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]) == 10\n assert candidate(nums = [-2000, -1999, -1998, 0, 0, 0, 1999, 2000]) == 3\n assert candidate(nums = [-1000, -999, -998, -997, -996, -995, -994, -993, -992, -991, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [-1000, -900, -800, -700, -600, -500, -400, -300, -200, -100, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [-2000, -1500, -1000, -750, -500, -250, 0, 250, 500, 750, 1000, 1500, 2000]) == 6\n assert candidate(nums = [-50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50]) == 5\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, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [-1000, 0, 1000]) == 1\n assert candidate(nums = [-1, 0, 0, 0, 0, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [-1000, -500, -250, -125, -62, -31, -15, -7, -3, -1, 0, 0, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]) == 10\n assert candidate(nums = [-2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 10\n assert candidate(nums = [-2000, -1999, -1998, -1997, -1996, -1995, -1994, -1993, -1992, -1991, -1990, -1989, -1988, -1987, -1986, -1985, -1984, -1983, -1982, -1981, -1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [-500, -400, -300, -200, -100, 0, 100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10\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, 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]) == 100\n assert candidate(nums = [-1000, -500, -250, -125, -62, -31, -15, -7, -3, -1, 0, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 17\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, 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]) == 20\n assert candidate(nums = [-2000, -1500, -1000, -500, -1, 0, 1, 500, 1000, 1500, 2000]) == 5\n assert candidate(nums = [-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, 1]) == 10\n assert candidate(nums = [-1000, -500, -250, -125, -62, -31, -15, -7, -3, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]) == 10\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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\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, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [-2000, -1500, -1000, -500, -100, -50, -10, -5, -2, -1, 0, 1, 2, 5, 10, 50, 100, 500, 1000, 1500, 2000]) == 10\n assert candidate(nums = [-500, -250, -100, -50, -25, -10, 0, 10, 25, 50, 100, 250, 500]) == 6\n assert candidate(nums = [-2000, -1999, -1998, -1997, 1998, 1999, 2000]) == 4\n assert candidate(nums = [-1999, -1998, -1997, -1996, -1995, 0, 1995, 1996, 1997, 1998, 1999]) == 5\n assert candidate(nums = [-2000, -1999, -1998, -1997, -1996, -1995, -1994, -1993, -1992, -1991, -1990, -1989, -1988, -1987, -1986, -1985, -1984, -1983, -1982, -1981, 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]) == 30\n assert candidate(nums = [-1000, -500, -250, -125, -62, -31, -15, -7, -3, -1, 0, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]) == 10\n assert candidate(nums = [-2000, -1999, -1998, -1997, -1996, -1995, -1994, -1993, -1992, -1991, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [-2000, -2000, -1000, -500, 0, 0, 0, 0, 0, 0, 500, 1000, 2000, 2000, 2000, 2000, 2000, 2000]) == 8\n assert candidate(nums = [-2000, -1999, -1998, -1000, -1, 0, 1, 1000, 1999, 2000]) == 5\n assert candidate(nums = [-2000, -1500, -1000, -500, -250, -100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100, 250, 500, 1000, 1500, 2000]) == 11\n assert candidate(nums = [-50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == 14\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, 0, 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]) == 20\n assert candidate(nums = [-2000, -1999, -1998, -1997, -1996, -1995, -1994, -1993, -1992, -1991, -1990, -1989, -1988, -1987, -1986, -1985, -1984, -1983, -1982, -1981, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000]) == 20\n assert candidate(nums = [-2000, -1500, -1000, -500, 0, 500, 1000, 1500, 2000]) == 4\n assert candidate(nums = [-15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 10\n assert candidate(nums = [-2000, -1500, -1000, -500, -250, -100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100, 250, 500, 1000, 1500, 2000, 2000, 2000, 2000, 2000]) == 15\n assert candidate(nums = [-2000, -1999, -1998, -1997, -1996, -1995, -1994, -1993, -1992, -1991, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000]) == 10\n assert candidate(nums = [-1000, -999, -998, -997, 0, 0, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumCount(int[] nums) {", "container": "Solution", "callable": "maximumCount", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2530, "task_id": "maximal-score-after-applying-k-operations", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and an integer k. You have a starting score of 0.\nIn one operation:\n\nchoose an index i such that 0 <= i < nums.length,\nincrease your score by nums[i], and\nreplace nums[i] with ceil(nums[i] / 3).\n\nReturn the maximum possible score you can attain after applying exactly k operations.\nThe ceiling function ceil(val) is the least integer greater than or equal to val.\n \nExample 1:\n\nInput: nums = [10,10,10,10,10], k = 5\nOutput: 50\nExplanation: Apply the operation to each array element exactly once. The final score is 10 + 10 + 10 + 10 + 10 = 50.\n\nExample 2:\n\nInput: nums = [1,10,3,3,3], k = 3\nOutput: 17\nExplanation: You can do the following operations:\nOperation 1: Select i = 1, so nums becomes [1,4,3,3,3]. Your score increases by 10.\nOperation 2: Select i = 1, so nums becomes [1,2,3,3,3]. Your score increases by 4.\nOperation 3: Select i = 2, so nums becomes [1,2,1,3,3]. Your score increases by 3.\nThe final score is 10 + 4 + 3 = 17.\n\n \nConstraints:\n\n1 <= nums.length, k <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [9, 9, 9, 9, 9],k = 4) == 36\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 6) == 30\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 1) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n assert candidate(nums = [10, 10, 10, 10, 10],k = 5) == 50\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 50\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 9\n assert candidate(nums = [5, 6, 7, 8, 9],k = 4) == 30\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 3) == 3000000000\n assert candidate(nums = [1, 10, 3, 3, 3],k = 3) == 17\n assert candidate(nums = [9, 9, 9, 9, 9],k = 1) == 9\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 7) == 37\n assert candidate(nums = [9, 8, 7, 6, 5],k = 4) == 30\n assert candidate(nums = [9, 7, 5, 3, 1],k = 4) == 24\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666],k = 50000) == 6500049939\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 20) == 1452\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 59\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 5) == 120\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 400\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],k = 5) == 4333333330\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 584\n assert candidate(nums = [333333333, 666666666, 999999999, 1000000000, 1],k = 5) == 3333333332\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995],k = 3) == 2999999994\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 = 20) == 20\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 20\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120],k = 15) == 799\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 5) == 2250000001\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 15) == 369\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333],k = 5) == 1995884772\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 1, 1, 1],k = 10) == 271\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 15) == 291\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 7) == 98\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 11) == 47\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 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],k = 20) == 227\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000],k = 3) == 1200000000\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 15) == 46635\n assert candidate(nums = [123456789, 987654321, 135792468, 864208642, 246813579],k = 5) == 2715964197\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 5) == 5000000000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 748\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 10) == 2754\n assert candidate(nums = [100, 99, 98, 97, 96],k = 10) == 655\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == 1050\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 20) == 2168\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 7) == 490\n assert candidate(nums = [8, 6, 4, 2, 1],k = 5) == 23\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],k = 10) == 6333333329\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 = 25) == 100\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119],k = 20) == 1335\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 = 20) == 1127\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 = 25) == 24803\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) == 10\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666],k = 5) == 4333333330\n assert candidate(nums = [123456789, 987654321, 456789123, 321987654, 654321987, 789123456, 891234567, 234567891, 567891234, 912345678],k = 15) == 7416772992\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 20) == 13333333340\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 10) == 292\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 10) == 1652386837\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 10) == 5834\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 692\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],k = 15) == 372\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == 21\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 10) == 1378\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 15) == 1281\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 5) == 375\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 7) == 91\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],k = 10) == 6666666670\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 = 30) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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) == 100\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 4000\n assert candidate(nums = [100, 200, 300, 400, 500],k = 5) == 1567\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610],k = 10) == 1984\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 100000) == 7500099960\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 10) == 9999955\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 10) == 303\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16],k = 30) == 269\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 112233445, 543216789, 987654321, 123456789],k = 8) == 3740639955\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555],k = 5) == 3888888885\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 48\n assert candidate(nums = [15, 21, 33, 47, 61, 75, 89, 103, 117, 131],k = 7) == 623\n assert candidate(nums = [987654321, 876543219, 765432198, 654321987, 543219876],k = 50000) == 5740807347\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 109\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 9) == 1648271610\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 5) == 4999999990\n assert candidate(nums = [9, 7, 5, 3, 1, 9, 7, 5, 3, 1, 9, 7, 5, 3, 1],k = 15) == 81\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 10) == 10000000000\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 = 20) == 675\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxKelements", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxKelements(int[] nums, int k) {", "container": "Solution", "callable": "maxKelements", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2531, "task_id": "make-number-of-distinct-characters-equal", "difficulty": "Medium", "problem_description": "You are given two 0-indexed strings word1 and word2.\nA move consists of choosing two indices i and j such that 0 <= i < word1.length and 0 <= j < word2.length and swapping word1[i] with word2[j].\nReturn true if it is possible to get the number of distinct characters in word1 and word2 to be equal with exactly one move. Return false otherwise.\n \nExample 1:\n\nInput: word1 = \"ac\", word2 = \"b\"\nOutput: false\nExplanation: Any pair of swaps would yield two distinct characters in the first string, and one in the second string.\n\nExample 2:\n\nInput: word1 = \"abcc\", word2 = \"aab\"\nOutput: true\nExplanation: We swap index 2 of the first string with index 0 of the second string. The resulting strings are word1 = \"abac\" and word2 = \"cab\", which both have 3 distinct characters.\n\nExample 3:\n\nInput: word1 = \"abcde\", word2 = \"fghij\"\nOutput: true\nExplanation: Both resulting strings will have 5 distinct characters, regardless of which indices we swap.\n\n \nConstraints:\n\n1 <= word1.length, word2.length <= 105\nword1 and word2 consist of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == True\n assert candidate(word1 = \"xyz\",word2 = \"zyx\") == True\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == True\n assert candidate(word1 = \"ac\",word2 = \"b\") == False\n assert candidate(word1 = \"unique\",word2 = \"letters\") == True\n assert candidate(word1 = \"abcc\",word2 = \"aab\") == True\n assert candidate(word1 = \"aabb\",word2 = \"ccdd\") == True\n assert candidate(word1 = \"hello\",word2 = \"world\") == True\n assert candidate(word1 = \"ab\",word2 = \"cd\") == True\n assert candidate(word1 = \"xyz\",word2 = \"xyz\") == True\n assert candidate(word1 = \"abcd\",word2 = \"efgh\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"xyz\") == False\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == True\n assert candidate(word1 = \"same\",word2 = \"same\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"xxxyyzz\") == True\n assert candidate(word1 = \"aaaa\",word2 = \"bbbb\") == True\n assert candidate(word1 = \"qrstuvwxyz\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(word1 = \"single\",word2 = \"letter\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"missouri\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"penelope\") == True\n assert candidate(word1 = \"xyzz\",word2 = \"zzxx\") == True\n assert candidate(word1 = \"aaaaaaa\",word2 = \"bbbbbbb\") == True\n assert candidate(word1 = \"oneonetwo\",word2 = \"twotwoone\") == True\n assert candidate(word1 = \"uniquecharacters\",word2 = \"distinctcharacters\") == True\n assert candidate(word1 = \"aaaaabbbbbaaaa\",word2 = \"cccccbccccbcccc\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"abcdefghijlkmnopqrstuvwxyz\") == True\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"aabbccddeeff\") == True\n assert candidate(word1 = \"repeatedletters\",word2 = \"differentletters\") == True\n assert candidate(word1 = \"unique\",word2 = \"distinct\") == True\n assert candidate(word1 = \"aaaaabbbbbccccc\",word2 = \"dddddeeeeeffffff\") == True\n assert candidate(word1 = \"onetwothreefour\",word2 = \"five\") == False\n assert candidate(word1 = \"almost\",word2 = \"almost\") == True\n assert candidate(word1 = \"aaaabbbb\",word2 = \"cccddd\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"bacbabacbacbacb\") == False\n assert candidate(word1 = \"aaaaabbbb\",word2 = \"ccccc\") == False\n assert candidate(word1 = \"abcd\",word2 = \"efghijklmnopqrstuvwxyz\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvttrrssppoonnmmllkkjjiihhggffeeddccbbaa\") == False\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxy\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"samechars\",word2 = \"samechars\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == True\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnopqrstuv\") == False\n assert candidate(word1 = \"longerstringwithrepeatedcharacters\",word2 = \"short\") == False\n assert candidate(word1 = \"xyz\",word2 = \"zyxwvut\") == False\n assert candidate(word1 = \"abcdefgh\",word2 = \"hgfedcba\") == True\n assert candidate(word1 = \"abcdef\",word2 = \"ghijklmnopqrstuvwxyz\") == False\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnop\") == False\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"bcadcbadcbadcbc\") == True\n assert candidate(word1 = \"xyxzyzxzyx\",word2 = \"zyxzyzxzyz\") == True\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaabcdabcd\") == True\n assert candidate(word1 = \"xyzz\",word2 = \"xxxyyyzzzz\") == True\n assert candidate(word1 = \"abracadabra\",word2 = \"alakazam\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijj\",word2 = \"zzzzzyyyxxwwvvuuttssrrqqppoonnmmllijkkihgfedcba\") == False\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"zzzzzzzzzzzzzzzzz\") == False\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"abcabcabcabc\") == True\n assert candidate(word1 = \"aaaaaa\",word2 = \"bbbbbb\") == True\n assert candidate(word1 = \"almost\",word2 = \"equal\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"defdefdef\") == True\n assert candidate(word1 = \"ababababab\",word2 = \"bababababa\") == True\n assert candidate(word1 = \"almostthesame\",word2 = \"almostthesamee\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"mnopqrstuv\") == True\n assert candidate(word1 = \"zzzzzzzzzzzz\",word2 = \"aaaaaaaaaaab\") == True\n assert candidate(word1 = \"almostthesame\",word2 = \"almostthesame\") == True\n assert candidate(word1 = \"xyzz\",word2 = \"xyz\") == True\n assert candidate(word1 = \"thisisaverylongwordwithrepeatedcharacters\",word2 = \"anotherlongwordwithdifferentcharacters\") == True\n assert candidate(word1 = \"unique\",word2 = \"words\") == True\n assert candidate(word1 = \"unique\",word2 = \"characters\") == False\n assert candidate(word1 = \"aabbcc\",word2 = \"aabbcd\") == True\n assert candidate(word1 = \"abcdef\",word2 = \"ghijkl\") == True\n assert candidate(word1 = \"thisisaverylongword\",word2 = \"whichhasmanycharacters\") == False\n assert candidate(word1 = \"mnopqr\",word2 = \"rstuvw\") == True\n assert candidate(word1 = \"aaaaaaaabbbbbbb\",word2 = \"ccccccccddddd\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"louisiana\") == False\n assert candidate(word1 = \"aabbcceeddee\",word2 = \"fghhiijjkk\") == True\n assert candidate(word1 = \"abcdefghijklmnop\",word2 = \"qrstuvwxyz\") == False\n assert candidate(word1 = \"aaaaabbbbcccc\",word2 = \"bbbbccccdddd\") == True\n assert candidate(word1 = \"aaaaaaaa\",word2 = \"bbbbbbbb\") == True\n assert candidate(word1 = \"aaaaaabbbbbcccccdddddeeeee\",word2 = \"eeeeeaaaaabbbbbcccccddddd\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"pennsylvania\") == False\n assert candidate(word1 = \"xyzz\",word2 = \"zzxy\") == True\n assert candidate(word1 = \"aabbccdd\",word2 = \"efgghhii\") == True\n assert candidate(word1 = \"aaaaabbbbbcccccdddddeeeee\",word2 = \"fffffggggghhhhhiiiii\") == False\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijklmnop\") == True\n assert candidate(word1 = \"repeatrepeat\",word2 = \"repeatrepeat\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"ddeeff\") == True\n assert candidate(word1 = \"abcdefghijk\",word2 = \"klmnopqrstu\") == True\n assert candidate(word1 = \"aabbc\",word2 = \"ccdde\") == True\n assert candidate(word1 = \"complex\",word2 = \"inputs\") == True\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaabcdabdc\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzyyxxwwvvuuttoosssrrqqppoonnmlkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"one\",word2 = \"twothreefour\") == False\n assert candidate(word1 = \"xyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(word1 = \"xyzz\",word2 = \"yzxx\") == True\n assert candidate(word1 = \"singlechar\",word2 = \"different\") == False\n assert candidate(word1 = \"aabbcc\",word2 = \"ddeeffgghhiijj\") == False\n assert candidate(word1 = \"abcdefg\",word2 = \"abcdefg\") == True\n assert candidate(word1 = \"characters\",word2 = \"words\") == False\n assert candidate(word1 = \"mississippi\",word2 = \"banana\") == True\n assert candidate(word1 = \"hellohello\",word2 = \"worldworld\") == True\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"ggffeeddccbaaa\") == True\n assert candidate(word1 = \"python\",word2 = \"programming\") == False\n assert candidate(word1 = \"aaaaaa\",word2 = \"bbbbbbbbb\") == True\n assert candidate(word1 = \"aaaaaaaaaa\",word2 = \"bbbbbbbbbb\") == True\n assert candidate(word1 = \"xyzzxyzz\",word2 = \"mnopmnop\") == False\n assert candidate(word1 = \"mississippi\",word2 = \"elephant\") == False\n assert candidate(word1 = \"qqqq\",word2 = \"pppq\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"xxxyyy\") == False\n assert candidate(word1 = \"aabbcc\",word2 = \"bbccdd\") == True\n assert candidate(word1 = \"zzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"a\",word2 = \"b\") == True\n assert candidate(word1 = \"aabbaa\",word2 = \"aabbaa\") == True\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"defdefdefdef\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"abc\") == True\n assert candidate(word1 = \"aabbbcc\",word2 = \"dddeeefff\") == True\n assert candidate(word1 = \"abacabadaba\",word2 = \"acaacaaca\") == True\n assert candidate(word1 = \"abcdabcd\",word2 = \"abcdabcd\") == True\n assert candidate(word1 = \"aabbccddeeffgghh\",word2 = \"iiiiijjjjjkkkkkk\") == False\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().isItPossible", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isItPossible(String word1, String word2) {", "container": "Solution", "callable": "isItPossible", "parameters": [{"name": "word1", "type": "String"}, {"name": "word2", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2532, "task_id": "time-to-cross-a-bridge", "difficulty": "Hard", "problem_description": "There are k workers who want to move n boxes from the right (old) warehouse to the left (new) warehouse. You are given the two integers n and k, and a 2D integer array time of size k x 4 where time[i] = [righti, picki, lefti, puti].\nThe warehouses are separated by a river and connected by a bridge. Initially, all k workers are waiting on the left side of the bridge. To move the boxes, the ith worker can do the following:\n\nCross the bridge to the right side in righti minutes.\nPick a box from the right warehouse in picki minutes.\nCross the bridge to the left side in lefti minutes.\nPut the box into the left warehouse in puti minutes.\n\nThe ith worker is less efficient than the jth worker if either condition is met:\n\nlefti + righti > leftj + rightj\nlefti + righti == leftj + rightj and i > j\n\nThe following rules regulate the movement of the workers through the bridge:\n\nOnly one worker can use the bridge at a time.\nWhen the bridge is unused prioritize the least efficient worker (who have picked up the box) on the right side to cross. If not, prioritize the least efficient worker on the left side to cross.\nIf enough workers have already been dispatched from the left side to pick up all the remaining boxes, no more workers will be sent from the left side.\n\nReturn the elapsed minutes at which the last box reaches the left side of the bridge.\n \nExample 1:\n\nInput: n = 1, k = 3, time = [[1,1,2,1],[1,1,3,1],[1,1,4,1]]\nOutput: 6\nExplanation:\n\nFrom 0 to 1 minutes: worker 2 crosses the bridge to the right.\nFrom 1 to 2 minutes: worker 2 picks up a box from the right warehouse.\nFrom 2 to 6 minutes: worker 2 crosses the bridge to the left.\nFrom 6 to 7 minutes: worker 2 puts a box at the left warehouse.\nThe whole process ends after 7 minutes. We return 6 because the problem asks for the instance of time at which the last worker reaches the left side of the bridge.\n\n\nExample 2:\n\nInput: n = 3, k = 2, time = [[1,5,1,8],[10,10,10,10]]\nOutput: 37\nExplanation:\n\n\n\nThe last box reaches the left side at 37 seconds. Notice, how we do not put the last boxes down, as that would take more time, and they are already on the left with the workers.\n\n \nConstraints:\n\n1 <= n, k <= 104\ntime.length == k\ntime[i].length == 4\n1 <= lefti, picki, righti, puti <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,k = 4,time = [[2, 10, 1, 5], [3, 1, 2, 2], [1, 5, 0, 1], [4, 3, 2, 1]]) == 31\n assert candidate(n = 2,k = 1,time = [[1, 2, 3, 4]]) == 16\n assert candidate(n = 5,k = 5,time = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]) == 54\n assert candidate(n = 7,k = 4,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == 48\n assert candidate(n = 5,k = 5,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == 43\n assert candidate(n = 2,k = 1,time = [[1, 2, 1, 2]]) == 10\n assert candidate(n = 10,k = 1,time = [[5, 5, 5, 5]]) == 195\n assert candidate(n = 5,k = 3,time = [[1, 2, 1, 2], [3, 4, 3, 4], [2, 3, 2, 3]]) == 26\n assert candidate(n = 10,k = 3,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]) == 45\n assert candidate(n = 6,k = 3,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]) == 24\n assert candidate(n = 2,k = 4,time = [[2, 10, 1, 1], [3, 1, 2, 2], [1, 4, 3, 3], [1, 1, 5, 5]]) == 11\n assert candidate(n = 10,k = 5,time = [[2, 1, 3, 2], [4, 3, 5, 4], [3, 2, 4, 3], [1, 1, 2, 1], [2, 2, 3, 3]]) == 80\n assert candidate(n = 10,k = 5,time = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]) == 108\n assert candidate(n = 4,k = 2,time = [[1, 1, 2, 2], [3, 3, 4, 4]]) == 25\n assert candidate(n = 10,k = 5,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == 87\n assert candidate(n = 3,k = 2,time = [[1, 5, 1, 8], [10, 10, 10, 10]]) == 37\n assert candidate(n = 1,k = 3,time = [[1, 1, 2, 1], [1, 1, 3, 1], [1, 1, 4, 1]]) == 6\n assert candidate(n = 5,k = 4,time = [[1, 2, 1, 2], [2, 2, 2, 2], [3, 2, 3, 3], [4, 2, 4, 4]]) == 34\n assert candidate(n = 15,k = 5,time = [[2, 3, 2, 2], [4, 4, 3, 3], [1, 2, 1, 1], [5, 5, 5, 5], [3, 3, 3, 3]]) == 115\n assert candidate(n = 10,k = 10,time = [[5, 1, 5, 1], [4, 2, 4, 2], [3, 3, 3, 3], [2, 4, 2, 4], [1, 5, 1, 5], [2, 3, 2, 3], [3, 2, 3, 2], [4, 1, 4, 1], [5, 4, 5, 4], [6, 5, 6, 5]]) == 110\n assert candidate(n = 20,k = 7,time = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 1, 3, 4], [3, 4, 1, 2], [1, 3, 4, 2], [5, 5, 5, 5], [2, 2, 2, 2]]) == 143\n assert candidate(n = 20,k = 5,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == 163\n assert candidate(n = 25,k = 4,time = [[10, 5, 15, 20], [5, 10, 10, 15], [20, 25, 30, 5], [15, 15, 10, 10]]) == 875\n assert candidate(n = 12,k = 6,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]]) == 120\n assert candidate(n = 10,k = 5,time = [[1, 1, 1, 10], [2, 2, 2, 20], [3, 3, 3, 30], [4, 4, 4, 40], [5, 5, 5, 50]]) == 77\n assert candidate(n = 8,k = 4,time = [[10, 10, 1, 1], [5, 5, 2, 2], [3, 3, 3, 3], [1, 1, 5, 5]]) == 60\n assert candidate(n = 25,k = 3,time = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 255\n assert candidate(n = 20,k = 3,time = [[3, 2, 2, 1], [4, 3, 3, 2], [5, 4, 4, 3]]) == 160\n assert candidate(n = 50,k = 3,time = [[1, 10, 1, 1], [2, 9, 2, 2], [3, 8, 3, 3]]) == 288\n assert candidate(n = 15,k = 5,time = [[2, 1, 3, 2], [1, 2, 4, 1], [3, 1, 1, 3], [2, 2, 2, 2], [1, 1, 1, 1]]) == 74\n assert candidate(n = 10,k = 4,time = [[2, 5, 3, 2], [3, 5, 5, 2], [4, 5, 6, 2], [5, 5, 7, 2]]) == 107\n assert candidate(n = 15,k = 3,time = [[10, 10, 1, 1], [1, 10, 5, 10], [5, 5, 2, 2]]) == 142\n assert candidate(n = 25,k = 7,time = [[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]]) == 309\n assert candidate(n = 30,k = 6,time = [[5, 1, 5, 1], [3, 2, 3, 2], [2, 3, 2, 3], [1, 4, 1, 4], [4, 1, 4, 1], [6, 1, 6, 1]]) == 330\n assert candidate(n = 15,k = 5,time = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 1, 3, 4], [3, 4, 1, 2], [1, 3, 4, 2]]) == 80\n assert candidate(n = 50,k = 5,time = [[1, 1, 1, 10], [10, 1, 1, 1], [1, 10, 1, 1], [1, 1, 10, 1], [1, 1, 1, 1]]) == 550\n assert candidate(n = 10,k = 3,time = [[2, 3, 1, 2], [1, 2, 2, 3], [3, 2, 2, 1]]) == 40\n assert candidate(n = 20,k = 10,time = [[1, 2, 1, 2], [2, 1, 2, 1], [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]]) == 363\n assert candidate(n = 15,k = 5,time = [[3, 7, 2, 5], [5, 4, 2, 6], [1, 3, 1, 2], [4, 6, 3, 8], [2, 2, 2, 2]]) == 90\n assert candidate(n = 20,k = 4,time = [[5, 5, 5, 5], [4, 4, 4, 4], [3, 3, 3, 3], [2, 2, 2, 2]]) == 163\n assert candidate(n = 25,k = 4,time = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 3, 3, 1], [1, 4, 4, 1]]) == 99\n assert candidate(n = 50,k = 9,time = [[1, 1, 1, 1], [1, 2, 1, 2], [1, 3, 1, 3], [1, 4, 1, 4], [1, 5, 1, 5], [1, 6, 1, 6], [1, 7, 1, 7], [1, 8, 1, 8], [1, 9, 1, 9]]) == 115\n assert candidate(n = 40,k = 5,time = [[1, 1, 2, 2], [2, 2, 3, 3], [3, 3, 4, 4], [4, 4, 5, 5], [5, 5, 6, 6]]) == 367\n assert candidate(n = 8,k = 8,time = [[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]]) == 115\n assert candidate(n = 25,k = 6,time = [[2, 3, 2, 3], [3, 2, 3, 2], [1, 4, 1, 4], [4, 1, 4, 1], [5, 5, 5, 5], [6, 6, 6, 6]]) == 258\n assert candidate(n = 8,k = 8,time = [[1, 2, 3, 4], [8, 7, 6, 5], [1, 3, 5, 7], [2, 4, 6, 8], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == 72\n assert candidate(n = 100,k = 10,time = [[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]]) == 1812\n assert candidate(n = 40,k = 5,time = [[5, 10, 5, 10], [10, 5, 10, 5], [5, 10, 10, 5], [10, 5, 5, 10], [5, 5, 5, 5]]) == 700\n assert candidate(n = 15,k = 5,time = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]) == 150\n assert candidate(n = 12,k = 4,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == 72\n assert candidate(n = 20,k = 3,time = [[3, 1, 2, 1], [2, 2, 3, 2], [1, 3, 1, 3]]) == 100\n assert candidate(n = 5,k = 3,time = [[1, 1, 1, 100], [2, 2, 2, 90], [3, 3, 3, 80]]) == 107\n assert candidate(n = 30,k = 10,time = [[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]]) == 180\n assert candidate(n = 30,k = 5,time = [[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]]) == 240\n assert candidate(n = 50,k = 5,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == 403\n assert candidate(n = 30,k = 8,time = [[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]]) == 240\n assert candidate(n = 30,k = 7,time = [[1, 1, 1, 1], [1, 2, 1, 2], [1, 3, 1, 3], [1, 4, 1, 4], [1, 5, 1, 5], [1, 6, 1, 6], [1, 7, 1, 7]]) == 74\n assert candidate(n = 20,k = 3,time = [[10, 10, 10, 10], [15, 15, 15, 15], [5, 5, 5, 5]]) == 415\n assert candidate(n = 30,k = 10,time = [[1, 1, 1, 1], [1, 2, 1, 2], [2, 1, 2, 1], [1, 3, 1, 3], [2, 2, 2, 2], [1, 4, 1, 4], [2, 3, 2, 3], [3, 2, 3, 2], [3, 3, 3, 3], [4, 1, 4, 1]]) == 210\n assert candidate(n = 12,k = 6,time = [[5, 2, 3, 1], [2, 3, 4, 2], [1, 4, 5, 3], [3, 5, 1, 4], [2, 1, 4, 5], [4, 3, 2, 6]]) == 84\n assert candidate(n = 30,k = 7,time = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8], [6, 7, 8, 9], [7, 8, 9, 10]]) == 420\n assert candidate(n = 20,k = 5,time = [[2, 3, 2, 1], [1, 1, 1, 1], [3, 2, 3, 2], [2, 2, 2, 2], [1, 3, 1, 3]]) == 100\n assert candidate(n = 18,k = 5,time = [[1, 1, 10, 10], [2, 2, 9, 9], [3, 3, 8, 8], [4, 4, 7, 7], [5, 5, 6, 6]]) == 198\n assert candidate(n = 18,k = 7,time = [[5, 3, 4, 2], [2, 1, 2, 1], [3, 2, 3, 2], [1, 5, 1, 5], [4, 4, 4, 4], [6, 6, 6, 6], [7, 7, 7, 7]]) == 210\n assert candidate(n = 100,k = 8,time = [[5, 5, 5, 5], [4, 4, 4, 4], [3, 3, 3, 3], [2, 2, 2, 2], [1, 1, 1, 1], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]]) == 1410\n assert candidate(n = 20,k = 4,time = [[10, 10, 1, 1], [1, 1, 10, 10], [5, 5, 5, 5], [2, 2, 2, 2]]) == 209\n assert candidate(n = 60,k = 12,time = [[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, 11, 11, 11], [12, 12, 12, 12]]) == 1320\n assert candidate(n = 40,k = 8,time = [[2, 1, 3, 4], [4, 2, 1, 3], [1, 2, 2, 1], [3, 3, 3, 3], [5, 4, 4, 5], [2, 2, 2, 2], [3, 1, 2, 1], [4, 3, 1, 4]]) == 268\n assert candidate(n = 10,k = 6,time = [[1, 2, 3, 4], [4, 5, 6, 7], [7, 8, 9, 10], [10, 9, 8, 7], [8, 7, 6, 5], [5, 4, 3, 2]]) == 171\n assert candidate(n = 15,k = 3,time = [[5, 2, 3, 2], [3, 5, 3, 2], [2, 3, 4, 2]]) == 108\n assert candidate(n = 30,k = 6,time = [[2, 5, 3, 7], [3, 4, 2, 6], [4, 3, 5, 2], [1, 6, 4, 3], [5, 2, 1, 4], [6, 1, 3, 5]]) == 270\n assert candidate(n = 25,k = 4,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == 156\n assert candidate(n = 15,k = 3,time = [[2, 3, 4, 5], [1, 4, 3, 2], [3, 2, 5, 1]]) == 105\n assert candidate(n = 10,k = 4,time = [[1, 1, 1, 1], [1, 1, 1, 2], [1, 1, 2, 1], [1, 1, 1, 3]]) == 25\n assert candidate(n = 25,k = 4,time = [[2, 1, 2, 1], [4, 2, 4, 2], [3, 3, 3, 3], [5, 5, 5, 5]]) == 207\n assert candidate(n = 25,k = 3,time = [[10, 1, 1, 1], [1, 10, 1, 1], [1, 1, 10, 1]]) == 276\n assert candidate(n = 30,k = 5,time = [[2, 2, 2, 2], [3, 3, 3, 3], [1, 1, 1, 1], [4, 4, 4, 4], [5, 5, 5, 5]]) == 240\n assert candidate(n = 15,k = 3,time = [[5, 1, 2, 1], [2, 1, 5, 2], [1, 1, 1, 1]]) == 106\n assert candidate(n = 100,k = 5,time = [[2, 3, 4, 1], [1, 2, 3, 1], [5, 3, 2, 1], [4, 1, 3, 2], [3, 2, 1, 5]]) == 700\n assert candidate(n = 10,k = 6,time = [[2, 3, 2, 3], [1, 1, 1, 1], [5, 5, 5, 5], [3, 2, 3, 2], [2, 5, 2, 5], [4, 4, 4, 4]]) == 87\n assert candidate(n = 25,k = 6,time = [[1, 5, 1, 8], [10, 10, 10, 10], [3, 2, 1, 4], [2, 1, 2, 3], [1, 4, 3, 2], [4, 3, 2, 1]]) == 178\n assert candidate(n = 20,k = 6,time = [[3, 2, 2, 1], [2, 1, 3, 2], [4, 3, 3, 4], [1, 2, 1, 2], [5, 5, 5, 5], [0, 0, 0, 0]]) == 150\n assert candidate(n = 6,k = 6,time = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]]) == 60\n assert candidate(n = 15,k = 6,time = [[1, 1, 1, 10], [1, 1, 1, 9], [1, 1, 1, 8], [1, 1, 1, 7], [1, 1, 1, 6], [1, 1, 1, 5]]) == 31\n assert candidate(n = 100,k = 10,time = [[10, 10, 10, 10], [9, 9, 9, 9], [8, 8, 8, 8], [7, 7, 7, 7], [6, 6, 6, 6], [5, 5, 5, 5], [4, 4, 4, 4], [3, 3, 3, 3], [2, 2, 2, 2], [1, 1, 1, 1]]) == 1812\n assert candidate(n = 8,k = 4,time = [[1, 4, 2, 3], [3, 2, 1, 4], [2, 3, 4, 1], [4, 1, 3, 2]]) == 52\n assert candidate(n = 12,k = 3,time = [[3, 3, 2, 2], [2, 2, 3, 3], [1, 1, 1, 1]]) == 49\n assert candidate(n = 7,k = 3,time = [[10, 5, 10, 5], [5, 10, 5, 10], [1, 1, 1, 1]]) == 115\n assert candidate(n = 12,k = 4,time = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]) == 72\n assert candidate(n = 15,k = 4,time = [[5, 1, 1, 5], [1, 5, 5, 1], [3, 3, 3, 3], [2, 2, 2, 2]]) == 86\n assert candidate(n = 7,k = 7,time = [[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]]) == 93\n assert candidate(n = 25,k = 4,time = [[10, 10, 10, 10], [9, 9, 9, 9], [8, 8, 8, 8], [7, 7, 7, 7]]) == 462\n assert candidate(n = 20,k = 5,time = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 2, 2, 2], [3, 1, 4, 1], [5, 5, 5, 5]]) == 156\n assert candidate(n = 18,k = 5,time = [[1, 1, 10, 1], [1, 1, 9, 1], [1, 1, 8, 1], [1, 1, 7, 1], [1, 1, 6, 1]]) == 189\n assert candidate(n = 12,k = 6,time = [[3, 2, 1, 2], [2, 2, 2, 2], [1, 2, 3, 2], [4, 2, 4, 2], [5, 2, 5, 2], [6, 2, 6, 2]]) == 132\n assert candidate(n = 8,k = 6,time = [[1, 2, 1, 2], [2, 3, 2, 3], [3, 4, 3, 4], [4, 5, 4, 5], [5, 6, 5, 6], [6, 7, 6, 7]]) == 84\n assert candidate(n = 50,k = 10,time = [[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]]) == 903\n assert candidate(n = 20,k = 5,time = [[2, 3, 4, 5], [1, 2, 3, 4], [3, 1, 2, 1], [4, 4, 1, 3], [5, 5, 5, 5]]) == 145\n assert candidate(n = 20,k = 5,time = [[5, 2, 3, 2], [4, 3, 2, 5], [3, 5, 1, 3], [2, 4, 1, 4], [1, 6, 2, 6]]) == 140\n assert candidate(n = 10,k = 3,time = [[1, 2, 1, 2], [2, 3, 2, 3], [3, 4, 3, 4]]) == 52\n"}, "metadata": {"canonical_parameter_names": ["n", "k", "time"], "leetcode_dataset_entry_point": "Solution().findCrossingTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findCrossingTime(int n, int k, int[][] time) {", "container": "Solution", "callable": "findCrossingTime", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}, {"name": "time", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2535, "task_id": "difference-between-element-sum-and-digit-sum-of-an-array", "difficulty": "Easy", "problem_description": "You are given a positive integer array nums.\n\nThe element sum is the sum of all the elements in nums.\nThe digit sum is the sum of all the digits (not necessarily distinct) that appear in nums.\n\nReturn the absolute difference between the element sum and digit sum of nums.\nNote that the absolute difference between two integers x and y is defined as |x - y|.\n \nExample 1:\n\nInput: nums = [1,15,6,3]\nOutput: 9\nExplanation: \nThe element sum of nums is 1 + 15 + 6 + 3 = 25.\nThe digit sum of nums is 1 + 1 + 5 + 6 + 3 = 16.\nThe absolute difference between the element sum and digit sum is |25 - 16| = 9.\n\nExample 2:\n\nInput: nums = [1,2,3,4]\nOutput: 0\nExplanation:\nThe element sum of nums is 1 + 2 + 3 + 4 = 10.\nThe digit sum of nums is 1 + 2 + 3 + 4 = 10.\nThe absolute difference between the element sum and digit sum is |10 - 10| = 0.\n\n \nConstraints:\n\n1 <= nums.length <= 2000\n1 <= nums[i] <= 2000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1111, 2222, 3333, 4444]) == 11070\n assert candidate(nums = [2000, 1999, 1, 0]) == 3969\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [10, 11, 12, 13]) == 36\n assert candidate(nums = [1, 15, 6, 3]) == 9\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [10, 100, 1000]) == 1107\n assert candidate(nums = [1, 2, 3, 4]) == 0\n assert candidate(nums = [5, 12, 43, 78]) == 108\n assert candidate(nums = [123, 456, 789, 101, 111]) == 1530\n assert candidate(nums = [2000, 1999, 1000, 999]) == 5940\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 504\n assert candidate(nums = [999, 1000, 1001]) == 2970\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [123, 456, 789]) == 1323\n assert candidate(nums = [9, 99, 999, 9999]) == 11016\n assert candidate(nums = [5, 55, 555, 5555]) == 6120\n assert candidate(nums = [2000, 1000, 500, 250]) == 3735\n assert candidate(nums = [1111, 2222, 3333, 4444]) == 11070\n assert candidate(nums = [10, 20, 30, 40, 50]) == 135\n assert candidate(nums = [18, 46, 89, 37]) == 144\n assert candidate(nums = [2000, 1999, 1998, 1997]) == 7911\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [2000, 1111, 999, 888]) == 4941\n assert candidate(nums = [111, 222, 333]) == 648\n assert candidate(nums = [10, 20, 30, 40]) == 90\n assert candidate(nums = [101, 1234, 56789, 234567]) == 292617\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999]) == 111110778\n assert candidate(nums = [555, 666, 777, 888, 999, 1000]) == 4779\n assert candidate(nums = [123, 456, 789, 101, 112, 123, 134, 145, 156, 167, 178, 189]) == 2538\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == 11106\n assert candidate(nums = [1999, 2998, 3997, 4996, 5995]) == 19845\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111]) == 4860\n assert candidate(nums = [10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009]) == 99990\n assert candidate(nums = [10, 100, 1000, 10000, 11111, 22222, 33333, 44444, 55555, 66666]) == 244332\n assert candidate(nums = [5, 50, 500, 5000, 1500, 2500, 3500, 4500, 6500, 7500, 8500, 9500]) == 49455\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005]) == 14985\n assert candidate(nums = [1, 22, 333, 4444, 55555]) == 60300\n assert candidate(nums = [1999, 1888, 1777, 1666, 1555, 1444, 1333, 1222, 1111]) == 13851\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 19350\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1010, 1111]) == 6975\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5454\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324]) == 809838\n assert candidate(nums = [1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990]) == 19710\n assert candidate(nums = [1999, 1998, 1997, 1996, 1995, 1994]) == 11826\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993]) == 15795\n assert candidate(nums = [2000, 2000, 2000, 2000, 2000]) == 9990\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999999]) == 11111110605\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981]) == 39366\n assert candidate(nums = [987, 654, 321, 111, 222]) == 2241\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930]) == 1345347\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991]) == 19737\n assert candidate(nums = [2000, 1500, 1000, 500, 250]) == 5229\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 10000]) == 59814\n assert candidate(nums = [1634, 2356, 7890, 1122, 3344, 5566, 7788, 9900]) == 39456\n assert candidate(nums = [1, 234, 567, 890, 432, 765, 109, 876, 543, 210]) == 4509\n assert candidate(nums = [987, 654, 321, 999, 888]) == 3753\n assert candidate(nums = [102030, 405060, 708090, 101112, 131415]) == 1447641\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 111111102\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005]) == 5994\n assert candidate(nums = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000]) == 27450\n assert candidate(nums = [19, 28, 37, 46, 55, 64, 73, 82, 91]) == 405\n assert candidate(nums = [98765, 43210, 11111, 22222, 33333, 44444, 55555, 66666, 77777]) == 452898\n assert candidate(nums = [1999, 2998, 3997, 4996, 5995, 6994, 7993, 8992, 9991, 10990]) == 64674\n assert candidate(nums = [1234, 5678, 91011, 121314]) == 219177\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1000]) == 5859\n assert candidate(nums = [987, 654, 321, 876, 543, 210, 765, 432, 109]) == 4779\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == 111105\n assert candidate(nums = [2000, 1000, 500, 250, 125]) == 3852\n assert candidate(nums = [1, 22, 333, 4444, 55555, 666666, 7777777, 88888888, 99999999]) == 197393409\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 4860\n assert candidate(nums = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 9999\n assert candidate(nums = [500, 400, 300, 200, 100, 99, 98, 97, 96, 95]) == 1890\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555]) == 16605\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996, 1995]) == 11853\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == 49815\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1971\n assert candidate(nums = [11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999, 100000]) == 599769\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 44955\n assert candidate(nums = [2000, 1500, 1000, 500, 100]) == 5085\n assert candidate(nums = [999, 111, 222, 333, 444, 555, 666, 777, 888]) == 4860\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 99630\n assert candidate(nums = [9876, 6543, 3210, 1111, 2222]) == 22896\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555]) == 2777777550\n assert candidate(nums = [9876, 5432, 1357, 2468, 1111, 2222, 3333, 4444, 5555, 6666]) == 42300\n assert candidate(nums = [1999, 1998, 1997, 1996, 1995, 1994, 1993]) == 13797\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909]) == 4455\n assert candidate(nums = [1999, 1888, 1777, 1666, 1555, 1444, 1333, 1222, 1111, 1000]) == 14850\n assert candidate(nums = [1234, 4321, 5678, 8765, 9876, 6789]) == 36531\n assert candidate(nums = [9876, 6543, 3210, 2468]) == 22023\n assert candidate(nums = [123, 456, 789, 321, 654, 987, 159, 753, 951, 842]) == 5886\n assert candidate(nums = [10, 200, 3000, 40000, 500000]) == 543195\n assert candidate(nums = [1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509]) == 14940\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992]) == 17766\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 108\n assert candidate(nums = [2000, 1500, 1000, 500, 100, 50, 10, 5, 1]) == 5139\n assert candidate(nums = [123, 456, 789, 1011, 1213]) == 3537\n assert candidate(nums = [123, 456, 789, 101112, 131415]) == 233829\n assert candidate(nums = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 5904\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().differenceOfSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int differenceOfSum(int[] nums) {", "container": "Solution", "callable": "differenceOfSum", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2536, "task_id": "increment-submatrices-by-one", "difficulty": "Medium", "problem_description": "You are given a positive integer n, indicating that we initially have an n x n 0-indexed integer matrix mat filled with zeroes.\nYou are also given a 2D integer array query. For each query[i] = [row1i, col1i, row2i, col2i], you should do the following operation:\n\nAdd 1 to every element in the submatrix with the top left corner (row1i, col1i) and the bottom right corner (row2i, col2i). That is, add 1 to mat[x][y] for all row1i <= x <= row2i and col1i <= y <= col2i.\n\nReturn the matrix mat after performing every query.\n \nExample 1:\n\n\nInput: n = 3, queries = [[1,1,2,2],[0,0,1,1]]\nOutput: [[1,1,0],[1,2,1],[0,1,1]]\nExplanation: The diagram above shows the initial matrix, the matrix after the first query, and the matrix after the second query.\n- In the first query, we add 1 to every element in the submatrix with the top left corner (1, 1) and bottom right corner (2, 2).\n- In the second query, we add 1 to every element in the submatrix with the top left corner (0, 0) and bottom right corner (1, 1).\n\nExample 2:\n\n\nInput: n = 2, queries = [[0,0,1,1]]\nOutput: [[1,1],[1,1]]\nExplanation: The diagram above shows the initial matrix and the matrix after the first query.\n- In the first query we add 1 to every element in the matrix.\n\n \nConstraints:\n\n1 <= n <= 500\n1 <= queries.length <= 104\n0 <= row1i <= row2i < n\n0 <= col1i <= col2i < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,queries = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == [[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]]\n assert candidate(n = 1,queries = [[0, 0, 0, 0]]) == [[1]]\n assert candidate(n = 5,queries = [[0, 0, 4, 4], [1, 1, 3, 3], [2, 2, 2, 2]]) == [[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]]\n assert candidate(n = 3,queries = [[0, 0, 2, 2], [1, 1, 1, 1], [0, 1, 1, 2]]) == [[1, 2, 2], [1, 3, 2], [1, 1, 1]]\n assert candidate(n = 4,queries = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]) == [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]\n assert candidate(n = 4,queries = [[0, 0, 3, 3], [0, 0, 3, 3], [0, 0, 3, 3]]) == [[3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3]]\n assert candidate(n = 4,queries = [[0, 0, 3, 3], [1, 1, 2, 2], [2, 2, 3, 3]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 2], [1, 1, 2, 2]]\n assert candidate(n = 4,queries = [[0, 0, 3, 3], [1, 1, 2, 2], [0, 0, 1, 1]]) == [[2, 2, 1, 1], [2, 3, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]]\n assert candidate(n = 2,queries = [[0, 0, 1, 1]]) == [[1, 1], [1, 1]]\n assert candidate(n = 3,queries = [[1, 1, 2, 2], [0, 0, 1, 1]]) == [[1, 1, 0], [1, 2, 1], [0, 1, 1]]\n assert candidate(n = 5,queries = [[0, 0, 2, 2], [2, 2, 4, 4], [1, 1, 3, 3], [0, 2, 0, 4], [4, 0, 4, 2]]) == [[1, 1, 2, 1, 1], [1, 2, 2, 1, 0], [1, 2, 3, 2, 1], [0, 1, 2, 2, 1], [1, 1, 2, 1, 1]]\n assert candidate(n = 10,queries = [[0, 0, 9, 9], [1, 1, 8, 8], [2, 2, 7, 7], [3, 3, 6, 6], [4, 4, 5, 5], [5, 5, 5, 5]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 10,queries = [[0, 0, 4, 4], [4, 4, 8, 8], [8, 8, 9, 9], [0, 0, 9, 0], [9, 0, 9, 9], [0, 9, 9, 9]]) == [[2, 1, 1, 1, 1, 0, 0, 0, 0, 1], [2, 1, 1, 1, 1, 0, 0, 0, 0, 1], [2, 1, 1, 1, 1, 0, 0, 0, 0, 1], [2, 1, 1, 1, 1, 0, 0, 0, 0, 1], [2, 1, 1, 1, 2, 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, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 2, 3]]\n assert candidate(n = 8,queries = [[0, 0, 7, 7], [1, 1, 6, 6], [2, 2, 5, 5], [3, 3, 4, 4], [0, 0, 3, 3], [4, 4, 7, 7], [1, 2, 5, 6], [2, 3, 4, 5]]) == [[2, 2, 2, 2, 1, 1, 1, 1], [2, 3, 4, 4, 3, 3, 3, 1], [2, 3, 5, 6, 5, 5, 3, 1], [2, 3, 5, 7, 6, 5, 3, 1], [1, 2, 4, 6, 7, 6, 4, 2], [1, 2, 4, 4, 5, 5, 4, 2], [1, 2, 2, 2, 3, 3, 3, 2], [1, 1, 1, 1, 2, 2, 2, 2]]\n assert candidate(n = 3,queries = [[0, 0, 2, 2], [1, 1, 1, 1], [0, 1, 1, 2], [2, 0, 2, 0]]) == [[1, 2, 2], [1, 3, 2], [2, 1, 1]]\n assert candidate(n = 3,queries = [[0, 0, 0, 0], [0, 1, 0, 1], [0, 2, 0, 2], [1, 0, 1, 0], [1, 1, 1, 1], [1, 2, 1, 2], [2, 0, 2, 0], [2, 1, 2, 1], [2, 2, 2, 2]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(n = 3,queries = [[0, 0, 2, 2], [0, 0, 2, 1], [0, 1, 2, 2], [1, 0, 2, 1], [1, 1, 2, 2], [0, 0, 0, 0]]) == [[3, 3, 2], [3, 5, 3], [3, 5, 3]]\n assert candidate(n = 10,queries = [[0, 0, 9, 9], [1, 1, 8, 8], [2, 2, 7, 7], [3, 3, 6, 6], [4, 4, 5, 5], [5, 5, 5, 5], [0, 0, 9, 9], [1, 1, 8, 8]]) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 4, 4, 4, 4, 4, 4, 4, 4, 2], [2, 4, 5, 5, 5, 5, 5, 5, 4, 2], [2, 4, 5, 6, 6, 6, 6, 5, 4, 2], [2, 4, 5, 6, 7, 7, 6, 5, 4, 2], [2, 4, 5, 6, 7, 8, 6, 5, 4, 2], [2, 4, 5, 6, 6, 6, 6, 5, 4, 2], [2, 4, 5, 5, 5, 5, 5, 5, 4, 2], [2, 4, 4, 4, 4, 4, 4, 4, 4, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]\n assert candidate(n = 20,queries = [[0, 0, 19, 19], [5, 5, 14, 14], [10, 10, 10, 10], [3, 3, 16, 16], [8, 8, 11, 11]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1], [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 4, 3, 3, 3, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1], [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(n = 30,queries = [[0, 0, 29, 29], [0, 0, 0, 29], [29, 0, 29, 29], [0, 29, 29, 29], [15, 15, 15, 15], [14, 14, 16, 16], [10, 10, 20, 20]]) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 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, 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, 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, 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, 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, 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, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 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, 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, 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, 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, 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, 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, 3]]\n assert candidate(n = 5,queries = [[0, 0, 4, 4], [0, 1, 3, 4], [1, 0, 4, 3], [1, 1, 3, 3], [2, 2, 2, 2]]) == [[1, 2, 2, 2, 2], [2, 4, 4, 4, 2], [2, 4, 5, 4, 2], [2, 4, 4, 4, 2], [2, 2, 2, 2, 1]]\n assert candidate(n = 3,queries = [[0, 0, 2, 2], [0, 1, 1, 2], [1, 0, 2, 1]]) == [[1, 2, 2], [2, 3, 2], [2, 2, 1]]\n assert candidate(n = 10,queries = [[0, 0, 9, 9], [0, 0, 0, 9], [9, 0, 9, 9], [0, 9, 9, 9], [5, 5, 5, 5], [4, 4, 6, 6]]) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 3], [1, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 2, 2, 2, 1, 1, 2], [1, 1, 1, 1, 2, 3, 2, 1, 1, 2], [1, 1, 1, 1, 2, 2, 2, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 3]]\n assert candidate(n = 4,queries = [[0, 0, 3, 3], [0, 0, 1, 1], [2, 2, 3, 3], [1, 2, 2, 3], [1, 1, 2, 2]]) == [[2, 2, 1, 1], [2, 3, 3, 2], [1, 2, 4, 3], [1, 1, 2, 2]]\n assert candidate(n = 5,queries = [[0, 0, 4, 4], [1, 1, 3, 3], [2, 2, 2, 2], [0, 4, 0, 4], [4, 0, 4, 4], [3, 1, 3, 3]]) == [[1, 1, 1, 1, 2], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 3, 3, 3, 1], [2, 2, 2, 2, 2]]\n assert candidate(n = 10,queries = [[0, 0, 0, 0], [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]]) == [[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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]\n assert candidate(n = 3,queries = [[0, 0, 2, 0], [0, 1, 2, 1], [0, 2, 2, 2], [1, 0, 1, 2], [2, 0, 2, 2], [0, 0, 2, 2]]) == [[2, 2, 2], [3, 3, 3], [3, 3, 3]]\n assert candidate(n = 3,queries = [[0, 0, 2, 2], [0, 1, 0, 1], [1, 0, 1, 0], [1, 2, 1, 2], [2, 1, 2, 1]]) == [[1, 2, 1], [2, 1, 2], [1, 2, 1]]\n assert candidate(n = 100,queries = [[0, 0, 99, 99], [25, 25, 74, 74], [50, 50, 49, 49], [0, 50, 49, 99], [50, 0, 99, 49], [25, 25, 74, 74]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 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, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 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, 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, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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(n = 6,queries = [[0, 0, 5, 5], [1, 2, 4, 3], [2, 3, 4, 2], [3, 1, 3, 1], [4, 2, 4, 4]]) == [[1, 1, 1, 1, 1, 1], [1, 1, 2, 2, 1, 1], [1, 1, 2, 2, 1, 1], [1, 2, 2, 2, 1, 1], [1, 1, 3, 3, 2, 1], [1, 1, 1, 1, 1, 1]]\n assert candidate(n = 4,queries = [[0, 0, 1, 1], [1, 1, 2, 2], [2, 2, 3, 3], [0, 2, 1, 3]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [0, 1, 2, 1], [0, 0, 1, 1]]\n assert candidate(n = 6,queries = [[0, 0, 5, 5], [1, 1, 4, 4], [2, 2, 3, 3], [0, 2, 2, 4], [3, 0, 5, 2]]) == [[1, 1, 2, 2, 2, 1], [1, 2, 3, 3, 3, 1], [1, 2, 4, 4, 3, 1], [2, 3, 4, 3, 2, 1], [2, 3, 3, 2, 2, 1], [2, 2, 2, 1, 1, 1]]\n assert candidate(n = 4,queries = [[0, 0, 1, 1], [1, 1, 2, 2], [2, 2, 3, 3], [0, 3, 1, 3]]) == [[1, 1, 0, 1], [1, 2, 1, 1], [0, 1, 2, 1], [0, 0, 1, 1]]\n assert candidate(n = 6,queries = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == [[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]]\n assert candidate(n = 4,queries = [[0, 0, 3, 3], [1, 1, 2, 2], [0, 1, 1, 2], [2, 3, 3, 3], [0, 0, 1, 3], [2, 2, 3, 3], [0, 2, 1, 3], [1, 0, 2, 1]]) == [[2, 3, 4, 3], [3, 5, 5, 3], [2, 3, 3, 3], [1, 1, 2, 3]]\n assert candidate(n = 10,queries = [[0, 0, 4, 4], [5, 5, 9, 9], [0, 5, 4, 9], [5, 0, 9, 4], [2, 2, 7, 7], [3, 3, 8, 8], [6, 6, 9, 9], [1, 1, 8, 8]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 4, 3, 1], [1, 2, 3, 4, 4, 4, 4, 4, 3, 1], [1, 2, 3, 4, 4, 4, 4, 4, 3, 1], [1, 2, 3, 4, 4, 4, 5, 5, 4, 2], [1, 2, 3, 4, 4, 4, 5, 5, 4, 2], [1, 2, 2, 3, 3, 3, 4, 4, 4, 2], [1, 1, 1, 1, 1, 1, 2, 2, 2, 2]]\n assert candidate(n = 7,queries = [[0, 0, 6, 6], [1, 1, 5, 5], [2, 2, 4, 4], [0, 3, 2, 5], [4, 2, 6, 5], [1, 0, 3, 3]]) == [[1, 1, 1, 2, 2, 2, 1], [2, 3, 3, 4, 3, 3, 1], [2, 3, 4, 5, 4, 3, 1], [2, 3, 4, 4, 3, 2, 1], [1, 2, 4, 4, 4, 3, 1], [1, 2, 3, 3, 3, 3, 1], [1, 1, 2, 2, 2, 2, 1]]\n assert candidate(n = 100,queries = [[0, 0, 99, 99], [50, 50, 99, 99], [0, 0, 49, 49], [50, 50, 50, 50]]) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]\n assert candidate(n = 10,queries = [[0, 0, 9, 9], [1, 1, 8, 8], [2, 2, 7, 7], [3, 3, 6, 6], [4, 4, 5, 5], [5, 5, 4, 4], [6, 6, 3, 3], [7, 7, 2, 2], [8, 8, 1, 1], [9, 9, 0, 0]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 3, 3, 3, 3, 3, 3, 3, 3, 1], [1, 3, 5, 5, 5, 5, 5, 5, 3, 1], [1, 3, 5, 7, 7, 7, 7, 5, 3, 1], [1, 3, 5, 7, 9, 9, 7, 5, 3, 1], [1, 3, 5, 7, 9, 9, 7, 5, 3, 1], [1, 3, 5, 7, 7, 7, 7, 5, 3, 1], [1, 3, 5, 5, 5, 5, 5, 5, 3, 1], [1, 3, 3, 3, 3, 3, 3, 3, 3, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 6,queries = [[0, 0, 2, 2], [2, 2, 4, 4], [4, 4, 1, 1], [1, 1, 3, 3], [3, 3, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [2, 2, 3, 3], [3, 3, 2, 2], [4, 4, 5, 5], [5, 5, 4, 4]]) == [[2, 2, 1, 0, 0, 0], [2, 4, 3, 1, 0, 0], [1, 3, 6, 4, 1, 0], [0, 1, 4, 4, 1, 0], [0, 0, 1, 1, 2, 1], [0, 0, 0, 0, 1, 1]]\n assert candidate(n = 10,queries = [[0, 0, 9, 1], [1, 1, 8, 2], [2, 2, 7, 3], [3, 3, 6, 4], [4, 4, 5, 5]]) == [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 1, 0, 0, 0, 0, 0, 0, 0], [1, 2, 2, 1, 0, 0, 0, 0, 0, 0], [1, 2, 2, 2, 1, 0, 0, 0, 0, 0], [1, 2, 2, 2, 2, 1, 0, 0, 0, 0], [1, 2, 2, 2, 2, 1, 0, 0, 0, 0], [1, 2, 2, 2, 1, 0, 0, 0, 0, 0], [1, 2, 2, 1, 0, 0, 0, 0, 0, 0], [1, 2, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(n = 50,queries = [[0, 0, 49, 49], [0, 0, 0, 49], [49, 0, 49, 49], [0, 49, 49, 49], [25, 25, 25, 25], [24, 24, 26, 26], [15, 15, 35, 35]]) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]]\n assert candidate(n = 4,queries = [[0, 0, 1, 1], [1, 1, 3, 3], [0, 2, 2, 3], [2, 0, 3, 1]]) == [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 2, 2], [1, 2, 1, 1]]\n assert candidate(n = 4,queries = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [0, 1, 1, 0], [1, 2, 2, 1], [2, 3, 3, 2], [3, 0, 0, 3]]) == [[1, 0, 0, 0], [-1, 0, -1, -1], [-1, -1, 0, -1], [0, 0, 0, 1]]\n assert candidate(n = 20,queries = [[0, 0, 19, 19], [1, 1, 18, 18], [2, 2, 17, 17], [3, 3, 16, 16], [4, 4, 15, 15], [5, 5, 14, 14], [6, 6, 13, 13], [7, 7, 12, 12], [8, 8, 11, 11], [9, 9, 10, 10]]) == [[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, 1], [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 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], [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, 9, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 6,queries = [[0, 0, 5, 5], [1, 2, 4, 4], [2, 3, 3, 5], [0, 0, 2, 2], [3, 3, 5, 5]]) == [[2, 2, 2, 1, 1, 1], [2, 2, 3, 2, 2, 1], [2, 2, 3, 3, 3, 2], [1, 1, 2, 4, 4, 3], [1, 1, 2, 3, 3, 2], [1, 1, 1, 2, 2, 2]]\n assert candidate(n = 10,queries = [[0, 0, 9, 9], [2, 2, 7, 7], [5, 5, 5, 5]]) == [[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, 1, 1], [1, 1, 2, 2, 2, 2, 2, 2, 1, 1], [1, 1, 2, 2, 2, 2, 2, 2, 1, 1], [1, 1, 2, 2, 2, 3, 2, 2, 1, 1], [1, 1, 2, 2, 2, 2, 2, 2, 1, 1], [1, 1, 2, 2, 2, 2, 2, 2, 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(n = 10,queries = [[0, 0, 9, 9], [0, 0, 8, 8], [1, 1, 7, 7], [2, 2, 6, 6], [3, 3, 5, 5], [4, 4, 4, 4]]) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 1], [2, 3, 3, 3, 3, 3, 3, 3, 2, 1], [2, 3, 4, 4, 4, 4, 4, 3, 2, 1], [2, 3, 4, 5, 5, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 5, 5, 4, 3, 2, 1], [2, 3, 4, 4, 4, 4, 4, 3, 2, 1], [2, 3, 3, 3, 3, 3, 3, 3, 2, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 50,queries = [[0, 0, 49, 49], [10, 10, 39, 39], [25, 25, 25, 25], [15, 15, 35, 35], [20, 20, 29, 29], [5, 5, 44, 44]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(n = 10,queries = [[0, 0, 9, 9], [2, 2, 7, 7], [3, 3, 6, 6], [5, 5, 5, 5]]) == [[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, 1, 1], [1, 1, 2, 3, 3, 3, 3, 2, 1, 1], [1, 1, 2, 3, 3, 3, 3, 2, 1, 1], [1, 1, 2, 3, 3, 4, 3, 2, 1, 1], [1, 1, 2, 3, 3, 3, 3, 2, 1, 1], [1, 1, 2, 2, 2, 2, 2, 2, 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(n = 7,queries = [[0, 0, 6, 6], [1, 1, 5, 5], [2, 2, 4, 4], [3, 3, 3, 3], [0, 3, 3, 0]]) == [[1, 0, 0, 1, 1, 1, 1], [1, 1, 1, 2, 2, 2, 1], [1, 1, 2, 3, 3, 2, 1], [1, 1, 2, 4, 3, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 8,queries = [[0, 0, 7, 7], [1, 1, 6, 6], [2, 2, 5, 5], [3, 3, 4, 4], [0, 7, 7, 0], [1, 6, 6, 1], [2, 5, 5, 2], [3, 4, 4, 3]]) == [[1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1]]\n assert candidate(n = 10,queries = [[0, 0, 9, 9], [1, 1, 8, 8], [2, 2, 7, 7], [3, 3, 6, 6], [4, 4, 5, 5]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 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, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 6,queries = [[0, 0, 5, 5], [0, 0, 2, 2], [3, 3, 5, 5], [1, 1, 4, 4], [0, 3, 2, 5], [3, 0, 5, 2], [1, 2, 4, 3], [2, 1, 3, 4]]) == [[2, 2, 2, 2, 2, 2], [2, 3, 4, 4, 3, 2], [2, 4, 5, 5, 4, 2], [2, 4, 5, 5, 4, 2], [2, 3, 4, 4, 3, 2], [2, 2, 2, 2, 2, 2]]\n assert candidate(n = 8,queries = [[0, 0, 7, 7], [1, 1, 6, 6], [2, 2, 5, 5], [3, 3, 4, 4], [0, 2, 1, 5], [6, 2, 7, 7]]) == [[1, 1, 2, 2, 2, 2, 1, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2], [1, 1, 2, 2, 2, 2, 2, 2]]\n assert candidate(n = 4,queries = [[0, 0, 3, 3], [1, 1, 2, 2], [0, 1, 1, 3], [2, 0, 3, 1]]) == [[1, 2, 2, 2], [1, 3, 3, 2], [2, 3, 2, 1], [2, 2, 1, 1]]\n assert candidate(n = 100,queries = [[0, 0, 99, 99], [0, 0, 0, 99], [99, 0, 99, 99], [0, 99, 99, 99], [50, 50, 50, 50], [49, 49, 51, 51], [30, 30, 70, 70]]) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 3, 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]]\n assert candidate(n = 4,queries = [[0, 0, 3, 3], [1, 1, 2, 2], [2, 2, 3, 3], [0, 1, 2, 3], [1, 0, 3, 2]]) == [[1, 2, 2, 2], [2, 4, 4, 2], [2, 4, 5, 3], [2, 2, 3, 2]]\n assert candidate(n = 4,queries = [[0, 0, 3, 3], [1, 1, 2, 2], [0, 2, 1, 3], [2, 0, 3, 1]]) == [[1, 1, 2, 2], [1, 2, 3, 2], [2, 3, 2, 1], [2, 2, 1, 1]]\n assert candidate(n = 10,queries = [[0, 0, 0, 9], [1, 1, 1, 8], [2, 2, 2, 7], [3, 3, 3, 6], [4, 4, 4, 5], [5, 5, 5, 5]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 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], [0, 0, 0, 0, 0, 0, 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,queries = [[0, 0, 4, 0], [0, 1, 0, 4], [4, 0, 4, 4], [2, 2, 2, 2], [3, 3, 3, 3]]) == [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 1, 0, 0], [1, 0, 0, 1, 0], [2, 1, 1, 1, 1]]\n assert candidate(n = 10,queries = [[0, 0, 9, 9], [2, 2, 7, 7], [4, 4, 5, 5], [1, 1, 8, 8], [6, 6, 9, 9]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 3, 4, 4, 3, 3, 2, 1], [1, 2, 3, 3, 4, 4, 3, 3, 2, 1], [1, 2, 3, 3, 3, 3, 4, 4, 3, 2], [1, 2, 3, 3, 3, 3, 4, 4, 3, 2], [1, 2, 2, 2, 2, 2, 3, 3, 3, 2], [1, 1, 1, 1, 1, 1, 2, 2, 2, 2]]\n assert candidate(n = 10,queries = [[0, 0, 9, 9], [1, 1, 8, 8], [2, 2, 7, 7], [3, 3, 6, 6], [4, 4, 5, 5], [0, 5, 5, 0], [5, 0, 0, 5]]) == [[1, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 2, 2, 2, 1], [0, 0, 1, 1, 1, 2, 3, 3, 2, 1], [0, 0, 1, 2, 2, 3, 4, 3, 2, 1], [0, 0, 1, 2, 3, 4, 4, 3, 2, 1], [1, 1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 9,queries = [[0, 0, 8, 8], [1, 2, 7, 6], [2, 3, 5, 4], [3, 4, 4, 5], [4, 5, 5, 6], [5, 6, 6, 7], [6, 7, 7, 8]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 2, 2, 2, 2, 2, 1, 1], [1, 1, 2, 3, 3, 2, 2, 1, 1], [1, 1, 2, 3, 4, 3, 2, 1, 1], [1, 1, 2, 3, 4, 4, 3, 1, 1], [1, 1, 2, 3, 3, 3, 4, 2, 1], [1, 1, 2, 2, 2, 2, 3, 3, 2], [1, 1, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 15,queries = [[0, 0, 14, 14], [1, 1, 13, 13], [2, 2, 12, 12], [3, 3, 11, 11], [4, 4, 10, 10], [5, 5, 9, 9]]) == [[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, 1], [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 5,queries = [[0, 0, 0, 4], [1, 1, 1, 3], [2, 2, 2, 2], [3, 3, 3, 4], [4, 4, 4, 4]]) == [[1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]\n assert candidate(n = 50,queries = [[0, 0, 49, 49], [10, 10, 39, 39], [20, 20, 29, 29], [5, 5, 44, 44], [15, 15, 34, 34]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [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, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 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, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(n = 6,queries = [[0, 0, 2, 2], [1, 1, 4, 4], [2, 2, 5, 5], [3, 3, 5, 5], [0, 3, 2, 3], [1, 4, 3, 4]]) == [[1, 1, 1, 1, 0, 0], [1, 2, 2, 2, 2, 0], [1, 2, 3, 3, 3, 1], [0, 1, 2, 3, 4, 2], [0, 1, 2, 3, 3, 2], [0, 0, 1, 2, 2, 2]]\n assert candidate(n = 8,queries = [[0, 0, 7, 7], [0, 2, 6, 6], [2, 0, 5, 5], [3, 3, 3, 3], [4, 4, 4, 4]]) == [[1, 1, 2, 2, 2, 2, 2, 1], [1, 1, 2, 2, 2, 2, 2, 1], [2, 2, 3, 3, 3, 3, 2, 1], [2, 2, 3, 4, 3, 3, 2, 1], [2, 2, 3, 3, 4, 3, 2, 1], [2, 2, 3, 3, 3, 3, 2, 1], [1, 1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 4,queries = [[0, 0, 3, 3], [0, 0, 1, 1], [1, 1, 2, 2], [2, 2, 3, 3], [0, 3, 3, 3], [3, 0, 3, 0]]) == [[2, 2, 1, 2], [2, 3, 2, 2], [1, 2, 3, 3], [2, 1, 2, 3]]\n assert candidate(n = 15,queries = [[0, 0, 14, 14], [1, 1, 13, 13], [2, 2, 12, 12], [3, 3, 11, 11], [4, 4, 10, 10], [5, 5, 9, 9], [6, 6, 8, 8]]) == [[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, 1], [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 7, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 7, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 7, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(n = 20,queries = [[0, 0, 19, 19], [5, 5, 14, 14], [10, 10, 15, 15], [0, 10, 9, 19], [10, 0, 19, 9]]) == [[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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [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, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1], [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1], [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1], [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1], [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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]]\n assert candidate(n = 3,queries = [[0, 0, 2, 2], [0, 1, 2, 1], [1, 0, 1, 2], [2, 0, 2, 2], [0, 0, 0, 0]]) == [[2, 2, 1], [2, 3, 2], [2, 3, 2]]\n"}, "metadata": {"canonical_parameter_names": ["n", "queries"], "leetcode_dataset_entry_point": "Solution().rangeAddQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] rangeAddQueries(int n, int[][] queries) {", "container": "Solution", "callable": "rangeAddQueries", "parameters": [{"name": "n", "type": "int"}, {"name": "queries", "type": "int[][]"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2537, "task_id": "count-the-number-of-good-subarrays", "difficulty": "Medium", "problem_description": "Given an integer array nums and an integer k, return the number of good subarrays of nums.\nA subarray arr is good if there are at least k pairs of indices (i, j) such that i < j and arr[i] == arr[j].\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,1,1,1,1], k = 10\nOutput: 1\nExplanation: The only good subarray is the array nums itself.\n\nExample 2:\n\nInput: nums = [3,1,4,3,2,2,4], k = 2\nOutput: 4\nExplanation: There are 4 different good subarrays:\n- [3,1,4,3,2,2] that has 2 pairs.\n- [3,1,4,3,2,2,4] that has 3 pairs.\n- [1,4,3,2,2,4] that has 2 pairs.\n- [4,3,2,2,4] that has 2 pairs.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i], k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 15) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 0\n assert candidate(nums = [10, 20, 30, 10, 20, 30, 10],k = 3) == 3\n assert candidate(nums = [10, 10, 10, 1, 1, 1, 1, 1, 1, 1],k = 5) == 23\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 4) == 5\n assert candidate(nums = [10, 20, 30, 10, 20, 30],k = 3) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5) == 15\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3],k = 10) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],k = 5) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 10\n assert candidate(nums = [3, 1, 4, 3, 2, 2, 4],k = 2) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 6\n assert candidate(nums = [1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(nums = [1],k = 1) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 9) == 3\n assert candidate(nums = [1, 3, 2, 1, 3, 1, 3],k = 3) == 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],k = 3) == 36\n assert candidate(nums = [1, 1],k = 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],k = 50) == 55\n assert candidate(nums = [10, 20, 10, 20, 10],k = 4) == 1\n assert candidate(nums = [1, 2, 1, 3, 4, 2, 1, 2, 1],k = 2) == 12\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],k = 6) == 22\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 0\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1],k = 5) == 6\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],k = 200) == 153\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 = 40) == 0\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 4, 4, 4, 4],k = 10) == 2\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 15) == 78\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],k = 10) == 6\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 10) == 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 = 15) == 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 = 40) == 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, 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 = 100) == 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],k = 20) == 120\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) == 21\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) == 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, 5, 5, 5, 5, 5],k = 25) == 68\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 20, 30, 40, 10, 20],k = 8) == 3\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4],k = 20) == 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],k = 10) == 1\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 = 10) == 36\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 = 30) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2],k = 10) == 14\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) == 28\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],k = 60) == 37\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 = 30) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3],k = 5) == 36\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],k = 20) == 25\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],k = 25) == 55\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],k = 30) == 0\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 = 1) == 55\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],k = 30) == 47\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 = 50) == 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, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6],k = 60) == 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 = 100) == 21\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 45) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],k = 10) == 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, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 30) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 6) == 0\n assert candidate(nums = [10, 10, 10, 10, 20, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40],k = 40) == 0\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 = 30) == 28\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],k = 30) == 28\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) == 21\n assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],k = 20) == 0\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 30) == 45\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2],k = 15) == 82\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 10) == 55\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 25) == 0\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 = 30) == 78\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 = 15) == 22\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 0\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) == 66\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 25) == 0\n assert candidate(nums = [1, 2, 2, 1, 1, 3, 3, 3, 2, 2, 1, 1],k = 6) == 15\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1],k = 5) == 10\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 = 50) == 0\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2],k = 5) == 15\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],k = 10) == 128\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],k = 150) == 351\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6],k = 15) == 78\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 1, 2, 2, 1, 3, 3, 3, 1, 2, 2, 1, 3, 3, 3, 1, 2, 2, 1, 3, 3, 3, 1, 2, 2],k = 35) == 136\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3],k = 10) == 28\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 = 100) == 21\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6],k = 20) == 28\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 25) == 73\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 20) == 15\n assert candidate(nums = [1, 2, 2, 1, 1, 1, 2, 1, 1],k = 5) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 136\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 = 10) == 91\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 = 25) == 28\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 = 10) == 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, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 21\n assert candidate(nums = [7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10],k = 25) == 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],k = 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],k = 30) == 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 = 10) == 1\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 18) == 0\n assert candidate(nums = [7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10],k = 25) == 6\n assert candidate(nums = [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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 100) == 153\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 = 40) == 12\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 1, 2, 2, 1],k = 5) == 15\n assert candidate(nums = [10, 10, 20, 20, 20, 30, 30, 30, 30, 30],k = 15) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 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, 6, 6, 6, 6],k = 50) == 0\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 7, 7, 7],k = 10) == 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],k = 15) == 21\n assert candidate(nums = [1, 2, 2, 1, 1, 3, 3, 3, 4, 4, 4, 4],k = 5) == 24\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 = 50) == 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],k = 15) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 15) == 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],k = 40) == 0\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 = 10) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 5) == 3\n assert candidate(nums = [10, 20, 10, 30, 20, 10, 40, 30, 20, 10],k = 5) == 6\n assert candidate(nums = [7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10],k = 30) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 25) == 6\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countGood", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countGood(int[] nums, int k) {", "container": "Solution", "callable": "countGood", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2538, "task_id": "difference-between-maximum-and-minimum-price-sum", "difficulty": "Hard", "problem_description": "There exists an undirected and initially unrooted tree with n nodes indexed from 0 to n - 1. You are given the integer n and 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.\nEach node has an associated price. You are given an integer array price, where price[i] is the price of the ith node.\nThe price sum of a given path is the sum of the prices of all nodes lying on that path.\nThe tree can be rooted at any node root of your choice. The incurred cost after choosing root is the difference between the maximum and minimum price sum amongst all paths starting at root.\nReturn the maximum possible cost amongst all possible root choices.\n \nExample 1:\n\n\nInput: n = 6, edges = [[0,1],[1,2],[1,3],[3,4],[3,5]], price = [9,8,7,6,10,5]\nOutput: 24\nExplanation: The diagram above denotes the tree after rooting it at node 2. The first part (colored in red) shows the path with the maximum price sum. The second part (colored in blue) shows the path with the minimum price sum.\n- The first path contains nodes [2,1,3,4]: the prices are [7,8,6,10], and the sum of the prices is 31.\n- The second path contains the node [2] with the price [7].\nThe difference between the maximum and minimum price sum is 24. It can be proved that 24 is the maximum cost.\n\nExample 2:\n\n\nInput: n = 3, edges = [[0,1],[1,2]], price = [1,1,1]\nOutput: 2\nExplanation: The diagram above denotes the tree after rooting it at node 0. The first part (colored in red) shows the path with the maximum price sum. The second part (colored in blue) shows the path with the minimum price sum.\n- The first path contains nodes [0,1,2]: the prices are [1,1,1], and the sum of the prices is 3.\n- The second path contains node [0] with a price [1].\nThe difference between the maximum and minimum price sum is 2. It can be proved that 2 is the maximum cost.\n\n \nConstraints:\n\n1 <= n <= 105\nedges.length == n - 1\n0 <= ai, bi <= n - 1\nedges represents a valid tree.\nprice.length == n\n1 <= price[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]],price = [5, 4, 3, 2, 1]) == 12\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]],price = [5, 10, 20, 30, 40]) == 55\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [1, 3]],price = [10, 5, 1, 1]) == 15\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [1, 3]],price = [1, 2, 3, 4]) == 6\n assert candidate(n = 4,edges = [[0, 1], [0, 2], [0, 3]],price = [2, 3, 4, 5]) == 7\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]],price = [10, 20, 30, 40, 50]) == 140\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5]],price = [9, 8, 7, 6, 10, 5]) == 24\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6]],price = [1, 2, 3, 4, 5, 6, 7]) == 19\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]],price = [10, 9, 8, 7, 6]) == 34\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]],price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(n = 3,edges = [[0, 1], [1, 2]],price = [1, 1, 1]) == 2\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [1, 3]],price = [10, 20, 30, 40]) == 60\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 21\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [2, 3], [2, 4], [2, 5], [5, 6]],price = [3, 5, 6, 2, 1, 7, 4]) == 21\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]],price = [5, 2, 3, 4, 6]) == 13\n assert candidate(n = 1,edges = [],price = [100]) == 0\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],price = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 44\n assert candidate(n = 25,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]],price = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16]) == 438\n assert candidate(n = 15,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]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 330\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]],price = [7, 6, 5, 4, 3, 2, 1, 8]) == 30\n assert candidate(n = 20,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]],price = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(n = 15,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]],price = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 30\n assert candidate(n = 14,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]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 320\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10]],price = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 30\n assert candidate(n = 25,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]],price = [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]) == 65\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],price = [100, 200, 300, 400, 500, 600, 700, 800]) == 3500\n assert candidate(n = 15,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]],price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 33\n assert candidate(n = 20,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]],price = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(n = 25,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]],price = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976]) == 799956\n assert candidate(n = 30,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]],price = [100000, 90000, 80000, 70000, 60000, 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]) == 432000\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11]],price = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10, 12, 11]) == 36\n assert candidate(n = 30,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]],price = [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, 30]) == 72\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]],price = [15, 25, 35, 45, 55, 65, 75, 85]) == 205\n assert candidate(n = 30,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]],price = [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]) == 370\n assert candidate(n = 15,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]],price = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 999999999, 99999999, 9999999, 999999, 99999, 9999, 999, 99, 9]) == 1010101109\n assert candidate(n = 100,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], [25, 51], [25, 52], [26, 53], [26, 54], [27, 55], [27, 56], [28, 57], [28, 58], [29, 59], [29, 60], [30, 61], [30, 62], [31, 63], [31, 64], [32, 65], [32, 66], [33, 67], [33, 68], [34, 69], [34, 70], [35, 71], [35, 72], [36, 73], [36, 74], [37, 75], [37, 76], [38, 77], [38, 78], [39, 79], [39, 80], [40, 81], [40, 82], [41, 83], [41, 84], [42, 85], [42, 86], [43, 87], [43, 88], [44, 89], [44, 90], [45, 91], [45, 92], [46, 93], [46, 94], [47, 95], [47, 96], [48, 97], [48, 98], [49, 99]],price = [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]) == 285\n assert candidate(n = 20,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]],price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 50\n assert candidate(n = 20,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]],price = [5, 8, 3, 11, 10, 4, 2, 6, 9, 7, 12, 14, 13, 1, 15, 17, 16, 18, 19, 20]) == 65\n assert candidate(n = 25,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]],price = [2, 5, 1, 8, 3, 6, 9, 4, 7, 10, 12, 14, 13, 1, 15, 17, 16, 18, 19, 20, 21, 22, 23, 24, 25]) == 68\n assert candidate(n = 15,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]],price = [100, 50, 200, 150, 250, 300, 400, 5, 10, 15, 20, 25, 30, 35, 40]) == 1040\n assert candidate(n = 50,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]],price = [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]) == 266\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9]],price = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 130\n assert candidate(n = 25,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]],price = [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]) == 6500\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],price = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],price = [10, 20, 30, 40, 50, 60]) == 200\n assert candidate(n = 18,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]],price = [15, 22, 10, 25, 30, 12, 18, 20, 21, 24, 26, 27, 31, 32, 33, 34, 35, 36]) == 147\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],price = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 385\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],price = [3, 4, 5, 6, 7, 8, 9]) == 21\n assert candidate(n = 50,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]],price = [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]) == 138\n assert candidate(n = 15,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]],price = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 275\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 29\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 280\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],price = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 143\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]],price = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 20000\n assert candidate(n = 25,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]],price = [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]) == 122\n assert candidate(n = 15,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]],price = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 3300\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],price = [5, 15, 25, 35, 45, 55, 65]) == 110\n assert candidate(n = 20,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]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 500\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "price"], "leetcode_dataset_entry_point": "Solution().maxOutput", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxOutput(int n, int[][] edges, int[] price) {", "container": "Solution", "callable": "maxOutput", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}, {"name": "price", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2540, "task_id": "minimum-common-value", "difficulty": "Easy", "problem_description": "Given two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays. If there is no common integer amongst nums1 and nums2, return -1.\nNote that an integer is said to be common to nums1 and nums2 if both arrays have at least one occurrence of that integer.\n \nExample 1:\n\nInput: nums1 = [1,2,3], nums2 = [2,4]\nOutput: 2\nExplanation: The smallest element common to both arrays is 2, so we return 2.\n\nExample 2:\n\nInput: nums1 = [1,2,3,6], nums2 = [2,3,4,5]\nOutput: 2\nExplanation: There are two common elements in the array 2 and 3 out of which 2 is the smallest, so 2 is returned.\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 105\n1 <= nums1[i], nums2[j] <= 109\nBoth nums1 and nums2 are sorted in non-decreasing order.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [1, 2, 2, 3],nums2 = [2, 2]) == 2\n assert candidate(nums1 = [10, 20, 30],nums2 = [5, 15, 25, 35]) == -1\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 1\n assert candidate(nums1 = [1, 3, 5, 7],nums2 = [2, 4, 6, 8]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == -1\n assert candidate(nums1 = [10, 20, 30],nums2 = [1, 2, 3]) == -1\n assert candidate(nums1 = [1, 1, 2, 2],nums2 = [2, 2, 3, 3]) == 2\n assert candidate(nums1 = [10, 20, 30],nums2 = [5, 15, 25]) == -1\n assert candidate(nums1 = [1, 2, 3],nums2 = [2, 4]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1000000000],nums2 = [1000000000]) == 1000000000\n assert candidate(nums1 = [1, 5, 9],nums2 = [3, 6, 9]) == 9\n assert candidate(nums1 = [1, 5, 9, 13, 17],nums2 = [2, 6, 10, 14, 18]) == -1\n assert candidate(nums1 = [1],nums2 = [2]) == -1\n assert candidate(nums1 = [1, 5, 9],nums2 = [3, 7, 11]) == -1\n assert candidate(nums1 = [5, 10, 15],nums2 = [15, 20, 25]) == 15\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == -1\n assert candidate(nums1 = [1, 2, 3, 6],nums2 = [2, 3, 4, 5]) == 2\n assert candidate(nums1 = [1, 10, 20],nums2 = [5, 15, 25]) == -1\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [1, 5, 7, 9],nums2 = [2, 6, 8, 10]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 5\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [11, 13, 15, 17, 19]) == -1\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 2\n assert candidate(nums1 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],nums2 = [2, 5, 8, 13, 21, 34, 55, 89]) == -1\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]) == 1\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5],nums2 = [2, 2, 3, 4, 5, 6]) == 2\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == -1\n assert candidate(nums1 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],nums2 = [1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]) == 1\n assert candidate(nums1 = [1, 4, 7, 10, 13],nums2 = [2, 5, 8, 11, 14]) == -1\n assert candidate(nums1 = [2, 10, 20, 30, 50],nums2 = [1, 2, 3, 10, 100]) == 2\n assert candidate(nums1 = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],nums2 = [5, 10, 16, 23, 31, 40, 50, 61, 73, 86]) == 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]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\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]) == 5\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 3\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],nums2 = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == -1\n assert candidate(nums1 = [100, 101, 102, 103, 104],nums2 = [99, 100, 101, 102, 105]) == 100\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, 4, 8, 10, 12, 15, 18, 20],nums2 = [2, 4, 6, 8, 10, 14, 18]) == 4\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == -1\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5],nums2 = [2, 3, 3, 4, 5, 6]) == 2\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],nums2 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == -1\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]) == -1\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == 1\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]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [16, 17, 18, 19, 20]) == -1\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9]) == -1\n assert candidate(nums1 = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45],nums2 = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45]) == 1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == -1\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]) == -1\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 3\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, 4, 6, 10, 20],nums2 = [3, 4, 15, 20, 25]) == 4\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums1 = [1, 4, 7, 10, 13],nums2 = [2, 5, 8, 11, 14]) == -1\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]) == 1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == -1\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],nums2 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 15\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 5\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == -1\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 = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 20\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000],nums2 = [500000, 1500000, 2500000, 3500000]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 3\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5, 5, 5, 6],nums2 = [2, 3, 3, 4, 5, 5, 6, 7, 8]) == 2\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]) == 1\n assert candidate(nums1 = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67],nums2 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 2\n assert candidate(nums1 = [5, 15, 25, 35, 45],nums2 = [6, 12, 18, 24, 30]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15]) == -1\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [5, 10, 15, 20, 25, 30, 35, 40]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\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]) == 10\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [150, 250, 350, 450, 550]) == -1\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5],nums2 = [2, 2, 3, 4, 6, 7]) == 2\n assert candidate(nums1 = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],nums2 = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 1\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]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9]) == 5\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45, 55]) == -1\n assert candidate(nums1 = [1, 10, 100, 1000, 10000],nums2 = [5, 50, 500, 5000, 50000]) == -1\n assert candidate(nums1 = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],nums2 = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250]) == 50\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().getCommon", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int getCommon(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "getCommon", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2541, "task_id": "minimum-operations-to-make-array-equal-ii", "difficulty": "Medium", "problem_description": "You are given two integer arrays nums1 and nums2 of equal length n and an integer k. You can perform the following operation on nums1:\n\nChoose two indexes i and j and increment nums1[i] by k and decrement nums1[j] by k. In other words, nums1[i] = nums1[i] + k and nums1[j] = nums1[j] - k.\n\nnums1 is said to be equal to nums2 if for all indices i such that 0 <= i < n, nums1[i] == nums2[i].\nReturn the minimum number of operations required to make nums1 equal to nums2. If it is impossible to make them equal, return -1.\n \nExample 1:\n\nInput: nums1 = [4,3,1,4], nums2 = [1,3,7,1], k = 3\nOutput: 2\nExplanation: In 2 operations, we can transform nums1 to nums2.\n1st operation: i = 2, j = 0. After applying the operation, nums1 = [1,3,4,4].\n2nd operation: i = 2, j = 3. After applying the operation, nums1 = [1,3,7,1].\nOne can prove that it is impossible to make arrays equal in fewer operations.\nExample 2:\n\nInput: nums1 = [3,8,5,2], nums2 = [2,4,1,6], k = 1\nOutput: -1\nExplanation: It can be proved that it is impossible to make the two arrays equal.\n\n \nConstraints:\n\nn == nums1.length == nums2.length\n2 <= n <= 105\n0 <= nums1[i], nums2[j] <= 109\n0 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [3, 8, 5, 2],nums2 = [2, 4, 1, 6],k = 1) == -1\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [10, 10, 10, 10],k = 5) == -1\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [1, 2, 3, 4],k = 2) == 0\n assert candidate(nums1 = [10, 20, 30],nums2 = [20, 30, 40],k = 10) == -1\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1],k = 2) == 1\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0],k = 0) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [10, 10, 0, 0],k = 5) == 2\n assert candidate(nums1 = [1, 1, 1],nums2 = [2, 2, 2],k = 0) == -1\n assert candidate(nums1 = [1, 2, 3],nums2 = [1, 2, 3],k = 0) == 0\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0],k = 0) == 0\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10],k = 10) == 2\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1],k = 2) == -1\n assert candidate(nums1 = [10, 20, 30],nums2 = [10, 20, 30],k = 5) == 0\n assert candidate(nums1 = [4, 3, 1, 4],nums2 = [1, 3, 7, 1],k = 3) == 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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 100\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1],k = 100000) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100],k = 50) == 12\n assert candidate(nums1 = [1000000000, 0, 0, 0],nums2 = [0, 0, 0, 1000000000],k = 250000000) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1],nums2 = [9, 9, 9, 9, 9, 9, 9, 9],k = 2) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 3],k = 1) == -1\n assert candidate(nums1 = [1000000000, 1000000000, 1000000000],nums2 = [500000000, 500000000, 500000000],k = 500000000) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [20, 30, 40, 50, 60],k = 10) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [9, 7, 5, 3, 1],k = 2) == 6\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [40, 30, 20, 10],k = 10) == 4\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [50, 150, 250, 350, 451],k = 50) == -1\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == -1\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [10, 8, 6, 4, 2],k = 2) == 6\n assert candidate(nums1 = [1000000000, 0, 0, 1000000000],nums2 = [500000000, 500000000, 500000000, 500000000],k = 500000000) == 2\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [400, 300, 200, 100],k = 50) == 8\n assert candidate(nums1 = [100000, 200000, 300000],nums2 = [300000, 200000, 100000],k = 100000) == 2\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],k = 0) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1],k = 1) == 9\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1],k = 1) == 9\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 10, 10, 10, 10, 0, 0, 0, 0, 0],k = 5) == 5\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [10, -10, 20, -20],k = 10) == 3\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [40, 30, 20, 10],k = 10) == 4\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 = 0) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11],k = 1) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9],k = 1) == 1\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],k = 10) == 6\n assert candidate(nums1 = [100, 150, 200, 250, 300],nums2 = [300, 250, 200, 150, 100],k = 50) == 6\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],k = 100) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2],k = 1) == -1\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0],k = 100000) == 0\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [400, 300, 200, 100],k = 100) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1],nums2 = [7, 7, 7, 7, 7, 7, 7, 7],k = 3) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13],nums2 = [13, 11, 9, 7, 5, 3, 1],k = 2) == 12\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],k = 15) == -1\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600],nums2 = [600, 500, 400, 300, 200, 100],k = 100) == 9\n assert candidate(nums1 = [1000000000, 500000000, 250000000, 125000000],nums2 = [0, 0, 0, 0],k = 125000000) == -1\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [50, 100, 150, 200, 250],k = 50) == -1\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [10, 8, 6, 4, 2],k = 2) == 6\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9],k = 1) == -1\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [10, 8, 6, 4, 2],k = 3) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 10\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100],k = 10) == 60\n assert candidate(nums1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 0) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60],nums2 = [60, 50, 40, 30, 20, 10],k = 10) == 9\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],k = 0) == 0\n assert candidate(nums1 = [10, 15, 20, 25, 30, 35],nums2 = [35, 30, 25, 20, 15, 10],k = 5) == 9\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100],k = 50) == 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 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 1) == 25\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65],nums2 = [15, 25, 35, 45, 55, 65, 75],k = 10) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2],k = 1) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1],k = 100) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],k = 10) == 6\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [10, 20, 30, 40, 50],k = 5) == 0\n assert candidate(nums1 = [1000000, 1000000, 1000000],nums2 = [500000, 500000, 500000],k = 500000) == -1\n assert candidate(nums1 = [7, 7, 7, 7],nums2 = [1, 13, 1, 13],k = 3) == 4\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],k = 5) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 9],k = 2) == -1\n assert candidate(nums1 = [5, 6, 7, 8, 9, 10],nums2 = [15, 14, 13, 12, 11, 10],k = 2) == -1\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],k = 5) == 0\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) == 0\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65],nums2 = [65, 55, 45, 35, 25, 15, 5],k = 10) == 12\n assert candidate(nums1 = [1000000000, 0, 500000000, 500000000],nums2 = [500000000, 500000000, 0, 1000000000],k = 500000000) == 2\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 1) == -1\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],k = 1) == 25\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],k = 1) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2],k = 0) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [5, 5, 5, 5, 5, 5],k = 4) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1],k = 1) == 9\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1000) == 0\n assert candidate(nums1 = [1000000000, 1000000000, 1000000000],nums2 = [999999998, 1000000002, 1000000000],k = 1) == 2\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 1) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [9, 7, 5, 3, 1],k = 2) == 6\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 3],k = 2) == -1\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 = 100000) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6],k = 1) == -1\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [10, 20, 30, 40, 50],k = 0) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6],k = 5) == -1\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == 10\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [50, 150, 250, 350, 450],k = 50) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 25\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [40, 30, 20, 10],k = 5) == 8\n assert candidate(nums1 = [9, 18, 27, 36, 45],nums2 = [45, 36, 27, 18, 9],k = 9) == 6\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16],nums2 = [16, 14, 12, 10, 8, 6, 4, 2],k = 2) == 16\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5],k = 0) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 56\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],k = 5) == 12\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [40, 30, 20, 10],k = 5) == 8\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 0\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],k = 10) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "k"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minOperations(int[] nums1, int[] nums2, int k) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2542, "task_id": "maximum-subsequence-score", "difficulty": "Medium", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2 of equal length n and a positive integer k. You must choose a subsequence of indices from nums1 of length k.\nFor chosen indices i0, i1, ..., ik - 1, your score is defined as:\n\nThe sum of the selected elements from nums1 multiplied with the minimum of the selected elements from nums2.\nIt can defined simply as: (nums1[i0] + nums1[i1] +...+ nums1[ik - 1]) * min(nums2[i0] , nums2[i1], ... ,nums2[ik - 1]).\n\nReturn the maximum possible score.\nA subsequence of indices of an array is a set that can be derived from the set {0, 1, ..., n-1} by deleting some or no elements.\n \nExample 1:\n\nInput: nums1 = [1,3,3,2], nums2 = [2,1,3,4], k = 3\nOutput: 12\nExplanation: \nThe four possible subsequence scores are:\n- We choose the indices 0, 1, and 2 with score = (1+3+3) * min(2,1,3) = 7.\n- We choose the indices 0, 1, and 3 with score = (1+3+2) * min(2,1,4) = 6. \n- We choose the indices 0, 2, and 3 with score = (1+3+2) * min(2,3,4) = 12. \n- We choose the indices 1, 2, and 3 with score = (3+3+2) * min(1,3,4) = 8.\nTherefore, we return the max score, which is 12.\n\nExample 2:\n\nInput: nums1 = [4,2,3,1,1], nums2 = [7,5,10,9,6], k = 1\nOutput: 30\nExplanation: \nChoosing index 2 is optimal: nums1[2] * nums2[2] = 3 * 10 = 30 is the maximum possible score.\n\n \nConstraints:\n\nn == nums1.length == nums2.length\n1 <= n <= 105\n0 <= nums1[i], nums2[j] <= 105\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],k = 2) == 15\n assert candidate(nums1 = [100000, 0, 0, 0, 0],nums2 = [1, 100000, 1, 100000, 1],k = 1) == 100000\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],k = 5) == 150\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1],k = 3) == 27\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 3) == 3\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 10, 15, 20, 25],k = 4) == 1400\n assert candidate(nums1 = [1, 3, 3, 2],nums2 = [2, 1, 3, 4],k = 3) == 12\n assert candidate(nums1 = [4, 2, 3, 1, 1],nums2 = [7, 5, 10, 9, 6],k = 1) == 30\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5],k = 4) == 0\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [100, 200, 300, 400],k = 2) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],k = 3) == 360\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0],k = 4) == 0\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5],k = 2) == 15\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5],k = 5) == 125\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [0, 0, 0, 0, 0],k = 2) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1],k = 2) == 10\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1],k = 2) == 10\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],k = 2) == 55\n assert candidate(nums1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 50\n assert candidate(nums1 = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 8888800\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 6) == 225000\n assert candidate(nums1 = [5, 15, 10, 20, 25, 30],nums2 = [3, 1, 4, 2, 5, 6],k = 4) == 210\n assert candidate(nums1 = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 198437\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0],k = 3) == 12\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 = 6) == 2250\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],k = 5) == 100\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55],nums2 = [10, 20, 30, 40, 50, 60],k = 4) == 4800\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 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 20\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 4) == 1155\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == 80\n assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == 490000\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 400\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 = 10) == 550\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 240000\n assert candidate(nums1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 1000\n assert candidate(nums1 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5],k = 7) == 448\n assert candidate(nums1 = [5, 15, 20, 25, 30, 35, 40],nums2 = [10, 20, 15, 30, 25, 40, 35],k = 5) == 2900\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 72\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) == 1000\n assert candidate(nums1 = [5, 15, 10, 20, 25, 30, 40],nums2 = [2, 3, 1, 5, 4, 6, 7],k = 3) == 450\n assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000],nums2 = [5, 10, 15, 20, 25],k = 3) == 3150000\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 24\n assert candidate(nums1 = [99999, 99999, 99998, 99997, 99996, 99995],nums2 = [1, 1, 2, 2, 3, 3],k = 2) == 599973\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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 720\n assert candidate(nums1 = [10, 15, 20, 25, 30, 35, 40],nums2 = [40, 35, 30, 25, 20, 15, 10],k = 4) == 1800\n assert candidate(nums1 = [100, 100, 100, 100, 100],nums2 = [100, 100, 100, 100, 100],k = 5) == 50000\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 2040\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],nums2 = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 33000\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == 80\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == 10000\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == 56\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 294\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == 0\n assert candidate(nums1 = [5, 8, 9, 3, 7],nums2 = [6, 5, 4, 3, 2],k = 3) == 88\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 = 8) == 1560\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 40\n assert candidate(nums1 = [9, 1, 4, 7, 3, 6, 2, 8, 5, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 114\n assert candidate(nums1 = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 1400000\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 30\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 18\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 330\n assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 300000\n assert candidate(nums1 = [50, 60, 10, 90, 30, 20, 80, 70, 40, 60],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6) == 1500\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [10, 20, 30, 40, 50],k = 1) == 450\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 0\n assert candidate(nums1 = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],nums2 = [60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10],k = 8) == 5500\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [10, 9, 8, 7, 6],k = 2) == 54\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5],k = 5) == 2500\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],k = 1) == 30\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == 10000\n assert candidate(nums1 = [9, 7, 5, 3, 1],nums2 = [2, 4, 6, 8, 10],k = 3) == 60\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 = 7) == 1960\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 5500\n assert candidate(nums1 = [9, 7, 5, 3, 1],nums2 = [1, 3, 5, 7, 9],k = 4) == 48\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],k = 3) == 75\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(nums1 = [100000, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000],k = 5) == 100000\n assert candidate(nums1 = [8, 2, 11, 3, 6, 9],nums2 = [5, 8, 1, 4, 7, 10],k = 4) == 125\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 300\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == 1000\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 = 5) == 5\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 55000\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 30\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 400\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5],k = 3) == 75\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [1, 2, 3, 4, 5],k = 3) == 180\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == 216000\n assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 1120000\n assert candidate(nums1 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 3000000\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 400\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],k = 5) == 100\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 6) == 450\n assert candidate(nums1 = [5, 2, 6, 1, 4, 3],nums2 = [10, 5, 8, 2, 7, 6],k = 4) == 108\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 30\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 7500\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 80\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 15) == 4500\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],k = 3) == 18\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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 110\n assert candidate(nums1 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 955\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],k = 5) == 1500\n assert candidate(nums1 = [50000, 50000, 50000, 50000, 50000],nums2 = [1, 2, 3, 4, 5],k = 5) == 250000\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 90\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [10, 10, 10, 10, 10],k = 2) == 9000\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 7) == 11200\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 0\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],k = 4) == 90\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 21600\n assert candidate(nums1 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],k = 10) == 1050\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],k = 5) == 240000\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 5) == 300\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "k"], "leetcode_dataset_entry_point": "Solution().maxScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxScore(int[] nums1, int[] nums2, int k) {", "container": "Solution", "callable": "maxScore", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2543, "task_id": "check-if-point-is-reachable", "difficulty": "Hard", "problem_description": "There exists an infinitely large grid. You are currently at point (1, 1), and you need to reach the point (targetX, targetY) using a finite number of steps.\nIn one step, you can move from point (x, y) to any one of the following points:\n\n(x, y - x)\n(x - y, y)\n(2 * x, y)\n(x, 2 * y)\n\nGiven two integers targetX and targetY representing the X-coordinate and Y-coordinate of your final position, return true if you can reach the point from (1, 1) using some number of steps, and false otherwise.\n \nExample 1:\n\nInput: targetX = 6, targetY = 9\nOutput: false\nExplanation: It is impossible to reach (6,9) from (1,1) using any sequence of moves, so false is returned.\n\nExample 2:\n\nInput: targetX = 4, targetY = 7\nOutput: true\nExplanation: You can follow the path (1,1) -> (1,2) -> (1,4) -> (1,8) -> (1,7) -> (2,7) -> (4,7).\n\n \nConstraints:\n\n1 <= targetX, targetY <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(targetX = 7,targetY = 3) == True\n assert candidate(targetX = 6,targetY = 9) == False\n assert candidate(targetX = 16,targetY = 8) == True\n assert candidate(targetX = 3,targetY = 5) == True\n assert candidate(targetX = 10,targetY = 1) == True\n assert candidate(targetX = 1,targetY = 1) == True\n assert candidate(targetX = 9,targetY = 6) == False\n assert candidate(targetX = 2,targetY = 2) == True\n assert candidate(targetX = 8,targetY = 16) == True\n assert candidate(targetX = 4,targetY = 7) == True\n assert candidate(targetX = 31,targetY = 47) == True\n assert candidate(targetX = 2,targetY = 1048576) == True\n assert candidate(targetX = 17,targetY = 34) == False\n assert candidate(targetX = 100,targetY = 1) == True\n assert candidate(targetX = 19,targetY = 38) == False\n assert candidate(targetX = 13,targetY = 19) == True\n assert candidate(targetX = 100,targetY = 200) == False\n assert candidate(targetX = 63,targetY = 27) == False\n assert candidate(targetX = 13,targetY = 21) == True\n assert candidate(targetX = 5,targetY = 13) == True\n assert candidate(targetX = 16,targetY = 32) == True\n assert candidate(targetX = 10,targetY = 10) == False\n assert candidate(targetX = 987654321,targetY = 987654321) == False\n assert candidate(targetX = 27,targetY = 18) == False\n assert candidate(targetX = 77,targetY = 154) == False\n assert candidate(targetX = 49,targetY = 147) == False\n assert candidate(targetX = 31,targetY = 62) == False\n assert candidate(targetX = 255,targetY = 1023) == False\n assert candidate(targetX = 512,targetY = 384) == True\n assert candidate(targetX = 16384,targetY = 8192) == True\n assert candidate(targetX = 88888,targetY = 55555) == False\n assert candidate(targetX = 512,targetY = 1025) == True\n assert candidate(targetX = 128,targetY = 192) == True\n assert candidate(targetX = 18,targetY = 33) == False\n assert candidate(targetX = 77,targetY = 44) == False\n assert candidate(targetX = 27,targetY = 81) == False\n assert candidate(targetX = 999999999,targetY = 333333333) == False\n assert candidate(targetX = 17,targetY = 1024) == True\n assert candidate(targetX = 5,targetY = 25) == False\n assert candidate(targetX = 65536,targetY = 129) == True\n assert candidate(targetX = 3125,targetY = 243) == True\n assert candidate(targetX = 1234567,targetY = 7654321) == True\n assert candidate(targetX = 32,targetY = 48) == True\n assert candidate(targetX = 999,targetY = 333) == False\n assert candidate(targetX = 987,targetY = 654) == False\n assert candidate(targetX = 1023,targetY = 1) == True\n assert candidate(targetX = 123456,targetY = 654321) == False\n assert candidate(targetX = 123,targetY = 456) == False\n assert candidate(targetX = 31,targetY = 31) == False\n assert candidate(targetX = 63,targetY = 21) == False\n assert candidate(targetX = 8192,targetY = 16384) == True\n assert candidate(targetX = 511,targetY = 256) == True\n assert candidate(targetX = 54,targetY = 36) == False\n assert candidate(targetX = 19,targetY = 23) == True\n assert candidate(targetX = 99999,targetY = 1) == True\n assert candidate(targetX = 1000000000,targetY = 1) == True\n assert candidate(targetX = 1000000000,targetY = 500000000) == False\n assert candidate(targetX = 1024,targetY = 512) == True\n assert candidate(targetX = 81,targetY = 27) == False\n assert candidate(targetX = 15,targetY = 10) == False\n assert candidate(targetX = 256,targetY = 513) == True\n assert candidate(targetX = 256,targetY = 512) == True\n assert candidate(targetX = 81,targetY = 243) == False\n assert candidate(targetX = 1073741824,targetY = 536870912) == True\n assert candidate(targetX = 32,targetY = 128) == True\n assert candidate(targetX = 97,targetY = 83) == True\n assert candidate(targetX = 256,targetY = 256) == True\n assert candidate(targetX = 77,targetY = 49) == False\n assert candidate(targetX = 256,targetY = 1024) == True\n assert candidate(targetX = 1001,targetY = 1003) == True\n assert candidate(targetX = 511,targetY = 1024) == True\n assert candidate(targetX = 128,targetY = 256) == True\n assert candidate(targetX = 65536,targetY = 32768) == True\n assert candidate(targetX = 777,targetY = 111) == False\n assert candidate(targetX = 1,targetY = 1000000000) == True\n assert candidate(targetX = 33333,targetY = 22222) == False\n assert candidate(targetX = 999999937,targetY = 999999937) == False\n assert candidate(targetX = 33,targetY = 55) == False\n assert candidate(targetX = 3,targetY = 12) == False\n assert candidate(targetX = 1024,targetY = 2048) == True\n assert candidate(targetX = 255,targetY = 127) == True\n assert candidate(targetX = 100,targetY = 25) == False\n assert candidate(targetX = 77,targetY = 33) == False\n assert candidate(targetX = 101,targetY = 101) == False\n assert candidate(targetX = 13,targetY = 39) == False\n assert candidate(targetX = 123456789,targetY = 987654321) == False\n"}, "metadata": {"canonical_parameter_names": ["targetX", "targetY"], "leetcode_dataset_entry_point": "Solution().isReachable", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isReachable(int targetX, int targetY) {", "container": "Solution", "callable": "isReachable", "parameters": [{"name": "targetX", "type": "int"}, {"name": "targetY", "type": "int"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2544, "task_id": "alternating-digit-sum", "difficulty": "Easy", "problem_description": "You are given a positive integer n. Each digit of n has a sign according to the following rules:\n\nThe most significant digit is assigned a positive sign.\nEach other digit has an opposite sign to its adjacent digits.\n\nReturn the sum of all digits with their corresponding sign.\n \nExample 1:\n\nInput: n = 521\nOutput: 4\nExplanation: (+5) + (-2) + (+1) = 4.\n\nExample 2:\n\nInput: n = 111\nOutput: 1\nExplanation: (+1) + (-1) + (+1) = 1.\n\nExample 3:\n\nInput: n = 886996\nOutput: 0\nExplanation: (+8) + (-8) + (+6) + (-9) + (+9) + (-6) = 0.\n\n \nConstraints:\n\n1 <= n <= 109\n\n \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 987654321) == 5\n assert candidate(n = 123) == 2\n assert candidate(n = 987) == 8\n assert candidate(n = 9) == 9\n assert candidate(n = 123456789) == 5\n assert candidate(n = 111) == 1\n assert candidate(n = 1) == 1\n assert candidate(n = 1000000000) == 1\n assert candidate(n = 521) == 4\n assert candidate(n = 100000000) == 1\n assert candidate(n = 24680) == -4\n assert candidate(n = 886996) == 0\n assert candidate(n = 222222222) == 2\n assert candidate(n = 111222333444555666777888999) == 5\n assert candidate(n = 999999999) == 9\n assert candidate(n = 987654321987654321) == 0\n assert candidate(n = 10987654321) == 6\n assert candidate(n = 1234567890123456789) == 10\n assert candidate(n = 5432109876) == 5\n assert candidate(n = 100000001) == 2\n assert candidate(n = 909090909) == 45\n assert candidate(n = 202020202) == 10\n assert candidate(n = 135791357) == 9\n assert candidate(n = 975318642) == 1\n assert candidate(n = 505050505) == 25\n assert candidate(n = 999888777) == 8\n assert candidate(n = 135792468) == 9\n assert candidate(n = 99887766554433221100) == 0\n assert candidate(n = 246802468) == 0\n assert candidate(n = 123321123321) == 0\n assert candidate(n = 9753186420) == 1\n assert candidate(n = 121212121) == -3\n assert candidate(n = 5040302010) == 15\n assert candidate(n = 808080808) == 40\n assert candidate(n = 101010101) == 5\n assert candidate(n = 1212121212) == -5\n assert candidate(n = 4321234) == 5\n assert candidate(n = 8642086420) == 0\n assert candidate(n = 9876543210) == 5\n assert candidate(n = 112233445566778899) == 0\n assert candidate(n = 7654321) == 4\n assert candidate(n = 1122334455) == 0\n assert candidate(n = 555555555) == 5\n assert candidate(n = 864208642) == 0\n assert candidate(n = 1000000001) == 0\n assert candidate(n = 4321234321234) == 6\n assert candidate(n = 111111111) == 1\n assert candidate(n = 1010101010) == 5\n assert candidate(n = 2222222222) == 0\n assert candidate(n = 110011001) == 1\n assert candidate(n = 123321) == 0\n assert candidate(n = 246813579) == 1\n assert candidate(n = 123012301) == 5\n assert candidate(n = 543210987654) == 6\n assert candidate(n = 1357924680) == 9\n assert candidate(n = 543210987) == 11\n assert candidate(n = 1111111111) == 0\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().alternateDigitSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int alternateDigitSum(int n) {", "container": "Solution", "callable": "alternateDigitSum", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2545, "task_id": "sort-the-students-by-their-kth-score", "difficulty": "Medium", "problem_description": "There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row represents one student and score[i][j] denotes the score the ith student got in the jth exam. The matrix score contains distinct integers only.\nYou are also given an integer k. Sort the students (i.e., the rows of the matrix) by their scores in the kth (0-indexed) exam from the highest to the lowest.\nReturn the matrix after sorting it.\n \nExample 1:\n\n\nInput: score = [[10,6,9,1],[7,5,11,2],[4,8,3,15]], k = 2\nOutput: [[7,5,11,2],[10,6,9,1],[4,8,3,15]]\nExplanation: In the above diagram, S denotes the student, while E denotes the exam.\n- The student with index 1 scored 11 in exam 2, which is the highest score, so they got first place.\n- The student with index 0 scored 9 in exam 2, which is the second highest score, so they got second place.\n- The student with index 2 scored 3 in exam 2, which is the lowest score, so they got third place.\n\nExample 2:\n\n\nInput: score = [[3,4],[5,6]], k = 0\nOutput: [[5,6],[3,4]]\nExplanation: In the above diagram, S denotes the student, while E denotes the exam.\n- The student with index 1 scored 5 in exam 0, which is the highest score, so they got first place.\n- The student with index 0 scored 3 in exam 0, which is the lowest score, so they got second place.\n\n \nConstraints:\n\nm == score.length\nn == score[i].length\n1 <= m, n <= 250\n1 <= score[i][j] <= 105\nscore consists of distinct integers.\n0 <= k < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(score = [[90, 80, 70], [60, 50, 40], [30, 20, 10]],k = 1) == [[90, 80, 70], [60, 50, 40], [30, 20, 10]]\n assert candidate(score = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]],k = 3) == [[3, 4, 5, 6], [2, 3, 4, 5], [1, 2, 3, 4]]\n assert candidate(score = [[10, 6, 9, 1], [7, 5, 11, 2], [4, 8, 3, 15]],k = 2) == [[7, 5, 11, 2], [10, 6, 9, 1], [4, 8, 3, 15]]\n assert candidate(score = [[20, 10], [15, 5], [25, 15]],k = 1) == [[25, 15], [20, 10], [15, 5]]\n assert candidate(score = [[100]],k = 0) == [[100]]\n assert candidate(score = [[5, 1, 4, 2, 3], [2, 5, 3, 4, 1], [1, 2, 5, 3, 4]],k = 3) == [[2, 5, 3, 4, 1], [1, 2, 5, 3, 4], [5, 1, 4, 2, 3]]\n assert candidate(score = [[9, 5, 7], [8, 4, 6], [7, 3, 5]],k = 1) == [[9, 5, 7], [8, 4, 6], [7, 3, 5]]\n assert candidate(score = [[25, 50, 75], [15, 30, 45], [10, 20, 30]],k = 0) == [[25, 50, 75], [15, 30, 45], [10, 20, 30]]\n assert candidate(score = [[3, 4], [5, 6]],k = 0) == [[5, 6], [3, 4]]\n assert candidate(score = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 2) == [[7, 8, 9], [4, 5, 6], [1, 2, 3]]\n assert candidate(score = [[1, 2, 3], [6, 5, 4], [9, 8, 7]],k = 2) == [[9, 8, 7], [6, 5, 4], [1, 2, 3]]\n assert candidate(score = [[5, 2, 1, 4], [3, 1, 4, 2], [4, 4, 2, 3]],k = 0) == [[5, 2, 1, 4], [4, 4, 2, 3], [3, 1, 4, 2]]\n assert candidate(score = [[20, 30], [15, 25], [10, 15]],k = 1) == [[20, 30], [15, 25], [10, 15]]\n assert candidate(score = [[5, 3, 7, 9], [8, 6, 4, 2], [1, 10, 11, 12]],k = 1) == [[1, 10, 11, 12], [8, 6, 4, 2], [5, 3, 7, 9]]\n assert candidate(score = [[20, 40, 60, 80, 100], [50, 30, 90, 70, 120], [10, 20, 30, 40, 50]],k = 2) == [[50, 30, 90, 70, 120], [20, 40, 60, 80, 100], [10, 20, 30, 40, 50]]\n assert candidate(score = [[123, 456, 789], [789, 456, 123], [123, 789, 456], [456, 123, 789], [789, 123, 456]],k = 0) == [[789, 456, 123], [789, 123, 456], [456, 123, 789], [123, 456, 789], [123, 789, 456]]\n assert candidate(score = [[12345, 98765, 45678], [11111, 22222, 33333], [99999, 88888, 77777]],k = 1) == [[12345, 98765, 45678], [99999, 88888, 77777], [11111, 22222, 33333]]\n assert candidate(score = [[42, 23, 67, 19], [85, 43, 23, 56], [34, 67, 89, 23], [78, 56, 45, 34]],k = 1) == [[34, 67, 89, 23], [78, 56, 45, 34], [85, 43, 23, 56], [42, 23, 67, 19]]\n assert candidate(score = [[98765, 43210, 12345, 67890, 24680], [13579, 24680, 35791, 46802, 57913], [65432, 12345, 98765, 24680, 35791], [24680, 35791, 46802, 57913, 65432], [57913, 65432, 79135, 87914, 96721]],k = 2) == [[65432, 12345, 98765, 24680, 35791], [57913, 65432, 79135, 87914, 96721], [24680, 35791, 46802, 57913, 65432], [13579, 24680, 35791, 46802, 57913], [98765, 43210, 12345, 67890, 24680]]\n assert candidate(score = [[1, 25, 49, 73, 97], [2, 26, 50, 74, 98], [3, 27, 51, 75, 99], [4, 28, 52, 76, 100], [5, 29, 53, 77, 101], [6, 30, 54, 78, 102], [7, 31, 55, 79, 103], [8, 32, 56, 80, 104], [9, 33, 57, 81, 105], [10, 34, 58, 82, 106]],k = 2) == [[10, 34, 58, 82, 106], [9, 33, 57, 81, 105], [8, 32, 56, 80, 104], [7, 31, 55, 79, 103], [6, 30, 54, 78, 102], [5, 29, 53, 77, 101], [4, 28, 52, 76, 100], [3, 27, 51, 75, 99], [2, 26, 50, 74, 98], [1, 25, 49, 73, 97]]\n assert candidate(score = [[123, 456, 789], [321, 654, 987], [456, 789, 123], [789, 123, 456], [654, 987, 321]],k = 1) == [[654, 987, 321], [456, 789, 123], [321, 654, 987], [123, 456, 789], [789, 123, 456]]\n assert candidate(score = [[20, 30, 40, 50], [50, 40, 30, 20], [10, 60, 70, 80]],k = 3) == [[10, 60, 70, 80], [20, 30, 40, 50], [50, 40, 30, 20]]\n assert candidate(score = [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [30, 40, 50, 60, 70, 10, 20]],k = 5) == [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [30, 40, 50, 60, 70, 10, 20]]\n assert candidate(score = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 6, 8, 10], [10, 8, 6, 4, 2]],k = 4) == [[2, 4, 6, 8, 10], [1, 2, 3, 4, 5], [10, 8, 6, 4, 2], [5, 4, 3, 2, 1]]\n assert candidate(score = [[5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [3, 1, 4, 2, 5], [2, 3, 5, 1, 4]],k = 0) == [[5, 4, 3, 2, 1], [3, 1, 4, 2, 5], [2, 3, 5, 1, 4], [1, 2, 3, 4, 5]]\n assert candidate(score = [[100, 200, 300, 400, 500], [90, 190, 290, 390, 490], [80, 180, 280, 380, 480], [70, 170, 270, 370, 470], [60, 160, 260, 360, 460]],k = 2) == [[100, 200, 300, 400, 500], [90, 190, 290, 390, 490], [80, 180, 280, 380, 480], [70, 170, 270, 370, 470], [60, 160, 260, 360, 460]]\n assert candidate(score = [[1000, 2000, 3000], [2000, 1000, 3000], [3000, 2000, 1000], [1000, 3000, 2000]],k = 1) == [[1000, 3000, 2000], [1000, 2000, 3000], [3000, 2000, 1000], [2000, 1000, 3000]]\n assert candidate(score = [[100, 50, 75, 25], [70, 90, 30, 10], [60, 40, 80, 65], [20, 85, 55, 45]],k = 2) == [[60, 40, 80, 65], [100, 50, 75, 25], [20, 85, 55, 45], [70, 90, 30, 10]]\n assert candidate(score = [[15, 25, 35, 45], [25, 35, 45, 15], [35, 45, 15, 25], [45, 15, 25, 35], [10, 20, 30, 40]],k = 0) == [[45, 15, 25, 35], [35, 45, 15, 25], [25, 35, 45, 15], [15, 25, 35, 45], [10, 20, 30, 40]]\n assert candidate(score = [[1000, 1001, 1002, 1003, 1004], [2000, 2001, 2002, 2003, 2004], [3000, 3001, 3002, 3003, 3004], [4000, 4001, 4002, 4003, 4004], [5000, 5001, 5002, 5003, 5004]],k = 0) == [[5000, 5001, 5002, 5003, 5004], [4000, 4001, 4002, 4003, 4004], [3000, 3001, 3002, 3003, 3004], [2000, 2001, 2002, 2003, 2004], [1000, 1001, 1002, 1003, 1004]]\n assert candidate(score = [[1, 2, 3, 4, 5], [10, 20, 30, 40, 50], [100, 200, 300, 400, 500], [1000, 2000, 3000, 4000, 5000], [10000, 20000, 30000, 40000, 50000]],k = 3) == [[10000, 20000, 30000, 40000, 50000], [1000, 2000, 3000, 4000, 5000], [100, 200, 300, 400, 500], [10, 20, 30, 40, 50], [1, 2, 3, 4, 5]]\n assert candidate(score = [[5, 8, 1, 9], [9, 1, 5, 8], [8, 9, 5, 1], [1, 5, 8, 9]],k = 2) == [[1, 5, 8, 9], [9, 1, 5, 8], [8, 9, 5, 1], [5, 8, 1, 9]]\n assert candidate(score = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [9, 19, 29, 39, 49, 59, 69, 79, 89, 99]],k = 9) == [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [9, 19, 29, 39, 49, 59, 69, 79, 89, 99], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]]\n assert candidate(score = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [3, 1, 4, 6, 5, 2], [2, 4, 6, 1, 3, 5]],k = 4) == [[1, 2, 3, 4, 5, 6], [3, 1, 4, 6, 5, 2], [2, 4, 6, 1, 3, 5], [6, 5, 4, 3, 2, 1]]\n assert candidate(score = [[10, 20, 30], [30, 10, 20], [20, 30, 10], [50, 40, 60], [40, 50, 70], [60, 70, 80], [70, 80, 90]],k = 0) == [[70, 80, 90], [60, 70, 80], [50, 40, 60], [40, 50, 70], [30, 10, 20], [20, 30, 10], [10, 20, 30]]\n assert candidate(score = [[100, 99, 98], [97, 96, 95], [94, 93, 92], [91, 90, 89], [88, 87, 86]],k = 2) == [[100, 99, 98], [97, 96, 95], [94, 93, 92], [91, 90, 89], [88, 87, 86]]\n assert candidate(score = [[1, 3, 2], [3, 2, 1], [2, 1, 3], [4, 5, 6], [6, 4, 5], [5, 6, 4]],k = 2) == [[4, 5, 6], [6, 4, 5], [5, 6, 4], [2, 1, 3], [1, 3, 2], [3, 2, 1]]\n assert candidate(score = [[150, 130, 110], [140, 120, 100], [135, 115, 95], [145, 125, 105]],k = 1) == [[150, 130, 110], [145, 125, 105], [140, 120, 100], [135, 115, 95]]\n assert candidate(score = [[20, 45, 67, 89, 10], [45, 78, 12, 56, 34], [67, 23, 89, 12, 45], [89, 10, 23, 45, 67], [10, 89, 45, 67, 23]],k = 3) == [[20, 45, 67, 89, 10], [10, 89, 45, 67, 23], [45, 78, 12, 56, 34], [89, 10, 23, 45, 67], [67, 23, 89, 12, 45]]\n assert candidate(score = [[99, 100, 98], [97, 96, 95], [94, 93, 92], [91, 90, 89]],k = 0) == [[99, 100, 98], [97, 96, 95], [94, 93, 92], [91, 90, 89]]\n assert candidate(score = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [2, 12, 22, 32, 42], [8, 18, 28, 38, 48], [4, 14, 24, 34, 44]],k = 1) == [[10, 20, 30, 40, 50], [8, 18, 28, 38, 48], [5, 15, 25, 35, 45], [4, 14, 24, 34, 44], [2, 12, 22, 32, 42]]\n assert candidate(score = [[123, 456, 789], [987, 654, 321], [111, 222, 333], [444, 555, 666]],k = 1) == [[987, 654, 321], [444, 555, 666], [123, 456, 789], [111, 222, 333]]\n assert candidate(score = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [20, 30, 40, 50, 10], [40, 50, 10, 20, 30]],k = 1) == [[40, 50, 10, 20, 30], [50, 40, 30, 20, 10], [20, 30, 40, 50, 10], [10, 20, 30, 40, 50]]\n assert candidate(score = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100], [300, 500, 200, 100, 400], [200, 300, 500, 400, 100]],k = 4) == [[100, 200, 300, 400, 500], [300, 500, 200, 100, 400], [500, 400, 300, 200, 100], [200, 300, 500, 400, 100]]\n assert candidate(score = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1]],k = 4) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1]]\n assert candidate(score = [[1, 12, 3, 4, 5], [10, 11, 2, 7, 8], [6, 9, 1, 10, 4], [2, 5, 6, 3, 9]],k = 0) == [[10, 11, 2, 7, 8], [6, 9, 1, 10, 4], [2, 5, 6, 3, 9], [1, 12, 3, 4, 5]]\n assert candidate(score = [[25, 26, 27, 28, 29], [24, 23, 22, 21, 20], [19, 18, 17, 16, 15], [14, 13, 12, 11, 10], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0]],k = 4) == [[25, 26, 27, 28, 29], [24, 23, 22, 21, 20], [19, 18, 17, 16, 15], [14, 13, 12, 11, 10], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0]]\n assert candidate(score = [[2, 1, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 22, 33, 44, 55, 66, 77, 88, 99, 100]],k = 5) == [[11, 22, 33, 44, 55, 66, 77, 88, 99, 100], [2, 1, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]\n assert candidate(score = [[100000, 90000, 80000, 70000, 60000], [50000, 40000, 30000, 20000, 10000]],k = 4) == [[100000, 90000, 80000, 70000, 60000], [50000, 40000, 30000, 20000, 10000]]\n assert candidate(score = [[100000, 90000, 80000, 70000, 60000], [10000, 20000, 30000, 40000, 50000], [5000, 6000, 7000, 8000, 9000], [1, 2, 3, 4, 5]],k = 0) == [[100000, 90000, 80000, 70000, 60000], [10000, 20000, 30000, 40000, 50000], [5000, 6000, 7000, 8000, 9000], [1, 2, 3, 4, 5]]\n assert candidate(score = [[99, 101, 102, 98], [103, 104, 97, 96], [95, 94, 93, 105], [106, 107, 108, 109]],k = 3) == [[106, 107, 108, 109], [95, 94, 93, 105], [99, 101, 102, 98], [103, 104, 97, 96]]\n assert candidate(score = [[5, 10, 15, 20, 25, 30, 35, 40], [40, 35, 30, 25, 20, 15, 10, 5], [15, 20, 25, 30, 35, 40, 5, 10]],k = 6) == [[5, 10, 15, 20, 25, 30, 35, 40], [40, 35, 30, 25, 20, 15, 10, 5], [15, 20, 25, 30, 35, 40, 5, 10]]\n assert candidate(score = [[10, 20, 30], [20, 10, 40], [30, 40, 20], [40, 30, 10], [50, 10, 20], [60, 20, 30]],k = 2) == [[20, 10, 40], [10, 20, 30], [60, 20, 30], [30, 40, 20], [50, 10, 20], [40, 30, 10]]\n assert candidate(score = [[5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [4, 3, 2, 1, 5], [2, 1, 5, 4, 3], [3, 5, 4, 3, 2]],k = 2) == [[2, 1, 5, 4, 3], [3, 5, 4, 3, 2], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [4, 3, 2, 1, 5]]\n assert candidate(score = [[5, 3, 1, 4], [2, 1, 5, 3], [4, 2, 3, 1], [3, 5, 4, 2]],k = 0) == [[5, 3, 1, 4], [4, 2, 3, 1], [3, 5, 4, 2], [2, 1, 5, 3]]\n assert candidate(score = [[50, 90, 80, 70], [60, 10, 20, 30], [100, 5, 15, 25], [40, 65, 55, 45]],k = 1) == [[50, 90, 80, 70], [40, 65, 55, 45], [60, 10, 20, 30], [100, 5, 15, 25]]\n assert candidate(score = [[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 = 0) == [[5, 5, 5, 5, 5], [4, 4, 4, 4, 4], [3, 3, 3, 3, 3], [2, 2, 2, 2, 2], [1, 1, 1, 1, 1]]\n assert candidate(score = [[120, 130, 140, 150], [110, 100, 90, 80], [160, 170, 180, 190], [95, 85, 75, 65]],k = 2) == [[160, 170, 180, 190], [120, 130, 140, 150], [110, 100, 90, 80], [95, 85, 75, 65]]\n assert candidate(score = [[55, 65, 75, 85, 95], [45, 35, 25, 15, 5], [90, 80, 70, 60, 50], [15, 25, 35, 45, 55]],k = 3) == [[55, 65, 75, 85, 95], [90, 80, 70, 60, 50], [15, 25, 35, 45, 55], [45, 35, 25, 15, 5]]\n assert candidate(score = [[88, 77, 66, 55], [55, 66, 77, 88], [66, 88, 77, 55], [77, 55, 88, 66]],k = 0) == [[88, 77, 66, 55], [77, 55, 88, 66], [66, 88, 77, 55], [55, 66, 77, 88]]\n assert candidate(score = [[34, 56, 23, 89], [67, 34, 56, 12], [90, 89, 78, 67], [23, 45, 67, 89]],k = 3) == [[34, 56, 23, 89], [23, 45, 67, 89], [90, 89, 78, 67], [67, 34, 56, 12]]\n assert candidate(score = [[123, 456, 789, 101, 112], [234, 567, 890, 212, 123], [345, 678, 901, 323, 134], [456, 789, 101, 434, 145], [567, 890, 212, 545, 156], [678, 901, 323, 656, 167]],k = 1) == [[678, 901, 323, 656, 167], [567, 890, 212, 545, 156], [456, 789, 101, 434, 145], [345, 678, 901, 323, 134], [234, 567, 890, 212, 123], [123, 456, 789, 101, 112]]\n assert candidate(score = [[100, 90, 80, 70], [60, 50, 40, 30], [20, 10, 0, 100]],k = 1) == [[100, 90, 80, 70], [60, 50, 40, 30], [20, 10, 0, 100]]\n assert candidate(score = [[50, 85, 75], [35, 90, 60], [45, 95, 65], [25, 80, 70]],k = 1) == [[45, 95, 65], [35, 90, 60], [50, 85, 75], [25, 80, 70]]\n assert candidate(score = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [19, 18, 17, 16, 15, 14, 13, 12, 11, 10]],k = 5) == [[19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]\n assert candidate(score = [[100000, 1, 2, 3], [99999, 4, 5, 6], [99998, 7, 8, 9], [99997, 10, 11, 12]],k = 1) == [[99997, 10, 11, 12], [99998, 7, 8, 9], [99999, 4, 5, 6], [100000, 1, 2, 3]]\n assert candidate(score = [[95, 85, 75, 65, 55], [65, 55, 45, 35, 25], [80, 90, 100, 70, 85], [40, 50, 60, 95, 80], [70, 80, 90, 100, 75]],k = 3) == [[70, 80, 90, 100, 75], [40, 50, 60, 95, 80], [80, 90, 100, 70, 85], [95, 85, 75, 65, 55], [65, 55, 45, 35, 25]]\n assert candidate(score = [[50, 90, 20, 60], [30, 70, 80, 40], [10, 50, 30, 20], [70, 30, 50, 90]],k = 2) == [[30, 70, 80, 40], [70, 30, 50, 90], [10, 50, 30, 20], [50, 90, 20, 60]]\n assert candidate(score = [[5, 10, 15, 20], [20, 15, 10, 5], [10, 5, 20, 15], [15, 20, 5, 10], [25, 30, 35, 40]],k = 3) == [[25, 30, 35, 40], [5, 10, 15, 20], [10, 5, 20, 15], [15, 20, 5, 10], [20, 15, 10, 5]]\n assert candidate(score = [[20, 30, 10], [40, 50, 60], [10, 20, 30], [70, 80, 90]],k = 2) == [[70, 80, 90], [40, 50, 60], [10, 20, 30], [20, 30, 10]]\n assert candidate(score = [[15, 25, 35, 45, 55], [55, 45, 35, 25, 15], [25, 35, 15, 55, 45], [45, 15, 55, 35, 25]],k = 3) == [[25, 35, 15, 55, 45], [15, 25, 35, 45, 55], [45, 15, 55, 35, 25], [55, 45, 35, 25, 15]]\n assert candidate(score = [[100, 200, 300, 400, 500], [200, 100, 400, 300, 500], [500, 400, 300, 200, 100], [400, 300, 200, 500, 100]],k = 2) == [[200, 100, 400, 300, 500], [100, 200, 300, 400, 500], [500, 400, 300, 200, 100], [400, 300, 200, 500, 100]]\n assert candidate(score = [[200, 300, 400, 500], [250, 350, 450, 550], [150, 250, 350, 450], [100, 200, 300, 400]],k = 3) == [[250, 350, 450, 550], [200, 300, 400, 500], [150, 250, 350, 450], [100, 200, 300, 400]]\n assert candidate(score = [[250, 240, 230], [220, 210, 200], [190, 180, 170], [160, 150, 140], [130, 120, 110]],k = 0) == [[250, 240, 230], [220, 210, 200], [190, 180, 170], [160, 150, 140], [130, 120, 110]]\n assert candidate(score = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [2, 12, 22, 32, 42], [3, 13, 23, 33, 43], [4, 14, 24, 34, 44]],k = 4) == [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [4, 14, 24, 34, 44], [3, 13, 23, 33, 43], [2, 12, 22, 32, 42], [1, 11, 21, 31, 41]]\n assert candidate(score = [[500, 600, 700, 800], [400, 300, 200, 100], [900, 1000, 1100, 1200], [1300, 1400, 1500, 1600], [1700, 1800, 1900, 2000]],k = 3) == [[1700, 1800, 1900, 2000], [1300, 1400, 1500, 1600], [900, 1000, 1100, 1200], [500, 600, 700, 800], [400, 300, 200, 100]]\n assert candidate(score = [[150, 140, 130, 120, 110], [100, 90, 80, 70, 60], [50, 40, 30, 20, 10], [200, 190, 180, 170, 160]],k = 2) == [[200, 190, 180, 170, 160], [150, 140, 130, 120, 110], [100, 90, 80, 70, 60], [50, 40, 30, 20, 10]]\n assert candidate(score = [[200, 150, 100, 50, 0], [400, 350, 300, 250, 200], [300, 250, 200, 150, 100]],k = 3) == [[400, 350, 300, 250, 200], [300, 250, 200, 150, 100], [200, 150, 100, 50, 0]]\n assert candidate(score = [[5, 4, 3, 2, 1], [9, 8, 7, 6, 5], [13, 12, 11, 10, 9], [17, 16, 15, 14, 13]],k = 4) == [[17, 16, 15, 14, 13], [13, 12, 11, 10, 9], [9, 8, 7, 6, 5], [5, 4, 3, 2, 1]]\n assert candidate(score = [[999, 998, 997, 996, 995, 994, 993, 992, 991, 990], [989, 988, 987, 986, 985, 984, 983, 982, 981, 980], [979, 978, 977, 976, 975, 974, 973, 972, 971, 970]],k = 7) == [[999, 998, 997, 996, 995, 994, 993, 992, 991, 990], [989, 988, 987, 986, 985, 984, 983, 982, 981, 980], [979, 978, 977, 976, 975, 974, 973, 972, 971, 970]]\n assert candidate(score = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 4, 5]],k = 4) == [[1, 2, 3, 4, 5], [3, 1, 2, 4, 5], [4, 5, 1, 2, 3], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1]]\n assert candidate(score = [[100000, 99999, 99998, 99997, 99996], [99995, 99994, 99993, 99992, 99991], [99990, 99989, 99988, 99987, 99986]],k = 1) == [[100000, 99999, 99998, 99997, 99996], [99995, 99994, 99993, 99992, 99991], [99990, 99989, 99988, 99987, 99986]]\n assert candidate(score = [[10, 20, 30, 40], [20, 30, 40, 50], [30, 40, 50, 60], [40, 50, 60, 70], [50, 60, 70, 80]],k = 3) == [[50, 60, 70, 80], [40, 50, 60, 70], [30, 40, 50, 60], [20, 30, 40, 50], [10, 20, 30, 40]]\n"}, "metadata": {"canonical_parameter_names": ["score", "k"], "leetcode_dataset_entry_point": "Solution().sortTheStudents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] sortTheStudents(int[][] score, int k) {", "container": "Solution", "callable": "sortTheStudents", "parameters": [{"name": "score", "type": "int[][]"}, {"name": "k", "type": "int"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2546, "task_id": "apply-bitwise-operations-to-make-strings-equal", "difficulty": "Medium", "problem_description": "You are given two 0-indexed binary strings s and target of the same length n. You can do the following operation on s any number of times:\n\nChoose two different indices i and j where 0 <= i, j < n.\nSimultaneously, replace s[i] with (s[i] OR s[j]) and s[j] with (s[i] XOR s[j]).\n\nFor example, if s = \"0110\", you can choose i = 0 and j = 2, then simultaneously replace s[0] with (s[0] OR s[2] = 0 OR 1 = 1), and s[2] with (s[0] XOR s[2] = 0 XOR 1 = 1), so we will have s = \"1110\".\nReturn true if you can make the string s equal to target, or false otherwise.\n \nExample 1:\n\nInput: s = \"1010\", target = \"0110\"\nOutput: true\nExplanation: We can do the following operations:\n- Choose i = 2 and j = 0. We have now s = \"0010\".\n- Choose i = 2 and j = 1. We have now s = \"0110\".\nSince we can make s equal to target, we return true.\n\nExample 2:\n\nInput: s = \"11\", target = \"00\"\nOutput: false\nExplanation: It is not possible to make s equal to target with any number of operations.\n\n \nConstraints:\n\nn == s.length == target.length\n2 <= n <= 105\ns and target consist of only the digits 0 and 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1001\",target = \"1001\") == True\n assert candidate(s = \"1010\",target = \"0110\") == True\n assert candidate(s = \"11\",target = \"00\") == False\n assert candidate(s = \"0000\",target = \"0000\") == True\n assert candidate(s = \"1100\",target = \"0011\") == True\n assert candidate(s = \"1101\",target = \"1101\") == True\n assert candidate(s = \"1111\",target = \"1111\") == True\n assert candidate(s = \"111000\",target = \"000111\") == True\n assert candidate(s = \"1001\",target = \"1100\") == True\n assert candidate(s = \"0101\",target = \"1010\") == True\n assert candidate(s = \"101010\",target = \"010101\") == True\n assert candidate(s = \"000111\",target = \"111000\") == True\n assert candidate(s = \"11110000000000000000\",target = \"00001111111111111111\") == True\n assert candidate(s = \"11001100110011001100\",target = \"00110011001100110011\") == True\n assert candidate(s = \"111100001111\",target = \"000011110000\") == True\n assert candidate(s = \"101010101010\",target = \"010101010101\") == True\n assert candidate(s = \"0000000000\",target = \"1010101010\") == False\n assert candidate(s = \"11111111111111111111\",target = \"11111111111111111111\") == True\n assert candidate(s = \"10010010010010010010\",target = \"01101101101101101101\") == True\n assert candidate(s = \"01010101010101010101\",target = \"10101010101010101010\") == True\n assert candidate(s = \"0101010101\",target = \"1010101010\") == True\n assert candidate(s = \"10101010101010\",target = \"01010101010101\") == True\n assert candidate(s = \"0110011001\",target = \"1001100110\") == True\n assert candidate(s = \"0101010101\",target = \"1010101011\") == True\n assert candidate(s = \"0101010101\",target = \"0000000000\") == False\n assert candidate(s = \"0000011111\",target = \"1111100000\") == True\n assert candidate(s = \"111000111000\",target = \"100111100111\") == True\n assert candidate(s = \"1000000001\",target = \"0111111110\") == True\n assert candidate(s = \"00000000000000000000\",target = \"10101010101010101010\") == False\n assert candidate(s = \"10101010101010101010101010101010\",target = \"01010101010101010101010101010101\") == True\n assert candidate(s = \"110101\",target = \"011010\") == True\n assert candidate(s = \"1010101010\",target = \"1111111111\") == True\n assert candidate(s = \"110000110000\",target = \"001111001111\") == True\n assert candidate(s = \"0000111100\",target = \"1111000011\") == True\n assert candidate(s = \"1111000011\",target = \"1100110011\") == True\n assert candidate(s = \"1001011011011011\",target = \"0110100100100100\") == True\n assert candidate(s = \"101010101010101010\",target = \"010101010101010101\") == True\n assert candidate(s = \"1000000001\",target = \"1000000001\") == True\n assert candidate(s = \"10101010101010101010101010\",target = \"01010101010101010101010101\") == True\n assert candidate(s = \"0000000000\",target = \"1111111111\") == False\n assert candidate(s = \"1111111111\",target = \"1111111111\") == True\n assert candidate(s = \"1100110011001100\",target = \"0011001100110011\") == True\n assert candidate(s = \"00000000000000000000\",target = \"11111111111111111111\") == False\n assert candidate(s = \"1111000011110000\",target = \"0000111100001111\") == True\n assert candidate(s = \"0010101110\",target = \"1001010110\") == True\n assert candidate(s = \"1111100000000000\",target = \"0000011111111111\") == True\n assert candidate(s = \"11000110001100011000\",target = \"00111001110011100111\") == True\n assert candidate(s = \"1001100110\",target = \"0110011001\") == True\n assert candidate(s = \"10101010101010101010\",target = \"01010101010101010101\") == True\n assert candidate(s = \"1111111100\",target = \"0000000011\") == True\n assert candidate(s = \"1101010101\",target = \"1110110110\") == True\n assert candidate(s = \"11110000111100001111\",target = \"00001111000011110000\") == True\n assert candidate(s = \"1100110011\",target = \"0011001100\") == True\n assert candidate(s = \"1010101010\",target = \"0101010101\") == True\n assert candidate(s = \"1010010101\",target = \"0101101010\") == True\n assert candidate(s = \"11111111000000001111\",target = \"11111111000000001111\") == True\n assert candidate(s = \"01001000100001001000\",target = \"10110111011110110111\") == True\n assert candidate(s = \"000011110000\",target = \"111100001111\") == True\n assert candidate(s = \"1000001000\",target = \"0010000010\") == True\n assert candidate(s = \"11100000000000000000\",target = \"11100000000000000000\") == True\n assert candidate(s = \"00000000000000000000\",target = \"00000000000000000000\") == True\n assert candidate(s = \"00001111\",target = \"11110000\") == True\n assert candidate(s = \"1111000011\",target = \"0000111100\") == True\n assert candidate(s = \"10000010000010000010\",target = \"01111101111101111101\") == True\n assert candidate(s = \"1110001110\",target = \"0001110001\") == True\n assert candidate(s = \"0001000100\",target = \"1110111011\") == True\n assert candidate(s = \"11111111111111111111\",target = \"00000000000000000000\") == False\n assert candidate(s = \"11001100110011001100\",target = \"10101010101010101010\") == True\n assert candidate(s = \"00001111111111110000\",target = \"11110000000000001111\") == True\n assert candidate(s = \"1111111111\",target = \"0000000000\") == False\n assert candidate(s = \"0101010101\",target = \"1101101101\") == True\n assert candidate(s = \"1101101101\",target = \"0010010010\") == True\n assert candidate(s = \"1010101010101010\",target = \"0101010101010101\") == True\n assert candidate(s = \"11001100\",target = \"00110011\") == True\n assert candidate(s = \"01001000100001001000\",target = \"01001000100001001000\") == True\n assert candidate(s = \"10101010\",target = \"01010101\") == True\n assert candidate(s = \"1001011011\",target = \"0110100100\") == True\n assert candidate(s = \"101101101101\",target = \"010010010010\") == True\n assert candidate(s = \"010010\",target = \"100100\") == True\n assert candidate(s = \"11110000\",target = \"00001111\") == True\n assert candidate(s = \"111000111000\",target = \"111000111000\") == True\n assert candidate(s = \"110011001100\",target = \"001100110011\") == True\n assert candidate(s = \"000111000111\",target = \"111000111000\") == True\n assert candidate(s = \"1101110111\",target = \"0010001000\") == True\n assert candidate(s = \"11111111111100000000\",target = \"00000000000011111111\") == True\n assert candidate(s = \"10100101001010010100\",target = \"01011010110101101011\") == True\n assert candidate(s = \"10101010101010101010\",target = \"11111111111111111111\") == True\n assert candidate(s = \"001100110011\",target = \"110011001100\") == True\n assert candidate(s = \"1111100000\",target = \"0000011111\") == True\n assert candidate(s = \"000000\",target = \"000000\") == True\n assert candidate(s = \"1111110000\",target = \"0000001111\") == True\n assert candidate(s = \"100010001000\",target = \"011101110111\") == True\n assert candidate(s = \"1010101010\",target = \"1010101011\") == True\n assert candidate(s = \"111111\",target = \"111111\") == True\n assert candidate(s = \"1110001110\",target = \"1110001110\") == True\n"}, "metadata": {"canonical_parameter_names": ["s", "target"], "leetcode_dataset_entry_point": "Solution().makeStringsEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean makeStringsEqual(String s, String target) {", "container": "Solution", "callable": "makeStringsEqual", "parameters": [{"name": "s", "type": "String"}, {"name": "target", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2547, "task_id": "minimum-cost-to-split-an-array", "difficulty": "Hard", "problem_description": "You are given an integer array nums and an integer k.\nSplit the array into some number of non-empty subarrays. The cost of a split is the sum of the importance value of each subarray in the split.\nLet trimmed(subarray) be the version of the subarray where all numbers which appear only once are removed.\n\nFor example, trimmed([3,1,2,4,3,4]) = [3,4,3,4].\n\nThe importance value of a subarray is k + trimmed(subarray).length.\n\nFor example, if a subarray is [1,2,3,3,3,4,4], then trimmed([1,2,3,3,3,4,4]) = [3,3,3,4,4].The importance value of this subarray will be k + 5.\n\nReturn the minimum possible cost of a split of nums.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,2,1,2,1,3,3], k = 2\nOutput: 8\nExplanation: We split nums to have two subarrays: [1,2], [1,2,1,3,3].\nThe importance value of [1,2] is 2 + (0) = 2.\nThe importance value of [1,2,1,3,3] is 2 + (2 + 2) = 6.\nThe cost of the split is 2 + 6 = 8. It can be shown that this is the minimum possible cost among all the possible splits.\n\nExample 2:\n\nInput: nums = [1,2,1,2,1], k = 2\nOutput: 6\nExplanation: We split nums to have two subarrays: [1,2], [1,2,1].\nThe importance value of [1,2] is 2 + (0) = 2.\nThe importance value of [1,2,1] is 2 + (2) = 4.\nThe cost of the split is 2 + 4 = 6. It can be shown that this is the minimum possible cost among all the possible splits.\n\nExample 3:\n\nInput: nums = [1,2,1,2,1], k = 5\nOutput: 10\nExplanation: We split nums to have one subarray: [1,2,1,2,1].\nThe importance value of [1,2,1,2,1] is 5 + (3 + 2) = 10.\nThe cost of the split is 10. It can be shown that this is the minimum possible cost among all the possible splits.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n0 <= nums[i] < nums.length\n1 <= k <= 109\n\n \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],k = 4) == 14\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],k = 1) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 1\n assert candidate(nums = [1],k = 10) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 15\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],k = 5) == 15\n assert candidate(nums = [1, 2],k = 1) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 3\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 3) == 18\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 3) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(nums = [1, 3, 2, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 3) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 3\n assert candidate(nums = [1, 2, 1, 2, 1, 3, 3],k = 2) == 8\n assert candidate(nums = [1],k = 100) == 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],k = 7) == 27\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 = 4) == 14\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 6) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 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, 11, 11],k = 8) == 30\n assert candidate(nums = [1, 2, 1, 2, 1],k = 2) == 6\n assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 7) == 17\n assert candidate(nums = [1, 2, 1, 2, 1],k = 5) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 6\n assert candidate(nums = [1, 2, 3, 4, 5],k = 10) == 10\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 2) == 12\n assert candidate(nums = [5, 4, 3, 2, 1],k = 3) == 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, 11, 11, 12, 12, 13, 13, 14, 14],k = 15) == 43\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],k = 8) == 16\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 = 4) == 34\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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 12) == 60\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 3) == 18\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7],k = 12) == 39\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) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 25\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 3) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1],k = 6) == 24\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 = 10) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6) == 18\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5) == 21\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],k = 4) == 26\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 = 7) == 27\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 5, 4, 7, 8, 9, 8, 7, 10, 11, 12, 11, 10],k = 8) == 24\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) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 52\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) == 30\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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 6) == 36\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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 4) == 46\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1, 4, 4, 3, 3, 2, 2, 1, 1],k = 4) == 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 = 2) == 22\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 = 15) == 30\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],k = 9) == 39\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) == 10\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 = 9) == 39\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],k = 10) == 30\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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1],k = 6) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 7) == 14\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],k = 15) == 59\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 = 12) == 36\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 3) == 18\n assert candidate(nums = [1, 2, 3, 3, 2, 1, 4, 5, 5, 4, 6, 7, 7, 6, 8, 9, 9, 8, 10, 11, 11, 10],k = 9) == 31\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) == 9\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) == 27\n assert candidate(nums = [1, 2, 1, 2, 1, 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],k = 5) == 43\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 10) == 20\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],k = 20) == 44\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 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],k = 10) == 76\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 3) == 18\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) == 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, 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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == 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],k = 25) == 25\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],k = 5) == 26\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 = 1) == 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, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 2) == 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],k = 3) == 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, 7, 8, 9, 10],k = 10) == 30\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, 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 = 7) == 57\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 = 8) == 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, 3, 1, 2, 3, 1, 2, 3],k = 9) == 36\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, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5) == 71\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 = 4) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 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],k = 8) == 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],k = 1) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 31\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],k = 6) == 30\n assert candidate(nums = [1, 2, 1, 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 = 6) == 20\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6],k = 8) == 27\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 = 6) == 26\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2],k = 7) == 26\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2],k = 7) == 27\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 51\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 = 6) == 26\n assert candidate(nums = [1, 2, 2, 1, 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],k = 9) == 40\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],k = 9) == 36\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) == 20\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],k = 10) == 26\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 3) == 23\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, 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 = 15) == 74\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],k = 5) == 23\n assert candidate(nums = [1, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 3) == 17\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],k = 7) == 31\n assert candidate(nums = [10, 11, 10, 12, 11, 12, 13, 13, 14, 14, 14, 15, 15, 15, 15],k = 4) == 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, 10, 10],k = 8) == 38\n assert candidate(nums = [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],k = 10) == 37\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 = 8) == 8\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 10) == 25\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1],k = 10) == 25\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 = 7) == 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],k = 15) == 30\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 15) == 35\n assert candidate(nums = [1, 2, 1, 2, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 7) == 28\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 4) == 18\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 3) == 23\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minCost(int[] nums, int k) {", "container": "Solution", "callable": "minCost", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2549, "task_id": "count-distinct-numbers-on-board", "difficulty": "Easy", "problem_description": "You are given a positive integer n, that is initially placed on a board. Every day, for 109 days, you perform the following procedure:\n\nFor each number x present on the board, find all numbers 1 <= i <= n such that x % i == 1.\nThen, place those numbers on the board.\n\nReturn the number of distinct integers present on the board after 109 days have elapsed.\nNote:\n\nOnce a number is placed on the board, it will remain on it until the end.\n% stands for the modulo operation. For example, 14 % 3 is 2.\n\n \nExample 1:\n\nInput: n = 5\nOutput: 4\nExplanation: Initially, 5 is present on the board. \nThe next day, 2 and 4 will be added since 5 % 2 == 1 and 5 % 4 == 1. \nAfter that day, 3 will be added to the board because 4 % 3 == 1. \nAt the end of a billion days, the distinct numbers on the board will be 2, 3, 4, and 5. \n\nExample 2:\n\nInput: n = 3\nOutput: 2\nExplanation: \nSince 3 % 2 == 1, 2 will be added to the board. \nAfter a billion days, the only two distinct numbers on the board are 2 and 3. \n\n \nConstraints:\n\n1 <= n <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 99) == 98\n assert candidate(n = 20) == 19\n assert candidate(n = 100) == 99\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 9\n assert candidate(n = 5) == 4\n assert candidate(n = 97) == 96\n assert candidate(n = 88) == 87\n assert candidate(n = 29) == 28\n assert candidate(n = 45) == 44\n assert candidate(n = 61) == 60\n assert candidate(n = 49) == 48\n assert candidate(n = 47) == 46\n assert candidate(n = 82) == 81\n assert candidate(n = 70) == 69\n assert candidate(n = 50) == 49\n assert candidate(n = 34) == 33\n assert candidate(n = 28) == 27\n assert candidate(n = 60) == 59\n assert candidate(n = 87) == 86\n assert candidate(n = 30) == 29\n assert candidate(n = 95) == 94\n assert candidate(n = 67) == 66\n assert candidate(n = 40) == 39\n assert candidate(n = 37) == 36\n assert candidate(n = 64) == 63\n assert candidate(n = 17) == 16\n assert candidate(n = 98) == 97\n assert candidate(n = 2) == 1\n assert candidate(n = 23) == 22\n assert candidate(n = 73) == 72\n assert candidate(n = 80) == 79\n assert candidate(n = 89) == 88\n assert candidate(n = 75) == 74\n assert candidate(n = 71) == 70\n assert candidate(n = 91) == 90\n assert candidate(n = 77) == 76\n assert candidate(n = 81) == 80\n assert candidate(n = 13) == 12\n assert candidate(n = 11) == 10\n assert candidate(n = 85) == 84\n assert candidate(n = 41) == 40\n assert candidate(n = 31) == 30\n assert candidate(n = 83) == 82\n assert candidate(n = 65) == 64\n assert candidate(n = 55) == 54\n assert candidate(n = 7) == 6\n assert candidate(n = 90) == 89\n assert candidate(n = 25) == 24\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().distinctIntegers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int distinctIntegers(int n) {", "container": "Solution", "callable": "distinctIntegers", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2551, "task_id": "put-marbles-in-bags", "difficulty": "Hard", "problem_description": "You have k bags. You are given a 0-indexed integer array weights where weights[i] is the weight of the ith marble. You are also given the integer k.\nDivide the marbles into the k bags according to the following rules:\n\nNo bag is empty.\nIf the ith marble and jth marble are in a bag, then all marbles with an index between the ith and jth indices should also be in that same bag.\nIf a bag consists of all the marbles with an index from i to j inclusively, then the cost of the bag is weights[i] + weights[j].\n\nThe score after distributing the marbles is the sum of the costs of all the k bags.\nReturn the difference between the maximum and minimum scores among marble distributions.\n \nExample 1:\n\nInput: weights = [1,3,5,1], k = 2\nOutput: 4\nExplanation: \nThe distribution [1],[3,5,1] results in the minimal score of (1+1) + (3+1) = 6. \nThe distribution [1,3],[5,1], results in the maximal score of (1+3) + (5+1) = 10. \nThus, we return their difference 10 - 6 = 4.\n\nExample 2:\n\nInput: weights = [1, 3], k = 2\nOutput: 0\nExplanation: The only distribution possible is [1],[3]. \nSince both the maximal and minimal score are the same, we return 0.\n\n \nConstraints:\n\n1 <= k <= weights.length <= 105\n1 <= weights[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(weights = [1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 0\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n assert candidate(weights = [1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(weights = [5, 5, 5, 5, 5, 5],k = 4) == 0\n assert candidate(weights = [1, 3],k = 2) == 0\n assert candidate(weights = [4, 1, 2, 2, 7, 1, 3, 2],k = 3) == 10\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n assert candidate(weights = [1, 3, 5, 1],k = 2) == 4\n assert candidate(weights = [4, 1, 5, 1, 2],k = 3) == 4\n assert candidate(weights = [5, 5, 5, 5, 5, 5],k = 2) == 0\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == 30\n assert candidate(weights = [4, 1, 5, 1, 2],k = 3) == 4\n assert candidate(weights = [10, 20, 30, 40, 50],k = 4) == 60\n assert candidate(weights = [10, 20, 30, 40, 50],k = 2) == 60\n assert candidate(weights = [10, 20, 30, 40, 50],k = 2) == 60\n assert candidate(weights = [1, 2, 3, 4, 5],k = 3) == 8\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n assert candidate(weights = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],k = 5) == 0\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 0\n assert candidate(weights = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],k = 5) == 560\n assert candidate(weights = [1000000000, 500000000, 1000000000, 500000000, 1000000000],k = 3) == 0\n assert candidate(weights = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 30\n assert candidate(weights = [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],k = 15) == 0\n assert candidate(weights = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],k = 15) == 0\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 96\n assert candidate(weights = [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 = 15) == 280\n assert candidate(weights = [100, 200, 100, 200, 100, 200, 100],k = 4) == 0\n assert candidate(weights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 10) == 0\n assert candidate(weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(weights = [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],k = 13) == 0\n assert candidate(weights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 8) == 0\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 180\n assert candidate(weights = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 4000\n assert candidate(weights = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 3) == 280\n assert candidate(weights = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 4) == 300\n assert candidate(weights = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],k = 4) == 122087790\n assert candidate(weights = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000],k = 4) == 12208779\n assert candidate(weights = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2],k = 7) == 0\n assert candidate(weights = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 3) == 0\n assert candidate(weights = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 6) == 700\n assert candidate(weights = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 3) == 280\n assert candidate(weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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) == 0\n assert candidate(weights = [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) == 1200\n assert candidate(weights = [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 = 25) == 720\n assert candidate(weights = [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) == 380\n assert candidate(weights = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 10) == 18000\n assert candidate(weights = [2, 3, 4, 1, 6, 7, 8],k = 4) == 18\n assert candidate(weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 0\n assert candidate(weights = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],k = 4) == 0\n assert candidate(weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(weights = [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) == 0\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == 90\n assert candidate(weights = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 7) == 6000\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 120\n assert candidate(weights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 9) == 72\n assert candidate(weights = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 32\n assert candidate(weights = [1, 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) == 0\n assert candidate(weights = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888],k = 5) == 2777777775\n assert candidate(weights = [2, 1, 3, 4, 5, 6, 7],k = 4) == 19\n assert candidate(weights = [500000000, 1, 500000000, 1, 500000000, 1, 500000000],k = 3) == 0\n assert candidate(weights = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 6) == 50\n assert candidate(weights = [20, 15, 10, 5, 1, 2, 3, 4, 5, 10, 15, 20],k = 4) == 81\n assert candidate(weights = [5, 1, 3, 8, 2, 9, 4, 7, 6, 10],k = 3) == 19\n assert candidate(weights = [1, 2, 3, 4, 5],k = 1) == 0\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 0\n assert candidate(weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(weights = [5, 1, 3, 2, 4, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 144\n assert candidate(weights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 6) == 0\n assert candidate(weights = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 5) == 0\n assert candidate(weights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 80\n assert candidate(weights = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 24\n assert candidate(weights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 800\n assert candidate(weights = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200],k = 3) == 0\n assert candidate(weights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 400\n assert candidate(weights = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 6) == 4000\n assert candidate(weights = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 3) == 28\n assert candidate(weights = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 5) == 320\n assert candidate(weights = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5],k = 10) == 0\n assert candidate(weights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 960\n assert candidate(weights = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],k = 6) == 39\n assert candidate(weights = [9, 1, 8, 2, 7, 3, 6, 4, 5],k = 3) == 2\n assert candidate(weights = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 2) == 1099999989\n assert candidate(weights = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995],k = 3) == 12\n assert candidate(weights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 13) == 96\n assert candidate(weights = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],k = 4) == 35\n assert candidate(weights = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1],k = 4) == 0\n assert candidate(weights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 6) == 1400\n"}, "metadata": {"canonical_parameter_names": ["weights", "k"], "leetcode_dataset_entry_point": "Solution().putMarbles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long putMarbles(int[] weights, int k) {", "container": "Solution", "callable": "putMarbles", "parameters": [{"name": "weights", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2552, "task_id": "count-increasing-quadruplets", "difficulty": "Hard", "problem_description": "Given a 0-indexed integer array nums of size n containing all numbers from 1 to n, return the number of increasing quadruplets.\nA quadruplet (i, j, k, l) is increasing if:\n\n0 <= i < j < k < l < n, and\nnums[i] < nums[k] < nums[j] < nums[l].\n\n \nExample 1:\n\nInput: nums = [1,3,2,4,5]\nOutput: 2\nExplanation: \n- When i = 0, j = 1, k = 2, and l = 3, nums[i] < nums[k] < nums[j] < nums[l].\n- When i = 0, j = 1, k = 2, and l = 4, nums[i] < nums[k] < nums[j] < nums[l]. \nThere are no other quadruplets, so we return 2.\n\nExample 2:\n\nInput: nums = [1,2,3,4]\nOutput: 0\nExplanation: There exists only one quadruplet with i = 0, j = 1, k = 2, l = 3, but since nums[j] < nums[k], we return 0.\n\n \nConstraints:\n\n4 <= nums.length <= 4000\n1 <= nums[i] <= nums.length\nAll the integers of nums are unique. nums is a permutation.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == 2\n assert candidate(nums = [4, 3, 2, 1]) == 0\n assert candidate(nums = [4, 3, 2, 1, 5, 6]) == 0\n assert candidate(nums = [3, 1, 4, 2, 5, 6, 9, 7, 8, 10]) == 18\n assert candidate(nums = [5, 2, 3, 1, 4, 6, 7]) == 0\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 7]) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [3, 1, 2, 4, 5]) == 0\n assert candidate(nums = [2, 3, 1, 5, 4, 8, 7, 10, 9, 6]) == 25\n assert candidate(nums = [1, 2, 3, 4]) == 0\n assert candidate(nums = [5, 1, 4, 2, 3]) == 0\n assert candidate(nums = [3, 1, 2, 6, 5, 4, 9, 7, 10, 8]) == 42\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 35\n assert candidate(nums = [1, 4, 3, 2, 5]) == 3\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7]) == 0\n assert candidate(nums = [1, 2, 4, 3, 5, 6, 7]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 0\n assert candidate(nums = [5, 2, 3, 4, 1, 6, 7]) == 0\n assert candidate(nums = [1, 4, 2, 3, 5]) == 2\n assert candidate(nums = [2, 3, 1, 4, 5]) == 0\n assert candidate(nums = [5, 1, 4, 3, 2]) == 0\n assert candidate(nums = [20, 1, 18, 3, 16, 5, 14, 7, 12, 9, 10, 11, 8, 13, 6, 15, 4, 17, 2, 19]) == 370\n assert candidate(nums = [25, 15, 5, 30, 20, 10, 2, 24, 14, 4, 23, 13, 3, 22, 12, 1, 21, 11, 19, 9, 18, 8, 17, 7, 16, 6]) == 252\n assert candidate(nums = [1, 15, 3, 14, 4, 13, 5, 12, 6, 11, 7, 10, 8, 9, 2]) == 0\n assert candidate(nums = [4, 10, 3, 6, 2, 8, 1, 7, 5, 9]) == 13\n assert candidate(nums = [30, 1, 29, 2, 28, 3, 27, 4, 26, 5, 25, 6, 24, 7, 23, 8, 22, 9, 21, 10, 20, 11, 19, 12, 18, 13, 17, 14, 16, 15]) == 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]) == 0\n assert candidate(nums = [7, 1, 6, 2, 5, 3, 4]) == 0\n assert candidate(nums = [5, 2, 8, 3, 7, 4, 10, 6, 1, 9]) == 17\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]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [6, 1, 8, 3, 9, 2, 10, 5, 7, 4]) == 8\n assert candidate(nums = [12, 1, 11, 2, 10, 3, 9, 4, 8, 5, 7, 6]) == 0\n assert candidate(nums = [20, 1, 19, 2, 18, 3, 17, 4, 16, 5, 15, 6, 14, 7, 13, 8, 12, 9, 11, 10]) == 0\n assert candidate(nums = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [2, 3, 5, 1, 7, 6, 10, 9, 12, 11, 15, 14, 18, 17, 20, 19, 22, 21, 24, 23]) == 448\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5]) == 0\n assert candidate(nums = [1, 6, 3, 2, 8, 5, 4, 9, 10, 7]) == 41\n assert candidate(nums = [8, 6, 5, 7, 4, 3, 2, 1, 9, 10, 11, 12]) == 0\n assert candidate(nums = [12, 1, 11, 2, 10, 3, 9, 4, 8, 5, 7, 6]) == 0\n assert candidate(nums = [1, 4, 2, 7, 3, 8, 5, 10, 6, 11, 9, 14, 12, 15, 13]) == 224\n assert candidate(nums = [4, 7, 10, 2, 6, 8, 3, 5, 9, 1]) == 9\n assert candidate(nums = [15, 1, 14, 2, 13, 3, 12, 4, 11, 5, 10, 6, 9, 7, 8]) == 0\n assert candidate(nums = [10, 1, 2, 9, 3, 8, 4, 7, 5, 6]) == 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]) == 0\n assert candidate(nums = [3, 8, 5, 2, 9, 4, 7, 1, 6, 10]) == 20\n assert candidate(nums = [40, 1, 39, 2, 38, 3, 37, 4, 36, 5, 35, 6, 34, 7, 33, 8, 32, 9, 31, 10, 30, 11, 29, 12, 28, 13, 27, 14, 26, 15, 25, 16, 24, 17, 23, 18, 22, 19, 21, 20]) == 0\n assert candidate(nums = [30, 27, 21, 24, 15, 26, 18, 23, 10, 25, 12, 22, 6, 20, 9, 19, 3, 17, 2, 16, 5, 14, 8, 13, 1, 11, 7]) == 3\n assert candidate(nums = [10, 1, 3, 2, 9, 5, 7, 4, 8, 6]) == 15\n assert candidate(nums = [20, 1, 19, 2, 18, 3, 17, 4, 16, 5, 15, 6, 14, 7, 13, 8, 12, 9, 11, 10]) == 0\n assert candidate(nums = [15, 1, 14, 2, 13, 3, 12, 4, 11, 5, 10, 6, 9, 7, 8]) == 0\n assert candidate(nums = [10, 1, 3, 5, 2, 6, 4, 7, 8, 9]) == 24\n assert candidate(nums = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13]) == 270\n assert candidate(nums = [1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 3]) == 140\n assert candidate(nums = [30, 1, 29, 2, 28, 3, 27, 4, 26, 5, 25, 6, 24, 7, 23, 8, 22, 9, 21, 10, 20, 11, 19, 12, 18, 13, 17, 14, 16, 15]) == 0\n assert candidate(nums = [4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 14, 13, 12, 11]) == 240\n assert candidate(nums = [4, 1, 5, 3, 8, 2, 7, 6, 10, 9]) == 41\n assert candidate(nums = [7, 1, 5, 3, 9, 2, 8, 4, 10, 6]) == 23\n assert candidate(nums = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 0\n assert candidate(nums = [3, 5, 2, 1, 6, 4, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 448\n assert candidate(nums = [3, 6, 1, 5, 8, 2, 7, 4, 10, 9]) == 33\n assert candidate(nums = [3, 7, 5, 4, 10, 6, 1, 9, 8, 2]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 0\n assert candidate(nums = [8, 1, 7, 2, 6, 3, 5, 4]) == 0\n assert candidate(nums = [4000, 3999, 3998, 3997, 3996, 3995, 3994, 3993, 3992, 3991, 3990, 3989, 3988, 3987, 3986, 3985, 3984, 3983, 3982, 3981, 3980, 3979, 3978, 3977, 3976, 3975, 3974, 3973, 3972, 3971, 3970, 3969, 3968, 3967, 3966, 3965, 3964, 3963, 3962, 3961, 3960, 3959, 3958, 3957, 3956, 3955, 3954, 3953, 3952, 3951, 3950, 3949, 3948, 3947, 3946, 3945, 3944, 3943, 3942, 3941, 3940, 3939, 3938, 3937, 3936, 3935, 3934, 3933, 3932, 3931, 3930, 3929, 3928, 3927, 3926, 3925, 3924, 3923, 3922, 3921, 3920, 3919, 3918, 3917, 3916, 3915, 3914, 3913, 3912, 3911, 3910, 3909, 3908, 3907, 3906, 3905, 3904, 3903, 3902, 3901, 3900, 3899, 3898, 3897, 3896, 3895, 3894, 3893, 3892, 3891, 3890, 3889, 3888, 3887, 3886, 3885, 3884, 3883, 3882, 3881, 3880, 3879, 3878, 3877, 3876, 3875, 3874, 3873, 3872, 3871, 3870, 3869, 3868, 3867, 3866, 3865, 3864, 3863, 3862, 3861, 3860, 3859, 3858, 3857, 3856, 3855, 3854, 3853, 3852, 3851, 3850, 3849, 3848, 3847, 3846, 3845, 3844, 3843, 3842, 3841, 3840, 3839, 3838, 3837, 3836, 3835, 3834, 3833, 3832, 3831, 3830, 3829, 3828, 3827, 3826, 3825, 3824, 3823, 3822, 3821, 3820, 3819, 3818, 3817, 3816, 3815, 3814, 3813, 3812, 3811, 3810, 3809, 3808, 3807, 3806, 3805, 3804, 3803, 3802, 3801, 3800, 3799, 3798, 3797, 3796, 3795, 3794, 3793, 3792, 3791, 3790, 3789, 3788, 3787, 3786, 3785, 3784, 3783, 3782, 3781, 3780, 3779, 3778, 3777, 3776, 3775, 3774, 3773, 3772, 3771, 3770, 3769, 3768, 3767, 3766, 3765, 3764, 3763, 3762, 3761, 3760, 3759, 3758, 3757, 3756, 3755, 3754, 3753, 3752, 3751, 3750, 3749, 3748, 3747, 3746, 3745, 3744, 3743, 3742, 3741, 3740, 3739, 3738, 3737, 3736, 3735, 3734, 3733, 3732, 3731, 3730, 3729, 3728, 3727, 3726, 3725, 3724, 3723, 3722, 3721, 3720, 3719, 3718, 3717, 3716, 3715, 3714, 3713, 3712, 3711, 3710, 3709, 3708, 3707, 3706, 3705, 3704, 3703, 3702, 3701, 3700, 1]) == 0\n assert candidate(nums = [8, 1, 10, 4, 6, 2, 9, 3, 7, 5]) == 8\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 480\n assert candidate(nums = [4000, 3999, 3998, 3997, 3996, 3995, 3994, 3993, 3992, 3991, 3990, 3989, 3988, 3987, 3986, 3985, 3984, 3983, 3982, 3981, 3980, 3979, 3978, 3977, 3976, 3975, 3974, 3973, 3972, 3971, 3970, 3969, 3968, 3967, 3966, 3965, 3964, 3963, 3962, 3961, 3960, 3959, 3958, 3957, 3956, 3955, 3954, 3953, 3952, 3951, 3950, 3949, 3948, 3947, 3946, 3945, 3944, 3943, 3942, 3941, 3940, 3939, 3938, 3937, 3936, 3935, 3934, 3933, 3932, 3931, 3930, 3929, 3928, 3927, 3926, 3925, 3924, 3923, 3922, 3921, 3920, 3919, 3918, 3917, 3916, 3915, 3914, 3913, 3912, 3911, 3910, 3909, 3908, 3907, 3906, 3905, 3904, 3903, 3902, 3901, 3900, 3899, 3898, 3897, 3896, 3895, 3894, 3893, 3892, 3891, 3890, 3889, 3888, 3887, 3886, 3885, 3884, 3883, 3882, 3881, 3880, 3879, 3878, 3877, 3876, 3875, 3874, 3873, 3872, 3871, 3870, 3869, 3868, 3867, 3866, 3865, 3864, 3863, 3862, 3861, 3860, 3859, 3858, 3857, 3856, 3855, 3854, 3853, 3852, 3851, 3850, 3849, 3848, 3847, 3846, 3845, 3844, 3843, 3842, 3841, 3840, 3839, 3838, 3837, 3836, 3835, 3834, 3833, 3832, 3831, 3830, 3829, 3828, 3827, 3826, 3825, 3824, 3823, 3822, 3821, 3820, 3819, 3818, 3817, 3816, 3815, 3814, 3813, 3812, 3811, 3810, 3809, 3808, 3807, 3806, 3805, 3804, 3803, 3802, 3801, 3800, 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(nums = [15, 1, 6, 9, 3, 11, 4, 14, 2, 7, 13, 5, 12, 8, 10]) == 83\n assert candidate(nums = [7, 2, 9, 4, 10, 3, 1, 8, 5, 6]) == 4\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 0\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 182\n assert candidate(nums = [9, 2, 7, 5, 1, 8, 3, 6, 10, 4]) == 11\n assert candidate(nums = [1, 5, 2, 9, 3, 6, 4, 7, 8, 10]) == 34\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10]) == 30\n assert candidate(nums = [10, 3, 6, 7, 2, 5, 9, 1, 8, 4]) == 4\n assert candidate(nums = [4, 3, 5, 1, 6, 2, 7, 8, 9, 10]) == 4\n assert candidate(nums = [7, 1, 3, 10, 2, 8, 5, 9, 4, 6]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16]) == 1000\n assert candidate(nums = [1, 20, 2, 19, 3, 18, 4, 17, 5, 16, 6, 15, 7, 14, 8, 13, 9, 12, 10, 11]) == 0\n assert candidate(nums = [1, 5, 7, 3, 6, 9, 2, 10, 8, 4]) == 23\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]) == 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]) == 0\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981, 1980, 1979, 1978, 1977, 1976, 1975, 1974, 1973, 1972, 1971, 1970, 1969, 1968, 1967, 1966, 1965, 1964, 1963, 1962, 1961, 1960, 1959, 1958, 1957, 1956, 1955, 1954, 1953, 1952, 1951, 1950, 1949, 1948, 1947, 1946, 1945, 1944, 1943, 1942, 1941, 1940, 1939, 1938, 1937, 1936, 1935, 1934, 1933, 1932, 1931, 1930, 1929, 1928, 1927, 1926, 1925, 1924, 1923, 1922, 1921, 1920, 1919, 1918, 1917, 1916, 1915, 1914, 1913, 1912, 1911, 1910, 1909, 1908, 1907, 1906, 1905, 1904, 1903, 1902, 1901, 1900, 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, 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]) == 0\n assert candidate(nums = [10, 2, 7, 4, 6, 3, 9, 1, 8, 5]) == 11\n assert candidate(nums = [7, 1, 5, 3, 6, 2, 4, 8, 9]) == 16\n assert candidate(nums = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 0\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 40\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countQuadruplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countQuadruplets(int[] nums) {", "container": "Solution", "callable": "countQuadruplets", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2553, "task_id": "separate-the-digits-in-an-array", "difficulty": "Easy", "problem_description": "Given an array of positive integers nums, return an array answer that consists of the digits of each integer in nums after separating them in the same order they appear in nums.\nTo separate the digits of an integer is to get all the digits it has in the same order.\n\nFor example, for the integer 10921, the separation of its digits is [1,0,9,2,1].\n\n \nExample 1:\n\nInput: nums = [13,25,83,77]\nOutput: [1,3,2,5,8,3,7,7]\nExplanation: \n- The separation of 13 is [1,3].\n- The separation of 25 is [2,5].\n- The separation of 83 is [8,3].\n- The separation of 77 is [7,7].\nanswer = [1,3,2,5,8,3,7,7]. Note that answer contains the separations in the same order.\n\nExample 2:\n\nInput: nums = [7,1,3,9]\nOutput: [7,1,3,9]\nExplanation: The separation of each integer in nums is itself.\nanswer = [7,1,3,9].\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10921, 456, 78]) == [1, 0, 9, 2, 1, 4, 5, 6, 7, 8]\n assert candidate(nums = [98765, 43210, 11111, 22222]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]\n assert candidate(nums = [98765, 43210]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [7, 1, 3, 9]) == [7, 1, 3, 9]\n assert candidate(nums = [999, 888, 777, 666, 555]) == [9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5]\n assert candidate(nums = [10921, 123, 456, 789]) == [1, 0, 9, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [10921, 2024, 55]) == [1, 0, 9, 2, 1, 2, 0, 2, 4, 5, 5]\n assert candidate(nums = [100, 200, 300, 400]) == [1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0]\n assert candidate(nums = [9, 99, 999, 9999, 99999]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [13, 25, 83, 77]) == [1, 3, 2, 5, 8, 3, 7, 7]\n assert candidate(nums = [10921, 123, 4567, 89]) == [1, 0, 9, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [98765, 43210, 10203]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 2, 0, 3]\n assert candidate(nums = [111, 222, 333, 444]) == [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]\n assert candidate(nums = [12345, 67890, 111]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [111, 222, 333]) == [1, 1, 1, 2, 2, 2, 3, 3, 3]\n assert candidate(nums = [505, 303, 101]) == [5, 0, 5, 3, 0, 3, 1, 0, 1]\n assert candidate(nums = [10921, 2023]) == [1, 0, 9, 2, 1, 2, 0, 2, 3]\n assert candidate(nums = [12345, 67890, 11111]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 1, 1, 1, 1]\n assert candidate(nums = [1234567, 8765432, 13579, 24680]) == [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 3, 5, 7, 9, 2, 4, 6, 8, 0]\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000]) == [1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0]\n assert candidate(nums = [99998, 88887, 77776, 66665, 55554]) == [9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4]\n assert candidate(nums = [1, 11, 111, 1111, 11111]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [9876543210, 1234567890]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\n assert candidate(nums = [1234, 5678, 91011, 1213]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3]\n assert candidate(nums = [1234, 56789, 1011121314, 1516171819]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9]\n assert candidate(nums = [987654321, 123456789, 1122334455]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]\n assert candidate(nums = [987654321, 123456789, 111111111, 222222222]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [54321, 12345, 98765, 56789, 23456]) == [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 9, 8, 7, 6, 5, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6]\n assert candidate(nums = [102030405, 504030201, 123321, 456654]) == [1, 0, 2, 0, 3, 0, 4, 0, 5, 5, 0, 4, 0, 3, 0, 2, 0, 1, 1, 2, 3, 3, 2, 1, 4, 5, 6, 6, 5, 4]\n assert candidate(nums = [192837465, 111222333, 444555666, 777888999, 999]) == [1, 9, 2, 8, 3, 7, 4, 6, 5, 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, 9, 9, 9]\n assert candidate(nums = [123, 456, 789, 101, 202, 303]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 2, 0, 2, 3, 0, 3]\n assert candidate(nums = [123456, 789012, 345678, 901234]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]\n assert candidate(nums = [100001, 200002, 300003, 400004, 500005, 600006, 700007, 800008, 900009]) == [1, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 3, 4, 0, 0, 0, 0, 4, 5, 0, 0, 0, 0, 5, 6, 0, 0, 0, 0, 6, 7, 0, 0, 0, 0, 7, 8, 0, 0, 0, 0, 8, 9, 0, 0, 0, 0, 9]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5]\n assert candidate(nums = [987654, 321098, 7654321, 111222333]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3]\n assert candidate(nums = [50505, 101010, 2020202]) == [5, 0, 5, 0, 5, 1, 0, 1, 0, 1, 0, 2, 0, 2, 0, 2, 0, 2]\n assert candidate(nums = [123, 456, 789, 101112, 131415]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5]\n assert candidate(nums = [54321, 12345, 67890, 98765]) == [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5]\n assert candidate(nums = [112233, 445566, 778899, 101010, 202020, 303030, 404040]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 1, 0, 1, 0, 1, 0, 2, 0, 2, 0, 2, 0, 3, 0, 3, 0, 3, 0, 4, 0, 4, 0, 4, 0]\n assert candidate(nums = [100001, 200002, 300003, 400004]) == [1, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 3, 4, 0, 0, 0, 0, 4]\n assert candidate(nums = [9, 98, 987, 9876, 98765, 987654, 9876543]) == [9, 9, 8, 9, 8, 7, 9, 8, 7, 6, 9, 8, 7, 6, 5, 9, 8, 7, 6, 5, 4, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == [1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0]\n assert candidate(nums = [98765, 43210, 112233, 445566, 778899]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]\n assert candidate(nums = [100005, 20304, 506070, 80900]) == [1, 0, 0, 0, 0, 5, 2, 0, 3, 0, 4, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 0]\n assert candidate(nums = [111111, 222222, 333333, 444444]) == [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [123, 456, 789, 101112]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2]\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]\n assert candidate(nums = [1234567890, 9876543210, 112233445566778899]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]\n assert candidate(nums = [101010, 202020, 303030, 404040]) == [1, 0, 1, 0, 1, 0, 2, 0, 2, 0, 2, 0, 3, 0, 3, 0, 3, 0, 4, 0, 4, 0, 4, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == [1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0]\n assert candidate(nums = [1234, 5678, 91011, 121314]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4]\n assert candidate(nums = [123456789, 987654321, 111222333]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3]\n assert candidate(nums = [1001001, 2002002, 3003003, 4004004]) == [1, 0, 0, 1, 0, 0, 1, 2, 0, 0, 2, 0, 0, 2, 3, 0, 0, 3, 0, 0, 3, 4, 0, 0, 4, 0, 0, 4]\n assert candidate(nums = [10101, 20202, 30303, 40404]) == [1, 0, 1, 0, 1, 2, 0, 2, 0, 2, 3, 0, 3, 0, 3, 4, 0, 4, 0, 4]\n assert candidate(nums = [987, 654, 321, 876, 543, 210]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [99, 888, 7777, 66666, 555555]) == [9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1001, 2002, 3003, 4004]) == [1, 0, 0, 1, 2, 0, 0, 2, 3, 0, 0, 3, 4, 0, 0, 4]\n assert candidate(nums = [100000, 20000, 3000, 400, 50, 6]) == [1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 5, 0, 6]\n assert candidate(nums = [987654321, 123456789, 101010101, 202020202, 303030303]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 0, 2, 0, 2, 0, 2, 0, 2, 3, 0, 3, 0, 3, 0, 3, 0, 3]\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 2, 0, 2, 1]\n assert candidate(nums = [100100, 200200, 300300, 400400]) == [1, 0, 0, 1, 0, 0, 2, 0, 0, 2, 0, 0, 3, 0, 0, 3, 0, 0, 4, 0, 0, 4, 0, 0]\n assert candidate(nums = [1, 20, 300, 4000, 50000]) == [1, 2, 0, 3, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 0]\n assert candidate(nums = [12, 23, 34, 45, 56, 67, 78, 89, 90]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0]\n assert candidate(nums = [9876543210, 1234567890, 5432109876]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6]\n assert candidate(nums = [12, 34, 56, 78, 90, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [101010101, 202020202, 303030303, 404040404, 505050505]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 0, 2, 0, 2, 0, 2, 0, 2, 3, 0, 3, 0, 3, 0, 3, 0, 3, 4, 0, 4, 0, 4, 0, 4, 0, 4, 5, 0, 5, 0, 5, 0, 5, 0, 5]\n assert candidate(nums = [123456789, 987654321, 1122334455]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]\n assert candidate(nums = [10101, 20202, 30303]) == [1, 0, 1, 0, 1, 2, 0, 2, 0, 2, 3, 0, 3, 0, 3]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4]\n assert candidate(nums = [98765, 43210, 54321, 65432, 76543]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3]\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005]) == [1, 0, 0, 1, 2, 0, 0, 2, 3, 0, 0, 3, 4, 0, 0, 4, 5, 0, 0, 5]\n assert candidate(nums = [1, 22, 333, 4444, 55555]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [100001, 20002, 30030, 4040, 505, 66]) == [1, 0, 0, 0, 0, 1, 2, 0, 0, 0, 2, 3, 0, 0, 3, 0, 4, 0, 4, 0, 5, 0, 5, 6, 6]\n assert candidate(nums = [1000, 20002, 300003, 4000004]) == [1, 0, 0, 0, 2, 0, 0, 0, 2, 3, 0, 0, 0, 0, 3, 4, 0, 0, 0, 0, 0, 4]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0]\n assert candidate(nums = [111222333444555, 666777888999, 123123123, 456456456, 789789789]) == [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, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6, 4, 5, 6, 7, 8, 9, 7, 8, 9, 7, 8, 9]\n assert candidate(nums = [55555, 4444, 333, 22, 1]) == [5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [101010101, 202020202, 303030303, 404040404]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 0, 2, 0, 2, 0, 2, 0, 2, 3, 0, 3, 0, 3, 0, 3, 0, 3, 4, 0, 4, 0, 4, 0, 4, 0, 4]\n assert candidate(nums = [11111, 222222, 3333333, 44444444]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444]) == [9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4]\n assert candidate(nums = [987654321, 123456789, 98765, 43210, 1234]) == [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, 0, 1, 2, 3, 4]\n assert candidate(nums = [555555, 246810, 135791, 111222]) == [5, 5, 5, 5, 5, 5, 2, 4, 6, 8, 1, 0, 1, 3, 5, 7, 9, 1, 1, 1, 1, 2, 2, 2]\n assert candidate(nums = [999888, 777666, 555444, 333222, 111000]) == [9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0]\n assert candidate(nums = [100, 2000, 30000, 400000, 5000000]) == [1, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == [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]\n assert candidate(nums = [102030405, 908070605, 4030201]) == [1, 0, 2, 0, 3, 0, 4, 0, 5, 9, 0, 8, 0, 7, 0, 6, 0, 5, 4, 0, 3, 0, 2, 0, 1]\n assert candidate(nums = [10, 100, 1000, 10000, 100000]) == [1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]\n assert candidate(nums = [12, 34, 56, 78, 90, 11, 22, 33, 44, 55]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]\n assert candidate(nums = [9, 88, 777, 6666, 55555, 444444, 3333333, 22222222, 111111111]) == [9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [99999, 8888, 777, 66, 5, 4, 3, 2, 1]) == [9, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555]) == [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]\n assert candidate(nums = [9999999, 8888888, 7777777, 6666666, 5555555]) == [9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [12, 234, 3456, 45678, 567890]) == [1, 2, 2, 3, 4, 3, 4, 5, 6, 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 0]\n assert candidate(nums = [112233, 445566, 778899, 113355, 224466]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 1, 1, 3, 3, 5, 5, 2, 2, 4, 4, 6, 6]\n assert candidate(nums = [98765, 43210, 111222, 333444, 555666]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]\n assert candidate(nums = [1, 23, 456, 7890, 12345]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [101010, 202020, 303030, 404040, 505050]) == [1, 0, 1, 0, 1, 0, 2, 0, 2, 0, 2, 0, 3, 0, 3, 0, 3, 0, 4, 0, 4, 0, 4, 0, 5, 0, 5, 0, 5, 0]\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [100001, 200002, 300003, 400004, 500005]) == [1, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 3, 4, 0, 0, 0, 0, 4, 5, 0, 0, 0, 0, 5]\n assert candidate(nums = [10001, 20002, 30003, 40004, 50005]) == [1, 0, 0, 0, 1, 2, 0, 0, 0, 2, 3, 0, 0, 0, 3, 4, 0, 0, 0, 4, 5, 0, 0, 0, 5]\n assert candidate(nums = [191919, 282828, 373737, 464646, 555555]) == [1, 9, 1, 9, 1, 9, 2, 8, 2, 8, 2, 8, 3, 7, 3, 7, 3, 7, 4, 6, 4, 6, 4, 6, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1000000, 200000, 30000, 4000, 500, 60, 7]) == [1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 6, 0, 7]\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909]) == [1, 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]\n assert candidate(nums = [98765, 87654, 76543, 65432, 54321]) == [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]\n assert candidate(nums = [10, 200, 3000, 40000, 500000]) == [1, 0, 2, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0]\n assert candidate(nums = [1234567890, 9876543210, 1020304050, 5040302010, 9080706050]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0]\n assert candidate(nums = [1, 22, 333, 4444, 55555, 666666, 7777777, 88888888, 999999999]) == [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]\n assert candidate(nums = [54321, 65432, 76543, 87654]) == [5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 8, 7, 6, 5, 4]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().separateDigits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] separateDigits(int[] nums) {", "container": "Solution", "callable": "separateDigits", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2554, "task_id": "maximum-number-of-integers-to-choose-from-a-range-i", "difficulty": "Medium", "problem_description": "You are given an integer array banned and two integers n and maxSum. You are choosing some number of integers following the below rules:\n\nThe chosen integers have to be in the range [1, n].\nEach integer can be chosen at most once.\nThe chosen integers should not be in the array banned.\nThe sum of the chosen integers should not exceed maxSum.\n\nReturn the maximum number of integers you can choose following the mentioned rules.\n \nExample 1:\n\nInput: banned = [1,6,5], n = 5, maxSum = 6\nOutput: 2\nExplanation: You can choose the integers 2 and 4.\n2 and 4 are from the range [1, 5], both did not appear in banned, and their sum is 6, which did not exceed maxSum.\n\nExample 2:\n\nInput: banned = [1,2,3,4,5,6,7], n = 8, maxSum = 1\nOutput: 0\nExplanation: You cannot choose any integer while following the mentioned conditions.\n\nExample 3:\n\nInput: banned = [11], n = 7, maxSum = 50\nOutput: 7\nExplanation: You can choose the integers 1, 2, 3, 4, 5, 6, and 7.\nThey are from the range [1, 7], all did not appear in banned, and their sum is 28, which did not exceed maxSum.\n\n \nConstraints:\n\n1 <= banned.length <= 104\n1 <= banned[i], n <= 104\n1 <= maxSum <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(banned = [11],n = 7,maxSum = 50) == 7\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7],n = 8,maxSum = 1) == 0\n assert candidate(banned = [],n = 10,maxSum = 55) == 10\n assert candidate(banned = [1, 6, 5],n = 5,maxSum = 6) == 2\n assert candidate(banned = [2, 4, 6, 8],n = 10,maxSum = 30) == 5\n assert candidate(banned = [2, 4, 6, 8],n = 10,maxSum = 15) == 3\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],n = 10,maxSum = 55) == 0\n assert candidate(banned = [5, 6, 7, 8, 9, 10],n = 10,maxSum = 1) == 1\n assert candidate(banned = [100, 200, 300],n = 500,maxSum = 1500) == 54\n assert candidate(banned = [10],n = 10,maxSum = 10) == 4\n assert candidate(banned = [1, 3, 5, 7, 9],n = 10,maxSum = 25) == 4\n assert candidate(banned = [3, 5, 7],n = 10,maxSum = 25) == 5\n assert candidate(banned = [2, 4, 6, 8],n = 10,maxSum = 15) == 3\n assert candidate(banned = [1, 2, 3],n = 3,maxSum = 5) == 0\n assert candidate(banned = [3, 5, 7, 9],n = 15,maxSum = 40) == 6\n assert candidate(banned = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 20,maxSum = 100) == 9\n assert candidate(banned = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],n = 100,maxSum = 1000) == 41\n assert candidate(banned = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 100,maxSum = 1500) == 51\n assert candidate(banned = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 100,maxSum = 450) == 28\n assert candidate(banned = [9996, 9997, 9998, 9999, 10000],n = 10000,maxSum = 50000000) == 9995\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],n = 20,maxSum = 150) == 5\n assert candidate(banned = [10, 20, 30, 40, 50],n = 50,maxSum = 1275) == 45\n assert candidate(banned = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 100,maxSum = 4950) == 89\n assert candidate(banned = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],n = 50,maxSum = 125) == 14\n assert candidate(banned = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009],n = 10000,maxSum = 25000000) == 7067\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],n = 15,maxSum = 45) == 3\n assert candidate(banned = [100, 200, 300, 400],n = 500,maxSum = 10000) == 140\n assert candidate(banned = [1, 3, 5, 7, 9],n = 15,maxSum = 50) == 6\n assert candidate(banned = [5000, 5001, 5002, 5003, 5004],n = 10000,maxSum = 25000000) == 7069\n assert candidate(banned = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],n = 30,maxSum = 250) == 15\n assert candidate(banned = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],n = 100,maxSum = 2500) == 67\n assert candidate(banned = [1000],n = 10000,maxSum = 1000000) == 1413\n assert candidate(banned = [100, 200, 300, 400, 500],n = 1000,maxSum = 10000) == 140\n assert candidate(banned = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],n = 100,maxSum = 5000) == 89\n assert candidate(banned = [15, 25, 35, 45, 55, 65, 75, 85, 95],n = 100,maxSum = 4500) == 90\n assert candidate(banned = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],n = 50,maxSum = 1000) == 40\n assert candidate(banned = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],n = 100,maxSum = 3000) == 70\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],n = 20,maxSum = 150) == 9\n assert candidate(banned = [1, 2, 3, 4, 5],n = 10000,maxSum = 1000000000) == 9995\n assert candidate(banned = [1000, 2000, 3000, 4000],n = 5000,maxSum = 12500000) == 4996\n assert candidate(banned = [9999],n = 10000,maxSum = 10000) == 140\n assert candidate(banned = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],n = 50,maxSum = 600) == 24\n assert candidate(banned = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192],n = 10000,maxSum = 10000000) == 4460\n assert candidate(banned = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],n = 30,maxSum = 150) == 12\n assert candidate(banned = [1, 10, 100, 1000, 10000],n = 10000,maxSum = 50005000) == 9995\n assert candidate(banned = [50, 51, 52, 53, 54, 55],n = 100,maxSum = 1000) == 44\n assert candidate(banned = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99],n = 100,maxSum = 1500) == 47\n assert candidate(banned = [],n = 10000,maxSum = 50000000) == 9999\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],n = 25,maxSum = 100) == 4\n assert candidate(banned = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],n = 50,maxSum = 1275) == 40\n assert candidate(banned = [1, 3, 5, 7, 9],n = 10,maxSum = 25) == 4\n assert candidate(banned = [],n = 100,maxSum = 5000) == 99\n assert candidate(banned = [],n = 50,maxSum = 1275) == 50\n assert candidate(banned = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],n = 30,maxSum = 250) == 18\n assert candidate(banned = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 20,maxSum = 190) == 10\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],n = 20,maxSum = 190) == 0\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],n = 20,maxSum = 90) == 5\n assert candidate(banned = [2, 3, 5, 7, 11, 13, 17, 19],n = 20,maxSum = 50) == 7\n assert candidate(banned = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],n = 1000,maxSum = 500500) == 990\n assert candidate(banned = [100, 200, 300, 400, 500],n = 1000,maxSum = 5000) == 99\n assert candidate(banned = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],n = 30,maxSum = 225) == 15\n assert candidate(banned = [15, 16, 17, 18, 19, 20],n = 20,maxSum = 150) == 14\n assert candidate(banned = [1],n = 10000,maxSum = 5000000) == 3160\n assert candidate(banned = [2, 4, 6, 8, 10, 12, 14, 16],n = 20,maxSum = 100) == 10\n assert candidate(banned = [2, 4, 6, 8, 10],n = 15,maxSum = 50) == 7\n assert candidate(banned = [1, 10, 100, 1000, 10000],n = 10000,maxSum = 50000000) == 9995\n assert candidate(banned = [101, 102, 103, 104, 105],n = 150,maxSum = 10000) == 139\n assert candidate(banned = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],n = 40,maxSum = 400) == 19\n assert candidate(banned = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 20,maxSum = 100) == 10\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],n = 20,maxSum = 190) == 1\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],n = 20,maxSum = 210) == 0\n assert candidate(banned = [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],n = 100,maxSum = 2500) == 49\n assert candidate(banned = [1, 2, 3, 4, 5],n = 10,maxSum = 20) == 2\n assert candidate(banned = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],n = 15,maxSum = 50) == 4\n assert candidate(banned = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],n = 1500,maxSum = 100000) == 444\n assert candidate(banned = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],n = 1000,maxSum = 5000) == 99\n assert candidate(banned = [1, 3, 5, 7, 9, 11, 13, 15],n = 15,maxSum = 60) == 7\n assert candidate(banned = [2, 4, 6, 8, 10],n = 20,maxSum = 100) == 10\n assert candidate(banned = [15, 30, 45, 60, 75],n = 100,maxSum = 3775) == 83\n assert candidate(banned = [1],n = 10000,maxSum = 50005000) == 9999\n assert candidate(banned = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 150,maxSum = 1000) == 42\n assert candidate(banned = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],n = 10000,maxSum = 1000000) == 1413\n assert candidate(banned = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145],n = 150,maxSum = 1000) == 41\n assert candidate(banned = [1000],n = 2000,maxSum = 1000000) == 1413\n assert candidate(banned = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],n = 110,maxSum = 1050) == 45\n assert candidate(banned = [15, 16, 17, 18, 19, 20],n = 20,maxSum = 190) == 14\n assert candidate(banned = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 20,maxSum = 150) == 10\n assert candidate(banned = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],n = 50,maxSum = 200) == 17\n assert candidate(banned = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],n = 1000,maxSum = 20000) == 198\n assert candidate(banned = [100, 101, 102, 103, 104],n = 110,maxSum = 500) == 31\n assert candidate(banned = [5, 10, 15, 20, 25],n = 30,maxSum = 200) == 17\n assert candidate(banned = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],n = 100,maxSum = 2500) == 63\n assert candidate(banned = [10, 20, 30, 40, 50],n = 60,maxSum = 1770) == 55\n assert candidate(banned = [10000],n = 10000,maxSum = 10000000) == 4471\n assert candidate(banned = [50, 51, 52, 53, 54, 55],n = 100,maxSum = 2500) == 68\n assert candidate(banned = [20, 40, 60, 80, 100],n = 100,maxSum = 500) == 30\n assert candidate(banned = [1, 3, 5, 7, 9],n = 15,maxSum = 60) == 7\n assert candidate(banned = [2500, 5000, 7500],n = 10000,maxSum = 25000000) == 7069\n assert candidate(banned = [1],n = 100,maxSum = 5050) == 99\n assert candidate(banned = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 20,maxSum = 90) == 9\n assert candidate(banned = [1, 3, 5, 7, 9, 11, 13, 15],n = 15,maxSum = 100) == 7\n"}, "metadata": {"canonical_parameter_names": ["banned", "n", "maxSum"], "leetcode_dataset_entry_point": "Solution().maxCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxCount(int[] banned, int n, int maxSum) {", "container": "Solution", "callable": "maxCount", "parameters": [{"name": "banned", "type": "int[]"}, {"name": "n", "type": "int"}, {"name": "maxSum", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2555, "task_id": "maximize-win-from-two-segments", "difficulty": "Medium", "problem_description": "There are some prizes on the X-axis. You are given an integer array prizePositions that is sorted in non-decreasing order, where prizePositions[i] is the position of the ith prize. There could be different prizes at the same position on the line. You are also given an integer k.\nYou are allowed to select two segments with integer endpoints. The length of each segment must be k. You will collect all prizes whose position falls within at least one of the two selected segments (including the endpoints of the segments). The two selected segments may intersect.\n\nFor example if k = 2, you can choose segments [1, 3] and [2, 4], and you will win any prize i that satisfies 1 <= prizePositions[i] <= 3 or 2 <= prizePositions[i] <= 4.\n\nReturn the maximum number of prizes you can win if you choose the two segments optimally.\n \nExample 1:\n\nInput: prizePositions = [1,1,2,2,3,3,5], k = 2\nOutput: 7\nExplanation: In this example, you can win all 7 prizes by selecting two segments [1, 3] and [3, 5].\n\nExample 2:\n\nInput: prizePositions = [1,2,3,4], k = 0\nOutput: 2\nExplanation: For this example, one choice for the segments is [3, 3] and [4, 4], and you will be able to get 2 prizes. \n\n \nConstraints:\n\n1 <= prizePositions.length <= 105\n1 <= prizePositions[i] <= 109\n0 <= k <= 109 \nprizePositions is sorted in non-decreasing order.\n\n \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prizePositions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(prizePositions = [1, 3, 5, 7, 9],k = 1) == 2\n assert candidate(prizePositions = [5, 5, 5, 5, 5],k = 1) == 5\n assert candidate(prizePositions = [5, 5, 5, 5, 5],k = 3) == 5\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 8\n assert candidate(prizePositions = [1, 1, 2, 2, 3, 3, 5],k = 2) == 7\n assert candidate(prizePositions = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 20\n assert candidate(prizePositions = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9, 9],k = 3) == 18\n assert candidate(prizePositions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 6\n assert candidate(prizePositions = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],k = 5) == 4\n assert candidate(prizePositions = [1, 3, 5, 7, 9],k = 2) == 4\n assert candidate(prizePositions = [1, 1, 1, 1, 1],k = 0) == 5\n assert candidate(prizePositions = [1, 2, 3, 4],k = 0) == 2\n assert candidate(prizePositions = [1, 2, 2, 2, 3, 4, 5, 5],k = 2) == 8\n assert candidate(prizePositions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 4\n assert candidate(prizePositions = [1, 2, 2, 3, 3, 3, 4, 4, 5],k = 2) == 9\n assert candidate(prizePositions = [1, 3, 5, 7, 9],k = 4) == 5\n assert candidate(prizePositions = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 3) == 20\n assert candidate(prizePositions = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 4\n assert candidate(prizePositions = [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 = 3) == 16\n assert candidate(prizePositions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 4\n assert candidate(prizePositions = [1, 3, 6, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 5\n assert candidate(prizePositions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10],k = 1) == 14\n assert candidate(prizePositions = [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) == 30\n assert candidate(prizePositions = [1, 2, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 10, 10],k = 4) == 15\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 8\n assert candidate(prizePositions = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],k = 10) == 4\n assert candidate(prizePositions = [1, 1, 1, 2, 2, 3, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16],k = 5) == 31\n assert candidate(prizePositions = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 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, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10],k = 10) == 70\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 20\n assert candidate(prizePositions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 6\n assert candidate(prizePositions = [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],k = 6) == 36\n assert candidate(prizePositions = [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],k = 2) == 33\n assert candidate(prizePositions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 6\n assert candidate(prizePositions = [1, 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],k = 2) == 8\n assert candidate(prizePositions = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 15) == 8\n assert candidate(prizePositions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 6\n assert candidate(prizePositions = [1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10],k = 2) == 9\n assert candidate(prizePositions = [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],k = 20) == 42\n assert candidate(prizePositions = [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],k = 0) == 8\n assert candidate(prizePositions = [1, 1, 2, 2, 2, 3, 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, 9, 9, 9, 9, 10, 10, 10, 10],k = 4) == 40\n assert candidate(prizePositions = [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) == 28\n assert candidate(prizePositions = [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 = 4) == 6\n assert candidate(prizePositions = [1, 1, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13],k = 4) == 24\n assert candidate(prizePositions = [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, 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],k = 5) == 62\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24, 25],k = 5) == 12\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10],k = 3) == 12\n assert candidate(prizePositions = [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) == 30\n assert candidate(prizePositions = [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],k = 1) == 24\n assert candidate(prizePositions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5) == 6\n assert candidate(prizePositions = [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],k = 1) == 30\n assert candidate(prizePositions = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 2) == 12\n assert candidate(prizePositions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 4) == 6\n assert candidate(prizePositions = [1, 2, 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 15],k = 4) == 20\n assert candidate(prizePositions = [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 = 5) == 12\n assert candidate(prizePositions = [1, 2, 2, 3, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 10, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 20\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 12\n assert candidate(prizePositions = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 3) == 16\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],k = 9) == 38\n assert candidate(prizePositions = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 2) == 13\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 6\n assert candidate(prizePositions = [1, 1, 1, 1, 1, 1, 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) == 30\n assert candidate(prizePositions = [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 = 0) == 2\n assert candidate(prizePositions = [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 = 2) == 18\n assert candidate(prizePositions = [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, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10],k = 8) == 70\n assert candidate(prizePositions = [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],k = 10) == 44\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 20\n assert candidate(prizePositions = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7) == 20\n assert candidate(prizePositions = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 6) == 28\n assert candidate(prizePositions = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],k = 3) == 29\n assert candidate(prizePositions = [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 = 0) == 2\n assert candidate(prizePositions = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 8) == 7\n assert candidate(prizePositions = [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 = 15) == 32\n assert candidate(prizePositions = [1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7) == 22\n assert candidate(prizePositions = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 2) == 16\n assert candidate(prizePositions = [1, 2, 2, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10, 10],k = 3) == 12\n assert candidate(prizePositions = [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 = 10) == 22\n assert candidate(prizePositions = [1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],k = 4) == 22\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 0) == 2\n assert candidate(prizePositions = [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],k = 2) == 18\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6) == 14\n assert candidate(prizePositions = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13],k = 1) == 14\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 20\n assert candidate(prizePositions = [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) == 40\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 6\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == 17\n assert candidate(prizePositions = [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 = 5) == 12\n assert candidate(prizePositions = [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],k = 3) == 32\n assert candidate(prizePositions = [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) == 22\n assert candidate(prizePositions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 0) == 12\n assert candidate(prizePositions = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == 20\n assert candidate(prizePositions = [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) == 22\n assert candidate(prizePositions = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 4) == 20\n assert candidate(prizePositions = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10],k = 2) == 16\n assert candidate(prizePositions = [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, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 3) == 49\n assert candidate(prizePositions = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10, 10],k = 1) == 16\n assert candidate(prizePositions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 3) == 4\n assert candidate(prizePositions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 1) == 2\n"}, "metadata": {"canonical_parameter_names": ["prizePositions", "k"], "leetcode_dataset_entry_point": "Solution().maximizeWin", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximizeWin(int[] prizePositions, int k) {", "container": "Solution", "callable": "maximizeWin", "parameters": [{"name": "prizePositions", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2556, "task_id": "disconnect-path-in-a-binary-matrix-by-at-most-one-flip", "difficulty": "Medium", "problem_description": "You are given a 0-indexed m x n binary matrix grid. You can move from a cell (row, col) to any of the cells (row + 1, col) or (row, col + 1) that has the value 1. The matrix is disconnected if there is no path from (0, 0) to (m - 1, n - 1).\nYou can flip the value of at most one (possibly none) cell. You cannot flip the cells (0, 0) and (m - 1, n - 1).\nReturn true if it is possible to make the matrix disconnect or false otherwise.\nNote that flipping a cell changes its value from 0 to 1 or from 1 to 0.\n \nExample 1:\n\n\nInput: grid = [[1,1,1],[1,0,0],[1,1,1]]\nOutput: true\nExplanation: We can change the cell shown in the diagram above. There is no path from (0, 0) to (2, 2) in the resulting grid.\n\nExample 2:\n\n\nInput: grid = [[1,1,1],[1,0,1],[1,1,1]]\nOutput: false\nExplanation: It is not possible to change at most one cell such that there is not path from (0, 0) to (2, 2).\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 1000\n1 <= m * n <= 105\ngrid[i][j] is either 0 or 1.\ngrid[0][0] == grid[m - 1][n - 1] == 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 0, 1], [1, 0, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1], [1, 0, 0], [1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 0], [1, 0, 0, 0], [1, 1, 1, 0], [1, 0, 1, 1]]) == True\n assert candidate(grid = [[1, 0], [0, 1]]) == True\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 0], [0, 1, 0], [0, 1, 1]]) == True\n assert candidate(grid = [[1, 0, 0, 0], [1, 1, 1, 0], [0, 1, 1, 1], [0, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 0, 0, 0], [1, 1, 1, 0], [0, 1, 1, 1], [0, 0, 1, 1]]) == True\n assert candidate(grid = [[1, 0, 1, 1], [1, 1, 0, 0], [1, 1, 1, 0], [0, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 1, 1, 0], [0, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0], [1, 0, 1], [1, 1, 1]]) == True\n assert candidate(grid = [[1, 0, 0, 0], [1, 1, 1, 0], [0, 1, 0, 0], [1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0], [1, 1, 1], [0, 1, 1]]) == True\n assert candidate(grid = [[1, 0, 1], [1, 1, 1], [1, 0, 1]]) == True\n assert candidate(grid = [[1, 1], [1, 1]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1], [1, 1, 1, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 0, 1, 0, 1, 1], [1, 1, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1], [1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 1], [1, 1, 0, 0, 1], [0, 1, 1, 1, 0], [1, 0, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1], [0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 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, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1, 0, 1, 0, 1], [1, 1, 0, 0, 0, 0, 0, 1, 1, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 0], [1, 1, 0, 0, 0, 0, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1], [1, 1, 1, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 1, 0, 1, 0, 1, 1], [0, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 0, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0, 1, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 1, 0, 1, 1], [0, 1, 1, 0, 1], [1, 0, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 1, 1, 1, 0, 1], [1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 1, 1, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 0, 0, 1], [1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1], [1, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [1, 0, 0, 1, 1, 0], [1, 1, 0, 0, 1, 1], [0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 1, 1, 0, 1], [1, 1, 1, 0, 1, 0, 1, 1], [0, 0, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 0, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 1, 0, 1], [0, 1, 0, 1, 1], [1, 0, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 0, 1, 0], [1, 0, 1, 1, 1, 1], [0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 0, 1]]) == True\n assert candidate(grid = [[1, 0, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 0, 0, 1, 0], [1, 0, 1, 0, 1, 1], [1, 1, 1, 0, 1, 0], [1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 1, 0, 1], [1, 1, 0, 0, 1, 1], [0, 1, 1, 0, 1, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 0, 1]]) == True\n assert candidate(grid = [[1, 0, 0, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 0, 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, 0, 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]]) == True\n assert candidate(grid = [[1, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1], [1, 1, 1, 0, 1, 1], [1, 0, 0, 1, 1, 0], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 0, 0, 1, 1, 1, 1, 0, 1], [1, 1, 1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 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, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 1, 0, 1, 1], [0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 0, 1], [1, 0, 0, 1, 1], [1, 1, 0, 0, 1], [0, 1, 1, 0, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 1, 1, 1, 1, 1], [1, 0, 1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1], [1, 1, 0, 0, 1], [1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 0, 0, 1], [1, 0, 1, 0, 1], [1, 1, 1, 0, 1], [1, 0, 0, 1, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 1], [1, 0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 1, 1, 1, 1, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 0, 1, 0, 1, 1], [1, 1, 1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1, 0, 1, 1], [1, 1, 1, 0, 1, 1, 1, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 0, 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, 0, 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]]) == False\n assert candidate(grid = [[1, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 1, 0, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0], [1, 0, 1, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1], [0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [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], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 1, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1], [0, 1, 0, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(grid = [[1, 1, 0, 0, 1], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [0, 1, 1, 0, 1], [1, 1, 1, 1, 1]]) == True\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().isPossibleToCutPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isPossibleToCutPath(int[][] grid) {", "container": "Solution", "callable": "isPossibleToCutPath", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2558, "task_id": "take-gifts-from-the-richest-pile", "difficulty": "Easy", "problem_description": "You are given an integer array gifts denoting the number of gifts in various piles. Every second, you do the following:\n\nChoose the pile with the maximum number of gifts.\nIf there is more than one pile with the maximum number of gifts, choose any.\nReduce the number of gifts in the pile to the floor of the square root of the original number of gifts in the pile.\n\nReturn the number of gifts remaining after k seconds.\n \nExample 1:\n\nInput: gifts = [25,64,9,4,100], k = 4\nOutput: 29\nExplanation: \nThe gifts are taken in the following way:\n- In the first second, the last pile is chosen and 10 gifts are left behind.\n- Then the second pile is chosen and 8 gifts are left behind.\n- After that the first pile is chosen and 5 gifts are left behind.\n- Finally, the last pile is chosen again and 3 gifts are left behind.\nThe final remaining gifts are [5,8,9,4,3], so the total number of gifts remaining is 29.\n\nExample 2:\n\nInput: gifts = [1,1,1,1], k = 4\nOutput: 4\nExplanation: \nIn this case, regardless which pile you choose, you have to leave behind 1 gift in each pile. \nThat is, you can't take any pile with you. \nSo, the total gifts remaining are 4.\n\n \nConstraints:\n\n1 <= gifts.length <= 103\n1 <= gifts[i] <= 109\n1 <= k <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(gifts = [25, 64, 9, 4, 100],k = 4) == 29\n assert candidate(gifts = [16, 81, 49],k = 3) == 20\n assert candidate(gifts = [1, 1, 1, 1],k = 4) == 4\n assert candidate(gifts = [49, 36, 25, 16, 9],k = 5) == 25\n assert candidate(gifts = [1000000000],k = 1000) == 1\n assert candidate(gifts = [16, 81, 4, 25, 9],k = 3) == 31\n assert candidate(gifts = [36, 27, 18, 12, 9],k = 5) == 21\n assert candidate(gifts = [1000000000],k = 10) == 1\n assert candidate(gifts = [36, 49, 64, 81],k = 2) == 102\n assert candidate(gifts = [16, 25, 36, 49, 64, 81, 100],k = 3) == 153\n assert candidate(gifts = [1000000000],k = 1) == 31622\n assert candidate(gifts = [16, 81, 25, 9],k = 3) == 27\n assert candidate(gifts = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 10) == 27\n assert candidate(gifts = [1000000000, 999999999, 888888888, 777777777, 666666666],k = 100) == 5\n assert candidate(gifts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 25) == 20\n assert candidate(gifts = [987654321, 876543219, 765432198, 654321987, 543219876],k = 7) == 76901\n assert candidate(gifts = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991, 99999990, 99999989, 99999988, 99999987, 99999986, 99999985, 99999984, 99999983, 99999982, 99999981],k = 1000) == 20\n assert candidate(gifts = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 30) == 11\n assert candidate(gifts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 60) == 15\n assert candidate(gifts = [987654321, 98765432, 9876543, 987654, 98765],k = 15) == 38\n assert candidate(gifts = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 100) == 10\n assert candidate(gifts = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 15) == 30\n assert candidate(gifts = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1024, 512, 256, 128, 64],k = 50) == 16\n assert candidate(gifts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 75) == 20\n assert candidate(gifts = [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(gifts = [123456789, 987654321, 135792468, 246813579, 111213141],k = 20) == 15\n assert candidate(gifts = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],k = 500) == 20\n assert candidate(gifts = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 1000) == 15\n assert candidate(gifts = [987654321, 987654321, 987654321, 987654321, 987654321],k = 100) == 5\n assert candidate(gifts = [1000000000, 100000000, 10000000, 1000000, 100000],k = 10) == 381\n assert candidate(gifts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 24\n assert candidate(gifts = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888],k = 100) == 10\n assert candidate(gifts = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 10) == 195\n assert candidate(gifts = [1000000, 100000, 10000, 1000, 100, 10, 1],k = 1000) == 7\n assert candidate(gifts = [81, 81, 81, 81, 81, 81, 81, 81, 81, 81],k = 20) == 30\n assert candidate(gifts = [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],k = 50) == 50\n assert candidate(gifts = [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 = 25) == 125\n assert candidate(gifts = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 10) == 56\n assert candidate(gifts = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 1000) == 5\n assert candidate(gifts = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 100) == 10\n assert candidate(gifts = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1000) == 10\n assert candidate(gifts = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144],k = 100) == 9\n assert candidate(gifts = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000],k = 100) == 10\n assert candidate(gifts = [16, 81, 4, 25, 9, 36, 64, 49, 100],k = 15) == 23\n assert candidate(gifts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50) == 10\n assert candidate(gifts = [123456, 654321, 111111, 222222, 333333],k = 50) == 5\n assert candidate(gifts = [987654321, 876543219, 765432108, 654321097, 543210986, 432109875, 321098764, 210987653, 109876542],k = 500) == 9\n assert candidate(gifts = [123456789, 987654321, 456789123, 321987654, 654321987],k = 15) == 58\n assert candidate(gifts = [1000000, 990000, 980000, 970000, 960000, 950000],k = 100) == 6\n assert candidate(gifts = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000],k = 500) == 10\n assert candidate(gifts = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225],k = 75) == 15\n assert candidate(gifts = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 500) == 10\n assert candidate(gifts = [16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324],k = 100) == 15\n assert candidate(gifts = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10],k = 10) == 1890\n assert candidate(gifts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 100) == 20\n assert candidate(gifts = [987654321, 876543219, 765432197, 654321975, 543219753, 432197531, 321975319, 219753197, 197531975, 975319753],k = 1000) == 10\n assert candidate(gifts = [100000, 100000, 100000, 100000, 100000],k = 250) == 5\n assert candidate(gifts = [100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1],k = 100) == 9\n assert candidate(gifts = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 20) == 84\n assert candidate(gifts = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],k = 30) == 77\n assert candidate(gifts = [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 = 100) == 25\n assert candidate(gifts = [981, 961, 941, 921, 901, 881, 861, 841, 821, 801, 781, 761, 741, 721, 701],k = 15) == 428\n assert candidate(gifts = [16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529],k = 20) == 263\n assert candidate(gifts = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],k = 50) == 34\n assert candidate(gifts = [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],k = 25) == 268\n assert candidate(gifts = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 20) == 10\n assert candidate(gifts = [314159265, 271828182, 161803398, 141421356, 111111111, 618033988, 333333333],k = 100) == 7\n assert candidate(gifts = [3, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61],k = 30) == 29\n assert candidate(gifts = [999999999, 1, 999999999, 1, 999999999, 1, 999999999, 1, 999999999, 1],k = 10) == 890\n assert candidate(gifts = [999999999],k = 1000) == 1\n assert candidate(gifts = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 100) == 9\n assert candidate(gifts = [1000000, 1000000, 1000000, 1000000, 1000000],k = 50) == 5\n assert candidate(gifts = [987654321, 98765432, 9876543, 987654, 98765, 9876, 987, 98, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 106\n assert candidate(gifts = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 20) == 37\n assert candidate(gifts = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 50) == 15\n assert candidate(gifts = [16, 144, 121, 100, 81, 64, 49, 36, 25, 16],k = 15) == 40\n assert candidate(gifts = [81, 64, 49, 36, 25, 16, 9, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 30\n assert candidate(gifts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 10\n assert candidate(gifts = [1000000000, 999999999, 888888888, 777777777, 666666666],k = 10) == 852\n assert candidate(gifts = [361, 441, 529, 625, 729, 841, 961],k = 20) == 16\n assert candidate(gifts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 51\n assert candidate(gifts = [441, 361, 289, 225, 169, 121, 81, 49, 25, 9, 1],k = 7) == 189\n assert candidate(gifts = [361, 441, 529, 625, 729, 841, 961, 1089, 1225, 1369, 1521, 1681, 1849, 2025, 2209],k = 15) == 495\n assert candidate(gifts = [65536, 4096, 256, 16, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 500) == 20\n assert candidate(gifts = [123456789, 987654321, 135792468, 246813579, 864204680],k = 50) == 5\n assert candidate(gifts = [1000000000, 999999999, 888888888, 777777777, 666666666],k = 1000) == 5\n assert candidate(gifts = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],k = 100) == 10\n assert candidate(gifts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 25) == 10\n assert candidate(gifts = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 200) == 20\n assert candidate(gifts = [121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484],k = 30) == 31\n assert candidate(gifts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 10\n assert candidate(gifts = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 10) == 644\n assert candidate(gifts = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543, 98765432],k = 50) == 10\n assert candidate(gifts = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025],k = 500) == 25\n assert candidate(gifts = [169, 441, 961, 1681, 2809, 4489, 6889, 10201, 14641],k = 75) == 9\n assert candidate(gifts = [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],k = 30) == 375\n assert candidate(gifts = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 5) == 5005000\n assert candidate(gifts = [46656, 1296, 324, 81, 25, 9, 4, 1],k = 15) == 18\n assert candidate(gifts = [1000000000, 999999999, 999999998, 999999997],k = 1000) == 4\n assert candidate(gifts = [3125, 5625, 144, 2025, 441, 900],k = 25) == 6\n assert candidate(gifts = [999999999, 1, 999999999, 1, 999999999, 1, 999999999, 1, 999999999, 1],k = 1000) == 10\n assert candidate(gifts = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287],k = 15) == 451\n assert candidate(gifts = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 100) == 5\n assert candidate(gifts = [1000, 500, 250, 125, 63, 32, 16, 8, 4, 2, 1],k = 500) == 11\n assert candidate(gifts = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 20) == 20\n assert candidate(gifts = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111],k = 300) == 9\n assert candidate(gifts = [169, 144, 121, 100, 81, 64, 49, 36, 25, 16, 9, 4, 1],k = 13) == 72\n assert candidate(gifts = [123456789, 987654321, 111213141, 212223242, 313233343, 414243444, 515253545, 616263646, 717273747, 818283848],k = 1000) == 10\n"}, "metadata": {"canonical_parameter_names": ["gifts", "k"], "leetcode_dataset_entry_point": "Solution().pickGifts", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long pickGifts(int[] gifts, int k) {", "container": "Solution", "callable": "pickGifts", "parameters": [{"name": "gifts", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2559, "task_id": "count-vowel-strings-in-ranges", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of strings words and a 2D array of integers queries.\nEach query queries[i] = [li, ri] asks us to find the number of strings present at the indices ranging from li to ri (both inclusive) of words that start and end with a vowel.\nReturn an array ans of size queries.length, where ans[i] is the answer to the ith query.\nNote that the vowel letters are 'a', 'e', 'i', 'o', and 'u'.\n \nExample 1:\n\nInput: words = [\"aba\",\"bcb\",\"ece\",\"aa\",\"e\"], queries = [[0,2],[1,4],[1,1]]\nOutput: [2,3,0]\nExplanation: The strings starting and ending with a vowel are \"aba\", \"ece\", \"aa\" and \"e\".\nThe answer to the query [0,2] is 2 (strings \"aba\" and \"ece\").\nto query [1,4] is 3 (strings \"ece\", \"aa\", \"e\").\nto query [1,1] is 0.\nWe return [2,3,0].\n\nExample 2:\n\nInput: words = [\"a\",\"e\",\"i\"], queries = [[0,2],[0,1],[2,2]]\nOutput: [3,2,1]\nExplanation: Every string satisfies the conditions, so we return [3,2,1].\n \nConstraints:\n\n1 <= words.length <= 105\n1 <= words[i].length <= 40\nwords[i] consists only of lowercase English letters.\nsum(words[i].length) <= 3 * 105\n1 <= queries.length <= 105\n0 <= li <= ri < words.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['aeiou', 'bcd', 'cde', 'ua'],queries = [[0, 0], [1, 2], [0, 3]]) == [1, 0, 2]\n assert candidate(words = ['aeiou', 'bcd', 'cde', 'dea'],queries = [[0, 3], [1, 2], [2, 2]]) == [1, 0, 0]\n assert candidate(words = ['aeiou', 'bcd', 'cde', 'aeiou'],queries = [[0, 3], [1, 2], [3, 3]]) == [2, 0, 1]\n assert candidate(words = ['aaaa', 'ee', 'iii', 'oo', 'uu'],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [1, 1, 1, 1, 1]\n assert candidate(words = ['abc', 'bcd', 'cde', 'dea'],queries = [[0, 1], [1, 3], [2, 3]]) == [0, 0, 0]\n assert candidate(words = ['abc', 'bcd', 'cde', 'dea'],queries = [[0, 1], [1, 3], [0, 3]]) == [0, 0, 0]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u'],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [1, 1, 1, 1, 1]\n assert candidate(words = ['aba', 'bcb', 'ece', 'aa', 'e'],queries = [[0, 2], [1, 4], [1, 1]]) == [2, 3, 0]\n assert candidate(words = ['abc', 'bcd', 'cde', 'dea'],queries = [[0, 1], [2, 3], [0, 3]]) == [0, 0, 0]\n assert candidate(words = ['aeiou', 'bcd', 'cde', 'dea', 'eae'],queries = [[0, 4], [1, 3], [2, 2]]) == [2, 0, 0]\n assert candidate(words = ['abc', 'bcd', 'cde', 'dea', 'eae'],queries = [[0, 1], [1, 3], [2, 4]]) == [0, 0, 1]\n assert candidate(words = ['a', 'e', 'i'],queries = [[0, 2], [0, 1], [2, 2]]) == [3, 2, 1]\n assert candidate(words = ['abc', 'bcd', 'cde', 'dea'],queries = [[0, 3], [1, 2], [2, 2]]) == [0, 0, 0]\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [1, 0, 0, 0, 1]\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],queries = [[0, 4], [1, 3], [2, 2]]) == [2, 0, 0]\n assert candidate(words = ['aeiou', 'bcd', 'eoe'],queries = [[0, 0], [1, 2], [0, 2]]) == [1, 1, 2]\n assert candidate(words = ['aeioua', 'beoibe', 'ieoiie', 'oioioi', 'uaouau', 'aeiou', 'eioue', 'iouoi', 'ououo', 'uouou'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [9, 7, 6, 4, 2, 4, 5, 2, 3, 3, 3, 3, 3, 3]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'aeiou', 'uoiea', 'aeiouaeiou'],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 0], [7, 7]]) == [8, 6, 4, 2, 1, 1]\n assert candidate(words = ['ae', 'ea', 'aa', 'ee', 'ii', 'oo', 'uu', 'aee', 'eaa', 'iee'],queries = [[0, 9], [0, 5], [5, 9], [3, 6], [7, 8]]) == [10, 6, 5, 4, 2]\n assert candidate(words = ['aeiou'],queries = [[0, 0]]) == [1]\n assert candidate(words = ['apple', 'orange', 'umbrella', 'elephant', 'ice'],queries = [[0, 2], [1, 4], [2, 2], [3, 4], [0, 4]]) == [3, 3, 1, 1, 4]\n assert candidate(words = ['automobile', 'bicycle', 'car', 'plane', 'ship', 'train', 'truck', 'motorcycle', 'bus', 'ferry'],queries = [[0, 4], [1, 5], [2, 8], [0, 9], [1, 6], [2, 4], [3, 7], [0, 7], [8, 9]]) == [1, 0, 0, 1, 0, 0, 0, 1, 0]\n assert candidate(words = ['education', 'environment', 'algorithm', 'finance', 'economics', 'optimization', 'development'],queries = [[0, 2], [3, 5], [0, 6], [2, 4], [1, 3], [0, 5], [4, 6]]) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(words = ['umbrella', 'elephant', 'ice', 'onion', 'apple', 'orange'],queries = [[0, 2], [1, 5], [3, 4], [0, 1], [2, 3]]) == [2, 3, 1, 1, 1]\n assert candidate(words = ['banana', 'grape', 'kiwi', 'lemon', 'melon', 'mango', 'peach', 'pear', 'plum'],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 5], [6, 6], [7, 7], [0, 1], [2, 3], [4, 5], [6, 7]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(words = ['aabbcc', 'eoo', 'i', 'oee', 'u', 'aa', 'e', 'i', 'o', 'u'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [9, 8, 6, 4, 2, 4, 5]\n assert candidate(words = ['ab', 'cd', 'ef', 'gh', 'ij', 'kl', 'mn', 'op', 'qr', 'st', 'uv', 'wx', 'yz'],queries = [[0, 12], [1, 11], [2, 10], [3, 9], [4, 8]]) == [0, 0, 0, 0, 0]\n assert candidate(words = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd', 'eeeeee', 'ffffff', 'gggggg'],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6]]) == [1, 0, 0, 1, 1, 0, 2]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u'],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4], [0, 3], [1, 4]]) == [1, 1, 1, 1, 1, 5, 4, 4]\n assert candidate(words = ['aeiou', 'bcd', 'efg', 'hij', 'klm', 'nop', 'qrstu', 'vwxyz', 'yzzzy', 'uaeuu'],queries = [[0, 9], [1, 3], [2, 8], [4, 7], [5, 5]]) == [2, 0, 0, 0, 0]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'aa', 'ee', 'ii', 'oo', 'uu', 'aaa', 'eee', 'iii', 'ooo', 'uuu'],queries = [[0, 4], [5, 9], [10, 14], [0, 9], [5, 14], [0, 14], [1, 13]]) == [5, 5, 5, 10, 10, 15, 13]\n assert candidate(words = ['banana', 'apple', 'grape', 'kiwi', 'melon', 'peach', 'pear'],queries = [[0, 3], [2, 5], [1, 6], [0, 6], [4, 4]]) == [1, 0, 1, 1, 0]\n assert candidate(words = ['aeiouaeiou', 'bcdefghijklmno', 'pqrstuvwxyzz', 'zyxwvutsrqponmlkjihgfedcba', 'aeiouaeiouaeiou'],queries = [[0, 4], [1, 3], [0, 0], [2, 2], [1, 4]]) == [2, 0, 1, 0, 1]\n assert candidate(words = ['education', 'university', 'college', 'school', 'academy', 'institute', 'faculty', 'student', 'teacher', 'research'],queries = [[0, 9], [1, 4], [2, 6], [3, 8], [4, 7]]) == [1, 0, 1, 1, 1]\n assert candidate(words = ['umbrella', 'elephant', 'ice', 'onion', 'apple', 'orange', 'grape'],queries = [[0, 6], [1, 5], [2, 4], [0, 1], [5, 6], [2, 3], [4, 4]]) == [4, 3, 2, 1, 1, 1, 1]\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [3, 2, 1, 1, 1]\n assert candidate(words = ['aaaa', 'eeeee', 'iiii', 'oooo', 'uuuu', 'aeiou', 'uoiea'],queries = [[0, 4], [3, 6], [0, 3], [4, 4], [5, 6], [1, 1], [2, 2]]) == [5, 4, 4, 1, 2, 1, 1]\n assert candidate(words = ['abc', 'bcd', 'cde', 'dea', 'aeiou', 'uoiea'],queries = [[0, 5], [1, 4], [2, 3], [0, 0], [5, 5]]) == [2, 1, 0, 0, 1]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'aeiou', 'uoiea'],queries = [[0, 6], [1, 5], [2, 4], [0, 3], [3, 6]]) == [7, 5, 3, 4, 4]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'ae', 'ei', 'ou', 'io', 'ua'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 0], [9, 9]]) == [10, 8, 6, 4, 2, 1, 1]\n assert candidate(words = ['apple', 'orange', 'banana', 'grape', 'peach'],queries = [[0, 2], [1, 3], [0, 3], [2, 2], [3, 3], [1, 4], [0, 4]]) == [2, 1, 2, 0, 0, 1, 2]\n assert candidate(words = ['bcd'],queries = [[0, 0]]) == [0]\n assert candidate(words = ['banana', 'apricot', 'grape', 'kiwi', 'peach', 'melon'],queries = [[0, 5], [1, 3], [2, 4], [0, 2], [3, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(words = ['banana', 'anana', 'nana', 'ana', 'na', 'a', 'e', 'i', 'o', 'u'],queries = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [0, 9]]) == [3, 4, 4, 5, 5, 7]\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'],queries = [[0, 14], [0, 9], [5, 10], [10, 14]]) == [4, 3, 1, 1]\n assert candidate(words = ['abcde', 'edcba', 'fghij', 'jihgf', 'klmno', 'onmlk', 'pqrst', 'tsrqp', 'uvwxy', 'yxwvu'],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [0, 8], [1, 9], [0, 7], [2, 5]]) == [2, 0, 0, 0, 2, 1, 2, 0]\n assert candidate(words = ['banana', 'grape', 'avocado', 'kiwi', 'melon', 'orange', 'elderberry'],queries = [[0, 6], [1, 5], [2, 4], [3, 3], [0, 3]]) == [2, 2, 1, 0, 1]\n assert candidate(words = ['x', 'y', 'z', 'aeiou', 'aeiou', 'aeiou'],queries = [[0, 2], [2, 4], [4, 5], [0, 5]]) == [0, 2, 2, 3]\n assert candidate(words = ['aeiou', 'bcd', 'cde', 'dea', 'aeiou', 'bcd', 'cde', 'dea', 'aeiou', 'bcd'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [3, 2, 1, 1, 1]\n assert candidate(words = ['aeiou', 'bcd', 'cde', 'dea', 'aeiou', 'bcd', 'cde', 'dea', 'aeiou', 'bcd', 'cde', 'dea', 'aeiou', 'bcd', 'cde', 'dea'],queries = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8]]) == [4, 3, 3, 3, 2, 1, 1, 1]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'ae', 'ei', 'ou', 'ia', 'uo'],queries = [[0, 5], [2, 8], [1, 4], [0, 9], [3, 7], [5, 9], [0, 0], [9, 9]]) == [6, 7, 4, 10, 5, 5, 1, 1]\n assert candidate(words = ['abacax', 'azedo', 'oiue', 'ueia', 'uiaeu', 'uiaed', 'uieaeu', 'ueae', 'euae', 'aeu'],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [0, 1, 1, 1, 1, 0, 1, 1, 1, 1]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'ae', 'ei', 'ou', 'uo', 'ea'],queries = [[0, 9], [0, 5], [5, 9], [3, 6], [7, 8]]) == [10, 6, 5, 4, 2]\n assert candidate(words = ['aeiou', 'bcd', 'aee', 'oau', 'bcd', 'eaa'],queries = [[0, 2], [1, 5], [3, 5], [0, 5]]) == [2, 3, 2, 4]\n assert candidate(words = ['apple', 'orange', 'umbrella', 'elephant', 'ice', 'onion'],queries = [[0, 5], [1, 4], [2, 3], [0, 0], [5, 5]]) == [4, 3, 1, 1, 0]\n assert candidate(words = ['aeiou', 'bcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvw', 'xyz'],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 0], [7, 7]]) == [1, 0, 0, 0, 1, 0]\n assert candidate(words = ['aaa', 'eee', 'iii', 'ooo', 'uuu', 'aa', 'ee', 'ii', 'oo', 'uu'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [10, 8, 6, 4, 2, 5, 5]\n assert candidate(words = ['banana', 'avocado', 'elderberry', 'kiwi', 'grape', 'lemon'],queries = [[0, 2], [1, 5], [2, 3], [0, 5]]) == [1, 1, 0, 1]\n assert candidate(words = ['aeiou', 'bcd', 'ocean', 'elephant', 'umbrella'],queries = [[0, 0], [0, 4], [1, 2], [2, 3], [3, 4], [0, 3], [1, 4]]) == [1, 2, 0, 0, 1, 1, 1]\n assert candidate(words = ['under', 'over', 'around', 'before', 'after', 'above', 'below'],queries = [[0, 1], [2, 4], [1, 3], [0, 6], [5, 5]]) == [0, 0, 0, 1, 1]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u'],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 5], [5, 10], [10, 15], [15, 20]]) == [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 6, 6, 6, 5]\n assert candidate(words = ['aeiou', 'bcd', 'eae', 'oio', 'uaa'],queries = [[0, 2], [1, 4], [0, 4]]) == [2, 3, 4]\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb', 'ccbbdd', 'ddeerr', 'eeffgg', 'ffggee', 'gghhee', 'hhiig', 'iihhj'],queries = [[0, 2], [1, 5], [2, 7], [0, 8], [1, 6], [2, 4], [3, 7], [0, 7], [8, 9]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(words = ['algorithm', 'data', 'science', 'python', 'java', 'c++', 'javascript'],queries = [[0, 2], [3, 5], [1, 4], [0, 6], [5, 5], [2, 3], [4, 6]]) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(words = ['abacax', 'azedo', 'oiue', 'ueia', 'uiaeu', 'uiaed', 'uieaeu', 'ueae', 'euae', 'aeu'],queries = [[0, 4], [1, 7], [2, 8], [3, 9], [0, 9]]) == [4, 6, 6, 6, 8]\n assert candidate(words = ['aeiou', 'bcdfg', 'ae', 'iou', 'a', 'e', 'i', 'o', 'u'],queries = [[0, 8], [1, 5], [2, 7], [3, 6], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == [8, 4, 6, 4, 1, 1, 1, 1, 1]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'aeiou'],queries = [[0, 5], [1, 4], [2, 3], [0, 0], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4]]) == [6, 4, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'aeiou'],queries = [[0, 5], [1, 4], [0, 0], [5, 5]]) == [6, 4, 1, 1]\n assert candidate(words = ['apple', 'orange', 'umbrella', 'echo', 'alpha'],queries = [[0, 4], [1, 3], [0, 0], [2, 2], [1, 4]]) == [5, 3, 1, 1, 4]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u'],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [0, 9], [1, 8]]) == [15, 13, 11, 9, 7, 5, 3, 1, 10, 8]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'aeiou', 'uoiea', 'bcd'],queries = [[0, 6], [1, 5], [2, 7], [3, 3]]) == [7, 5, 5, 1]\n assert candidate(words = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yz'],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 6], [1, 5], [2, 4]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(words = ['amplifier', 'equalizer', 'microphone', 'audio', 'sound', 'voice', 'volume', 'level', 'peak', 'gain'],queries = [[0, 2], [1, 5], [2, 7], [3, 8], [4, 9], [0, 9]]) == [0, 1, 1, 1, 0, 1]\n assert candidate(words = ['algorithm', 'datastructure', 'programming', 'python', 'java', 'csharp', 'javascript', 'html', 'css', 'vue'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(words = ['a', 'bcd', 'cde', 'dea', 'aeiou', 'bcd', 'cde', 'dea', 'aeiou', 'bcd', 'cde', 'dea', 'aeiou', 'bcd', 'cde', 'dea'],queries = [[0, 15], [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]]) == [4, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]\n assert candidate(words = ['strawberry', 'blueberry', 'raspberry', 'blackberry', 'kiwi', 'mango', 'papaya'],queries = [[0, 6], [1, 5], [2, 4], [0, 1], [5, 6]]) == [0, 0, 0, 0, 0]\n assert candidate(words = ['aabb', 'bbaa', 'abcd', 'dcba', 'efgh', 'hgfe', 'ijkl', 'lkji', 'mnop', 'ponm'],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(words = ['algorithm', 'engine', 'idea', 'open', 'ocean', 'under', 'education'],queries = [[0, 2], [1, 5], [2, 6], [0, 6]]) == [2, 2, 1, 2]\n assert candidate(words = ['abacaxi', 'ananas', 'acerola', 'banana', 'manga', 'abacaxi', 'manga', 'banana'],queries = [[0, 3], [4, 7], [0, 4], [3, 6], [1, 5], [2, 2], [6, 7]]) == [2, 1, 2, 1, 2, 1, 0]\n assert candidate(words = ['umbrella', 'orange', 'apple', 'elephant', 'ocean', 'idea', 'education'],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6]]) == [2, 2, 1, 0, 1, 1, 4]\n assert candidate(words = ['ae', 'ei', 'ou', 'ia', 'oe', 'uo', 'oi', 'ie', 'oa', 'eu'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9], [0, 3], [1, 7], [2, 6]]) == [10, 8, 6, 4, 2, 5, 5, 4, 7, 5]\n assert candidate(words = ['apple', 'orange', 'umbrella', 'electric', 'ice', 'onion', 'octopus'],queries = [[0, 6], [1, 3], [2, 5], [0, 0], [6, 6], [3, 4], [1, 5]]) == [4, 2, 2, 1, 0, 1, 3]\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'vowel', 'nonvowel'],queries = [[0, 6], [1, 5], [2, 4], [3, 3], [4, 4]]) == [5, 4, 3, 1, 1]\n assert candidate(words = ['aeioua', 'aeioue', 'aeiouo', 'aeioui', 'aeiouu', 'euoeu', 'iuoie', 'oueia', 'uaeio', 'eaoui'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9], [0, 3], [1, 7], [2, 6]]) == [10, 8, 6, 4, 2, 5, 5, 4, 7, 5]\n assert candidate(words = ['algorithm', 'data', 'structure', 'design', 'computer', 'science', 'software', 'engineering'],queries = [[0, 3], [1, 5], [2, 7], [0, 8], [1, 6], [2, 4], [3, 7], [0, 7]]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(words = ['aabbcc', 'ddeeff', 'gg', 'hhii', 'jjkk', 'llmm', 'nnoopp', 'qqrr', 'ssttuu', 'vvww'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(words = ['aeiou', 'bcd', 'eae', 'oio', 'uaa', 'aeiou', 'bcd', 'eae', 'oio', 'uaa'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [0, 4], [1, 9]]) == [8, 6, 5, 3, 2, 5, 4, 7]\n assert candidate(words = ['apple', 'orange', 'ice', 'elephant', 'umbrella'],queries = [[0, 1], [1, 3], [2, 4], [0, 4]]) == [2, 2, 2, 4]\n assert candidate(words = ['aeiou', 'bcd', 'eee', 'oee', 'uau'],queries = [[0, 4], [1, 3], [2, 4], [0, 0], [4, 4]]) == [4, 2, 3, 1, 1]\n assert candidate(words = ['umbrella', 'raincoat', 'umbrella', 'hat', 'scarf', 'umbrella', 'umbrella', 'raincoat'],queries = [[0, 3], [4, 7], [0, 4], [3, 6], [1, 5], [0, 6], [2, 2], [5, 7]]) == [2, 2, 2, 2, 2, 4, 1, 2]\n assert candidate(words = ['abacax', 'azedo', 'oiue', 'ueia', 'uiaeu', 'uiaed', 'uieaeu', 'ueae', 'euae', 'aeu'],queries = [[0, 4], [1, 3], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == [4, 3, 3, 3, 3, 3, 4]\n assert candidate(words = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvw', 'xyz'],queries = [[0, 6], [1, 5], [2, 4], [0, 2], [3, 5], [0, 6], [6, 6]]) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(words = ['aeiouaeiou', 'bcd', 'eee', 'oau', 'bcd', 'eaa', 'aeiou', 'bcd', 'cde', 'dea'],queries = [[0, 4], [1, 7], [3, 8], [0, 9], [5, 5]]) == [3, 4, 3, 5, 1]\n assert candidate(words = ['aabbcc', 'eeffgg', 'hhhiii', 'jjjkll', 'mmmoonnn', 'pppqqq', 'rrrsss', 'tttuuu', 'vvvwww', 'xxxyyy'],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(words = ['apple', 'orange', 'banana', 'umbrella', 'ice', 'elephant', 'octopus'],queries = [[0, 2], [3, 6], [0, 6], [2, 4]]) == [2, 2, 4, 2]\n assert candidate(words = ['banana', 'apple', 'orange', 'grape', 'kiwi'],queries = [[0, 4], [1, 2], [2, 3], [3, 4], [0, 3]]) == [2, 2, 1, 0, 2]\n assert candidate(words = ['aeiou', 'banana', 'grape', 'kiwi', 'a', 'e', 'i', 'o', 'u'],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4]]) == [6, 4, 3, 2, 1]\n"}, "metadata": {"canonical_parameter_names": ["words", "queries"], "leetcode_dataset_entry_point": "Solution().vowelStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] vowelStrings(String[] words, int[][] queries) {", "container": "Solution", "callable": "vowelStrings", "parameters": [{"name": "words", "type": "String[]"}, {"name": "queries", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2560, "task_id": "house-robber-iv", "difficulty": "Medium", "problem_description": "There are several consecutive houses along a street, each of which has some money inside. There is also a robber, who wants to steal money from the homes, but he refuses to steal from adjacent homes.\nThe capability of the robber is the maximum amount of money he steals from one house of all the houses he robbed.\nYou are given an integer array nums representing how much money is stashed in each house. More formally, the ith house from the left has nums[i] dollars.\nYou are also given an integer k, representing the minimum number of houses the robber will steal from. It is always possible to steal at least k houses.\nReturn the minimum capability of the robber out of all the possible ways to steal at least k houses.\n \nExample 1:\n\nInput: nums = [2,3,5,9], k = 2\nOutput: 5\nExplanation: \nThere are three ways to rob at least 2 houses:\n- Rob the houses at indices 0 and 2. Capability is max(nums[0], nums[2]) = 5.\n- Rob the houses at indices 0 and 3. Capability is max(nums[0], nums[3]) = 9.\n- Rob the houses at indices 1 and 3. Capability is max(nums[1], nums[3]) = 9.\nTherefore, we return min(5, 9, 9) = 5.\n\nExample 2:\n\nInput: nums = [2,7,9,3,1], k = 2\nOutput: 2\nExplanation: There are 7 ways to rob the houses. The way which leads to minimum capability is to rob the house at index 0 and 4. Return max(nums[0], nums[4]) = 2.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= k <= (nums.length + 1)/2\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 9\n assert candidate(nums = [10, 1, 1, 10, 1, 1, 10],k = 3) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 5\n assert candidate(nums = [10, 20, 30, 40, 50],k = 1) == 10\n assert candidate(nums = [5, 3, 1, 1, 2, 3],k = 2) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 5\n assert candidate(nums = [2, 7, 9, 3, 1],k = 2) == 2\n assert candidate(nums = [2, 3, 5, 9],k = 2) == 5\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],k = 4) == 2\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],k = 15) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 9\n assert candidate(nums = [10, 5, 15, 20, 25, 30, 35, 40],k = 4) == 35\n assert candidate(nums = [2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1],k = 5) == 1\n assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],k = 3) == 250\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) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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) == 2\n assert candidate(nums = [3, 6, 1, 8, 5, 2, 9, 4, 7, 10],k = 4) == 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 = 10) == 37\n assert candidate(nums = [10, 5, 20, 25, 15, 30, 35, 40, 45, 50],k = 8) == 51\n assert candidate(nums = [3, 5, 7, 2, 9, 1, 10, 8, 6, 4],k = 3) == 3\n assert candidate(nums = [10, 2, 8, 4, 7, 3, 9, 5, 6, 1],k = 4) == 4\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],k = 3) == 1\n assert candidate(nums = [10, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],k = 6) == 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],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, 67, 71, 73, 79, 83, 89, 97],k = 10) == 67\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 = 6) == 11\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1],k = 5) == 1\n assert candidate(nums = [100, 10, 1, 100, 10, 1, 100, 10, 1, 100],k = 4) == 100\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 8) == 29\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5) == 1\n assert candidate(nums = [10, 1, 1, 10, 1, 1, 10, 1, 1, 10],k = 5) == 10\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],k = 2) == 1000000000\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == 50\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 4) == 35\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 10) == 1\n assert candidate(nums = [8, 12, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 7) == 56\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 = 10) == 38\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 5\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 13\n assert candidate(nums = [3, 5, 10, 2, 8, 14, 1, 11, 7, 6],k = 5) == 10\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 5) == 50\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 900\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9],k = 3) == 6\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],k = 15) == 3\n assert candidate(nums = [3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10],k = 4) == 3\n assert candidate(nums = [8, 3, 9, 2, 7, 4, 6, 1, 5, 10],k = 4) == 4\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],k = 7) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 90\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 6) == 22\n assert candidate(nums = [1, 3, 1, 1, 2, 1, 5, 1, 4, 1],k = 4) == 1\n assert candidate(nums = [2, 3, 7, 8, 4, 5, 6, 9],k = 3) == 6\n assert candidate(nums = [10, 2, 9, 4, 7, 3, 8, 5, 6, 1],k = 3) == 3\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3],k = 8) == 3\n assert candidate(nums = [9, 2, 5, 7, 1, 3, 8, 6, 4, 10],k = 5) == 9\n assert candidate(nums = [23, 45, 12, 34, 56, 78, 89, 67, 45, 23, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22],k = 6) == 20\n assert candidate(nums = [7, 10, 4, 3, 20, 15],k = 3) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 17\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) == 98\n assert candidate(nums = [2, 1, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2],k = 5) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 500\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) == 1\n assert candidate(nums = [3, 6, 2, 8, 7, 2, 5, 9, 4, 10],k = 4) == 4\n assert candidate(nums = [3, 6, 7, 12, 14, 11, 14, 13, 15, 10, 11, 13],k = 4) == 11\n assert candidate(nums = [1000000000, 500000000, 1000000000, 500000000, 1000000000, 500000000, 1000000000],k = 3) == 500000000\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1],k = 5) == 1\n assert candidate(nums = [100, 200, 300, 10, 20, 30, 400, 500, 600, 1000],k = 5) == 600\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 7) == 26\n assert candidate(nums = [1, 3, 2, 5, 7, 6, 4, 8, 9, 10],k = 5) == 9\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) == 1\n assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3],k = 4) == 3\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 5) == 1\n assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5],k = 3) == 3\n assert candidate(nums = [9, 4, 1, 7, 3, 8, 5, 2, 6, 0],k = 4) == 3\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 6) == 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 = 5) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == 50\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],k = 5) == 1\n assert candidate(nums = [1, 3, 1, 5, 1, 7, 1, 9],k = 4) == 1\n assert candidate(nums = [5, 9, 7, 1, 3, 8, 6, 4, 2, 10, 1, 11, 13, 12, 14, 15, 16, 17, 18, 19],k = 6) == 7\n assert candidate(nums = [9, 1, 5, 3, 7, 11, 15, 13, 17, 19],k = 4) == 13\n assert candidate(nums = [15, 20, 10, 5, 1, 25, 30, 40, 50, 60],k = 5) == 50\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1],k = 4) == 1\n assert candidate(nums = [15, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 80\n assert candidate(nums = [1, 2, 100, 3, 4, 100, 5, 6, 100, 7, 8, 100, 9, 10, 100],k = 5) == 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],k = 6) == 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) == 19\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 5) == 5\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 7) == 10\n assert candidate(nums = [50, 10, 25, 60, 20, 30, 70, 5, 80, 1],k = 6) == 81\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 = [1, 3, 2, 5, 7, 8, 6, 9, 4, 10],k = 3) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 17\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6) == 11\n assert candidate(nums = [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, 5],k = 10) == 1\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60],k = 3) == 10\n assert candidate(nums = [50, 1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10],k = 5) == 5\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 5) == 5\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 4) == 70\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 = 7) == 5\n assert candidate(nums = [8, 2, 4, 1, 6, 5, 3, 7, 10, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6) == 11\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minCapability", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minCapability(int[] nums, int k) {", "container": "Solution", "callable": "minCapability", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2561, "task_id": "rearranging-fruits", "difficulty": "Hard", "problem_description": "You have two fruit baskets containing n fruits each. You are given two 0-indexed integer arrays basket1 and basket2 representing the cost of fruit in each basket. You want to make both baskets equal. To do so, you can use the following operation as many times as you want:\n\nChose two indices i and j, and swap the ith fruit of basket1 with the jth fruit of basket2.\nThe cost of the swap is min(basket1[i],basket2[j]).\n\nTwo baskets are considered equal if sorting them according to the fruit cost makes them exactly the same baskets.\nReturn the minimum cost to make both the baskets equal or -1 if impossible.\n \nExample 1:\n\nInput: basket1 = [4,2,2,2], basket2 = [1,4,1,2]\nOutput: 1\nExplanation: Swap index 1 of basket1 with index 0 of basket2, which has cost 1. Now basket1 = [4,1,2,2] and basket2 = [2,4,1,2]. Rearranging both the arrays makes them equal.\n\nExample 2:\n\nInput: basket1 = [2,3,4,1], basket2 = [3,2,5,1]\nOutput: -1\nExplanation: It can be shown that it is impossible to make both the baskets equal.\n\n \nConstraints:\n\nbasket1.length == basket2.length\n1 <= basket1.length <= 105\n1 <= basket1[i],basket2[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(basket1 = [1000000000, 1000000000],basket2 = [1000000000, 1000000000]) == 0\n assert candidate(basket1 = [2, 3, 4, 1],basket2 = [3, 2, 5, 1]) == -1\n assert candidate(basket1 = [1, 1, 2, 2],basket2 = [2, 2, 1, 1]) == 0\n assert candidate(basket1 = [5, 7, 10, 15],basket2 = [15, 10, 7, 5]) == 0\n assert candidate(basket1 = [1, 2, 3],basket2 = [3, 2, 1]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5],basket2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(basket1 = [1, 3, 5, 7, 9],basket2 = [2, 4, 6, 8, 10]) == -1\n assert candidate(basket1 = [4, 2, 2, 2],basket2 = [1, 4, 1, 2]) == 1\n assert candidate(basket1 = [10, 10, 10, 10],basket2 = [10, 10, 10, 10]) == 0\n assert candidate(basket1 = [100, 200, 300, 400],basket2 = [400, 500, 600, 700]) == -1\n assert candidate(basket1 = [5, 7, 9, 11],basket2 = [11, 9, 7, 5]) == 0\n assert candidate(basket1 = [1, 3, 5, 7],basket2 = [2, 4, 6, 8]) == -1\n assert candidate(basket1 = [1, 2, 3, 4],basket2 = [4, 3, 2, 1]) == 0\n assert candidate(basket1 = [1, 1, 2, 3],basket2 = [1, 1, 3, 2]) == 0\n assert candidate(basket1 = [10, 10, 10, 10],basket2 = [1, 1, 1, 1]) == 2\n assert candidate(basket1 = [5, 5, 5, 5],basket2 = [5, 5, 5, 5]) == 0\n assert candidate(basket1 = [10, 20, 30, 40],basket2 = [40, 30, 20, 10]) == 0\n assert candidate(basket1 = [1, 1, 1, 1],basket2 = [1, 1, 1, 1]) == 0\n assert candidate(basket1 = [1, 3, 5, 7, 9, 11, 13, 15],basket2 = [15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(basket1 = [100, 200, 300, 400, 500],basket2 = [500, 400, 300, 200, 100]) == 0\n assert candidate(basket1 = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5],basket2 = [5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1]) == 0\n assert candidate(basket1 = [3, 5, 7, 9, 11],basket2 = [9, 11, 5, 7, 3]) == 0\n assert candidate(basket1 = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4],basket2 = [1, 1, 2, 2, 2, 2, 3, 3, 4, 4]) == -1\n assert candidate(basket1 = [1, 2, 2, 3, 3, 4, 5, 5, 5, 6],basket2 = [6, 5, 5, 4, 3, 3, 2, 2, 1, 1]) == -1\n assert candidate(basket1 = [1000000000, 999999999, 1, 2],basket2 = [1000000000, 999999999, 3, 4]) == -1\n assert candidate(basket1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],basket2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(basket1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],basket2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(basket1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],basket2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],basket2 = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 0\n assert candidate(basket1 = [1, 3, 5, 7, 9, 11],basket2 = [2, 4, 6, 8, 10, 12]) == -1\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],basket2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(basket1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],basket2 = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == 0\n assert candidate(basket1 = [1, 1, 2, 3, 4, 5, 6, 7, 8],basket2 = [8, 7, 6, 5, 4, 3, 2, 1, 1]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],basket2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],basket2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == -1\n assert candidate(basket1 = [3, 5, 6, 7, 8, 9],basket2 = [9, 8, 7, 6, 5, 3]) == 0\n assert candidate(basket1 = [1000000000, 1000000000, 1, 1],basket2 = [1, 1, 1000000000, 1000000000]) == 0\n assert candidate(basket1 = [3, 3, 3, 3, 3, 3],basket2 = [1, 1, 1, 1, 1, 1]) == 3\n assert candidate(basket1 = [1, 2, 3, 4, 5],basket2 = [6, 7, 8, 9, 10]) == -1\n assert candidate(basket1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],basket2 = [6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == 0\n assert candidate(basket1 = [1, 3, 5, 7, 9],basket2 = [9, 7, 5, 3, 1]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],basket2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(basket1 = [1, 2, 2, 3, 4, 5],basket2 = [5, 4, 3, 2, 2, 6]) == -1\n assert candidate(basket1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5],basket2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(basket1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],basket2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 5\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],basket2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1]) == 0\n assert candidate(basket1 = [1, 1, 1, 2, 2, 3],basket2 = [1, 1, 1, 2, 2, 3]) == 0\n assert candidate(basket1 = [5, 5, 5, 5, 5],basket2 = [5, 5, 5, 5, 5]) == 0\n assert candidate(basket1 = [2, 2, 2, 2, 3, 3, 3, 3],basket2 = [1, 1, 1, 1, 4, 4, 4, 4]) == 6\n assert candidate(basket1 = [9, 7, 5, 3, 1],basket2 = [1, 3, 5, 7, 9]) == 0\n assert candidate(basket1 = [1, 2, 2, 3, 4, 5],basket2 = [5, 4, 3, 2, 2, 1]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],basket2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(basket1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],basket2 = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == -1\n assert candidate(basket1 = [1, 1, 2, 3, 4, 5],basket2 = [2, 3, 4, 5, 5, 5]) == 1\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],basket2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(basket1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],basket2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(basket1 = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],basket2 = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(basket1 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],basket2 = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 0\n assert candidate(basket1 = [5, 7, 9, 11, 13, 15],basket2 = [15, 13, 11, 9, 7, 5]) == 0\n assert candidate(basket1 = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4],basket2 = [4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 1, 1]) == 0\n assert candidate(basket1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],basket2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 0\n assert candidate(basket1 = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3],basket2 = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(basket1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],basket2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],basket2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(basket1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],basket2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 0\n assert candidate(basket1 = [1, 3, 5, 7, 9, 11, 13, 15],basket2 = [2, 4, 6, 8, 10, 12, 14, 16]) == -1\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6],basket2 = [6, 5, 4, 3, 2, 1]) == 0\n assert candidate(basket1 = [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],basket2 = [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]) == 0\n assert candidate(basket1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],basket2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(basket1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],basket2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(basket1 = [5, 10, 15, 20, 25, 30, 35, 40],basket2 = [40, 35, 30, 25, 20, 15, 10, 5]) == 0\n assert candidate(basket1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],basket2 = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],basket2 = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(basket1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],basket2 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6]) == -1\n assert candidate(basket1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],basket2 = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 0\n assert candidate(basket1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],basket2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5]) == 0\n assert candidate(basket1 = [3, 6, 8, 8, 10],basket2 = [10, 8, 6, 3, 8]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],basket2 = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(basket1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],basket2 = [5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 0\n assert candidate(basket1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],basket2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],basket2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(basket1 = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3],basket2 = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(basket1 = [1, 3, 5, 7, 9, 11, 13],basket2 = [13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(basket1 = [1000000000, 1000000000, 1000000000, 1000000000],basket2 = [1, 1, 1, 1]) == 2\n assert candidate(basket1 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],basket2 = [3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],basket2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 11]) == -1\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],basket2 = [1, 1, 1, 1, 1, 10, 10, 10, 10, 10]) == -1\n assert candidate(basket1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],basket2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8],basket2 = [8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(basket1 = [10, 20, 30, 40, 50, 60],basket2 = [60, 50, 40, 30, 20, 10]) == 0\n assert candidate(basket1 = [1, 2, 2, 3, 4, 5, 5, 6],basket2 = [6, 5, 5, 4, 3, 2, 2, 1]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],basket2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(basket1 = [1, 3, 5, 7, 9, 11, 13, 15],basket2 = [15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(basket1 = [5, 10, 15, 20, 25],basket2 = [25, 20, 15, 10, 5]) == 0\n assert candidate(basket1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],basket2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(basket1 = [10, 20, 30, 40, 50],basket2 = [50, 40, 30, 20, 10]) == 0\n assert candidate(basket1 = [1000000000, 1000000000, 1000000000],basket2 = [1, 1, 1]) == -1\n assert candidate(basket1 = [2, 2, 3, 3, 4, 4],basket2 = [4, 4, 3, 3, 2, 2]) == 0\n assert candidate(basket1 = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2],basket2 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(basket1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],basket2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == -1\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],basket2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(basket1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],basket2 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 0\n assert candidate(basket1 = [7, 7, 7, 8, 9],basket2 = [9, 8, 7, 7, 7]) == 0\n assert candidate(basket1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],basket2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 0\n assert candidate(basket1 = [1, 1, 1, 2, 2, 3],basket2 = [1, 1, 1, 2, 3, 3]) == -1\n assert candidate(basket1 = [1, 3, 5, 7, 9],basket2 = [2, 4, 6, 8, 10]) == -1\n assert candidate(basket1 = [1, 1, 2, 3, 4, 5, 6, 7],basket2 = [7, 6, 5, 4, 3, 2, 1, 1]) == 0\n assert candidate(basket1 = [10, 20, 30, 40, 50],basket2 = [5, 15, 25, 35, 45]) == -1\n assert candidate(basket1 = [1, 2, 2, 3, 4],basket2 = [1, 2, 2, 3, 4]) == 0\n"}, "metadata": {"canonical_parameter_names": ["basket1", "basket2"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minCost(int[] basket1, int[] basket2) {", "container": "Solution", "callable": "minCost", "parameters": [{"name": "basket1", "type": "int[]"}, {"name": "basket2", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2562, "task_id": "find-the-array-concatenation-value", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums.\nThe concatenation of two numbers is the number formed by concatenating their numerals.\n\nFor example, the concatenation of 15, 49 is 1549.\n\nThe concatenation value of nums is initially equal to 0. Perform this operation until nums becomes empty:\n\nIf nums has a size greater than one, add the value of the concatenation of the first and the last element to the concatenation value of nums, and remove those two elements from nums. For example, if the nums was [1, 2, 4, 5, 6], add 16 to the concatenation value.\nIf only one element exists in nums, add its value to the concatenation value of nums, then remove it.\n\nReturn the concatenation value of nums.\n \nExample 1:\n\nInput: nums = [7,52,2,4]\nOutput: 596\nExplanation: Before performing any operation, nums is [7,52,2,4] and concatenation value is 0.\n - In the first operation:\nWe pick the first element, 7, and the last element, 4.\nTheir concatenation is 74, and we add it to the concatenation value, so it becomes equal to 74.\nThen we delete them from nums, so nums becomes equal to [52,2].\n - In the second operation:\nWe pick the first element, 52, and the last element, 2.\nTheir concatenation is 522, and we add it to the concatenation value, so it becomes equal to 596.\nThen we delete them from the nums, so nums becomes empty.\nSince the concatenation value is 596 so the answer is 596.\n\nExample 2:\n\nInput: nums = [5,14,13,8,12]\nOutput: 673\nExplanation: Before performing any operation, nums is [5,14,13,8,12] and concatenation value is 0.\n - In the first operation:\nWe pick the first element, 5, and the last element, 12.\nTheir concatenation is 512, and we add it to the concatenation value, so it becomes equal to 512.\nThen we delete them from the nums, so nums becomes equal to [14,13,8].\n - In the second operation:\nWe pick the first element, 14, and the last element, 8.\nTheir concatenation is 148, and we add it to the concatenation value, so it becomes equal to 660.\nThen we delete them from the nums, so nums becomes equal to [13].\n - In the third operation:\nnums has only one element, so we pick 13 and add it to the concatenation value, so it becomes equal to 673.\nThen we delete it from nums, so nums become empty.\nSince the concatenation value is 673 so the answer is 673.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 104\n\n \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 14, 13, 8, 12]) == 673\n assert candidate(nums = [1, 1, 1, 1]) == 22\n assert candidate(nums = [111, 222, 333, 444, 555]) == 334332\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 315\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 280\n assert candidate(nums = [9]) == 9\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [56, 78, 90, 12, 34]) == 13536\n assert candidate(nums = [7, 52, 2, 4]) == 596\n assert candidate(nums = [9999]) == 9999\n assert candidate(nums = [1234, 5678, 9101]) == 12354779\n assert candidate(nums = [1, 2, 3, 4, 5]) == 42\n assert candidate(nums = [123, 456, 789]) == 124245\n assert candidate(nums = [9, 99, 999, 9999]) == 199998\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 75\n assert candidate(nums = [100, 200, 300, 400, 500]) == 301200\n assert candidate(nums = [9876, 5432, 1234]) == 98766666\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000]) == 30012000\n assert candidate(nums = [10, 20]) == 1020\n assert candidate(nums = [111, 222, 333]) == 111555\n assert candidate(nums = [123, 456, 789, 101, 112]) == 580002\n assert candidate(nums = [1, 2, 3]) == 15\n assert candidate(nums = [10000]) == 10000\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996]) == 200019991\n assert candidate(nums = [123, 456, 789, 101]) == 579890\n assert candidate(nums = [10, 20, 30, 40]) == 3070\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 1113885\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 31111000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 32775\n assert candidate(nums = [54321, 67890, 12345, 98760, 43215]) == 12221254320\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 2404000\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324]) == 102480707478\n assert candidate(nums = [98765, 43210, 13579, 24680]) == 14197538259\n assert candidate(nums = [123, 456, 789, 1011, 1213]) == 5793013\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 11, 22, 33, 44, 55]) == 31152\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 315\n assert candidate(nums = [10000, 10001, 10002, 10003, 10004, 10005]) == 3000330012\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 1000000000]) == 10000000001000000042\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == 11107000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == 678\n assert candidate(nums = [123, 456, 789, 1011, 1213, 1415, 1617, 1819, 2021, 2223]) == 35929095\n assert candidate(nums = [987654, 321098, 765432, 109876]) == 1308752875308\n assert candidate(nums = [55555, 44444, 33333, 22222, 11111]) == 9999966666\n assert candidate(nums = [555, 555, 555, 555, 555, 555, 555, 555, 555, 555]) == 2777775\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 100135035\n assert candidate(nums = [9999, 1, 222, 33, 4444, 555]) == 10036232\n assert candidate(nums = [1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111]) == 55555555555\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]) == 16818\n assert candidate(nums = [98765, 43210, 1111, 2222, 3333, 4444]) == 1430869999\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930]) == 233896111620\n assert candidate(nums = [1, 22, 333, 4444, 55555, 66666, 777777, 8888888, 99999999]) == 1207188885\n assert candidate(nums = [10000, 9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111]) == 433316665\n assert candidate(nums = [12345, 67890, 12345, 67890, 12345, 67890, 12345, 67890, 12345]) == 16047172815\n assert candidate(nums = [1, 10, 100, 1000, 10000, 9999, 999, 99, 9, 8888, 888, 88, 8, 7777, 777, 77, 7]) == 13208429\n assert candidate(nums = [1, 9, 8, 7, 6, 5, 4, 3, 2]) == 270\n assert candidate(nums = [1, 10, 100, 1000, 10000, 9999, 999, 99, 9]) == 10122116\n assert candidate(nums = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111]) == 333316665\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021]) == 1368586266\n assert candidate(nums = [123456789, 987654321, 112233445, 556677889, 998877665, 554433221, 110011223, 334455667, 778899110]) == 1780022446776676886\n assert candidate(nums = [555, 555, 555, 555, 555, 555, 555, 555]) == 2222220\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 42510\n assert candidate(nums = [10000, 9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 0]) == 333416665\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 5655\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 101010, 111111, 121212]) == 6833009997\n assert candidate(nums = [10000, 1, 10000, 1, 10000, 1, 10000]) == 2000020012\n assert candidate(nums = [101010, 202020, 303030, 404040, 505050, 606060]) == 606061515150\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 10001, 20002, 30003, 40004, 50005]) == 15000150015\n assert candidate(nums = [12345, 67890, 12, 345]) == 19134357\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 10350\n assert candidate(nums = [104729, 209458, 314187, 418926, 523665, 628404, 733143, 837882, 942621]) == 1047303665715\n assert candidate(nums = [9876, 5432, 1234, 8765, 4321]) == 153094320\n assert candidate(nums = [777, 888, 999, 111, 222, 333, 444, 555, 666, 0, 1]) == 1350649\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930]) == 233896111620\n assert candidate(nums = [12, 34, 56, 78, 90, 87, 65, 43, 21]) == 18306\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 51111100000\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]) == 8047\n assert candidate(nums = [1, 22, 333, 4444, 55555, 66666, 777777, 8888888, 99999999, 1]) == 15639233341\n assert candidate(nums = [1000, 200, 30, 4, 500, 60, 7000, 800]) == 3015360\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2262\n assert candidate(nums = [100000, 99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 1]) == 33334166666\n assert candidate(nums = [505, 404, 303, 202, 101, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 151845\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 551550\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == 111138885\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999]) == 29999997\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 360\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1010, 1111, 2222]) == 8332007\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 75570\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 5655\n assert candidate(nums = [9876, 5432, 1098, 7654, 3210, 98765, 43210, 12345, 67890]) == 2406225420\n assert candidate(nums = [12345, 67890, 11111, 22222, 33333, 44444]) == 9134699999\n assert candidate(nums = [123, 456, 789, 101, 112, 131, 141, 151]) == 1469535\n assert candidate(nums = [10000, 1000, 100, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, 10000]) == 1010112245\n assert candidate(nums = [54321, 67890, 11111, 22222, 33333, 44444, 55555]) == 13332355554\n assert candidate(nums = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1234]) == 388862344\n assert candidate(nums = [11111, 22222, 33333, 44444, 55555]) == 3333433332\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1111, 2222, 3333]) == 8334330\n assert candidate(nums = [11111, 2222, 333, 44, 5, 6, 77, 888, 9999, 111111]) == 11133679531\n assert candidate(nums = [1010, 2020, 3030, 4040, 5050, 6060, 7070, 8080, 9090, 101010]) == 1151531310\n assert candidate(nums = [104, 205, 306, 407, 508, 609, 710, 811, 912, 1013, 1114, 1215, 1316, 1417, 1518]) == 22109316\n assert candidate(nums = [12345, 67890, 101112, 131415]) == 80235232527\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11, 22, 33, 44, 55, 66, 77, 88, 99]) == 49895\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999999]) == 499999999995\n assert candidate(nums = [876, 543, 210, 987, 654, 321]) == 1630962\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006]) == 60075015\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125]) == 2998531250\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 496450\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 275\n assert candidate(nums = [10, 200, 3000, 40000, 500000, 6000000]) == 606540000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 110\n assert candidate(nums = [12345, 67890, 11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == 14690533329\n assert candidate(nums = [987654321, 123456789, 987654, 12345, 9876, 1234, 987, 123, 98, 12, 9]) == 22343210973\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 360\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == 111138885\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 411110000\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 2428040\n assert candidate(nums = [9, 99, 999, 9999, 99999, 9999, 999, 99, 9]) == 101110095\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 240040000\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 4444, 3333, 2222, 1111]) == 111116665\n assert candidate(nums = [1, 22, 333, 4444, 55555, 666666, 7777777, 88888888, 999999999]) == 12071388885\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 9999, 8888, 7777]) == 570060664\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findTheArrayConcVal", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long findTheArrayConcVal(int[] nums) {", "container": "Solution", "callable": "findTheArrayConcVal", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2563, "task_id": "count-the-number-of-fair-pairs", "difficulty": "Medium", "problem_description": "Given a 0-indexed integer array nums of size n and two integers lower and upper, return the number of fair pairs.\nA pair (i, j) is fair if:\n\n0 <= i < j < n, and\nlower <= nums[i] + nums[j] <= upper\n\n \nExample 1:\n\nInput: nums = [0,1,7,4,4,5], lower = 3, upper = 6\nOutput: 6\nExplanation: There are 6 fair pairs: (0,3), (0,4), (0,5), (1,3), (1,4), and (1,5).\n\nExample 2:\n\nInput: nums = [1,7,9,2,5], lower = 11, upper = 11\nOutput: 1\nExplanation: There is a single fair pair: (2,3).\n\n \nConstraints:\n\n1 <= nums.length <= 105\nnums.length == n\n-109 <= nums[i] <= 109\n-109 <= lower <= upper <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000],lower = 0,upper = 0) == 2\n assert candidate(nums = [0, 1, 7, 4, 4, 5],lower = 3,upper = 6) == 6\n assert candidate(nums = [5, 5, 5, 5, 5],lower = 10,upper = 10) == 10\n assert candidate(nums = [-1, 0, 1, 2, 3],lower = 0,upper = 4) == 8\n assert candidate(nums = [-1, 0, 1, 2, 3],lower = -2,upper = 2) == 6\n assert candidate(nums = [10, 20, 30, 40, 50],lower = 50,upper = 70) == 6\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000],lower = -1500000000,upper = 1500000000) == 6\n assert candidate(nums = [-1, 0, 1, 2, 3],lower = 0,upper = 2) == 5\n assert candidate(nums = [1, 7, 9, 2, 5],lower = 11,upper = 11) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],lower = 5,upper = 15) == 37\n assert candidate(nums = [5, 5, 5, 5, 5],lower = 10,upper = 10) == 10\n assert candidate(nums = [-1, 0, 1, 2, 3],lower = 0,upper = 2) == 5\n assert candidate(nums = [-10, -20, -30, -40, -50],lower = -80,upper = -50) == 7\n assert candidate(nums = [1, 2, 3, 4, 5],lower = 5,upper = 8) == 7\n assert candidate(nums = [-1, 0, 1, 2, 3],lower = 0,upper = 4) == 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],lower = 1,upper = 38) == 189\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],lower = 0,upper = 0) == 190\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],lower = 50,upper = 150) == 37\n assert candidate(nums = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10],lower = -150,upper = -50) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],lower = 10,upper = 20) == 64\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],lower = 10,upper = 30) == 37\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000],lower = -1000000000,upper = 1000000000) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],lower = 15,upper = 35) == 57\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 0],lower = -1000000000,upper = 1000000000) == 8\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000, 750000000, -750000000, 125000000, -125000000],lower = -1500000000,upper = 1500000000) == 43\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45],lower = -50,upper = 50) == 37\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],lower = 15,upper = 20) == 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],lower = 5,upper = 10) == 18\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],lower = 10,upper = 28) == 35\n assert candidate(nums = [-1000000000, 1000000000, 0, -500000000, 500000000],lower = -1500000000,upper = 1500000000) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],lower = 3,upper = 7) == 34\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],lower = -10,upper = 10) == 55\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],lower = 2,upper = 2) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],lower = 10,upper = 20) == 21\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],lower = 10,upper = 20) == 18\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],lower = 1,upper = 38) == 45\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40],lower = -50,upper = 50) == 24\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],lower = -150,upper = -50) == 37\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],lower = 10,upper = 50) == 97\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],lower = 100,upper = 300) == 149\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40],lower = -50,upper = 50) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],lower = 5,upper = 15) == 37\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],lower = 30,upper = 170) == 43\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],lower = 500,upper = 1500) == 37\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],lower = 20,upper = 80) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],lower = 10,upper = 20) == 64\n assert candidate(nums = [5, 2, 8, 3, 1, 9, 6, 4, 7, 10],lower = 5,upper = 15) == 37\n assert candidate(nums = [1, 2, 3, 4, 5],lower = 3,upper = 9) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],lower = 50,upper = 80) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],lower = 2,upper = 2) == 105\n assert candidate(nums = [-5, -4, -3, -2, -1],lower = -8,upper = -2) == 9\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],lower = 5,upper = 10) == 37\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000],lower = -1500000000,upper = 1500000000) == 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],lower = 1,upper = 2) == 190\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],lower = 1000,upper = 2000) == 29\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],lower = 20,upper = 20) == 105\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],lower = 15,upper = 18) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],lower = 100,upper = 200) == 29\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],lower = 10,upper = 20) == 21\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 0],lower = -1500000000,upper = 1500000000) == 10\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45],lower = -30,upper = 30) == 27\n assert candidate(nums = [1, 2, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10],lower = 6,upper = 12) == 40\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],lower = -200,upper = -100) == 29\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],lower = 5000,upper = 15000) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],lower = 18,upper = 20) == 26\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],lower = 0,upper = 0) == 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],lower = 10,upper = 30) == 149\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000],lower = -1500000000,upper = 1500000000) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],lower = 15,upper = 20) == 9\n assert candidate(nums = [-5, 0, 5, 10, 15, 20, 25, 30, 35, 40],lower = 10,upper = 60) == 37\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],lower = 2,upper = 2) == 190\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35],lower = -20,upper = 20) == 16\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],lower = -20,upper = -10) == 29\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],lower = 20,upper = 30) == 84\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],lower = 30,upper = 40) == 30\n assert candidate(nums = [1, 2, 3, 3, 3, 4, 5, 5, 6, 7, 8, 9, 10],lower = 6,upper = 12) == 49\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],lower = 5,upper = 15) == 47\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],lower = 190,upper = 200) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],lower = 18,upper = 30) == 25\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],lower = 1000,upper = 1900) == 29\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],lower = 5,upper = 10) == 23\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],lower = -150,upper = -50) == 37\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],lower = 3,upper = 19) == 188\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],lower = 5,upper = 15) == 37\n assert candidate(nums = [-1, -3, -5, -7, -9, -11, -13, -15, -17, -19],lower = -20,upper = -10) == 21\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],lower = 100,upper = 200) == 35\n assert candidate(nums = [-9, -7, -5, -3, -1, 1, 3, 5, 7, 9],lower = -18,upper = 18) == 45\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],lower = 50,upper = 150) == 37\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],lower = 0,upper = 0) == 45\n"}, "metadata": {"canonical_parameter_names": ["nums", "lower", "upper"], "leetcode_dataset_entry_point": "Solution().countFairPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countFairPairs(int[] nums, int lower, int upper) {", "container": "Solution", "callable": "countFairPairs", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "lower", "type": "int"}, {"name": "upper", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2564, "task_id": "substring-xor-queries", "difficulty": "Medium", "problem_description": "You are given a binary string s, and a 2D integer array queries where queries[i] = [firsti, secondi].\nFor the ith query, find the shortest substring of s whose decimal value, val, yields secondi when bitwise XORed with firsti. In other words, val ^ firsti == secondi.\nThe answer to the ith query is the endpoints (0-indexed) of the substring [lefti, righti] or [-1, -1] if no such substring exists. If there are multiple answers, choose the one with the minimum lefti.\nReturn an array ans where ans[i] = [lefti, righti] is the answer to the ith query.\nA substring is a contiguous non-empty sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"101101\", queries = [[0,5],[1,2]]\nOutput: [[0,2],[2,3]]\nExplanation: For the first query the substring in range [0,2] is \"101\" which has a decimal value of 5, and 5 ^ 0 = 5, hence the answer to the first query is [0,2]. In the second query, the substring in range [2,3] is \"11\", and has a decimal value of 3, and 3 ^ 1 = 2. So, [2,3] is returned for the second query. \n\n\nExample 2:\n\nInput: s = \"0101\", queries = [[12,8]]\nOutput: [[-1,-1]]\nExplanation: In this example there is no substring that answers the query, hence [-1,-1] is returned.\n\nExample 3:\n\nInput: s = \"1\", queries = [[4,5]]\nOutput: [[0,0]]\nExplanation: For this example, the substring in range [0,0] has a decimal value of 1, and 1 ^ 4 = 5. So, the answer is [0,0].\n\n \nConstraints:\n\n1 <= s.length <= 104\ns[i] is either '0' or '1'.\n1 <= queries.length <= 105\n0 <= firsti, secondi <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1\",queries = [[4, 5]]) == [[0, 0]]\n assert candidate(s = \"1100110011\",queries = [[15, 0], [7, 8], [3, 12], [5, 10]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"0101\",queries = [[12, 8]]) == [[-1, -1]]\n assert candidate(s = \"101101\",queries = [[0, 5], [1, 2]]) == [[0, 2], [2, 3]]\n assert candidate(s = \"1010101010\",queries = [[1, 0], [0, 1], [2, 3], [3, 2]]) == [[0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"1111111111\",queries = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"0000000000\",queries = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [[0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"1010101010101010101010101010101010101010\",queries = [[1, 2], [3, 0], [7, 4], [15, 8], [31, 16]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100\",queries = [[15, 0], [31, 16], [63, 48], [127, 96], [255, 192]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"10101100011001100110011001100110011001100110011001100110011001100\",queries = [[12, 8], [14, 10], [15, 9], [16, 8], [17, 9], [18, 10]]) == [[5, 7], [5, 7], [4, 6], [4, 8], [4, 8], [4, 8]]\n assert candidate(s = \"111000111000\",queries = [[7, 7], [14, 14], [1, 1], [2, 2], [3, 3]]) == [[3, 3], [3, 3], [3, 3], [3, 3], [3, 3]]\n assert candidate(s = \"1101001010111010100101001110010111\",queries = [[15, 7], [30, 5], [63, 6], [127, 8], [255, 9]]) == [[-1, -1], [-1, -1], [24, 29], [-1, -1], [-1, -1]]\n assert candidate(s = \"10111011101110111011101110111011101110111011101110111011101110111\",queries = [[0, 5], [1, 2], [3, 6], [4, 7], [8, 9], [10, 11]]) == [[0, 2], [2, 3], [0, 2], [2, 3], [0, 0], [0, 0]]\n assert candidate(s = \"0110110110110110110110110110110110110110110110110110110110110110\",queries = [[6, 6], [14, 14], [22, 22], [30, 30], [38, 38], [46, 46], [54, 54]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010\",queries = [[1, 1], [3, 3], [7, 7], [15, 15], [31, 31], [63, 63], [127, 127], [255, 255], [511, 511]]) == [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]\n assert candidate(s = \"1110001110001110\",queries = [[7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0], [14, 14], [13, 13], [12, 12], [11, 11], [10, 10], [9, 9], [8, 8]]) == [[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]]\n assert candidate(s = \"1111000011110000111100001111000011110000\",queries = [[15, 15], [30, 30], [60, 60], [120, 120], [240, 240]]) == [[4, 4], [4, 4], [4, 4], [4, 4], [4, 4]]\n assert candidate(s = \"10010010010010010010\",queries = [[9, 9], [18, 18], [27, 27], [36, 36], [45, 45]]) == [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]\n assert candidate(s = \"1101101101101101101101101101101101101101101101101101101101101101\",queries = [[13, 13], [9, 9], [7, 7], [5, 5], [3, 3], [1, 1], [0, 0], [15, 15], [2, 2], [6, 6], [4, 4], [8, 8]]) == [[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(s = \"1010101010101010101010101010101010101010101010101010101010101010\",queries = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"10010010010010010010010010010010\",queries = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"01010101010101010101010101010101\",queries = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"111111111111\",queries = [[1023, 1023], [511, 511], [255, 255], [127, 127]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"01100110011001100110011001100110\",queries = [[6, 6], [3, 3], [7, 7], [14, 14], [1, 1], [15, 15], [0, 0]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"10000000000000000001\",queries = [[1, 1], [1024, 1], [1, 1024], [2048, 2], [2, 2048]]) == [[1, 1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"100010001000100010\",queries = [[1, 1], [0, 0], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [15, 15], [14, 14], [13, 13], [12, 12], [11, 11]]) == [[1, 1], [1, 1], [1, 1], [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(s = \"1111111111111111111111111111111111111111111111111111111111111111\",queries = [[1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"10111011101110111011\",queries = [[15, 15], [30, 30], [60, 60], [120, 120], [240, 240]]) == [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]\n assert candidate(s = \"1100110011\",queries = [[3, 7], [15, 8], [2, 14], [5, 10], [6, 12]]) == [[1, 3], [-1, -1], [0, 3], [-1, -1], [-1, -1]]\n assert candidate(s = \"000100010001000100010001000100010001000100010001000100010001000100010001\",queries = [[1, 1], [3, 3], [7, 7], [15, 15], [31, 31], [63, 63], [127, 127], [255, 255], [511, 511]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"101010101010101010\",queries = [[5, 5], [3, 0], [1, 2], [7, 6], [15, 10], [31, 28]]) == [[1, 1], [-1, -1], [-1, -1], [0, 0], [0, 2], [-1, -1]]\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"11001100110011001100\",queries = [[3, 3], [12, 12], [48, 48], [192, 192], [768, 768]]) == [[2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]\n assert candidate(s = \"00000000000000000000000000000000\",queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"11001100110011001100\",queries = [[10, 5], [14, 1], [7, 8], [1, 14]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"11011010101100110110\",queries = [[5, 3], [2, 7], [15, 10], [1, 1]]) == [[0, 2], [1, 3], [1, 3], [2, 2]]\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101\",queries = [[9, 8], [13, 14], [5, 4], [11, 10], [1, 0]]) == [[1, 1], [-1, -1], [1, 1], [1, 1], [1, 1]]\n assert candidate(s = \"110101011010\",queries = [[1, 3], [4, 0], [5, 7], [6, 2]]) == [[1, 2], [-1, -1], [1, 2], [-1, -1]]\n assert candidate(s = \"000111000111000111\",queries = [[7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0], [14, 14], [13, 13], [12, 12], [11, 11], [10, 10], [9, 9], [8, 8]]) == [[0, 0], [0, 0], [0, 0], [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(s = \"10110110110110110110110110110110110110110110110110110110110110110\",queries = [[0, 5], [1, 2], [3, 6], [4, 7], [8, 9], [10, 11]]) == [[0, 2], [2, 3], [0, 2], [2, 3], [0, 0], [0, 0]]\n assert candidate(s = \"10100101001010010100101001010010\",queries = [[1, 0], [2, 3], [3, 2], [4, 7], [8, 15]]) == [[0, 0], [0, 0], [0, 0], [-1, -1], [-1, -1]]\n assert candidate(s = \"0101010101010101\",queries = [[255, 255], [127, 127], [63, 63], [31, 31], [15, 15], [7, 7], [3, 3], [1, 1]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"00010001000100010001000100010001\",queries = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5]]) == [[3, 3], [3, 3], [3, 3], [3, 3], [3, 3]]\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101\",queries = [[1, 0], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23]]) == [[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(s = \"11111111111111111111\",queries = [[1023, 1023], [0, 2047], [1, 2046], [2047, 0]]) == [[-1, -1], [0, 10], [0, 10], [0, 10]]\n assert candidate(s = \"11011011011011011011011011011011\",queries = [[1, 1], [3, 3], [5, 5], [7, 7], [15, 15]]) == [[2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]\n assert candidate(s = \"11111111111111111111\",queries = [[31, 0], [15, 16], [7, 8], [3, 12]]) == [[0, 4], [0, 4], [0, 3], [0, 3]]\n assert candidate(s = \"101010101010\",queries = [[0, 1], [1, 0], [2, 3], [3, 2]]) == [[0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"01010101010101010101\",queries = [[1, 1], [2, 3], [3, 2], [4, 7], [5, 4]]) == [[0, 0], [1, 1], [1, 1], [-1, -1], [1, 1]]\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000000000000000\",queries = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"1100110011001100110011001100110011001100\",queries = [[3, 3], [6, 6], [12, 12], [24, 24], [48, 48]]) == [[2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]\n assert candidate(s = \"11110000111100001111\",queries = [[15, 15], [240, 240], [15, 240], [240, 15], [15, 0]]) == [[4, 4], [4, 4], [-1, -1], [-1, -1], [0, 3]]\n assert candidate(s = \"11100011100011100011\",queries = [[7, 2], [1, 14], [6, 9], [11, 4]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"110011001100110011001100\",queries = [[15, 10], [8, 1], [4, 4], [2, 5], [7, 7], [0, 0]]) == [[-1, -1], [1, 4], [2, 2], [-1, -1], [2, 2], [2, 2]]\n assert candidate(s = \"01010101010101010101010101010101\",queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"10101010101010101010\",queries = [[10, 10], [40, 40], [160, 160], [640, 640], [2560, 2560]]) == [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]\n assert candidate(s = \"110110110110\",queries = [[7, 6], [6, 7], [5, 4], [4, 5], [3, 2], [2, 3], [1, 0], [0, 1]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"10110101010110111011011011010110101101011010110101101011010110101\",queries = [[0, 5], [1, 2], [3, 6], [4, 7], [8, 9], [10, 11]]) == [[0, 2], [2, 3], [0, 2], [2, 3], [0, 0], [0, 0]]\n assert candidate(s = \"01001011010010011001001\",queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"01110111011101110111011101110111\",queries = [[1, 0], [2, 3], [3, 2], [7, 0], [15, 8]]) == [[1, 1], [1, 1], [1, 1], [1, 3], [1, 3]]\n assert candidate(s = \"100010001000100010001000100010001000100010001000100010001000\",queries = [[8, 8], [12, 12], [16, 16], [24, 24], [32, 32], [48, 48], [64, 64]]) == [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]\n assert candidate(s = \"101010101010101010101010101010101010101010101010\",queries = [[3, 10], [12, 5], [8, 1], [4, 4], [2, 5], [7, 7], [0, 0]]) == [[-1, -1], [-1, -1], [-1, -1], [1, 1], [-1, -1], [1, 1], [1, 1]]\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010\",queries = [[12, 8], [14, 10], [15, 9], [16, 8], [17, 9], [18, 10]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"11110000111100001111000011110000111100001111000011110000\",queries = [[15, 15], [31, 31], [63, 63], [127, 127], [255, 255], [511, 511]]) == [[4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4]]\n assert candidate(s = \"110100101011001010110011001010110010101100110010101001010011001\",queries = [[10, 11], [20, 21], [30, 31], [40, 41], [50, 51], [60, 61], [70, 71]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"1010101010101010\",queries = [[1, 0], [2, 3], [4, 7], [8, 15], [16, 31]]) == [[0, 0], [0, 0], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"10101010101010101010\",queries = [[10, 5], [14, 1], [6, 9], [2, 13]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"1100101011001010110010101100101011001010110010101100101011001010110010101100101011001010\",queries = [[123, 89], [456, 789], [101010, 110110], [98765, 56789]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"11111111111111111111111111111111\",queries = [[255, 255], [127, 127], [63, 63], [31, 31], [15, 15], [7, 7], [3, 3], [1, 1]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"001100110011\",queries = [[3, 0], [3, 1], [3, 2], [3, 3]]) == [[2, 3], [3, 4], [2, 2], [0, 0]]\n assert candidate(s = \"11111111111111111111111111111111\",queries = [[15, 0], [14, 1], [13, 2], [12, 3], [11, 4]]) == [[0, 3], [0, 3], [0, 3], [0, 3], [0, 3]]\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000111\",queries = [[31, 30], [28, 29], [25, 26], [22, 23], [19, 20], [16, 17], [13, 14]]) == [[0, 0], [0, 0], [0, 1], [0, 0], [0, 2], [0, 0], [0, 1]]\n assert candidate(s = \"111100001111000011110000\",queries = [[15, 15], [0, 0], [1, 1], [14, 14], [7, 7], [8, 8]]) == [[4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4]]\n assert candidate(s = \"001110011100111\",queries = [[5, 5], [3, 0], [1, 2], [7, 6], [15, 10]]) == [[0, 0], [2, 3], [2, 3], [2, 2], [-1, -1]]\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010\",queries = [[511, 510], [255, 254], [127, 126], [63, 62], [31, 30], [15, 14], [7, 6]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001\",queries = [[9, 9], [5, 5], [10, 10], [6, 6], [2, 2], [3, 3], [1, 1], [0, 0]]) == [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]\n assert candidate(s = \"10010010010010010010\",queries = [[9, 6], [3, 12], [11, 4], [1, 14]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001\",queries = [[1, 0], [0, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"00110011001100110011\",queries = [[3, 12], [14, 1], [5, 0], [2, 13]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"00000000000000000000000000000000\",queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"10101010101010101010101010101010\",queries = [[10, 5], [3, 6], [7, 0], [15, 15]]) == [[-1, -1], [0, 2], [-1, -1], [1, 1]]\n assert candidate(s = \"01010101010101010101\",queries = [[5, 0], [2, 3], [6, 7], [10, 5]]) == [[1, 3], [1, 1], [1, 1], [-1, -1]]\n assert candidate(s = \"1011001100011100000111100000111110000011\",queries = [[255, 255], [127, 127], [63, 63], [31, 31], [15, 15]]) == [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]\n assert candidate(s = \"1100110011\",queries = [[3, 6], [7, 0], [1, 3], [2, 1]]) == [[-1, -1], [-1, -1], [1, 2], [0, 1]]\n assert candidate(s = \"11001100110011001100110011001100\",queries = [[1, 1], [2, 3], [4, 7], [8, 15]]) == [[2, 2], [0, 0], [0, 1], [-1, -1]]\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100\",queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [[2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010\",queries = [[21, 30], [15, 16], [7, 8], [3, 12], [10, 5], [6, 9], [14, 1], [2, 13], [11, 4], [5, 0], [9, 6], [1, 14], [4, 11], [8, 7]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [0, 2], [-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"10101010101010101010\",queries = [[10, 15], [5, 0], [1, 1], [0, 2], [255, 255]]) == [[0, 2], [0, 2], [1, 1], [0, 1], [1, 1]]\n assert candidate(s = \"0011110011110011110011110011110011110011\",queries = [[1, 0], [3, 2], [7, 6], [15, 14], [31, 30]]) == [[2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]\n assert candidate(s = \"1100110011001100\",queries = [[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, 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], [2, 2], [2, 2], [2, 2], [2, 2]]\n assert candidate(s = \"1001101001101001101001101001101001101001101001101001101001101001\",queries = [[5, 6], [10, 11], [15, 16], [20, 21], [25, 26], [30, 31], [35, 36]]) == [[3, 4], [0, 0], [-1, -1], [0, 0], [3, 4], [0, 0], [-1, -1]]\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000000000000000\",queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",queries = [[1023, 511], [511, 1023], [2047, 255], [255, 2047], [65535, 32767], [32767, 65535]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"11111111111111111111\",queries = [[31, 30], [15, 14], [7, 6], [3, 2], [1, 0]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001\",queries = [[9, 1], [15, 15], [7, 0], [3, 1], [1, 0]]) == [[-1, -1], [1, 1], [-1, -1], [0, 1], [0, 0]]\n assert candidate(s = \"0011001100110011001100110011001100110011001100110011001100110011\",queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13]]) == [[2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]\n assert candidate(s = \"1001001001001001001001001001\",queries = [[9, 9], [5, 5], [10, 10], [6, 6], [2, 2], [3, 3], [1, 1]]) == [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",queries = [[1000000, 500000], [500000, 1000000], [2000000, 250000], [250000, 2000000], [6000000, 3000000], [3000000, 6000000]]) == [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]]\n assert candidate(s = \"00110011001100110011\",queries = [[3, 3], [12, 12], [48, 48], [192, 192], [768, 768]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n assert candidate(s = \"0100100010001000100010001000100010001000\",queries = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16]]) == [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]\n"}, "metadata": {"canonical_parameter_names": ["s", "queries"], "leetcode_dataset_entry_point": "Solution().substringXorQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] substringXorQueries(String s, int[][] queries) {", "container": "Solution", "callable": "substringXorQueries", "parameters": [{"name": "s", "type": "String"}, {"name": "queries", "type": "int[][]"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2565, "task_id": "subsequence-with-the-minimum-score", "difficulty": "Hard", "problem_description": "You are given two strings s and t.\nYou are allowed to remove any number of characters from the string t.\nThe score of the string is 0 if no characters are removed from the string t, otherwise:\n\nLet left be the minimum index among all removed characters.\nLet right be the maximum index among all removed characters.\n\nThen the score of the string is right - left + 1.\nReturn the minimum possible score to make t a subsequence of s.\nA subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., \"ace\" is a subsequence of \"abcde\" while \"aec\" is not).\n \nExample 1:\n\nInput: s = \"abacaba\", t = \"bzaa\"\nOutput: 1\nExplanation: In this example, we remove the character \"z\" at index 1 (0-indexed).\nThe string t becomes \"baa\" which is a subsequence of the string \"abacaba\" and the score is 1 - 1 + 1 = 1.\nIt can be proven that 1 is the minimum score that we can achieve.\n\nExample 2:\n\nInput: s = \"cde\", t = \"xyz\"\nOutput: 3\nExplanation: In this example, we remove characters \"x\", \"y\" and \"z\" at indices 0, 1, and 2 (0-indexed).\nThe string t becomes \"\" which is a subsequence of the string \"cde\" and the score is 2 - 0 + 1 = 3.\nIt can be proven that 3 is the minimum score that we can achieve.\n\n \nConstraints:\n\n1 <= s.length, t.length <= 105\ns and t consist of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",t = \"abcde\") == 1\n assert candidate(s = \"hello\",t = \"world\") == 5\n assert candidate(s = \"abcdefghij\",t = \"fihgjedcba\") == 8\n assert candidate(s = \"abcde\",t = \"edcba\") == 4\n assert candidate(s = \"aaaaa\",t = \"aa\") == 0\n assert candidate(s = \"testcase\",t = \"ttccasse\") == 3\n assert candidate(s = \"programming\",t = \"gnimmargorp\") == 9\n assert candidate(s = \"abcd\",t = \"dbca\") == 3\n assert candidate(s = \"xyz\",t = \"abc\") == 3\n assert candidate(s = \"minimum\",t = \"imumin\") == 2\n assert candidate(s = \"abcd\",t = \"dcba\") == 3\n assert candidate(s = \"abcdefg\",t = \"xyz\") == 3\n assert candidate(s = \"programming\",t = \"gaming\") == 0\n assert candidate(s = \"abacaba\",t = \"bzaa\") == 1\n assert candidate(s = \"cde\",t = \"xyz\") == 3\n assert candidate(s = \"abcde\",t = \"ace\") == 0\n assert candidate(s = \"hello\",t = \"olelh\") == 4\n assert candidate(s = \"xyzxyzxyzxyzxyz\",t = \"zyzyzyzyzyzyzyzyzyz\") == 9\n assert candidate(s = \"testcase\",t = \"tttttttt\") == 6\n assert candidate(s = \"abcde\",t = \"abcdxyzef\") == 5\n assert candidate(s = \"hello world\",t = \"worldhello\") == 5\n assert candidate(s = \"abacabadabacaba\",t = \"zabacabadabacabaz\") == 17\n assert candidate(s = \"abababab\",t = \"bababa\") == 0\n assert candidate(s = \"aaaaaaaaaa\",t = \"aaaaaaaaaab\") == 1\n assert candidate(s = \"abcdexyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"aabbaabbaabb\",t = \"bbbb\") == 0\n assert candidate(s = \"abacabadabacaba\",t = \"aaaaabaaa\") == 0\n assert candidate(s = \"longstringwithmanypatterns\",t = \"stringwithpatternsstring\") == 6\n assert candidate(s = \"thisisaverylongstringfortesting\",t = \"stringfortestingthisisaverylong\") == 15\n assert candidate(s = \"abcdefghij\",t = \"bcdefghia\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 84\n assert candidate(s = \"abcabcabcabc\",t = \"cccc\") == 0\n assert candidate(s = \"mississippi\",t = \"pi\") == 0\n assert candidate(s = \"hellotherehellotherehellotherehellothere\",t = \"herehellotherehellotherehellotherehellotherehello\") == 14\n assert candidate(s = \"abracadabra\",t = \"acraabdbrac\") == 6\n assert candidate(s = \"xyzxyzxyz\",t = \"zyxzyxzyx\") == 5\n assert candidate(s = \"abcdabcdabcd\",t = \"dcbaabdcba\") == 7\n assert candidate(s = \"sequence\",t = \"enqueseq\") == 5\n assert candidate(s = \"abracadabra\",t = \"rac\") == 0\n assert candidate(s = \"repeatedcharactersarehere\",t = \"tareeere\") == 0\n assert candidate(s = \"aabbccddeeffgg\",t = \"fedcbazyxwvutsrqponmlkjihgfedcba\") == 31\n assert candidate(s = \"abcdefghij\",t = \"abcdefghijabcdefghij\") == 10\n assert candidate(s = \"bananaananabayananabananabananabanana\",t = \"nananananananananananananananananan\") == 11\n assert candidate(s = \"abcde\",t = \"edcbaa\") == 5\n assert candidate(s = \"longstringwithseveralcharacters\",t = \"characterswithseveralstringlong\") == 21\n assert candidate(s = \"thisisaverylongstringwithmanysimilarcharacters\",t = \"similarcharacters\") == 0\n assert candidate(s = \"hellohellohello\",t = \"ollhll\") == 0\n assert candidate(s = \"longestsubstring\",t = \"strolng\") == 2\n assert candidate(s = \"solvingproblems\",t = \"problemsolving\") == 6\n assert candidate(s = \"banana\",t = \"bananabananabanana\") == 12\n assert candidate(s = \"ababababababababababababababababa\",t = \"bababababababababababababababababa\") == 1\n assert candidate(s = \"aabbccddeeffgghhii\",t = \"ihgfedcba\") == 8\n assert candidate(s = \"abcdefghij\",t = \"ihgfedcbaj\") == 8\n assert candidate(s = \"hellohellohello\",t = \"lllllooohehe\") == 5\n assert candidate(s = \"aaaaaa\",t = \"bbbbbb\") == 6\n assert candidate(s = \"aaaaaabbbbbbcccccc\",t = \"cccccccbaaaaa\") == 7\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",t = \"dogzyxvutwrofsjpmnklobq\") == 20\n assert candidate(s = \"aaaaaaaaaa\",t = \"aaaaaaaaa\") == 0\n assert candidate(s = \"programmingisfun\",t = \"misnpfrmigong\") == 9\n assert candidate(s = \"complexproblem\",t = \"problemcomplex\") == 7\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzzyyxxwwvvuuttssrrqppoonnmmllkkjjiihhhgggffeeedddccbbaa\") == 54\n assert candidate(s = \"abracadabra\",t = \"raac\") == 1\n assert candidate(s = \"findingthesolution\",t = \"solutionfinding\") == 7\n assert candidate(s = \"abcdefghijabcdefghij\",t = \"hgfedcbajihgfedcbaj\") == 16\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 23\n assert candidate(s = \"aaaaabbbbbccccc\",t = \"abcabcabcabc\") == 8\n assert candidate(s = \"abcdabcdabcd\",t = \"ddddccbbbaaa\") == 9\n assert candidate(s = \"racecar\",t = \"racecarracecar\") == 7\n assert candidate(s = \"mississippi\",t = \"ississipisipismiss\") == 9\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzzzyyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbaaabbaa\") == 59\n assert candidate(s = \"mississippi\",t = \"ppiisimiss\") == 6\n assert candidate(s = \"samestring\",t = \"samestring\") == 0\n assert candidate(s = \"abcdexyzabcdexyz\",t = \"zyxwvutzyxwvutzyxwvut\") == 19\n assert candidate(s = \"abcde\",t = \"bcdea\") == 1\n assert candidate(s = \"aabbccddeeff\",t = \"fedcba\") == 5\n assert candidate(s = \"uniquecharacters\",t = \"charactersunique\") == 6\n assert candidate(s = \"abcdefghijabcdefghij\",t = \"fihgjedcbafihgjedcbafihg\") == 21\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 50\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"quickbrownfox\",t = \"brownfoxquick\") == 5\n assert candidate(s = \"dynamicprogramming\",t = \"ymnpgmcratidnodpmg\") == 13\n assert candidate(s = \"abababababab\",t = \"bababababa\") == 0\n assert candidate(s = \"aaaaaabbbbbccccc\",t = \"ccccbbbaaaaa\") == 7\n assert candidate(s = \"abacaxbadacabacaba\",t = \"bacabaa\") == 0\n assert candidate(s = \"abcdefghij\",t = \"abcdefghijk\") == 1\n assert candidate(s = \"longstringthatcontainscharactersrepeatedly\",t = \"characterscharacterscharacters\") == 18\n assert candidate(s = \"abcdabcdabcdabcdabcdabcd\",t = \"dddddddddd\") == 4\n assert candidate(s = \"thisisaverylongstring\",t = \"stringisaverylong\") == 5\n assert candidate(s = \"mississippi\",t = \"issississississississsissississississsississississs\") == 44\n assert candidate(s = \"qzxtqzxtqzxt\",t = \"xtzxtzxtzxtzxtzxtzxtzxtzxtzxtzxtzxtzxtzxtzxt\") == 35\n assert candidate(s = \"abacabadabacaba\",t = \"bzaaazza\") == 6\n assert candidate(s = \"repeatedcharacters\",t = \"eedaaeerereeeddperrrrttt\") == 18\n assert candidate(s = \"pythonprogramming\",t = \"ptyhnonrpgmaminnorgm\") == 14\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzzyyxxwwvvuutssrrqqppoonnllkkjjiihhhgggffeeeddccbaab\") == 50\n assert candidate(s = \"mississippi\",t = \"ppisissam\") == 6\n assert candidate(s = \"thisisatest\",t = \"ttttt\") == 2\n assert candidate(s = \"mississippi\",t = \"ssssii\") == 0\n assert candidate(s = \"abcabcabcabcabcabc\",t = \"cccbbbbaaabbbcccbbbbaaabbb\") == 19\n assert candidate(s = \"thisisalongstring\",t = \"thisstringislong\") == 6\n assert candidate(s = \"xyzxyzxyzxyz\",t = \"zzzzyyyyxxxxyyyyzzzz\") == 15\n assert candidate(s = \"thisisaverylongstring\",t = \"gnirtsylonlavraesiisthis\") == 20\n assert candidate(s = \"abcdefghij\",t = \"aabbccddeeffgghhiijj\") == 18\n assert candidate(s = \"optimization\",t = \"ttttiiiooonnnssss\") == 15\n assert candidate(s = \"abacabadabacaba\",t = \"dabacabad\") == 1\n assert candidate(s = \"abcdeabcdeabcde\",t = \"ecbedcab\") == 4\n assert candidate(s = \"abacabadabacaba\",t = \"abadab\") == 0\n assert candidate(s = \"abcdabcdabcd\",t = \"dddd\") == 1\n assert candidate(s = \"hello\",t = \"hhheeelllllooooo\") == 14\n assert candidate(s = \"thisisaverylongstring\",t = \"tsring\") == 0\n assert candidate(s = \"abacabadabacaba\",t = \"aaabbbccc\") == 3\n assert candidate(s = \"pythonprogramming\",t = \"notapysubsequence\") == 15\n assert candidate(s = \"abacabadabacaba\",t = \"aaaaa\") == 0\n assert candidate(s = \"mississippi\",t = \"ssissip\") == 0\n assert candidate(s = \"abcdefghijabcdefghij\",t = \"jihgfedcbajihgfedcba\") == 18\n assert candidate(s = \"abcdefabcdefabcdef\",t = \"fedcba\") == 3\n assert candidate(s = \"abcdefg\",t = \"gfedcbaacdefg\") == 7\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",t = \"dcbaabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 3\n assert candidate(s = \"mississippi\",t = \"msssssssssssss\") == 9\n assert candidate(s = \"abababababababab\",t = \"babababababababa\") == 1\n assert candidate(s = \"abacabadabacaba\",t = \"abacabacaba\") == 0\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\",t = \"jihgfedcbajihgfedcbajihgfedcbajihgfedcba\") == 36\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"nestednestednested\",t = \"nns\") == 0\n assert candidate(s = \"abacabadabacaba\",t = \"zzzzzzzzzzzzzzz\") == 15\n assert candidate(s = \"aaaaabbbbbcccccdddddeeeee\",t = \"bbbbbeeecdddd\") == 3\n assert candidate(s = \"mississippi\",t = \"ppisss\") == 2\n assert candidate(s = \"aaaaaabbbbbbbccccccdddddeeeeefffff\",t = \"ffffeeeeeddccccbbbaaaa\") == 18\n assert candidate(s = \"longwordhere\",t = \"helloworld\") == 8\n assert candidate(s = \"aaaaaaa\",t = \"aaaaaaa\") == 0\n assert candidate(s = \"abcdefghij\",t = \"abcdefghijxyz\") == 3\n"}, "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().minimumScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumScore(String s, String t) {", "container": "Solution", "callable": "minimumScore", "parameters": [{"name": "s", "type": "String"}, {"name": "t", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2566, "task_id": "maximum-difference-by-remapping-a-digit", "difficulty": "Easy", "problem_description": "You are given an integer num. You know that Bob will sneakily remap one of the 10 possible digits (0 to 9) to another digit.\nReturn the difference between the maximum and minimum values Bob can make by remapping exactly one digit in num.\nNotes:\n\nWhen Bob remaps a digit d1 to another digit d2, Bob replaces all occurrences of d1 in num with d2.\nBob can remap a digit to itself, in which case num does not change.\nBob can remap different digits for obtaining minimum and maximum values respectively.\nThe resulting number after remapping can contain leading zeroes.\n\n \nExample 1:\n\nInput: num = 11891\nOutput: 99009\nExplanation: \nTo achieve the maximum value, Bob can remap the digit 1 to the digit 9 to yield 99899.\nTo achieve the minimum value, Bob can remap the digit 1 to the digit 0, yielding 890.\nThe difference between these two numbers is 99009.\n\nExample 2:\n\nInput: num = 90\nOutput: 99\nExplanation:\nThe maximum value that can be returned by the function is 99 (if 0 is replaced by 9) and the minimum value that can be returned by the function is 0 (if 9 is replaced by 0).\nThus, we return 99.\n \nConstraints:\n\n1 <= num <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 11891) == 99009\n assert candidate(num = 234567890) == 900000000\n assert candidate(num = 123321) == 900009\n assert candidate(num = 55555555) == 99999999\n assert candidate(num = 111111) == 999999\n assert candidate(num = 123456789) == 900000000\n assert candidate(num = 9876543210) == 9100000000\n assert candidate(num = 88888888) == 99999999\n assert candidate(num = 987654321) == 910000000\n assert candidate(num = 101010101) == 909090909\n assert candidate(num = 12321) == 90009\n assert candidate(num = 9999999) == 9999999\n assert candidate(num = 1) == 9\n assert candidate(num = 475328) == 900000\n assert candidate(num = 99999999) == 99999999\n assert candidate(num = 8888888) == 9999999\n assert candidate(num = 99999) == 99999\n assert candidate(num = 1000000) == 9000000\n assert candidate(num = 90) == 99\n assert candidate(num = 1111111) == 9999999\n assert candidate(num = 66666666) == 99999999\n assert candidate(num = 44444444) == 99999999\n assert candidate(num = 111111111) == 999999999\n assert candidate(num = 888111222) == 999000000\n assert candidate(num = 8765432109) == 9000000000\n assert candidate(num = 9999999999999999999) == 9999999999999999999\n assert candidate(num = 101010101010101) == 909090909090909\n assert candidate(num = 88888888888888888888) == 99999999999999999999\n assert candidate(num = 1111000011) == 9999000099\n assert candidate(num = 1000000000) == 9000000000\n assert candidate(num = 80808080) == 90909090\n assert candidate(num = 3330333) == 9990999\n assert candidate(num = 11119999) == 99990000\n assert candidate(num = 1233211233) == 9000099000\n assert candidate(num = 777000777) == 999000999\n assert candidate(num = 59595959) == 90909090\n assert candidate(num = 5678909876) == 9000000000\n assert candidate(num = 555555555555555555) == 999999999999999999\n assert candidate(num = 123123123) == 900900900\n assert candidate(num = 4321098765) == 9000000000\n assert candidate(num = 5555555555) == 9999999999\n assert candidate(num = 111000111000111) == 999000999000999\n assert candidate(num = 111222333444555666777888999) == 999000000000000000000000000\n assert candidate(num = 7777777777) == 9999999999\n assert candidate(num = 1232123212321232123) == 9000900090009000900\n assert candidate(num = 7676767676) == 9090909090\n assert candidate(num = 50505050) == 90909090\n assert candidate(num = 199999991) == 900000009\n assert candidate(num = 123321123) == 900009900\n assert candidate(num = 12233445) == 90000000\n assert candidate(num = 990099009) == 999999999\n assert candidate(num = 505050505) == 909090909\n assert candidate(num = 111999) == 999000\n assert candidate(num = 10001) == 90009\n assert candidate(num = 111222333) == 999000000\n assert candidate(num = 3210987654) == 9000000000\n assert candidate(num = 959595959) == 949494949\n assert candidate(num = 10101010) == 90909090\n assert candidate(num = 1000000001) == 9000000009\n assert candidate(num = 12345678901234567890) == 90000000009000000000\n assert candidate(num = 1098765432) == 9000000000\n assert candidate(num = 1199119911) == 9900990099\n assert candidate(num = 999999999) == 999999999\n assert candidate(num = 555555555) == 999999999\n assert candidate(num = 555505555) == 999909999\n assert candidate(num = 999111999111999) == 999888999888999\n assert candidate(num = 8888888888) == 9999999999\n assert candidate(num = 98765432109876543210) == 91000000009100000000\n assert candidate(num = 111000111) == 999000999\n assert candidate(num = 1010101010) == 9090909090\n assert candidate(num = 9900990099) == 9999999999\n assert candidate(num = 888888888888888888) == 999999999999999999\n assert candidate(num = 777777777) == 999999999\n assert candidate(num = 989898989) == 919191919\n assert candidate(num = 12312312312312312312) == 90090090090090090090\n assert candidate(num = 1001001001) == 9009009009\n assert candidate(num = 100000001) == 900000009\n assert candidate(num = 2109876543) == 9000000000\n assert candidate(num = 1223344556677889900) == 9000000000000000000\n assert candidate(num = 19999999999999999999) == 90000000000000000000\n assert candidate(num = 595959595) == 909090909\n assert candidate(num = 876543210) == 900000000\n assert candidate(num = 9999999999) == 9999999999\n assert candidate(num = 90909090) == 99999999\n assert candidate(num = 99990000) == 99999999\n assert candidate(num = 191919191) == 909090909\n assert candidate(num = 555000) == 999000\n assert candidate(num = 989898989898989) == 919191919191919\n assert candidate(num = 5432109876) == 9000000000\n assert candidate(num = 11100011) == 99900099\n assert candidate(num = 888888888) == 999999999\n assert candidate(num = 1111111111) == 9999999999\n assert candidate(num = 321321321) == 900900900\n assert candidate(num = 95959595) == 94949494\n assert candidate(num = 121212121) == 909090909\n assert candidate(num = 1234321098) == 9000009000\n assert candidate(num = 4321234321) == 9000009000\n assert candidate(num = 1230123012) == 9000900090\n assert candidate(num = 2233223322) == 9900990099\n assert candidate(num = 99009900) == 99999999\n assert candidate(num = 9123456789) == 9800000009\n assert candidate(num = 5555555) == 9999999\n assert candidate(num = 122334455) == 900000000\n assert candidate(num = 1234567890) == 9000000000\n assert candidate(num = 9090909090) == 9999999999\n assert candidate(num = 999000) == 999999\n assert candidate(num = 10101010101010101010) == 90909090909090909090\n assert candidate(num = 88811122) == 99900000\n assert candidate(num = 202020202) == 909090909\n assert candidate(num = 246813579135791357) == 900000000000000000\n assert candidate(num = 12121212) == 90909090\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().minMaxDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minMaxDifference(int num) {", "container": "Solution", "callable": "minMaxDifference", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2567, "task_id": "minimum-score-by-changing-two-elements", "difficulty": "Medium", "problem_description": "You are given an integer array nums.\n\nThe low score of nums is the minimum absolute difference between any two integers.\nThe high score of nums is the maximum absolute difference between any two integers.\nThe score of nums is the sum of the high and low scores.\n\nReturn the minimum score after changing two elements of nums.\n \nExample 1:\n\nInput: nums = [1,4,7,8,5]\nOutput: 3\nExplanation:\n\nChange nums[0] and nums[1] to be 6 so that nums becomes [6,6,7,8,5].\nThe low score is the minimum absolute difference: |6 - 6| = 0.\nThe high score is the maximum absolute difference: |8 - 5| = 3.\nThe sum of high and low score is 3.\n\n\nExample 2:\n\nInput: nums = [1,4,3]\nOutput: 0\nExplanation:\n\nChange nums[1] and nums[2] to 1 so that nums becomes [1,1,1].\nThe sum of maximum absolute difference and minimum absolute difference is 0.\n\n\n \nConstraints:\n\n3 <= nums.length <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 100, 1000, 10000, 100000]) == 990\n assert candidate(nums = [1, 4, 7, 8, 5]) == 3\n assert candidate(nums = [1, 4, 3]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1200\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, 16, 85, 17, 84, 18, 83, 19, 82, 20, 81]) == 97\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 26\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5]) == 6\n assert candidate(nums = [1, 2, 3, 1000, 1001, 1002, 1003, 1004, 1005, 1006]) == 1003\n assert candidate(nums = [1, 1, 1, 1, 100, 100, 100, 100, 100, 100]) == 99\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 24\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == 999999997\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1001, 1002, 1003, 1004]) == 704\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 799\n assert candidate(nums = [1000000000, 999999999, 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, 11, 12, 13, 14, 15]) == 12\n assert candidate(nums = [1, 2, 3, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 799\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == 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]) == 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, 1000]) == 0\n assert candidate(nums = [1, 2, 100, 101, 102, 103, 104, 105, 106, 107]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 3\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 10, 20, 30, 40]) == 79\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1001, 1002, 1003, 1004, 1005]) == 705\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]) == 13\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 30\n assert candidate(nums = [1, 2, 3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 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]) == 22\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 80\n assert candidate(nums = [1000000000, 999999999, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 97\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100, 200, 300, 400, 500]) == 299\n assert candidate(nums = [1, 2, 3, 1000000000, 1000000001, 1000000002, 1000000003]) == 1000000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 100, 101]) == 13\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 799\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 70\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84]) == 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]) == 27\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 119\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 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, 100]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 80\n assert candidate(nums = [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 = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == 300\n assert candidate(nums = [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, 2]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 70\n assert candidate(nums = [1, 2, 3, 1000000000, 2, 3, 1000000000, 2, 3, 1000000000]) == 999999998\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 12\n assert candidate(nums = [10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100]) == 70\n assert candidate(nums = [1, 2, 1000000000, 2, 1000000000, 3, 1000000000, 4, 1000000000, 5]) == 999999998\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 170\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 = [1, 2, 3, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 999999997\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 179\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 200, 300, 400, 500]) == 299\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 2, 3, 4, 5, 6]) == 9999999\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 999999997\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [1, 3, 6, 8, 12, 15, 18, 21, 24, 27]) == 20\n assert candidate(nums = [1, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 70\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 0\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 79\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1000000000, 999999999]) == 9\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]) == 90\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 120\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 60\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimizeSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimizeSum(int[] nums) {", "container": "Solution", "callable": "minimizeSum", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2568, "task_id": "minimum-impossible-or", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums.\nWe say that an integer x is expressible from nums if there exist some integers 0 <= index1 < index2 < ... < indexk < nums.length for which nums[index1] | nums[index2] | ... | nums[indexk] = x. In other words, an integer is expressible if it can be written as the bitwise OR of some subsequence of nums.\nReturn the minimum positive non-zero integer that is not expressible from nums.\n \nExample 1:\n\nInput: nums = [2,1]\nOutput: 4\nExplanation: 1 and 2 are already present in the array. We know that 3 is expressible, since nums[0] | nums[1] = 2 | 1 = 3. Since 4 is not expressible, we return 4.\n\nExample 2:\n\nInput: nums = [5,3,2]\nOutput: 1\nExplanation: We can show that 1 is the smallest number that is not expressible.\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, 3, 2]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16]) == 32\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2048\n assert candidate(nums = [2, 1]) == 4\n assert candidate(nums = [7, 14, 21, 28]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9]) == 2\n assert candidate(nums = [3, 6, 9, 12]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(nums = [6, 10, 14, 18]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 1\n assert candidate(nums = [1024, 2048, 4096, 8192]) == 1\n assert candidate(nums = [7, 14, 28, 56]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [3, 7, 15, 31, 63]) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 16\n assert candidate(nums = [7, 14, 28]) == 1\n assert candidate(nums = [3, 6, 9]) == 1\n assert candidate(nums = [3, 7, 15, 31]) == 1\n assert candidate(nums = [10, 20, 30, 40]) == 1\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 = [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(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 = [1023, 2047, 4095, 8191, 16383, 32767, 65535]) == 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\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1024\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 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]) == 1048576\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 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]) == 2\n assert candidate(nums = [1048576, 2097152, 4194304, 8388608, 16777216, 33554432]) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095]) == 2\n assert candidate(nums = [1073741823, 2147483647, 4294967295, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471]) == 1\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 = [1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456]) == 2\n assert candidate(nums = [2147483647, 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, 1]) == 2147483648\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 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48]) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 65536\n assert candidate(nums = [2, 6, 18, 54, 162, 486, 1458, 4374, 13122, 39366]) == 1\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 102, 106, 110, 114, 118]) == 1\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143]) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 2\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 1\n assert candidate(nums = [8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296]) == 1\n assert candidate(nums = [5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131077]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58]) == 1\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642]) == 1\n assert candidate(nums = [1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125]) == 2\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 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2048\n assert candidate(nums = [3, 5, 9, 17, 33, 65, 129, 257, 513]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 32768\n assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120]) == 1\n assert candidate(nums = [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046, 4094, 8190, 16382, 32766, 65534]) == 1\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]) == 1\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000]) == 1\n assert candidate(nums = [4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92, 100, 108, 116, 124]) == 1\n assert candidate(nums = [31, 63, 127, 255, 511, 1023, 2047, 4095]) == 1\n assert candidate(nums = [100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400]) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 4096\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]) == 1\n assert candidate(nums = [3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385]) == 1\n assert candidate(nums = [1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456]) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 1\n assert candidate(nums = [1, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 2\n assert candidate(nums = [1000000000, 999999999, 1000000001, 999999998, 1000000002, 999999997, 1000000003, 999999996, 1000000004, 999999995]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 2\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168]) == 1\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62]) == 1\n assert candidate(nums = [1, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097]) == 2\n assert candidate(nums = [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]) == 4\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 131072\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, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 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]) == 32\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 1\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57]) == 2\n assert candidate(nums = [1073741824, 2147483648, 4294967296, 8589934592, 17179869184]) == 1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(nums = [255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 1\n assert candidate(nums = [3, 5, 6, 9, 10, 12, 15, 17, 18, 20, 24, 30]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 8192\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 524288\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152]) == 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]) == 32\n assert candidate(nums = [2147483647, 1073741824, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096]) == 1\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2048\n assert candidate(nums = [1073741824, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576]) == 1\n assert candidate(nums = [4294967295, 2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191]) == 1\n assert candidate(nums = [1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144]) == 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]) == 2\n assert candidate(nums = [3, 11, 43, 171, 683, 2731, 10923, 43691, 174763, 699051, 2796203, 11184811, 44739243, 178956971, 715827883]) == 1\n assert candidate(nums = [3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48]) == 1\n assert candidate(nums = [31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]) == 1\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61]) == 2\n assert candidate(nums = [7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071]) == 1\n assert candidate(nums = [9, 18, 36, 72, 144, 288, 576, 1152, 2304, 4608, 9216]) == 1\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]) == 2\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minImpossibleOR", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minImpossibleOR(int[] nums) {", "container": "Solution", "callable": "minImpossibleOR", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2569, "task_id": "handling-sum-queries-after-update", "difficulty": "Hard", "problem_description": "You are given two 0-indexed arrays nums1 and nums2 and a 2D array queries of queries. There are three types of queries:\n\nFor a query of type 1, queries[i] = [1, l, r]. Flip the values from 0 to 1 and from 1 to 0 in nums1 from index l to index r. Both l and r are 0-indexed.\nFor a query of type 2, queries[i] = [2, p, 0]. For every index 0 <= i < n, set nums2[i] = nums2[i] + nums1[i] * p.\nFor a query of type 3, queries[i] = [3, 0, 0]. Find the sum of the elements in nums2.\n\nReturn an array containing all the answers to the third type queries.\n \nExample 1:\n\nInput: nums1 = [1,0,1], nums2 = [0,0,0], queries = [[1,1,1],[2,1,0],[3,0,0]]\nOutput: [3]\nExplanation: After the first query nums1 becomes [1,1,1]. After the second query, nums2 becomes [1,1,1], so the answer to the third query is 3. Thus, [3] is returned.\n\nExample 2:\n\nInput: nums1 = [1], nums2 = [5], queries = [[2,0,0],[3,0,0]]\nOutput: [5]\nExplanation: After the first query, nums2 remains [5], so the answer to the second query is 5. Thus, [5] is returned.\n\n \nConstraints:\n\n1 <= nums1.length,nums2.length <= 105\nnums1.length = nums2.length\n1 <= queries.length <= 105\nqueries[i].length = 3\n0 <= l <= r <= nums1.length - 1\n0 <= p <= 106\n0 <= nums1[i] <= 1\n0 <= nums2[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [1],nums2 = [5],queries = [[2, 0, 0], [3, 0, 0]]) == [5]\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50],queries = [[2, 5, 0], [3, 0, 0], [1, 0, 2], [2, 3, 0], [3, 0, 0]]) == [175, 181]\n assert candidate(nums1 = [1, 0, 1],nums2 = [0, 0, 0],queries = [[1, 1, 1], [2, 1, 0], [3, 0, 0]]) == [3]\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],queries = [[1, 0, 4], [1, 0, 4], [2, 1, 0], [3, 0, 0]]) == [0]\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 2, 3, 4],queries = [[1, 0, 3], [2, 2, 0], [3, 0, 0], [1, 1, 2], [3, 0, 0]]) == [18, 18]\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],queries = [[3, 0, 0], [1, 0, 1], [3, 0, 0], [2, 3, 0], [3, 0, 0]]) == [4, 4, 10]\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [0, 0, 0, 0],queries = [[2, 1, 0], [3, 0, 0], [1, 0, 1], [2, 2, 0], [3, 0, 0]]) == [4, 8]\n assert candidate(nums1 = [0, 1, 0, 1, 0],nums2 = [1, 2, 3, 4, 5],queries = [[1, 0, 4], [2, 2, 0], [3, 0, 0], [1, 1, 3], [2, 3, 0], [3, 0, 0]]) == [21, 33]\n assert candidate(nums1 = [1, 0, 0, 1],nums2 = [10, 20, 30, 40],queries = [[1, 0, 3], [2, 5, 0], [3, 0, 0], [1, 1, 2], [2, 10, 0], [3, 0, 0]]) == [110, 110]\n assert candidate(nums1 = [1, 1, 0, 0],nums2 = [10, 20, 30, 40],queries = [[2, 1, 0], [3, 0, 0], [1, 0, 1], [2, 3, 0], [3, 0, 0]]) == [102, 102]\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 1, 1, 1],queries = [[1, 0, 2], [2, 3, 0], [3, 0, 0], [1, 1, 3], [3, 0, 0]]) == [13, 13]\n assert candidate(nums1 = [1, 0, 1, 0, 1],nums2 = [5, 5, 5, 5, 5],queries = [[1, 0, 4], [2, 2, 0], [3, 0, 0], [1, 1, 3], [2, 1, 0], [3, 0, 0]]) == [29, 30]\n assert candidate(nums1 = [0, 1, 0, 1],nums2 = [1, 2, 3, 4],queries = [[1, 0, 3], [2, 2, 0], [3, 0, 0], [1, 1, 2], [3, 0, 0]]) == [14, 14]\n assert candidate(nums1 = [0, 1, 1, 0, 1],nums2 = [1, 2, 3, 4, 5],queries = [[1, 0, 4], [2, 2, 0], [3, 0, 0], [1, 2, 3], [3, 0, 0]]) == [19, 19]\n assert candidate(nums1 = [1, 0, 0, 1, 1],nums2 = [5, 5, 5, 5, 5],queries = [[2, 1, 0], [3, 0, 0], [1, 0, 4], [3, 0, 0], [2, 2, 0], [3, 0, 0]]) == [28, 28, 32]\n assert candidate(nums1 = [1, 1, 0, 0, 1],nums2 = [10, 20, 30, 40, 50],queries = [[1, 1, 3], [2, 3, 0], [3, 0, 0], [1, 0, 2], [3, 0, 0]]) == [162, 162]\n assert candidate(nums1 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[1, 0, 9], [2, 5, 0], [3, 0, 0], [1, 2, 7], [2, 3, 0], [3, 0, 0], [1, 1, 8], [3, 0, 0], [1, 0, 9], [3, 0, 0]]) == [5520, 5526, 5526, 5526]\n assert candidate(nums1 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],queries = [[1, 0, 5], [2, 10, 0], [3, 0, 0], [1, 6, 11], [2, 20, 0], [3, 0, 0], [1, 2, 9], [3, 0, 0], [1, 0, 11], [2, 5, 0], [3, 0, 0]]) == [820, 940, 940, 970]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 0, 4], [2, 2, 0], [3, 0, 0], [1, 5, 9], [2, 3, 0], [3, 0, 0], [1, 0, 9], [3, 0, 0]]) == [558, 573, 573]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000],queries = [[1, 0, 9], [2, 1000000, 0], [3, 0, 0], [1, 0, 4], [2, 500000, 0], [3, 0, 0], [1, 5, 9], [2, 300000, 0], [3, 0, 0], [1, 1, 8], [3, 0, 0]]) == [60000000, 63000000, 64500000, 64500000]\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[1, 0, 19], [2, 1, 0], [3, 0, 0], [1, 2, 18], [2, 2, 0], [3, 0, 0], [1, 3, 17], [2, 3, 0], [3, 0, 0], [1, 0, 16], [3, 0, 0]]) == [230, 236, 290, 290]\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],queries = [[2, 5, 0], [3, 0, 0], [1, 0, 2], [2, 3, 0], [3, 0, 0], [1, 3, 6], [2, 2, 0], [3, 0, 0], [1, 0, 4], [3, 0, 0]]) == [10000005, 10000026, 10000032, 10000032]\n assert candidate(nums1 = [1, 0, 0, 1, 1, 0, 0, 1],nums2 = [100, 200, 300, 400, 500, 600, 700, 800],queries = [[1, 0, 3], [2, 4, 0], [3, 0, 0], [1, 4, 7], [2, 2, 0], [3, 0, 0]]) == [3616, 3624]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],queries = [[1, 0, 19], [2, 2, 0], [3, 0, 0], [1, 5, 15], [2, 3, 0], [3, 0, 0], [1, 10, 18], [2, 5, 0], [3, 0, 0]]) == [2120, 2147, 2197]\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000],queries = [[1, 0, 9], [2, 1000, 0], [3, 0, 0], [1, 0, 4], [2, 500, 0], [3, 0, 0], [1, 5, 9], [2, 300, 0], [3, 0, 0]]) == [55005000, 55007000, 55008500]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[1, 0, 19], [2, 1, 0], [3, 0, 0], [1, 5, 14], [2, 2, 0], [3, 0, 0], [1, 0, 9], [3, 0, 0], [1, 10, 19], [3, 0, 0]]) == [220, 240, 240, 240]\n assert candidate(nums1 = [0, 0, 1, 1, 0, 1, 0, 0, 1, 0],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 2, 5], [2, 3, 0], [3, 0, 0], [1, 1, 8], [2, 5, 0], [3, 0, 0], [1, 0, 9], [2, 1, 0], [3, 0, 0]]) == [556, 586, 590]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[1, 0, 19], [2, 5, 0], [3, 0, 0], [1, 5, 14], [2, 3, 0], [3, 0, 0], [1, 1, 18], [2, 7, 0], [3, 0, 0]]) == [260, 290, 360]\n assert candidate(nums1 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],queries = [[1, 0, 19], [2, 5, 0], [3, 0, 0], [1, 2, 17], [2, 3, 0], [3, 0, 0], [1, 1, 16], [3, 0, 0], [1, 0, 15], [3, 0, 0], [1, 0, 19], [3, 0, 0]]) == [21050, 21080, 21080, 21080, 21080]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[1, 0, 14], [2, 1, 0], [3, 0, 0], [1, 3, 7], [2, 2, 0], [3, 0, 0], [1, 10, 14], [3, 0, 0]]) == [82, 94, 94]\n assert candidate(nums1 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 1, 8], [2, 2, 0], [3, 0, 0], [1, 2, 7], [2, 3, 0], [3, 0, 0]]) == [104, 112, 130]\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 0, 19], [2, 1, 0], [3, 0, 0], [1, 0, 9], [2, 2, 0], [3, 0, 0], [1, 10, 19], [2, 3, 0], [3, 0, 0]]) == [40, 60, 60]\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 0, 9], [3, 0, 0], [1, 0, 9], [3, 0, 0]]) == [20, 20, 20, 20]\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[1, 0, 3], [2, 2, 0], [3, 0, 0], [1, 4, 7], [2, 3, 0], [3, 0, 0], [1, 5, 9], [2, 1, 0], [3, 0, 0], [1, 0, 9], [3, 0, 0]]) == [5510, 5525, 5531, 5531]\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[2, 10, 0], [3, 0, 0], [1, 0, 4], [2, 5, 0], [3, 0, 0], [1, 5, 9], [2, 3, 0], [3, 0, 0]]) == [5600, 5625, 5625]\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 1, 8], [2, 5, 0], [3, 0, 0], [1, 0, 4], [2, 3, 0], [3, 0, 0], [1, 5, 9], [3, 0, 0]]) == [575, 593, 593]\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 0, 4], [2, 2, 0], [3, 0, 0], [1, 5, 9], [2, 3, 0], [3, 0, 0]]) == [5510, 5520, 5520]\n assert candidate(nums1 = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[1, 0, 1], [2, 5, 0], [3, 0, 0], [1, 2, 3], [2, 3, 0], [3, 0, 0], [1, 4, 5], [3, 0, 0]]) == [5530, 5542, 5542]\n assert candidate(nums1 = [0, 0, 1, 1, 0, 1, 0, 0, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 0, 9], [2, 2, 0], [3, 0, 0], [1, 1, 5], [2, 3, 0], [3, 0, 0], [1, 2, 4], [2, 1, 0], [3, 0, 0]]) == [560, 578, 583]\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 1, 8], [2, 2, 0], [3, 0, 0], [1, 2, 7], [3, 0, 0]]) == [15, 25, 25]\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [[1, 0, 9], [2, 5, 0], [3, 0, 0], [1, 1, 8], [2, 3, 0], [3, 0, 0], [1, 0, 4], [3, 0, 0], [1, 5, 9], [3, 0, 0]]) == [300, 315, 315, 315]\n assert candidate(nums1 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 3, 6], [2, 2, 0], [3, 0, 0], [1, 0, 4], [2, 3, 0], [3, 0, 0]]) == [54, 62, 77]\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 1, 8], [2, 2, 0], [3, 0, 0], [1, 2, 7], [2, 3, 0], [3, 0, 0], [1, 0, 9], [2, 1, 0], [3, 0, 0]]) == [15, 25, 40, 45]\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],queries = [[1, 0, 14], [2, 15, 0], [3, 0, 0], [1, 3, 7], [2, 2, 0], [3, 0, 0], [1, 10, 14], [3, 0, 0], [1, 0, 14], [2, 1, 0], [3, 0, 0], [1, 6, 10], [2, 3, 0], [3, 0, 0]]) == [12000, 12010, 12010, 12015, 12033]\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],queries = [[1, 0, 9], [2, 1000000, 0], [3, 0, 0], [1, 0, 4], [2, 1000000, 0], [3, 0, 0], [1, 5, 9], [2, 1000000, 0], [3, 0, 0]]) == [10, 5000010, 15000010]\n assert candidate(nums1 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[1, 1, 3], [2, 1, 0], [3, 0, 0], [1, 5, 7], [2, 2, 0], [3, 0, 0], [1, 0, 9], [3, 0, 0]]) == [57, 73, 73]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 1, 8], [2, 2, 0], [3, 0, 0], [1, 2, 7], [2, 3, 0], [3, 0, 0]]) == [280, 290, 305]\n assert candidate(nums1 = [0, 0, 1, 1, 0, 0, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1, 6], [2, 1, 0], [3, 0, 0], [1, 0, 5], [2, 3, 0], [3, 0, 0], [1, 2, 4], [3, 0, 0], [1, 0, 7], [3, 0, 0]]) == [12, 24, 24, 24]\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[1, 0, 0], [2, 15, 0], [3, 0, 0], [1, 1, 1], [2, 14, 0], [3, 0, 0], [1, 2, 2], [3, 0, 0], [1, 3, 3], [3, 0, 0], [1, 4, 4], [3, 0, 0], [1, 5, 5], [3, 0, 0], [1, 6, 6], [3, 0, 0], [1, 7, 7], [3, 0, 0], [1, 8, 8], [3, 0, 0], [1, 9, 9], [3, 0, 0], [1, 10, 10], [3, 0, 0], [1, 11, 11], [3, 0, 0], [1, 12, 12], [3, 0, 0], [1, 13, 13], [3, 0, 0], [1, 14, 14], [3, 0, 0]]) == [135, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],queries = [[1, 0, 14], [2, 2, 0], [3, 0, 0], [1, 1, 13], [2, 3, 0], [3, 0, 0], [1, 2, 12], [2, 1, 0], [3, 0, 0], [1, 3, 11], [3, 0, 0], [1, 4, 10], [2, 2, 0], [3, 0, 0]]) == [1214, 1232, 1237, 1237, 1243]\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 0, 9], [2, 2, 0], [3, 0, 0], [1, 1, 8], [2, 3, 0], [3, 0, 0], [1, 4, 7], [2, 4, 0], [3, 0, 0]]) == [65, 80, 100]\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[1, 0, 9], [2, 2, 0], [3, 0, 0], [1, 1, 8], [2, 4, 0], [3, 0, 0], [1, 2, 7], [2, 6, 0], [3, 0, 0]]) == [120, 140, 170]\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 0, 4], [2, 2, 0], [3, 0, 0], [1, 5, 9], [2, 3, 0], [3, 0, 0], [1, 2, 8], [2, 1, 0], [3, 0, 0]]) == [20, 50, 53]\n assert candidate(nums1 = [1, 0, 0, 1, 1, 0, 1, 0, 1, 1],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [[1, 0, 9], [2, 5, 0], [3, 0, 0], [1, 3, 6], [2, 3, 0], [3, 0, 0], [1, 2, 4], [3, 0, 0], [1, 1, 8], [2, 2, 0], [3, 0, 0]]) == [295, 313, 313, 323]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [[1, 0, 4], [2, 2, 0], [3, 0, 0], [1, 5, 9], [2, 3, 0], [3, 0, 0], [1, 2, 6], [2, 1, 0], [3, 0, 0]]) == [283, 298, 304]\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 2, 8], [2, 2, 0], [3, 0, 0], [1, 3, 7], [2, 3, 0], [3, 0, 0]]) == [65, 71, 95]\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],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 10, 19], [2, 1, 0], [3, 0, 0], [1, 0, 19], [2, 1, 0], [3, 0, 0]]) == [30, 30, 50]\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 = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981],queries = [[2, 5, 0], [3, 0, 0], [1, 0, 2], [2, 3, 0], [3, 0, 0], [1, 3, 6], [2, 2, 0], [3, 0, 0], [1, 0, 4], [3, 0, 0], [2, 7, 0], [3, 0, 0]]) == [19999910, 19999961, 19999987, 19999987, 20000113]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [0, 2, 0, 4, 0, 6, 0, 8, 0, 10],queries = [[1, 1, 8], [2, 3, 0], [3, 0, 0], [1, 0, 9], [2, 2, 0], [3, 0, 0]]) == [45, 55]\n assert candidate(nums1 = [0, 1, 1, 0, 1, 0, 1, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8],queries = [[1, 0, 7], [2, 3, 0], [3, 0, 0], [1, 1, 5], [2, 2, 0], [3, 0, 0], [1, 2, 4], [3, 0, 0]]) == [48, 58, 58]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 0, 9], [2, 5, 0], [3, 0, 0], [1, 2, 7], [2, 3, 0], [3, 0, 0], [1, 1, 8], [3, 0, 0]]) == [575, 590, 590]\n assert candidate(nums1 = [0, 1, 1, 0, 1, 1, 0, 1],nums2 = [100, 200, 300, 400, 500, 600, 700, 800],queries = [[1, 1, 6], [2, 150, 0], [3, 0, 0], [1, 2, 5], [2, 100, 0], [3, 0, 0], [1, 0, 7], [3, 0, 0]]) == [4050, 4550, 4550]\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[1, 0, 19], [2, 5, 0], [3, 0, 0], [1, 2, 17], [2, 3, 0], [3, 0, 0], [1, 1, 16], [3, 0, 0], [1, 0, 15], [3, 0, 0]]) == [260, 290, 290, 290]\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 0, 9], [2, 5, 0], [3, 0, 0], [1, 2, 7], [2, 2, 0], [3, 0, 0], [1, 1, 8], [2, 3, 0], [3, 0, 0], [1, 3, 6], [3, 0, 0]]) == [550, 562, 568, 568]\n assert candidate(nums1 = [1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0],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],queries = [[1, 0, 29], [2, 30, 0], [3, 0, 0], [1, 0, 10], [2, 10, 0], [3, 0, 0], [1, 5, 25], [2, 20, 0], [3, 0, 0], [1, 10, 20], [2, 15, 0], [3, 0, 0]]) == [945, 1115, 1395, 1680]\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],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],queries = [[1, 0, 29], [2, 30, 0], [3, 0, 0], [1, 5, 20], [2, 10, 0], [3, 0, 0], [1, 15, 25], [3, 0, 0], [1, 10, 25], [2, 2, 0], [3, 0, 0]]) == [945, 1105, 1105, 1139]\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 0, 19], [2, 2, 0], [3, 0, 0], [1, 1, 18], [2, 3, 0], [3, 0, 0], [1, 2, 17], [2, 1, 0], [3, 0, 0], [1, 3, 16], [3, 0, 0], [1, 4, 15], [2, 2, 0], [3, 0, 0], [1, 5, 14], [3, 0, 0], [1, 6, 13], [3, 0, 0], [1, 7, 12], [3, 0, 0], [1, 8, 11], [3, 0, 0], [1, 9, 10], [3, 0, 0]]) == [60, 66, 84, 84, 116, 116, 116, 116, 116, 116]\n assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 1, 8], [2, 2, 0], [3, 0, 0], [1, 2, 7], [2, 3, 0], [3, 0, 0], [1, 3, 6], [3, 0, 0], [1, 4, 5], [3, 0, 0]]) == [15, 25, 40, 40, 40]\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 0, 9], [2, 1, 0], [3, 0, 0], [1, 2, 8], [2, 2, 0], [3, 0, 0], [1, 0, 4], [3, 0, 0]]) == [20, 26, 26]\n assert candidate(nums1 = [1, 0, 0, 1, 1, 0, 1, 0, 1, 0],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 0, 9], [2, 2, 0], [3, 0, 0], [1, 3, 6], [2, 3, 0], [3, 0, 0], [1, 1, 8], [3, 0, 0]]) == [560, 581, 581]\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "queries"], "leetcode_dataset_entry_point": "Solution().handleQuery", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long[] handleQuery(int[] nums1, int[] nums2, int[][] queries) {", "container": "Solution", "callable": "handleQuery", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}, {"name": "queries", "type": "int[][]"}], "return_type": "long[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2570, "task_id": "merge-two-2d-arrays-by-summing-values", "difficulty": "Easy", "problem_description": "You are given two 2D integer arrays nums1 and nums2.\n\nnums1[i] = [idi, vali] indicate that the number with the id idi has a value equal to vali.\nnums2[i] = [idi, vali] indicate that the number with the id idi has a value equal to vali.\n\nEach array contains unique ids and is sorted in ascending order by id.\nMerge the two arrays into one array that is sorted in ascending order by id, respecting the following conditions:\n\nOnly ids that appear in at least one of the two arrays should be included in the resulting array.\nEach id should be included only once and its value should be the sum of the values of this id in the two arrays. If the id does not exist in one of the two arrays, then assume its value in that array to be 0.\n\nReturn the resulting array. The returned array must be sorted in ascending order by id.\n \nExample 1:\n\nInput: nums1 = [[1,2],[2,3],[4,5]], nums2 = [[1,4],[3,2],[4,1]]\nOutput: [[1,6],[2,3],[3,2],[4,6]]\nExplanation: The resulting array contains the following:\n- id = 1, the value of this id is 2 + 4 = 6.\n- id = 2, the value of this id is 3.\n- id = 3, the value of this id is 2.\n- id = 4, the value of this id is 5 + 1 = 6.\n\nExample 2:\n\nInput: nums1 = [[2,4],[3,6],[5,5]], nums2 = [[1,3],[4,3]]\nOutput: [[1,3],[2,4],[3,6],[4,3],[5,5]]\nExplanation: There are no common ids, so we just include each id with its value in the resulting list.\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 200\nnums1[i].length == nums2[j].length == 2\n1 <= idi, vali <= 1000\nBoth arrays contain unique ids.\nBoth arrays are in strictly ascending order by id.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [[1, 2], [2, 3], [4, 5]],nums2 = [[1, 4], [3, 2], [4, 1]]) == [(1, 6), (2, 3), (3, 2), (4, 6)]\n assert candidate(nums1 = [[2, 4], [3, 6], [5, 5]],nums2 = [[1, 3], [4, 3]]) == [(1, 3), (2, 4), (3, 6), (4, 3), (5, 5)]\n assert candidate(nums1 = [[1, 5], [2, 3]],nums2 = [[1, 5], [2, 3]]) == [(1, 10), (2, 6)]\n assert candidate(nums1 = [[1, 5]],nums2 = [[2, 3]]) == [(1, 5), (2, 3)]\n assert candidate(nums1 = [[1, 1000], [2, 999], [3, 998]],nums2 = [[4, 997], [5, 996], [6, 995]]) == [(1, 1000), (2, 999), (3, 998), (4, 997), (5, 996), (6, 995)]\n assert candidate(nums1 = [[500, 1000], [600, 900], [700, 800]],nums2 = [[550, 850], [650, 750], [750, 650]]) == [(500, 1000), (550, 850), (600, 900), (650, 750), (700, 800), (750, 650)]\n assert candidate(nums1 = [[1, 2], [3, 4], [5, 6], [7, 8]],nums2 = [[1, 9], [3, 8], [5, 7], [7, 6]]) == [(1, 11), (3, 12), (5, 13), (7, 14)]\n assert candidate(nums1 = [[1, 5], [3, 15], [5, 25], [7, 35]],nums2 = [[2, 10], [4, 20], [6, 30], [8, 40]]) == [(1, 5), (2, 10), (3, 15), (4, 20), (5, 25), (6, 30), (7, 35), (8, 40)]\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, 10], [2, 20], [3, 30], [4, 40], [5, 50]]) == [(1, 11), (2, 22), (3, 33), (4, 44), (5, 55), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)]\n assert candidate(nums1 = [[1, 999], [2, 998], [3, 997], [4, 996], [5, 995]],nums2 = [[1, 1]]) == [(1, 1000), (2, 998), (3, 997), (4, 996), (5, 995)]\n assert candidate(nums1 = [[50, 1], [100, 1], [150, 1], [200, 1]],nums2 = [[25, 1], [75, 1], [125, 1], [175, 1], [225, 1]]) == [(25, 1), (50, 1), (75, 1), (100, 1), (125, 1), (150, 1), (175, 1), (200, 1), (225, 1)]\n assert candidate(nums1 = [[1, 50], [2, 50], [3, 50], [4, 50], [5, 50]],nums2 = [[1, 50], [2, 50], [3, 50], [4, 50], [5, 50]]) == [(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)]\n assert candidate(nums1 = [[1, 1000], [2, 999], [3, 998]],nums2 = [[1, 1], [2, 2], [3, 3]]) == [(1, 1001), (2, 1001), (3, 1001)]\n assert candidate(nums1 = [[1, 999]],nums2 = [[2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [(1, 999), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1), (7, 1), (8, 1), (9, 1), (10, 1)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3]],nums2 = [[1, 2], [2, 3], [3, 4]]) == [(1, 3), (2, 5), (3, 7)]\n assert candidate(nums1 = [[1, 1]],nums2 = [[999, 1000], [998, 999], [997, 998], [996, 997], [995, 996]]) == [(1, 1), (995, 996), (996, 997), (997, 998), (998, 999), (999, 1000)]\n assert candidate(nums1 = [[1, 2], [5, 6], [9, 10]],nums2 = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11]]) == [(1, 2), (2, 3), (4, 5), (5, 6), (6, 7), (8, 9), (9, 10), (10, 11)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],nums2 = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18]]) == [(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)]\n assert candidate(nums1 = [[1, 999]],nums2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 1000), (2, 2), (3, 3), (4, 4), (5, 5)]\n assert candidate(nums1 = [[100, 100], [200, 200], [300, 300]],nums2 = [[101, 101], [201, 201], [301, 301]]) == [(100, 100), (101, 101), (200, 200), (201, 201), (300, 300), (301, 301)]\n assert candidate(nums1 = [[100, 100], [200, 200], [300, 300]],nums2 = [[100, 100], [200, 200], [300, 300]]) == [(100, 200), (200, 400), (300, 600)]\n assert candidate(nums1 = [[10, 20], [30, 40], [50, 60], [70, 80]],nums2 = [[20, 30], [40, 50], [60, 70], [80, 90]]) == [(10, 20), (20, 30), (30, 40), (40, 50), (50, 60), (60, 70), (70, 80), (80, 90)]\n assert candidate(nums1 = [[100, 100], [101, 101], [102, 102], [103, 103], [104, 104]],nums2 = [[99, 99], [100, 1], [101, 1], [102, 1], [103, 1], [104, 1], [105, 99]]) == [(99, 99), (100, 101), (101, 102), (102, 103), (103, 104), (104, 105), (105, 99)]\n assert candidate(nums1 = [[1, 1], [3, 3], [5, 5], [7, 7]],nums2 = [[2, 2], [4, 4], [6, 6], [8, 8]]) == [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8)]\n assert candidate(nums1 = [[10, 100], [20, 200], [30, 300]],nums2 = [[5, 50], [15, 150], [25, 250], [35, 350]]) == [(5, 50), (10, 100), (15, 150), (20, 200), (25, 250), (30, 300), (35, 350)]\n assert candidate(nums1 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70]],nums2 = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700]]) == [(1, 110), (2, 220), (3, 330), (4, 440), (5, 550), (6, 660), (7, 770)]\n assert candidate(nums1 = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],nums2 = [[2, 2], [4, 4], [6, 6], [8, 8], [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(nums1 = [[1, 100], [2, 200], [3, 300]],nums2 = [[1, 900], [2, 800], [3, 700], [4, 600], [5, 500]]) == [(1, 1000), (2, 1000), (3, 1000), (4, 600), (5, 500)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3], [4, 4]],nums2 = [[1, 9], [2, 8], [3, 7], [5, 6], [6, 5]]) == [(1, 10), (2, 10), (3, 10), (4, 4), (5, 6), (6, 5)]\n assert candidate(nums1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],nums2 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == [(10, 20), (20, 40), (30, 60), (40, 80), (50, 100)]\n assert candidate(nums1 = [[1, 100], [5, 200], [10, 300]],nums2 = [[2, 150], [5, 250], [8, 350]]) == [(1, 100), (2, 150), (5, 450), (8, 350), (10, 300)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],nums2 = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [(1, 6), (2, 6), (3, 6), (4, 6), (5, 6)]\n assert candidate(nums1 = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]],nums2 = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1]]) == [(1, 2), (2, 2), (3, 2), (4, 2), (5, 2), (6, 1), (7, 1)]\n assert candidate(nums1 = [[1, 200], [2, 199], [3, 198], [4, 197], [5, 196]],nums2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 201), (2, 201), (3, 201), (4, 201), (5, 201)]\n assert candidate(nums1 = [[1, 500], [100, 150], [200, 250]],nums2 = [[50, 200], [150, 300], [250, 350], [300, 400]]) == [(1, 500), (50, 200), (100, 150), (150, 300), (200, 250), (250, 350), (300, 400)]\n assert candidate(nums1 = [[100, 1], [101, 1], [102, 1], [103, 1], [104, 1]],nums2 = [[105, 1], [106, 1], [107, 1], [108, 1], [109, 1]]) == [(100, 1), (101, 1), (102, 1), (103, 1), (104, 1), (105, 1), (106, 1), (107, 1), (108, 1), (109, 1)]\n assert candidate(nums1 = [[1, 10], [3, 20], [5, 30], [7, 40]],nums2 = [[2, 15], [4, 25], [6, 35], [8, 45]]) == [(1, 10), (2, 15), (3, 20), (4, 25), (5, 30), (6, 35), (7, 40), (8, 45)]\n assert candidate(nums1 = [[1, 10], [3, 20], [5, 30], [7, 40], [9, 50]],nums2 = [[2, 10], [4, 20], [6, 30], [8, 40], [10, 50]]) == [(1, 10), (2, 10), (3, 20), (4, 20), (5, 30), (6, 30), (7, 40), (8, 40), (9, 50), (10, 50)]\n assert candidate(nums1 = [[1, 10], [3, 15], [6, 20]],nums2 = [[2, 5], [3, 10], [7, 30]]) == [(1, 10), (2, 5), (3, 25), (6, 20), (7, 30)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],nums2 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]]) == [(1, 11), (2, 22), (3, 33), (4, 44), (5, 55)]\n assert candidate(nums1 = [[1, 10], [2, 20], [3, 30], [4, 40]],nums2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [(1, 11), (2, 22), (3, 33), (4, 44), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9)]\n assert candidate(nums1 = [[50, 100], [150, 200], [250, 300]],nums2 = [[100, 250], [200, 350], [300, 400]]) == [(50, 100), (100, 250), (150, 200), (200, 350), (250, 300), (300, 400)]\n assert candidate(nums1 = [[1, 999], [2, 998], [3, 997]],nums2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 1000), (2, 1000), (3, 1000), (4, 4), (5, 5)]\n assert candidate(nums1 = [[1, 50], [2, 30], [4, 20]],nums2 = [[1, 20], [2, 50], [3, 40], [5, 60]]) == [(1, 70), (2, 80), (3, 40), (4, 20), (5, 60)]\n assert candidate(nums1 = [[1, 999], [2, 998], [3, 997]],nums2 = [[4, 996], [5, 995], [6, 994]]) == [(1, 999), (2, 998), (3, 997), (4, 996), (5, 995), (6, 994)]\n assert candidate(nums1 = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]],nums2 = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == [(1, 3), (2, 3), (3, 3), (4, 3), (5, 3)]\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, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [(1, 11), (2, 11), (3, 11), (4, 11), (5, 11), (6, 11), (7, 11), (8, 11), (9, 11), (10, 11)]\n assert candidate(nums1 = [[1, 100], [2, 200], [3, 300]],nums2 = [[2, 250], [3, 350], [4, 400]]) == [(1, 100), (2, 450), (3, 650), (4, 400)]\n assert candidate(nums1 = [[1, 200], [3, 400], [5, 600], [7, 800]],nums2 = [[2, 100], [4, 300], [6, 500], [8, 700]]) == [(1, 200), (2, 100), (3, 400), (4, 300), (5, 600), (6, 500), (7, 800), (8, 700)]\n assert candidate(nums1 = [[1, 100], [2, 200], [3, 300]],nums2 = [[1, 100], [2, 200], [3, 300]]) == [(1, 200), (2, 400), (3, 600)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],nums2 = [[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(nums1 = [[5, 50], [10, 100], [15, 150], [20, 200], [25, 250]],nums2 = [[3, 30], [6, 60], [9, 90], [12, 120], [18, 180]]) == [(3, 30), (5, 50), (6, 60), (9, 90), (10, 100), (12, 120), (15, 150), (18, 180), (20, 200), (25, 250)]\n assert candidate(nums1 = [[1, 100], [200, 200]],nums2 = [[50, 50], [150, 150]]) == [(1, 100), (50, 50), (150, 150), (200, 200)]\n assert candidate(nums1 = [[1, 50], [4, 75], [7, 100], [10, 125]],nums2 = [[2, 60], [3, 80], [5, 90], [6, 105], [8, 130], [9, 145]]) == [(1, 50), (2, 60), (3, 80), (4, 75), (5, 90), (6, 105), (7, 100), (8, 130), (9, 145), (10, 125)]\n assert candidate(nums1 = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],nums2 = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]]) == [(1, 200), (2, 400), (3, 600), (4, 800), (5, 1000), (6, 1200), (7, 1400), (8, 1600), (9, 1800), (10, 2000)]\n assert candidate(nums1 = [[500, 500]],nums2 = [[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), (500, 500)]\n assert candidate(nums1 = [[999, 1000]],nums2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (999, 1000)]\n assert candidate(nums1 = [[100, 100], [200, 200], [300, 300], [400, 400]],nums2 = [[150, 150], [250, 250], [350, 350], [450, 450]]) == [(100, 100), (150, 150), (200, 200), (250, 250), (300, 300), (350, 350), (400, 400), (450, 450)]\n assert candidate(nums1 = [[1, 999]],nums2 = [[1, 1]]) == [(1, 1000)]\n assert candidate(nums1 = [[10, 10], [20, 20], [30, 30]],nums2 = [[5, 5], [15, 15], [25, 25], [35, 35]]) == [(5, 5), (10, 10), (15, 15), (20, 20), (25, 25), (30, 30), (35, 35)]\n assert candidate(nums1 = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5]],nums2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 10), (2, 10), (3, 10), (4, 10), (5, 10)]\n assert candidate(nums1 = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]],nums2 = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5]]) == [(1, 10), (2, 9), (3, 8), (4, 7), (5, 6)]\n assert candidate(nums1 = [[100, 1], [200, 2], [300, 3]],nums2 = [[150, 4], [250, 5], [350, 6]]) == [(100, 1), (150, 4), (200, 2), (250, 5), (300, 3), (350, 6)]\n assert candidate(nums1 = [[1, 500], [100, 500], [1000, 500]],nums2 = [[50, 500], [250, 500], [500, 500], [750, 500]]) == [(1, 500), (50, 500), (100, 500), (250, 500), (500, 500), (750, 500), (1000, 500)]\n assert candidate(nums1 = [[1, 1]],nums2 = [[1, 999], [2, 998], [3, 997], [4, 996], [5, 995]]) == [(1, 1000), (2, 998), (3, 997), (4, 996), (5, 995)]\n assert candidate(nums1 = [[1, 200], [100, 300], [200, 400]],nums2 = [[1, 100], [150, 200], [200, 100]]) == [(1, 300), (100, 300), (150, 200), (200, 500)]\n assert candidate(nums1 = [[100, 200], [102, 202], [104, 204], [106, 206], [108, 208]],nums2 = [[101, 201], [103, 203], [105, 205], [107, 207], [109, 209]]) == [(100, 200), (101, 201), (102, 202), (103, 203), (104, 204), (105, 205), (106, 206), (107, 207), (108, 208), (109, 209)]\n assert candidate(nums1 = [[1, 1], [1000, 1000]],nums2 = [[500, 500], [1000, 500]]) == [(1, 1), (500, 500), (1000, 1500)]\n assert candidate(nums1 = [[5, 1], [10, 10], [15, 15], [20, 20]],nums2 = [[2, 2], [4, 4], [6, 6], [8, 8], [12, 12], [14, 14], [16, 16], [18, 18], [22, 22]]) == [(2, 2), (4, 4), (5, 1), (6, 6), (8, 8), (10, 10), (12, 12), (14, 14), (15, 15), (16, 16), (18, 18), (20, 20), (22, 22)]\n assert candidate(nums1 = [[1, 1000], [1000, 1]],nums2 = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [(1, 1000), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (1000, 1)]\n assert candidate(nums1 = [[1, 1000], [2, 1000], [3, 1000]],nums2 = [[4, 1000], [5, 1000], [6, 1000], [7, 1000], [8, 1000]]) == [(1, 1000), (2, 1000), (3, 1000), (4, 1000), (5, 1000), (6, 1000), (7, 1000), (8, 1000)]\n assert candidate(nums1 = [[1, 100], [3, 150], [5, 200], [7, 250]],nums2 = [[2, 120], [4, 180], [6, 240], [8, 300]]) == [(1, 100), (2, 120), (3, 150), (4, 180), (5, 200), (6, 240), (7, 250), (8, 300)]\n assert candidate(nums1 = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],nums2 = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50]]) == [(100, 11), (200, 22), (300, 33), (400, 44), (500, 55)]\n assert candidate(nums1 = [[10, 10], [20, 20], [30, 30]],nums2 = [[15, 15], [25, 25], [35, 35]]) == [(10, 10), (15, 15), (20, 20), (25, 25), (30, 30), (35, 35)]\n assert candidate(nums1 = [[1, 1]],nums2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 2), (2, 2), (3, 3), (4, 4), (5, 5)]\n assert candidate(nums1 = [[1, 1], [1000, 1000]],nums2 = [[500, 500], [1000, 1000]]) == [(1, 1), (500, 500), (1000, 2000)]\n assert candidate(nums1 = [[10, 100], [20, 200], [30, 300]],nums2 = [[10, 10], [20, 20], [40, 40]]) == [(10, 110), (20, 220), (30, 300), (40, 40)]\n assert candidate(nums1 = [[1, 900], [2, 800], [3, 700], [4, 600], [5, 500]],nums2 = [[6, 400], [7, 300], [8, 200], [9, 100]]) == [(1, 900), (2, 800), (3, 700), (4, 600), (5, 500), (6, 400), (7, 300), (8, 200), (9, 100)]\n assert candidate(nums1 = [[100, 100], [200, 200], [300, 300]],nums2 = [[101, 101], [102, 102], [103, 103], [104, 104], [105, 105]]) == [(100, 100), (101, 101), (102, 102), (103, 103), (104, 104), (105, 105), (200, 200), (300, 300)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],nums2 = [[3, 10], [4, 20], [5, 30], [6, 40], [7, 50]]) == [(1, 1), (2, 2), (3, 13), (4, 24), (5, 35), (6, 40), (7, 50)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],nums2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 2), (2, 4), (3, 6), (4, 8), (5, 10)]\n assert candidate(nums1 = [[1, 2], [3, 4], [5, 6]],nums2 = [[2, 3], [4, 5], [6, 7]]) == [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7)]\n assert candidate(nums1 = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],nums2 = [[1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2]]) == [(1, 10), (2, 10), (3, 10), (4, 10), (5, 10), (6, 10), (7, 10)]\n assert candidate(nums1 = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],nums2 = [[1, 999]]) == [(1, 1000), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1), (7, 1), (8, 1), (9, 1), (10, 1)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],nums2 = [[6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [(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(nums1 = [[10, 50], [20, 60], [30, 70]],nums2 = [[5, 10], [15, 20], [25, 30], [35, 40]]) == [(5, 10), (10, 50), (15, 20), (20, 60), (25, 30), (30, 70), (35, 40)]\n assert candidate(nums1 = [[50, 500], [100, 1000]],nums2 = [[25, 250], [75, 750], [125, 1250]]) == [(25, 250), (50, 500), (75, 750), (100, 1000), (125, 1250)]\n assert candidate(nums1 = [[1, 100], [3, 200], [5, 300], [7, 400]],nums2 = [[2, 150], [4, 250], [6, 350], [8, 450]]) == [(1, 100), (2, 150), (3, 200), (4, 250), (5, 300), (6, 350), (7, 400), (8, 450)]\n assert candidate(nums1 = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996]],nums2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 1001), (2, 1001), (3, 1001), (4, 1001), (5, 1001)]\n assert candidate(nums1 = [[1, 5], [100, 5], [200, 5]],nums2 = [[50, 5], [150, 5], [250, 5], [300, 5], [350, 5]]) == [(1, 5), (50, 5), (100, 5), (150, 5), (200, 5), (250, 5), (300, 5), (350, 5)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],nums2 = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [(1, 1), (2, 2), (3, 3), (4, 4), (5, 10), (6, 6), (7, 7), (8, 8), (9, 9)]\n assert candidate(nums1 = [[1, 10], [4, 20], [6, 30]],nums2 = [[2, 15], [4, 25], [5, 35]]) == [(1, 10), (2, 15), (4, 45), (5, 35), (6, 30)]\n assert candidate(nums1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],nums2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [(1, 2), (2, 4), (3, 6), (4, 8), (5, 10), (6, 12), (7, 14), (8, 16), (9, 18)]\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().mergeArrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] mergeArrays(int[][] nums1, int[][] nums2) {", "container": "Solution", "callable": "mergeArrays", "parameters": [{"name": "nums1", "type": "int[][]"}, {"name": "nums2", "type": "int[][]"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2571, "task_id": "minimum-operations-to-reduce-an-integer-to-0", "difficulty": "Medium", "problem_description": "You are given a positive integer n, you can do the following operation any number of times:\n\nAdd or subtract a power of 2 from n.\n\nReturn the minimum number of operations to make n equal to 0.\nA number x is power of 2 if x == 2i where i >= 0.\n \nExample 1:\n\nInput: n = 39\nOutput: 3\nExplanation: We can do the following operations:\n- Add 20 = 1 to n, so now n = 40.\n- Subtract 23 = 8 from n, so now n = 32.\n- Subtract 25 = 32 from n, so now n = 0.\nIt can be shown that 3 is the minimum number of operations we need to make n equal to 0.\n\nExample 2:\n\nInput: n = 54\nOutput: 3\nExplanation: We can do the following operations:\n- Add 21 = 2 to n, so now n = 56.\n- Add 23 = 8 to n, so now n = 64.\n- Subtract 26 = 64 from n, so now n = 0.\nSo the minimum number of operations is 3.\n\n \nConstraints:\n\n1 <= n <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 63) == 2\n assert candidate(n = 100) == 3\n assert candidate(n = 50000) == 6\n assert candidate(n = 4) == 1\n assert candidate(n = 64) == 1\n assert candidate(n = 16) == 1\n assert candidate(n = 10000) == 4\n assert candidate(n = 2) == 1\n assert candidate(n = 1024) == 1\n assert candidate(n = 54) == 3\n assert candidate(n = 100000) == 6\n assert candidate(n = 1048576) == 1\n assert candidate(n = 65536) == 1\n assert candidate(n = 32) == 1\n assert candidate(n = 1023) == 2\n assert candidate(n = 39) == 3\n assert candidate(n = 65535) == 2\n assert candidate(n = 15) == 2\n assert candidate(n = 32768) == 1\n assert candidate(n = 1048575) == 2\n assert candidate(n = 31) == 2\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 2\n assert candidate(n = 65534) == 2\n assert candidate(n = 33333) == 6\n assert candidate(n = 99999) == 7\n assert candidate(n = 8765) == 5\n assert candidate(n = 131071) == 2\n assert candidate(n = 12345) == 5\n assert candidate(n = 7456) == 4\n assert candidate(n = 77777) == 6\n assert candidate(n = 67890) == 6\n assert candidate(n = 65537) == 2\n assert candidate(n = 111111) == 6\n assert candidate(n = 32767) == 2\n assert candidate(n = 65533) == 3\n assert candidate(n = 86420) == 7\n assert candidate(n = 19683) == 7\n assert candidate(n = 16383) == 2\n assert candidate(n = 24680) == 5\n assert candidate(n = 16384) == 1\n assert candidate(n = 123) == 3\n assert candidate(n = 10001) == 5\n assert candidate(n = 81920) == 2\n assert candidate(n = 1365) == 6\n assert candidate(n = 32769) == 2\n assert candidate(n = 4095) == 2\n assert candidate(n = 8192) == 1\n assert candidate(n = 999) == 4\n assert candidate(n = 8191) == 2\n assert candidate(n = 7890) == 5\n assert candidate(n = 11001) == 6\n assert candidate(n = 39321) == 8\n assert candidate(n = 13579) == 7\n assert candidate(n = 98765) == 7\n assert candidate(n = 43210) == 7\n assert candidate(n = 54321) == 7\n assert candidate(n = 531441) == 5\n assert candidate(n = 1536) == 2\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minOperations(int n) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2572, "task_id": "count-the-number-of-square-free-subsets", "difficulty": "Medium", "problem_description": "You are given a positive integer 0-indexed array nums.\nA subset of the array nums is square-free if the product of its elements is a square-free integer.\nA square-free integer is an integer that is divisible by no square number other than 1.\nReturn the number of square-free non-empty subsets of the array nums. Since the answer may be too large, return it modulo 109 + 7.\nA non-empty subset of nums is an array that can be obtained by deleting some (possibly none but not all) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.\n \nExample 1:\n\nInput: nums = [3,4,4,5]\nOutput: 3\nExplanation: There are 3 square-free subsets in this example:\n- The subset consisting of the 0th element [3]. The product of its elements is 3, which is a square-free integer.\n- The subset consisting of the 3rd element [5]. The product of its elements is 5, which is a square-free integer.\n- The subset consisting of 0th and 3rd elements [3,5]. The product of its elements is 15, which is a square-free integer.\nIt can be proven that there are no more than 3 square-free subsets in the given array.\nExample 2:\n\nInput: nums = [1]\nOutput: 1\nExplanation: There is 1 square-free subset in this example:\n- The subset consisting of the 0th element [1]. The product of its elements is 1, which is a square-free integer.\nIt can be proven that there is no more than 1 square-free subset in the given array.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 30\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\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]) == 147483633.0\n assert candidate(nums = [2, 3, 5, 7, 11]) == 31.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 47.0\n assert candidate(nums = [1, 2, 3, 6, 7, 14, 21, 42]) == 27.0\n assert candidate(nums = [1]) == 1.0\n assert candidate(nums = [10, 14, 15, 21, 22, 26, 33, 34, 35, 38, 39, 46, 51, 55, 57, 58, 62, 65, 66, 69, 74, 77, 78, 82, 85, 86, 87, 91, 93, 94, 95, 102, 105, 106, 111, 114, 115, 118, 119, 122, 123, 126, 129, 130, 133, 134, 138, 139, 141, 142, 143, 145, 146, 147, 154, 155, 158, 159, 161, 165, 166, 171, 172, 174, 177, 178, 182, 183, 185, 186, 187, 189, 190, 194, 195, 201, 202, 203, 205, 206, 207, 209, 210, 213, 214, 215, 217, 218, 219, 221, 222, 223, 225, 226, 229, 231, 235, 237, 238, 242, 246, 247, 249, 253, 254, 255, 258, 259, 261, 262, 265, 266, 267, 273, 274, 278, 282, 285, 286, 287, 291, 295, 298, 299, 301, 302, 303, 305, 306, 309, 310, 314, 315, 318, 319, 321, 322, 323, 326, 327, 329, 334, 335, 338, 339, 341, 345, 346, 351, 354, 355, 357, 358, 359, 362, 365, 366, 371, 374, 377, 378, 381, 382, 385, 386, 387, 391, 393, 394, 395, 398, 399, 402, 403, 405, 406, 407, 411, 413, 415, 417, 418, 422, 423, 426, 427, 429, 434, 435, 437, 438, 442, 445, 446, 447, 451, 453, 454, 455, 458, 459, 462, 465, 466, 469, 471, 473, 474, 478, 479, 481, 483, 485, 489, 493, 494, 495, 497, 501]) == 12.0\n assert candidate(nums = [30, 30, 30, 30, 30]) == 5.0\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30]) == 6655.0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 0.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 10.0\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30]) == 3327.0\n assert candidate(nums = [1, 2, 3, 6, 9, 18, 27, 54]) == 9.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 20.0\n assert candidate(nums = [29, 28, 21, 18, 16, 13, 10, 3, 25, 7]) == 39.0\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28]) == 0.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1023.0\n assert candidate(nums = [4, 9, 16, 25]) == 0.0\n assert candidate(nums = [9, 10, 14, 15, 21, 22, 26, 30]) == 13.0\n assert candidate(nums = [3, 4, 4, 5]) == 3.0\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43]) == 63.0\n assert candidate(nums = [4, 8, 12, 16]) == 0.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1023.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 33, 34]) == 14.0\n assert candidate(nums = [1, 2, 3, 6, 7, 10, 14, 15, 21, 22, 26, 30]) == 79.0\n assert candidate(nums = [9, 15, 21, 25, 27, 30]) == 3.0\n assert candidate(nums = [10, 15, 21, 22, 26, 27]) == 10.0\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 59048.0\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.0\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 20.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 6, 10, 14, 15, 21, 22, 26, 30, 6, 10, 14, 15, 21, 22, 26, 30]) == 78.0\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 33, 34, 35, 37, 38, 39, 41, 42, 43, 46, 47, 51, 53, 55, 57, 58, 59, 61, 62, 65, 66, 67, 69, 70, 71, 73, 74, 77, 78, 79, 82, 83, 85, 86, 87, 89, 91, 93, 94, 95, 97, 98, 99, 100]) == 3327.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 33, 34, 35, 38, 39, 42, 46, 51, 55, 57, 58, 62]) == 14.0\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 6, 7, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 6, 7, 10, 14, 15, 21, 22, 26, 30]) == 1053.0\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 14, 15, 21, 22, 26, 30, 33, 34, 35, 38, 39, 42, 46, 55]) == 63.0\n assert candidate(nums = [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]) == 0.0\n assert candidate(nums = [1, 2, 3, 5, 6, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 46, 47, 51, 53, 55, 57, 58, 59, 61, 62, 65, 67, 69, 71, 73, 74, 77, 79, 82, 83, 85, 86, 87, 89, 91, 93, 94, 95, 1, 2, 3, 5, 6, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 46, 47, 51, 53, 55, 57, 58, 59, 61, 62, 65, 67, 69, 71, 73, 74, 77, 79, 82, 83, 85, 86, 87, 89, 91, 93, 94, 95]) == 331451.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 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, 30, 30, 30, 30]) == 6015.0\n assert candidate(nums = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 32, 36, 40, 44, 45, 48, 49, 50, 52, 54, 56, 60, 63, 64, 68, 72, 75, 76, 80, 81, 84, 88, 90, 96, 98, 100]) == 0.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 78.0\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]) == 0.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 118097.0\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 46, 47, 51, 53, 55, 57, 58, 59, 61, 62, 65, 67, 69, 71, 73, 74, 77, 79, 82, 83, 85, 86, 87, 89, 91, 93, 94, 95]) == 3327.0\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1048575.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]) == 949480668.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]) == 73741816.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 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]) == 1048575.0\n assert candidate(nums = [10, 14, 15, 21, 22, 26, 30, 10, 14, 15, 21, 22, 26, 30, 10, 14, 15, 21, 22, 26, 30, 10, 14, 15, 21, 22, 26, 30, 10, 14, 15, 21, 22, 26, 30, 10, 14, 15, 21, 22, 26, 30, 10, 14, 15, 21, 22, 26, 30, 10, 14, 15, 21, 22, 26, 30]) == 440.0\n assert candidate(nums = [4, 9, 12, 16, 18, 20, 24, 25, 27, 28, 32, 36, 40, 44, 45, 48, 49, 50, 52, 54, 56, 60, 63, 64, 68, 72, 75, 76, 80, 81, 84, 88, 90, 96, 98, 99, 100]) == 0.0\n assert candidate(nums = [2, 3, 5, 6, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 6, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 6, 10, 14, 15, 21, 22, 26, 30]) == 402.0\n assert candidate(nums = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 32, 36, 40, 44, 45, 48, 49, 50, 52, 54]) == 0.0\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30]) == 691091.0\n assert candidate(nums = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 32, 36, 40, 44, 45, 48, 49, 50, 52, 54, 56, 60, 63, 64, 72, 75, 76, 80, 81, 84, 88, 90, 96, 98, 100]) == 0.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]) == 1023.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1048575.0\n assert candidate(nums = [10, 22, 26, 30, 33, 34, 35, 38, 39, 42, 46, 51, 55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95]) == 4.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 9765624.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]) == 7.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 4607.0\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 0.0\n assert candidate(nums = [1, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1023.0\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]) == 25.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 98, 99, 100]) == 14.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]) == 6655.0\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450]) == 1.0\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 10, 14, 15, 21, 22, 26, 30, 33, 34, 35, 38, 39, 42, 46]) == 127.0\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, 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]) == 691091.0\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]) == 2047.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]) == 1023.0\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361]) == 1.0\n assert candidate(nums = [30, 21, 15, 10, 6, 3, 2, 1, 1, 2, 3, 6, 10, 15, 21, 30, 1, 1, 2, 3, 6, 10, 15, 21, 30, 1, 1]) == 4287.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 59048.0\n assert candidate(nums = [31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113]) == 0.0\n assert candidate(nums = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 32, 36, 40, 44, 45, 48, 49, 50]) == 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, 1]) == 371842543.0\n assert candidate(nums = [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, 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, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 80.0\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]) == 1.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 2047.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]) == 1055.0\n assert candidate(nums = [9, 27, 81, 243, 729, 3, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467, 1]) == 3.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, 42, 44, 46, 48, 50]) == 7.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]) == 268198251.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, 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]) == 691091.0\n assert candidate(nums = [15, 21, 22, 26, 30, 33, 34, 35, 38, 39, 42, 46, 51, 55, 57, 58, 62, 65, 66, 69]) == 9.0\n assert candidate(nums = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 32, 36, 40, 44, 45, 48, 49, 50, 54]) == 0.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, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 59048.0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 0.0\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 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]) == 6655.0\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 120.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 6, 10, 14, 15, 21, 22, 26, 30, 6, 10, 14, 15, 21, 22, 26, 30, 6, 10, 14, 15, 21, 22, 26, 30]) == 128.0\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 18, 19, 21, 22, 23, 26, 29, 30, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 18, 19, 21, 22, 23, 26, 29, 30]) == 172772.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]) == 1023.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]) == 1048575.0\n assert candidate(nums = [1, 2, 3, 5, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30]) == 6143.0\n assert candidate(nums = [1, 4, 9, 16, 25, 27, 36, 49, 54, 63, 72, 81, 90, 100, 121, 125]) == 1.0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 20.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 6, 10, 14, 15, 21, 22, 26, 30, 6, 10, 14, 15, 21, 22, 26, 30, 6, 10, 14, 15, 21, 22, 26, 30, 6, 10, 14, 15, 21, 22, 26, 30]) == 190.0\n assert candidate(nums = [2, 3, 2, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 31, 31, 37, 37, 41, 41, 43, 43, 47, 47, 53, 53, 59, 59, 61, 61, 67, 67, 71, 71, 73, 73, 79, 79, 83, 83, 89, 89, 97, 97]) == 59048.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, 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]) == 118097.0\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30]) == 3327.0\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30]) == 6655.0\n assert candidate(nums = [2, 3, 5, 6, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 6, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 6, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 6, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 6, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 6, 10, 14, 15, 21, 22, 26, 30]) == 2298.0\n assert candidate(nums = [1, 1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30]) == 13311.0\n assert candidate(nums = [1, 4, 8, 9, 16, 25, 27, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324]) == 1.0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().squareFreeSubsets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int squareFreeSubsets(int[] nums) {", "container": "Solution", "callable": "squareFreeSubsets", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2573, "task_id": "find-the-string-with-lcp", "difficulty": "Hard", "problem_description": "We define the lcp matrix of any 0-indexed string word of n lowercase English letters as an n x n grid such that:\n\nlcp[i][j] is equal to the length of the longest common prefix between the substrings word[i,n-1] and word[j,n-1].\n\nGiven an n x n matrix lcp, return the alphabetically smallest string word that corresponds to lcp. If there is no such string, return an empty string.\nA string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b. For example, \"aabd\" is lexicographically smaller than \"aaca\" because the first position they differ is at the third letter, and 'b' comes before 'c'.\n \nExample 1:\n\nInput: lcp = [[4,0,2,0],[0,3,0,1],[2,0,2,0],[0,1,0,1]]\nOutput: \"abab\"\nExplanation: lcp corresponds to any 4 letter string with two alternating letters. The lexicographically smallest of them is \"abab\".\n\nExample 2:\n\nInput: lcp = [[4,3,2,1],[3,3,2,1],[2,2,2,1],[1,1,1,1]]\nOutput: \"aaaa\"\nExplanation: lcp corresponds to any 4 letter string with a single distinct letter. The lexicographically smallest of them is \"aaaa\". \n\nExample 3:\n\nInput: lcp = [[4,3,2,1],[3,3,2,1],[2,2,2,1],[1,1,1,3]]\nOutput: \"\"\nExplanation: lcp[3][3] cannot be equal to 3 since word[3,...,3] consists of only a single letter; Thus, no answer exists.\n\n \nConstraints:\n\n1 <= n == lcp.length == lcp[i].length <= 1000\n0 <= lcp[i][j] <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(lcp = [[4, 3, 2, 1], [3, 3, 2, 1], [2, 2, 2, 1], [1, 1, 1, 3]]) == \"\"\n assert candidate(lcp = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == \"\"\n assert candidate(lcp = [[4, 0, 2, 0], [0, 3, 0, 1], [2, 0, 2, 0], [0, 1, 0, 1]]) == \"abab\"\n assert candidate(lcp = [[4, 3, 2, 1], [3, 3, 2, 1], [2, 2, 2, 1], [1, 1, 1, 1]]) == \"aaaa\"\n assert candidate(lcp = [[2, 1, 0], [1, 2, 0], [0, 0, 1]]) == \"\"\n assert candidate(lcp = [[2, 1], [1, 2]]) == \"\"\n assert candidate(lcp = [[3, 2, 1], [2, 2, 1], [1, 1, 1]]) == \"aaa\"\n assert candidate(lcp = [[3, 2, 2, 1], [2, 3, 2, 1], [2, 2, 3, 1], [1, 1, 1, 1]]) == \"\"\n assert candidate(lcp = [[3, 2, 1, 0], [2, 2, 1, 0], [1, 1, 1, 0], [0, 0, 0, 1]]) == \"\"\n assert candidate(lcp = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 10, 9, 8, 7, 6, 5, 4, 3, 2], [8, 9, 10, 9, 8, 7, 6, 5, 4, 3], [7, 8, 9, 10, 9, 8, 7, 6, 5, 4], [6, 7, 8, 9, 10, 9, 8, 7, 6, 5], [5, 6, 7, 8, 9, 10, 9, 8, 7, 6], [4, 5, 6, 7, 8, 9, 10, 9, 8, 7], [3, 4, 5, 6, 7, 8, 9, 10, 9, 8], [2, 3, 4, 5, 6, 7, 8, 9, 10, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == \"\"\n assert candidate(lcp = [[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, 1, 1], [0, 0, 0, 0, 1, 1]]) == \"\"\n assert candidate(lcp = [[5, 1, 1, 1, 1], [1, 4, 2, 2, 2], [1, 2, 3, 1, 1], [1, 2, 1, 3, 1], [1, 2, 1, 1, 1]]) == \"\"\n assert candidate(lcp = [[5, 4, 3, 2, 1], [4, 5, 4, 3, 2], [3, 4, 5, 4, 3], [2, 3, 4, 5, 4], [1, 2, 3, 4, 5]]) == \"\"\n assert candidate(lcp = [[6, 5, 4, 3, 2, 1], [5, 5, 4, 3, 2, 1], [4, 4, 4, 3, 2, 1], [3, 3, 3, 6, 5, 4], [2, 2, 2, 5, 5, 4], [1, 1, 1, 4, 4, 4]]) == \"\"\n assert candidate(lcp = [[5, 0, 3, 0, 0], [0, 5, 0, 0, 0], [3, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 2]]) == \"\"\n assert candidate(lcp = [[2, 2, 0, 0], [2, 2, 0, 0], [0, 0, 3, 1], [0, 0, 1, 1]]) == \"\"\n assert candidate(lcp = [[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]]) == \"\"\n assert candidate(lcp = [[4, 2, 2, 2, 2], [2, 3, 1, 1, 1], [2, 1, 3, 1, 1], [2, 1, 1, 2, 1], [2, 1, 1, 1, 2]]) == \"\"\n assert candidate(lcp = [[3, 3, 2, 1], [3, 3, 2, 1], [2, 2, 2, 1], [1, 1, 1, 1]]) == \"\"\n assert candidate(lcp = [[4, 3, 2, 1], [3, 3, 2, 1], [2, 2, 3, 2], [1, 1, 2, 3]]) == \"\"\n assert candidate(lcp = [[8, 7, 6, 5, 4, 3, 2, 1], [7, 7, 6, 5, 4, 3, 2, 1], [6, 6, 6, 5, 4, 3, 2, 1], [5, 5, 5, 5, 4, 3, 2, 1], [4, 4, 4, 4, 4, 3, 2, 1], [3, 3, 3, 3, 3, 3, 2, 1], [2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == \"aaaaaaaa\"\n assert candidate(lcp = [[10, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 10, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 10, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 10, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 10, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 10, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]) == \"\"\n assert candidate(lcp = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 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(lcp = [[3, 1, 1, 0, 0], [1, 3, 2, 0, 0], [1, 2, 3, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]]) == \"\"\n assert candidate(lcp = [[1, 1, 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, 1, 1, 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, 1, 1, 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, 1, 1, 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, 1, 1, 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, 1, 1, 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, 1, 1, 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, 1]]) == \"\"\n assert candidate(lcp = [[5, 0, 0, 0, 0, 0], [0, 5, 0, 0, 0, 0], [0, 0, 5, 0, 0, 0], [0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 5]]) == \"\"\n assert candidate(lcp = [[3, 2, 1, 0, 0], [2, 2, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]]) == \"\"\n assert candidate(lcp = [[5, 0, 0, 0, 0, 0], [0, 5, 0, 0, 0, 0], [0, 0, 5, 2, 2, 0], [0, 0, 2, 5, 2, 1], [0, 0, 2, 2, 5, 1], [0, 0, 0, 1, 1, 5]]) == \"\"\n assert candidate(lcp = [[2, 2, 2, 0, 0], [2, 2, 2, 0, 0], [2, 2, 2, 0, 0], [0, 0, 0, 3, 2], [0, 0, 0, 2, 3]]) == \"\"\n assert candidate(lcp = [[2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2]]) == \"\"\n assert candidate(lcp = [[5, 4, 3, 2, 1], [4, 4, 2, 2, 1], [3, 2, 3, 2, 1], [2, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == \"\"\n assert candidate(lcp = [[0, 1, 0, 0, 0], [1, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 1], [0, 0, 0, 1, 0]]) == \"\"\n assert candidate(lcp = [[2, 1, 0, 0], [1, 2, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == \"\"\n assert candidate(lcp = [[7, 5, 3, 1], [5, 5, 3, 1], [3, 3, 3, 1], [1, 1, 1, 1]]) == \"\"\n assert candidate(lcp = [[4, 3, 2, 1, 0, 0], [3, 4, 3, 2, 0, 0], [2, 3, 4, 3, 0, 0], [1, 2, 3, 4, 0, 0], [0, 0, 0, 0, 4, 2], [0, 0, 0, 0, 2, 4]]) == \"\"\n assert candidate(lcp = [[6, 5, 4, 3, 2], [5, 6, 5, 4, 3], [4, 5, 6, 5, 4], [3, 4, 5, 6, 5], [2, 3, 4, 5, 6]]) == \"\"\n assert candidate(lcp = [[3, 2, 2, 1], [2, 2, 2, 1], [2, 2, 2, 1], [1, 1, 1, 1]]) == \"\"\n assert candidate(lcp = [[5, 2, 2, 2, 2], [2, 3, 2, 1, 1], [2, 2, 3, 2, 2], [2, 1, 2, 3, 2], [2, 1, 2, 2, 3]]) == \"\"\n assert candidate(lcp = [[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(lcp = [[6, 2, 2, 0, 0], [2, 6, 2, 0, 0], [2, 2, 6, 0, 0], [0, 0, 0, 3, 2], [0, 0, 0, 2, 3]]) == \"\"\n assert candidate(lcp = [[7, 0, 0, 0, 0, 0, 0], [0, 3, 2, 1, 0, 0, 0], [0, 2, 3, 2, 0, 0, 0], [0, 1, 2, 3, 0, 0, 0], [0, 0, 0, 0, 5, 4, 3], [0, 0, 0, 0, 4, 5, 4], [0, 0, 0, 0, 3, 4, 5]]) == \"\"\n assert candidate(lcp = [[5, 4, 3, 2, 1], [4, 4, 3, 2, 1], [3, 3, 3, 2, 1], [2, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == \"aaaaa\"\n assert candidate(lcp = [[5, 3, 3, 3, 3], [3, 4, 2, 2, 2], [3, 2, 3, 2, 2], [3, 2, 2, 3, 2], [3, 2, 2, 2, 3]]) == \"\"\n assert candidate(lcp = [[6, 5, 4, 3, 2, 1], [5, 5, 4, 3, 2, 1], [4, 4, 4, 3, 2, 1], [3, 3, 3, 3, 2, 1], [2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == \"aaaaaa\"\n assert candidate(lcp = [[5, 4, 3, 2, 1, 0], [4, 4, 3, 2, 1, 0], [3, 3, 3, 2, 1, 0], [2, 2, 2, 2, 1, 0], [1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1]]) == \"\"\n assert candidate(lcp = [[3, 2, 1, 0, 0], [2, 3, 2, 1, 0], [1, 2, 3, 2, 1], [0, 1, 2, 3, 2], [0, 0, 1, 2, 3]]) == \"\"\n assert candidate(lcp = [[3, 1, 0, 0, 0], [1, 3, 0, 0, 0], [0, 0, 2, 1, 1], [0, 0, 1, 2, 1], [0, 0, 1, 1, 2]]) == \"\"\n assert candidate(lcp = [[6, 0, 0, 0, 0, 0], [0, 5, 4, 3, 2, 1], [0, 4, 4, 3, 2, 1], [0, 3, 3, 3, 2, 1], [0, 2, 2, 2, 2, 1], [0, 1, 1, 1, 1, 1]]) == \"abbbbb\"\n assert candidate(lcp = [[4, 0, 2, 0, 0, 0], [0, 4, 0, 2, 0, 0], [2, 0, 4, 0, 2, 0], [0, 2, 0, 4, 0, 2], [0, 0, 2, 0, 4, 0], [0, 0, 0, 2, 0, 4]]) == \"\"\n assert candidate(lcp = [[6, 3, 2, 1, 0], [3, 4, 3, 2, 1], [2, 3, 4, 3, 2], [1, 2, 3, 4, 3], [0, 1, 2, 3, 4]]) == \"\"\n assert candidate(lcp = [[3, 2, 2, 0, 0], [2, 3, 2, 0, 0], [2, 2, 3, 1, 0], [0, 0, 1, 3, 1], [0, 0, 0, 1, 3]]) == \"\"\n assert candidate(lcp = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 8, 8, 7, 6, 5, 4, 3, 2, 1], [7, 7, 7, 7, 6, 5, 4, 3, 2, 1], [6, 6, 6, 6, 6, 5, 4, 3, 2, 1], [5, 5, 5, 5, 5, 5, 4, 3, 2, 1], [4, 4, 4, 4, 4, 4, 4, 3, 2, 1], [3, 3, 3, 3, 3, 3, 3, 3, 2, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == \"aaaaaaaaaa\"\n assert candidate(lcp = [[4, 2, 0, 0], [2, 4, 0, 0], [0, 0, 3, 0], [0, 0, 0, 3]]) == \"\"\n assert candidate(lcp = [[2, 0, 0, 0, 0], [0, 2, 2, 0, 0], [0, 2, 2, 0, 0], [0, 0, 0, 2, 0], [0, 0, 0, 0, 2]]) == \"\"\n assert candidate(lcp = [[3, 2, 2, 2], [2, 3, 2, 2], [2, 2, 3, 2], [2, 2, 2, 3]]) == \"\"\n assert candidate(lcp = [[5, 3, 2, 1, 0], [3, 5, 3, 2, 1], [2, 3, 5, 3, 2], [1, 2, 3, 5, 3], [0, 1, 2, 3, 5]]) == \"\"\n assert candidate(lcp = [[8, 0, 0, 0, 0, 0, 0, 0], [0, 7, 6, 5, 4, 3, 2, 1], [0, 6, 6, 5, 4, 3, 2, 1], [0, 5, 5, 5, 4, 3, 2, 1], [0, 4, 4, 4, 4, 3, 2, 1], [0, 3, 3, 3, 3, 3, 2, 1], [0, 2, 2, 2, 2, 2, 2, 1], [0, 1, 1, 1, 1, 1, 1, 1]]) == \"abbbbbbb\"\n assert candidate(lcp = [[7, 3, 2, 0, 0, 0, 0], [3, 7, 3, 0, 0, 0, 0], [2, 3, 7, 0, 0, 0, 0], [0, 0, 0, 3, 2, 0, 0], [0, 0, 0, 2, 3, 0, 0], [0, 0, 0, 0, 0, 3, 2], [0, 0, 0, 0, 0, 2, 3]]) == \"\"\n assert candidate(lcp = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == \"\"\n assert candidate(lcp = [[5, 4, 0, 0, 0], [4, 5, 0, 0, 0], [0, 0, 5, 4, 3], [0, 0, 4, 5, 4], [0, 0, 3, 4, 5]]) == \"\"\n assert candidate(lcp = [[9, 1, 1, 1, 1, 1, 1, 1, 1], [1, 9, 1, 1, 1, 1, 1, 1, 1], [1, 1, 9, 1, 1, 1, 1, 1, 1], [1, 1, 1, 9, 1, 1, 1, 1, 1], [1, 1, 1, 1, 9, 1, 1, 1, 1], [1, 1, 1, 1, 1, 9, 1, 1, 1], [1, 1, 1, 1, 1, 1, 9, 1, 1], [1, 1, 1, 1, 1, 1, 1, 9, 1], [1, 1, 1, 1, 1, 1, 1, 1, 9]]) == \"\"\n assert candidate(lcp = [[7, 0, 0, 0, 0, 0, 0], [0, 4, 3, 2, 1, 0, 0], [0, 3, 4, 3, 2, 1, 0], [0, 2, 3, 4, 3, 2, 1], [0, 1, 2, 3, 4, 3, 2], [0, 0, 1, 2, 3, 4, 3], [0, 0, 0, 1, 2, 3, 4]]) == \"\"\n assert candidate(lcp = [[10, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 7, 6, 5, 4, 3, 2, 1, 0, 0], [0, 6, 6, 5, 4, 3, 2, 1, 0, 0], [0, 5, 5, 5, 4, 3, 2, 1, 0, 0], [0, 4, 4, 4, 4, 3, 2, 1, 0, 0], [0, 3, 3, 3, 3, 3, 2, 1, 0, 0], [0, 2, 2, 2, 2, 2, 2, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 6, 5], [0, 0, 0, 0, 0, 0, 0, 0, 5, 6]]) == \"\"\n assert candidate(lcp = [[7, 1, 1, 1, 1, 1, 1], [1, 6, 1, 1, 1, 1, 1], [1, 1, 6, 1, 1, 1, 1], [1, 1, 1, 6, 1, 1, 1], [1, 1, 1, 1, 6, 1, 1], [1, 1, 1, 1, 1, 6, 1], [1, 1, 1, 1, 1, 1, 6]]) == \"\"\n assert candidate(lcp = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 8, 7, 6, 5, 4, 3, 2, 1], [7, 7, 7, 6, 5, 4, 3, 2, 1], [6, 6, 6, 6, 5, 4, 3, 2, 1], [5, 5, 5, 5, 5, 4, 3, 2, 1], [4, 4, 4, 4, 4, 4, 3, 2, 1], [3, 3, 3, 3, 3, 3, 3, 2, 1], [2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == \"aaaaaaaaa\"\n assert candidate(lcp = [[4, 3, 2, 1, 0], [3, 3, 2, 1, 0], [2, 2, 2, 1, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 1]]) == \"\"\n assert candidate(lcp = [[4, 3, 2, 1, 0], [3, 3, 2, 1, 0], [2, 2, 3, 2, 1], [1, 1, 2, 3, 2], [0, 0, 1, 2, 4]]) == \"\"\n assert candidate(lcp = [[4, 1, 0, 0], [1, 4, 1, 0], [0, 1, 4, 1], [0, 0, 1, 4]]) == \"\"\n assert candidate(lcp = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 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(lcp = [[7, 6, 5, 4, 3, 2, 1], [6, 6, 5, 4, 3, 2, 1], [5, 5, 5, 4, 3, 2, 1], [4, 4, 4, 4, 3, 2, 1], [3, 3, 3, 3, 3, 2, 1], [2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == \"aaaaaaa\"\n assert candidate(lcp = [[7, 1, 0, 0, 0, 0, 0], [1, 7, 1, 0, 0, 0, 0], [0, 1, 7, 1, 0, 0, 0], [0, 0, 1, 7, 1, 0, 0], [0, 0, 0, 1, 7, 1, 0], [0, 0, 0, 0, 1, 7, 1], [0, 0, 0, 0, 0, 1, 7]]) == \"\"\n assert candidate(lcp = [[8, 7, 6, 5, 4], [7, 7, 6, 5, 4], [6, 6, 6, 5, 4], [5, 5, 5, 5, 4], [4, 4, 4, 4, 4]]) == \"\"\n assert candidate(lcp = [[5, 0, 2, 0, 0], [0, 3, 0, 2, 0], [2, 0, 3, 0, 1], [0, 2, 0, 2, 0], [0, 0, 1, 0, 1]]) == \"\"\n assert candidate(lcp = [[2, 1, 0, 0], [1, 2, 1, 0], [0, 1, 2, 1], [0, 0, 1, 2]]) == \"\"\n assert candidate(lcp = [[5, 0, 0, 0, 0], [0, 3, 0, 0, 0], [0, 0, 2, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 5]]) == \"\"\n"}, "metadata": {"canonical_parameter_names": ["lcp"], "leetcode_dataset_entry_point": "Solution().findTheString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String findTheString(int[][] lcp) {", "container": "Solution", "callable": "findTheString", "parameters": [{"name": "lcp", "type": "int[][]"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2574, "task_id": "left-and-right-sum-differences", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums of size n.\nDefine two arrays leftSum and rightSum where:\n\nleftSum[i] is the sum of elements to the left of the index i in the array nums. If there is no such element, leftSum[i] = 0.\nrightSum[i] is the sum of elements to the right of the index i in the array nums. If there is no such element, rightSum[i] = 0.\n\nReturn an integer array answer of size n where answer[i] = |leftSum[i] - rightSum[i]|.\n \nExample 1:\n\nInput: nums = [10,4,8,3]\nOutput: [15,1,11,22]\nExplanation: The array leftSum is [0,10,14,22] and the array rightSum is [15,11,3,0].\nThe array answer is [|0 - 15|,|10 - 11|,|14 - 3|,|22 - 0|] = [15,1,11,22].\n\nExample 2:\n\nInput: nums = [1]\nOutput: [0]\nExplanation: The array leftSum is [0] and the array rightSum is [0].\nThe array answer is [|0 - 0|] = [0].\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == [10, 1, 6, 11, 14]\n assert candidate(nums = [1]) == [0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [54, 51, 46, 39, 30, 19, 6, 9, 26, 45]\n assert candidate(nums = [10, 20, 30]) == [50, 20, 30]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [9, 7, 5, 3, 1, 1, 3, 5, 7, 9]\n assert candidate(nums = [100000, 100000, 100000]) == [200000, 0, 200000]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [9, 7, 5, 3, 1, 1, 3, 5, 7, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [540, 510, 460, 390, 300, 190, 60, 90, 260, 450]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [4, 2, 0, 2, 4]\n assert candidate(nums = [1, 2]) == [2, 1]\n assert candidate(nums = [100000, 1, 1, 1]) == [3, 99998, 100000, 100002]\n assert candidate(nums = [1000, 1000, 1000, 1000]) == [3000, 1000, 1000, 3000]\n assert candidate(nums = [5, 5, 5, 5]) == [15, 5, 5, 15]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [14, 11, 6, 1, 10]\n assert candidate(nums = [100000, 100000, 100000]) == [200000, 0, 200000]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == [400000, 200000, 0, 200000, 400000]\n assert candidate(nums = [10, 4, 8, 3]) == [15, 1, 11, 22]\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == [400005, 300004, 200003, 100002, 1, 100000, 200001, 300002, 400003, 500004]\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [196, 140, 88, 40, 4, 44, 80, 112, 140, 164, 184, 200, 212, 220, 224]\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 1300000, 1400000, 1500000]) == [11900000, 11600000, 11100000, 10400000, 9500000, 8400000, 7100000, 5600000, 3900000, 2000000, 100000, 2400000, 4900000, 7600000, 10500000]\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [361, 285, 213, 145, 81, 21, 35, 87, 135, 179, 219, 255, 287, 315, 339, 359, 375, 387, 395, 399]\n assert candidate(nums = [99999, 1, 99999, 1, 99999, 1, 99999]) == [300000, 200000, 100000, 0, 100000, 200000, 300000]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1045, 1030, 1005, 970, 925, 870, 805, 730, 645, 550, 445, 330, 205, 70, 75, 230, 395, 570, 755, 950]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == [450000, 260000, 90000, 60000, 190000, 300000, 390000, 460000, 510000, 540000]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == [99994, 50006, 125006, 162506, 181256, 190631, 195318, 197661, 198832, 199417, 199709, 199854, 199926, 199962, 199980, 199989, 199993]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == [11900, 11600, 11100, 10400, 9500, 8400, 7100, 5600, 3900, 2000, 100, 2400, 4900, 7600, 10500]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]) == [607, 604, 599, 591, 578, 557, 523, 468, 379, 235, 2, 375]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == [9000, 8700, 8200, 7500, 6600, 5500, 4200, 2700, 1000, 900, 3000, 5300, 7800]\n assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == [400000, 300000, 200000, 100000, 0, 100000, 200000, 300000, 400000, 500000]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [5400, 5100, 4600, 3900, 3000, 1900, 600, 900, 2600, 4500]\n assert candidate(nums = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500, 600, 600, 700, 700, 800, 800, 900, 900, 1000, 1000]) == [10900, 10700, 10400, 10000, 9500, 8900, 8200, 7400, 6500, 5500, 4400, 3200, 1900, 500, 1000, 2600, 4300, 6100, 8000, 10000]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1022, 1019, 1013, 1001, 977, 929, 833, 641, 257, 511]\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]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [270, 255, 230, 195, 150, 95, 30, 45, 130, 225]\n assert candidate(nums = [10, 4, 8, 3, 7, 2, 5, 6, 9, 1]) == [45, 31, 19, 8, 2, 11, 18, 29, 44, 54]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [600, 580, 540, 480, 400, 300, 180, 40, 120, 300, 500]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985]) == [1399881, 1199884, 999889, 799896, 599905, 399916, 199929, 56, 200039, 400020, 599999, 799976, 999951, 1199924, 1399895]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [399, 395, 387, 375, 359, 339, 315, 287, 255, 219, 179, 135, 87, 35, 21, 81, 145, 213, 285, 361]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == [1048574, 1048571, 1048565, 1048553, 1048529, 1048481, 1048385, 1048193, 1047809, 1047041, 1045505, 1042433, 1036289, 1024001, 999425, 950273, 851969, 655361, 262145, 524287]\n assert candidate(nums = [100000, 10000, 1000, 100, 10, 1]) == [11111, 98889, 109889, 110989, 111099, 111110]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [95, 85, 75, 65, 55, 45, 35, 25, 15, 5, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == [9900, 9600, 9100, 8400, 7500, 6400, 5100, 3600, 1900, 0, 1900, 3600, 5100, 6400, 7500, 8400, 9100, 9600, 9900]\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == [450000, 350000, 250000, 150000, 50000, 50000, 150000, 250000, 350000, 450000]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == [1150, 1060, 990, 940, 910, 900, 890, 860, 810, 740, 650, 540, 410, 260, 90, 100, 310, 540, 790, 1060]\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]) == [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [45, 26, 9, 6, 19, 30, 39, 46, 51, 54]\n assert candidate(nums = [210, 190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1]) == [1330, 930, 569, 245, 44, 300, 525, 721, 890, 1034, 1155, 1255, 1336, 1400, 1449, 1485, 1510, 1526, 1535, 1539]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [190, 151, 114, 79, 46, 15, 14, 41, 66, 89, 110, 129, 146, 161, 174, 185, 194, 201, 206, 209]\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]) == [2320, 2305, 2280, 2245, 2200, 2145, 2080, 2005, 1920, 1825, 1720, 1605, 1480, 1345, 1200, 1045, 880, 705, 520, 325, 120, 95, 320, 555, 800, 1055, 1320, 1595, 1880, 2175]\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]) == [196415, 196412, 196407, 196399, 196386, 196365, 196331, 196276, 196187, 196043, 195810, 195433, 194823, 193836, 192239, 189655, 185474, 178709, 167763, 150052, 121395, 75027, 2, 121391]\n assert candidate(nums = [12345, 67890, 54321, 98765, 43210, 87654, 32109, 76543, 21098, 65432]) == [547022, 466787, 344576, 191490, 49515, 81349, 201112, 309764, 407405, 493935]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == [111111110, 111111099, 111110989, 111109889, 111098889, 110988889, 109888889, 98888889, 11111111]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == [900000, 700000, 500000, 300000, 100000, 100000, 300000, 500000, 700000, 900000]\n assert candidate(nums = [99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1]) == [400001, 300001, 200001, 100001, 1, 99999, 199999, 299999, 399999, 499999]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [36, 19, 4, 9, 20, 29, 36, 41, 44]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == [24, 21, 16, 9, 0, 9, 16, 21, 24]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [2046, 2043, 2037, 2025, 2001, 1953, 1857, 1665, 1281, 513, 1023]\n assert candidate(nums = [20000, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == [19995, 10005, 25005, 32505, 36255, 38130, 39067, 39535, 39769, 39886, 39944, 39972, 39985, 39991, 39994]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [105, 76, 49, 24, 1, 20, 39, 56, 71, 84, 95, 104, 111, 116, 119]\n assert candidate(nums = [5, 4, 3, 2, 1]) == [10, 1, 6, 11, 14]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [119, 116, 111, 104, 95, 84, 71, 56, 39, 20, 1, 24, 49, 76, 105]\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == [1400, 1100, 800, 500, 200, 100, 400, 700, 1000, 1300]\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]) == [100, 81, 64, 49, 36, 25, 16, 9, 4, 1, 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [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, 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]\n assert candidate(nums = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == [899991, 699993, 499995, 299997, 99999, 99999, 299997, 499995, 699993, 899991]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [990, 960, 910, 840, 750, 640, 510, 360, 190, 0, 190, 360, 510, 640, 750, 840, 910, 960, 990]\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10]) == [240, 210, 160, 90, 0, 90, 160, 210, 240]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [224, 220, 212, 200, 184, 164, 140, 112, 80, 44, 4, 40, 88, 140, 196]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [2090, 2060, 2010, 1940, 1850, 1740, 1610, 1460, 1290, 1100, 890, 660, 410, 140, 150, 460, 790, 1140, 1510, 1900]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == [1539, 1535, 1526, 1510, 1485, 1449, 1400, 1336, 1255, 1155, 1034, 890, 721, 525, 300, 44, 245, 569, 930, 1330]\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, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(nums = [99999, 1, 99999, 2, 99999, 3, 99999, 4, 99999, 5]) == [400011, 300011, 200011, 100010, 9, 99993, 199995, 299998, 400001, 500005]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [495, 475, 435, 375, 295, 195, 75, 65, 225, 405]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [950, 850, 750, 650, 550, 450, 350, 250, 150, 50, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950]\n assert candidate(nums = [50, 25, 12, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [47, 28, 65, 83, 92, 96, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [209, 206, 201, 194, 185, 174, 161, 146, 129, 110, 89, 66, 41, 14, 15, 46, 79, 114, 151, 190]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [54000, 51000, 46000, 39000, 30000, 19000, 6000, 9000, 26000, 45000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1190, 1160, 1110, 1040, 950, 840, 710, 560, 390, 200, 10, 240, 490, 760, 1050]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 10000, 1000, 100, 10]) == [122220, 122209, 122099, 120999, 109999, 1, 110001, 121001, 122101, 122211]\n assert candidate(nums = [50, 40, 30, 20, 10, 5, 3, 2, 1, 1, 2, 3, 5, 10, 20, 30, 40, 50]) == [272, 182, 112, 62, 32, 17, 9, 4, 1, 1, 4, 9, 17, 32, 62, 112, 182, 272]\n assert candidate(nums = [100000, 100000, 100000, 100000]) == [300000, 100000, 100000, 300000]\n assert candidate(nums = [1000, 500, 250, 125, 63, 31, 15, 7, 3, 1]) == [995, 505, 1255, 1630, 1818, 1912, 1958, 1980, 1990, 1994]\n assert candidate(nums = [1, 2, 3]) == [5, 2, 3]\n assert candidate(nums = [8, 8, 8, 8, 8]) == [32, 16, 0, 16, 32]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == [6, 4, 2, 0, 2, 4, 6]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995]) == [399986, 199989, 6, 199999, 399990]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == [399990, 199991, 6, 200001, 399994]\n assert candidate(nums = [100000, 100000, 100000, 100000]) == [300000, 100000, 100000, 300000]\n assert candidate(nums = [1000, 2000, 3000]) == [5000, 2000, 3000]\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == [100, 85, 60, 25, 20, 75]\n assert candidate(nums = [3, 2, 1]) == [3, 2, 5]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [140, 110, 60, 10, 100]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [14, 11, 6, 1, 10]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == [400000, 200000, 0, 200000, 400000]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [45, 26, 9, 6, 19, 30, 39, 46, 51, 54]\n assert candidate(nums = [100000, 1, 1, 1, 1]) == [4, 99997, 99999, 100001, 100003]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [36, 19, 4, 9, 20, 29, 36, 41, 44]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [36, 19, 4, 9, 20, 29, 36, 41, 44, 45]\n assert candidate(nums = [5, 6, 7, 8, 9]) == [30, 19, 6, 9, 26]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [140, 110, 60, 10, 100]\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == [5, 3, 1, 1, 3, 5]\n assert candidate(nums = [5, 5, 5, 5, 5]) == [20, 10, 0, 10, 20]\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000]) == [4000, 2000, 0, 2000, 4000]\n assert candidate(nums = [9, 7, 5, 3, 1]) == [16, 0, 12, 20, 24]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [4, 2, 0, 2, 4]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == [440, 410, 360, 290, 200, 90, 40, 190, 360]\n assert candidate(nums = [2, 3, 2, 4, 3, 2, 3, 4]) == [21, 16, 11, 5, 2, 7, 12, 19]\n assert candidate(nums = [5, 10]) == [10, 5]\n assert candidate(nums = [100, 200, 300, 400, 500]) == [1400, 1100, 600, 100, 1000]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == [899946, 699949, 499954, 299961, 99970, 100019, 300006, 499991, 699974, 899955]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [54, 51, 46, 39, 30, 19, 6, 9, 26, 45]\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == [4500, 2600, 900, 600, 1900, 3000, 3900, 4600, 5100, 5400]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [540, 510, 460, 390, 300, 190, 60, 90, 260, 450]\n assert candidate(nums = [30, 25, 20, 15, 10, 5]) == [75, 20, 25, 60, 85, 100]\n assert candidate(nums = [1, 2]) == [2, 1]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == [99803, 50197, 125197, 162697, 181447, 190822, 195509, 197852, 199023, 199608]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250]) == [93750, 56250, 131250, 168750, 187500]\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == [200, 170, 120, 50, 40, 150]\n assert candidate(nums = [10, 4, 8, 3]) == [15, 1, 11, 22]\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == [25, 15, 5, 5, 15, 25]\n assert candidate(nums = [7, 1, 3, 4, 1]) == [9, 1, 3, 10, 15]\n assert candidate(nums = [50, 40, 30, 20, 10]) == [100, 10, 60, 110, 140]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [99, 95, 87, 75, 59, 39, 15, 13, 45, 81]\n assert candidate(nums = [100, 200, 300, 400, 500]) == [1400, 1100, 600, 100, 1000]\n assert candidate(nums = [5]) == [0]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000]) == [14000, 11000, 6000, 1000, 10000]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [450, 260, 90, 60, 190, 300, 390, 460, 510, 540]\n assert candidate(nums = [7, 1, 3, 4, 1, 5]) == [14, 6, 2, 5, 10, 16]\n assert candidate(nums = [500, 400, 300, 200, 100]) == [1000, 100, 600, 1100, 1400]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().leftRightDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] leftRightDifference(int[] nums) {", "container": "Solution", "callable": "leftRightDifference", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2575, "task_id": "find-the-divisibility-array-of-a-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string word of length n consisting of digits, and a positive integer m.\nThe divisibility array div of word is an integer array of length n such that:\n\ndiv[i] = 1 if the numeric value of word[0,...,i] is divisible by m, or\ndiv[i] = 0 otherwise.\n\nReturn the divisibility array of word.\n \nExample 1:\n\nInput: word = \"998244353\", m = 3\nOutput: [1,1,0,0,0,1,1,0,0]\nExplanation: There are only 4 prefixes that are divisible by 3: \"9\", \"99\", \"998244\", and \"9982443\".\n\nExample 2:\n\nInput: word = \"1010\", m = 10\nOutput: [0,1,0,1]\nExplanation: There are only 2 prefixes that are divisible by 10: \"10\", and \"1010\".\n\n \nConstraints:\n\n1 <= n <= 105\nword.length == n\nword consists of digits from 0 to 9\n1 <= m <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"1111111111\",m = 5) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(word = \"998244353\",m = 3) == [1, 1, 0, 0, 0, 1, 1, 0, 0]\n assert candidate(word = \"00000\",m = 1) == [1, 1, 1, 1, 1]\n assert candidate(word = \"1010\",m = 10) == [0, 1, 0, 1]\n assert candidate(word = \"00000\",m = 5) == [1, 1, 1, 1, 1]\n assert candidate(word = \"1111111111\",m = 11) == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n"}, "metadata": {"canonical_parameter_names": ["word", "m"], "leetcode_dataset_entry_point": "Solution().divisibilityArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] divisibilityArray(String word, int m) {", "container": "Solution", "callable": "divisibilityArray", "parameters": [{"name": "word", "type": "String"}, {"name": "m", "type": "int"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2576, "task_id": "find-the-maximum-number-of-marked-indices", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums.\nInitially, all of the indices are unmarked. You are allowed to make this operation any number of times:\n\nPick two different unmarked indices i and j such that 2 * nums[i] <= nums[j], then mark i and j.\n\nReturn the maximum possible number of marked indices in nums using the above operation any number of times.\n \nExample 1:\n\nInput: nums = [3,5,2,4]\nOutput: 2\nExplanation: In the first operation: pick i = 2 and j = 1, the operation is allowed because 2 * nums[2] <= nums[1]. Then mark index 2 and 1.\nIt can be shown that there's no other valid operation so the answer is 2.\n\nExample 2:\n\nInput: nums = [9,2,5,4]\nOutput: 4\nExplanation: In the first operation: pick i = 3 and j = 0, the operation is allowed because 2 * nums[3] <= nums[0]. Then mark index 3 and 0.\nIn the second operation: pick i = 1 and j = 2, the operation is allowed because 2 * nums[1] <= nums[2]. Then mark index 1 and 2.\nSince there is no other operation, the answer is 4.\n\nExample 3:\n\nInput: nums = [7,6,8]\nOutput: 0\nExplanation: There is no valid operation to do, so the answer is 0.\n\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n\n \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 6\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 10\n assert candidate(nums = [7, 6, 8]) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [5, 10, 20, 25, 30, 35, 40, 45, 50]) == 8\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [5, 5, 5, 10, 10, 10, 15, 15, 15, 20, 20, 20]) == 12\n assert candidate(nums = [10, 20, 30, 40, 50]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [3, 5, 2, 4]) == 2\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\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]) == 6\n assert candidate(nums = [5, 10, 20, 40, 80, 160]) == 6\n assert candidate(nums = [9, 2, 5, 4]) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 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 = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 16\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 14\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 20\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 2, 20, 200, 2000, 20000, 200000, 2000000, 20000000, 200000000, 2000000000]) == 20\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\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]) == 26\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 40\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 20\n assert candidate(nums = [1, 2, 3, 6, 12, 24, 48, 96]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 6, 6, 12, 12]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 18\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 16\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721]) == 16\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864]) == 20\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 14\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 440, 480, 520, 560, 600, 640, 680, 720, 760, 800, 880, 960, 1040, 1120, 1200]) == 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, 51, 53, 55, 57, 59]) == 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]) == 30\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]) == 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]) == 30\n assert candidate(nums = [2, 5, 7, 8, 10, 13, 15, 16, 19, 20, 22, 23, 25, 27, 28, 30, 32, 33, 35, 37, 38, 40, 41, 43, 45, 46, 48, 50]) == 26\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]) == 24\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 6\n assert candidate(nums = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000]) == 10\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 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]) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == 32\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, 317811, 514229, 832040]) == 28\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 14\n assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920, 163840, 327680, 655360, 1310720, 2621440, 5242880, 10485760, 20971520, 41943040, 83886080, 167772160, 335544320, 671088640]) == 28\n assert candidate(nums = [1, 2, 3, 6, 12, 24, 48, 96, 192]) == 8\n assert candidate(nums = [2, 4, 4, 8, 8, 8, 16, 16, 16, 16, 32, 32, 32, 32, 32]) == 14\n assert candidate(nums = [50, 25, 10, 5, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 24\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]) == 24\n assert candidate(nums = [1, 3, 5, 15, 25, 45, 75, 105, 150, 225, 300, 450, 600]) == 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, 6]) == 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]) == 20\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 14\n assert candidate(nums = [1, 4, 5, 6, 8, 10, 12, 15, 16, 18, 20, 22, 25, 28, 30]) == 14\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 14\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164, 175, 186, 197, 208]) == 18\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 20\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119]) == 20\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 18\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 20\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 16\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]) == 24\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 10\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 10\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]) == 30\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 18, 27, 36, 54, 81, 108, 162, 243, 324, 486, 729, 972, 1458, 2187, 2916, 4374, 6561, 8748, 13122, 19683, 26244, 39366, 59049, 78732, 118098, 177147, 236196, 354294, 531441, 708588, 1062882]) == 36\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10]) == 22\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125, 6103515625]) == 14\n assert candidate(nums = [1, 3, 3, 7, 10, 15, 20, 25, 30, 40, 50, 60]) == 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, 20, 20, 30, 30, 40, 40, 50, 50]) == 28\n assert candidate(nums = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50]) == 12\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]) == 30\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 20\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]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 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, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10\n assert candidate(nums = [9, 4, 2, 18, 3, 12, 6, 24, 8, 48]) == 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 = [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]) == 30\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 20\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(nums = [1, 5, 10, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170]) == 20\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]) == 24\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147]) == 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]) == 20\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467]) == 20\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 = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135]) == 14\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344, 114688, 229376, 458752, 917504, 1835008, 3670016]) == 20\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]) == 22\n assert candidate(nums = [3, 5, 2, 4, 8, 16, 32, 64]) == 8\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969]) == 14\n assert candidate(nums = [1, 3, 5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 200]) == 20\n assert candidate(nums = [10, 25, 30, 50, 60, 100, 120, 150, 200, 300]) == 10\n assert candidate(nums = [30, 60, 120, 240, 480, 960, 1920, 3840, 7680, 15360, 30720, 61440, 122880, 245760, 491520, 983040, 1966080, 3932160, 7864320, 15728640, 31457280, 62914560, 125829120, 251658240, 503316480, 1006632960, 2013265920, 4026531840, 8053063680, 16106127360]) == 30\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 16\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 18, 24, 36, 48]) == 10\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]) == 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, 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]) == 20\n assert candidate(nums = [3, 3, 6, 6, 12, 12, 24, 24, 48, 48, 96, 96]) == 12\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxNumOfMarkedIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxNumOfMarkedIndices(int[] nums) {", "container": "Solution", "callable": "maxNumOfMarkedIndices", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2577, "task_id": "minimum-time-to-visit-a-cell-in-a-grid", "difficulty": "Hard", "problem_description": "You are given a m x n matrix grid consisting of non-negative integers where grid[row][col] represents the minimum time required to be able to visit the cell (row, col), which means you can visit the cell (row, col) only when the time you visit it is greater than or equal to grid[row][col].\nYou are standing in the top-left cell of the matrix in the 0th second, and you must move to any adjacent cell in the four directions: up, down, left, and right. Each move you make takes 1 second.\nReturn the minimum time required in which you can visit the bottom-right cell of the matrix. If you cannot visit the bottom-right cell, then return -1.\n \nExample 1:\n\n\nInput: grid = [[0,1,3,2],[5,1,2,5],[4,3,8,6]]\nOutput: 7\nExplanation: One of the paths that we can take is the following:\n- at t = 0, we are on the cell (0,0).\n- at t = 1, we move to the cell (0,1). It is possible because grid[0][1] <= 1.\n- at t = 2, we move to the cell (1,1). It is possible because grid[1][1] <= 2.\n- at t = 3, we move to the cell (1,2). It is possible because grid[1][2] <= 3.\n- at t = 4, we move to the cell (1,1). It is possible because grid[1][1] <= 4.\n- at t = 5, we move to the cell (1,2). It is possible because grid[1][2] <= 5.\n- at t = 6, we move to the cell (1,3). It is possible because grid[1][3] <= 6.\n- at t = 7, we move to the cell (2,3). It is possible because grid[2][3] <= 7.\nThe final time is 7. It can be shown that it is the minimum time possible.\n\nExample 2:\n\n\nInput: grid = [[0,2,4],[3,2,1],[1,0,4]]\nOutput: -1\nExplanation: There is no path from the top left to the bottom-right cell.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n2 <= m, n <= 1000\n4 <= m * n <= 105\n0 <= grid[i][j] <= 105\ngrid[0][0] == 0\n\n \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 2, 4], [3, 2, 1], [1, 0, 4]]) == -1\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 4\n assert candidate(grid = [[0, 0], [0, 1]]) == 2\n assert candidate(grid = [[0, 1, 3, 2], [5, 1, 2, 5], [4, 3, 8, 6]]) == 7\n assert candidate(grid = [[0, 1], [2, 1]]) == 2\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 4\n assert candidate(grid = [[0, 1, 0, 1, 2], [0, 1, 0, 1, 2], [0, 1, 0, 1, 2], [0, 1, 0, 1, 2]]) == 7\n assert candidate(grid = [[0, 100], [101, 100]]) == -1\n assert candidate(grid = [[0, 1], [2, 3]]) == 4\n assert candidate(grid = [[0, 1, 2], [1, 1, 1], [2, 1, 0]]) == 4\n assert candidate(grid = [[0, 1, 1], [2, 2, 1], [1, 1, 0]]) == 4\n assert candidate(grid = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]) == 8\n assert candidate(grid = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]]) == 8\n assert candidate(grid = [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 99, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[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]]) == 29\n assert candidate(grid = [[0, 10000, 10000], [10000, 1, 10000], [10000, 10000, 1]]) == -1\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 0], [5, 4, 3, 2, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[0, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 99, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 0]]) == 8\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [1, 9, 9, 9, 9, 1], [1, 9, 9, 9, 9, 1], [1, 9, 9, 9, 9, 1], [1, 9, 9, 9, 9, 1], [1, 1, 1, 1, 1, 0]]) == 10\n assert candidate(grid = [[0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]]) == 11\n assert candidate(grid = [[0, 99, 99, 99, 99, 99, 99], [99, 99, 99, 99, 99, 99, 99], [99, 99, 0, 1, 1, 1, 99], [99, 99, 1, 99, 99, 1, 99], [99, 99, 1, 1, 1, 1, 99], [99, 99, 99, 99, 99, 99, 99], [99, 99, 99, 99, 99, 99, 0]]) == -1\n assert candidate(grid = [[0, 10, 15], [1, 5, 20], [2, 10, 25], [3, 15, 30]]) == 31\n assert candidate(grid = [[0, 1, 1, 1], [1, 99, 99, 1], [1, 1, 99, 1], [1, 1, 1, 0]]) == 6\n assert candidate(grid = [[0, 1, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000], [1, 1000, 1, 1, 1, 1, 1, 1, 1, 1000], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 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]]) == 18\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 0], [4, 3, 2, 1, 0, 0]]) == 10\n assert candidate(grid = [[0, 2, 2, 1, 3], [1, 2, 3, 1, 2], [1, 2, 1, 2, 1], [2, 1, 1, 3, 2]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [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], [5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6]]) == 12\n assert candidate(grid = [[0, 2, 5, 7], [2, 5, 7, 9], [7, 9, 2, 5], [9, 2, 5, 0]]) == -1\n assert candidate(grid = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [0, 1, 2, 3, 0]]) == 8\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, 9, 8, 7, 6, 5, 4, 3, 2, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 18\n assert candidate(grid = [[0, 10, 20, 30], [15, 5, 25, 35], [10, 30, 10, 40], [5, 20, 30, 1]]) == -1\n assert candidate(grid = [[0, 1, 2, 3], [10, 9, 8, 7], [2, 3, 4, 5], [11, 12, 13, 6]]) == 10\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [1, 6, 7, 8, 9, 10], [2, 7, 12, 13, 14, 15], [3, 8, 13, 18, 19, 20], [4, 9, 14, 19, 24, 25], [5, 10, 15, 20, 25, 0]]) == 26\n assert candidate(grid = [[0, 2, 2, 2], [2, 1, 2, 2], [2, 2, 1, 2], [2, 2, 2, 1]]) == -1\n assert candidate(grid = [[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]]) == 8\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 1], [1, 2, 3, 4, 5, 6, 7, 6, 5, 1], [1, 2, 3, 4, 5, 6, 7, 8, 7, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 18\n assert candidate(grid = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 6\n assert candidate(grid = [[0, 10000, 9999], [10000, 9998, 10000], [9997, 10000, 10000]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 100000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 38\n assert candidate(grid = [[0, 0, 0], [0, 100, 0], [0, 0, 0]]) == 4\n assert candidate(grid = [[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]]) == 49\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [1, 6, 7, 8, 9, 10], [2, 11, 12, 13, 14, 15], [3, 16, 17, 18, 19, 20], [4, 21, 22, 23, 24, 25], [5, 26, 27, 28, 29, 30]]) == 30\n assert candidate(grid = [[0, 1, 2], [3, 100, 5], [6, 101, 8]]) == 8\n assert candidate(grid = [[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, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 18\n assert candidate(grid = [[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, 0]]) == 25\n assert candidate(grid = [[0, 1, 3, 5, 7], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]]) == 14\n assert candidate(grid = [[0, 2, 5, 9, 13], [4, 5, 6, 10, 14], [7, 8, 7, 11, 15], [12, 13, 14, 16, 19], [16, 17, 18, 18, 20]]) == -1\n assert candidate(grid = [[0, 2, 1, 4], [1, 6, 1, 2], [3, 1, 5, 3], [1, 2, 3, 0]]) == 8\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 99999, 99999, 99999, 0], [0, 99999, 99999, 99999, 0], [0, 99999, 99999, 99999, 0], [0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 99, 99, 99, 99, 99, 99, 99, 99, 1], [1, 99, 99, 99, 99, 99, 99, 99, 99, 1], [1, 99, 99, 99, 99, 99, 99, 99, 99, 1], [1, 99, 99, 99, 99, 99, 99, 99, 99, 1], [1, 99, 99, 99, 99, 99, 99, 99, 99, 1], [1, 99, 99, 99, 99, 99, 99, 99, 99, 1], [1, 99, 99, 99, 99, 99, 99, 99, 99, 1], [1, 99, 99, 99, 99, 99, 99, 99, 99, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 18\n assert candidate(grid = [[0, 2, 4, 5, 6], [7, 3, 8, 9, 1], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]) == -1\n assert candidate(grid = [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]]) == 16\n assert candidate(grid = [[0, 5, 10, 15], [15, 10, 5, 0], [10, 5, 0, 5], [15, 0, 5, 0]]) == -1\n assert candidate(grid = [[0, 5, 7, 8, 9], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 0]]) == 16\n assert candidate(grid = [[0, 1, 2, 3], [1, 100000, 1, 4], [2, 1, 1, 5], [3, 4, 5, 6]]) == 6\n assert candidate(grid = [[0, 1, 3, 2], [5, 8, 2, 5], [4, 3, 8, 6], [7, 6, 9, 0]]) == 8\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [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, 0]]) == 10\n assert candidate(grid = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]]) == 8\n assert candidate(grid = [[0, 99, 99, 99, 99], [99, 99, 99, 99, 99], [99, 99, 1, 99, 99], [99, 99, 1, 99, 99], [99, 99, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 5, 7, 9, 11, 13, 15, 17, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 3], [3, 5, 7, 9, 11, 13, 15, 17, 19, 5], [4, 6, 8, 10, 12, 14, 16, 18, 20, 7], [5, 7, 9, 11, 13, 15, 17, 19, 21, 9], [6, 8, 10, 12, 14, 16, 18, 20, 22, 11], [7, 9, 11, 13, 15, 17, 19, 21, 23, 13], [8, 10, 12, 14, 16, 18, 20, 22, 24, 15], [9, 1, 3, 5, 7, 9, 11, 13, 15, 17]]) == 18\n assert candidate(grid = [[0, 10, 11, 12], [1, 2, 3, 4], [5, 6, 7, 8], [9, 1, 2, 1]]) == 10\n assert candidate(grid = [[0, 1, 2, 3, 4], [4, 3, 2, 3, 4], [4, 3, 2, 3, 4], [4, 3, 2, 3, 4], [4, 3, 2, 3, 0]]) == 8\n assert candidate(grid = [[0, 1, 5, 3, 4, 2], [1, 0, 1, 0, 1, 0], [2, 0, 2, 0, 2, 0], [1, 0, 1, 0, 1, 0], [3, 2, 3, 2, 3, 1]]) == 9\n assert candidate(grid = [[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]]) == 8\n assert candidate(grid = [[0, 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, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 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(grid = [[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]]) == 48\n assert candidate(grid = [[0, 1, 5], [1, 9, 1], [2, 8, 1]]) == 8\n assert candidate(grid = [[0, 3, 1, 1, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1]]) == 8\n assert candidate(grid = [[0, 2, 5, 7, 8], [1, 3, 4, 6, 9], [2, 1, 3, 5, 7], [3, 4, 2, 1, 8], [4, 3, 5, 2, 0]]) == 8\n assert candidate(grid = [[0, 10, 10, 10], [10, 9, 9, 10], [10, 9, 8, 10], [10, 10, 10, 0]]) == -1\n assert candidate(grid = [[0, 10, 5], [20, 0, 15], [5, 15, 0]]) == -1\n assert candidate(grid = [[0, 1, 2, 3, 4], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [5, 6, 7, 8, 9], [0, 1, 2, 3, 4]]) == 10\n assert candidate(grid = [[0, 10, 15, 20], [5, 4, 3, 2], [10, 9, 8, 7], [15, 14, 13, 6]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1], [1, 9, 1, 9, 1], [1, 1, 9, 1, 1], [1, 9, 1, 9, 1], [1, 1, 1, 9, 0]]) == 8\n assert candidate(grid = [[0, 10, 10, 10], [10, 1, 10, 10], [10, 10, 1, 10], [10, 10, 10, 1]]) == -1\n assert candidate(grid = [[0, 2, 3, 5, 1], [1, 4, 3, 2, 6], [7, 3, 1, 5, 8], [6, 2, 4, 1, 7], [5, 1, 2, 3, 0]]) == 10\n assert candidate(grid = [[0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [10, 12, 14, 16, 18], [19, 21, 23, 25, 27], [28, 30, 32, 34, 36]]) == 36\n assert candidate(grid = [[0, 2, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[0, 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, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 10, 0], [0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5], [5, 4, 3, 99, 99, 99], [0, 1, 2, 99, 99, 99], [0, 0, 0, 99, 99, 99]]) == 102\n assert candidate(grid = [[0, 5, 5, 5, 5, 5], [5, 1, 1, 1, 1, 1], [5, 1, 5, 5, 5, 1], [5, 1, 1, 5, 1, 1], [5, 5, 5, 1, 5, 5], [5, 1, 1, 1, 1, 5]]) == -1\n assert candidate(grid = [[0, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 4], [1, 1, 1, 0]]) == 6\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0], [10, 9, 8, 7, 6, 5, 4, 3, 2, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0], [10, 9, 8, 7, 6, 5, 4, 3, 2, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0], [10, 9, 8, 7, 6, 5, 4, 3, 2, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 19\n assert candidate(grid = [[0, 2, 1, 4], [3, 0, 5, 2], [1, 4, 0, 3], [2, 5, 3, 0]]) == -1\n assert candidate(grid = [[0, 0, 0], [0, 10, 0], [0, 0, 0]]) == 4\n assert candidate(grid = [[0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12]]) == 12\n assert candidate(grid = [[0, 3, 1, 4], [3, 5, 7, 8], [4, 9, 6, 7], [11, 12, 5, 10]]) == -1\n assert candidate(grid = [[0, 1, 2, 3], [10, 11, 12, 4], [13, 14, 15, 5], [16, 17, 18, 6]]) == 6\n assert candidate(grid = [[0, 1, 2, 3], [1, 9, 8, 7], [2, 8, 7, 6], [3, 7, 6, 0]]) == 10\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, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 18\n assert candidate(grid = [[0, 10, 20, 30, 40], [10, 11, 21, 31, 41], [20, 21, 22, 32, 42], [30, 31, 32, 33, 43], [40, 41, 42, 43, 44]]) == -1\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 1], [2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 3], [4, 5, 6, 7, 8, 9], [10, 1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[0, 1, 3, 5], [9, 1, 2, 4], [8, 7, 6, 5], [1, 3, 5, 7]]) == 8\n assert candidate(grid = [[0, 1, 2, 3, 4], [1, 10, 10, 10, 1], [2, 10, 1, 10, 2], [3, 10, 10, 10, 3], [4, 1, 2, 3, 4]]) == 8\n assert candidate(grid = [[0, 1, 2, 3], [4, 1, 2, 3], [4, 1, 2, 3], [4, 1, 2, 3]]) == 6\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0]]) == 10\n assert candidate(grid = [[0, 1, 10, 100, 1000], [1, 10, 100, 1000, 10000], [10, 100, 1000, 10000, 100000], [100, 1000, 10000, 100000, 1000000], [1000, 10000, 100000, 1000000, 0]]) == 1000002\n assert candidate(grid = [[0, 3, 4, 5, 6], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 0]]) == 8\n assert candidate(grid = [[0, 2, 2, 2, 2, 2], [2, 2, 9, 9, 9, 2], [2, 9, 9, 9, 9, 9], [2, 9, 9, 9, 9, 9], [2, 2, 9, 9, 9, 2], [2, 2, 2, 2, 2, 0]]) == -1\n assert candidate(grid = [[0, 1, 5, 2, 10], [6, 3, 1, 4, 7], [8, 5, 9, 1, 6], [7, 4, 8, 3, 2]]) == 9\n assert candidate(grid = [[0, 5, 10, 15], [20, 25, 30, 35], [40, 45, 50, 55], [60, 65, 70, 75]]) == -1\n assert candidate(grid = [[0, 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, 1, 1, 1, 1, 1, 0]]) == 10\n assert candidate(grid = [[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\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], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 13\n assert candidate(grid = [[0, 1, 99, 99, 99, 99, 99, 99, 99, 99, 99], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [99, 1, 99, 99, 99, 99, 99, 99, 99, 99, 1], [99, 1, 99, 99, 99, 99, 99, 99, 99, 99, 1], [99, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1], [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1], [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1], [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1], [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1], [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0]]) == 20\n assert candidate(grid = [[0, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 1, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0], [0, 10, 10, 0], [0, 10, 10, 0], [0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12]]) == 12\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 3, 0]]) == 10\n assert candidate(grid = [[0, 100], [1, 101], [2, 102], [3, 103], [4, 104], [5, 105]]) == 106\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 1, 2], [3, 1, 1], [2, 1, 0]]) == 4\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minimumTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumTime(int[][] grid) {", "container": "Solution", "callable": "minimumTime", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2578, "task_id": "split-with-minimum-sum", "difficulty": "Easy", "problem_description": "Given a positive integer num, split it into two non-negative integers num1 and num2 such that:\n\nThe concatenation of num1 and num2 is a permutation of num.\n\n\t\nIn other words, the sum of the number of occurrences of each digit in num1 and num2 is equal to the number of occurrences of that digit in num.\n\n\nnum1 and num2 can contain leading zeros.\n\nReturn the minimum possible sum of num1 and num2.\nNotes:\n\nIt is guaranteed that num does not contain any leading zeros.\nThe order of occurrence of the digits in num1 and num2 may differ from the order of occurrence of num.\n\n \nExample 1:\n\nInput: num = 4325\nOutput: 59\nExplanation: We can split 4325 so that num1 is 24 and num2 is 35, giving a sum of 59. We can prove that 59 is indeed the minimal possible sum.\n\nExample 2:\n\nInput: num = 687\nOutput: 75\nExplanation: We can split 687 so that num1 is 68 and num2 is 7, which would give an optimal sum of 75.\n\n \nConstraints:\n\n10 <= num <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 10) == 1\n assert candidate(num = 687) == 75\n assert candidate(num = 4325) == 59\n assert candidate(num = 1111111111) == 22222\n assert candidate(num = 1234) == 37\n assert candidate(num = 222) == 24\n assert candidate(num = 1000000000) == 1\n assert candidate(num = 111111) == 222\n assert candidate(num = 123456789) == 16047\n assert candidate(num = 9876543210) == 16047\n assert candidate(num = 111222333) == 12456\n assert candidate(num = 1999999999) == 119998\n assert candidate(num = 1020304050) == 159\n assert candidate(num = 29392342) == 4588\n assert candidate(num = 1001) == 2\n assert candidate(num = 543321) == 369\n assert candidate(num = 5555555555) == 111110\n assert candidate(num = 999999) == 1998\n assert candidate(num = 9191919191) == 23198\n assert candidate(num = 1000000) == 1\n assert candidate(num = 1357924680) == 16047\n assert candidate(num = 314159) == 284\n assert candidate(num = 444444444444444444) == 888888888\n assert candidate(num = 2233445566778899) == 46913578\n assert candidate(num = 567894321) == 16047\n assert candidate(num = 99991111) == 2398\n assert candidate(num = 5647382910) == 16047\n assert candidate(num = 1000000009) == 10\n assert candidate(num = 100100100100) == 22\n assert candidate(num = 4444444444) == 88888\n assert candidate(num = 99887766554433221100) == 246913578\n assert candidate(num = 303030303030) == 666\n assert candidate(num = 4444455555) == 89010\n assert candidate(num = 111222333444) == 234678\n assert candidate(num = 111222333444555666777888999) == 12456901345788\n assert candidate(num = 3030303030) == 366\n assert candidate(num = 111122223333444455556666777788889999) == 224466891133557798\n assert candidate(num = 594939291909) == 160998\n assert candidate(num = 7070707070) == 854\n assert candidate(num = 12345678987654321) == 135802467\n assert candidate(num = 8642013579) == 16047\n assert candidate(num = 8642086420) == 4936\n assert candidate(num = 1298765432) == 36047\n assert candidate(num = 111222333444555) == 12456900\n assert candidate(num = 222333444555666777888999) == 456901345788\n assert candidate(num = 2222222222) == 44444\n assert candidate(num = 2020202020) == 244\n assert candidate(num = 222222222222222222222222222222222222) == 444444444444444444\n assert candidate(num = 1357913579) == 27158\n assert candidate(num = 2323232323) == 44566\n assert candidate(num = 6060606060) == 732\n assert candidate(num = 31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679) == 12223444445666667888901112333355557777779999998\n assert candidate(num = 1000000001) == 2\n assert candidate(num = 87654321) == 3825\n assert candidate(num = 999998888877777666665555544444333332222211111) == 12244566890113345577898\n assert candidate(num = 12345678901234567890) == 246913578\n assert candidate(num = 1111222233334444) == 22446688\n assert candidate(num = 2468024680) == 4936\n assert candidate(num = 1122334455) == 24690\n assert candidate(num = 333311112222) == 224466\n assert candidate(num = 999111222333) == 234738\n assert candidate(num = 123456789012) == 136047\n assert candidate(num = 999888777666555444333222111) == 12456901345788\n assert candidate(num = 8080808080) == 976\n assert candidate(num = 321123321123) == 224466\n assert candidate(num = 98765432109876543210) == 246913578\n assert candidate(num = 1223334444) == 35688\n assert candidate(num = 1010101010) == 122\n assert candidate(num = 999988887777666655554444333322221111) == 224466891133557798\n assert candidate(num = 8051726349) == 16047\n assert candidate(num = 4040404040) == 488\n assert candidate(num = 777777777777777777) == 1555555554\n assert candidate(num = 5959595959) == 111598\n assert candidate(num = 987654321) == 16047\n assert candidate(num = 2929292929) == 45298\n assert candidate(num = 54321) == 159\n assert candidate(num = 765432109876543210) == 24691357\n assert candidate(num = 333322221111) == 224466\n assert candidate(num = 9999999999) == 199998\n assert candidate(num = 112233445566778899) == 246913578\n assert candidate(num = 1234567890123456789) == 246913578\n assert candidate(num = 5432109876) == 16047\n assert candidate(num = 1234321) == 1357\n assert candidate(num = 5678901234) == 16047\n assert candidate(num = 8070605040302010) == 3825\n assert candidate(num = 5432112345) == 24690\n assert candidate(num = 2468013579) == 16047\n assert candidate(num = 1234567890987654321) == 246913578\n assert candidate(num = 12233344445555566666677777778888888899999999) == 3568911233455577779998\n assert candidate(num = 1234567890) == 16047\n assert candidate(num = 9090909090) == 1098\n assert candidate(num = 7654321098) == 16047\n assert candidate(num = 8888888888888888888) == 9777777776\n assert candidate(num = 5050505050) == 610\n assert candidate(num = 333333333333333333) == 666666666\n assert candidate(num = 5432109876543210) == 2469147\n assert candidate(num = 98765432100) == 16047\n assert candidate(num = 90909090909090) == 10998\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().splitNum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int splitNum(int num) {", "container": "Solution", "callable": "splitNum", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2579, "task_id": "count-total-number-of-colored-cells", "difficulty": "Medium", "problem_description": "There exists an infinitely large two-dimensional grid of uncolored unit cells. You are given a positive integer n, indicating that you must do the following routine for n minutes:\n\nAt the first minute, color any arbitrary unit cell blue.\nEvery minute thereafter, color blue every uncolored cell that touches a blue cell.\n\nBelow is a pictorial representation of the state of the grid after minutes 1, 2, and 3.\n\nReturn the number of colored cells at the end of n minutes.\n \nExample 1:\n\nInput: n = 1\nOutput: 1\nExplanation: After 1 minute, there is only 1 blue cell, so we return 1.\n\nExample 2:\n\nInput: n = 2\nOutput: 5\nExplanation: After 2 minutes, there are 4 colored cells on the boundary and 1 in the center, so we return 5. \n\n \nConstraints:\n\n1 <= n <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 13\n assert candidate(n = 100000) == 19999800001\n assert candidate(n = 100) == 19801\n assert candidate(n = 10000) == 199980001\n assert candidate(n = 2) == 5\n assert candidate(n = 1) == 1\n assert candidate(n = 1000) == 1998001\n assert candidate(n = 10) == 181\n assert candidate(n = 15000) == 449970001\n assert candidate(n = 99999) == 19999400005\n assert candidate(n = 12345) == 304773361\n assert candidate(n = 7500) == 112485001\n assert candidate(n = 2000) == 7996001\n assert candidate(n = 50000) == 4999900001\n assert candidate(n = 50) == 4901\n assert candidate(n = 5) == 41\n assert candidate(n = 30) == 1741\n assert candidate(n = 60000) == 7199880001\n assert candidate(n = 1500) == 4497001\n assert candidate(n = 4) == 25\n assert candidate(n = 30000) == 1799940001\n assert candidate(n = 1001) == 2002001\n assert candidate(n = 85000) == 14449830001\n assert candidate(n = 80000) == 12799840001\n assert candidate(n = 20000) == 799960001\n assert candidate(n = 5000) == 49990001\n assert candidate(n = 75000) == 11249850001\n assert candidate(n = 20) == 761\n assert candidate(n = 40000) == 3199920001\n assert candidate(n = 15) == 421\n assert candidate(n = 2500) == 12495001\n assert candidate(n = 9000) == 161982001\n assert candidate(n = 200) == 79601\n assert candidate(n = 99998) == 19999000013\n assert candidate(n = 500) == 499001\n assert candidate(n = 25) == 1201\n assert candidate(n = 25000) == 1249950001\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().coloredCells", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long coloredCells(int n) {", "container": "Solution", "callable": "coloredCells", "parameters": [{"name": "n", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2581, "task_id": "count-number-of-possible-root-nodes", "difficulty": "Hard", "problem_description": "Alice has an undirected tree with n nodes labeled from 0 to n - 1. The tree is represented as 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.\nAlice wants Bob to find the root of the tree. She allows Bob to make several guesses about her tree. In one guess, he does the following:\n\nChooses two distinct integers u and v such that there exists an edge [u, v] in the tree.\nHe tells Alice that u is the parent of v in the tree.\n\nBob's guesses are represented by a 2D integer array guesses where guesses[j] = [uj, vj] indicates Bob guessed uj to be the parent of vj.\nAlice being lazy, does not reply to each of Bob's guesses, but just says that at least k of his guesses are true.\nGiven the 2D integer arrays edges, guesses and the integer k, return the number of possible nodes that can be the root of Alice's tree. If there is no such tree, return 0.\n \nExample 1:\n\n\nInput: edges = [[0,1],[1,2],[1,3],[4,2]], guesses = [[1,3],[0,1],[1,0],[2,4]], k = 3\nOutput: 3\nExplanation: \nRoot = 0, correct guesses = [1,3], [0,1], [2,4]\nRoot = 1, correct guesses = [1,3], [1,0], [2,4]\nRoot = 2, correct guesses = [1,3], [1,0], [2,4]\nRoot = 3, correct guesses = [1,0], [2,4]\nRoot = 4, correct guesses = [1,3], [1,0]\nConsidering 0, 1, or 2 as root node leads to 3 correct guesses.\n\n\nExample 2:\n\n\nInput: edges = [[0,1],[1,2],[2,3],[3,4]], guesses = [[1,0],[3,4],[2,1],[3,2]], k = 1\nOutput: 5\nExplanation: \nRoot = 0, correct guesses = [3,4]\nRoot = 1, correct guesses = [1,0], [3,4]\nRoot = 2, correct guesses = [1,0], [2,1], [3,4]\nRoot = 3, correct guesses = [1,0], [2,1], [3,2], [3,4]\nRoot = 4, correct guesses = [1,0], [2,1], [3,2]\nConsidering any node as root will give at least 1 correct guess. \n\n\n \nConstraints:\n\nedges.length == n - 1\n2 <= n <= 105\n1 <= guesses.length <= 105\n0 <= ai, bi, uj, vj <= n - 1\nai != bi\nuj != vj\nedges represents a valid tree.\nguesses[j] is an edge of the tree.\nguesses is unique.\n0 <= k <= guesses.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[0, 1], [0, 2], [0, 3]],guesses = [[0, 1], [0, 2], [0, 3]],k = 2) == 4\n assert candidate(edges = [[0, 1], [0, 2]],guesses = [[0, 1]],k = 1) == 2\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [4, 2]],guesses = [[1, 3], [0, 1], [1, 0], [2, 4]],k = 3) == 3\n assert candidate(edges = [[0, 1], [1, 2], [2, 3]],guesses = [[1, 2], [2, 3]],k = 2) == 2\n assert candidate(edges = [[0, 1], [0, 2], [2, 3], [2, 4], [4, 5]],guesses = [[0, 1], [0, 2], [2, 3], [2, 4], [4, 5]],k = 5) == 1\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4]],guesses = [[1, 0], [3, 4], [2, 1], [3, 2]],k = 1) == 5\n assert candidate(edges = [[0, 1], [0, 2], [0, 3]],guesses = [[0, 1], [0, 2], [0, 3]],k = 3) == 1\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [1, 4]],guesses = [[0, 1], [1, 2], [1, 3], [1, 4]],k = 4) == 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]],guesses = [[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]],k = 15) == 6\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],guesses = [[0, 1], [1, 3], [3, 7], [3, 8], [1, 4], [4, 9], [4, 10], [0, 2], [2, 5], [2, 6]],k = 5) == 11\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],guesses = [[0, 1], [1, 4], [1, 5], [0, 2], [2, 6], [2, 7], [0, 3], [3, 8], [3, 9]],k = 4) == 10\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],guesses = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],k = 5) == 11\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],k = 5) == 4\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]],guesses = [[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], [2, 1], [14, 7], [15, 7], [16, 8], [17, 8], [20, 10], [21, 10], [22, 11], [23, 11], [24, 12], [25, 12], [26, 13], [27, 13]],k = 10) == 28\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],k = 8) == 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]],guesses = [[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], [0, 2], [1, 4], [6, 2], [3, 7], [4, 9], [5, 11]],k = 8) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],guesses = [[0, 1], [1, 3], [2, 5], [3, 7], [4, 9], [0, 2], [1, 4], [2, 6], [3, 8], [4, 10]],k = 5) == 11\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6]],guesses = [[0, 1], [1, 3], [3, 5], [0, 2], [2, 4], [4, 6]],k = 4) == 5\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]],guesses = [[0, 1], [1, 2], [1, 3], [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], [1, 0], [3, 1], [5, 2], [10, 4], [7, 3], [13, 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]],k = 15) == 29\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16]],guesses = [[0, 1], [1, 3], [3, 7], [3, 8], [1, 4], [4, 9], [0, 2], [2, 5], [2, 6], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16]],k = 10) == 17\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1]],k = 5) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],guesses = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 1], [5, 2]],k = 4) == 7\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],guesses = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],k = 7) == 10\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21]],guesses = [[0, 1], [1, 3], [3, 7], [3, 8], [1, 4], [4, 9], [0, 2], [2, 5], [2, 6], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21]],k = 12) == 22\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]],guesses = [[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], [3, 2], [7, 6], [11, 10], [13, 14]],k = 9) == 15\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]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 6) == 7\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]],guesses = [[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]],k = 10) == 6\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]],guesses = [[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], [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]],k = 9) == 15\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [3, 2], [7, 6]],k = 6) == 6\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [4, 7], [4, 8]],guesses = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [4, 7], [4, 8], [3, 1], [5, 2]],k = 4) == 9\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]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [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]],k = 10) == 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]],guesses = [[0, 1], [1, 3], [3, 7], [3, 8], [1, 4], [4, 9], [4, 10], [0, 2], [2, 5], [2, 6]],k = 7) == 11\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],k = 9) == 2\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11]],guesses = [[0, 1], [1, 3], [3, 7], [3, 8], [1, 4], [4, 9], [0, 2], [2, 5], [2, 6], [5, 10], [6, 11]],k = 7) == 12\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],guesses = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 1], [5, 1], [6, 2], [7, 2], [8, 3], [9, 3]],k = 4) == 10\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],guesses = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],k = 8) == 7\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]],guesses = [[0, 1], [1, 4], [1, 5], [0, 2], [2, 6], [2, 7], [0, 3], [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]],k = 10) == 22\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]],guesses = [[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], [3, 1], [5, 2], [10, 4], [7, 3], [13, 6]],k = 7) == 15\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 6) == 4\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],guesses = [[1, 0], [3, 4], [2, 1], [3, 2], [5, 6], [4, 5], [6, 7]],k = 4) == 7\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]],guesses = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]],k = 6) == 8\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],k = 9) == 0\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],guesses = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],k = 6) == 1\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],guesses = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [1, 0], [2, 0], [3, 0], [4, 1], [5, 1], [6, 2], [7, 2], [8, 3], [9, 3]],k = 7) == 10\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]],guesses = [[0, 1], [1, 3], [3, 7], [3, 8], [1, 4], [4, 9], [4, 10], [0, 2], [2, 5], [2, 6], [5, 11], [5, 12], [6, 13], [6, 14]],k = 7) == 15\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]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [2, 1], [6, 5], [10, 9]],k = 7) == 8\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],guesses = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 2], [5, 2], [6, 3], [7, 3]],k = 5) == 8\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 9) == 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], [12, 25], [12, 26]],guesses = [[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], [3, 2], [7, 6], [11, 10], [13, 14]],k = 12) == 27\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]],guesses = [[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, 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]],k = 10) == 15\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],guesses = [[0, 1], [1, 3], [2, 5], [1, 0], [4, 1], [6, 2]],k = 3) == 5\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],guesses = [[0, 1], [1, 3], [2, 5], [3, 7], [4, 9], [0, 2], [1, 4], [2, 6], [3, 8], [4, 10]],k = 3) == 11\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],guesses = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3]],k = 6) == 9\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [4, 7], [4, 8], [8, 9], [9, 10], [10, 11], [11, 12]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [4, 7], [4, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 6) == 7\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]],guesses = [[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]],k = 12) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],guesses = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 1], [5, 2], [4, 1], [6, 2]],k = 3) == 7\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],guesses = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 6], [6, 5], [6, 7], [7, 6]],k = 7) == 8\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 2], [1, 4]],k = 5) == 6\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],guesses = [[1, 0], [3, 1], [5, 3], [2, 1], [4, 2], [6, 5]],k = 3) == 1\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [4, 7], [4, 8]],guesses = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [4, 7], [4, 8]],k = 8) == 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]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],k = 5) == 6\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]],guesses = [[0, 1], [1, 3], [2, 5], [1, 0], [4, 1], [6, 2], [3, 7], [4, 9], [5, 11], [0, 2], [1, 4], [6, 14], [3, 8], [4, 10], [5, 12]],k = 7) == 15\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],k = 7) == 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]],guesses = [[0, 1], [1, 4], [2, 6], [3, 8], [4, 10], [0, 2], [1, 5], [2, 7], [3, 9], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],k = 10) == 22\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]],guesses = [[0, 1], [1, 4], [2, 6], [3, 8], [4, 10], [0, 2], [1, 5], [2, 7], [3, 9], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],k = 5) == 22\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],guesses = [[0, 1], [1, 4], [1, 5], [0, 2], [2, 6], [2, 7], [0, 3], [3, 8], [3, 9]],k = 5) == 10\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],guesses = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]],k = 5) == 10\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]],guesses = [[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], [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]],k = 15) == 31\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8]],guesses = [[0, 1], [1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8]],k = 8) == 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]],guesses = [[0, 1], [1, 2], [1, 3], [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]],k = 14) == 21\n"}, "metadata": {"canonical_parameter_names": ["edges", "guesses", "k"], "leetcode_dataset_entry_point": "Solution().rootCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int rootCount(int[][] edges, int[][] guesses, int k) {", "container": "Solution", "callable": "rootCount", "parameters": [{"name": "edges", "type": "int[][]"}, {"name": "guesses", "type": "int[][]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2582, "task_id": "pass-the-pillow", "difficulty": "Easy", "problem_description": "There are n people standing in a line labeled from 1 to n. The first person in the line is holding a pillow initially. Every second, the person holding the pillow passes it to the next person standing in the line. Once the pillow reaches the end of the line, the direction changes, and people continue passing the pillow in the opposite direction.\n\nFor example, once the pillow reaches the nth person they pass it to the n - 1th person, then to the n - 2th person and so on.\n\nGiven the two positive integers n and time, return the index of the person holding the pillow after time seconds.\n \nExample 1:\n\nInput: n = 4, time = 5\nOutput: 2\nExplanation: People pass the pillow in the following way: 1 -> 2 -> 3 -> 4 -> 3 -> 2.\nAfter five seconds, the 2nd person is holding the pillow.\n\nExample 2:\n\nInput: n = 3, time = 2\nOutput: 3\nExplanation: People pass the pillow in the following way: 1 -> 2 -> 3.\nAfter two seconds, the 3rd person is holding the pillow.\n\n \nConstraints:\n\n2 <= n <= 1000\n1 <= time <= 1000\n\n \nNote: This question is the same as 3178: Find the Child Who Has the Ball After K Seconds.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,time = 5) == 2\n assert candidate(n = 10,time = 15) == 4\n assert candidate(n = 500,time = 750) == 249\n assert candidate(n = 2,time = 1) == 2\n assert candidate(n = 7,time = 20) == 5\n assert candidate(n = 8,time = 20) == 7\n assert candidate(n = 5,time = 7) == 2\n assert candidate(n = 3,time = 2) == 3\n assert candidate(n = 6,time = 12) == 3\n assert candidate(n = 2,time = 2) == 1\n assert candidate(n = 1000,time = 1000) == 999\n assert candidate(n = 6,time = 1) == 2\n assert candidate(n = 8,time = 12) == 3\n assert candidate(n = 4,time = 5) == 2\n assert candidate(n = 600,time = 800) == 399\n assert candidate(n = 7,time = 49) == 2\n assert candidate(n = 15,time = 500) == 5\n assert candidate(n = 9,time = 50) == 3\n assert candidate(n = 15,time = 120) == 9\n assert candidate(n = 15,time = 100) == 13\n assert candidate(n = 100,time = 800) == 9\n assert candidate(n = 50,time = 1000) == 21\n assert candidate(n = 499,time = 1002) == 7\n assert candidate(n = 8,time = 45) == 4\n assert candidate(n = 20,time = 150) == 3\n assert candidate(n = 550,time = 725) == 374\n assert candidate(n = 500,time = 2500) == 495\n assert candidate(n = 15,time = 25) == 4\n assert candidate(n = 12,time = 150) == 5\n assert candidate(n = 499,time = 500) == 497\n assert candidate(n = 12,time = 60) == 7\n assert candidate(n = 15,time = 225) == 2\n assert candidate(n = 200,time = 400) == 3\n assert candidate(n = 999,time = 999) == 998\n assert candidate(n = 7,time = 1000) == 5\n assert candidate(n = 500,time = 1250) == 253\n assert candidate(n = 10,time = 100) == 9\n assert candidate(n = 20,time = 500) == 7\n assert candidate(n = 999,time = 998) == 999\n assert candidate(n = 6,time = 11) == 2\n assert candidate(n = 250,time = 1000) == 5\n assert candidate(n = 100,time = 150) == 49\n assert candidate(n = 2,time = 1000) == 1\n assert candidate(n = 1000,time = 2000) == 3\n assert candidate(n = 12,time = 30) == 9\n assert candidate(n = 850,time = 1500) == 199\n assert candidate(n = 450,time = 999) == 102\n assert candidate(n = 250,time = 1250) == 245\n assert candidate(n = 450,time = 675) == 224\n assert candidate(n = 100,time = 250) == 53\n assert candidate(n = 3,time = 9) == 2\n assert candidate(n = 450,time = 500) == 399\n assert candidate(n = 150,time = 500) == 97\n assert candidate(n = 18,time = 90) == 13\n assert candidate(n = 6,time = 13) == 4\n assert candidate(n = 12,time = 100) == 11\n assert candidate(n = 2,time = 100) == 1\n assert candidate(n = 250,time = 750) == 247\n assert candidate(n = 9,time = 150) == 7\n assert candidate(n = 20,time = 1000) == 13\n assert candidate(n = 6,time = 30) == 1\n assert candidate(n = 20,time = 199) == 10\n assert candidate(n = 100,time = 500) == 95\n assert candidate(n = 9,time = 40) == 9\n assert candidate(n = 8,time = 31) == 4\n assert candidate(n = 9,time = 25) == 8\n assert candidate(n = 20,time = 50) == 13\n assert candidate(n = 2,time = 2000) == 1\n assert candidate(n = 333,time = 998) == 331\n assert candidate(n = 8,time = 24) == 5\n assert candidate(n = 10,time = 25) == 8\n assert candidate(n = 30,time = 150) == 25\n assert candidate(n = 3,time = 999) == 2\n assert candidate(n = 999,time = 1998) == 3\n assert candidate(n = 9,time = 81) == 2\n assert candidate(n = 300,time = 550) == 49\n assert candidate(n = 300,time = 600) == 3\n assert candidate(n = 6,time = 101) == 2\n assert candidate(n = 25,time = 625) == 2\n assert candidate(n = 250,time = 1001) == 6\n assert candidate(n = 9,time = 18) == 3\n assert candidate(n = 1000,time = 999) == 1000\n assert candidate(n = 5,time = 25) == 2\n assert candidate(n = 12,time = 25) == 4\n assert candidate(n = 600,time = 999) == 200\n assert candidate(n = 8,time = 27) == 2\n assert candidate(n = 999,time = 1000) == 997\n assert candidate(n = 8,time = 100) == 3\n assert candidate(n = 750,time = 2001) == 504\n assert candidate(n = 2,time = 500) == 1\n assert candidate(n = 8,time = 30) == 3\n assert candidate(n = 600,time = 900) == 299\n assert candidate(n = 25,time = 250) == 11\n assert candidate(n = 500,time = 1001) == 4\n"}, "metadata": {"canonical_parameter_names": ["n", "time"], "leetcode_dataset_entry_point": "Solution().passThePillow", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int passThePillow(int n, int time) {", "container": "Solution", "callable": "passThePillow", "parameters": [{"name": "n", "type": "int"}, {"name": "time", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2583, "task_id": "kth-largest-sum-in-a-binary-tree", "difficulty": "Medium", "problem_description": "You are given the root of a binary tree and a positive integer k.\nThe level sum in the tree is the sum of the values of the nodes that are on the same level.\nReturn the kth largest level sum in the tree (not necessarily distinct). If there are fewer than k levels in the tree, return -1.\nNote that two nodes are on the same level if they have the same distance from the root.\n \nExample 1:\n\n\nInput: root = [5,8,9,2,1,3,7,4,6], k = 2\nOutput: 13\nExplanation: The level sums are the following:\n- Level 1: 5.\n- Level 2: 8 + 9 = 17.\n- Level 3: 2 + 1 + 3 + 7 = 13.\n- Level 4: 4 + 6 = 10.\nThe 2nd largest level sum is 13.\n\nExample 2:\n\n\nInput: root = [1,2,null,3], k = 1\nOutput: 3\nExplanation: The largest level sum is 3.\n\n \nConstraints:\n\nThe number of nodes in the tree is n.\n2 <= n <= 105\n1 <= Node.val <= 106\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 5) == -1\n assert candidate(root = tree_node([5, 2, 3, None, None, 1, 6, 4, None, None, None, None, 7]),k = 3) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 4) == 1\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7, 8, None, None, None, None, 11]),k = 4) == 8\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18]),k = 3) == 10\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18]),k = 2) == 20\n assert candidate(root = tree_node([7, 10, 11, 2, 4, 5, 3, None, None, None, None, None, None, 1]),k = 4) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 5) == -1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5]),k = 3) == 3\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 17, 19]),k = 3) == 20\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 14, 18, 25]),k = 4) == 10\n assert candidate(root = tree_node([5, 3, 8, 1, 4, 7, 9, 2, 6, None, None, None, None, None, None, None, 10]),k = 5) == 5\n assert candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 4) == 6\n assert candidate(root = tree_node([1, 3, 2, 5, 6, 3, 9]),k = 2) == 5\n assert candidate(root = tree_node([10, 20, 30, 40, 50, 60, 70]),k = 4) == -1\n assert candidate(root = tree_node([1, 3, 2, 5]),k = 2) == 5\n assert candidate(root = tree_node([5, 8, 9, 2, 1, 3, 7, 4, 6]),k = 2) == 13\n assert candidate(root = tree_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),k = 4) == 10\n assert candidate(root = tree_node([1, 3, 2, 15, 20, 7]),k = 2) == 5\n assert candidate(root = tree_node([1, 2, 2, 3, 3, 3, 3]),k = 2) == 4\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7]),k = 2) == 22\n assert candidate(root = tree_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]),k = 5) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 3) == 22\n assert candidate(root = tree_node([1, 3, 2, 5, 6, 7, 8]),k = 3) == 1\n assert candidate(root = tree_node([1, 3, 2, 5, 6, 7, 4]),k = 4) == -1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 3) == 5\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7]),k = 1) == 29\n assert candidate(root = tree_node([1, 2, None, 3]),k = 1) == 3\n assert candidate(root = tree_node([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]),k = 4) == 7\n assert candidate(root = tree_node([1, 3, 2, 5, 6, 7]),k = 3) == 1\n assert candidate(root = tree_node([7, 3, 15, None, None, 9, 20, None, None, 11, 17]),k = 4) == 7\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5]),k = 2) == 4\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, None, 1, None, None, None]),k = 5) == -1\n assert candidate(root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 5) == -1\n assert candidate(root = tree_node([100, 90, 80, 70, 60, 50, 40, 30, 20, 10]),k = 5) == -1\n assert candidate(root = tree_node([5, 2, 6, None, 4, None, 8]),k = 2) == 8\n assert candidate(root = tree_node([5, 3, 8, 2, 4, 7, 9]),k = 6) == -1\n assert candidate(root = tree_node([7, 3, 15, None, None, 9, 20, None, None, 8, 16, 18, 25]),k = 5) == 7\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5]),k = 3) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),k = 3) == 1\n assert candidate(root = tree_node([5, 2, 6, 1, None, 4, None, None, 3, None, None, None, 7]),k = 2) == 7\n assert candidate(root = tree_node([1]),k = 1) == 1\n assert candidate(root = tree_node([6, 10, 2, None, 8, 3, 3, None, None, 1, 5, None, None, 9, 7, None, 4, 6, None, None, None, 2]),k = 3) == 12\n assert candidate(root = tree_node([5, 2, 13, None, 8, None, None, None, 9]),k = 1) == 15\n assert candidate(root = tree_node([5, 2, -3]),k = 1) == 5\n"}, "metadata": {"canonical_parameter_names": ["root", "k"], "leetcode_dataset_entry_point": "Solution().kthLargestLevelSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2584, "task_id": "split-the-array-to-make-coprime-products", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums of length n.\nA split at an index i where 0 <= i <= n - 2 is called valid if the product of the first i + 1 elements and the product of the remaining elements are coprime.\n\nFor example, if nums = [2, 3, 3], then a split at the index i = 0 is valid because 2 and 9 are coprime, while a split at the index i = 1 is not valid because 6 and 3 are not coprime. A split at the index i = 2 is not valid because i == n - 1.\n\nReturn the smallest index i at which the array can be split validly or -1 if there is no such split.\nTwo values val1 and val2 are coprime if gcd(val1, val2) == 1 where gcd(val1, val2) is the greatest common divisor of val1 and val2.\n \nExample 1:\n\n\nInput: nums = [4,7,8,15,3,5]\nOutput: 2\nExplanation: The table above shows the values of the product of the first i + 1 elements, the remaining elements, and their gcd at each index i.\nThe only valid split is at index 2.\n\nExample 2:\n\n\nInput: nums = [4,7,15,8,3,5]\nOutput: -1\nExplanation: The table above shows the values of the product of the first i + 1 elements, the remaining elements, and their gcd at each index i.\nThere is no valid split.\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 104\n1 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [60, 1, 2, 3]) == -1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12]) == -1\n assert candidate(nums = [30, 35, 14]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [60, 45, 10]) == -1\n assert candidate(nums = [1000000, 1000000]) == -1\n assert candidate(nums = [18, 5, 100]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums = [4, 7, 15, 8, 3, 5]) == -1\n assert candidate(nums = [4, 7, 8, 15, 3, 5]) == 2\n assert candidate(nums = [13, 17, 19, 23, 29]) == 0\n assert candidate(nums = [7, 3, 5, 2, 10]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums = [6, 10, 15, 21, 28, 35]) == -1\n assert candidate(nums = [30, 30, 30, 30]) == -1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == -1\n assert candidate(nums = [2, 2, 2, 2]) == -1\n assert candidate(nums = [7, 11, 13, 17, 19, 23]) == 0\n assert candidate(nums = [60, 45, 105, 30, 20]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11]) == 0\n assert candidate(nums = [30, 30, 30, 30, 30, 30]) == -1\n assert candidate(nums = [3, 9, 7, 11, 13]) == 1\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == -1\n assert candidate(nums = [60, 105, 210, 315, 420, 525, 630, 735, 840, 945]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == -1\n assert candidate(nums = [18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == -1\n assert candidate(nums = [1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129]) == 0\n assert candidate(nums = [999983, 999989, 999991, 999997, 1000003, 1000033, 1000037, 1000039, 1000081, 1000099]) == 0\n assert candidate(nums = [60, 105, 56, 21, 10, 14]) == -1\n assert candidate(nums = [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]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == -1\n assert candidate(nums = [2, 3, 4, 6, 8, 12, 18, 24, 36, 48, 72, 144]) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == -1\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == -1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == -1\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996]) == -1\n assert candidate(nums = [8, 12, 18, 24, 30, 36]) == -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]) == -1\n assert candidate(nums = [210, 330, 420, 462, 546, 630, 714, 840, 924, 1092, 1260]) == -1\n assert candidate(nums = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180]) == -1\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 33, 35, 38, 39, 45, 46, 51, 55]) == -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]) == -1\n assert candidate(nums = [97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167]) == 0\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == -1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == -1\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187]) == -1\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625]) == -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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = [11, 22, 33, 44, 55, 66, 77, 88, 99]) == -1\n assert candidate(nums = [18, 24, 30, 42, 56, 70, 84, 98, 112, 126]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == -1\n assert candidate(nums = [6, 10, 15, 21, 35, 70]) == -1\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 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]) == 0\n assert candidate(nums = [6, 10, 15, 21, 28, 35, 42, 50, 56, 63, 70, 77, 84, 90, 91]) == -1\n assert candidate(nums = [987654, 321654, 123456, 654321, 789012, 369258, 456789]) == -1\n assert candidate(nums = [15, 21, 35, 14, 30, 63, 70, 90, 105, 140]) == -1\n assert candidate(nums = [9973, 9967, 9979, 9983, 9971, 9989]) == 0\n assert candidate(nums = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020]) == -1\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26]) == -1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == -1\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 8\n assert candidate(nums = [1024, 512, 256, 128, 64, 32]) == -1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10]) == -1\n assert candidate(nums = [60, 70, 84, 90, 105, 110, 130, 154, 165, 210, 220, 231, 286, 315, 330, 385, 462, 495, 550, 770, 840, 924, 990, 1155, 1320, 1430, 1540, 1650, 2145, 2310, 2640, 2772, 2970, 3300, 3960, 4290, 4620, 4950, 6600, 7260, 7920, 8580, 9900]) == -1\n assert candidate(nums = [999983, 999989, 999991, 999997, 1000003, 1000009, 1000021, 1000033, 1000037, 1000039]) == 0\n assert candidate(nums = [840, 720, 600, 480, 360, 240, 120, 60, 30, 15, 5]) == -1\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005]) == -1\n assert candidate(nums = [2310, 30030, 510510, 9699690, 223092870, 6469693230]) == -1\n assert candidate(nums = [60, 35, 28, 15, 45, 70]) == -1\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == -1\n assert candidate(nums = [99, 121, 165, 495, 605, 1210]) == -1\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == -1\n assert candidate(nums = [121, 143, 169, 187, 209, 221, 247, 253, 299, 323, 341]) == -1\n assert candidate(nums = [143, 169, 187, 221, 247, 299, 323, 341, 377, 391, 437, 451, 481, 493, 529]) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 0\n assert candidate(nums = [50, 75, 100, 125, 150, 175, 200, 225, 250, 275]) == -1\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995]) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == 0\n assert candidate(nums = [23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23]) == -1\n assert candidate(nums = [840, 924, 1008, 1092, 1176, 1260, 1344, 1428, 1512, 1608]) == -1\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 8\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]) == 0\n assert candidate(nums = [60, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == -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, 42, 44, 46, 48, 50]) == -1\n assert candidate(nums = [84, 132, 220, 154, 385]) == -1\n assert candidate(nums = [12, 15, 21, 25, 30, 35, 42]) == -1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == -1\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147]) == -1\n assert candidate(nums = [999983, 999979, 999961, 999959, 999953, 999943]) == 0\n assert candidate(nums = [60, 105, 140, 210, 35, 10]) == -1\n assert candidate(nums = [42, 63, 84, 105, 126, 147]) == -1\n assert candidate(nums = [121, 143, 169, 187, 209, 221, 247, 253, 299, 319]) == -1\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480]) == -1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 9\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000]) == -1\n assert candidate(nums = [210, 330, 55, 14, 22, 110]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findValidSplit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findValidSplit(int[] nums) {", "container": "Solution", "callable": "findValidSplit", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2585, "task_id": "number-of-ways-to-earn-points", "difficulty": "Hard", "problem_description": "There is a test that has n types of questions. You are given an integer target and a 0-indexed 2D integer array types where types[i] = [counti, marksi] indicates that there are counti questions of the ith type, and each one of them is worth marksi points.\n\n\nReturn the number of ways you can earn exactly target points in the exam. Since the answer may be too large, return it modulo 109 + 7.\nNote that questions of the same type are indistinguishable.\n\nFor example, if there are 3 questions of the same type, then solving the 1st and 2nd questions is the same as solving the 1st and 3rd questions, or the 2nd and 3rd questions.\n\n \nExample 1:\n\nInput: target = 6, types = [[6,1],[3,2],[2,3]]\nOutput: 7\nExplanation: You can earn 6 points in one of the seven ways:\n- Solve 6 questions of the 0th type: 1 + 1 + 1 + 1 + 1 + 1 = 6\n- Solve 4 questions of the 0th type and 1 question of the 1st type: 1 + 1 + 1 + 1 + 2 = 6\n- Solve 2 questions of the 0th type and 2 questions of the 1st type: 1 + 1 + 2 + 2 = 6\n- Solve 3 questions of the 0th type and 1 question of the 2nd type: 1 + 1 + 1 + 3 = 6\n- Solve 1 question of the 0th type, 1 question of the 1st type and 1 question of the 2nd type: 1 + 2 + 3 = 6\n- Solve 3 questions of the 1st type: 2 + 2 + 2 = 6\n- Solve 2 questions of the 2nd type: 3 + 3 = 6\n\nExample 2:\n\nInput: target = 5, types = [[50,1],[50,2],[50,5]]\nOutput: 4\nExplanation: You can earn 5 points in one of the four ways:\n- Solve 5 questions of the 0th type: 1 + 1 + 1 + 1 + 1 = 5\n- Solve 3 questions of the 0th type and 1 question of the 1st type: 1 + 1 + 1 + 2 = 5\n- Solve 1 questions of the 0th type and 2 questions of the 1st type: 1 + 2 + 2 = 5\n- Solve 1 question of the 2nd type: 5\n\nExample 3:\n\nInput: target = 18, types = [[6,1],[3,2],[2,3]]\nOutput: 1\nExplanation: You can only earn 18 points by answering all questions.\n\n \nConstraints:\n\n1 <= target <= 1000\nn == types.length\n1 <= n <= 50\ntypes[i].length == 2\n1 <= counti, marksi <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = 10,types = [[2, 5], [1, 3]]) == 1\n assert candidate(target = 1,types = [[1, 1]]) == 1\n assert candidate(target = 30,types = [[5, 10], [3, 5], [2, 15]]) == 5\n assert candidate(target = 750,types = [[50, 15], [50, 25], [50, 35]]) == 119\n assert candidate(target = 20,types = [[2, 5], [3, 10], [4, 20]]) == 3\n assert candidate(target = 10,types = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]) == 3\n assert candidate(target = 5,types = [[50, 1], [50, 2], [50, 5]]) == 4\n assert candidate(target = 10,types = [[10, 1], [5, 2]]) == 6\n assert candidate(target = 100,types = [[10, 5], [10, 10], [10, 15], [10, 20]]) == 90\n assert candidate(target = 20,types = [[2, 5], [2, 10], [3, 15]]) == 3\n assert candidate(target = 6,types = [[6, 1], [3, 2], [2, 3]]) == 7\n assert candidate(target = 10,types = [[10, 1], [5, 2], [3, 3]]) == 14\n assert candidate(target = 20,types = [[1, 10], [2, 5], [3, 2]]) == 1\n assert candidate(target = 1000,types = [[100, 10], [100, 20], [100, 30], [100, 40]]) == 8037\n assert candidate(target = 20,types = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]) == 0\n assert candidate(target = 18,types = [[6, 1], [3, 2], [2, 3]]) == 1\n assert candidate(target = 20,types = [[5, 10], [3, 5], [2, 2]]) == 2\n assert candidate(target = 500,types = [[20, 10], [30, 20], [40, 30], [10, 50]]) == 721\n assert candidate(target = 500,types = [[20, 10], [20, 15], [20, 20], [20, 25], [20, 30]]) == 6939\n assert candidate(target = 450,types = [[50, 3], [50, 6], [50, 9], [50, 12], [50, 15]]) == 165604\n assert candidate(target = 400,types = [[20, 5], [20, 10], [20, 15], [20, 20], [20, 25]]) == 12066\n assert candidate(target = 650,types = [[40, 10], [30, 15], [20, 20], [10, 25], [5, 30], [2, 35], [1, 40]]) == 56729\n assert candidate(target = 700,types = [[25, 5], [30, 10], [35, 15], [40, 20], [45, 25], [50, 30], [55, 35], [60, 40], [65, 45], [70, 50], [75, 55]]) == 124162326\n assert candidate(target = 800,types = [[15, 5], [25, 10], [35, 15], [45, 20], [55, 25]]) == 59531\n assert candidate(target = 600,types = [[50, 50], [50, 100], [50, 150], [50, 200]]) == 34\n assert candidate(target = 999,types = [[49, 1], [49, 2], [49, 3], [49, 4], [49, 5]]) == 0\n assert candidate(target = 650,types = [[30, 20], [30, 21], [30, 22], [30, 23], [30, 24]]) == 2012\n assert candidate(target = 700,types = [[25, 28], [25, 29], [25, 30], [25, 31], [25, 32]]) == 624\n assert candidate(target = 200,types = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 90\n assert candidate(target = 300,types = [[30, 10], [20, 20], [40, 30], [10, 40], [30, 50]]) == 674\n assert candidate(target = 300,types = [[50, 10], [30, 15], [20, 20], [10, 25], [5, 30], [2, 35]]) == 2734\n assert candidate(target = 600,types = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30]]) == 124635\n assert candidate(target = 600,types = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]) == 0\n assert candidate(target = 250,types = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5]]) == 692188\n assert candidate(target = 550,types = [[25, 10], [25, 20], [25, 30], [25, 40], [25, 50]]) == 4654\n assert candidate(target = 250,types = [[15, 5], [15, 10], [15, 15], [15, 20], [15, 25], [15, 30], [15, 35], [15, 40], [15, 45], [15, 50], [15, 55], [15, 60], [15, 65], [15, 70], [15, 75]]) == 129491\n assert candidate(target = 950,types = [[100, 9], [100, 18], [100, 27], [100, 36], [100, 45]]) == 0\n assert candidate(target = 450,types = [[30, 5], [30, 10], [30, 15], [30, 20], [30, 25], [30, 30], [30, 35], [30, 40], [30, 45], [30, 50], [30, 55], [30, 60]]) == 6856397\n assert candidate(target = 650,types = [[50, 10], [60, 20], [70, 30], [80, 40], [90, 50], [100, 60], [110, 70]]) == 65012\n assert candidate(target = 800,types = [[10, 80], [20, 40], [30, 20], [40, 10], [50, 5]]) == 26045\n assert candidate(target = 600,types = [[50, 1], [50, 2], [50, 4], [50, 8]]) == 6711\n assert candidate(target = 350,types = [[25, 5], [25, 15], [25, 25], [25, 35]]) == 530\n assert candidate(target = 550,types = [[15, 10], [15, 20], [15, 30], [15, 40], [15, 50], [15, 60], [15, 70]]) == 22303\n assert candidate(target = 900,types = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]]) == 0\n assert candidate(target = 700,types = [[40, 10], [30, 20], [20, 30], [10, 40]]) == 2426\n assert candidate(target = 800,types = [[15, 20], [25, 30], [10, 40], [20, 50]]) == 574\n assert candidate(target = 600,types = [[25, 10], [25, 20], [25, 30], [25, 40], [25, 50], [25, 60]]) == 17893\n assert candidate(target = 300,types = [[20, 10], [30, 15], [40, 25], [50, 30]]) == 276\n assert candidate(target = 500,types = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == 34142\n assert candidate(target = 350,types = [[15, 7], [15, 14], [15, 21], [15, 28], [15, 35]]) == 2610\n assert candidate(target = 800,types = [[50, 5], [50, 10], [50, 15], [50, 20]]) == 19178\n assert candidate(target = 250,types = [[25, 5], [25, 10], [25, 15], [25, 20], [25, 25]]) == 3432\n assert candidate(target = 700,types = [[50, 10], [50, 20], [50, 30], [50, 40], [50, 50]]) == 12306\n assert candidate(target = 450,types = [[50, 5], [50, 15], [50, 25], [50, 35], [50, 45], [50, 55]]) == 11092\n assert candidate(target = 1000,types = [[20, 50], [15, 60], [10, 70], [5, 80], [10, 90]]) == 451\n assert candidate(target = 650,types = [[50, 10], [40, 20], [30, 30], [20, 40], [10, 50], [5, 60], [3, 70], [2, 80], [1, 90]]) == 157298\n assert candidate(target = 700,types = [[25, 5], [25, 10], [25, 15], [25, 20], [25, 25], [25, 30], [25, 35], [25, 40], [25, 45], [25, 50]]) == 56776700\n assert candidate(target = 999,types = [[30, 5], [20, 10], [40, 20], [30, 25]]) == 0\n assert candidate(target = 400,types = [[20, 25], [30, 50], [25, 75], [40, 100], [30, 125]]) == 101\n assert candidate(target = 500,types = [[15, 5], [25, 10], [35, 15], [45, 20]]) == 2461\n assert candidate(target = 700,types = [[50, 1], [50, 3], [50, 7], [50, 11], [50, 13], [50, 17], [50, 19]]) == 53354051\n assert candidate(target = 400,types = [[25, 4], [25, 8], [25, 12], [25, 16], [25, 20]]) == 27739\n assert candidate(target = 550,types = [[45, 15], [55, 25], [65, 35], [75, 45], [85, 55], [95, 65]]) == 2608\n assert candidate(target = 1000,types = [[50, 1], [50, 3], [50, 7], [50, 11], [50, 13]]) == 433268\n assert candidate(target = 250,types = [[20, 1], [30, 2], [20, 3], [10, 4], [10, 5], [5, 6]]) == 35\n assert candidate(target = 450,types = [[30, 10], [40, 20], [50, 30], [60, 40], [70, 50], [80, 60]]) == 5852\n assert candidate(target = 650,types = [[50, 10], [50, 20], [50, 30], [50, 40], [50, 50]]) == 9472\n assert candidate(target = 800,types = [[40, 10], [50, 20], [60, 30], [70, 40], [80, 50]]) == 18680\n assert candidate(target = 700,types = [[5, 50], [10, 100], [15, 150], [20, 200], [25, 250]]) == 52\n assert candidate(target = 450,types = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10]]) == 909681426\n assert candidate(target = 500,types = [[25, 20], [25, 30], [25, 40], [25, 50]]) == 258\n assert candidate(target = 350,types = [[20, 10], [20, 20], [20, 30], [20, 40], [20, 50], [20, 60], [20, 70], [20, 80]]) == 4950\n assert candidate(target = 400,types = [[50, 20], [30, 15], [20, 10], [10, 5]]) == 1129\n assert candidate(target = 600,types = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10]]) == 209801687\n assert candidate(target = 450,types = [[15, 30], [20, 25], [25, 20], [30, 15], [35, 10]]) == 5753\n assert candidate(target = 500,types = [[30, 10], [20, 15], [10, 20], [5, 25]]) == 535\n assert candidate(target = 300,types = [[15, 5], [15, 10], [15, 15], [15, 20], [15, 25], [15, 30], [15, 35], [15, 40], [15, 45]]) == 108177\n assert candidate(target = 200,types = [[20, 10], [20, 20], [20, 30], [20, 40]]) == 108\n assert candidate(target = 800,types = [[30, 25], [40, 50], [20, 75]]) == 101\n assert candidate(target = 900,types = [[20, 10], [30, 20], [10, 30], [20, 40]]) == 1725\n assert candidate(target = 500,types = [[20, 25], [20, 30], [20, 35], [20, 40], [20, 45]]) == 520\n assert candidate(target = 900,types = [[100, 9], [100, 10], [100, 11], [100, 12], [100, 13]]) == 199590\n assert candidate(target = 550,types = [[15, 5], [25, 10], [35, 15], [45, 20], [55, 25], [65, 30], [75, 35], [85, 40], [95, 45], [105, 50]]) == 8359201\n assert candidate(target = 600,types = [[50, 12], [50, 14], [50, 16], [50, 18], [50, 20]]) == 14453\n assert candidate(target = 999,types = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15]]) == 805840421\n assert candidate(target = 550,types = [[40, 5], [40, 10], [40, 15], [30, 20], [20, 25], [10, 30]]) == 249864\n assert candidate(target = 800,types = [[40, 10], [30, 20], [20, 30], [10, 40], [5, 50]]) == 13462\n assert candidate(target = 900,types = [[30, 5], [30, 15], [30, 25], [30, 35], [30, 45], [30, 55], [30, 65], [30, 75], [30, 85], [30, 95]]) == 5111100\n assert candidate(target = 800,types = [[60, 20], [70, 40], [80, 60], [90, 80]]) == 632\n assert candidate(target = 850,types = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]]) == 117144248\n assert candidate(target = 800,types = [[50, 1], [50, 3], [50, 5], [50, 7], [50, 9]]) == 485554\n assert candidate(target = 600,types = [[50, 5], [50, 10], [50, 15], [50, 20], [50, 25]]) == 79630\n assert candidate(target = 700,types = [[30, 15], [30, 25], [30, 35], [30, 45], [30, 55]]) == 2386\n assert candidate(target = 1000,types = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5]]) == 0\n assert candidate(target = 900,types = [[25, 30], [35, 45], [45, 60], [50, 75]]) == 414\n assert candidate(target = 300,types = [[60, 5], [60, 6], [60, 7], [60, 8], [60, 9]]) == 27971\n assert candidate(target = 400,types = [[25, 1], [25, 2], [25, 3], [25, 4], [25, 5], [25, 6], [25, 7], [25, 8]]) == 683239099\n assert candidate(target = 300,types = [[20, 5], [30, 10], [10, 15]]) == 116\n assert candidate(target = 250,types = [[50, 5], [50, 10], [50, 15], [50, 20], [50, 25]]) == 3765\n assert candidate(target = 600,types = [[30, 10], [20, 20], [10, 30], [5, 40]]) == 858\n assert candidate(target = 300,types = [[10, 2], [20, 3], [30, 5], [40, 7], [50, 11]]) == 18034\n assert candidate(target = 900,types = [[50, 1], [50, 2], [50, 5], [50, 10]]) == 1\n assert candidate(target = 900,types = [[50, 15], [40, 25], [30, 35], [20, 45], [10, 55], [5, 65]]) == 19430\n assert candidate(target = 400,types = [[20, 10], [20, 20], [20, 30], [20, 40], [20, 50]]) == 1583\n assert candidate(target = 400,types = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6]]) == 2270071\n assert candidate(target = 500,types = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 48055\n assert candidate(target = 400,types = [[80, 5], [80, 10], [80, 15], [80, 20], [80, 25]]) == 20282\n assert candidate(target = 700,types = [[40, 10], [50, 20], [60, 30], [70, 40], [80, 50]]) == 11867\n assert candidate(target = 300,types = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7]]) == 19837096\n assert candidate(target = 250,types = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]) == 57127\n assert candidate(target = 800,types = [[40, 10], [30, 20], [20, 30], [10, 40]]) == 3041\n assert candidate(target = 950,types = [[5, 100], [10, 50], [15, 33], [20, 25], [25, 20], [30, 16], [35, 14], [40, 12], [45, 11], [50, 10]]) == 240007134\n assert candidate(target = 200,types = [[10, 5], [10, 10], [10, 15], [10, 20], [10, 25]]) == 1003\n assert candidate(target = 600,types = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10]]) == 209801687\n assert candidate(target = 300,types = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 203\n assert candidate(target = 900,types = [[20, 5], [30, 10], [40, 15], [10, 20], [10, 25]]) == 21573\n assert candidate(target = 750,types = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10]]) == 450083451\n"}, "metadata": {"canonical_parameter_names": ["target", "types"], "leetcode_dataset_entry_point": "Solution().waysToReachTarget", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int waysToReachTarget(int target, int[][] types) {", "container": "Solution", "callable": "waysToReachTarget", "parameters": [{"name": "target", "type": "int"}, {"name": "types", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2586, "task_id": "count-the-number-of-vowel-strings-in-range", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array of string words and two integers left and right.\nA string is called a vowel string if it starts with a vowel character and ends with a vowel character where vowel characters are 'a', 'e', 'i', 'o', and 'u'.\nReturn the number of vowel strings words[i] where i belongs to the inclusive range [left, right].\n \nExample 1:\n\nInput: words = [\"are\",\"amy\",\"u\"], left = 0, right = 2\nOutput: 2\nExplanation: \n- \"are\" is a vowel string because it starts with 'a' and ends with 'e'.\n- \"amy\" is not a vowel string because it does not end with a vowel.\n- \"u\" is a vowel string because it starts with 'u' and ends with 'u'.\nThe number of vowel strings in the mentioned range is 2.\n\nExample 2:\n\nInput: words = [\"hey\",\"aeo\",\"mu\",\"ooo\",\"artro\"], left = 1, right = 4\nOutput: 3\nExplanation: \n- \"aeo\" is a vowel string because it starts with 'a' and ends with 'o'.\n- \"mu\" is not a vowel string because it does not start with a vowel.\n- \"ooo\" is a vowel string because it starts with 'o' and ends with 'o'.\n- \"artro\" is a vowel string because it starts with 'a' and ends with 'o'.\nThe number of vowel strings in the mentioned range is 3.\n\n \nConstraints:\n\n1 <= words.length <= 1000\n1 <= words[i].length <= 10\nwords[i] consists of only lowercase English letters.\n0 <= left <= right < words.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['sky', 'fly', 'why'],left = 0,right = 2) == 0\n assert candidate(words = ['apple', 'banana', 'orange', 'umbrella'],left = 0,right = 3) == 3\n assert candidate(words = ['are', 'amy', 'u'],left = 0,right = 2) == 2\n assert candidate(words = ['hey', 'aeo', 'mu', 'ooo', 'artro'],left = 1,right = 4) == 3\n assert candidate(words = ['up', 'open', 'over'],left = 1,right = 2) == 0\n assert candidate(words = ['ae', 'ea', 'ei', 'ie', 'ou'],left = 0,right = 4) == 5\n assert candidate(words = ['aeiou', 'uoiea', 'aeiou', 'uoiea', 'aeiou', 'uoiea'],left = 0,right = 5) == 6\n assert candidate(words = ['sky', 'fly', 'why', 'a', 'e'],left = 0,right = 4) == 2\n assert candidate(words = ['umbrella', 'encyclopedia', 'analysis', 'outstanding', 'initiative'],left = 1,right = 3) == 1\n assert candidate(words = ['ocean', 'mountain', 'forest', 'desert', 'rain'],left = 0,right = 4) == 0\n assert candidate(words = ['beautiful', 'world', 'with', 'diverse', 'languages'],left = 2,right = 4) == 0\n assert candidate(words = ['aeiou', 'uoiea', 'uiaeou', 'ouaei', 'eioua'],left = 0,right = 4) == 5\n assert candidate(words = ['xylophone', 'zephyr', 'orchestra', 'xylophone', 'aeiou', 'uoiea', 'uoiea'],left = 0,right = 6) == 4\n assert candidate(words = ['aaa', 'eee', 'iii', 'ooo', 'uuu', 'aaee', 'eeaa', 'aeea', 'aaea', 'eeea', 'eaae', 'eaeaa', 'aeaae', 'aaeae'],left = 0,right = 13) == 14\n assert candidate(words = ['queue', 'adieu', 'ice', 'ocean', 'earth'],left = 0,right = 3) == 2\n assert candidate(words = ['umbrella', 'moon', 'noon', 'noon', 'moon'],left = 2,right = 4) == 0\n assert candidate(words = ['algorithm', 'education', 'umbrella', 'icecream', 'operation', 'university'],left = 1,right = 5) == 1\n assert candidate(words = ['umbrella', 'opposite', 'idea', 'encyclopedia', 'algorithm', 'umbrella', 'opposite', 'idea', 'encyclopedia', 'algorithm'],left = 3,right = 7) == 4\n assert candidate(words = ['elephant', 'umbrella', 'apple', 'orange', 'ice', 'echo', 'umbrella'],left = 1,right = 6) == 6\n assert candidate(words = ['aviation', 'exhibition', 'occasion', 'environment', 'instrumentation'],left = 1,right = 3) == 0\n assert candidate(words = ['vowel', 'nonvowel', 'aeiou', 'bvowel', 'endvowel'],left = 0,right = 4) == 1\n assert candidate(words = ['aabb', 'abba', 'baab', 'baba', 'abab'],left = 0,right = 4) == 1\n assert candidate(words = ['example', 'samples', 'tests', 'inputs', 'outputs'],left = 0,right = 4) == 1\n assert candidate(words = ['xyz', 'uvw', 'qwe', 'rty', 'poi'],left = 0,right = 4) == 0\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'],left = 0,right = 24) == 5\n assert candidate(words = ['environment', 'umbrella', 'education', 'algorithm', 'university', 'encyclopedia'],left = 2,right = 5) == 1\n assert candidate(words = ['beautiful', 'enormous', 'interesting', 'unexpected', 'odd'],left = 2,right = 4) == 0\n assert candidate(words = ['sequence', 'equal', 'education', 'algorithm', 'encyclopedia'],left = 0,right = 3) == 0\n assert candidate(words = ['eeeee', 'aaaaa', 'iiiii', 'ooooo', 'uuuuu', 'auaeu', 'eiaie', 'ouioo', 'uaeuu', 'ieoia'],left = 2,right = 9) == 8\n assert candidate(words = ['abcdefgh', 'ijklmnop', 'qrstuvwxyz', 'zyxwvutsr', 'qrstponmlkjihgfedcba'],left = 0,right = 4) == 0\n assert candidate(words = ['banana', 'orange', 'grape', 'kiwi', 'pear', 'peach', 'plum', 'grapefruit', 'blueberry', 'cherry'],left = 3,right = 9) == 0\n assert candidate(words = ['racecar', 'level', 'rotor', 'kayak', 'reviler'],left = 1,right = 4) == 0\n assert candidate(words = ['aerodynamic', 'encyclopedia', 'umbrella', 'idea', 'audio'],left = 1,right = 4) == 4\n assert candidate(words = ['umbrella', 'map', 'python', 'algorithm', 'encyclopedia'],left = 1,right = 4) == 1\n assert candidate(words = ['umbrella', 'opposite', 'idea', 'encyclopedia', 'algorithm'],left = 1,right = 4) == 3\n assert candidate(words = ['quick', 'brown', 'fox', 'jumps', 'over', 'lazy', 'dog'],left = 1,right = 5) == 0\n assert candidate(words = ['aardvark', 'elephant', 'iguana', 'okapi', 'umbrella'],left = 0,right = 4) == 3\n assert candidate(words = ['vowel', 'voewl', 'ovwle', 'wolve', 'volve'],left = 0,right = 4) == 1\n assert candidate(words = ['beautiful', 'umbrella', 'innovative', 'economic', 'outstanding', 'underwater'],left = 0,right = 5) == 2\n assert candidate(words = ['applepie', 'banana', 'orangejuice', 'grape', 'peach'],left = 1,right = 3) == 1\n assert candidate(words = ['ar', 'er', 'ir', 'or', 'ur'],left = 1,right = 4) == 0\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u'],left = 0,right = 9) == 10\n assert candidate(words = ['sequence', 'development', 'environment', 'assignment', 'information'],left = 1,right = 3) == 0\n assert candidate(words = ['a', 'e', 'i', 'o', 'u', 'aeiou'],left = 0,right = 5) == 6\n assert candidate(words = ['racecar', 'level', 'rotor', 'deified', 'repaper'],left = 1,right = 4) == 0\n assert candidate(words = ['orchid', 'ocean', 'octopus', 'ostrich', 'oak', 'oceanography'],left = 0,right = 5) == 0\n assert candidate(words = ['volcano', 'trident', 'ozone', 'ocean', 'mountain'],left = 2,right = 4) == 1\n assert candidate(words = ['zzzzz', 'yyyyy', 'xxxxx', 'wwwww', 'vvvvv'],left = 0,right = 4) == 0\n assert candidate(words = ['banana', 'anana', 'nana', 'ana', 'na', 'a'],left = 0,right = 9) == 3\n assert candidate(words = ['education', 'university', 'algorithm', 'openai'],left = 1,right = 3) == 1\n assert candidate(words = ['aeiou', 'bcd', 'efg', 'hij', 'klm', 'nop', 'qrst', 'uvw', 'xyz'],left = 2,right = 7) == 0\n assert candidate(words = ['aardvark', 'algorithm', 'antelope', 'antenna', 'apple', 'antiquity', 'apricot', 'atlas'],left = 1,right = 7) == 3\n assert candidate(words = ['algorithm', 'evaluation', 'interview', 'education', 'optimization'],left = 0,right = 4) == 0\n assert candidate(words = ['aeiou', 'uoiea', 'iouea', 'uaieo', 'oieau', 'aeo', 'uoiea', 'uoiea', 'uoiea', 'uoiea', 'uoiea', 'uoiea'],left = 0,right = 11) == 12\n assert candidate(words = ['abracadabra', 'alabama', 'alaska', 'aerodynamic', 'algorithm', 'azalea'],left = 1,right = 5) == 3\n assert candidate(words = ['start', 'end', 'begin', 'finish', 'conclude'],left = 0,right = 4) == 0\n assert candidate(words = ['education', 'is', 'awesome', 'and', 'effective'],left = 1,right = 4) == 2\n assert candidate(words = ['xyz', 'uvw', 'qrs', 'tuv', 'lmn', 'opq'],left = 1,right = 5) == 0\n assert candidate(words = ['aeiou', 'ueiou', 'ieoai', 'oeuia', 'uaeio'],left = 0,right = 4) == 5\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'],left = 0,right = 14) == 4\n assert candidate(words = ['xylophone', 'xylophones', 'xylophonically', 'xylophonist', 'xylophonists'],left = 0,right = 4) == 0\n assert candidate(words = ['aeiou', 'uaeiou', 'aeu', 'aue', 'eua'],left = 0,right = 4) == 5\n assert candidate(words = ['xylophone', 'yacht', 'gymnymphilia', 'hydrangea', 'ivory'],left = 0,right = 4) == 0\n assert candidate(words = ['bcd', 'efg', 'hij', 'klm', 'nop'],left = 0,right = 4) == 0\n assert candidate(words = ['algorithm', 'education', 'umbrella', 'encyclopedia', 'ocean'],left = 2,right = 4) == 2\n assert candidate(words = ['a', 'e', 'i', 'o', 'u'],left = 0,right = 4) == 5\n assert candidate(words = ['umbrella', 'raincoat', 'scarf', 'boots', 'gloves', 'jacket', 'shoes', 'hat', 'mittens', 'gloves', 'umbrella', 'hat'],left = 0,right = 11) == 2\n assert candidate(words = ['a', 'a', 'a', 'a', 'a', 'a'],left = 0,right = 5) == 6\n assert candidate(words = ['education', 'algorithm', 'encyclopedia', 'under', 'umbrella'],left = 1,right = 4) == 2\n assert candidate(words = ['aeiou', 'uoiea', 'aieou', 'euoia', 'oueai'],left = 0,right = 4) == 5\n assert candidate(words = ['education', 'university', 'algorithm', 'optimization', 'encyclopedia'],left = 1,right = 4) == 1\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkll', 'mmnnoo'],left = 0,right = 4) == 0\n assert candidate(words = ['education', 'algorithm', 'umbrella', 'opposite', 'idea'],left = 0,right = 4) == 3\n assert candidate(words = ['aeiouaeiou', 'uoieauoiea', 'aieouaieou', 'euoiaeuoia', 'oueaioueai'],left = 1,right = 3) == 3\n assert candidate(words = ['aaa', 'eee', 'iii', 'ooo', 'uuu'],left = 0,right = 4) == 5\n assert candidate(words = ['education', 'umbrella', 'idea', 'algorithm', 'elephant'],left = 1,right = 4) == 2\n assert candidate(words = ['abacaxi', 'elderberry', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango', 'nectarine', 'orange', 'papaya', 'quince'],left = 0,right = 11) == 2\n assert candidate(words = ['sequential', 'programming', 'leads', 'to', 'complexity'],left = 1,right = 3) == 0\n assert candidate(words = ['aeiou', 'uoiea', 'ioeau', 'oaeiu', 'ueiao'],left = 0,right = 4) == 5\n assert candidate(words = ['aaaaa', 'eeeee', 'iiiii', 'ooooo', 'uuuuu'],left = 1,right = 3) == 3\n assert candidate(words = ['sequence', 'encounter', 'interval', 'equation', 'occasion'],left = 2,right = 4) == 0\n assert candidate(words = ['acoustic', 'analysis', 'bassoon', 'clarinet', 'didgeridoo', 'flute', 'guitar', 'harp', 'harp', 'piano', 'tuba'],left = 2,right = 10) == 0\n assert candidate(words = ['sequence', 'sequences', 'sequentially', 'sequenceable', 'sequenceless'],left = 2,right = 4) == 0\n assert candidate(words = ['ae', 'ea', 'oi', 'io', 'ou', 'uo'],left = 0,right = 5) == 6\n assert candidate(words = ['understanding', 'learning', 'grows', 'every', 'day'],left = 0,right = 2) == 0\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],left = 0,right = 4) == 2\n assert candidate(words = ['elephant', 'giraffe', 'hippo', 'iguana', 'jaguar'],left = 0,right = 4) == 1\n assert candidate(words = ['xylophone', 'xylo', 'yolo', 'mono', 'neon'],left = 1,right = 4) == 0\n assert candidate(words = ['sequence', 'structure', 'synergy', 'symmetry', 'spectrum', 'syzygy'],left = 2,right = 5) == 0\n assert candidate(words = ['vowel', 'testing', 'algorithm', 'education', 'umbrella', 'sequence', 'interview', 'exhibition', 'occasion', 'environment'],left = 3,right = 8) == 1\n assert candidate(words = ['algorithm', 'data', 'structure', 'programming', 'language'],left = 2,right = 4) == 0\n assert candidate(words = ['', 'a', 'e', 'i', 'o', 'u', 'aeiou', 'uoiea', 'euioa', 'aoieu'],left = 1,right = 9) == 9\n assert candidate(words = ['vowel', 'words', 'only', 'here', 'now'],left = 0,right = 4) == 0\n assert candidate(words = ['aeiou', 'eioua', 'iouae', 'ouaei', 'uaeio'],left = 0,right = 4) == 5\n assert candidate(words = ['vowel', 'vowels', 'vowelstring', 'vowelstrings', 'vowels', 'strings', 'string', 'vow', 'owel', 'vowels', 'vowel'],left = 3,right = 10) == 0\n assert candidate(words = ['vowel', 'start', 'end', 'middle', 'zone', 'sequence'],left = 2,right = 5) == 0\n assert candidate(words = ['sequence', 'queue', 'deque', 'peep', 'beep', 'keel', 'heel', 'heal', 'heap', 'heap', 'jeep', 'weep'],left = 1,right = 11) == 0\n assert candidate(words = ['elephant', 'antelope', 'giraffe', 'hippo', 'iguana', 'jackal', 'kangaroo', 'lemur'],left = 1,right = 7) == 2\n assert candidate(words = ['amazing', 'algorithm', 'umbrella', 'opposite', 'idea', 'beautiful', 'enormous', 'interesting', 'unexpected', 'odd'],left = 0,right = 9) == 3\n"}, "metadata": {"canonical_parameter_names": ["words", "left", "right"], "leetcode_dataset_entry_point": "Solution().vowelStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int vowelStrings(String[] words, int left, int right) {", "container": "Solution", "callable": "vowelStrings", "parameters": [{"name": "words", "type": "String[]"}, {"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2587, "task_id": "rearrange-array-to-maximize-prefix-score", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. You can rearrange the elements of nums to any order (including the given order).\nLet prefix be the array containing the prefix sums of nums after rearranging it. In other words, prefix[i] is the sum of the elements from 0 to i in nums after rearranging it. The score of nums is the number of positive integers in the array prefix.\nReturn the maximum score you can achieve.\n \nExample 1:\n\nInput: nums = [2,-1,0,1,-3,3,-3]\nOutput: 6\nExplanation: We can rearrange the array into nums = [2,3,1,-1,-3,0,-3].\nprefix = [2,5,6,5,2,2,-1], so the score is 6.\nIt can be shown that 6 is the maximum score we can obtain.\n\nExample 2:\n\nInput: nums = [-2,-3,0]\nOutput: 0\nExplanation: Any rearrangement of the array will result in a score of 0.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-106 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, -1, 3, 2, -4, 0, 2]) == 7\n assert candidate(nums = [-1]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 5\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [5, -2, 3, 1, -4, 7]) == 6\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 9\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [5, -1, 3, -2, 4, 0]) == 6\n assert candidate(nums = [5, -2, 3, 1, -4, 7, -1]) == 7\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]) == 0\n assert candidate(nums = [-2, -3, 0]) == 0\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [5, -1, 3, -2, 4, 0, -6, 2]) == 8\n assert candidate(nums = [2, -1, 0, 1, -3, 3, -3]) == 6\n assert candidate(nums = [-5, 1, -3, 2, -4, 0]) == 3\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == 5\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 0]) == 4\n assert candidate(nums = [1000000, -500000, 500000, -250000, 250000, -125000, 125000, -62500, 62500, -31250, 31250]) == 11\n assert candidate(nums = [999999, 1000000, -1999999, 2000000, -2999999, 3000000, -3999999, 4000000]) == 8\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10]) == 10\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600]) == 11\n assert candidate(nums = [1000000, -500000, 500000, -250000, 250000, -125000, 125000]) == 7\n assert candidate(nums = [50, 40, 30, 20, 10, -10, -20, -30, -40, -50, -60, -70, -80]) == 9\n assert candidate(nums = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 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\n assert candidate(nums = [1, 1, 1, 1, 1, -5, -5, -5, -5, -5, 10, 10, 10, 10, 10, -10, -10, -10, -10, -10]) == 17\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 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]) == 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]) == 9\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1]) == 11\n assert candidate(nums = [-5, 4, -3, 2, -1, 1, -2, 3, -4, 5]) == 9\n assert candidate(nums = [1000000, 999999, 999998, -1000000, -999999, -999998, 0, 0, 0]) == 8\n assert candidate(nums = [100000, -100000, 90000, -90000, 80000, -80000, 70000, -70000, 60000, -60000, 50000, -50000, 40000, -40000, 30000, -30000, 20000, -20000, 10000, -10000]) == 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]) == 19\n assert candidate(nums = [1000000, -999999, 1, -1, 0, 0, 0, 0, 0, 0]) == 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]) == 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]) == 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]) == 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, -11, -12, -13, -14, -15]) == 19\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 55]) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 20\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5]) == 19\n assert candidate(nums = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == 9\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 9\n assert candidate(nums = [500000, 400000, 300000, 200000, 100000, -100000, -200000, -300000, -400000, -500000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 19\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 9\n assert candidate(nums = [1000000, 999999, -1000000, 999998, -999999, 1]) == 6\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7]) == 14\n assert candidate(nums = [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1]) == 11\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 10\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, -1000000, -999999, -999998, -999997, -999996]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10, -6, -7, -8, -9, -10]) == 19\n assert candidate(nums = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 15\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000, -1000000, 1000000, -1000000, 1000000, -1000000]) == 9\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, -15000000]) == 5\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000, 500000, -1000000, -1000000, -1000000, -1000000]) == 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]) == 19\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 19\n assert candidate(nums = [10, 20, 30, -60, 40, 50, -70, 60, 70, 80, 90, -450]) == 11\n assert candidate(nums = [5, 4, 3, 2, 1, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, -10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [50, -50, 40, -40, 30, -30, 20, -20, 10, -10]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50]) == 9\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, -1]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10]) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [999999, -1, 999998, -2, 999997, -3, 999996, -4, 999995, -5, 999994, -6, 999993, -7, 999992, -8]) == 16\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, -100, -200, -300, -400, -500, -600, -700, -800, -900]) == 11\n assert candidate(nums = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5, 6]) == 11\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]) == 29\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 18\n assert candidate(nums = [-1000000, 1000000, -2000000, 2000000, -3000000, 3000000, -1500000, 1500000]) == 7\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 55]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 10, -20, 25, -30]) == 9\n assert candidate(nums = [-1000000, -999999, -999998, 1000000, 999999, 999998, 0, 0, 0]) == 8\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 0, 0, 0, 0, 0]) == 14\n assert candidate(nums = [-1000000, -1000000, -1000000, 1000000, 1000000, 1000000, 1000000]) == 7\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -2, -3, -4, -5]) == 20\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 16\n assert candidate(nums = [-1000000, -999999, -999998, -999997, -999996, -999995, -999994, -999993, -999992, -999991]) == 0\n assert candidate(nums = [1000000, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 10\n assert candidate(nums = [1000000, 2000000, 3000000, -1000000, -2000000, -3000000, 1500000, -1500000]) == 7\n assert candidate(nums = [999999, 1, -999999, -1, 999999, -999999]) == 5\n assert candidate(nums = [-500000, -400000, -300000, -200000, -100000, 100000, 200000, 300000, 400000, 500000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 19\n assert candidate(nums = [-1000000, 1000000, -1000000, 1000000, -1000000, 1000000]) == 5\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 10\n assert candidate(nums = [100000, -50000, 50000, -10000, 20000, -5000, 3000, 1000, -1000, 500, 50, 5, 1]) == 13\n assert candidate(nums = [100, -50, 200, -100, 300, -150, 400, -200, 500]) == 9\n assert candidate(nums = [-1, -2, -3, -4, -5, 20, -10, 30, -25, 40]) == 10\n assert candidate(nums = [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, 1, -1, 1, -1, 1, -1]) == 15\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 19\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 0\n assert candidate(nums = [999999, -999999, 999998, -999998, 999997, -999997, 999996, -999996]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxScore(int[] nums) {", "container": "Solution", "callable": "maxScore", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2588, "task_id": "count-the-number-of-beautiful-subarrays", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. In one operation, you can:\n\nChoose two different indices i and j such that 0 <= i, j < nums.length.\nChoose a non-negative integer k such that the kth bit (0-indexed) in the binary representation of nums[i] and nums[j] is 1.\nSubtract 2k from nums[i] and nums[j].\n\nA subarray is beautiful if it is possible to make all of its elements equal to 0 after applying the above operation any number of times.\nReturn the number of beautiful subarrays in the array nums.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [4,3,1,2,4]\nOutput: 2\nExplanation: There are 2 beautiful subarrays in nums: [4,3,1,2,4] and [4,3,1,2,4].\n- We can make all elements in the subarray [3,1,2] equal to 0 in the following way:\n - Choose [3, 1, 2] and k = 1. Subtract 21 from both numbers. The subarray becomes [1, 1, 0].\n - Choose [1, 1, 0] and k = 0. Subtract 20 from both numbers. The subarray becomes [0, 0, 0].\n- We can make all elements in the subarray [4,3,1,2,4] equal to 0 in the following way:\n - Choose [4, 3, 1, 2, 4] and k = 2. Subtract 22 from both numbers. The subarray becomes [0, 3, 1, 2, 0].\n - Choose [0, 3, 1, 2, 0] and k = 0. Subtract 20 from both numbers. The subarray becomes [0, 2, 0, 2, 0].\n - Choose [0, 2, 0, 2, 0] and k = 1. Subtract 21 from both numbers. The subarray becomes [0, 0, 0, 0, 0].\n\nExample 2:\n\nInput: nums = [1,10,4]\nOutput: 0\nExplanation: There are no beautiful subarrays in nums.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 25\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1]) == 6\n assert candidate(nums = [2, 4, 6, 8, 10]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [8, 1, 2, 12, 7]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5]) == 6\n assert candidate(nums = [8, 8, 8, 8, 8]) == 6\n assert candidate(nums = [0, 0, 0, 0, 0]) == 15\n assert candidate(nums = [5, 5, 5, 5]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [1, 10, 4]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [8, 12, 10, 14, 16]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 2\n assert candidate(nums = [8, 14, 4, 8, 7]) == 0\n assert candidate(nums = [0, 0, 0, 0]) == 10\n assert candidate(nums = [2, 2, 2, 2]) == 4\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 0\n assert candidate(nums = [4, 3, 1, 2, 4]) == 2\n assert candidate(nums = [8, 10, 12, 14, 16, 18, 20, 22, 24, 26]) == 6\n assert candidate(nums = [1024, 512, 256, 128, 64]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 25\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2]) == 6\n assert candidate(nums = [15, 15, 15, 15, 15]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 16\n assert candidate(nums = [21, 33, 45, 57, 69, 81, 93, 105, 117, 129]) == 2\n assert candidate(nums = [1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575]) == 12\n assert candidate(nums = [31, 15, 7, 3, 1, 1, 3, 7, 15, 31]) == 5\n assert candidate(nums = [32, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 25\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 10\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35]) == 4\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 0\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 0\n assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == 45\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 16\n assert candidate(nums = [5, 3, 15, 6, 9, 2, 8, 12]) == 2\n assert candidate(nums = [1023, 1023, 511, 511, 255, 255, 127, 127, 63, 63, 31, 31, 15, 15, 7, 7, 3, 3, 1, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 16\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 210\n assert candidate(nums = [5, 3, 8, 10, 14, 12, 6, 4, 2, 1]) == 5\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80]) == 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]) == 100\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1023, 511, 255]) == 0\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 0\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 56\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 55\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 6\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\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61]) == 0\n assert candidate(nums = [4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095]) == 64\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == 56\n assert candidate(nums = [13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57]) == 6\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 100\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 7\n assert candidate(nums = [5, 7, 1, 3, 9, 6, 2, 8, 4, 10]) == 2\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 0\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31]) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 255]) == 2\n assert candidate(nums = [3, 5, 11, 7, 3, 5, 11, 7]) == 1\n assert candidate(nums = [104729, 209458, 418916, 837832, 1675664, 3351328, 6702656, 13405312, 26810624, 53621248]) == 0\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1, 3, 15, 31]) == 2\n assert candidate(nums = [23, 17, 5, 10, 14, 6, 9, 3, 11, 15, 2, 7, 13]) == 2\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210]) == 12\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 100\n assert candidate(nums = [32, 16, 8, 4, 2, 1, 1, 2, 4, 8, 16, 32, 1, 2, 4, 8, 16, 32]) == 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]) == 100\n assert candidate(nums = [31, 28, 19, 5, 11, 23, 17, 7, 9, 3]) == 2\n assert candidate(nums = [7, 5, 3, 2, 5, 3, 7, 2]) == 2\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023]) == 25\n assert candidate(nums = [1, 3, 2, 7, 6, 5, 4, 15, 14, 13, 12, 11, 10, 9, 8]) == 16\n assert candidate(nums = [31, 14, 7, 14, 31]) == 0\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 0\n assert candidate(nums = [3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1]) == 45\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 0\n assert candidate(nums = [31, 14, 7, 15, 28, 21, 24, 13, 26, 19]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 55\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 49\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 16\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 25\n assert candidate(nums = [31, 17, 15, 23, 29, 31, 19, 23, 29]) == 0\n assert candidate(nums = [65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535]) == 16\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 4\n assert candidate(nums = [31, 14, 7, 3, 1, 0, 1, 3, 7, 14, 31]) == 6\n assert candidate(nums = [9, 5, 12, 6, 3, 15, 8, 4, 10, 2, 7, 11, 1, 13, 14]) == 8\n assert candidate(nums = [29, 25, 21, 17, 13, 9, 5, 1, 1, 5, 9, 13, 17, 21, 25, 29]) == 20\n assert candidate(nums = [104729, 209458, 418916, 837832, 1675664, 3351328, 6702656]) == 0\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135]) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 0\n assert candidate(nums = [5, 3, 7, 2, 1, 10, 6, 8, 4, 12]) == 3\n assert candidate(nums = [1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1]) == 70\n assert candidate(nums = [9, 3, 7, 15, 31, 15, 7, 3, 9]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 4\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 4\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]) == 56\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 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]) == 100\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 0\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [3, 1, 5, 7, 2, 4, 6, 8, 10, 12]) == 6\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 63, 127, 255]) == 8\n assert candidate(nums = [13, 11, 7, 5, 3, 2, 1, 1, 2, 3, 5, 7, 11, 13]) == 9\n assert candidate(nums = [31, 14, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == 27\n assert candidate(nums = [17, 34, 68, 136, 272, 544, 1088, 2176, 4352, 8704, 17408, 34816, 69632, 139264, 278528]) == 0\n assert candidate(nums = [5, 3, 6, 12, 5, 3, 6, 12]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().beautifulSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long beautifulSubarrays(int[] nums) {", "container": "Solution", "callable": "beautifulSubarrays", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2589, "task_id": "minimum-time-to-complete-all-tasks", "difficulty": "Hard", "problem_description": "There is a computer that can run an unlimited number of tasks at the same time. You are given a 2D integer array tasks where tasks[i] = [starti, endi, durationi] indicates that the ith task should run for a total of durationi seconds (not necessarily continuous) within the inclusive time range [starti, endi].\nYou may turn on the computer only when it needs to run a task. You can also turn it off if it is idle.\nReturn the minimum time during which the computer should be turned on to complete all tasks.\n \nExample 1:\n\nInput: tasks = [[2,3,1],[4,5,1],[1,5,2]]\nOutput: 2\nExplanation: \n- The first task can be run in the inclusive time range [2, 2].\n- The second task can be run in the inclusive time range [5, 5].\n- The third task can be run in the two inclusive time ranges [2, 2] and [5, 5].\nThe computer will be on for a total of 2 seconds.\n\nExample 2:\n\nInput: tasks = [[1,3,2],[2,5,3],[5,6,2]]\nOutput: 4\nExplanation: \n- The first task can be run in the inclusive time range [2, 3].\n- The second task can be run in the inclusive time ranges [2, 3] and [5, 5].\n- The third task can be run in the two inclusive time range [5, 6].\nThe computer will be on for a total of 4 seconds.\n\n \nConstraints:\n\n1 <= tasks.length <= 2000\ntasks[i].length == 3\n1 <= starti, endi <= 2000\n1 <= durationi <= endi - starti + 1 \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1]]) == 2\n assert candidate(tasks = [[1, 100, 50], [50, 150, 50], [100, 200, 50]]) == 99\n assert candidate(tasks = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1]]) == 5\n assert candidate(tasks = [[1, 2, 1], [1, 2, 1], [1, 2, 1]]) == 1\n assert candidate(tasks = [[1, 100, 50], [50, 150, 50], [150, 200, 50]]) == 100\n assert candidate(tasks = [[1, 10, 10], [2, 9, 8], [3, 8, 6], [4, 7, 4], [5, 6, 2]]) == 10\n assert candidate(tasks = [[1, 10, 10], [2, 9, 9], [3, 8, 8], [4, 7, 7], [5, 6, 6]]) == 10\n assert candidate(tasks = [[5, 10, 5], [15, 20, 5], [25, 30, 5]]) == 15\n assert candidate(tasks = [[1, 10, 10], [10, 20, 5], [20, 30, 5]]) == 18\n assert candidate(tasks = [[1, 5, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4]]) == 4\n assert candidate(tasks = [[10, 20, 5], [20, 30, 5], [30, 40, 5], [40, 50, 5]]) == 17\n assert candidate(tasks = [[5, 10, 3], [10, 15, 3], [15, 20, 4]]) == 8\n assert candidate(tasks = [[1, 3, 2], [2, 5, 3], [5, 6, 2]]) == 4\n assert candidate(tasks = [[1, 5, 5], [6, 10, 5], [11, 15, 5]]) == 15\n assert candidate(tasks = [[1, 2, 1], [2, 3, 1], [3, 4, 1]]) == 2\n assert candidate(tasks = [[1, 10, 10], [10, 20, 10], [20, 30, 10]]) == 28\n assert candidate(tasks = [[1, 10, 10]]) == 10\n assert candidate(tasks = [[1, 10, 5], [2, 9, 4], [3, 8, 3], [4, 7, 2]]) == 5\n assert candidate(tasks = [[2, 3, 1], [4, 5, 1], [1, 5, 2]]) == 2\n assert candidate(tasks = [[1, 5, 3], [2, 6, 4], [3, 7, 5], [4, 8, 6], [5, 9, 7]]) == 7\n assert candidate(tasks = [[1, 10, 5], [10, 20, 5], [20, 30, 5]]) == 13\n assert candidate(tasks = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1]]) == 4\n assert candidate(tasks = [[1, 2, 2], [2, 3, 2], [3, 4, 2]]) == 4\n assert candidate(tasks = [[1, 100, 50], [51, 150, 50], [101, 200, 50]]) == 100\n assert candidate(tasks = [[1, 10, 5], [10, 20, 10], [15, 25, 10]]) == 18\n assert candidate(tasks = [[1, 20, 10], [5, 15, 5], [10, 25, 10]]) == 10\n assert candidate(tasks = [[1, 2, 1], [3, 4, 1], [5, 6, 1]]) == 3\n assert candidate(tasks = [[1, 5, 3], [2, 5, 3], [3, 5, 3], [4, 5, 3], [1, 5, 3], [2, 5, 3], [3, 5, 3], [4, 5, 3], [1, 5, 3], [2, 5, 3], [3, 5, 3], [4, 5, 3], [1, 5, 3], [2, 5, 3], [3, 5, 3], [4, 5, 3]]) == 3\n assert candidate(tasks = [[1, 5, 1], [2, 6, 1], [3, 7, 1], [4, 8, 1], [5, 9, 1], [6, 10, 1], [7, 11, 1], [8, 12, 1], [9, 13, 1], [10, 14, 1]]) == 2\n assert candidate(tasks = [[1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 6, 1], [5, 7, 1], [6, 8, 1], [7, 9, 1], [8, 10, 1], [9, 11, 1], [10, 12, 1]]) == 4\n assert candidate(tasks = [[1, 15, 10], [5, 20, 12], [10, 25, 15], [15, 30, 18]]) == 25\n assert candidate(tasks = [[1, 500, 250], [200, 600, 200], [300, 700, 150], [400, 800, 100]]) == 250\n assert candidate(tasks = [[1, 10, 5], [1, 10, 5], [1, 10, 5], [1, 10, 5], [1, 10, 5]]) == 5\n assert candidate(tasks = [[1, 10, 10], [2, 9, 9], [3, 8, 8], [4, 7, 7], [5, 6, 6], [6, 5, 5], [7, 4, 4], [8, 3, 3], [9, 2, 2], [10, 1, 1]]) == 10\n assert candidate(tasks = [[1, 5, 2], [2, 4, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2]]) == 4\n assert candidate(tasks = [[1, 50, 25], [25, 75, 25], [50, 100, 25], [75, 125, 25], [100, 150, 25], [125, 175, 25], [150, 200, 25]]) == 97\n assert candidate(tasks = [[1, 5, 5], [5, 10, 5], [10, 15, 5], [15, 20, 5]]) == 17\n assert candidate(tasks = [[10, 20, 1], [11, 21, 1], [12, 22, 1], [13, 23, 1], [14, 24, 1], [15, 25, 1], [16, 26, 1], [17, 27, 1], [18, 28, 1], [19, 29, 1]]) == 1\n assert candidate(tasks = [[1, 100, 10], [20, 120, 20], [40, 140, 30], [60, 160, 40], [80, 180, 50], [100, 190, 60]]) == 69\n assert candidate(tasks = [[1, 10, 10], [2, 15, 5], [3, 20, 3], [4, 25, 2], [5, 30, 1], [6, 35, 2], [7, 40, 3], [8, 45, 4], [9, 50, 5], [10, 55, 6]]) == 15\n assert candidate(tasks = [[1, 10, 9], [2, 9, 8], [3, 8, 7], [4, 7, 6], [5, 6, 5]]) == 9\n assert candidate(tasks = [[10, 20, 10], [15, 30, 5], [20, 40, 3], [25, 50, 2], [30, 60, 1], [35, 70, 2], [40, 80, 3], [45, 90, 4], [50, 100, 5]]) == 17\n assert candidate(tasks = [[1, 10, 5], [1, 10, 5], [1, 10, 5], [1, 10, 5], [1, 10, 5], [1, 10, 5]]) == 5\n assert candidate(tasks = [[1, 2000, 1000], [500, 1500, 1000], [1000, 2000, 1000], [1, 1000, 500], [1001, 2000, 500]]) == 1499\n assert candidate(tasks = [[10, 20, 5], [15, 25, 4], [20, 30, 3], [25, 35, 2], [30, 40, 1], [35, 45, 2], [40, 50, 3], [45, 55, 4], [50, 60, 5], [55, 65, 6]]) == 17\n assert candidate(tasks = [[1, 2000, 1000], [500, 1500, 500], [1000, 2000, 1000], [1500, 2000, 500], [1, 1000, 500], [500, 1000, 250]]) == 1499\n assert candidate(tasks = [[1, 100, 50], [20, 30, 15], [40, 50, 10], [60, 70, 5], [80, 90, 3]]) == 50\n assert candidate(tasks = [[1, 20, 15], [5, 15, 10], [10, 25, 12], [15, 30, 10]]) == 19\n assert candidate(tasks = [[1, 10, 9], [2, 10, 8], [3, 10, 7], [4, 10, 6], [5, 10, 5]]) == 9\n assert candidate(tasks = [[1, 2000, 2000], [2, 1999, 1999], [3, 1998, 1998], [4, 1997, 1997], [5, 1996, 1996]]) == 2000\n assert candidate(tasks = [[1, 10, 1], [2, 3, 1], [4, 5, 1], [6, 7, 1], [8, 9, 1], [10, 10, 1]]) == 5\n assert candidate(tasks = [[1, 1000, 500], [1, 1000, 500], [1, 1000, 500], [1, 1000, 500], [1, 1000, 500]]) == 500\n assert candidate(tasks = [[5, 15, 10], [10, 20, 5], [15, 25, 3], [20, 30, 2], [25, 35, 1]]) == 12\n assert candidate(tasks = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5]]) == 5\n assert candidate(tasks = [[1, 5, 1], [2, 6, 1], [3, 7, 1], [4, 8, 1], [5, 9, 1], [6, 10, 1], [7, 11, 1], [8, 12, 1], [9, 13, 1], [10, 14, 1]]) == 2\n assert candidate(tasks = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5]]) == 4\n assert candidate(tasks = [[1, 20, 5], [2, 19, 5], [3, 18, 5], [4, 17, 5], [5, 16, 5], [6, 15, 5], [7, 14, 5], [8, 13, 5], [9, 12, 5], [10, 11, 5]]) == 5\n assert candidate(tasks = [[1, 1000, 500], [200, 800, 300], [400, 600, 200], [500, 700, 150]]) == 500\n assert candidate(tasks = [[1, 2, 1], [3, 4, 1], [5, 6, 1], [7, 8, 1], [9, 10, 1], [11, 12, 1], [13, 14, 1], [15, 16, 1], [17, 18, 1], [19, 20, 1]]) == 10\n assert candidate(tasks = [[1, 500, 250], [250, 750, 300], [500, 1000, 350], [750, 1250, 400], [1000, 1500, 450]]) == 1048\n assert candidate(tasks = [[1, 10, 3], [1, 10, 3], [1, 10, 3], [1, 10, 3], [1, 10, 3], [1, 10, 3], [1, 10, 3], [1, 10, 3], [1, 10, 3], [1, 10, 3], [1, 10, 3]]) == 3\n assert candidate(tasks = [[1, 10, 3], [2, 9, 5], [3, 8, 4], [4, 7, 1], [5, 6, 2]]) == 5\n assert candidate(tasks = [[1, 10, 10], [1, 10, 10], [1, 10, 10], [1, 10, 10], [1, 10, 10], [1, 10, 10], [1, 10, 10], [1, 10, 10], [1, 10, 10]]) == 10\n assert candidate(tasks = [[1, 10, 10], [2, 9, 9], [3, 8, 8], [4, 7, 7], [5, 6, 6], [6, 5, 5], [7, 4, 4], [8, 3, 3], [9, 2, 2]]) == 10\n assert candidate(tasks = [[1, 3, 3], [4, 6, 2], [7, 9, 1], [10, 12, 3], [13, 15, 2]]) == 11\n assert candidate(tasks = [[5, 10, 5], [10, 15, 5], [15, 20, 5], [20, 25, 5], [25, 30, 5], [30, 35, 5], [35, 40, 5], [40, 45, 5]]) == 33\n assert candidate(tasks = [[1, 50, 25], [25, 75, 30], [50, 100, 35], [75, 125, 40], [100, 150, 45]]) == 103\n assert candidate(tasks = [[1, 3, 3], [4, 6, 3], [7, 9, 3], [10, 12, 3], [13, 15, 3], [16, 18, 3], [19, 21, 3], [22, 24, 3], [25, 27, 3], [28, 30, 3]]) == 30\n assert candidate(tasks = [[1, 10, 3], [1, 20, 3], [1, 30, 3], [1, 40, 3], [1, 50, 3], [1, 60, 3], [1, 70, 3], [1, 80, 3], [1, 90, 3], [1, 100, 3]]) == 3\n assert candidate(tasks = [[1, 1000, 999], [500, 1500, 1000], [1000, 2000, 1000]]) == 1998\n assert candidate(tasks = [[1, 10, 5], [2, 9, 4], [3, 8, 3], [4, 7, 2], [5, 6, 1], [6, 5, 1], [7, 4, 1], [8, 3, 1], [9, 2, 1], [10, 1, 1]]) == 5\n assert candidate(tasks = [[1, 100, 99], [2, 150, 98], [3, 200, 97], [4, 250, 96], [5, 300, 95], [6, 350, 94], [7, 400, 93], [8, 450, 92], [9, 500, 91]]) == 99\n assert candidate(tasks = [[1, 2, 1], [3, 4, 1], [5, 6, 1], [7, 8, 1], [9, 10, 1], [11, 12, 1], [13, 14, 1], [15, 16, 1], [17, 18, 1], [19, 20, 1], [21, 22, 1], [23, 24, 1], [25, 26, 1], [27, 28, 1], [29, 30, 1]]) == 15\n assert candidate(tasks = [[1, 100, 50], [2, 90, 40], [3, 80, 30], [4, 70, 20], [5, 60, 10], [6, 50, 5], [7, 40, 3], [8, 30, 2], [9, 20, 1]]) == 50\n assert candidate(tasks = [[1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1], [1, 10, 1]]) == 1\n assert candidate(tasks = [[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, 9]]) == 5\n assert candidate(tasks = [[1, 2000, 2000], [10, 500, 400], [150, 800, 300], [300, 1800, 500], [1000, 1900, 600]]) == 2000\n assert candidate(tasks = [[1, 2000, 1000], [2, 1999, 999], [3, 1998, 998], [4, 1997, 997], [5, 1996, 996], [6, 1995, 995], [7, 1994, 994], [8, 1993, 993], [9, 1992, 992], [10, 1991, 991]]) == 1000\n assert candidate(tasks = [[1, 5, 5], [2, 6, 4], [3, 7, 3], [4, 8, 2], [5, 9, 1], [6, 10, 1], [7, 11, 1], [8, 12, 1], [9, 13, 1], [10, 14, 1]]) == 6\n assert candidate(tasks = [[1, 50, 10], [10, 20, 5], [20, 30, 5], [30, 40, 5], [40, 50, 5], [50, 60, 5], [60, 70, 5], [70, 80, 5], [80, 90, 5]]) == 33\n assert candidate(tasks = [[1, 100, 50], [50, 150, 60], [100, 200, 70], [150, 250, 80], [200, 300, 90]]) == 208\n assert candidate(tasks = [[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]]) == 5\n assert candidate(tasks = [[1, 10, 10], [2, 9, 9], [3, 8, 8], [4, 7, 7], [5, 6, 6], [6, 7, 5], [7, 8, 4], [8, 9, 3], [9, 10, 2], [10, 10, 1]]) == 10\n assert candidate(tasks = [[50, 150, 100], [100, 200, 100], [150, 250, 100], [200, 300, 100], [250, 350, 100], [300, 400, 100], [350, 450, 100], [400, 500, 100]]) == 446\n assert candidate(tasks = [[1, 10, 1], [2, 11, 2], [3, 12, 3], [4, 13, 4], [5, 14, 5], [6, 15, 6], [7, 16, 7], [8, 17, 8], [9, 18, 9], [10, 19, 10]]) == 10\n assert candidate(tasks = [[1, 5, 1], [6, 10, 1], [11, 15, 1], [16, 20, 1]]) == 4\n assert candidate(tasks = [[1, 100, 100], [50, 150, 50], [100, 200, 30], [150, 250, 20], [200, 300, 10]]) == 138\n assert candidate(tasks = [[1, 5, 5], [2, 6, 5], [3, 7, 5], [4, 8, 5], [5, 9, 5], [6, 10, 5], [7, 11, 5], [8, 12, 5], [9, 13, 5], [10, 14, 5]]) == 14\n assert candidate(tasks = [[1, 2000, 500], [2, 1999, 499], [3, 1998, 498], [4, 1997, 497], [5, 1996, 496], [6, 1995, 495], [7, 1994, 494], [8, 1993, 493], [9, 1992, 492], [10, 1991, 491]]) == 500\n assert candidate(tasks = [[1, 100, 50], [51, 150, 50], [101, 200, 50], [151, 250, 50], [201, 300, 50]]) == 150\n assert candidate(tasks = [[1, 100, 1], [2, 99, 1], [3, 98, 1], [4, 97, 1], [5, 96, 1], [6, 95, 1], [7, 94, 1], [8, 93, 1], [9, 92, 1], [10, 91, 1], [11, 90, 1], [12, 89, 1], [13, 88, 1], [14, 87, 1], [15, 86, 1], [16, 85, 1], [17, 84, 1], [18, 83, 1], [19, 82, 1], [20, 81, 1], [21, 80, 1], [22, 79, 1], [23, 78, 1], [24, 77, 1], [25, 76, 1], [26, 75, 1], [27, 74, 1], [28, 73, 1], [29, 72, 1], [30, 71, 1], [31, 70, 1], [32, 69, 1], [33, 68, 1], [34, 67, 1], [35, 66, 1], [36, 65, 1], [37, 64, 1], [38, 63, 1], [39, 62, 1], [40, 61, 1], [41, 60, 1], [42, 59, 1], [43, 58, 1], [44, 57, 1], [45, 56, 1], [46, 55, 1], [47, 54, 1], [48, 53, 1], [49, 52, 1], [50, 51, 1]]) == 1\n assert candidate(tasks = [[1, 3, 3], [2, 4, 2], [3, 5, 2], [4, 6, 2], [5, 7, 2], [6, 8, 2], [7, 9, 2]]) == 7\n assert candidate(tasks = [[1, 5, 5], [2, 10, 5], [3, 15, 5], [4, 20, 5], [5, 25, 5], [6, 30, 5]]) == 10\n assert candidate(tasks = [[1, 3, 1], [2, 5, 2], [3, 7, 3], [4, 9, 4], [5, 11, 5], [6, 13, 6], [7, 15, 7]]) == 9\n assert candidate(tasks = [[1, 50, 40], [25, 75, 30], [50, 100, 20], [75, 125, 10]]) == 59\n assert candidate(tasks = [[1, 20, 5], [1, 15, 5], [1, 10, 5], [1, 5, 5], [6, 10, 5], [11, 15, 5], [16, 20, 5]]) == 20\n assert candidate(tasks = [[1, 2000, 1000], [500, 1500, 500], [1000, 2000, 500], [1, 500, 100], [1500, 2000, 100]]) == 1000\n assert candidate(tasks = [[1, 2000, 1], [2, 2000, 2], [3, 2000, 3], [4, 2000, 4], [5, 2000, 5], [6, 2000, 6], [7, 2000, 7], [8, 2000, 8], [9, 2000, 9], [10, 2000, 10]]) == 10\n assert candidate(tasks = [[100, 200, 100], [150, 250, 100], [200, 300, 100], [250, 350, 100], [300, 400, 100]]) == 298\n assert candidate(tasks = [[1, 2000, 1000], [2, 1999, 999], [3, 1998, 998], [4, 1997, 997], [5, 1996, 996], [6, 1995, 995], [7, 1994, 994], [8, 1993, 993], [9, 1992, 992], [10, 1991, 991]]) == 1000\n assert candidate(tasks = [[1, 2000, 1000], [1000, 2000, 1000], [500, 1500, 500], [100, 1900, 900]]) == 1000\n assert candidate(tasks = [[1, 2, 1], [1, 3, 1], [1, 4, 1], [1, 5, 1], [1, 6, 1], [1, 7, 1], [1, 8, 1], [1, 9, 1], [1, 10, 1]]) == 1\n assert candidate(tasks = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 10, 1]]) == 6\n assert candidate(tasks = [[1, 10, 3], [2, 10, 3], [3, 10, 3], [4, 10, 3], [5, 10, 3], [6, 10, 3], [7, 10, 3], [8, 10, 3], [9, 10, 3], [1, 10, 3]]) == 3\n assert candidate(tasks = [[1, 100, 50], [50, 150, 50], [100, 200, 50], [150, 250, 50], [200, 300, 50]]) == 148\n assert candidate(tasks = [[1, 50, 25], [10, 60, 25], [20, 70, 25], [30, 80, 25], [40, 90, 25], [50, 100, 25], [60, 110, 25], [70, 120, 25], [80, 130, 25], [90, 140, 25]]) == 63\n assert candidate(tasks = [[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, 9], [10, 10, 10]]) == 5\n assert candidate(tasks = [[1, 10, 1], [2, 9, 1], [3, 8, 1], [4, 7, 1], [5, 6, 1], [6, 5, 1], [7, 4, 1], [8, 3, 1], [9, 2, 1], [10, 1, 1]]) == 1\n assert candidate(tasks = [[1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 6, 1], [5, 7, 1]]) == 2\n assert candidate(tasks = [[1, 5, 2], [1, 5, 2], [1, 5, 2], [1, 5, 2], [1, 5, 2]]) == 2\n assert candidate(tasks = [[1, 100, 50], [20, 150, 60], [30, 180, 70], [40, 200, 80]]) == 80\n assert candidate(tasks = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [2, 6, 1], [2, 6, 2], [2, 6, 3], [2, 6, 4], [2, 6, 5]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["tasks"], "leetcode_dataset_entry_point": "Solution().findMinimumTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findMinimumTime(int[][] tasks) {", "container": "Solution", "callable": "findMinimumTime", "parameters": [{"name": "tasks", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2591, "task_id": "distribute-money-to-maximum-children", "difficulty": "Easy", "problem_description": "You are given an integer money denoting the amount of money (in dollars) that you have and another integer children denoting the number of children that you must distribute the money to.\nYou have to distribute the money according to the following rules:\n\nAll money must be distributed.\nEveryone must receive at least 1 dollar.\nNobody receives 4 dollars.\n\nReturn the maximum number of children who may receive exactly 8 dollars if you distribute the money according to the aforementioned rules. If there is no way to distribute the money, return -1.\n \nExample 1:\n\nInput: money = 20, children = 3\nOutput: 1\nExplanation: \nThe maximum number of children with 8 dollars will be 1. One of the ways to distribute the money is:\n- 8 dollars to the first child.\n- 9 dollars to the second child. \n- 3 dollars to the third child.\nIt can be proven that no distribution exists such that number of children getting 8 dollars is greater than 1.\n\nExample 2:\n\nInput: money = 16, children = 2\nOutput: 2\nExplanation: Each child can be given 8 dollars.\n\n \nConstraints:\n\n1 <= money <= 200\n2 <= children <= 30\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(money = 150,children = 15) == 14\n assert candidate(money = 100,children = 5) == 4\n assert candidate(money = 15,children = 3) == 1\n assert candidate(money = 31,children = 3) == 2\n assert candidate(money = 7,children = 2) == 0\n assert candidate(money = 25,children = 4) == 3\n assert candidate(money = 8,children = 8) == 0\n assert candidate(money = 50,children = 6) == 5\n assert candidate(money = 28,children = 3) == 2\n assert candidate(money = 25,children = 5) == 2\n assert candidate(money = 150,children = 20) == 18\n assert candidate(money = 199,children = 25) == 24\n assert candidate(money = 100,children = 12) == 11\n assert candidate(money = 7,children = 3) == 0\n assert candidate(money = 16,children = 2) == 2\n assert candidate(money = 40,children = 5) == 5\n assert candidate(money = 30,children = 4) == 3\n assert candidate(money = 300,children = 30) == 29\n assert candidate(money = 3,children = 2) == 0\n assert candidate(money = 4,children = 2) == 0\n assert candidate(money = 30,children = 3) == 2\n assert candidate(money = 31,children = 4) == 3\n assert candidate(money = 8,children = 2) == 0\n assert candidate(money = 20,children = 3) == 1\n assert candidate(money = 200,children = 30) == 24\n assert candidate(money = 72,children = 9) == 9\n assert candidate(money = 300,children = 25) == 24\n assert candidate(money = 28,children = 4) == 2\n assert candidate(money = 7,children = 1) == 0\n assert candidate(money = 32,children = 4) == 4\n assert candidate(money = 12,children = 2) == 0\n assert candidate(money = 25,children = 3) == 2\n assert candidate(money = 6,children = 2) == 0\n assert candidate(money = 4,children = 1) == -1\n assert candidate(money = 1,children = 2) == -1\n assert candidate(money = 200,children = 25) == 25\n assert candidate(money = 8,children = 1) == 1\n assert candidate(money = 10,children = 2) == 1\n assert candidate(money = 30,children = 5) == 3\n assert candidate(money = 50,children = 7) == 6\n assert candidate(money = 100,children = 10) == 9\n assert candidate(money = 1,children = 1) == 0\n assert candidate(money = 15,children = 2) == 1\n assert candidate(money = 56,children = 7) == 7\n assert candidate(money = 24,children = 3) == 3\n assert candidate(money = 5,children = 2) == 0\n assert candidate(money = 50,children = 5) == 4\n"}, "metadata": {"canonical_parameter_names": ["money", "children"], "leetcode_dataset_entry_point": "Solution().distMoney", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int distMoney(int money, int children) {", "container": "Solution", "callable": "distMoney", "parameters": [{"name": "money", "type": "int"}, {"name": "children", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2592, "task_id": "maximize-greatness-of-an-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. You are allowed to permute nums into a new array perm of your choosing.\nWe define the greatness of nums be the number of indices 0 <= i < nums.length for which perm[i] > nums[i].\nReturn the maximum possible greatness you can achieve after permuting nums.\n \nExample 1:\n\nInput: nums = [1,3,5,2,1,3,1]\nOutput: 4\nExplanation: One of the optimal rearrangements is perm = [2,5,1,3,3,1,1].\nAt indices = 0, 1, 3, and 4, perm[i] > nums[i]. Hence, we return 4.\nExample 2:\n\nInput: nums = [1,2,3,4]\nOutput: 3\nExplanation: We can prove the optimal perm is [2,3,4,1].\nAt indices = 0, 1, and 2, perm[i] > nums[i]. Hence, we return 3.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 6\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4]) == 3\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == 5\n assert candidate(nums = [10000, 1000, 100, 10, 1]) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 8\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 4\n assert candidate(nums = [1, 3, 5, 2, 1, 3, 1]) == 4\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == 4\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 18\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]) == 15\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]) == 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]) == 19\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9]) == 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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == 19\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(nums = [1, 1, 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]) == 23\n assert candidate(nums = [10, 10, 10, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 9\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]) == 24\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 28\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]) == 24\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 18\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 9\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500]) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [100, 101, 102, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88]) == 14\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 19\n assert candidate(nums = [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 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 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]) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 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]) == 18\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 18\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == 15\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 12\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]) == 29\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 18\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]) == 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]) == 19\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 18\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 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, 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]) == 29\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 18\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 18\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]) == 29\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 18\n assert candidate(nums = [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]) == 23\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 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, 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]) == 45\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 14\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]) == 38\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 13, 13]) == 17\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]) == 27\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 30\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]) == 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]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 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]) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4]) == 16\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximizeGreatness", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximizeGreatness(int[] nums) {", "container": "Solution", "callable": "maximizeGreatness", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2593, "task_id": "find-score-of-an-array-after-marking-all-elements", "difficulty": "Medium", "problem_description": "You are given an array nums consisting of positive integers.\nStarting with score = 0, apply the following algorithm:\n\nChoose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest index.\nAdd the value of the chosen integer to score.\nMark the chosen element and its two adjacent elements if they exist.\nRepeat until all the array elements are marked.\n\nReturn the score you get after applying the above algorithm.\n \nExample 1:\n\nInput: nums = [2,1,3,4,5,2]\nOutput: 7\nExplanation: We mark the elements as follows:\n- 1 is the smallest unmarked element, so we mark it and its two adjacent elements: [2,1,3,4,5,2].\n- 2 is the smallest unmarked element, so we mark it and its left adjacent element: [2,1,3,4,5,2].\n- 4 is the only remaining unmarked element, so we mark it: [2,1,3,4,5,2].\nOur score is 1 + 2 + 4 = 7.\n\nExample 2:\n\nInput: nums = [2,3,5,1,3,2]\nOutput: 5\nExplanation: We mark the elements as follows:\n- 1 is the smallest unmarked element, so we mark it and its two adjacent elements: [2,3,5,1,3,2].\n- 2 is the smallest unmarked element, since there are two of them, we choose the left-most one, so we mark the one at index 0 and its right adjacent element: [2,3,5,1,3,2].\n- 2 is the only remaining unmarked element, so we mark it: [2,3,5,1,3,2].\nOur score is 1 + 2 + 2 = 5.\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 = [6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 1000000]) == 1\n assert candidate(nums = [1000000, 1, 1000000, 1, 1000000]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 25\n assert candidate(nums = [7, 3, 5, 1, 9, 2, 8, 6, 4]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 7\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums = [5, 3, 6, 2, 7, 4, 1, 8, 9]) == 15\n assert candidate(nums = [10, 20, 30, 40, 50]) == 90\n assert candidate(nums = [1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [2, 3, 5, 1, 3, 2]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 9\n assert candidate(nums = [3, 1, 2, 4, 5, 3, 2, 1]) == 9\n assert candidate(nums = [2, 1, 3, 4, 5, 2]) == 7\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5]) == 14\n assert candidate(nums = [1000000, 1]) == 1\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(nums = [1000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 25\n assert candidate(nums = [5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [1000000]) == 1000000\n assert candidate(nums = [1000000, 1, 1000000, 1, 1000000, 1]) == 3\n assert candidate(nums = [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995, 5]) == 15\n assert candidate(nums = [2, 1, 4, 1, 3, 4, 2, 1]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1]) == 38\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 25\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6]) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 41\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 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]) == 10\n assert candidate(nums = [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 = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 130\n assert candidate(nums = [6, 7, 8, 9, 10, 5, 4, 3, 2, 1]) == 23\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 16\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 64\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 29\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 1]) == 9\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 1090\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]) == 435\n assert candidate(nums = [500000, 500001, 499999, 500002, 499998, 500003, 499997, 500004, 499996]) == 2499990\n assert candidate(nums = [1000000, 2, 1000000, 3, 1000000, 4, 1000000, 5]) == 14\n assert candidate(nums = [1000000, 1000000, 1, 1, 1000000, 1, 1000000, 1]) == 1000003\n assert candidate(nums = [7, 5, 3, 5, 7, 9, 1, 2, 8, 4, 6]) == 22\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1]) == 6\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996, 6, 999995, 7, 999994, 8]) == 36\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996]) == 15\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]) == 225\n assert candidate(nums = [3, 1, 2, 4, 5, 3, 2, 1, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8]) == 45\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(nums = [9, 5, 7, 3, 8, 6, 10, 4, 2, 1]) == 19\n assert candidate(nums = [2, 3, 2, 4, 3, 2, 5, 4, 3, 2, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3]) == 26\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 125\n assert candidate(nums = [5, 3, 8, 3, 9, 1, 6, 2, 7, 4]) == 13\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 6\n assert candidate(nums = [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]) == 120\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 40\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 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]) == 120\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 24\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 25\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]) == 169\n assert candidate(nums = [2, 3, 5, 1, 3, 2, 5, 1, 3, 2, 5, 1, 3, 2, 5]) == 11\n assert candidate(nums = [1000, 999, 998, 1001, 1002, 997, 996, 995, 1003, 1004, 1005, 994, 993, 992, 1006]) == 6980\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(nums = [5, 3, 8, 1, 4, 7, 2, 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 225\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [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]) == 24\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == 80\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 25\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1]) == 50\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 325\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 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]) == 64\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5]) == 259\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 57\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 6, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 85\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 360\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 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]) == 100\n assert candidate(nums = [1000000, 999999, 999998, 1000001, 1000002, 999997, 999996, 999995, 1000003, 1000004]) == 4999994\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\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]) == 75\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1, 1, 4, 4, 4, 5, 5, 5]) == 21\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 50, 60, 10, 70]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(nums = [100, 101, 102, 99, 98, 97, 103, 104, 105, 96, 95, 94, 106, 107, 108]) == 697\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 95\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 19\n assert candidate(nums = [7, 1, 3, 2, 5, 4, 6, 8]) == 15\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 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]) == 10\n assert candidate(nums = [7, 6, 5, 8, 9, 1, 2, 3, 4, 10]) == 26\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == 4999970\n assert candidate(nums = [15, 10, 5, 1, 20, 25, 30, 35, 40, 45]) == 116\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 40\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 13\n assert candidate(nums = [100, 50, 25, 125, 62, 31, 156, 78, 39, 200, 100, 50, 25, 125, 62, 31]) == 351\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5]) == 46\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000]) == 2500000\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5]) == 15\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long findScore(int[] nums) {", "container": "Solution", "callable": "findScore", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2594, "task_id": "minimum-time-to-repair-cars", "difficulty": "Medium", "problem_description": "You are given an integer array ranks representing the ranks of some mechanics. ranksi is the rank of the ith mechanic. A mechanic with a rank r can repair n cars in r * n2 minutes.\nYou are also given an integer cars representing the total number of cars waiting in the garage to be repaired.\nReturn the minimum time taken to repair all the cars.\nNote: All the mechanics can repair the cars simultaneously.\n \nExample 1:\n\nInput: ranks = [4,2,3,1], cars = 10\nOutput: 16\nExplanation: \n- The first mechanic will repair two cars. The time required is 4 * 2 * 2 = 16 minutes.\n- The second mechanic will repair two cars. The time required is 2 * 2 * 2 = 8 minutes.\n- The third mechanic will repair two cars. The time required is 3 * 2 * 2 = 12 minutes.\n- The fourth mechanic will repair four cars. The time required is 1 * 4 * 4 = 16 minutes.\nIt can be proved that the cars cannot be repaired in less than 16 minutes.​​​​​\n\nExample 2:\n\nInput: ranks = [5,1,8], cars = 6\nOutput: 16\nExplanation: \n- The first mechanic will repair one car. The time required is 5 * 1 * 1 = 5 minutes.\n- The second mechanic will repair four cars. The time required is 1 * 4 * 4 = 16 minutes.\n- The third mechanic will repair one car. The time required is 8 * 1 * 1 = 8 minutes.\nIt can be proved that the cars cannot be repaired in less than 16 minutes.​​​​​\n\n \nConstraints:\n\n1 <= ranks.length <= 105\n1 <= ranks[i] <= 100\n1 <= cars <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(ranks = [1],cars = 1000000) == 1000000000000\n assert candidate(ranks = [10],cars = 100) == 100000\n assert candidate(ranks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cars = 20) == 25\n assert candidate(ranks = [5, 1, 8],cars = 6) == 16\n assert candidate(ranks = [1, 1, 1, 1, 1],cars = 5) == 1\n assert candidate(ranks = [1],cars = 1) == 1\n assert candidate(ranks = [1, 1, 1, 1],cars = 4) == 1\n assert candidate(ranks = [1, 2, 3, 4, 5],cars = 15) == 27\n assert candidate(ranks = [4, 2, 3, 1],cars = 10) == 16\n assert candidate(ranks = [10, 20, 30, 40, 50],cars = 5) == 40\n assert candidate(ranks = [100, 100, 100],cars = 3) == 100\n assert candidate(ranks = [100, 100, 100],cars = 300) == 1000000\n assert candidate(ranks = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],cars = 1000000) == 467557823524\n assert candidate(ranks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],cars = 100000) == 99181681\n assert candidate(ranks = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],cars = 500000) == 17879098464\n assert candidate(ranks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cars = 1000000) == 39666387103\n assert candidate(ranks = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],cars = 50000) == 214060374\n assert candidate(ranks = [1, 10, 100, 1000, 10000],cars = 10000) == 47073321\n assert candidate(ranks = [1, 1, 1, 1, 1],cars = 25) == 25\n assert candidate(ranks = [1, 3, 6, 10, 15],cars = 100000) == 1525913427\n assert candidate(ranks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cars = 1000000) == 396663871030\n assert candidate(ranks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],cars = 1000000) == 173349003750\n assert candidate(ranks = [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],cars = 10000) == 530670\n assert candidate(ranks = [1, 10, 100, 1000, 10000, 100000, 1, 10, 100, 1000],cars = 123456) == 1801323364\n assert candidate(ranks = [1, 1, 1, 1, 1],cars = 1000000) == 40000000000\n assert candidate(ranks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],cars = 10000) == 10000000\n assert candidate(ranks = [100, 100, 100, 100, 100],cars = 1000000) == 4000000000000\n assert candidate(ranks = [100, 50, 25, 12, 6, 3, 1],cars = 10000) == 13571856\n assert candidate(ranks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],cars = 1000000) == 28757183175\n assert candidate(ranks = [3, 3, 3, 3, 3],cars = 25) == 75\n assert candidate(ranks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cars = 50) == 25\n assert candidate(ranks = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],cars = 10000) == 8568300\n assert candidate(ranks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cars = 100000) == 99181681\n assert candidate(ranks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cars = 1000) == 10000\n assert candidate(ranks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],cars = 100) == 288\n assert candidate(ranks = [50, 25, 100, 20, 60, 40, 30, 80, 90, 10],cars = 1000) == 361250\n assert candidate(ranks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],cars = 500000) == 4333852224\n assert candidate(ranks = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],cars = 5000) == 25000000\n assert candidate(ranks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cars = 50) == 176\n assert candidate(ranks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cars = 100) == 100\n assert candidate(ranks = [1, 10, 100, 1000, 10000],cars = 100000) == 4705411216\n assert candidate(ranks = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],cars = 100000) == 3966868890\n assert candidate(ranks = [50, 40, 30, 20, 10],cars = 1000000) == 957518758440\n assert candidate(ranks = [10, 10, 10, 10, 10, 20, 20, 20, 20, 20],cars = 50) == 360\n assert candidate(ranks = [5, 10, 15, 20, 25],cars = 1000) == 480500\n assert candidate(ranks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cars = 50000) == 991816810\n assert candidate(ranks = [10, 20, 30, 40, 50],cars = 1000000) == 957518758440\n assert candidate(ranks = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],cars = 500000) == 236091196044\n assert candidate(ranks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cars = 50) == 1210\n assert candidate(ranks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],cars = 100) == 2205\n assert candidate(ranks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],cars = 50000) == 607889340\n assert candidate(ranks = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],cars = 75) == 363\n assert candidate(ranks = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],cars = 5000) == 23655095\n assert candidate(ranks = [1, 2, 3, 4, 5],cars = 1000000) == 95751875844\n assert candidate(ranks = [100],cars = 1000000) == 100000000000000\n assert candidate(ranks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cars = 100000) == 3966868890\n assert candidate(ranks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],cars = 1000) == 200000\n assert candidate(ranks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],cars = 500) == 25000\n assert candidate(ranks = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],cars = 1000000) == 239380328180\n assert candidate(ranks = [100, 50, 25, 10, 5, 2, 1],cars = 1000) == 118810\n assert candidate(ranks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cars = 100000) == 396686889\n assert candidate(ranks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cars = 1000000) == 10000000000\n assert candidate(ranks = [100, 50, 25, 12, 6],cars = 10000) == 77199414\n assert candidate(ranks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cars = 100000) == 100000000\n assert candidate(ranks = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],cars = 1000) == 400000\n assert candidate(ranks = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],cars = 30) == 144\n assert candidate(ranks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cars = 1000) == 40000\n assert candidate(ranks = [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],cars = 1000000) == 32624594527\n assert candidate(ranks = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],cars = 1000000) == 396663871030\n assert candidate(ranks = [100, 100, 100, 100, 100],cars = 500000) == 1000000000000\n assert candidate(ranks = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],cars = 1000000) == 91411289649\n assert candidate(ranks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],cars = 50000) == 24800400\n assert candidate(ranks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],cars = 5000) == 6094080\n assert candidate(ranks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cars = 1000) == 400000\n assert candidate(ranks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cars = 1000) == 10000\n assert candidate(ranks = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],cars = 1000000) == 500000000000\n assert candidate(ranks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],cars = 250) == 15870\n assert candidate(ranks = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],cars = 250) == 25920\n assert candidate(ranks = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],cars = 500) == 30276\n assert candidate(ranks = [99, 98, 97, 96, 95],cars = 1000000) == 3879392825484\n assert candidate(ranks = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],cars = 500000) == 55765049760\n assert candidate(ranks = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],cars = 100000) == 856147600\n assert candidate(ranks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],cars = 10000) == 2434446\n assert candidate(ranks = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],cars = 100) == 847\n assert candidate(ranks = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],cars = 1048576) == 201015929104\n assert candidate(ranks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cars = 10000) == 1250000\n assert candidate(ranks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cars = 1000) == 61731\n assert candidate(ranks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],cars = 10000) == 19845315\n assert candidate(ranks = [10, 10, 10, 10, 10],cars = 1000000) == 400000000000\n assert candidate(ranks = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],cars = 1000) == 500000\n assert candidate(ranks = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],cars = 500) == 20172\n assert candidate(ranks = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],cars = 1000000) == 34669800750\n"}, "metadata": {"canonical_parameter_names": ["ranks", "cars"], "leetcode_dataset_entry_point": "Solution().repairCars", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long repairCars(int[] ranks, int cars) {", "container": "Solution", "callable": "repairCars", "parameters": [{"name": "ranks", "type": "int[]"}, {"name": "cars", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2595, "task_id": "number-of-even-and-odd-bits", "difficulty": "Easy", "problem_description": "You are given a positive integer n.\nLet even denote the number of even indices in the binary representation of n with value 1.\nLet odd denote the number of odd indices in the binary representation of n with value 1.\nNote that bits are indexed from right to left in the binary representation of a number.\nReturn the array [even, odd].\n \nExample 1:\n\nInput: n = 50\nOutput: [1,2]\nExplanation:\nThe binary representation of 50 is 110010.\nIt contains 1 on indices 1, 4, and 5.\n\nExample 2:\n\nInput: n = 2\nOutput: [0,1]\nExplanation:\nThe binary representation of 2 is 10.\nIt contains 1 only on index 1.\n\n \nConstraints:\n\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == [0, 1]\n assert candidate(n = 3) == [1, 1]\n assert candidate(n = 1000) == [2, 4]\n assert candidate(n = 63) == [3, 3]\n assert candidate(n = 255) == [4, 4]\n assert candidate(n = 15) == [2, 2]\n assert candidate(n = 64) == [1, 0]\n assert candidate(n = 31) == [3, 2]\n assert candidate(n = 2) == [0, 1]\n assert candidate(n = 1) == [1, 0]\n assert candidate(n = 50) == [1, 2]\n assert candidate(n = 7) == [2, 1]\n assert candidate(n = 5) == [2, 0]\n assert candidate(n = 123) == [3, 3]\n assert candidate(n = 97) == [2, 1]\n assert candidate(n = 315) == [3, 3]\n assert candidate(n = 678) == [1, 4]\n assert candidate(n = 170) == [0, 4]\n assert candidate(n = 511) == [5, 4]\n assert candidate(n = 341) == [5, 0]\n assert candidate(n = 100) == [2, 1]\n assert candidate(n = 2047) == [6, 5]\n assert candidate(n = 496) == [3, 2]\n assert candidate(n = 841) == [3, 2]\n assert candidate(n = 384) == [1, 1]\n assert candidate(n = 4) == [1, 0]\n assert candidate(n = 345) == [4, 1]\n assert candidate(n = 16) == [1, 0]\n assert candidate(n = 192) == [1, 1]\n assert candidate(n = 254) == [3, 4]\n assert candidate(n = 1365) == [6, 0]\n assert candidate(n = 1001) == [3, 4]\n assert candidate(n = 977) == [4, 2]\n assert candidate(n = 819) == [3, 3]\n assert candidate(n = 128) == [0, 1]\n assert candidate(n = 4095) == [6, 6]\n assert candidate(n = 3141) == [4, 1]\n assert candidate(n = 250) == [2, 4]\n assert candidate(n = 789) == [4, 1]\n assert candidate(n = 43690) == [0, 8]\n assert candidate(n = 234) == [1, 4]\n assert candidate(n = 131) == [1, 2]\n assert candidate(n = 999) == [4, 4]\n assert candidate(n = 89) == [3, 1]\n assert candidate(n = 32) == [0, 1]\n assert candidate(n = 240) == [2, 2]\n assert candidate(n = 1023) == [5, 5]\n assert candidate(n = 564) == [2, 2]\n assert candidate(n = 768) == [1, 1]\n assert candidate(n = 65535) == [8, 8]\n assert candidate(n = 665) == [2, 3]\n assert candidate(n = 641) == [1, 2]\n assert candidate(n = 456) == [2, 2]\n assert candidate(n = 85) == [4, 0]\n assert candidate(n = 867) == [3, 3]\n assert candidate(n = 399) == [3, 3]\n assert candidate(n = 1234) == [3, 2]\n assert candidate(n = 512) == [0, 1]\n assert candidate(n = 224) == [1, 2]\n assert candidate(n = 577) == [2, 1]\n assert candidate(n = 199) == [3, 2]\n assert candidate(n = 987) == [4, 4]\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().evenOddBit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] evenOddBit(int n) {", "container": "Solution", "callable": "evenOddBit", "parameters": [{"name": "n", "type": "int"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2596, "task_id": "check-knight-tour-configuration", "difficulty": "Medium", "problem_description": "There is a knight on an n x n chessboard. In a valid configuration, the knight starts at the top-left cell of the board and visits every cell on the board exactly once.\nYou are given an n x n integer matrix grid consisting of distinct integers from the range [0, n * n - 1] where grid[row][col] indicates that the cell (row, col) is the grid[row][col]th cell that the knight visited. The moves are 0-indexed.\nReturn true if grid represents a valid configuration of the knight's movements or false otherwise.\nNote that a valid knight move consists of moving two squares vertically and one square horizontally, or two squares horizontally and one square vertically. The figure below illustrates all the possible eight moves of a knight from some cell.\n\n \nExample 1:\n\n\nInput: grid = [[0,11,16,5,20],[17,4,19,10,15],[12,1,8,21,6],[3,18,23,14,9],[24,13,2,7,22]]\nOutput: true\nExplanation: The above diagram represents the grid. It can be shown that it is a valid configuration.\n\nExample 2:\n\n\nInput: grid = [[0,3,6],[5,8,1],[2,7,4]]\nOutput: false\nExplanation: The above diagram represents the grid. The 8th move of the knight is not valid considering its position after the 7th move.\n\n \nConstraints:\n\nn == grid.length == grid[i].length\n3 <= n <= 7\n0 <= grid[row][col] < n * n\nAll integers in grid are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 5, 2], [6, 3, 1], [8, 7, 4]]) == False\n assert candidate(grid = [[0, 12, 3, 14, 5], [19, 2, 15, 4, 13], [6, 23, 8, 17, 16], [22, 11, 10, 9, 18], [7, 24, 21, 1, 20]]) == False\n assert candidate(grid = [[0, 5, 2], [3, 8, 7], [4, 1, 6]]) == False\n assert candidate(grid = [[0, 6, 1], [5, 8, 3], [4, 7, 2]]) == False\n assert candidate(grid = [[0, 1, 4, 25, 24, 23], [19, 8, 9, 26, 27, 22], [18, 7, 2, 17, 28, 21], [11, 6, 3, 12, 13, 20], [10, 15, 16, 1, 4, 14], [12, 21, 20, 29, 30, 5]]) == False\n assert candidate(grid = [[0, 2, 3], [1, 5, 4], [6, 7, 8]]) == False\n assert candidate(grid = [[0, 2, 3], [5, 6, 1], [4, 7, 8]]) == False\n assert candidate(grid = [[0, 11, 16, 5, 20], [17, 4, 19, 10, 15], [12, 1, 8, 21, 6], [3, 18, 23, 14, 9], [24, 13, 2, 7, 22]]) == True\n assert candidate(grid = [[0, 3, 6], [5, 8, 1], [2, 7, 4]]) == False\n assert candidate(grid = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]) == False\n assert candidate(grid = [[0, 29, 8, 25, 16, 23, 4], [31, 24, 7, 14, 27, 10, 15], [18, 1, 28, 9, 22, 5, 20], [13, 17, 32, 26, 11, 30, 19], [21, 34, 3, 31, 12, 33, 6], [37, 10, 1, 2, 35, 36, 17], [38, 5, 18, 30, 33, 28, 2]]) == False\n assert candidate(grid = [[0, 15, 24, 19, 8, 31, 28], [33, 4, 25, 12, 7, 30, 29], [18, 5, 26, 11, 6, 27, 20], [3, 2, 23, 14, 9, 22, 13], [17, 10, 1, 24, 32, 15, 21], [16, 35, 34, 31, 28, 10, 19], [30, 37, 36, 33, 38, 26, 12]]) == False\n assert candidate(grid = [[0, 15, 28, 21, 8, 19, 2], [31, 22, 7, 16, 29, 10, 27], [14, 23, 6, 25, 18, 9, 20], [3, 12, 33, 26, 11, 30, 17], [13, 24, 5, 32, 1, 34, 21], [35, 10, 1, 2, 31, 4, 23], [36, 11, 26, 3, 14, 27, 6]]) == False\n assert candidate(grid = [[0, 11, 24, 5, 21, 16], [23, 12, 4, 19, 10, 15], [18, 1, 8, 22, 6, 20], [13, 17, 25, 3, 27, 14], [26, 2, 9, 28, 7, 1], [30, 29, 18, 5, 24, 31]]) == False\n assert candidate(grid = [[0, 17, 28, 25, 8, 31, 16], [33, 24, 7, 14, 29, 10, 15], [18, 1, 26, 9, 22, 5, 20], [13, 17, 34, 27, 11, 32, 19], [21, 36, 3, 35, 12, 37, 6], [39, 10, 1, 2, 38, 30, 23], [40, 5, 18, 30, 33, 28, 2]]) == False\n assert candidate(grid = [[0, 29, 28, 13, 12, 3, 2], [27, 26, 15, 14, 11, 4, 1], [24, 17, 8, 7, 16, 5, 20], [19, 18, 3, 6, 15, 2, 16], [21, 22, 9, 20, 1, 14, 11], [33, 32, 35, 34, 23, 28, 37], [30, 31, 36, 39, 38, 41, 40]]) == False\n assert candidate(grid = [[0, 27, 12, 19, 24, 29, 4], [21, 28, 11, 20, 25, 30, 3], [22, 26, 13, 18, 23, 31, 5], [23, 22, 14, 17, 2, 32, 6], [24, 21, 15, 16, 33, 34, 7], [25, 20, 10, 1, 8, 35, 36], [26, 19, 9, 12, 11, 6, 37]]) == False\n assert candidate(grid = [[0, 35, 4, 31, 22, 11, 26, 3, 28], [15, 8, 37, 16, 23, 32, 13, 2, 27], [14, 7, 36, 17, 24, 33, 12, 1, 29], [27, 34, 19, 2, 5, 30, 18, 25, 36], [26, 33, 38, 35, 6, 31, 9, 24, 37], [25, 32, 39, 34, 5, 28, 8, 23, 38], [24, 31, 36, 33, 4, 37, 7, 22, 39], [23, 30, 35, 32, 3, 38, 6, 21, 30], [22, 29, 34, 31, 2, 39, 5, 20, 29]]) == False\n assert candidate(grid = [[0, 35, 4, 31, 22, 11, 26, 3], [15, 8, 37, 16, 23, 32, 13, 2], [14, 7, 36, 17, 24, 33, 12, 1], [27, 34, 19, 2, 5, 30, 18, 25], [26, 33, 38, 35, 6, 31, 9, 24], [25, 32, 39, 34, 5, 28, 8, 23], [24, 31, 36, 33, 4, 37, 7, 22], [23, 30, 35, 32, 3, 38, 6, 21]]) == False\n assert candidate(grid = [[0, 25, 14, 1, 18, 29, 2], [21, 24, 15, 26, 19, 28, 3], [20, 23, 16, 27, 12, 21, 4], [31, 22, 17, 28, 13, 24, 5], [30, 33, 36, 19, 25, 18, 6], [35, 32, 37, 34, 31, 38, 7], [39, 34, 35, 36, 37, 38, 8]]) == False\n assert candidate(grid = [[0, 27, 8, 25, 16, 35, 10], [1, 28, 9, 24, 17, 34, 11], [2, 29, 6, 23, 18, 33, 12], [3, 30, 7, 22, 19, 32, 13], [4, 31, 36, 21, 20, 37, 14], [5, 32, 39, 26, 29, 38, 15], [14, 33, 38, 39, 40, 41, 42]]) == False\n assert candidate(grid = [[0, 19, 10, 3, 18, 27, 12], [21, 2, 9, 14, 17, 26, 13], [20, 7, 4, 11, 16, 25, 14], [1, 8, 5, 12, 15, 24, 15], [2, 11, 6, 13, 14, 23, 16], [3, 10, 7, 14, 13, 22, 17], [4, 9, 8, 15, 12, 21, 18]]) == False\n assert candidate(grid = [[0, 19, 12, 25, 10, 9], [2, 20, 13, 24, 11, 8], [15, 3, 22, 1, 14, 7], [16, 17, 4, 21, 6, 18], [5, 23, 26, 18, 27, 12], [30, 29, 28, 27, 26, 31]]) == False\n assert candidate(grid = [[0, 25, 24, 11, 10, 3, 2], [23, 26, 13, 12, 9, 4, 1], [22, 17, 8, 7, 14, 5, 20], [19, 18, 3, 6, 15, 2, 16], [21, 10, 9, 20, 1, 14, 11], [30, 29, 34, 33, 28, 27, 32], [31, 26, 25, 36, 35, 38, 37]]) == False\n assert candidate(grid = [[0, 14, 9, 2, 23], [18, 8, 21, 15, 19], [13, 22, 1, 16, 10], [20, 5, 11, 4, 3], [6, 17, 12, 7, 24]]) == False\n assert candidate(grid = [[0, 13, 10, 21, 4], [22, 9, 2, 17, 20], [15, 6, 1, 18, 11], [24, 19, 8, 3, 16], [23, 14, 5, 12, 7]]) == False\n assert candidate(grid = [[0, 25, 16, 19, 22, 9, 28], [31, 14, 7, 12, 29, 2, 21], [32, 39, 20, 1, 18, 3, 10], [8, 27, 13, 26, 3, 24, 5], [38, 43, 11, 23, 4, 41, 6], [44, 35, 36, 22, 33, 20, 17], [37, 42, 45, 30, 31, 15, 34]]) == False\n assert candidate(grid = [[0, 25, 12, 13, 24, 11, 22], [21, 8, 19, 14, 23, 10, 27], [20, 7, 30, 15, 28, 9, 26], [17, 6, 29, 4, 31, 18, 33], [16, 5, 34, 3, 35, 2, 32], [39, 1, 38, 0, 37, 36, 19], [38, 35, 36, 37, 4, 5, 6]]) == False\n assert candidate(grid = [[0, 35, 6, 33, 18, 31, 12, 19], [31, 26, 7, 32, 17, 30, 11, 20], [32, 25, 14, 33, 16, 29, 10, 23], [13, 14, 5, 16, 21, 2, 17, 34], [12, 11, 4, 15, 20, 3, 18, 35], [39, 1, 38, 0, 37, 36, 19, 24], [40, 35, 36, 37, 4, 5, 6, 25], [39, 38, 33, 34, 35, 36, 37, 38]]) == False\n assert candidate(grid = [[0, 25, 18, 9, 26, 17, 6], [23, 2, 19, 10, 27, 16, 7], [22, 31, 4, 11, 28, 15, 8], [21, 32, 3, 12, 29, 14, 20], [24, 5, 36, 13, 30, 1, 34], [33, 38, 27, 6, 35, 32, 19], [37, 39, 30, 31, 4, 28, 25]]) == False\n assert candidate(grid = [[0, 17, 16, 3, 2, 1, 6], [15, 8, 9, 4, 7, 18, 13], [14, 11, 12, 19, 10, 5, 20], [31, 28, 29, 22, 21, 24, 23], [32, 27, 26, 39, 38, 25, 30], [37, 34, 35, 40, 33, 36, 41], [38, 43, 42, 45, 44, 47, 46]]) == False\n assert candidate(grid = [[0, 17, 14, 3, 4, 5, 36], [25, 18, 13, 2, 1, 6, 35], [24, 27, 12, 15, 10, 7, 34], [23, 26, 29, 8, 11, 16, 33], [22, 31, 28, 21, 20, 9, 32], [37, 30, 21, 18, 19, 14, 39], [38, 41, 32, 35, 40, 33, 42]]) == False\n assert candidate(grid = [[0, 21, 4, 15, 22, 33, 30], [25, 8, 29, 16, 23, 34, 31], [24, 7, 28, 17, 20, 35, 32], [26, 3, 27, 18, 19, 36, 33], [27, 22, 2, 13, 14, 37, 34], [28, 9, 23, 12, 11, 38, 35], [29, 10, 8, 1, 6, 39, 36]]) == False\n assert candidate(grid = [[0, 17, 4, 31, 22, 11, 26, 3, 36], [15, 8, 27, 16, 23, 32, 13, 2, 35], [14, 7, 28, 17, 24, 33, 12, 1, 34], [27, 34, 19, 2, 5, 30, 18, 25, 33], [26, 33, 38, 35, 6, 31, 9, 24, 32], [25, 32, 39, 34, 5, 28, 8, 23, 31], [24, 31, 36, 33, 4, 37, 7, 22, 30], [23, 30, 35, 32, 3, 38, 6, 21, 29], [22, 29, 34, 31, 2, 39, 5, 20, 28]]) == False\n assert candidate(grid = [[0, 11, 16, 5, 20, 25, 24], [17, 4, 19, 10, 15, 26, 30], [12, 1, 8, 21, 6, 23, 29], [3, 18, 27, 14, 9, 31, 28], [24, 13, 2, 7, 22, 32, 33], [35, 34, 29, 30, 31, 32, 33], [36, 37, 38, 39, 40, 41, 42]]) == False\n assert candidate(grid = [[0, 33, 24, 27, 4, 35, 18], [32, 1, 25, 26, 5, 34, 17], [31, 2, 23, 10, 7, 36, 16], [19, 20, 3, 12, 11, 28, 37], [30, 39, 22, 13, 8, 29, 38], [29, 38, 21, 36, 9, 14, 27], [28, 37, 32, 35, 2, 15, 10]]) == False\n assert candidate(grid = [[0, 35, 12, 3, 26, 15, 2], [23, 14, 1, 36, 17, 28, 31], [22, 13, 24, 11, 18, 27, 16], [33, 20, 7, 4, 37, 19, 29], [32, 21, 8, 35, 2, 38, 10], [39, 30, 15, 24, 13, 36, 9], [34, 31, 16, 17, 28, 19, 20]]) == False\n assert candidate(grid = [[0, 21, 12, 19, 8, 25, 2], [27, 22, 7, 16, 29, 10, 15], [18, 1, 8, 23, 6, 28, 24], [13, 17, 33, 26, 11, 30, 14], [20, 25, 34, 12, 3, 27, 9], [35, 10, 31, 4, 32, 1, 36], [37, 5, 18, 30, 33, 28, 21]]) == False\n assert candidate(grid = [[0, 19, 32, 15, 20, 23, 18], [35, 14, 7, 26, 17, 4, 13], [30, 37, 2, 25, 8, 11, 16], [9, 28, 1, 12, 3, 24, 6], [31, 34, 39, 42, 27, 22, 19], [36, 43, 21, 40, 33, 38, 5], [41, 44, 45, 30, 46, 47, 3]]) == False\n assert candidate(grid = [[0, 17, 2, 19, 22, 11, 26], [15, 8, 27, 4, 23, 20, 13], [16, 1, 24, 3, 28, 21, 12], [9, 18, 7, 10, 29, 25, 6], [14, 33, 36, 5, 32, 39, 1], [31, 26, 35, 34, 37, 4, 2], [30, 11, 38, 28, 3, 37, 5]]) == False\n assert candidate(grid = [[0, 13, 22, 9, 24, 21, 18], [17, 4, 11, 28, 25, 14, 19], [3, 16, 5, 12, 27, 20, 7], [30, 1, 2, 29, 6, 23, 10], [31, 8, 15, 26, 21, 20, 11], [36, 33, 38, 39, 40, 31, 42], [34, 41, 32, 37, 35, 30, 43]]) == False\n assert candidate(grid = [[0, 25, 6, 19, 22, 13, 2], [21, 16, 7, 18, 23, 12, 9], [20, 15, 8, 17, 24, 11, 10], [13, 14, 5, 16, 21, 2, 17], [12, 11, 4, 15, 20, 3, 18], [31, 30, 1, 32, 35, 10, 33], [32, 33, 28, 31, 36, 35, 34]]) == False\n assert candidate(grid = [[0, 15, 2, 21, 8, 7], [13, 14, 19, 20, 5, 6], [18, 17, 10, 11, 4, 1], [9, 16, 23, 24, 3, 12], [35, 30, 25, 26, 29, 28], [31, 32, 33, 34, 27, 22]]) == False\n assert candidate(grid = [[0, 27, 26, 25, 24, 23, 22], [21, 28, 13, 12, 11, 10, 20], [14, 15, 8, 7, 6, 19, 9], [17, 18, 5, 4, 16, 3, 1], [2, 31, 29, 1, 30, 35, 34], [33, 32, 37, 36, 39, 38, 41], [40, 43, 42, 47, 46, 45, 44]]) == False\n assert candidate(grid = [[0, 21, 24, 17, 4, 23, 2], [25, 16, 13, 18, 19, 8, 11], [22, 9, 12, 15, 6, 20, 5], [7, 14, 1, 10, 3, 11, 26], [27, 30, 29, 32, 31, 36, 33], [34, 28, 35, 38, 41, 40, 37], [42, 39, 44, 43, 48, 45, 46]]) == False\n assert candidate(grid = [[0, 25, 8, 1, 12, 23, 30], [31, 24, 9, 26, 13, 22, 33], [28, 7, 10, 27, 14, 21, 2], [29, 6, 11, 18, 15, 20, 3], [32, 5, 16, 19, 17, 20, 34], [35, 4, 36, 19, 37, 38, 39], [40, 41, 42, 43, 44, 45, 46]]) == False\n assert candidate(grid = [[0, 11, 18, 5, 22, 13], [19, 4, 21, 12, 23, 14], [16, 1, 10, 25, 8, 15], [3, 17, 24, 9, 20, 6], [26, 10, 3, 14, 27, 7], [32, 29, 28, 11, 16, 2]]) == False\n assert candidate(grid = [[0, 7, 14, 21, 16, 11, 6], [1, 8, 15, 22, 17, 12, 5], [2, 9, 10, 23, 18, 13, 4], [3, 12, 19, 24, 15, 14, 3], [4, 11, 18, 25, 20, 21, 2], [5, 10, 17, 26, 23, 22, 1], [6, 9, 16, 27, 24, 25, 0]]) == False\n assert candidate(grid = [[0, 19, 10, 3, 22, 13, 24], [35, 18, 11, 2, 23, 12, 25], [34, 17, 8, 1, 20, 14, 9], [33, 26, 7, 4, 21, 15, 16], [32, 27, 36, 3, 28, 19, 20], [31, 30, 29, 4, 26, 34, 35], [24, 25, 28, 29, 30, 31, 32]]) == False\n assert candidate(grid = [[0, 23, 12, 5, 24, 19, 6], [21, 2, 13, 22, 25, 18, 7], [20, 3, 8, 21, 26, 17, 8], [1, 10, 9, 16, 23, 14, 9], [2, 11, 4, 15, 20, 27, 10], [3, 12, 11, 18, 19, 28, 11], [4, 13, 14, 17, 22, 29, 12]]) == False\n assert candidate(grid = [[0, 15, 24, 3, 20, 11, 6], [19, 2, 13, 22, 17, 12, 5], [18, 7, 4, 23, 18, 13, 4], [1, 8, 5, 12, 15, 24, 3], [2, 11, 6, 13, 14, 23, 2], [5, 10, 17, 26, 21, 22, 1], [6, 9, 16, 27, 24, 25, 0]]) == False\n assert candidate(grid = [[0, 29, 28, 17, 16, 7, 6], [27, 26, 15, 14, 13, 8, 5], [24, 19, 18, 9, 12, 11, 4], [23, 22, 1, 2, 10, 3, 20], [31, 30, 25, 24, 21, 28, 29], [32, 37, 34, 33, 36, 39, 38], [35, 42, 41, 40, 47, 46, 45]]) == False\n assert candidate(grid = [[0, 17, 24, 13, 4, 35, 32], [37, 2, 25, 14, 5, 34, 31], [16, 1, 26, 15, 6, 33, 30], [21, 28, 3, 22, 11, 32, 29], [20, 27, 8, 19, 2, 23, 12], [9, 36, 23, 30, 7, 31, 18], [10, 31, 22, 29, 18, 33, 17]]) == False\n assert candidate(grid = [[0, 11, 18, 25, 16, 7, 28], [21, 12, 3, 14, 17, 8, 27], [20, 13, 2, 15, 10, 9, 26], [31, 22, 19, 4, 1, 12, 29], [30, 33, 24, 23, 6, 5, 32], [39, 34, 41, 36, 27, 26, 35], [38, 37, 40, 43, 42, 31, 44]]) == False\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().checkValidGrid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean checkValidGrid(int[][] grid) {", "container": "Solution", "callable": "checkValidGrid", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2597, "task_id": "the-number-of-beautiful-subsets", "difficulty": "Medium", "problem_description": "You are given an array nums of positive integers and a positive integer k.\nA subset of nums is beautiful if it does not contain two integers with an absolute difference equal to k.\nReturn the number of non-empty beautiful subsets of the array nums.\nA subset of nums is an array that can be obtained by deleting some (possibly none) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.\n \nExample 1:\n\nInput: nums = [2,4,6], k = 2\nOutput: 4\nExplanation: The beautiful subsets of the array nums are: [2], [4], [6], [2, 6].\nIt can be proved that there are only 4 beautiful subsets in the array [2,4,6].\n\nExample 2:\n\nInput: nums = [1], k = 1\nOutput: 1\nExplanation: The beautiful subset of the array nums is [1].\nIt can be proved that there is only 1 beautiful subset in the array [1].\n\n \nConstraints:\n\n1 <= nums.length <= 18\n1 <= nums[i], k <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90],k = 5) == 6764\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],k = 1) == 6764\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 143\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],k = 3) == 9260\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 5) == 20\n assert candidate(nums = [1, 3, 5, 7, 9],k = 2) == 12\n assert candidate(nums = [2, 4, 6],k = 2) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 143\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36],k = 2) == 6764\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 1) == 232\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22],k = 2) == 7920\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 143\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95],k = 6) == 2583\n assert candidate(nums = [3, 11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 91, 99, 107, 115, 123, 131, 139],k = 8) == 6764\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450],k = 25) == 6764\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126],k = 7) == 6764\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35],k = 2) == 6764\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72],k = 4) == 6764\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144],k = 8) == 6764\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198],k = 11) == 6764\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 199\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14],k = 2) == 33\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59],k = 1) == 163839\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180],k = 20) == 7920\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 143\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52],k = 3) == 6764\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 15) == 143\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35],k = 2) == 6764\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70],k = 4) == 6764\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],k = 1) == 6764\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072],k = 2) == 196607\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489],k = 6) == 196607\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26],k = 1) == 19682\n assert candidate(nums = [4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54],k = 5) == 232\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],k = 3) == 9260\n assert candidate(nums = [1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30, 33, 34],k = 4) == 7920\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234],k = 13) == 6764\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 199\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69],k = 4) == 6764\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198],k = 11) == 6764\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 168\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126],k = 7) == 6764\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20],k = 3) == 33\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36],k = 2) == 6764\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70],k = 4) == 6764\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112],k = 7) == 2583\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597],k = 2) == 40959\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 2) == 143\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072],k = 1) == 196607\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54],k = 3) == 6764\n assert candidate(nums = [2, 10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98, 106, 114, 122, 130, 138],k = 8) == 6764\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180],k = 10) == 6764\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800],k = 100) == 6764\n assert candidate(nums = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171],k = 10) == 6764\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61],k = 4) == 2583\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],k = 100) == 88\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 2) == 1596\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 11, 12, 13, 16, 17, 18, 21, 22, 23, 26, 27, 28],k = 3) == 62207\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53],k = 3) == 6764\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53],k = 1) == 49151\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59],k = 2) == 41471\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 1) == 49151\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072],k = 1) == 196607\n assert candidate(nums = [3, 13, 23, 33, 43, 53, 63, 73, 83, 93, 103, 113, 123, 133, 143, 153, 163, 173],k = 10) == 6764\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 143\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181],k = 1) == 163839\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240],k = 15) == 2583\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90],k = 5) == 6764\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175],k = 10) == 6764\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69],k = 4) == 6764\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 143\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54],k = 3) == 6764\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().beautifulSubsets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int beautifulSubsets(int[] nums, int k) {", "container": "Solution", "callable": "beautifulSubsets", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2598, "task_id": "smallest-missing-non-negative-integer-after-operations", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and an integer value.\nIn one operation, you can add or subtract value from any element of nums.\n\nFor example, if nums = [1,2,3] and value = 2, you can choose to subtract value from nums[0] to make nums = [-1,2,3].\n\nThe MEX (minimum excluded) of an array is the smallest missing non-negative integer in it.\n\nFor example, the MEX of [-1,2,3] is 0 while the MEX of [1,0,3] is 2.\n\nReturn the maximum MEX of nums after applying the mentioned operation any number of times.\n \nExample 1:\n\nInput: nums = [1,-10,7,13,6,8], value = 5\nOutput: 4\nExplanation: One can achieve this result by applying the following operations:\n- Add value to nums[1] twice to make nums = [1,0,7,13,6,8]\n- Subtract value from nums[2] once to make nums = [1,0,2,13,6,8]\n- Subtract value from nums[3] twice to make nums = [1,0,2,3,6,8]\nThe MEX of nums is 4. It can be shown that 4 is the maximum MEX we can achieve.\n\nExample 2:\n\nInput: nums = [1,-10,7,13,6,8], value = 7\nOutput: 2\nExplanation: One can achieve this result by applying the following operation:\n- subtract value from nums[2] once to make nums = [1,-10,0,13,6,8]\nThe MEX of nums is 2. It can be shown that 2 is the maximum MEX we can achieve.\n\n \nConstraints:\n\n1 <= nums.length, value <= 105\n-109 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 2, 3, 4, 5],value = 1) == 6\n assert candidate(nums = [0, 0, 0, 0],value = 3) == 1\n assert candidate(nums = [10, 15, 20, 25, 30],value = 5) == 1\n assert candidate(nums = [-1, -2, -3, -4],value = 2) == 4\n assert candidate(nums = [-5, -10, -15, -20, -25],value = 5) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5],value = 3) == 3\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000],value = 1000000000) == 1\n assert candidate(nums = [10, 20, 30, 40],value = 10) == 1\n assert candidate(nums = [1, -10, 7, 13, 6, 8],value = 7) == 2\n assert candidate(nums = [1, -10, 7, 13, 6, 8],value = 5) == 4\n assert candidate(nums = [-5, -4, -3, -2, -1],value = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],value = 2) == 10\n assert candidate(nums = [100, 200, 300, 400, 500],value = 3) == 3\n assert candidate(nums = [-5, -4, -3, -2, -1],value = 2) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],value = 1) == 5\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000],value = 1000000000) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],value = 10) == 1\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000],value = 1) == 4\n assert candidate(nums = [2, 3, 4, 5, 6],value = 3) == 4\n assert candidate(nums = [0, 1, 2, 3, 4, 5],value = 6) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],value = 13) == 13\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150],value = 20) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],value = 5) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],value = 1) == 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, 43, 45, 47, 49, 51, 53, 55, 57, 59],value = 2) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],value = 2) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],value = 2) == 0\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],value = 25) == 1\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91],value = 5) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],value = 16) == 16\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],value = 7) == 31\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],value = 100) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7],value = 3) == 6\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000],value = 100000) == 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],value = 1) == 20\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],value = 1) == 30\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],value = 10) == 1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],value = 3) == 9\n assert candidate(nums = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100],value = 10) == 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],value = 2) == 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],value = 3) == 18\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],value = 10) == 1\n assert candidate(nums = [1000000000, -1000000000, 2000000000, -2000000000, 0],value = 1000000000) == 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, 31],value = 3) == 30\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],value = 2) == 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],value = 3) == 18\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],value = 10) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],value = 7) == 15\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0],value = 1) == 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, 0],value = 10) == 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],value = 1) == 31\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],value = 7) == 26\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],value = 5) == 1\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164, 175, 186, 197, 208, 219],value = 11) == 0\n assert candidate(nums = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81],value = 5) == 2\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],value = 1) == 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],value = 12) == 24\n assert candidate(nums = [10, 20, 30, 40, 50, 60],value = 15) == 1\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109],value = 11) == 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],value = 2) == 0\n assert candidate(nums = [-1000000000, -999999999, -999999998, -999999997, -999999996],value = 5) == 5\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],value = 1000) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],value = 11) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],value = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],value = 5) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],value = 2) == 20\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],value = 5) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],value = 2) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],value = 1) == 10\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004],value = 1000000000) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],value = 3) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],value = 10) == 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],value = 5) == 30\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],value = 2) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],value = 1) == 10\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],value = 5) == 1\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81],value = 4) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],value = 4) == 16\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],value = 2) == 10\n assert candidate(nums = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19],value = 3) == 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],value = 5) == 30\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],value = 3) == 9\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],value = 2) == 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],value = 19) == 19\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27],value = 3) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],value = 1000000000) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],value = 1) == 11\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 0],value = 100000000) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],value = 5) == 10\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],value = 10) == 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],value = 10) == 20\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],value = 2) == 1\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],value = 3) == 9\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],value = 5) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],value = 1) == 16\n assert candidate(nums = [1, 1, 1, 1, 1],value = 2) == 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],value = 4) == 20\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],value = 2) == 0\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],value = 1000000000) == 1\n assert candidate(nums = [-100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100],value = 25) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],value = 3) == 15\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],value = 1) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],value = 2) == 0\n assert candidate(nums = [-1000000000, -2000000000, -3000000000, -4000000000, -5000000000],value = 1000000000) == 1\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],value = 1000000) == 1\n assert candidate(nums = [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5],value = 3) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],value = 1) == 10\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],value = 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],value = 5) == 20\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],value = 6) == 6\n assert candidate(nums = [-100, -200, -300, -400, -500],value = 150) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],value = 7) == 14\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29],value = 3) == 0\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25],value = 4) == 0\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],value = 5) == 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],value = 3) == 20\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],value = 4) == 21\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],value = 15) == 1\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004],value = 1) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],value = 5) == 15\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],value = 5) == 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],value = 6) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],value = 1000000000) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],value = 1) == 10\n assert candidate(nums = [-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],value = 7) == 26\n"}, "metadata": {"canonical_parameter_names": ["nums", "value"], "leetcode_dataset_entry_point": "Solution().findSmallestInteger", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findSmallestInteger(int[] nums, int value) {", "container": "Solution", "callable": "findSmallestInteger", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "value", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2600, "task_id": "k-items-with-the-maximum-sum", "difficulty": "Easy", "problem_description": "There is a bag that consists of items, each item has a number 1, 0, or -1 written on it.\nYou are given four non-negative integers numOnes, numZeros, numNegOnes, and k.\nThe bag initially contains:\n\nnumOnes items with 1s written on them.\nnumZeroes items with 0s written on them.\nnumNegOnes items with -1s written on them.\n\nWe want to pick exactly k items among the available items. Return the maximum possible sum of numbers written on the items.\n \nExample 1:\n\nInput: numOnes = 3, numZeros = 2, numNegOnes = 0, k = 2\nOutput: 2\nExplanation: We have a bag of items with numbers written on them {1, 1, 1, 0, 0}. We take 2 items with 1 written on them and get a sum in a total of 2.\nIt can be proven that 2 is the maximum possible sum.\n\nExample 2:\n\nInput: numOnes = 3, numZeros = 2, numNegOnes = 0, k = 4\nOutput: 3\nExplanation: We have a bag of items with numbers written on them {1, 1, 1, 0, 0}. We take 3 items with 1 written on them, and 1 item with 0 written on it, and get a sum in a total of 3.\nIt can be proven that 3 is the maximum possible sum.\n\n \nConstraints:\n\n0 <= numOnes, numZeros, numNegOnes <= 50\n0 <= k <= numOnes + numZeros + numNegOnes\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(numOnes = 25,numZeros = 25,numNegOnes = 0,k = 50) == 25\n assert candidate(numOnes = 0,numZeros = 50,numNegOnes = 0,k = 10) == 0\n assert candidate(numOnes = 3,numZeros = 2,numNegOnes = 0,k = 2) == 2\n assert candidate(numOnes = 20,numZeros = 20,numNegOnes = 10,k = 50) == 10\n assert candidate(numOnes = 10,numZeros = 10,numNegOnes = 10,k = 5) == 5\n assert candidate(numOnes = 25,numZeros = 0,numNegOnes = 25,k = 30) == 20\n assert candidate(numOnes = 50,numZeros = 50,numNegOnes = 50,k = 100) == 50\n assert candidate(numOnes = 0,numZeros = 25,numNegOnes = 25,k = 50) == -25\n assert candidate(numOnes = 1,numZeros = 3,numNegOnes = 2,k = 5) == 0\n assert candidate(numOnes = 5,numZeros = 5,numNegOnes = 5,k = 5) == 5\n assert candidate(numOnes = 50,numZeros = 30,numNegOnes = 20,k = 100) == 30\n assert candidate(numOnes = 0,numZeros = 0,numNegOnes = 50,k = 10) == -10\n assert candidate(numOnes = 0,numZeros = 25,numNegOnes = 25,k = 40) == -15\n assert candidate(numOnes = 0,numZeros = 50,numNegOnes = 0,k = 50) == 0\n assert candidate(numOnes = 0,numZeros = 0,numNegOnes = 50,k = 25) == -25\n assert candidate(numOnes = 10,numZeros = 10,numNegOnes = 10,k = 15) == 10\n assert candidate(numOnes = 50,numZeros = 0,numNegOnes = 0,k = 50) == 50\n assert candidate(numOnes = 0,numZeros = 0,numNegOnes = 50,k = 50) == -50\n assert candidate(numOnes = 0,numZeros = 0,numNegOnes = 0,k = 0) == 0\n assert candidate(numOnes = 10,numZeros = 10,numNegOnes = 30,k = 40) == -10\n assert candidate(numOnes = 1,numZeros = 1,numNegOnes = 1,k = 1) == 1\n assert candidate(numOnes = 50,numZeros = 0,numNegOnes = 0,k = 10) == 10\n assert candidate(numOnes = 0,numZeros = 0,numNegOnes = 5,k = 3) == -3\n assert candidate(numOnes = 0,numZeros = 50,numNegOnes = 0,k = 30) == 0\n assert candidate(numOnes = 25,numZeros = 25,numNegOnes = 0,k = 30) == 25\n assert candidate(numOnes = 25,numZeros = 0,numNegOnes = 25,k = 50) == 0\n assert candidate(numOnes = 0,numZeros = 0,numNegOnes = 50,k = 20) == -20\n assert candidate(numOnes = 3,numZeros = 2,numNegOnes = 0,k = 4) == 3\n assert candidate(numOnes = 0,numZeros = 50,numNegOnes = 0,k = 20) == 0\n assert candidate(numOnes = 45,numZeros = 0,numNegOnes = 5,k = 45) == 45\n assert candidate(numOnes = 30,numZeros = 10,numNegOnes = 10,k = 50) == 20\n assert candidate(numOnes = 20,numZeros = 10,numNegOnes = 20,k = 50) == 0\n assert candidate(numOnes = 30,numZeros = 20,numNegOnes = 5,k = 40) == 30\n assert candidate(numOnes = 45,numZeros = 20,numNegOnes = 35,k = 50) == 45\n assert candidate(numOnes = 20,numZeros = 20,numNegOnes = 10,k = 30) == 20\n assert candidate(numOnes = 15,numZeros = 10,numNegOnes = 25,k = 30) == 10\n assert candidate(numOnes = 40,numZeros = 5,numNegOnes = 5,k = 48) == 37\n assert candidate(numOnes = 20,numZeros = 0,numNegOnes = 30,k = 20) == 20\n assert candidate(numOnes = 30,numZeros = 10,numNegOnes = 10,k = 45) == 25\n assert candidate(numOnes = 30,numZeros = 15,numNegOnes = 10,k = 45) == 30\n assert candidate(numOnes = 10,numZeros = 10,numNegOnes = 30,k = 35) == -5\n assert candidate(numOnes = 40,numZeros = 5,numNegOnes = 5,k = 45) == 40\n assert candidate(numOnes = 5,numZeros = 0,numNegOnes = 45,k = 10) == 0\n assert candidate(numOnes = 30,numZeros = 0,numNegOnes = 20,k = 40) == 20\n assert candidate(numOnes = 20,numZeros = 15,numNegOnes = 15,k = 30) == 20\n assert candidate(numOnes = 50,numZeros = 0,numNegOnes = 0,k = 49) == 49\n assert candidate(numOnes = 40,numZeros = 5,numNegOnes = 5,k = 50) == 35\n assert candidate(numOnes = 20,numZeros = 30,numNegOnes = 10,k = 50) == 20\n assert candidate(numOnes = 45,numZeros = 3,numNegOnes = 2,k = 50) == 43\n assert candidate(numOnes = 25,numZeros = 25,numNegOnes = 0,k = 24) == 24\n assert candidate(numOnes = 0,numZeros = 50,numNegOnes = 0,k = 25) == 0\n assert candidate(numOnes = 45,numZeros = 0,numNegOnes = 5,k = 48) == 42\n assert candidate(numOnes = 25,numZeros = 15,numNegOnes = 10,k = 50) == 15\n assert candidate(numOnes = 10,numZeros = 0,numNegOnes = 40,k = 50) == -30\n assert candidate(numOnes = 15,numZeros = 0,numNegOnes = 35,k = 20) == 10\n assert candidate(numOnes = 20,numZeros = 10,numNegOnes = 20,k = 30) == 20\n assert candidate(numOnes = 10,numZeros = 10,numNegOnes = 30,k = 20) == 10\n assert candidate(numOnes = 45,numZeros = 2,numNegOnes = 3,k = 45) == 45\n assert candidate(numOnes = 10,numZeros = 20,numNegOnes = 30,k = 60) == -20\n assert candidate(numOnes = 20,numZeros = 15,numNegOnes = 15,k = 40) == 15\n assert candidate(numOnes = 10,numZeros = 30,numNegOnes = 10,k = 30) == 10\n assert candidate(numOnes = 10,numZeros = 20,numNegOnes = 20,k = 30) == 10\n assert candidate(numOnes = 15,numZeros = 15,numNegOnes = 20,k = 40) == 5\n assert candidate(numOnes = 0,numZeros = 25,numNegOnes = 25,k = 45) == -20\n assert candidate(numOnes = 0,numZeros = 20,numNegOnes = 30,k = 40) == -20\n assert candidate(numOnes = 40,numZeros = 0,numNegOnes = 10,k = 45) == 35\n assert candidate(numOnes = 25,numZeros = 25,numNegOnes = 0,k = 40) == 25\n assert candidate(numOnes = 15,numZeros = 15,numNegOnes = 20,k = 20) == 15\n assert candidate(numOnes = 50,numZeros = 0,numNegOnes = 0,k = 30) == 30\n assert candidate(numOnes = 30,numZeros = 15,numNegOnes = 5,k = 40) == 30\n assert candidate(numOnes = 35,numZeros = 10,numNegOnes = 5,k = 45) == 35\n assert candidate(numOnes = 0,numZeros = 30,numNegOnes = 20,k = 40) == -10\n assert candidate(numOnes = 15,numZeros = 20,numNegOnes = 15,k = 25) == 15\n assert candidate(numOnes = 10,numZeros = 20,numNegOnes = 20,k = 10) == 10\n assert candidate(numOnes = 10,numZeros = 40,numNegOnes = 10,k = 60) == 0\n assert candidate(numOnes = 30,numZeros = 10,numNegOnes = 10,k = 25) == 25\n assert candidate(numOnes = 20,numZeros = 0,numNegOnes = 30,k = 30) == 10\n assert candidate(numOnes = 1,numZeros = 48,numNegOnes = 1,k = 50) == 0\n assert candidate(numOnes = 0,numZeros = 25,numNegOnes = 25,k = 25) == 0\n assert candidate(numOnes = 1,numZeros = 1,numNegOnes = 1,k = 3) == 0\n assert candidate(numOnes = 30,numZeros = 15,numNegOnes = 15,k = 40) == 30\n assert candidate(numOnes = 40,numZeros = 40,numNegOnes = 10,k = 60) == 40\n assert candidate(numOnes = 20,numZeros = 30,numNegOnes = 50,k = 60) == 10\n assert candidate(numOnes = 10,numZeros = 30,numNegOnes = 10,k = 40) == 10\n assert candidate(numOnes = 2,numZeros = 2,numNegOnes = 2,k = 6) == 0\n assert candidate(numOnes = 25,numZeros = 25,numNegOnes = 0,k = 25) == 25\n assert candidate(numOnes = 15,numZeros = 25,numNegOnes = 10,k = 20) == 15\n assert candidate(numOnes = 50,numZeros = 0,numNegOnes = 0,k = 25) == 25\n assert candidate(numOnes = 10,numZeros = 10,numNegOnes = 10,k = 25) == 5\n assert candidate(numOnes = 30,numZeros = 20,numNegOnes = 50,k = 70) == 10\n assert candidate(numOnes = 30,numZeros = 5,numNegOnes = 15,k = 40) == 25\n assert candidate(numOnes = 20,numZeros = 15,numNegOnes = 15,k = 50) == 5\n assert candidate(numOnes = 30,numZeros = 20,numNegOnes = 10,k = 40) == 30\n assert candidate(numOnes = 0,numZeros = 25,numNegOnes = 25,k = 30) == -5\n assert candidate(numOnes = 0,numZeros = 0,numNegOnes = 100,k = 50) == -50\n assert candidate(numOnes = 45,numZeros = 30,numNegOnes = 25,k = 50) == 45\n assert candidate(numOnes = 0,numZeros = 10,numNegOnes = 40,k = 20) == -10\n assert candidate(numOnes = 25,numZeros = 25,numNegOnes = 0,k = 49) == 25\n assert candidate(numOnes = 45,numZeros = 0,numNegOnes = 5,k = 35) == 35\n assert candidate(numOnes = 50,numZeros = 0,numNegOnes = 50,k = 45) == 45\n assert candidate(numOnes = 20,numZeros = 15,numNegOnes = 10,k = 30) == 20\n assert candidate(numOnes = 5,numZeros = 5,numNegOnes = 40,k = 20) == -5\n assert candidate(numOnes = 45,numZeros = 5,numNegOnes = 0,k = 45) == 45\n assert candidate(numOnes = 10,numZeros = 10,numNegOnes = 30,k = 25) == 5\n assert candidate(numOnes = 5,numZeros = 10,numNegOnes = 35,k = 50) == -30\n"}, "metadata": {"canonical_parameter_names": ["numOnes", "numZeros", "numNegOnes", "k"], "leetcode_dataset_entry_point": "Solution().kItemsWithMaximumSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int kItemsWithMaximumSum(int numOnes, int numZeros, int numNegOnes, int k) {", "container": "Solution", "callable": "kItemsWithMaximumSum", "parameters": [{"name": "numOnes", "type": "int"}, {"name": "numZeros", "type": "int"}, {"name": "numNegOnes", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2601, "task_id": "prime-subtraction-operation", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of length n.\nYou can perform the following operation as many times as you want:\n\nPick an index i that you haven’t picked before, and pick a prime p strictly less than nums[i], then subtract p from nums[i].\n\nReturn true if you can make nums a strictly increasing array using the above operation and false otherwise.\nA strictly increasing array is an array whose each element is strictly greater than its preceding element.\n \nExample 1:\n\nInput: nums = [4,9,6,10]\nOutput: true\nExplanation: In the first operation: Pick i = 0 and p = 3, and then subtract 3 from nums[0], so that nums becomes [1,9,6,10].\nIn the second operation: i = 1, p = 7, subtract 7 from nums[1], so nums becomes equal to [1,2,6,10].\nAfter the second operation, nums is sorted in strictly increasing order, so the answer is true.\nExample 2:\n\nInput: nums = [6,8,11,12]\nOutput: true\nExplanation: Initially nums is sorted in strictly increasing order, so we don't need to make any operations.\nExample 3:\n\nInput: nums = [5,8,3]\nOutput: false\nExplanation: It can be proven that there is no way to perform operations to make nums sorted in strictly increasing order, so the answer is false.\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 1000\nnums.length == n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 9, 6, 10]) == True\n assert candidate(nums = [999, 998, 997, 996, 995]) == True\n assert candidate(nums = [5, 8, 3]) == False\n assert candidate(nums = [100, 99, 98, 97, 96]) == True\n assert candidate(nums = [2, 3, 5, 7, 11]) == True\n assert candidate(nums = [1000, 999, 998]) == True\n assert candidate(nums = [2, 3, 5]) == True\n assert candidate(nums = [7, 14, 4, 14]) == True\n assert candidate(nums = [3, 6, 9, 12]) == True\n assert candidate(nums = [7, 11, 13, 17]) == True\n assert candidate(nums = [20, 18, 15, 10]) == True\n assert candidate(nums = [1, 2, 3, 4]) == True\n assert candidate(nums = [1000, 999, 998, 997, 996]) == True\n assert candidate(nums = [30, 25, 20, 15, 10]) == True\n assert candidate(nums = [500, 400, 300, 200, 100]) == True\n assert candidate(nums = [1000, 999, 998, 997, 996, 995]) == True\n assert candidate(nums = [2, 5, 6]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [10, 9, 8, 7, 6]) == False\n assert candidate(nums = [20, 18, 16, 14, 12, 10]) == False\n assert candidate(nums = [10, 15, 20, 25]) == True\n assert candidate(nums = [15, 14, 13, 12, 11]) == True\n assert candidate(nums = [2, 3, 5, 7]) == True\n assert candidate(nums = [6, 8, 11, 12]) == True\n assert candidate(nums = [2, 5, 10, 17, 26]) == True\n assert candidate(nums = [10, 8, 5, 3]) == False\n assert candidate(nums = [10, 9, 8]) == True\n assert candidate(nums = [3, 3, 3]) == False\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == True\n assert candidate(nums = [20, 18, 16, 14, 12]) == True\n assert candidate(nums = [10, 5, 7, 8]) == True\n assert candidate(nums = [30, 25, 20, 15, 10, 5]) == False\n assert candidate(nums = [2, 5, 4, 6, 8]) == True\n assert candidate(nums = [10, 9, 8, 7]) == True\n assert candidate(nums = [500, 400, 300, 200, 100]) == True\n assert candidate(nums = [541, 523, 509, 499, 491, 487, 479, 467, 463, 461]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(nums = [541, 521, 503, 491, 479, 467, 457, 449, 439, 431]) == True\n assert candidate(nums = [100, 85, 75, 60, 50]) == True\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == True\n assert candidate(nums = [50, 60, 70, 80]) == True\n assert candidate(nums = [7, 17, 27, 37, 47, 57, 67, 77]) == True\n assert candidate(nums = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50]) == True\n assert candidate(nums = [20, 30, 50, 70, 110]) == True\n assert candidate(nums = [7, 17, 27, 37, 47, 57]) == True\n assert candidate(nums = [31, 31, 31, 31, 31]) == True\n assert candidate(nums = [30, 25, 20, 15, 10, 5]) == False\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == False\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23]) == True\n assert candidate(nums = [12, 14, 16, 18, 20, 22, 24]) == True\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24]) == True\n assert candidate(nums = [23, 29, 31, 37, 41]) == True\n assert candidate(nums = [500, 550, 600, 650, 700, 750, 800]) == True\n assert candidate(nums = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42]) == True\n assert candidate(nums = [11, 13, 15, 17, 19, 21, 23]) == True\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == True\n assert candidate(nums = [500, 490, 480, 470, 460, 450, 440, 430, 420, 410, 400, 390, 380, 370, 360, 350, 340, 330, 320, 310]) == True\n assert candidate(nums = [37, 41, 31, 38, 43]) == True\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80]) == True\n assert candidate(nums = [1000, 500, 250, 125, 63]) == True\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41]) == True\n assert candidate(nums = [13, 19, 23, 29, 31, 37, 41]) == True\n assert candidate(nums = [500, 490, 480, 470, 460, 450]) == True\n assert candidate(nums = [19, 23, 29, 31, 37, 41, 43, 47]) == True\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == True\n assert candidate(nums = [999, 998, 997, 996, 995]) == True\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56]) == True\n assert candidate(nums = [40, 35, 30, 25, 20, 15, 10]) == False\n assert candidate(nums = [300, 250, 200, 150, 100, 50]) == True\n assert candidate(nums = [8, 15, 22, 29, 36, 43]) == True\n assert candidate(nums = [500, 501, 502, 503, 504]) == True\n assert candidate(nums = [999, 888, 777, 666, 555]) == True\n assert candidate(nums = [4, 8, 12, 16, 20, 24]) == True\n assert candidate(nums = [29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == False\n assert candidate(nums = [19, 23, 29, 31, 37, 41, 43, 47, 53, 59]) == True\n assert candidate(nums = [11, 19, 29, 37, 41, 43]) == True\n assert candidate(nums = [100, 200, 150, 250, 200, 300, 250, 350, 300, 400]) == True\n assert candidate(nums = [20, 18, 16, 14, 12]) == True\n assert candidate(nums = [97, 89, 83, 79, 73, 71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == False\n assert candidate(nums = [100, 90, 80, 70, 60]) == True\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131]) == True\n assert candidate(nums = [200, 199, 198, 197, 196]) == True\n assert candidate(nums = [17, 23, 19, 29, 31]) == True\n assert candidate(nums = [19, 23, 18, 29, 31]) == True\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == True\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149]) == True\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == True\n assert candidate(nums = [600, 500, 400, 300, 200, 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]) == False\n assert candidate(nums = [15, 20, 25, 30, 35, 40]) == True\n assert candidate(nums = [83, 79, 73, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == False\n assert candidate(nums = [11, 11, 11, 11, 11, 11, 11, 11, 11, 11]) == False\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == True\n assert candidate(nums = [89, 97, 83, 79, 88, 85]) == True\n assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == True\n assert candidate(nums = [15, 18, 21, 25]) == True\n assert candidate(nums = [997, 991, 983, 977, 971, 967, 953, 947, 941, 937]) == True\n assert candidate(nums = [100, 98, 96, 94, 92]) == True\n assert candidate(nums = [100, 200, 150, 250, 200, 300]) == True\n assert candidate(nums = [250, 251, 252, 253, 254, 255]) == True\n assert candidate(nums = [1000, 999, 998, 997]) == True\n assert candidate(nums = [89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67]) == True\n assert candidate(nums = [50, 49, 48, 47, 46, 45]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(nums = [11, 13, 15, 17, 19]) == 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]) == True\n assert candidate(nums = [30, 28, 25, 23, 21, 19]) == True\n assert candidate(nums = [500, 450, 400, 350, 300]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 25, 10, 5, 1]) == False\n assert candidate(nums = [100, 90, 80, 70, 60]) == True\n assert candidate(nums = [29, 28, 27, 26, 25, 24]) == True\n assert candidate(nums = [20, 18, 16, 14]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == True\n assert candidate(nums = [17, 23, 29, 31, 37, 41, 43]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(nums = [45, 55, 65, 75, 85, 95, 105]) == True\n assert candidate(nums = [41, 43, 47, 53, 61]) == True\n assert candidate(nums = [30, 28, 26, 24, 22, 20, 18, 16]) == False\n assert candidate(nums = [20, 18, 15, 12, 10]) == True\n assert candidate(nums = [41, 37, 31, 29, 23, 19, 17, 13]) == False\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == False\n assert candidate(nums = [888, 887, 886, 885, 884]) == True\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == True\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == False\n assert candidate(nums = [100, 97, 94, 91]) == True\n assert candidate(nums = [42, 41, 40, 39, 38, 37, 36, 35, 34, 33]) == True\n assert candidate(nums = [10, 12, 8, 14, 6, 18, 4, 20, 2]) == False\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70]) == True\n assert candidate(nums = [7, 14, 21, 28, 35, 42]) == True\n assert candidate(nums = [839, 829, 827, 823, 821, 811, 809, 803, 797, 787]) == True\n assert candidate(nums = [300, 299, 298, 297, 296, 295]) == True\n assert candidate(nums = [15, 14, 13, 12, 11]) == True\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991]) == True\n assert candidate(nums = [29, 23, 19, 17, 13, 11, 7]) == False\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == True\n assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == True\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == False\n assert candidate(nums = [45, 56, 78, 89, 100]) == True\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59]) == True\n assert candidate(nums = [800, 850, 900, 950, 1000]) == True\n assert candidate(nums = [20, 15, 10, 5]) == True\n assert candidate(nums = [7, 14, 21, 28, 35]) == True\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117]) == True\n assert candidate(nums = [11, 22, 33, 44, 55, 66]) == True\n assert candidate(nums = [7, 17, 11, 23, 19]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19]) == True\n assert candidate(nums = [15, 18, 21, 24, 27, 30]) == True\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == True\n assert candidate(nums = [101, 103, 107, 109, 113]) == True\n assert candidate(nums = [24, 24, 24, 24, 24]) == True\n assert candidate(nums = [13, 23, 13, 23, 13]) == True\n assert candidate(nums = [50, 40, 30, 20, 10]) == False\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().primeSubOperation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean primeSubOperation(int[] nums) {", "container": "Solution", "callable": "primeSubOperation", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2602, "task_id": "minimum-operations-to-make-all-array-elements-equal", "difficulty": "Medium", "problem_description": "You are given an array nums consisting of positive integers.\nYou are also given an integer array queries of size m. For the ith query, you want to make all of the elements of nums equal to queries[i]. You can perform the following operation on the array any number of times:\n\nIncrease or decrease an element of the array by 1.\n\nReturn an array answer of size m where answer[i] is the minimum number of operations to make all elements of nums equal to queries[i].\nNote that after each query the array is reset to its original state.\n \nExample 1:\n\nInput: nums = [3,1,6,8], queries = [1,5]\nOutput: [14,10]\nExplanation: For the first query we can do the following operations:\n- Decrease nums[0] 2 times, so that nums = [1,1,6,8].\n- Decrease nums[2] 5 times, so that nums = [1,1,1,8].\n- Decrease nums[3] 7 times, so that nums = [1,1,1,1].\nSo the total number of operations for the first query is 2 + 5 + 7 = 14.\nFor the second query we can do the following operations:\n- Increase nums[0] 2 times, so that nums = [5,1,6,8].\n- Increase nums[1] 4 times, so that nums = [5,5,6,8].\n- Decrease nums[2] 1 time, so that nums = [5,5,5,8].\n- Decrease nums[3] 3 times, so that nums = [5,5,5,5].\nSo the total number of operations for the second query is 2 + 4 + 1 + 3 = 10.\n\nExample 2:\n\nInput: nums = [2,9,6,3], queries = [10]\nOutput: [20]\nExplanation: We can increase each value in the array to 10. The total number of operations will be 8 + 1 + 4 + 7 = 20.\n\n \nConstraints:\n\nn == nums.length\nm == queries.length\n1 <= n, m <= 105\n1 <= nums[i], queries[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000000],queries = [1000000000, 1, 999999999]) == [0, 999999999, 1]\n assert candidate(nums = [2, 9, 6, 3],queries = [10]) == [20]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [1, 2, 3]) == [0, 5, 10]\n assert candidate(nums = [100, 200, 300],queries = [150, 250]) == [250, 250]\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [3]) == [6]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],queries = [2, 3, 4]) == [12, 8, 10]\n assert candidate(nums = [1, 1, 1, 1],queries = [1]) == [0]\n assert candidate(nums = [3, 1, 6, 8],queries = [1, 5]) == [14, 10]\n assert candidate(nums = [1000000000, 1000000000, 1000000000],queries = [1000000000]) == [0]\n assert candidate(nums = [1, 3, 5, 7, 9],queries = [2, 4, 6, 8]) == [17, 13, 13, 17]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [5, 1, 10, 3]) == [25, 45, 45, 31]\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 = [3, 7, 10]) == [40, 40, 100]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],queries = [500000, 1500000]) == [2500000, 2500000]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [3, 10]) == [21, 66]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [3, 5]) == [12, 20]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [500000000, 1, 1000000000]) == [4888888889, 1111111101, 8888888889]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [5, 50, 500, 5000, 50000, 500000, 5000000, 50000000, 500000000]) == [1111111069, 1111110789, 1111108889, 1111098889, 1111088889, 1111888889, 1128888889, 1388888889, 4888888889]\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 = [15, 20, 25]) == [225, 245, 315]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],queries = [10, 25, 1, 35]) == [260, 208, 400, 298]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [7, 15, 1]) == [57, 105, 105]\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 = [20, 10, 30, 15]) == [200, 250, 250, 212]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],queries = [25, 50, 75]) == [250, 0, 250]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [5, 0, 10, 3]) == [25, 45, 55, 27]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [500000000, 1, 1000000000]) == [4888888889, 1111111101, 8888888889]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [500, 410, 340, 290, 260, 250, 260, 290, 340, 410, 500]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [5, 1, 10, 3]) == [0, 40, 50, 20]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [1, 3, 5, 7, 9]) == [33, 21, 21, 37, 55]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [55, 45, 65, 35, 75]) == [250, 260, 260, 290, 290]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [25, 15, 35, 10, 40]) == [125, 155, 135, 185, 155]\n assert candidate(nums = [1, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [1, 50, 100, 500, 1000, 5000, 10000, 50000, 1000000]) == [1111111092, 1111110749, 1111110399, 1111108399, 1111105899, 1111093899, 1111078899, 1111038899, 1111888899]\n assert candidate(nums = [1000000000, 999999999, 1000000001, 999999998, 1000000002],queries = [1000000000, 999999999, 1000000001]) == [6, 7, 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],queries = [1, 5, 10]) == [90, 50, 90]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [1, 5, 9]) == [40, 0, 40]\n assert candidate(nums = [999999999, 1, 999999998, 2, 999999997, 3, 999999996, 4, 999999995, 5],queries = [999999999, 1, 500000000, 1000000000]) == [4999999990, 4999999990, 4999999970, 5000000000]\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],queries = [999999990, 999999995, 999999999]) == [45, 25, 45]\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [15, 25, 35, 45]) == [85, 65, 65, 85]\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 = [10, 20, 30, 40]) == [250, 200, 250, 400]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [1, 5, 10]) == [40, 0, 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [15, 10, 25, 20]) == [225, 255, 315, 245]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [25, 95, 195, 295, 395, 495, 595, 695, 795, 895]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [25, 75, 50]) == [340, 290, 250]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [25, 35, 15, 45]) == [125, 135, 155, 185]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],queries = [10, 15, 20]) == [125, 112, 125]\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 = [10, 20, 30]) == [250, 200, 250]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [5, 10, 1]) == [20, 45, 36]\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],queries = [500000000, 1500000000]) == [2500000000, 2500000000]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [1, 5, 9]) == [36, 20, 36]\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]) == [90, 74, 62, 54, 50, 50, 54, 62, 74, 90]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [1, 8, 15]) == [105, 56, 105]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [55, 65]) == [250, 260]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [500, 410, 340, 290, 260, 250, 260, 290, 340, 410]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 2, 3, 4, 5]) == [0, 10, 20, 30, 40]\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],queries = [500000000, 1000000000, 1500000000]) == [10499999790, 19999999790, 30499999790]\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 = [10, 15, 5, 20]) == [100, 120, 130, 190]\n assert candidate(nums = [1000000000, 999999999, 1000000001],queries = [1000000000]) == [2]\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000],queries = [500000000, 1000000000, 1]) == [2999999997, 2999999997, 2999999997]\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [1000000000, 5, 1, 10]) == [8999999955, 1000000015, 1000000035, 1000000035]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [10, 1, 5]) == [90, 0, 40]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [5, 3, 7]) == [20, 24, 24]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [5, 10, 1]) == [25, 45, 45]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [1, 55, 101]) == [540, 250, 460]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],queries = [55, 85, 105, 125]) == [625, 565, 625, 765]\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, 0]) == [0, 20, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [5, 3, 7, 1]) == [25, 31, 27, 45]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],queries = [25, 50, 75]) == [650, 500, 600]\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 = [3, 7, 11, 1]) == [62, 54, 110, 90]\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996],queries = [1000000000, 500000000, 1, 1000000001]) == [4999999995, 4999999975, 4999999995, 5000000005]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 5, 10]) == [45, 25, 45]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [1, 5, 9]) == [36, 20, 36]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30]) == [210, 184, 162, 144, 130, 120, 114, 112, 114, 120, 130, 144, 162, 184, 210, 225]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [5, 10, 1]) == [0, 50, 40]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [3, 4, 2, 1]) == [12, 14, 14, 20]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [1, 10]) == [40, 50]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [2, 6, 10, 14, 18]) == [82, 58, 50, 58, 82]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [10, 55, 100]) == [450, 250, 450]\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 = [10, 15, 5, 25]) == [100, 120, 130, 290]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],queries = [999999993, 500000000]) == [31, 4999999955]\n assert candidate(nums = [500000000, 600000000, 700000000, 800000000, 900000000],queries = [400000000, 1000000000]) == [1500000000, 1500000000]\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],queries = [1, 1000000000, 1000000001]) == [4999999995, 0, 5]\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],queries = [1000000000, 1, 1953125]) == [8001953125, 1998046865, 1978515625]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [5, 3, 7, 10]) == [25, 31, 27, 45]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 2, 3]) == [0, 10, 20]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [1, 2, 3, 4, 5]) == [20, 14, 12, 14, 20]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [999999995, 999999998, 1000000000]) == [15, 6, 10]\n assert candidate(nums = [1, 3, 5, 7, 9],queries = [2, 4, 6, 8, 10]) == [17, 13, 13, 17, 25]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [0, 5, 10, 15, 20]) == [100, 62, 50, 62, 100]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [82, 68, 58, 52, 50, 52, 58, 68, 82, 100]\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, 20, 10, 15]) == [190, 190, 100, 120]\n assert candidate(nums = [9, 7, 5, 3, 1],queries = [6, 4, 2, 0, 8]) == [13, 13, 17, 25, 17]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [5, 1, 10, 3]) == [25, 45, 45, 31]\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],queries = [12, 13, 14]) == [157, 156, 157]\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]) == [0, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [7, 14]) == [57, 92]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [500, 50000, 5000000, 500000000]) == [1111108889, 1111088889, 1128888889, 4888888889]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [11, 12, 13, 14, 15]) == [55, 65, 75, 85, 95]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [5, 15]) == [25, 95]\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 = [10, 20, 30]) == [100, 190, 390]\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 = [5, 10, 15]) == [130, 100, 120]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [3, 4]) == [12, 14]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [5, 15, 0]) == [25, 95, 55]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [10, 20, 0, 15]) == [50, 100, 100, 62]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [21, 33, 20, 33, 21, 55, 26, 28, 21, 21, 21]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [3, 7, 10]) == [20, 20, 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, 21, 22, 23, 24, 25],queries = [1, 13, 25]) == [300, 156, 300]\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]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 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],queries = [10, 15, 20]) == [100, 120, 190]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List minOperations(int[] nums, int[] queries) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "queries", "type": "int[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2603, "task_id": "collect-coins-in-a-tree", "difficulty": "Hard", "problem_description": "There exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1. You are given an integer n and 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. You are also given an array coins of size n where coins[i] can be either 0 or 1, where 1 indicates the presence of a coin in the vertex i.\nInitially, you choose to start at any vertex in the tree. Then, you can perform the following operations any number of times: \n\nCollect all the coins that are at a distance of at most 2 from the current vertex, or\nMove to any adjacent vertex in the tree.\n\nFind the minimum number of edges you need to go through to collect all the coins and go back to the initial vertex.\nNote that if you pass an edge several times, you need to count it into the answer several times.\n \nExample 1:\n\n\nInput: coins = [1,0,0,0,0,1], edges = [[0,1],[1,2],[2,3],[3,4],[4,5]]\nOutput: 2\nExplanation: Start at vertex 2, collect the coin at vertex 0, move to vertex 3, collect the coin at vertex 5 then move back to vertex 2.\n\nExample 2:\n\n\nInput: coins = [0,0,0,1,1,0,0,1], edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[5,6],[5,7]]\nOutput: 2\nExplanation: Start at vertex 0, collect the coins at vertices 4 and 3, move to vertex 2, collect the coin at vertex 7, then move back to vertex 0.\n\n \nConstraints:\n\nn == coins.length\n1 <= n <= 3 * 104\n0 <= coins[i] <= 1\nedges.length == n - 1\nedges[i].length == 2\n0 <= ai, bi < n\nai != bi\nedges represents a valid tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coins = [0, 0, 1, 0, 1, 0],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5]]) == 0\n assert candidate(coins = [0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(coins = [1, 0, 0, 0, 0, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n assert candidate(coins = [1, 1, 0, 0, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4]]) == 0\n assert candidate(coins = [1, 1, 0, 0, 1, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]]) == 0\n assert candidate(coins = [0, 0, 0, 1, 1, 0, 0, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [5, 6], [5, 7]]) == 2\n assert candidate(coins = [1, 0, 1, 0, 1, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(coins = [0, 0, 1, 0, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4]]) == 0\n assert candidate(coins = [1, 1, 1, 1, 1, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]]) == 0\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 4\n assert candidate(coins = [1, 1, 0, 0],edges = [[0, 1], [1, 2], [1, 3]]) == 0\n assert candidate(coins = [0, 0, 0, 0, 0, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(coins = [1, 0, 1, 0, 1, 0, 1],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6]]) == 0\n assert candidate(coins = [1, 1, 0, 0, 0, 0, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 4\n assert candidate(coins = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 8\n assert candidate(coins = [0, 0, 1, 1, 1, 0, 1, 0, 0, 0],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [7, 8], [7, 9]]) == 0\n assert candidate(coins = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 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]]) == 14\n assert candidate(coins = [0, 0, 1, 0, 1, 1, 0, 0, 1, 0],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 4\n assert candidate(coins = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],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]]) == 28\n assert candidate(coins = [1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 8\n assert candidate(coins = [1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1],edges = [[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(coins = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 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]]) == 32\n assert candidate(coins = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],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]]) == 2\n assert candidate(coins = [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12]]) == 2\n assert candidate(coins = [1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 8\n assert candidate(coins = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [2, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 2\n assert candidate(coins = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [5, 8], [5, 9], [8, 10]]) == 2\n assert candidate(coins = [1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [3, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 10\n assert candidate(coins = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],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]]) == 20\n assert candidate(coins = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11]]) == 2\n assert candidate(coins = [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [7, 12], [7, 13], [11, 14]]) == 0\n assert candidate(coins = [1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == 4\n assert candidate(coins = [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],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], [12, 20], [12, 21], [13, 22], [13, 23]]) == 20\n assert candidate(coins = [1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 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]]) == 20\n assert candidate(coins = [1, 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],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], [20, 42], [20, 43], [21, 44], [21, 45], [22, 46], [22, 47], [23, 48], [23, 49], [24, 50], [24, 51], [25, 52], [25, 53], [26, 54], [26, 55], [27, 56], [27, 57], [28, 58], [28, 59], [29, 60], [29, 61]]) == 120\n assert candidate(coins = [0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 6\n assert candidate(coins = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],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]]) == 20\n assert candidate(coins = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],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]]) == 30\n assert candidate(coins = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 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], [0, 16]]) == 34\n assert candidate(coins = [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0],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]]) == 4\n assert candidate(coins = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],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]]) == 0\n assert candidate(coins = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 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]]) == 22\n assert candidate(coins = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 8\n assert candidate(coins = [1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0],edges = [[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(coins = [1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1],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]]) == 4\n assert candidate(coins = [0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 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]]) == 10\n assert candidate(coins = [1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 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]]) == 20\n assert candidate(coins = [1, 0, 0, 1, 0, 0, 1, 0, 1, 0],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 2\n assert candidate(coins = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [5, 10], [7, 11]]) == 4\n assert candidate(coins = [1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0],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], [10, 16], [11, 17]]) == 10\n assert candidate(coins = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 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]]) == 0\n assert candidate(coins = [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],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]]) == 14\n assert candidate(coins = [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, 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], [29, 30]]) == 22\n assert candidate(coins = [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 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\n assert candidate(coins = [0, 1, 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],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], [39, 40]]) == 66\n assert candidate(coins = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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]]) == 30\n assert candidate(coins = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 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]]) == 32\n assert candidate(coins = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 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]]) == 24\n assert candidate(coins = [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],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]]) == 40\n assert candidate(coins = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 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]]) == 16\n assert candidate(coins = [0, 1, 1, 0, 0, 1, 0, 1, 0, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5], [4, 6], [6, 7], [7, 8], [8, 9]]) == 6\n assert candidate(coins = [0, 1, 1, 1, 0, 0, 0, 1, 0, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 8\n assert candidate(coins = [0, 0, 1, 0, 1, 1, 0, 0, 1, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 4\n assert candidate(coins = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],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]]) == 20\n assert candidate(coins = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["coins", "edges"], "leetcode_dataset_entry_point": "Solution().collectTheCoins", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int collectTheCoins(int[] coins, int[][] edges) {", "container": "Solution", "callable": "collectTheCoins", "parameters": [{"name": "coins", "type": "int[]"}, {"name": "edges", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2605, "task_id": "form-smallest-number-from-two-digit-arrays", "difficulty": "Easy", "problem_description": "Given two arrays of unique digits nums1 and nums2, return the smallest number that contains at least one digit from each array.\n \nExample 1:\n\nInput: nums1 = [4,1,3], nums2 = [5,7]\nOutput: 15\nExplanation: The number 15 contains the digit 1 from nums1 and the digit 5 from nums2. It can be proven that 15 is the smallest number we can have.\n\nExample 2:\n\nInput: nums1 = [3,5,2,6], nums2 = [3,1,7]\nOutput: 3\nExplanation: The number 3 contains the digit 3 which exists in both arrays.\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 9\n1 <= nums1[i], nums2[i] <= 9\nAll digits in each array are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5]) == 3\n assert candidate(nums1 = [1, 2],nums2 = [3, 4]) == 13\n assert candidate(nums1 = [1, 9],nums2 = [2, 8]) == 12\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9]) == 16\n assert candidate(nums1 = [9, 8, 7],nums2 = [6, 5, 4]) == 47\n assert candidate(nums1 = [1],nums2 = [2]) == 12\n assert candidate(nums1 = [2],nums2 = [3]) == 23\n assert candidate(nums1 = [7, 8, 9],nums2 = [9, 8, 7]) == 7\n assert candidate(nums1 = [9, 8],nums2 = [7, 6]) == 68\n assert candidate(nums1 = [3, 5, 2, 6],nums2 = [3, 1, 7]) == 3\n assert candidate(nums1 = [5],nums2 = [5]) == 5\n assert candidate(nums1 = [7, 3],nums2 = [3, 7]) == 3\n assert candidate(nums1 = [1],nums2 = [9]) == 19\n assert candidate(nums1 = [9],nums2 = [1]) == 19\n assert candidate(nums1 = [2, 4, 6],nums2 = [1, 3, 5]) == 12\n assert candidate(nums1 = [4, 1, 3],nums2 = [5, 7]) == 15\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 14\n assert candidate(nums1 = [1, 4, 7],nums2 = [2, 5, 8, 9]) == 12\n assert candidate(nums1 = [9, 7, 5, 3, 1],nums2 = [2, 4, 6, 8]) == 12\n assert candidate(nums1 = [2, 4, 6, 8],nums2 = [3, 5, 7, 9, 1]) == 12\n assert candidate(nums1 = [8, 9],nums2 = [8, 9, 1, 2]) == 8\n assert candidate(nums1 = [2, 3, 5],nums2 = [2, 3, 4]) == 2\n assert candidate(nums1 = [7, 9, 1],nums2 = [2, 4, 6]) == 12\n assert candidate(nums1 = [7, 8, 9],nums2 = [2, 4, 6]) == 27\n assert candidate(nums1 = [1, 4, 7],nums2 = [2, 5, 8]) == 12\n assert candidate(nums1 = [3, 1, 4],nums2 = [1, 5, 9]) == 1\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [2, 4, 6, 8]) == 2\n assert candidate(nums1 = [5, 7, 9],nums2 = [5, 3, 8, 2]) == 5\n assert candidate(nums1 = [2, 3, 6, 9],nums2 = [1, 4, 7]) == 12\n assert candidate(nums1 = [8, 2, 4, 6],nums2 = [7, 3, 9, 1]) == 12\n assert candidate(nums1 = [3, 4, 5],nums2 = [3, 4, 5]) == 3\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [5, 9],nums2 = [5, 3]) == 5\n assert candidate(nums1 = [8, 2, 4],nums2 = [5, 6, 7, 9]) == 25\n assert candidate(nums1 = [2, 4, 6, 8],nums2 = [1, 3, 5, 7]) == 12\n assert candidate(nums1 = [9, 8, 7, 6, 5],nums2 = [4, 3, 2, 1]) == 15\n assert candidate(nums1 = [7, 3, 8],nums2 = [9, 4, 1]) == 13\n assert candidate(nums1 = [1, 4, 7],nums2 = [2, 5, 8]) == 12\n assert candidate(nums1 = [9, 7, 5],nums2 = [3, 1]) == 15\n assert candidate(nums1 = [9],nums2 = [1, 2, 3, 4, 5, 6, 7, 8]) == 19\n assert candidate(nums1 = [5, 6, 1],nums2 = [6, 7, 2]) == 6\n assert candidate(nums1 = [4, 5, 6],nums2 = [6, 7, 8]) == 6\n assert candidate(nums1 = [1, 5, 9],nums2 = [2, 6, 8]) == 12\n assert candidate(nums1 = [3, 6, 9],nums2 = [3, 5, 8]) == 3\n assert candidate(nums1 = [2, 5, 9],nums2 = [5, 8, 3]) == 5\n assert candidate(nums1 = [9, 8, 7, 6],nums2 = [5, 4, 3, 2, 1]) == 16\n assert candidate(nums1 = [8, 6, 4, 2, 0],nums2 = [7, 5, 3, 1, 9]) == 1\n assert candidate(nums1 = [5, 3, 7],nums2 = [8, 5, 3]) == 3\n assert candidate(nums1 = [6, 3, 1],nums2 = [7, 5, 9, 2, 4]) == 12\n assert candidate(nums1 = [4, 5],nums2 = [4, 5, 6]) == 4\n assert candidate(nums1 = [1, 2],nums2 = [3, 4, 5, 6, 7, 8, 9]) == 13\n assert candidate(nums1 = [3, 7, 1, 5],nums2 = [1, 9, 6, 8]) == 1\n assert candidate(nums1 = [1],nums2 = [9, 8, 7, 6, 5, 4, 3, 2]) == 12\n assert candidate(nums1 = [7, 8, 9],nums2 = [1, 2, 3]) == 17\n assert candidate(nums1 = [3, 5, 7],nums2 = [5, 7, 9]) == 5\n assert candidate(nums1 = [3, 6, 9],nums2 = [3, 6, 9]) == 3\n assert candidate(nums1 = [7, 2, 9],nums2 = [3, 2, 8]) == 2\n assert candidate(nums1 = [8, 6, 2],nums2 = [4, 2, 9]) == 2\n assert candidate(nums1 = [2, 4, 6, 8],nums2 = [1, 3, 5, 7, 9]) == 12\n assert candidate(nums1 = [3],nums2 = [9, 8, 7, 6, 5, 4, 2, 1]) == 13\n assert candidate(nums1 = [9, 7, 5],nums2 = [8, 6, 4]) == 45\n assert candidate(nums1 = [1, 6],nums2 = [5, 6]) == 6\n assert candidate(nums1 = [1, 5, 9],nums2 = [1, 5, 9]) == 1\n assert candidate(nums1 = [9, 8, 7],nums2 = [6, 5, 4]) == 47\n assert candidate(nums1 = [5, 3, 8, 1],nums2 = [4, 7, 6, 2, 9]) == 12\n assert candidate(nums1 = [2, 3, 5, 7],nums2 = [1, 4, 6, 8, 9]) == 12\n assert candidate(nums1 = [5],nums2 = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2],nums2 = [1]) == 12\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8]) == 12\n assert candidate(nums1 = [1, 3, 7, 9],nums2 = [2, 4, 6, 8]) == 12\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 0]) == 1\n assert candidate(nums1 = [3, 7, 9],nums2 = [3, 4, 5]) == 3\n assert candidate(nums1 = [5, 3, 8],nums2 = [8, 2, 7]) == 8\n assert candidate(nums1 = [3, 6, 8],nums2 = [2, 5, 7]) == 23\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9]) == 9\n assert candidate(nums1 = [1, 3, 5, 7],nums2 = [2, 4, 6, 8]) == 12\n assert candidate(nums1 = [8, 9],nums2 = [1, 2, 3, 4, 5]) == 18\n assert candidate(nums1 = [5, 9],nums2 = [5, 7]) == 5\n assert candidate(nums1 = [9, 7, 5, 3],nums2 = [8, 6, 4, 2, 1]) == 13\n assert candidate(nums1 = [1, 2],nums2 = [2, 3]) == 2\n assert candidate(nums1 = [1, 3, 5, 7],nums2 = [9, 8, 6, 4, 2, 0]) == 1\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [3, 4, 5, 6, 7]) == 3\n assert candidate(nums1 = [4],nums2 = [4]) == 4\n assert candidate(nums1 = [2, 4, 6, 8],nums2 = [4]) == 4\n assert candidate(nums1 = [7, 8, 9],nums2 = [1, 2, 3, 4, 5, 6]) == 17\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9]) == 5\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8]) == 12\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5]) == 3\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5, 6, 7]) == 3\n assert candidate(nums1 = [1],nums2 = [9, 8, 7, 6, 5, 4, 3, 2]) == 12\n assert candidate(nums1 = [5, 6, 7],nums2 = [1, 2, 3, 4]) == 15\n assert candidate(nums1 = [4, 8],nums2 = [5, 7, 9]) == 45\n assert candidate(nums1 = [7, 5, 3, 1],nums2 = [8, 6, 4, 2]) == 12\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums1 = [2, 8, 6],nums2 = [7, 4, 1]) == 12\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [4, 5, 6, 7]) == 4\n assert candidate(nums1 = [3, 6, 9],nums2 = [3, 5, 7]) == 3\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minNumber(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "minNumber", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2606, "task_id": "find-the-substring-with-maximum-cost", "difficulty": "Medium", "problem_description": "You are given a string s, a string chars of distinct characters and an integer array vals of the same length as chars.\nThe cost of the substring is the sum of the values of each character in the substring. The cost of an empty string is considered 0.\nThe value of the character is defined in the following way:\n\nIf the character is not in the string chars, then its value is its corresponding position (1-indexed) in the alphabet.\n\n\t\nFor example, the value of 'a' is 1, the value of 'b' is 2, and so on. The value of 'z' is 26.\n\n\nOtherwise, assuming i is the index where the character occurs in the string chars, then its value is vals[i].\n\nReturn the maximum cost among all substrings of the string s.\n \nExample 1:\n\nInput: s = \"adaa\", chars = \"d\", vals = [-1000]\nOutput: 2\nExplanation: The value of the characters \"a\" and \"d\" is 1 and -1000 respectively.\nThe substring with the maximum cost is \"aa\" and its cost is 1 + 1 = 2.\nIt can be proven that 2 is the maximum cost.\n\nExample 2:\n\nInput: s = \"abc\", chars = \"abc\", vals = [-1,-1,-1]\nOutput: 0\nExplanation: The value of the characters \"a\", \"b\" and \"c\" is -1, -1, and -1 respectively.\nThe substring with the maximum cost is the empty substring \"\" and its cost is 0.\nIt can be proven that 0 is the maximum cost.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consist of lowercase English letters.\n1 <= chars.length <= 26\nchars consist of distinct lowercase English letters.\nvals.length == chars.length\n-1000 <= vals[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"programming\",chars = \"pg\",vals = [-1, -2]) == 99\n assert candidate(s = \"a\",chars = \"a\",vals = [-1]) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",chars = \"abcdefghijklmnopqrstuvwxyz\",vals = [-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]) == 0\n assert candidate(s = \"zzzzz\",chars = \"z\",vals = [26]) == 130\n assert candidate(s = \"xyz\",chars = \"xyz\",vals = [24, 25, 26]) == 75\n assert candidate(s = \"adaa\",chars = \"d\",vals = [-1000]) == 2\n assert candidate(s = \"abacaba\",chars = \"abc\",vals = [1, 2, 3]) == 11\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",chars = \"abcdefghijklmnopqrstuvwxyz\",vals = [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(s = \"zzzz\",chars = \"z\",vals = [26]) == 104\n assert candidate(s = \"hello\",chars = \"he\",vals = [5, 10]) == 54\n assert candidate(s = \"abc\",chars = \"abc\",vals = [-1, -1, -1]) == 0\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",chars = \"abcdefghijklmnopqrstuvwxyz\",vals = [-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]) == 0\n assert candidate(s = \"abc\",chars = \"abc\",vals = [-1, -1, -1]) == 0\n assert candidate(s = \"zzyx\",chars = \"zxy\",vals = [100, 200, 300]) == 700\n assert candidate(s = \"aaa\",chars = \"a\",vals = [1]) == 3\n assert candidate(s = \"hello\",chars = \"aeiou\",vals = [1, 2, 3, 4, 5]) == 38\n assert candidate(s = \"programming\",chars = \"pg\",vals = [-5, -10]) == 91\n assert candidate(s = \"zzz\",chars = \"z\",vals = [1000]) == 3000\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",chars = \"abcdefghijklmnopqrstuvwxyz\",vals = [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(s = \"hello\",chars = \"helo\",vals = [5, 10, 15, 20]) == 65\n assert candidate(s = \"abcdefgxyz\",chars = \"abcdefgxyz\",vals = [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]) == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",chars = \"a\",vals = [1000]) == 2350\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",chars = \"abcdefghijklmnopqrstuvwxyz\",vals = [-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]) == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",chars = \"z\",vals = [1000]) == 26000\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",chars = \"z\",vals = [100]) == 2800\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzz\",chars = \"z\",vals = [-1]) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",chars = \"z\",vals = [-26]) == 325\n assert candidate(s = \"abacabadabacaba\",chars = \"abc\",vals = [-1, -2, -3]) == 4\n assert candidate(s = \"abacabadabacaba\",chars = \"abc\",vals = [3, 2, 1]) == 38\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",chars = \"\",vals = []) == 351\n assert candidate(s = \"programmingisfun\",chars = \"progfun\",vals = [5, 4, 3, 2, 1]) == 134\n assert candidate(s = \"aaaabbbbcccc\",chars = \"abc\",vals = [1, -2, 3]) == 12\n assert candidate(s = \"zzyyxx\",chars = \"xyz\",vals = [100, 200, -300]) == 600\n assert candidate(s = \"xyzzyxzyxzyxzyxzyxzyx\",chars = \"xyz\",vals = [10, 20, 30]) == 420\n assert candidate(s = \"hello\",chars = \"lo\",vals = [-1, -2]) == 13\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",chars = \"abcdefghijklmnopqrstuvwxy\",vals = [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]) == 702\n assert candidate(s = \"mnopqr\",chars = \"mnopqr\",vals = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(s = \"hellohellohello\",chars = \"he\",vals = [10, -5]) == 132\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",chars = \"z\",vals = [26]) == 520\n assert candidate(s = \"abcdefgxyz\",chars = \"xyz\",vals = [100, 100, 100]) == 328\n assert candidate(s = \"aabbccddeeffgg\",chars = \"abcdefg\",vals = [-1, -2, -3, -4, -5, -6, -7]) == 0\n assert candidate(s = \"mnopqrstuvwxyzaaa\",chars = \"mno\",vals = [13, 14, 15]) == 276\n assert candidate(s = \"abcxyz\",chars = \"abcxyz\",vals = [-1, -2, -3, -4, -5, -6]) == 0\n assert candidate(s = \"thisisatemporarystring\",chars = \"aeiou\",vals = [1, -1, 2, -2, 3]) == 259\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",chars = \"z\",vals = [-1]) == 0\n assert candidate(s = \"abcdefabcdefabcdef\",chars = \"def\",vals = [100, 200, 300]) == 1818\n assert candidate(s = \"zzzzzzzzzzz\",chars = \"z\",vals = [1000]) == 11000\n assert candidate(s = \"abcdefghijabcdefghij\",chars = \"acegikmoqsuwy\",vals = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 120\n assert candidate(s = \"abcdef\",chars = \"abcde\",vals = [-1, -2, -3, -4, -5]) == 6\n assert candidate(s = \"xyzzzzyx\",chars = \"xyz\",vals = [-1, -2, -3]) == 0\n assert candidate(s = \"qwpwoeirutyiuyweoiuqweoiuyt\",chars = \"qwertyuiopasdfghjklzxcvbnm\",vals = [-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]) == 0\n assert candidate(s = \"mnopqr\",chars = \"mno\",vals = [10, 20, -30]) == 51\n assert candidate(s = \"babababababababababababa\",chars = \"ab\",vals = [-1, 1]) == 1\n assert candidate(s = \"hello world\",chars = \"lo\",vals = [10, -10]) == 45\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",chars = \"abcdefghijklmnopqrstuvwxyz\",vals = [-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]) == 0\n assert candidate(s = \"mississippi\",chars = \"ism\",vals = [-1, -2, 10]) == 32\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",chars = \"def\",vals = [-10, 0, 5]) == 335\n assert candidate(s = \"abcdefg\",chars = \"\",vals = []) == 28\n assert candidate(s = \"abcdefghijklm\",chars = \"def\",vals = [10, 20, 30]) == 136\n assert candidate(s = \"abacabadabacaba\",chars = \"abc\",vals = [10, 20, 30]) == 224\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",chars = \"qwertyuiop\",vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 732\n assert candidate(s = \"aaaabaaa\",chars = \"a\",vals = [5]) == 37\n assert candidate(s = \"zzzzzzzzzz\",chars = \"z\",vals = [100]) == 1000\n assert candidate(s = \"v\",chars = \"v\",vals = [1000]) == 1000\n assert candidate(s = \"xyzabc\",chars = \"xyzabc\",vals = [6, 5, 4, 3, 2, 1]) == 21\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",chars = \"abcdefghijklmnopqrstuvwxy\",vals = [-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]) == 52\n assert candidate(s = \"abcdefghijklm\",chars = \"def\",vals = [-5, -6, -7]) == 70\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",chars = \"acegikmoqsuwy\",vals = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13]) == 378\n assert candidate(s = \"aaaaabbbbbccccc\",chars = \"abc\",vals = [1, -1, 0]) == 5\n assert candidate(s = \"abacabadabacaba\",chars = \"abc\",vals = [-1, -1, -1]) == 4\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",chars = \"a\",vals = [1]) == 32\n assert candidate(s = \"aaaaabaaaabaaaa\",chars = \"a\",vals = [-1]) == 2\n assert candidate(s = \"aabaaaabaaaaaaab\",chars = \"a\",vals = [-1]) == 2\n assert candidate(s = \"abacabadabacaba\",chars = \"abc\",vals = [3, -2, 1]) == 22\n assert candidate(s = \"aabaaaabaaaaaaab\",chars = \"a\",vals = [1]) == 19\n assert candidate(s = \"abababababababababababababab\",chars = \"ab\",vals = [1000, -1000]) == 1000\n assert candidate(s = \"abacabadabacaba\",chars = \"abc\",vals = [-1, 2, 3]) == 12\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",chars = \"z\",vals = [-5]) == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",chars = \"z\",vals = [0]) == 0\n assert candidate(s = \"abcdefg\",chars = \"xyz\",vals = [10, 20, 30]) == 28\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",chars = \"abc\",vals = [10, 20, 30]) == 600\n assert candidate(s = \"abcdefgxyz\",chars = \"adg\",vals = [10, -5, 20]) == 116\n assert candidate(s = \"abcabcabc\",chars = \"abc\",vals = [-1, -1, -1]) == 0\n assert candidate(s = \"thisisateststring\",chars = \"test\",vals = [-1, -2, -3, -4]) == 49\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",chars = \"z\",vals = [-26]) == 0\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",chars = \"qz\",vals = [-100, 100]) == 408\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",chars = \"zyx\",vals = [26, 25, 24]) == 351\n assert candidate(s = \"abcdexyz\",chars = \"xyz\",vals = [-1, -2, -3]) == 15\n assert candidate(s = \"abacabadabacaba\",chars = \"abc\",vals = [1, -2, 3]) == 12\n assert candidate(s = \"abcdefgxyz\",chars = \"aceg\",vals = [-1, -2, -3, -4]) == 78\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",chars = \"a\",vals = [-1]) == 350\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",chars = \"abcdefghijklmnopqrstuvwxyz\",vals = [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]) == 702\n assert candidate(s = \"zzzzzzzzzz\",chars = \"z\",vals = [-1]) == 0\n assert candidate(s = \"abacabadabacaba\",chars = \"abc\",vals = [5, -1, 10]) == 60\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",chars = \"qwertyuiopasdfghjklzxcvbnm\",vals = [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]) == 13\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",chars = \"aeiou\",vals = [-10, -20, -30, -40, -50]) == 53\n assert candidate(s = \"mnopqrstuvwxyz\",chars = \"mnop\",vals = [10, 20, 30, 40]) == 315\n assert candidate(s = \"abcabcabcabcabc\",chars = \"abc\",vals = [1, 2, 3]) == 30\n assert candidate(s = \"bananabananabanana\",chars = \"ban\",vals = [1, -1, 2]) == 7\n assert candidate(s = \"hellohellohello\",chars = \"ehllo\",vals = [-100, 10, 20, 30, -5]) == 65\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",chars = \"aeiou\",vals = [10, 20, 30, 40, 50]) == 900\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",chars = \"zyxwvutsrqponmlkjihgfedcba\",vals = [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(s = \"abcdxyz\",chars = \"abcd\",vals = [4, 3, 2, 1]) == 85\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",chars = \"quickbrownfoxjumpsoverthelazydog\",vals = [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]) == 372\n assert candidate(s = \"xyzzzzzzzzzyx\",chars = \"z\",vals = [-5]) == 53\n assert candidate(s = \"aabbccddeeff\",chars = \"abcdef\",vals = [-1, -2, -3, -4, -5, -6]) == 0\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",chars = \"qwerty\",vals = [-1, -2, -3, -4, -5, -6]) == 243\n assert candidate(s = \"abcdefgabcdefg\",chars = \"aceg\",vals = [-1, -2, -3, -4]) == 9\n assert candidate(s = \"\",chars = \"\",vals = []) == 0\n assert candidate(s = \"mississippi\",chars = \"sip\",vals = [1, 2, -3]) == 23\n assert candidate(s = \"abcdef\",chars = \"\",vals = []) == 21\n assert candidate(s = \"mississippi\",chars = \"sip\",vals = [10, -5, 15]) == 68\n assert candidate(s = \"abcdabcdabcdabcd\",chars = \"abcd\",vals = [1, -1, 2, -2]) == 2\n assert candidate(s = \"abacabadabacaba\",chars = \"abc\",vals = [-1, 2, -3]) == 6\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",chars = \"a\",vals = [26]) == 376\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",chars = \"z\",vals = [-500]) == 0\n assert candidate(s = \"qwertypoiuytrewq\",chars = \"qwertyuiop\",vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 76\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",chars = \"abcdefghijklmnopqrstuvwxyz\",vals = [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]) == 702\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",chars = \"z\",vals = [1000]) == 1325\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",chars = \"mnopqrstuvwxyz\",vals = [-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]) == 78\n assert candidate(s = \"mnopqrstuvwxyz\",chars = \"mnopqrstuvwxyz\",vals = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 119\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",chars = \"abcdefghijklmnopqrstuvwxyz\",vals = [-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]) == 0\n assert candidate(s = \"mnopqrstu\",chars = \"mnopqrstu\",vals = [-1, -2, -3, -4, -5, -6, -7, -8, -9]) == 0\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",chars = \"aeiou\",vals = [5, 5, 5, 5, 5]) == 401\n assert candidate(s = \"aaabbbccc\",chars = \"abc\",vals = [-1, -2, -3]) == 0\n assert candidate(s = \"abacabadabacaba\",chars = \"abc\",vals = [-1, 3, -2]) == 8\n assert candidate(s = \"baaabbbccc\",chars = \"abc\",vals = [26, 25, 24]) == 250\n"}, "metadata": {"canonical_parameter_names": ["s", "chars", "vals"], "leetcode_dataset_entry_point": "Solution().maximumCostSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumCostSubstring(String s, String chars, int[] vals) {", "container": "Solution", "callable": "maximumCostSubstring", "parameters": [{"name": "s", "type": "String"}, {"name": "chars", "type": "String"}, {"name": "vals", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2607, "task_id": "make-k-subarray-sums-equal", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array arr and an integer k. The array arr is circular. In other words, the first element of the array is the next element of the last element, and the last element of the array is the previous element of the first element.\nYou can do the following operation any number of times:\n\nPick any element from arr and increase or decrease it by 1.\n\nReturn the minimum number of operations such that the sum of each subarray of length k is equal.\nA subarray is a contiguous part of the array.\n \nExample 1:\n\nInput: arr = [1,4,1,3], k = 2\nOutput: 1\nExplanation: we can do one operation on index 1 to make its value equal to 3.\nThe array after the operation is [1,3,1,3]\n- Subarray starts at index 0 is [1, 3], and its sum is 4 \n- Subarray starts at index 1 is [3, 1], and its sum is 4 \n- Subarray starts at index 2 is [1, 3], and its sum is 4 \n- Subarray starts at index 3 is [3, 1], and its sum is 4 \n\nExample 2:\n\nInput: arr = [2,5,5,7], k = 3\nOutput: 5\nExplanation: we can do three operations on index 0 to make its value equal to 5 and two operations on index 3 to make its value equal to 5.\nThe array after the operations is [5,5,5,5]\n- Subarray starts at index 0 is [5, 5, 5], and its sum is 15\n- Subarray starts at index 1 is [5, 5, 5], and its sum is 15\n- Subarray starts at index 2 is [5, 5, 5], and its sum is 15\n- Subarray starts at index 3 is [5, 5, 5], and its sum is 15 \n\n \nConstraints:\n\n1 <= k <= arr.length <= 105\n1 <= arr[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5],k = 1) == 6\n assert candidate(arr = [5, 5, 5, 5, 5],k = 2) == 0\n assert candidate(arr = [1, 4, 1, 3],k = 2) == 1\n assert candidate(arr = [10, 20, 30, 40, 50],k = 5) == 0\n assert candidate(arr = [5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 2) == 8\n assert candidate(arr = [10, 20, 30, 40, 50],k = 2) == 60\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 25\n assert candidate(arr = [2, 5, 5, 7],k = 3) == 5\n assert candidate(arr = [1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 6) == 1000\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 4) == 12\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 50\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 2500\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 3) == 180\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 25\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 25\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 200\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 1000\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 3) == 50\n assert candidate(arr = [2, 4, 2, 4, 2, 4, 2, 4],k = 2) == 0\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == 24\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 48\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30],k = 3) == 0\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 10) == 0\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7) == 0\n assert candidate(arr = [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 = 8) == 156\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300],k = 7) == 4200\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 125\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10],k = 4) == 20\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 250\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 2) == 12\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 2) == 0\n assert candidate(arr = [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, 8, 7, 6, 5],k = 13) == 70\n assert candidate(arr = [3, 8, 15, 7, 5, 12],k = 3) == 10\n assert candidate(arr = [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(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 2) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 96\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 2500\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 3) == 187\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 100\n assert candidate(arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 5) == 2500\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 10) == 0\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],k = 11) == 52\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 500\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 4) == 16\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 50\n assert candidate(arr = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10],k = 4) == 24\n assert candidate(arr = [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) == 0\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5],k = 4) == 34\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 7) == 50\n assert candidate(arr = [7, 3, 5, 2, 8, 6, 4, 9, 1, 10],k = 5) == 9\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 2) == 12\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 50\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 6) == 180\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7) == 0\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 10) == 100\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 6) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 24\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 2) == 240\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 100\n assert candidate(arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 4) == 240\n assert candidate(arr = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],k = 3) == 120\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995],k = 3) == 9\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 8) == 36\n assert candidate(arr = [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(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6) == 360\n assert candidate(arr = [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) == 200\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10],k = 3) == 70\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 48\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 10) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 6) == 36\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 0\n assert candidate(arr = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 6) == 54\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 20\n assert candidate(arr = [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 = 5) == 150\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 25\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 7) == 112\n assert candidate(arr = [9, 1, 8, 2, 7, 3, 6, 4, 5],k = 9) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5) == 100\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 4) == 0\n assert candidate(arr = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707],k = 5) == 1526\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2],k = 4) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 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 = 31) == 0\n assert candidate(arr = [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],k = 13) == 52\n assert candidate(arr = [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 = 3) == 75\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 19) == 200\n assert candidate(arr = [1, 3, 5, 7, 9, 11],k = 3) == 18\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 4) == 2400\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],k = 5) == 25\n assert candidate(arr = [1, 3, 2, 4, 6, 5, 7, 8, 10, 9],k = 4) == 24\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 6) == 150\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6) == 64\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 5) == 25\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 100\n assert candidate(arr = [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],k = 7) == 65\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 7) == 381\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 5) == 100\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 100\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().makeSubKSumEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long makeSubKSumEqual(int[] arr, int k) {", "container": "Solution", "callable": "makeSubKSumEqual", "parameters": [{"name": "arr", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2608, "task_id": "shortest-cycle-in-a-graph", "difficulty": "Hard", "problem_description": "There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1. The edges in the graph are represented by a given 2D integer array edges, where edges[i] = [ui, vi] denotes an edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.\nReturn the length of the shortest cycle in the graph. If no cycle exists, return -1.\nA cycle is a path that starts and ends at the same node, and each edge in the path is used only once.\n \nExample 1:\n\n\nInput: n = 7, edges = [[0,1],[1,2],[2,0],[3,4],[4,5],[5,6],[6,3]]\nOutput: 3\nExplanation: The cycle with the smallest length is : 0 -> 1 -> 2 -> 0 \n\nExample 2:\n\n\nInput: n = 4, edges = [[0,1],[0,2]]\nOutput: -1\nExplanation: There are no cycles in this graph.\n\n \nConstraints:\n\n2 <= n <= 1000\n1 <= edges.length <= 1000\nedges[i].length == 2\n0 <= ui, vi < n\nui != vi\nThere are no repeated edges.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5]]) == 4\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 4]]) == 4\n assert candidate(n = 3,edges = [[0, 1], [1, 2], [2, 0]]) == 3\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [3, 4], [4, 5]]) == 3\n assert candidate(n = 4,edges = [[0, 1], [0, 2]]) == -1\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4]]) == 4\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == 8\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 10\n assert candidate(n = 10,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == -1\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == 6\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 3]]) == 5\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == 5\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [3, 4], [4, 5], [5, 3]]) == 3\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == -1\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == -1\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 4], [4, 3], [3, 0], [0, 2]]) == 3\n assert candidate(n = 3,edges = [[0, 1], [1, 2]]) == -1\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 6], [6, 3]]) == 3\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == 3\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [2, 7]]) == 6\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]) == 3\n assert candidate(n = 20,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, 0], [5, 15], [10, 2]]) == 9\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [3, 9]]) == 7\n assert candidate(n = 15,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, 0], [1, 3], [2, 8], [5, 10]]) == 3\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]]) == 4\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [1, 3], [3, 5], [5, 7]]) == 3\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [0, 3], [2, 4], [1, 5], [6, 11], [7, 9], [8, 10]]) == 3\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5]]) == 6\n assert candidate(n = 15,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, 0], [1, 7], [4, 11]]) == 7\n assert candidate(n = 20,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, 0], [0, 10], [2, 12], [4, 14], [6, 16], [8, 18]]) == 6\n assert candidate(n = 15,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, 0], [0, 7], [3, 6], [5, 10]]) == 4\n assert candidate(n = 15,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, 0], [7, 11]]) == 5\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == 5\n assert candidate(n = 15,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, 0], [4, 10]]) == 7\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [0, 9], [1, 4], [4, 7], [7, 2], [2, 5], [5, 8], [8, 3], [3, 6], [6, 0]]) == 3\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 5], [9, 6]]) == 3\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 6], [0, 8]]) == 6\n assert candidate(n = 20,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, 0], [0, 10], [5, 15], [10, 15]]) == 6\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 3], [0, 6]]) == 7\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [1, 3]]) == 3\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [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, 15], [0, 15], [5, 20], [7, 19]]) == 5\n assert candidate(n = 30,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, 0], [0, 15], [5, 20]]) == 12\n assert candidate(n = 18,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, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 16]]) == 3\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5], [11, 12], [12, 13], [13, 14], [14, 11], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 15], [21, 22], [22, 23], [23, 24], [24, 21], [0, 10], [1, 20], [2, 22], [12, 19], [7, 21], [14, 24]]) == 4\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 6]]) == 4\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 5], [5, 6], [6, 7], [7, 8], [8, 5], [1, 6], [2, 7], [3, 8], [4, 5]]) == 3\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 10], [10, 11], [11, 7], [0, 7]]) == 3\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12]]) == 3\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 3], [3, 6], [6, 9]]) == 4\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 5], [0, 10], [3, 7]]) == 5\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5], [10, 11], [11, 12], [12, 13], [13, 10], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 14], [0, 5], [7, 12], [11, 16], [14, 2], [17, 0]]) == 4\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 15], [18, 19], [19, 18], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 3\n assert candidate(n = 30,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, 0], [0, 15], [5, 20], [10, 25]]) == 12\n assert candidate(n = 18,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, 0], [0, 8], [4, 12], [7, 15]]) == 6\n assert candidate(n = 20,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, 15], [0, 9], [5, 12], [7, 17]]) == 5\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [2, 8], [4, 10]]) == 6\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [0, 8], [1, 7], [2, 6], [3, 5], [4, 0], [5, 1], [6, 2], [7, 3], [8, 4]]) == 3\n assert candidate(n = 15,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, 0], [0, 7], [2, 9], [4, 11], [6, 13]]) == 5\n assert candidate(n = 25,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, 0], [0, 12], [5, 18]]) == 13\n assert candidate(n = 14,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, 0], [0, 7], [4, 11], [2, 8]]) == 5\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [0, 12], [5, 9]]) == 3\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 4], [2, 6], [1, 5], [3, 7]]) == 4\n assert candidate(n = 20,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, 0], [0, 10], [5, 15]]) == 11\n assert candidate(n = 11,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 4\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().findShortestCycle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findShortestCycle(int n, int[][] edges) {", "container": "Solution", "callable": "findShortestCycle", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2609, "task_id": "find-the-longest-balanced-substring-of-a-binary-string", "difficulty": "Easy", "problem_description": "You are given a binary string s consisting only of zeroes and ones.\nA substring of s is considered balanced if all zeroes are before ones and the number of zeroes is equal to the number of ones inside the substring. Notice that the empty substring is considered a balanced substring.\nReturn the length of the longest balanced substring of s.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"01000111\"\nOutput: 6\nExplanation: The longest balanced substring is \"000111\", which has length 6.\n\nExample 2:\n\nInput: s = \"00111\"\nOutput: 4\nExplanation: The longest balanced substring is \"0011\", which has length 4. \n\nExample 3:\n\nInput: s = \"111\"\nOutput: 0\nExplanation: There is no balanced substring except the empty substring, so the answer is 0.\n\n \nConstraints:\n\n1 <= s.length <= 50\n'0' <= s[i] <= '1'\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"000000111111\") == 12\n assert candidate(s = \"000111000111\") == 6\n assert candidate(s = \"000110\") == 4\n assert candidate(s = \"01\") == 2\n assert candidate(s = \"00111\") == 4\n assert candidate(s = \"0001100111\") == 4\n assert candidate(s = \"111\") == 0\n assert candidate(s = \"111111\") == 0\n assert candidate(s = \"0\") == 0\n assert candidate(s = \"111111000000\") == 0\n assert candidate(s = \"1100\") == 0\n assert candidate(s = \"\") == 0\n assert candidate(s = \"00001111\") == 8\n assert candidate(s = \"000000\") == 0\n assert candidate(s = \"10\") == 0\n assert candidate(s = \"01010101\") == 2\n assert candidate(s = \"010101\") == 2\n assert candidate(s = \"1\") == 0\n assert candidate(s = \"101010\") == 2\n assert candidate(s = \"01000111\") == 6\n assert candidate(s = \"0000000001111111110000000111111\") == 18\n assert candidate(s = \"101010101010101010\") == 2\n assert candidate(s = \"0000111100000000111111110000000011111111\") == 16\n assert candidate(s = \"111111111111111111111111\") == 0\n assert candidate(s = \"111000111000111000\") == 6\n assert candidate(s = \"0001110000111100001111\") == 8\n assert candidate(s = \"000000011111110000011111\") == 14\n assert candidate(s = \"0000000000000011111111111111\") == 28\n assert candidate(s = \"0000000000111111111100000000001111111111\") == 20\n assert candidate(s = \"00111111001111110011111100111111\") == 4\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == 2\n assert candidate(s = \"11111111110000000000000000000000\") == 0\n assert candidate(s = \"0001000100010001000100010001000100010001\") == 2\n assert candidate(s = \"110011001100110011001100\") == 4\n assert candidate(s = \"000111000111000111000111000111000111000111000111\") == 6\n assert candidate(s = \"010101010101010101010101\") == 2\n assert candidate(s = \"0000000000000000000000000001111111111111111111111111111111\") == 54\n assert candidate(s = \"00000000111111110000000011111111\") == 16\n assert candidate(s = \"000000000000111111111111\") == 24\n assert candidate(s = \"00000000001111111111000111\") == 20\n assert candidate(s = \"00000000000000001111111111111111\") == 32\n assert candidate(s = \"11000111000111000111\") == 6\n assert candidate(s = \"001100110011001100110011\") == 4\n assert candidate(s = \"111111111100000000001111\") == 8\n assert candidate(s = \"0000000111110011000111\") == 10\n assert candidate(s = \"000111000111000111\") == 6\n assert candidate(s = \"101010101010101010101010\") == 2\n assert candidate(s = \"0001110111000111000111\") == 6\n assert candidate(s = \"0100010001000100010001000100010\") == 2\n assert candidate(s = \"000000000000000000001111111111111111\") == 32\n assert candidate(s = \"110000001111111111\") == 12\n assert candidate(s = \"00110011000000111111000000\") == 12\n assert candidate(s = \"1010101010\") == 2\n assert candidate(s = \"010101010101010101\") == 2\n assert candidate(s = \"110000111100000011111100000000011111\") == 12\n assert candidate(s = \"111000111000111000111000111000\") == 6\n assert candidate(s = \"000111000111000111000111\") == 6\n assert candidate(s = \"000000011111110000000111111100000001111111\") == 14\n assert candidate(s = \"01010101010101010101010101010101010101\") == 2\n assert candidate(s = \"000000111111000000111111000000111111\") == 12\n assert candidate(s = \"000111000011110000011111000000111111\") == 12\n assert candidate(s = \"111100001111000011110000\") == 8\n assert candidate(s = \"10001100110011\") == 4\n assert candidate(s = \"11000011000011000011000011000011\") == 4\n assert candidate(s = \"0000111100011100001111\") == 8\n assert candidate(s = \"111111111110000000000000000\") == 0\n assert candidate(s = \"111111111111111111110000000000000000\") == 0\n assert candidate(s = \"0011001100110011\") == 4\n assert candidate(s = \"000001110000011100000111\") == 6\n assert candidate(s = \"0000111100110011\") == 8\n assert candidate(s = \"10101010101010101010101\") == 2\n assert candidate(s = \"000000000001111111111111111\") == 22\n assert candidate(s = \"0000111100001111000011110000\") == 8\n assert candidate(s = \"0000000111111000011111\") == 12\n assert candidate(s = \"000100010001000100010001\") == 2\n assert candidate(s = \"00000000000001111111111111100000000001111111111111000000000\") == 26\n assert candidate(s = \"111111111111\") == 0\n assert candidate(s = \"000011100110001110011000111\") == 6\n assert candidate(s = \"00011000110001100011000110001100011\") == 4\n assert candidate(s = \"10101010101010101010101010101010101010\") == 2\n assert candidate(s = \"00110001100011000110001100011\") == 4\n assert candidate(s = \"101010101010\") == 2\n assert candidate(s = \"00000001111111\") == 14\n assert candidate(s = \"0110110110110110110110\") == 2\n assert candidate(s = \"100000001000000010000000\") == 2\n assert candidate(s = \"000111000001111000000111110000000111111\") == 12\n assert candidate(s = \"000011000011000011000011\") == 4\n assert candidate(s = \"111000111000111000111000111000111\") == 6\n assert candidate(s = \"00010001000111111111\") == 6\n assert candidate(s = \"000000000111111111\") == 18\n assert candidate(s = \"0001110000111000111000111\") == 6\n assert candidate(s = \"11111100000000000000111111111111\") == 24\n assert candidate(s = \"1110000111100001111000\") == 8\n assert candidate(s = \"11111100000000000000\") == 0\n assert candidate(s = \"111111000000000000000000\") == 0\n assert candidate(s = \"1111110000001111000000\") == 8\n assert candidate(s = \"1010101010101010101010101010101010\") == 2\n assert candidate(s = \"1111111100000001111111000000011111110000000111111100000000\") == 14\n assert candidate(s = \"00000000001111111111\") == 20\n assert candidate(s = \"00000111110000011111\") == 10\n assert candidate(s = \"00000000000111111111100000000001111111\") == 20\n assert candidate(s = \"000000000111100000001111000000001111\") == 8\n assert candidate(s = \"0000000011111111000000001111111100000000\") == 16\n assert candidate(s = \"111000111000111000111\") == 6\n assert candidate(s = \"010010001000010000001\") == 2\n assert candidate(s = \"1001001001001001\") == 2\n assert candidate(s = \"00000011111000000011111000000011111\") == 10\n assert candidate(s = \"11111111110000000000\") == 0\n assert candidate(s = \"1111000000111111\") == 12\n assert candidate(s = \"01010101010101010101010101010101\") == 2\n assert candidate(s = \"11001100110011001100\") == 4\n assert candidate(s = \"0101010101010101010101010101010101010101\") == 2\n assert candidate(s = \"1111111100000000111111110000000011111111\") == 16\n assert candidate(s = \"1111000001111000001111000001111000001111\") == 8\n assert candidate(s = \"0000000111111100000001111111\") == 14\n assert candidate(s = \"010000001111101000111010000111000011111110000011111000001111\") == 10\n assert candidate(s = \"011111110111111101111111\") == 2\n assert candidate(s = \"1100110011001100110011001100\") == 4\n assert candidate(s = \"010101010101\") == 2\n assert candidate(s = \"111110000001111100000111110000011111\") == 10\n assert candidate(s = \"11000110001100011000110001100011\") == 4\n assert candidate(s = \"0101010101010101\") == 2\n assert candidate(s = \"00000011111111\") == 12\n assert candidate(s = \"000000000000000000000000\") == 0\n assert candidate(s = \"000111000111000111000111000111\") == 6\n assert candidate(s = \"00010001000100010001\") == 2\n assert candidate(s = \"1100001111000011111\") == 8\n assert candidate(s = \"111111111111100000000000000111111111111000000000000111111111111\") == 24\n assert candidate(s = \"000011000011000011000011000011\") == 4\n assert candidate(s = \"000011110000111100001111\") == 8\n assert candidate(s = \"00000111100000000111111110000011111111000001111111000\") == 16\n assert candidate(s = \"10000000001111111111\") == 18\n assert candidate(s = \"0101010101\") == 2\n assert candidate(s = \"00001111000011110000111100001111\") == 8\n assert candidate(s = \"000110001100011\") == 4\n assert candidate(s = \"111111000000111111000000111111000000\") == 12\n assert candidate(s = \"00110011001100110011\") == 4\n assert candidate(s = \"00001111000111\") == 8\n assert candidate(s = \"0000001111100111\") == 10\n assert candidate(s = \"0110011001100110011\") == 4\n assert candidate(s = \"0000000011111111\") == 16\n assert candidate(s = \"1001001001001001001001001\") == 2\n assert candidate(s = \"111111111111111111111110000000000000000000000000\") == 0\n assert candidate(s = \"100000000000111111111111111000000000001111111111111111\") == 22\n assert candidate(s = \"0101010101010101010101010101010101010101010101\") == 2\n assert candidate(s = \"0000000011111100000111110000011111\") == 12\n assert candidate(s = \"000000000000000000000001111111111111111111111111\") == 46\n assert candidate(s = \"1010101010101010101010101010101010101010101010\") == 2\n assert candidate(s = \"001001001001001001001001001001001001001\") == 2\n assert candidate(s = \"00000111100001110011\") == 8\n assert candidate(s = \"1001001001001\") == 2\n assert candidate(s = \"010010010010010010010010010010010010010\") == 2\n assert candidate(s = \"001010110011000111\") == 6\n assert candidate(s = \"111000111000111000111000111000111000111000111\") == 6\n assert candidate(s = \"0110011001100110\") == 4\n assert candidate(s = \"0000000000001111111111111110000000000011111111111111110000000000011111111111111\") == 24\n assert candidate(s = \"00000000000000111111111111111111\") == 28\n assert candidate(s = \"00011100001111\") == 8\n assert candidate(s = \"01010101010101010101010101010101010101010101\") == 2\n assert candidate(s = \"001001001001\") == 2\n assert candidate(s = \"0011001100110011001100110011\") == 4\n assert candidate(s = \"01010101010101010101\") == 2\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101\") == 2\n assert candidate(s = \"11001100110011\") == 4\n assert candidate(s = \"1001001001001001001001001001\") == 2\n assert candidate(s = \"000111010001110011\") == 6\n assert candidate(s = \"0000011111111100000000111111000000\") == 12\n assert candidate(s = \"000001111100000111110000011111\") == 10\n assert candidate(s = \"000000000011111111111111\") == 20\n assert candidate(s = \"1110000000111000000111\") == 6\n assert candidate(s = \"11111111111111110000000000000000\") == 0\n assert candidate(s = \"10101010101010101010\") == 2\n assert candidate(s = \"00000000111111100000111100000111111100000000111111100000000\") == 14\n assert candidate(s = \"000110000111000001111\") == 8\n assert candidate(s = \"10101010101010\") == 2\n assert candidate(s = \"111111000000000000111111111\") == 18\n assert candidate(s = \"111000111000111000111000\") == 6\n assert candidate(s = \"11001100110011001100110011\") == 4\n assert candidate(s = \"000000011111000000011111000000011111\") == 10\n assert candidate(s = \"0000000000011111111111\") == 22\n assert candidate(s = \"010010001000010000000100000000001\") == 2\n assert candidate(s = \"11111111111111111111111111110000000000000000000000000000000\") == 0\n assert candidate(s = \"00111000111000111000111000111\") == 6\n assert candidate(s = \"001100110011\") == 4\n assert candidate(s = \"0000111100001111\") == 8\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().findTheLongestBalancedSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findTheLongestBalancedSubstring(String s) {", "container": "Solution", "callable": "findTheLongestBalancedSubstring", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2610, "task_id": "convert-an-array-into-a-2d-array-with-conditions", "difficulty": "Medium", "problem_description": "You are given an integer array nums. You need to create a 2D array from nums satisfying the following conditions:\n\nThe 2D array should contain only the elements of the array nums.\nEach row in the 2D array contains distinct integers.\nThe number of rows in the 2D array should be minimal.\n\nReturn the resulting array. If there are multiple answers, return any of them.\nNote that the 2D array can have a different number of elements on each row.\n \nExample 1:\n\nInput: nums = [1,3,4,1,2,3,1]\nOutput: [[1,3,4,2],[1,3],[1]]\nExplanation: We can create a 2D array that contains the following rows:\n- 1,3,4,2\n- 1,3\n- 1\nAll elements of nums were used, and each row of the 2D array contains distinct integers, so it is a valid answer.\nIt can be shown that we cannot have less than 3 rows in a valid array.\nExample 2:\n\nInput: nums = [1,2,3,4]\nOutput: [[4,3,2,1]]\nExplanation: All elements of the array are distinct, so we can keep all of them in the first row of the 2D array.\n\n \nConstraints:\n\n1 <= nums.length <= 200\n1 <= nums[i] <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [[1, 2, 3, 4], [2, 3, 4], [3, 4], [4]]\n assert candidate(nums = [1, 2, 3, 4]) == [[1, 2, 3, 4]]\n assert candidate(nums = [10, 1, 2, 9, 3, 8, 4, 7, 5, 6]) == [[10, 1, 2, 9, 3, 8, 4, 7, 5, 6]]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == [[1, 2, 3, 4], [1, 2, 3, 4]]\n assert candidate(nums = [1, 1, 1, 1]) == [[1], [1], [1], [1]]\n assert candidate(nums = [1, 2, 1, 3, 4, 2, 3]) == [[1, 2, 3, 4], [1, 2, 3]]\n assert candidate(nums = [5, 3, 3, 2, 1, 2, 4, 5]) == [[5, 3, 2, 1, 4], [5, 3, 2]]\n assert candidate(nums = [5, 5, 5, 5, 5]) == [[5], [5], [5], [5], [5]]\n assert candidate(nums = [7, 8, 9, 10, 7, 8, 9]) == [[7, 8, 9, 10], [7, 8, 9]]\n assert candidate(nums = [10, 9, 10, 8, 7, 9, 8, 10, 9]) == [[10, 9, 8, 7], [10, 9, 8], [10, 9]]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [[10, 9, 8, 7, 6, 5, 4, 3, 2, 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]]\n assert candidate(nums = [1, 3, 4, 1, 2, 3, 1]) == [[1, 3, 4, 2], [1, 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, 2, 3, 4, 5]) == [[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]]\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, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == [[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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 200, 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, 200], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 4, 3, 2, 1], [5, 4, 3, 2, 1], [5, 4, 3, 2, 1], [5, 4, 3, 2, 1], [5, 4, 3, 2, 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]]\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, 10, 9, 8, 7, 6, 5]) == [[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], [10, 9, 8, 7, 6, 5]]\n assert candidate(nums = [100, 50, 75, 25, 125, 62, 87, 31, 156, 78, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 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]) == [[100, 50, 75, 25, 125, 62, 87, 31, 156, 78, 1, 5, 10, 15, 20, 30, 35, 40, 45, 55, 60, 65, 70, 80, 85, 90, 95, 2, 3, 4, 6, 7, 8, 9], [100, 50, 75, 25, 1, 5, 10, 20, 30, 40, 60, 70, 80, 90, 2, 3, 4, 6, 7, 8, 9], [100, 50, 1, 5, 10, 2, 3, 4, 6, 7, 8, 9], [1, 5, 10], [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, 1, 2, 3, 4, 5, 5, 4, 3, 2, 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], [1, 2, 3, 4, 5]]\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]) == [[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]]\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]) == [[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]]\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]]\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100, 1, 2]) == [[100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [100, 1, 2]]\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 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]) == [[200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 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]]\n assert candidate(nums = [3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [[3, 2, 1, 4, 5], [3, 2, 1, 4, 5], [3, 2, 1, 4, 5], [3, 2, 1, 5], [3, 5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5]]\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]]\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]]\n assert candidate(nums = [1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 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], [1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5], [1, 2, 3, 4], [1, 2, 3], [1, 2], [1]]\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]]\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, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]\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, 6]) == [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6], [3, 4, 5, 6], [4, 5, 6], [5, 6], [6], [6]]\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [[2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [2], [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(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]) == [[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], [1, 2, 3, 4, 5]]\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, 19, 18]) == [[20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [20, 19, 18]]\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, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == [[20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 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, 11, 11, 12, 12, 13, 13, 14, 14]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 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]) == [[5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5]]\n assert candidate(nums = [5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9]) == [[5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [5, 6, 7, 8, 9]]\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180]) == [[200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180]]\n assert candidate(nums = [10, 20, 10, 30, 20, 10, 40, 30, 20, 10, 50, 40, 30, 20, 10]) == [[10, 20, 30, 40, 50], [10, 20, 30, 40], [10, 20, 30], [10, 20], [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]) == [[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, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6]) == [[5, 6], [5, 6], [5, 6], [5, 6], [5, 6], [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]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]\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]) == [[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]]\n assert candidate(nums = [10, 20, 10, 30, 20, 10, 40, 30, 20, 10, 50, 40, 30, 20, 10, 60, 50, 40, 30, 20]) == [[10, 20, 30, 40, 50, 60], [10, 20, 30, 40, 50], [10, 20, 30, 40], [10, 20, 30], [10, 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, 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, 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]]\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]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3], [1, 2, 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]]\n assert candidate(nums = [3, 3, 3, 2, 2, 2, 1, 1, 1, 3, 3, 2, 2, 1, 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], [3, 2, 1]]\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]) == [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5], [1, 2, 3, 4], [1, 2, 3], [1, 2], [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]) == [[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]]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == [[15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [15, 14, 13, 12, 11]]\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]) == [[1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5], [1, 2, 3, 4], [1, 2, 3], [1, 2], [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]) == [[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]]\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], [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]) == [[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(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 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]) == [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29], [10, 20, 30]]\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, 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]]\n assert candidate(nums = [3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [[3, 2, 1], [3, 2, 1], [3, 2, 1], [2, 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, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6], [3, 4, 5, 6], [4, 5, 6], [5, 6], [5, 6], [6], [6], [6], [6], [6], [6], [6], [6]]\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]) == [[1, 2, 3, 4, 5, 6, 7, 8], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8], [5, 6, 7, 8], [6, 7, 8], [7, 8], [8]]\n assert candidate(nums = [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]]\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]) == [[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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 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, 10, 10, 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]]\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, 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]) == [[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]]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6]) == [[3, 1, 2, 4, 5, 6], [3, 1, 2, 4, 5, 6], [3, 1, 2, 4, 5, 6], [3, 2, 5], [3, 2, 5], [3, 2, 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, 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], [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]]\n assert candidate(nums = [1, 2, 2, 1, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9, 10, 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], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(nums = [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]) == [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]\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 = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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], [1, 2, 3, 4, 5], [1, 2, 4, 5], [1, 4, 5], [4, 5], [4, 5], [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], [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, 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]]\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], [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]]\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]]\n assert candidate(nums = [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]) == [[15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findMatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List> findMatrix(int[] nums) {", "container": "Solution", "callable": "findMatrix", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "List>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2611, "task_id": "mice-and-cheese", "difficulty": "Medium", "problem_description": "There are two mice and n different types of cheese, each type of cheese should be eaten by exactly one mouse.\nA point of the cheese with index i (0-indexed) is:\n\nreward1[i] if the first mouse eats it.\nreward2[i] if the second mouse eats it.\n\nYou are given a positive integer array reward1, a positive integer array reward2, and a non-negative integer k.\nReturn the maximum points the mice can achieve if the first mouse eats exactly k types of cheese.\n \nExample 1:\n\nInput: reward1 = [1,1,3,4], reward2 = [4,4,1,1], k = 2\nOutput: 15\nExplanation: In this example, the first mouse eats the 2nd (0-indexed) and the 3rd types of cheese, and the second mouse eats the 0th and the 1st types of cheese.\nThe total points are 4 + 4 + 3 + 4 = 15.\nIt can be proven that 15 is the maximum total points that the mice can achieve.\n\nExample 2:\n\nInput: reward1 = [1,1], reward2 = [1,1], k = 2\nOutput: 2\nExplanation: In this example, the first mouse eats the 0th (0-indexed) and 1st types of cheese, and the second mouse does not eat any cheese.\nThe total points are 1 + 1 = 2.\nIt can be proven that 2 is the maximum total points that the mice can achieve.\n\n \nConstraints:\n\n1 <= n == reward1.length == reward2.length <= 105\n1 <= reward1[i], reward2[i] <= 1000\n0 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(reward1 = [10, 20, 30, 40],reward2 = [40, 30, 20, 10],k = 3) == 130\n assert candidate(reward1 = [5, 4, 3, 2, 1],reward2 = [1, 2, 3, 4, 5],k = 3) == 21\n assert candidate(reward1 = [10, 20, 30],reward2 = [40, 50, 60],k = 0) == 150\n assert candidate(reward1 = [1, 2, 3, 4, 5],reward2 = [5, 4, 3, 2, 1],k = 3) == 21\n assert candidate(reward1 = [7, 5, 3, 1],reward2 = [6, 4, 2, 0],k = 4) == 16\n assert candidate(reward1 = [5, 4, 3],reward2 = [1, 2, 3],k = 1) == 10\n assert candidate(reward1 = [7, 8, 9],reward2 = [10, 11, 12],k = 3) == 24\n assert candidate(reward1 = [100, 100, 100],reward2 = [1, 1, 1],k = 0) == 3\n assert candidate(reward1 = [10, 20, 30],reward2 = [30, 20, 10],k = 2) == 80\n assert candidate(reward1 = [7, 8, 9],reward2 = [1, 2, 3],k = 3) == 24\n assert candidate(reward1 = [1, 1, 3, 4],reward2 = [4, 4, 1, 1],k = 2) == 15\n assert candidate(reward1 = [5, 4, 3],reward2 = [1, 1, 1],k = 1) == 7\n assert candidate(reward1 = [1, 2, 3, 4, 5],reward2 = [5, 4, 3, 2, 1],k = 5) == 15\n assert candidate(reward1 = [100, 200, 300, 400],reward2 = [400, 300, 200, 100],k = 2) == 1400\n assert candidate(reward1 = [10, 20, 30],reward2 = [3, 6, 9],k = 0) == 18\n assert candidate(reward1 = [10, 20, 30],reward2 = [30, 20, 10],k = 0) == 60\n assert candidate(reward1 = [1, 1],reward2 = [1, 1],k = 2) == 2\n assert candidate(reward1 = [1, 3, 5, 7, 9],reward2 = [2, 4, 6, 8, 10],k = 2) == 28\n assert candidate(reward1 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],reward2 = [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2],k = 10) == 330\n assert candidate(reward1 = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],reward2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 10\n assert candidate(reward1 = [1, 3, 5, 7, 9, 11, 13, 15],reward2 = [2, 4, 6, 8, 10, 12, 14, 16],k = 4) == 68\n assert candidate(reward1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],reward2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 0) == 550\n assert candidate(reward1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],reward2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 55\n assert candidate(reward1 = [100, 200, 300, 400, 500, 600],reward2 = [10, 20, 30, 40, 50, 60],k = 2) == 1200\n assert candidate(reward1 = [100, 200, 300, 400, 500],reward2 = [10, 20, 30, 40, 50],k = 2) == 960\n assert candidate(reward1 = [50, 40, 30, 20, 10],reward2 = [10, 20, 30, 40, 50],k = 0) == 150\n assert candidate(reward1 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],reward2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 4040\n assert candidate(reward1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],reward2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 176\n assert candidate(reward1 = [100, 200, 300, 400, 500],reward2 = [5, 10, 15, 20, 25],k = 2) == 930\n assert candidate(reward1 = [1, 1, 1, 1, 1, 1],reward2 = [999, 999, 999, 999, 999, 999],k = 3) == 3000\n assert candidate(reward1 = [5, 5, 5, 5, 5],reward2 = [1, 2, 3, 4, 5],k = 5) == 25\n assert candidate(reward1 = [999, 1, 1, 1, 1, 1],reward2 = [1, 999, 1, 1, 1, 1],k = 1) == 2002\n assert candidate(reward1 = [500, 500, 500, 500, 500],reward2 = [500, 500, 500, 500, 500],k = 2) == 2500\n assert candidate(reward1 = [1, 2, 3, 4, 5],reward2 = [200, 200, 200, 200, 200],k = 3) == 412\n assert candidate(reward1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],reward2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 0) == 55\n assert candidate(reward1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],reward2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 0) == 110\n assert candidate(reward1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],reward2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 55\n assert candidate(reward1 = [100, 200, 300, 400, 500],reward2 = [90, 190, 290, 390, 490],k = 2) == 1470\n assert candidate(reward1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],reward2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == 800\n assert candidate(reward1 = [500, 400, 300, 200, 100],reward2 = [100, 200, 300, 400, 500],k = 0) == 1500\n assert candidate(reward1 = [500, 400, 300, 200, 100],reward2 = [50, 100, 150, 200, 250],k = 4) == 1650\n assert candidate(reward1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],reward2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 405\n assert candidate(reward1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],reward2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],k = 5) == 42\n assert candidate(reward1 = [100, 200, 300, 400, 500],reward2 = [500, 400, 300, 200, 100],k = 0) == 1500\n assert candidate(reward1 = [200, 200, 200, 200, 200],reward2 = [1, 2, 3, 4, 5],k = 2) == 412\n assert candidate(reward1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],reward2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 30\n assert candidate(reward1 = [8, 6, 7, 5, 3, 0, 9],reward2 = [1, 2, 3, 4, 5, 6, 7],k = 4) == 45\n assert candidate(reward1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],reward2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 5500\n assert candidate(reward1 = [1000, 1000, 1000, 1000],reward2 = [1, 1, 1, 1],k = 0) == 4\n assert candidate(reward1 = [1, 3, 5, 7, 9, 11, 13, 15],reward2 = [2, 4, 6, 8, 10, 12, 14, 16],k = 4) == 68\n assert candidate(reward1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],reward2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(reward1 = [90, 80, 70, 60, 50],reward2 = [10, 20, 30, 40, 50],k = 2) == 290\n assert candidate(reward1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],reward2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 415\n assert candidate(reward1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],reward2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 550\n assert candidate(reward1 = [100, 100, 100, 100, 100],reward2 = [1, 2, 3, 4, 5],k = 3) == 309\n assert candidate(reward1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],reward2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 30\n assert candidate(reward1 = [1, 2, 3, 4, 5],reward2 = [5, 4, 3, 2, 1],k = 5) == 15\n assert candidate(reward1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],reward2 = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == 65\n assert candidate(reward1 = [100, 100, 100, 100],reward2 = [50, 50, 50, 50],k = 2) == 300\n assert candidate(reward1 = [1000, 1000, 1000, 1000, 1000],reward2 = [900, 900, 900, 900, 900],k = 5) == 5000\n assert candidate(reward1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],reward2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5) == 105\n assert candidate(reward1 = [10, 20, 30, 40, 50],reward2 = [5, 15, 25, 35, 45],k = 3) == 140\n assert candidate(reward1 = [900, 800, 700, 600, 500, 400, 300, 200, 100, 0],reward2 = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900],k = 5) == 7000\n assert candidate(reward1 = [900, 800, 700, 600, 500],reward2 = [100, 200, 300, 400, 500],k = 2) == 2900\n assert candidate(reward1 = [800, 900, 700, 600, 500],reward2 = [100, 200, 300, 400, 500],k = 1) == 2200\n assert candidate(reward1 = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],reward2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5025\n assert candidate(reward1 = [10, 20, 30, 40, 50],reward2 = [500, 400, 300, 200, 100],k = 2) == 1290\n assert candidate(reward1 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],reward2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 5500\n assert candidate(reward1 = [500, 400, 300, 200, 100],reward2 = [1000, 900, 800, 700, 600],k = 5) == 1500\n assert candidate(reward1 = [9, 18, 27, 36, 45, 54],reward2 = [6, 12, 18, 24, 30, 36],k = 2) == 159\n assert candidate(reward1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],reward2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 55\n assert candidate(reward1 = [100, 200, 300, 400, 500],reward2 = [500, 400, 300, 200, 100],k = 3) == 2100\n assert candidate(reward1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],reward2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 80\n assert candidate(reward1 = [5, 5, 5, 5, 5],reward2 = [100, 200, 300, 400, 500],k = 0) == 1500\n assert candidate(reward1 = [50, 40, 30, 20, 10],reward2 = [10, 20, 30, 40, 50],k = 0) == 150\n assert candidate(reward1 = [100, 100, 100],reward2 = [10, 20, 30],k = 0) == 60\n assert candidate(reward1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],reward2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 55\n assert candidate(reward1 = [1000, 900, 800, 700, 600],reward2 = [10, 20, 30, 40, 50],k = 3) == 2790\n assert candidate(reward1 = [50, 30, 10, 20, 40],reward2 = [40, 20, 30, 10, 50],k = 4) == 170\n assert candidate(reward1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],reward2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 50\n assert candidate(reward1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],reward2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 176\n assert candidate(reward1 = [500, 400, 300, 200, 100],reward2 = [1, 2, 3, 4, 5],k = 5) == 1500\n assert candidate(reward1 = [1, 2, 3, 4, 5],reward2 = [500, 400, 300, 200, 100],k = 0) == 1500\n assert candidate(reward1 = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],reward2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 55\n assert candidate(reward1 = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],reward2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 3043\n assert candidate(reward1 = [1000, 900, 800, 700, 600],reward2 = [500, 600, 700, 800, 900],k = 5) == 4000\n assert candidate(reward1 = [900, 800, 700, 600, 500],reward2 = [100, 200, 300, 400, 500],k = 4) == 3500\n assert candidate(reward1 = [100, 200, 300, 400, 500],reward2 = [50, 150, 250, 350, 450],k = 3) == 1400\n assert candidate(reward1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],reward2 = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 3) == 7003\n assert candidate(reward1 = [10, 20, 30, 40, 50],reward2 = [5, 15, 25, 35, 45],k = 3) == 140\n assert candidate(reward1 = [100, 90, 80, 70, 60],reward2 = [10, 20, 30, 40, 50],k = 2) == 310\n assert candidate(reward1 = [10, 10, 10, 10, 10, 10],reward2 = [9, 9, 9, 9, 9, 9],k = 3) == 57\n assert candidate(reward1 = [100, 200, 300, 400, 500, 600],reward2 = [60, 50, 40, 30, 20, 10],k = 2) == 1280\n assert candidate(reward1 = [300, 200, 100],reward2 = [100, 200, 300],k = 1) == 800\n assert candidate(reward1 = [100, 200, 300, 400],reward2 = [150, 250, 350, 450],k = 1) == 1150\n assert candidate(reward1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],reward2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 272\n"}, "metadata": {"canonical_parameter_names": ["reward1", "reward2", "k"], "leetcode_dataset_entry_point": "Solution().miceAndCheese", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int miceAndCheese(int[] reward1, int[] reward2, int k) {", "container": "Solution", "callable": "miceAndCheese", "parameters": [{"name": "reward1", "type": "int[]"}, {"name": "reward2", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2614, "task_id": "prime-in-diagonal", "difficulty": "Easy", "problem_description": "You are given a 0-indexed two-dimensional integer array nums.\nReturn the largest prime number that lies on at least one of the diagonals of nums. In case, no prime is present on any of the diagonals, return 0.\nNote that:\n\nAn integer is prime if it is greater than 1 and has no positive integer divisors other than 1 and itself.\nAn integer val is on one of the diagonals of nums if there exists an integer i for which nums[i][i] = val or an i for which nums[i][nums.length - i - 1] = val.\n\n\nIn the above diagram, one diagonal is [1,5,9] and another diagonal is [3,5,7].\n \nExample 1:\n\nInput: nums = [[1,2,3],[5,6,7],[9,10,11]]\nOutput: 11\nExplanation: The numbers 1, 3, 6, 9, and 11 are the only numbers present on at least one of the diagonals. Since 11 is the largest prime, we return 11.\n\nExample 2:\n\nInput: nums = [[1,2,3],[5,17,7],[9,11,10]]\nOutput: 17\nExplanation: The numbers 1, 3, 9, 10, and 17 are all present on at least one of the diagonals. 17 is the largest prime, so we return 17.\n\n \nConstraints:\n\n1 <= nums.length <= 300\nnums.length == numsi.length\n1 <= nums[i][j] <= 4*106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [[4, 6, 8], [10, 12, 14], [16, 18, 20]]) == 0\n assert candidate(nums = [[3, 1, 4], [1, 5, 9], [2, 6, 5]]) == 5\n assert candidate(nums = [[1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12], [13, 14, 15, 16]]) == 13\n assert candidate(nums = [[31, 33, 35], [37, 39, 41], [43, 45, 47]]) == 47\n assert candidate(nums = [[31, 12, 43], [55, 67, 79], [81, 97, 101]]) == 101\n assert candidate(nums = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 0\n assert candidate(nums = [[2, 3, 5], [3, 5, 7], [5, 7, 11]]) == 11\n assert candidate(nums = [[1, 2, 3], [5, 6, 7], [9, 10, 11]]) == 11\n assert candidate(nums = [[1, 2, 3], [5, 17, 7], [9, 11, 10]]) == 17\n assert candidate(nums = [[2, 3, 5], [7, 11, 13], [17, 19, 23]]) == 23\n assert candidate(nums = [[2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [20, 22, 23, 25, 27], [28, 30, 31, 32, 34], [35, 36, 37, 38, 39]]) == 23\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [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]]) == 491\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]]) == 0\n assert candidate(nums = [[4, 6, 8, 10, 12, 14], [16, 18, 20, 22, 24, 26], [28, 30, 31, 32, 34, 36], [38, 40, 41, 42, 44, 46], [48, 50, 51, 52, 54, 56], [58, 60, 61, 62, 64, 66]]) == 41\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]]) == 97\n assert candidate(nums = [[1009, 1010, 1011, 1012], [1013, 1014, 1015, 1016], [1017, 1018, 1019, 1020], [1021, 1022, 1023, 1024]]) == 1021\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]]) == 29\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]]) == 29\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7], [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]]) == 7\n assert candidate(nums = [[79, 83, 89, 97, 101], [83, 89, 97, 101, 103], [89, 97, 101, 103, 107], [97, 101, 103, 107, 109], [101, 103, 107, 109, 113]]) == 113\n assert candidate(nums = [[2, 1, 1, 1, 2], [1, 2, 1, 2, 1], [1, 1, 2, 1, 1], [1, 2, 1, 2, 1], [2, 1, 1, 1, 2]]) == 2\n assert candidate(nums = [[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, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 13, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 17, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 19, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 23, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 29, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 31, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 41, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 43]]) == 43\n assert candidate(nums = [[3, 7, 11, 13, 17, 19], [7, 11, 13, 17, 19, 23], [11, 13, 17, 19, 23, 29], [13, 17, 19, 23, 29, 31], [17, 19, 23, 29, 31, 37], [19, 23, 29, 31, 37, 41]]) == 41\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, 47, 46, 45, 48, 49, 50], [51, 52, 53, 54, 55, 59, 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, 101]]) == 101\n assert candidate(nums = [[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31], [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 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, 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, 137]]) == 137\n assert candidate(nums = [[4, 6, 8, 10, 12, 14], [16, 18, 20, 22, 24, 26], [28, 30, 31, 32, 34, 36], [38, 40, 42, 43, 44, 46], [48, 50, 52, 54, 56, 58], [60, 62, 64, 66, 68, 70]]) == 43\n assert candidate(nums = [[2, 1, 1, 1, 1, 1, 3], [1, 2, 1, 1, 1, 3, 1], [1, 1, 2, 1, 3, 1, 1], [1, 1, 1, 2, 1, 1, 1], [1, 1, 3, 1, 2, 1, 1], [1, 3, 1, 1, 1, 2, 1], [3, 1, 1, 1, 1, 1, 2]]) == 3\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]]) == 97\n assert candidate(nums = [[101, 102, 103, 104, 105, 106, 107, 108, 109], [110, 111, 112, 113, 114, 115, 116, 117, 118], [119, 121, 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]]) == 467\n assert candidate(nums = [[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]]) == 197\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, 101]]) == 101\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]]) == 43\n assert candidate(nums = [[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31], [37, 39, 41, 43, 47, 51, 53, 57, 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, 503], [509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587], [593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647]]) == 647\n assert candidate(nums = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 3, 1], [1, 1, 1, 1, 5, 1, 1], [1, 1, 1, 7, 1, 1, 1], [1, 1, 11, 1, 1, 1, 1], [1, 13, 1, 1, 1, 1, 1]]) == 0\n assert candidate(nums = [[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]]) == 467\n assert candidate(nums = [[1000003, 1000009, 1000019, 1000021], [1000031, 1000033, 1000037, 1000039], [1000043, 1000049, 1000051, 1000061], [1000063, 1000067, 1000069, 1000073]]) == 1000037\n assert candidate(nums = [[1, 4, 9, 16, 25], [4, 9, 16, 25, 36], [9, 16, 25, 36, 49], [16, 25, 36, 49, 64], [25, 36, 49, 64, 81]]) == 0\n assert candidate(nums = [[13, 21, 34, 55, 89, 144, 233], [1, 2, 3, 5, 8, 13, 21], [2, 3, 5, 8, 13, 21, 34], [3, 5, 8, 13, 21, 34, 55], [5, 8, 13, 21, 34, 55, 89], [8, 13, 21, 34, 55, 89, 144], [13, 21, 34, 55, 89, 144, 233]]) == 233\n assert candidate(nums = [[2, 18, 22, 26, 30], [19, 23, 29, 33, 37], [24, 28, 31, 35, 39], [27, 32, 36, 38, 42], [34, 36, 40, 44, 47]]) == 47\n assert candidate(nums = [[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]]) == 2\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]]) == 151\n assert candidate(nums = [[961, 962, 963, 964, 965], [966, 967, 968, 969, 970], [971, 972, 973, 974, 975], [976, 977, 978, 979, 980], [981, 982, 983, 984, 985]]) == 977\n assert candidate(nums = [[4, 2, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [6, 7, 11, 13, 17, 19, 23], [8, 9, 13, 17, 19, 23, 29], [10, 11, 17, 19, 23, 29, 31], [12, 13, 19, 23, 29, 31, 37], [14, 15, 23, 29, 31, 37, 41]]) == 41\n assert candidate(nums = [[4, 6, 8, 10, 12], [3, 5, 7, 9, 11], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 3, 5, 7, 11]]) == 11\n assert candidate(nums = [[4, 6, 8, 10], [12, 14, 16, 18], [20, 22, 24, 26], [28, 30, 32, 34]]) == 0\n assert candidate(nums = [[2, 4, 6, 8, 10], [3, 5, 7, 11, 13], [17, 19, 23, 29, 31], [37, 41, 43, 47, 53], [59, 61, 67, 71, 73]]) == 73\n assert candidate(nums = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 29, 26, 28], [30, 32, 34, 36, 38], [40, 42, 44, 46, 48]]) == 29\n assert candidate(nums = [[4, 6, 8, 10, 12, 14], [6, 9, 12, 15, 18, 21], [8, 12, 15, 18, 21, 24], [10, 15, 18, 22, 25, 28], [12, 18, 21, 25, 29, 32], [14, 21, 24, 28, 32, 35]]) == 29\n assert candidate(nums = [[1000003, 1000007, 1000009], [1000013, 1000019, 1000021], [1000027, 1000031, 1000033]]) == 1000033\n assert candidate(nums = [[2, 0, 0, 0, 0, 0, 3], [0, 5, 0, 0, 0, 7, 0], [0, 0, 11, 0, 13, 0, 0], [0, 0, 0, 17, 0, 0, 0], [0, 0, 13, 0, 11, 0, 0], [0, 7, 0, 0, 0, 5, 0], [3, 0, 0, 0, 0, 0, 2]]) == 17\n assert candidate(nums = [[1000001, 1000003, 1000007, 1000009, 1000021], [1000033, 1000037, 1000039, 1000043, 1000049], [1000051, 1000061, 1000063, 1000067, 1000069], [1000073, 1000079, 1000081, 1000087, 1000093], [1000099, 1000103, 1000111, 1000123, 1000139]]) == 1000099\n assert candidate(nums = [[4000001, 4000003, 4000007, 4000009], [4000013, 4000031, 4000037, 4000039], [4000043, 4000047, 4000051, 4000061], [4000063, 4000067, 4000069, 4000071]]) == 4000063\n assert candidate(nums = [[14, 16, 18, 20, 22], [13, 15, 17, 19, 21], [12, 14, 16, 18, 20], [11, 13, 15, 17, 19], [10, 12, 14, 16, 17]]) == 19\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]]) == 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], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 47, 46, 49, 50, 51, 52], [53, 54, 55, 56, 57, 59, 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]]) == 71\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]]) == 43\n assert candidate(nums = [[9973, 9972, 9971, 9970, 9969, 9968, 9967], [9966, 9965, 9964, 9963, 9962, 9961, 9960], [9959, 9958, 9957, 9956, 9955, 9954, 9953], [9952, 9951, 9950, 9949, 9948, 9947, 9946], [9945, 9944, 9943, 9942, 9941, 9940, 9939], [9938, 9937, 9936, 9935, 9934, 9933, 9932], [9931, 9930, 9929, 9928, 9927, 9926, 9925]]) == 9973\n assert candidate(nums = [[29, 23, 19, 17, 13], [11, 7, 5, 3, 2], [41, 37, 31, 29, 23], [47, 53, 59, 61, 67], [71, 73, 79, 83, 89]]) == 89\n assert candidate(nums = [[991, 997, 1009, 1013], [1019, 1021, 1031, 1033], [1039, 1049, 1051, 1061], [1063, 1069, 1087, 1091]]) == 1091\n assert candidate(nums = [[233, 239, 241, 251], [257, 263, 269, 271], [277, 281, 283, 293], [307, 311, 313, 317]]) == 317\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, 503, 509, 521, 523, 541]]) == 541\n assert candidate(nums = [[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]]) == 229\n assert candidate(nums = [[983, 1019, 1031, 1049, 1061, 1069], [1087, 1091, 1093, 1097, 1103, 1109], [1117, 1123, 1129, 1151, 1153, 1163], [1171, 1181, 1187, 1193, 1201, 1213], [1217, 1223, 1229, 1231, 1237, 1249], [1259, 1277, 1279, 1283, 1289, 1291]]) == 1291\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]]) == 139\n assert candidate(nums = [[4000001, 4000003, 4000005], [4000007, 4000009, 4000011], [4000013, 4000015, 4000017]]) == 0\n assert candidate(nums = [[101, 103, 105, 107, 109], [111, 113, 115, 117, 119], [121, 123, 127, 129, 131], [133, 135, 137, 139, 141], [143, 145, 147, 149, 151]]) == 151\n assert candidate(nums = [[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]]) == 283\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]]) == 227\n assert candidate(nums = [[29, 23, 19, 17], [13, 11, 7, 5], [3, 2, 2, 3], [5, 7, 11, 13]]) == 29\n assert candidate(nums = [[101, 103, 107, 109, 113], [119, 121, 127, 131, 137], [139, 149, 151, 157, 163], [167, 173, 179, 181, 191], [193, 197, 199, 211, 223]]) == 223\n assert candidate(nums = [[2, 0, 0, 0, 3], [0, 5, 0, 7, 0], [0, 0, 11, 0, 0], [0, 13, 0, 17, 0], [19, 0, 0, 0, 23]]) == 23\n assert candidate(nums = [[1, 1, 1, 1, 1], [1, 2, 3, 5, 1], [1, 3, 5, 7, 1], [1, 5, 7, 11, 1], [1, 1, 1, 1, 1]]) == 11\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]]) == 367\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().diagonalPrime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int diagonalPrime(int[][] nums) {", "container": "Solution", "callable": "diagonalPrime", "parameters": [{"name": "nums", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2615, "task_id": "sum-of-distances", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. There exists an array arr of length nums.length, where arr[i] is the sum of |i - j| over all j such that nums[j] == nums[i] and j != i. If there is no such j, set arr[i] to be 0.\nReturn the array arr.\n \nExample 1:\n\nInput: nums = [1,3,1,1,2]\nOutput: [5,0,3,4,0]\nExplanation: \nWhen i = 0, nums[0] == nums[2] and nums[0] == nums[3]. Therefore, arr[0] = |0 - 2| + |0 - 3| = 5. \nWhen i = 1, arr[1] = 0 because there is no other index with value 3.\nWhen i = 2, nums[2] == nums[0] and nums[2] == nums[3]. Therefore, arr[2] = |2 - 0| + |2 - 3| = 3. \nWhen i = 3, nums[3] == nums[0] and nums[3] == nums[2]. Therefore, arr[3] = |3 - 0| + |3 - 2| = 4. \nWhen i = 4, arr[4] = 0 because there is no other index with value 2. \n\n\nExample 2:\n\nInput: nums = [0,5,3]\nOutput: [0,0,0]\nExplanation: Since each element in nums is distinct, arr[i] = 0 for all i.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 109\n\n \nNote: This question is the same as 2121: Intervals Between Identical Elements.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 5, 3]) == [0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1]) == [0]\n assert candidate(nums = [10, 10, 10, 10]) == [6, 4, 4, 6]\n assert candidate(nums = [5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10]) == [12, 0, 8, 0, 8, 0, 12]\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [10, 7, 6, 7, 10]\n assert candidate(nums = [10, 20, 10, 10, 30, 20, 10]) == [11, 4, 7, 7, 0, 4, 13]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == [9, 0, 0, 0, 0, 0, 0, 0, 0, 9]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 1, 1, 2]) == [5, 0, 3, 4, 0]\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1]) == [14, 10, 6, 8, 10, 2, 0, 2, 6, 14, 16]\n assert candidate(nums = [2, 1, 3, 1, 2, 3, 3]) == [4, 2, 7, 2, 4, 4, 5]\n assert candidate(nums = [2, 2, 2, 2]) == [6, 4, 4, 6]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\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]) == [27, 27, 27, 27, 27, 27, 27, 27, 27, 18, 18, 18, 18, 18, 18, 18, 18, 18, 27, 27, 27, 27, 27, 27, 27, 27, 27]\n assert candidate(nums = [50, 50, 40, 40, 40, 30, 30, 30, 30, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10]) == [1, 1, 3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 15]\n assert candidate(nums = [5, 3, 2, 5, 3, 5, 2, 5, 3]) == [15, 10, 4, 9, 7, 9, 4, 13, 11]\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10, 110]) == [90, 0, 74, 0, 62, 0, 54, 0, 50, 0, 50, 0, 54, 0, 62, 0, 74, 0, 90, 0]\n assert candidate(nums = [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]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45, 45, 37, 31, 27, 25, 25, 27, 31, 37, 45, 45, 37, 31, 27, 25, 25, 27, 31, 37, 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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 40, 42, 40, 42, 40, 42, 40, 42, 40, 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]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000000000, 999999999, 1000000000, 999999999, 1000000000, 999999999]) == [6, 6, 4, 4, 6, 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]) == [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, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n assert candidate(nums = [1000000000, 500000000, 1000000000, 250000000, 1000000000, 750000000, 1000000000]) == [12, 0, 8, 0, 8, 0, 12]\n assert candidate(nums = [10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50]) == [10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]\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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 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]) == [406, 379, 354, 331, 310, 291, 274, 259, 246, 235, 226, 219, 214, 211, 210, 211, 214, 219, 226, 235, 246, 259, 274, 291, 310, 331, 354, 379, 406]\n assert candidate(nums = [10, 20, 10, 30, 40, 10, 50, 60, 10, 70, 80, 10, 90, 100, 10, 110, 120, 10, 130, 140]) == [57, 0, 47, 0, 0, 38, 0, 0, 35, 0, 0, 38, 0, 0, 47, 0, 0, 62, 0, 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, 5, 5, 5, 5, 5]) == [10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [10, 14, 9, 13, 8, 12, 7, 11, 6, 10, 10, 9, 8, 7, 6, 14, 13, 12, 11, 10]\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, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3]\n assert candidate(nums = [100, 200, 100, 300, 200, 100, 400, 300, 200, 100, 500, 400, 300, 200, 100]) == [30, 22, 24, 13, 16, 21, 5, 9, 16, 25, 0, 5, 14, 26, 40]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]\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]) == [210, 0, 184, 0, 162, 0, 144, 0, 130, 0, 120, 0, 114, 0, 112, 0, 114, 0, 120, 0, 130, 0, 144, 0, 162, 0, 184, 0, 210]\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]) == [3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3]\n assert candidate(nums = [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, 3, 2, 1, 0]) == [60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == [21, 15, 9, 11, 13, 6, 11, 13, 9, 17, 19]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2]) == [27, 27, 9, 9, 9, 9, 9, 9, 9, 18, 18, 9, 9, 9, 9, 9, 9, 9, 27, 27]\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]) == [135, 135, 135, 111, 111, 111, 93, 93, 93, 81, 81, 81, 75, 75, 75, 75, 75, 75, 81, 81, 81, 93, 93, 93, 111, 111, 111, 135, 135, 135]\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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 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(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]) == [60, 60, 60, 60, 60, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40, 20, 20, 20, 20, 20, 40, 40, 40, 40, 40, 30, 30, 30, 30, 30, 60, 60, 60, 60, 60]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [55, 46, 39, 34, 31, 30, 31, 34, 39, 46, 55]\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]) == [75, 75, 75, 75, 75, 55, 55, 55, 55, 55, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 55, 55, 55, 55, 55, 75, 75, 75, 75, 75]\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, 1, 1, 1, 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, 6, 6, 7, 7, 8, 8, 9, 9, 10, 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 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10]\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, 20, 30, 40, 50]) == [30, 30, 30, 30, 30, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 30, 30, 30, 30, 30]\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10]) == [72, 0, 58, 0, 48, 0, 42, 0, 40, 0, 42, 0, 48, 0, 58, 0, 72]\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]) == [0, 1, 1, 3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 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, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [435, 407, 381, 357, 335, 315, 297, 281, 267, 255, 245, 237, 231, 227, 225, 225, 227, 231, 237, 245, 255, 267, 281, 297, 315, 335, 357, 381, 407, 435]\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]) == [42, 40, 42, 40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 40, 42, 40, 42]\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]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 1000000000, 999999999, 999999998, 1000000000]) == [11, 4, 4, 0, 7, 4, 4, 10]\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, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [210, 192, 194, 168, 171, 176, 140, 144, 151, 160, 110, 115, 124, 136, 150, 80, 86, 97, 112, 130, 150, 52, 59, 72, 90, 112, 137, 164, 28, 36, 51, 72, 98, 128, 161, 196, 10, 19, 36, 60, 90, 125, 164, 206, 250, 0, 10, 29, 56, 90, 130, 175, 224, 276, 330]\n assert candidate(nums = [1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0]) == [20, 20, 14, 14, 12, 12, 14, 14, 20, 20]\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1]) == [90, 0, 74, 0, 62, 0, 54, 0, 50, 0, 50, 0, 54, 0, 62, 0, 74, 0, 90]\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]) == [0, 0, 0, 0, 0, 0, 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(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]) == [3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 15, 21, 16, 13, 12, 13, 16, 21]\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, 1, 1, 1, 2, 2, 2]) == [96, 92, 90, 96, 92, 90, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 90, 92, 96, 90, 92, 96]\n assert candidate(nums = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300]) == [18, 18, 18, 12, 12, 12, 12, 12, 12, 18, 18, 18]\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, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [100, 200, 100, 300, 100, 400, 100, 500, 100]) == [20, 0, 14, 0, 12, 0, 14, 0, 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, 1, 2, 3, 4, 5]) == [30, 30, 30, 30, 30, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 30, 30, 30, 30, 30]\n assert candidate(nums = [100, 200, 100, 300, 100, 400, 100, 500, 100, 600, 100, 700, 100, 800, 100]) == [56, 0, 44, 0, 36, 0, 32, 0, 32, 0, 36, 0, 44, 0, 56]\n assert candidate(nums = [100, 200, 100, 300, 400, 100, 200, 300, 400, 100]) == [16, 5, 12, 4, 4, 12, 5, 4, 4, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60]\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10]) == [72, 0, 58, 0, 48, 0, 42, 0, 40, 0, 42, 0, 48, 0, 58, 0, 72]\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]\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]) == [3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [3, 2, 3, 1, 1, 3, 2, 3, 6, 4, 4, 6]\n assert candidate(nums = [1000000000, 999999999, 1000000000, 999999998, 1000000000, 999999997, 1000000000, 999999996, 1000000000, 999999995]) == [20, 0, 14, 0, 12, 0, 14, 0, 20, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 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]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]\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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 10]) == [2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2]\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\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]) == [78, 72, 66, 60, 27, 52, 50, 48, 46, 44, 42, 40, 38, 18, 38, 40, 42, 44, 46, 48, 50, 52, 27, 60, 66, 72, 78]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10]) == [20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20]\n assert candidate(nums = [1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [100, 91, 72, 77, 58, 67, 48, 61, 42, 59, 40, 61, 42, 67, 48, 77, 58, 91, 72, 109]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == [9, 0, 0, 0, 0, 0, 0, 0, 0, 9]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [0, 1, 1, 3, 2, 3, 6, 4, 4, 6]\n assert candidate(nums = [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]) == [63, 59, 63, 59, 63, 59, 63, 59, 63, 59, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 59, 63, 59, 63, 59, 63, 59, 63, 59, 63]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\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]) == [112, 98, 100, 80, 83, 88, 60, 64, 71, 80, 40, 45, 54, 66, 80, 22, 28, 39, 54, 72, 92, 8, 15, 28, 46, 68, 93, 120, 0, 8, 23, 44, 70, 100, 133, 168]\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1000000000]) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\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]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [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]) == [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [7, 3, 7, 7, 10, 3, 7, 3, 7, 7, 7, 10, 3, 7, 3, 7, 7, 7, 10, 3]) == [99, 52, 81, 74, 21, 36, 59, 32, 53, 52, 53, 14, 32, 62, 36, 72, 79, 88, 21, 56]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().distance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long[] distance(int[] nums) {", "container": "Solution", "callable": "distance", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2616, "task_id": "minimize-the-maximum-difference-of-pairs", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and an integer p. Find p pairs of indices of nums such that the maximum difference amongst all the pairs is minimized. Also, ensure no index appears more than once amongst the p pairs.\nNote that for a pair of elements at the index i and j, the difference of this pair is |nums[i] - nums[j]|, where |x| represents the absolute value of x.\nReturn the minimum maximum difference among all p pairs. We define the maximum of an empty set to be zero.\n \nExample 1:\n\nInput: nums = [10,1,2,7,1,3], p = 2\nOutput: 1\nExplanation: The first pair is formed from the indices 1 and 4, and the second pair is formed from the indices 2 and 5. \nThe maximum difference is max(|nums[1] - nums[4]|, |nums[2] - nums[5]|) = max(0, 1) = 1. Therefore, we return 1.\n\nExample 2:\n\nInput: nums = [4,2,1,2], p = 1\nOutput: 0\nExplanation: Let the indices 1 and 3 form a pair. The difference of that pair is |2 - 2| = 0, which is the minimum we can attain.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 109\n0 <= p <= (nums.length)/2\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 6, 8, 10],p = 2) == 2\n assert candidate(nums = [5, 3, 8, 4, 9, 1],p = 3) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],p = 2) == 0\n assert candidate(nums = [7, 1, 3, 4, 2, 5],p = 0) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1],p = 2) == 0\n assert candidate(nums = [5, 4, 2, 2, 1, 3, 3, 5],p = 3) == 0\n assert candidate(nums = [1, 3, 5, 7, 9],p = 2) == 2\n assert candidate(nums = [1, 3, 6, 9, 12, 15],p = 2) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],p = 4) == 0\n assert candidate(nums = [1, 3, 6, 19, 20],p = 2) == 2\n assert candidate(nums = [8, 4, 2, 6, 10, 12],p = 3) == 2\n assert candidate(nums = [5, 4, 3, 2, 1],p = 3) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 3) == 1\n assert candidate(nums = [10, 1, 2, 7, 1, 3],p = 2) == 1\n assert candidate(nums = [4, 2, 1, 2],p = 1) == 0\n assert candidate(nums = [5, 3, 2, 4, 1],p = 2) == 1\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20],p = 10) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],p = 5) == 10\n assert candidate(nums = [5, 1, 9, 3, 7, 6, 8, 2, 4, 10],p = 5) == 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],p = 9) == 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, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],p = 25) == 2\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],p = 15) == 5\n assert candidate(nums = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27],p = 4) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],p = 5) == 1\n assert candidate(nums = [2, 3, 1, 5, 4, 6, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],p = 5) == 1\n assert candidate(nums = [5, 8, 12, 15, 19, 22, 26, 30, 35, 40, 45, 50, 55, 60, 65, 70],p = 7) == 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, 11, 11, 12, 12, 13, 13, 14, 14],p = 12) == 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],p = 10) == 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, 210, 220, 230, 240, 250],p = 10) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14, 15, 16, 17, 18, 19, 20],p = 8) == 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],p = 10) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 5) == 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],p = 5) == 0\n assert candidate(nums = [1000000000, 0, 500000000, 250000000, 750000000, 125000000, 625000000, 312500000, 875000000, 937500000],p = 4) == 125000000\n assert candidate(nums = [1, 3, 6, 19, 20, 25, 30, 32, 40, 50],p = 4) == 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],p = 10) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],p = 5) == 1\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],p = 5) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],p = 5) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],p = 4) == 10\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],p = 5) == 256\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],p = 2) == 900\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],p = 8) == 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],p = 15) == 1\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],p = 10) == 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],p = 10) == 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],p = 10) == 10\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],p = 7) == 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],p = 9) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],p = 2) == 1\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],p = 9) == 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],p = 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],p = 10) == 1\n assert candidate(nums = [9, 1, 10, 15, 2, 11, 16, 3, 12, 17, 4, 13, 18, 5, 14, 19, 6, 20, 7, 8],p = 7) == 1\n assert candidate(nums = [1, 100, 101, 102, 103, 104, 105, 106, 107, 108],p = 3) == 1\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],p = 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],p = 12) == 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, 8, 8, 8, 9, 9, 9, 10, 10, 10],p = 5) == 0\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],p = 5) == 1\n assert candidate(nums = [1, 2, 3, 100, 101, 102, 200, 201, 202, 300],p = 4) == 97\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],p = 5) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019],p = 10) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],p = 5) == 1\n assert candidate(nums = [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],p = 15) == 1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51],p = 10) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],p = 8) == 0\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],p = 12) == 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],p = 15) == 1\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],p = 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],p = 5) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],p = 5) == 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],p = 5) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 200, 201, 202, 203, 204],p = 4) == 1\n assert candidate(nums = [1, 5, 3, 7, 2, 6, 4, 8, 9, 13, 11, 15, 10, 14, 12, 16, 17, 21, 19, 23],p = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],p = 5) == 1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],p = 8) == 0\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],p = 10) == 0\n assert candidate(nums = [8, 1, 4, 3, 2, 7, 5, 6, 9, 10],p = 4) == 1\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996],p = 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],p = 5) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],p = 5) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],p = 9) == 10\n assert candidate(nums = [4, 8, 2, 15, 16, 23, 42, 10],p = 3) == 2\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115],p = 7) == 1\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140],p = 7) == 10\n assert candidate(nums = [100, 200, 300, 10, 20, 30, 150, 250, 50, 350],p = 4) == 50\n assert candidate(nums = [1, 3, 6, 8, 12, 14, 17, 20, 23, 26, 29, 31, 34, 37, 40, 42],p = 5) == 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],p = 10) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],p = 5) == 0\n assert candidate(nums = [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],p = 12) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],p = 6) == 1\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],p = 15) == 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],p = 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, 21, 22, 23, 24, 25],p = 10) == 1\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],p = 10) == 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],p = 7) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],p = 7) == 2\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],p = 8) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],p = 6) == 2\n assert candidate(nums = [1000000000, 0, 500000000, 250000000, 750000000],p = 2) == 250000000\n assert candidate(nums = [100, 3, 5, 15, 1, 200, 8, 2, 7, 6],p = 4) == 7\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],p = 3) == 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],p = 5) == 0\n assert candidate(nums = [1, 3, 6, 19, 20, 22, 30, 31, 33, 40, 41, 43, 50],p = 4) == 2\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],p = 5) == 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, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],p = 20) == 59\n"}, "metadata": {"canonical_parameter_names": ["nums", "p"], "leetcode_dataset_entry_point": "Solution().minimizeMax", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimizeMax(int[] nums, int p) {", "container": "Solution", "callable": "minimizeMax", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "p", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2617, "task_id": "minimum-number-of-visited-cells-in-a-grid", "difficulty": "Hard", "problem_description": "You are given a 0-indexed m x n integer matrix grid. Your initial position is at the top-left cell (0, 0).\nStarting from the cell (i, j), you can move to one of the following cells:\n\nCells (i, k) with j < k <= grid[i][j] + j (rightward movement), or\nCells (k, j) with i < k <= grid[i][j] + i (downward movement).\n\nReturn the minimum number of cells you need to visit to reach the bottom-right cell (m - 1, n - 1). If there is no valid path, return -1.\n \nExample 1:\n\n\nInput: grid = [[3,4,2,1],[4,2,3,1],[2,1,0,0],[2,4,0,0]]\nOutput: 4\nExplanation: The image above shows one of the paths that visits exactly 4 cells.\n\nExample 2:\n\n\nInput: grid = [[3,4,2,1],[4,2,1,1],[2,1,1,0],[3,4,1,0]]\nOutput: 3\nExplanation: The image above shows one of the paths that visits exactly 3 cells.\n\nExample 3:\n\n\nInput: grid = [[2,1,0],[1,0,0]]\nOutput: -1\nExplanation: It can be proven that no path exists.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 105\n1 <= m * n <= 105\n0 <= grid[i][j] < m * n\ngrid[m - 1][n - 1] == 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[2, 0, 0], [1, 3, 1], [0, 1, 0]]) == 5\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == -1\n assert candidate(grid = [[3, 4, 2, 1], [4, 2, 3, 1], [2, 1, 0, 0], [2, 4, 0, 0]]) == 4\n assert candidate(grid = [[3, 4, 2, 1], [4, 2, 1, 1], [2, 1, 1, 0], [3, 4, 1, 0]]) == 3\n assert candidate(grid = [[0, 0], [0, 0]]) == -1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 0]]) == 5\n assert candidate(grid = [[2, 1, 0], [1, 0, 0]]) == -1\n assert candidate(grid = [[0]]) == 1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 4\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == -1\n assert candidate(grid = [[1, 0], [0, 0]]) == -1\n assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 0], [3, 4, 5, 0, 0], [4, 5, 0, 0, 0], [5, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[3, 2, 1, 4, 0], [4, 1, 2, 3, 1], [2, 3, 0, 1, 0], [3, 0, 2, 0, 1], [0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[2, 0, 0], [0, 2, 0], [0, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 0]]) == -1\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]]) == -1\n assert candidate(grid = [[2, 1, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\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, 0]]) == 5\n assert candidate(grid = [[2, 2, 1, 1], [1, 2, 2, 1], [1, 1, 2, 2], [1, 1, 1, 0]]) == 5\n assert candidate(grid = [[2, 2, 0, 0], [2, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 3], [0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 0]]) == 4\n assert candidate(grid = [[3, 0, 0, 0], [0, 3, 0, 0], [0, 0, 3, 0], [0, 0, 0, 3]]) == -1\n assert candidate(grid = [[3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 0]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[2, 3, 0, 0, 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(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, 0]]) == -1\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]]) == 9\n assert candidate(grid = [[0, 1, 2, 3, 4], [1, 0, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 0, 1], [4, 3, 2, 1, 0]]) == -1\n assert candidate(grid = [[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]]) == 5\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 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], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[3, 3, 0, 2, 1, 1], [2, 2, 0, 1, 1, 0], [1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == -1\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], [0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 0]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [5, 4, 3, 2, 0]]) == 5\n assert candidate(grid = [[2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 0]]) == 5\n assert candidate(grid = [[3, 0, 0, 1], [0, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 0]]) == 5\n assert candidate(grid = [[5, 0, 0, 0, 0], [4, 0, 0, 0, 0], [3, 0, 0, 0, 0], [2, 0, 0, 0, 0], [1, 0, 0, 0, 0]]) == -1\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, 0]]) == 13\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\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], [0, 1, 0, 1, 0, 0]]) == -1\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, 0]]) == 5\n assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 1, 4, 3], [3, 4, 1, 0]]) == 4\n assert candidate(grid = [[3, 2, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 0]]) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 11\n assert candidate(grid = [[2, 1, 0, 0], [0, 2, 1, 0], [1, 0, 2, 0], [0, 0, 0, 0]]) == -1\n assert candidate(grid = [[3, 0, 2, 1, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 1, 2, 3], [1, 2, 3, 0], [2, 3, 0, 0], [3, 0, 0, 0]]) == -1\n assert candidate(grid = [[5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [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(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 0]]) == 7\n assert candidate(grid = [[2, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 2, 0, 0], [0, 0, 0, 2, 0], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[2, 3, 1, 1, 4], [2, 2, 2, 2, 2], [1, 1, 2, 1, 2], [2, 2, 2, 2, 2], [0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[2, 3, 0, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[4, 3, 2, 1, 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(grid = [[3, 1, 0, 2, 0], [0, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 0], [2, 3, 4, 5, 0, 5], [3, 4, 5, 0, 5, 4], [4, 5, 0, 5, 4, 3], [5, 0, 5, 4, 3, 0]]) == -1\n assert candidate(grid = [[3, 2, 1, 0], [2, 2, 2, 2], [1, 2, 2, 2], [0, 2, 2, 0]]) == 5\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 0]]) == 7\n assert candidate(grid = [[2, 3, 1, 1, 1], [1, 2, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 0]]) == 7\n assert candidate(grid = [[5, 4, 3, 2, 1, 0], [4, 3, 2, 1, 0, 0], [3, 2, 1, 0, 0, 0], [2, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 3, 1, 3, 1, 3], [3, 1, 3, 1, 3, 1], [1, 3, 1, 3, 1, 0], [3, 1, 3, 1, 3, 1], [1, 3, 1, 3, 1, 1]]) == 6\n assert candidate(grid = [[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, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0]]) == 19\n assert candidate(grid = [[5, 3, 2, 1], [2, 2, 2, 1], [1, 1, 1, 1], [0, 0, 0, 0]]) == 5\n assert candidate(grid = [[10, 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(grid = [[3, 2, 2, 1], [1, 2, 3, 4], [2, 3, 1, 1], [1, 1, 1, 0]]) == 4\n assert candidate(grid = [[3, 1, 2, 1, 1], [2, 2, 1, 1, 2], [1, 1, 2, 1, 1], [1, 2, 1, 2, 1], [0, 0, 0, 0, 0]]) == 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], [1, 1, 1, 1, 1, 0]]) == 11\n assert candidate(grid = [[2, 0, 2, 0, 1, 0], [0, 2, 0, 2, 0, 2], [2, 0, 2, 0, 2, 0], [0, 2, 0, 2, 0, 2], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 2, 2], [2, 0, 2], [2, 2, 0]]) == -1\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, 0], [2, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[2, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0], [0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 0]]) == 3\n assert candidate(grid = [[4, 3, 2, 1, 0], [3, 3, 3, 3, 3], [2, 3, 2, 3, 2], [1, 3, 2, 3, 1], [0, 3, 2, 3, 0]]) == 5\n assert candidate(grid = [[4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 0]]) == 3\n assert candidate(grid = [[2, 2, 2, 2], [2, 0, 0, 2], [2, 0, 0, 2], [2, 2, 2, 0]]) == 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], [0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[3, 1, 2, 3, 2], [1, 1, 1, 1, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [2, 1, 1, 1, 0]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 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], [1, 1, 1, 1, 1, 0]]) == 11\n assert candidate(grid = [[4, 4, 4, 4], [4, 4, 4, 4], [4, 4, 4, 4], [4, 4, 4, 0]]) == 3\n assert candidate(grid = [[2, 3, 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, 1, 1, 1], [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, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[2, 2, 1, 2], [2, 2, 2, 1], [1, 2, 2, 2], [2, 1, 1, 0]]) == 5\n assert candidate(grid = [[3, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 3]]) == -1\n assert candidate(grid = [[3, 2, 1, 1, 2], [2, 2, 3, 1, 1], [1, 3, 2, 1, 1], [1, 1, 1, 2, 3], [1, 1, 1, 1, 0]]) == 6\n assert candidate(grid = [[3, 2, 1, 0], [2, 3, 1, 0], [1, 1, 0, 0], [0, 0, 0, 0]]) == -1\n assert candidate(grid = [[5, 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(grid = [[2, 1, 1, 1], [1, 1, 2, 1], [1, 2, 1, 1], [1, 1, 1, 2]]) == 5\n assert candidate(grid = [[2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[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, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 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(grid = [[2, 3, 4, 5, 6], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[2, 0, 3, 0, 0], [1, 0, 0, 0, 4], [0, 0, 0, 0, 0], [3, 0, 0, 0, 2], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[4, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 3], [3, 4, 3, 2], [4, 3, 2, 1]]) == 4\n assert candidate(grid = [[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]]) == -1\n assert candidate(grid = [[3, 3, 3], [3, 0, 0], [3, 0, 0]]) == 3\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 0, 0, 0, 0], [5, 0, 0, 0, 0], [5, 0, 0, 0, 0], [5, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[3, 2, 1, 4, 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]]) == -1\n assert candidate(grid = [[3, 2, 1, 0, 0], [2, 2, 0, 1, 0], [0, 1, 0, 2, 3], [1, 0, 0, 0, 4], [0, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[1, 1, 1], [1, 0, 0], [1, 0, 0]]) == -1\n assert candidate(grid = [[4, 2, 0, 0, 0], [2, 2, 2, 0, 0], [0, 2, 2, 2, 0], [0, 0, 2, 2, 2], [0, 0, 0, 2, 0]]) == 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, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[2, 1, 2], [1, 2, 1], [2, 1, 0]]) == 3\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]]) == -1\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]]) == 9\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minimumVisitedCells", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumVisitedCells(int[][] grid) {", "container": "Solution", "callable": "minimumVisitedCells", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2639, "task_id": "find-the-width-of-columns-of-a-grid", "difficulty": "Easy", "problem_description": "You are given a 0-indexed m x n integer matrix grid. The width of a column is the maximum length of its integers.\n\nFor example, if grid = [[-10], [3], [12]], the width of the only column is 3 since -10 is of length 3.\n\nReturn an integer array ans of size n where ans[i] is the width of the ith column.\nThe length of an integer x with len digits is equal to len if x is non-negative, and len + 1 otherwise.\n \nExample 1:\n\nInput: grid = [[1],[22],[333]]\nOutput: [3]\nExplanation: In the 0th column, 333 is of length 3.\n\nExample 2:\n\nInput: grid = [[-15,1,3],[15,7,12],[5,6,-2]]\nOutput: [3,1,2]\nExplanation: \nIn the 0th column, only -15 is of length 3.\nIn the 1st column, all integers are of length 1. \nIn the 2nd column, both 12 and -2 are of length 2.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 100 \n-109 <= grid[r][c] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[12345], [67890]]) == [5]\n assert candidate(grid = [[1], [22], [333]]) == [3]\n assert candidate(grid = [[1000], [-1000], [100], [-100], [10], [-10], [1], [-1]]) == [5]\n assert candidate(grid = [[-15, 1, 3], [15, 7, 12], [5, 6, -2]]) == [3, 1, 2]\n assert candidate(grid = [[123456789, -123456789], [987654321, 123456789]]) == [9, 10]\n assert candidate(grid = [[-1, -2, -3], [10, 20, 30], [100, 200, 300]]) == [3, 3, 3]\n assert candidate(grid = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12]]) == [2, 3, 3, 3]\n assert candidate(grid = [[-1000000000, 1000000000], [999999999, -999999999]]) == [11, 10]\n assert candidate(grid = [[123, 456, 789], [987, 654, 321], [111, 222, 333]]) == [3, 3, 3]\n assert candidate(grid = [[123, 456, 789], [987, 654, 321], [111, 222, 333]]) == [3, 3, 3]\n assert candidate(grid = [[123456789, 123456789, 123456789], [1, 2, 3], [987654321, 987654321, 987654321]]) == [9, 9, 9]\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == [1, 1, 1]\n assert candidate(grid = [[-1, -22, -333], [-4444, -55555, -666666], [-7777777, -88888888, -999999999]]) == [8, 9, 10]\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == [1, 1, 1]\n assert candidate(grid = [[-1000000000, 1000000000], [999999999, -999999999]]) == [11, 10]\n assert candidate(grid = [[0, 0, 0], [0, 0, 0]]) == [1, 1, 1]\n assert candidate(grid = [[123456789, -987654321], [111, 222], [3, 4, 5]]) == [9, 10]\n assert candidate(grid = [[123, 4567, 89], [12, 34, 5678], [9, 876, 5432], [101112, 131415, 161718], [192021, 222324, 252627]]) == [6, 6, 6]\n assert candidate(grid = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [2]\n assert candidate(grid = [[123456789, -987654321, 123], [111, 222, 333], [0, 0, 0]]) == [9, 10, 3]\n assert candidate(grid = [[-123456789, 987654321, -111], [222, 333, 444], [555, 666, 777]]) == [10, 9, 4]\n assert candidate(grid = [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9], [10, -10]]) == [2, 3]\n assert candidate(grid = [[-1000000000, 1000000000, -999999999, 999999999], [999999998, -999999998, 999999997, -999999997]]) == [11, 10, 10, 10]\n assert candidate(grid = [[-1, 2, -3, 4, -5], [-10, 20, -30, 40, -50], [-100, 200, -300, 400, -500], [-1000, 2000, -3000, 4000, -5000]]) == [5, 4, 5, 4, 5]\n assert candidate(grid = [[10000, 1000, 100, 10, 1], [1, 10, 100, 1000, 10000], [1, -2, 3, -4, 5], [-6, 7, -8, 9, -10]]) == [5, 4, 3, 4, 5]\n assert candidate(grid = [[-123456789, 987654321, -111111111], [222222222, -333333333, 444444444], [555555555, -666666666, 777777777]]) == [10, 10, 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]]) == [2, 3, 2, 3, 2]\n assert candidate(grid = [[-1, 0, 1], [-10, 0, 10], [-100, 0, 100], [-1000, 0, 1000], [-10000, 0, 10000]]) == [6, 1, 5]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [-10, -9, -8, -7, -6]]) == [3, 2, 2, 2, 2]\n assert candidate(grid = [[0, -1000000000, 1000000000], [123456789, -987654321, 111111111], [987654321, 123456789, 0]]) == [9, 11, 10]\n assert candidate(grid = [[12345, 67890], [-12345, 67890], [12345, -67890], [-12345, -67890], [0, 0]]) == [6, 6]\n assert candidate(grid = [[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, 2, 1, 2, 1]\n assert candidate(grid = [[123, 456, 789], [-987, -654, -321], [111, 222, 333], [-444, -555, -666]]) == [4, 4, 4]\n assert candidate(grid = [[1000000000], [100000000], [10000000], [1000000], [100000], [10000], [1000], [100], [10], [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]]) == [1, 1, 1, 1, 1]\n assert candidate(grid = [[12, -123, 1234, -12345, 123456], [654, -789, 101112, -13141516, 17181920], [21, -22, 23, -24, 25]]) == [3, 4, 6, 9, 8]\n assert candidate(grid = [[1, 10, 100, 1000], [2, 20, 200, 2000], [3, 30, 300, 3000], [4, 40, 400, 4000], [5, 50, 500, 5000]]) == [1, 2, 3, 4]\n assert candidate(grid = [[1, -10, 100, -1000, 10000, -100000, 1000000, -10000000, 100000000, -1000000000]]) == [1, 3, 3, 5, 5, 7, 7, 9, 9, 11]\n assert candidate(grid = [[12, 34, 56], [78, 90, 12], [34, 56, 78], [90, 12, 34], [56, 78, 90]]) == [2, 2, 2]\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]]) == [3, 2, 3, 2, 3]\n assert candidate(grid = [[-123456789, 987654321, 123456789], [111111111, -222222222, 333333333], [444444444, 555555555, 666666666]]) == [10, 10, 9]\n assert candidate(grid = [[0, 10, 100, 1000, 10000], [-10, -100, -1000, -10000, -100000], [123456789, -987654321, 12345678, -9876543]]) == [9, 10, 8, 8]\n assert candidate(grid = [[987654321, -123456789, 0, 98765432, -12345678, 9876543, -1234567, 987654, -123456, 98765], [-98765, 12345, -6789, 6789, -5432, 5432, -4321, 4321, -3210, 3210], [987, -654, 321, -987, 654, -321, 789, -456, 123, -1]]) == [9, 10, 5, 8, 9, 7, 8, 6, 7, 5]\n assert candidate(grid = [[-1, 0, 1, -10, 10], [100, -100, 1000, -1000, 10000], [100000, -100000, 1000000, -1000000, 10000000]]) == [6, 7, 7, 8, 8]\n assert candidate(grid = [[1, 22, 333, 4444, 55555], [98765, 4321, 987, 6543, 21], [11, 222, 3333, 44444, 555555]]) == [5, 4, 4, 5, 6]\n assert candidate(grid = [[1000000000, 999999999, 888888888, 777777777, 666666666], [555555555, 444444444, 333333333, 222222222, 111111111]]) == [10, 9, 9, 9, 9]\n assert candidate(grid = [[12345, 6789, -101112], [-131415, 161718, 192021], [222324, -252627, 282930], [313233, 343536, -373839]]) == [7, 7, 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]]) == [1, 1, 1, 1, 1]\n assert candidate(grid = [[-987654321, 987654321], [123456789, -123456789], [1, 2], [-1, -2], [10, -10], [100, -100]]) == [10, 10]\n assert candidate(grid = [[-1, -10, -100, -1000, -10000], [2, 20, 200, 2000, 20000], [3, 30, 300, 3000, 30000]]) == [2, 3, 4, 5, 6]\n assert candidate(grid = [[123, 456, -789], [987, 654, 321], [-111, 222, -333], [100, -200, 300]]) == [4, 4, 4]\n assert candidate(grid = [[111, -222, 333], [444, -555, 666], [-777, 888, -999], [1000, -1000, 1000], [-10000, 10000, -10000]]) == [6, 5, 6]\n assert candidate(grid = [[-123, 456, -789], [100000, 200000, 300000], [1, -2, 3], [-4, 5, -6], [7, -8, 9]]) == [6, 6, 6]\n assert candidate(grid = [[-123456789, 234567890, -345678901], [456789012, -567890123, 678901234], [789012345, -890123456, 901234567]]) == [10, 10, 10]\n assert candidate(grid = [[123, 456, 789, 101112, -131415], [161718, 192021, 222324, -252627, 282930], [-313233, 343536, 373839, 404142, 434445]]) == [7, 6, 6, 7, 7]\n assert candidate(grid = [[-123, 456, -789], [1011, -1213, 1415], [-1617, 1819, -2021], [2223, -2425, 2627], [-2829, 3031, -3233]]) == [5, 5, 5]\n assert candidate(grid = [[123456789, 123456789, 123456789], [987654321, 987654321, 987654321], [111111111, 111111111, 111111111]]) == [9, 9, 9]\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, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(grid = [[-99999999, 99999999, 9999999], [99999998, -99999998, 9999998], [99999997, 99999997, -9999997], [-99999996, 99999996, 9999996], [99999995, -99999995, 9999995], [99999994, 99999994, -9999994], [-99999993, 99999993, 9999993], [99999992, -99999992, 9999992], [99999991, 99999991, -9999991], [99999990, -99999990, 9999990]]) == [9, 9, 8]\n assert candidate(grid = [[-1000000000], [1000000000], [123456789], [-987654321], [111111111], [-222222222]]) == [11]\n assert candidate(grid = [[-123456789, 2147483647, 123456789], [987654321, -987654321, 1000000000], [1, 2, 3]]) == [10, 10, 10]\n assert candidate(grid = [[-1, 2, -3, 4, -5], [5, -4, 3, -2, 1], [-10, 20, -30, 40, -50], [50, -40, 30, -20, 10]]) == [3, 3, 3, 3, 3]\n assert candidate(grid = [[-1, 2, -3, 4, -5], [5, -4, 3, -2, 1], [11, -22, 33, -44, 55], [-55, 44, -33, 22, -11]]) == [3, 3, 3, 3, 3]\n assert candidate(grid = [[123456789, -987654321, 100000000], [111111111, 222222222, -333333333], [999999999, 888888888, 777777777]]) == [9, 10, 10]\n assert candidate(grid = [[9, 88, 777, 6666], [55555, 4444, 333, 22], [1, -10, -100, -1000]]) == [5, 4, 4, 5]\n assert candidate(grid = [[-1, -22, -333, -4444, -55555], [55555, 4444, 333, 22, -1], [-55555, -4444, -333, -22, -1]]) == [6, 5, 4, 5, 6]\n assert candidate(grid = [[123456789, -987654321], [987654321, 123456789], [-111111111, 222222222], [333333333, -444444444]]) == [10, 10]\n assert candidate(grid = [[0, 1000000000, -1000000000], [100000000, -10000000, 1000000], [10000000, -1000000, 100000], [1000000, -100000, 10000], [100000, -10000, 1000], [10000, -1000, 100], [1000, -100, 10], [100, -10, 1], [10, -1, 0]]) == [9, 10, 11]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 3]\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]]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(grid = [[-123456789, 0, 123456789], [1000000000, -1000000000, 0], [123456789, 0, -123456789]]) == [10, 11, 10]\n assert candidate(grid = [[0, 0, 0, 0, 0], [-1, -2, -3, -4, -5], [999999999, 888888888, 777777777, 666666666, 555555555]]) == [9, 9, 9, 9, 9]\n assert candidate(grid = [[-987654321, 123456789, 111111111], [98765432, -12345678, 222222222], [9876543, 1234567, -333333333]]) == [10, 9, 10]\n assert candidate(grid = [[-1000000000], [-100000000], [-10000000], [-1000000], [-100000], [-10000], [-1000], [-100], [-10], [-1]]) == [11]\n assert candidate(grid = [[1000000000], [-999999999], [123456789], [-123456789], [987654321], [-987654321]]) == [10]\n assert candidate(grid = [[-999999999, 1000000000, 123456789], [987654321, -876543210, 123], [1, 22, 333]]) == [10, 10, 9]\n assert candidate(grid = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15]]) == [2]\n assert candidate(grid = [[-1, 2, -3, 4, -5], [10, -20, 30, -40, 50], [100, -200, 300, -400, 500], [-1000, 2000, -3000, 4000, -5000]]) == [5, 4, 5, 4, 5]\n assert candidate(grid = [[-1, -20, -300, -4000, -50000], [-600000, 70000, -8000, 900, -100], [1, 2, 3, 4, 5], [-6, -7, -8, -9, -10]]) == [7, 5, 5, 5, 6]\n assert candidate(grid = [[987654321, 987654321, 987654321], [-123456789, -123456789, -123456789], [0, 0, 0], [1, -1, 2], [2, -2, 3], [3, -3, 4]]) == [10, 10, 10]\n assert candidate(grid = [[1234567890], [9876543210], [1000000000], [-999999999], [123456789]]) == [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]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(grid = [[100, 200, 300], [-1000, 2000, -3000], [10000, -20000, 30000], [-100000, 200000, -300000], [1000000, -2000000, 3000000], [-10000000, 20000000, -30000000], [100000000, -200000000, 300000000], [-1000000000, 2000000000, -3000000000]]) == [11, 10, 11]\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]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(grid = [[12345, -67890, 11122], [-33344, 55566, -77788], [99900, -12131, 44455], [66677, -88899, 0]]) == [6, 6, 6]\n assert candidate(grid = [[1234567890], [-1234567890], [1234567890], [-1234567890], [1234567890]]) == [11]\n assert candidate(grid = [[1], [-22], [333], [-4444], [55555], [-666666], [7777777], [-88888888], [999999999], [-1000000000]]) == [11]\n assert candidate(grid = [[-1234567890, 1234567890], [-1111111111, 1111111111], [999999999, -999999999], [888888888, -888888888], [777777777, -777777777]]) == [11, 10]\n assert candidate(grid = [[-999999999, -888888888, -777777777], [666666666, 555555555, 444444444], [333333333, 222222222, 111111111]]) == [10, 10, 10]\n assert candidate(grid = [[-9, -99, -999, -9999], [8, 88, 888, 8888], [7, 77, 777, 7777], [6, 66, 666, 6666]]) == [2, 3, 4, 5]\n assert candidate(grid = [[1000000000], [-1000000000], [999999999], [-999999999], [1], [-1]]) == [11]\n assert candidate(grid = [[1111, 2222, 3333], [-1111, -2222, -3333], [999, 888, 777], [-999, -888, -777], [1234, -1234, 2345]]) == [5, 5, 5]\n assert candidate(grid = [[0, 0, 0, 0], [-1, 0, 1, 0], [0, -1, 0, 1], [10, -10, 100, -100], [-123, 0, 123, 0], [0, 123, 0, -123]]) == [4, 3, 3, 4]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 3]\n assert candidate(grid = [[-1, 100000000, 0], [123456789, -98765432, 999999999], [0, 1, -1000000]]) == [9, 9, 9]\n assert candidate(grid = [[0, 123456789, -987654321], [987654321, 0, 123456789], [-123456789, -987654321, 0]]) == [10, 10, 10]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().findColumnWidth", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] findColumnWidth(int[][] grid) {", "container": "Solution", "callable": "findColumnWidth", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2640, "task_id": "find-the-score-of-all-prefixes-of-an-array", "difficulty": "Medium", "problem_description": "We define the conversion array conver of an array arr as follows:\n\nconver[i] = arr[i] + max(arr[0..i]) where max(arr[0..i]) is the maximum value of arr[j] over 0 <= j <= i.\n\nWe also define the score of an array arr as the sum of the values of the conversion array of arr.\nGiven a 0-indexed integer array nums of length n, return an array ans of length n where ans[i] is the score of the prefix nums[0..i].\n \nExample 1:\n\nInput: nums = [2,3,7,5,10]\nOutput: [4,10,24,36,56]\nExplanation: \nFor the prefix [2], the conversion array is [4] hence the score is 4\nFor the prefix [2, 3], the conversion array is [4, 6] hence the score is 10\nFor the prefix [2, 3, 7], the conversion array is [4, 6, 14] hence the score is 24\nFor the prefix [2, 3, 7, 5], the conversion array is [4, 6, 14, 12] hence the score is 36\nFor the prefix [2, 3, 7, 5, 10], the conversion array is [4, 6, 14, 12, 20] hence the score is 56\n\nExample 2:\n\nInput: nums = [1,1,2,4,8,16]\nOutput: [2,4,8,16,32,64]\nExplanation: \nFor the prefix [1], the conversion array is [2] hence the score is 2\nFor the prefix [1, 1], the conversion array is [2, 2] hence the score is 4\nFor the prefix [1, 1, 2], the conversion array is [2, 2, 4] hence the score is 8\nFor the prefix [1, 1, 2, 4], the conversion array is [2, 2, 4, 8] hence the score is 16\nFor the prefix [1, 1, 2, 4, 8], the conversion array is [2, 2, 4, 8, 16] hence the score is 32\nFor the prefix [1, 1, 2, 4, 8, 16], the conversion array is [2, 2, 4, 8, 16, 32] hence the score is 64\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, 3, 2, 1]) == [10, 19, 27, 34, 40]\n assert candidate(nums = [1]) == [2]\n assert candidate(nums = [1000000000]) == [2000000000]\n assert candidate(nums = [1, 1, 2, 4, 8, 16]) == [2, 4, 8, 16, 32, 64]\n assert candidate(nums = [2, 3, 7, 5, 10]) == [4, 10, 24, 36, 56]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046]\n assert candidate(nums = [5, 5, 5, 5, 5]) == [10, 20, 30, 40, 50]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 39, 57, 74, 90, 105, 119, 132, 144, 155]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [2, 6, 12, 20, 30]\n assert candidate(nums = [10, 9, 8, 7, 6]) == [20, 39, 57, 74, 90]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 6, 12, 20, 30, 42, 56, 72, 90, 110]\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]) == [2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462, 506, 552, 600, 650, 702, 756, 812, 870, 930, 992, 1056, 1122, 1190, 1260, 1332, 1406, 1482, 1560, 1640, 1722, 1806, 1892, 1980, 2070, 2162, 2256, 2352, 2450, 2550]\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [2000000000, 4000000000, 6000000000, 8000000000, 10000000000]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == [2, 22, 222, 2222, 22222, 222222, 2222222]\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]) == [58, 115, 171, 226, 280, 333, 385, 436, 486, 535, 583, 630, 676, 721, 765, 808, 850, 891, 931, 970, 1008, 1045, 1081, 1116, 1150, 1183, 1215, 1246, 1276]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [2, 8, 18, 32, 50, 72, 98, 128, 162, 200, 242, 288, 338, 392, 450, 512]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [200, 600, 1200, 2000, 3000, 4200, 5600, 7200, 9000, 11000]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046, 4094, 8190, 16382, 32766, 65534, 131070, 262142, 524286, 1048574, 2097150]\n assert candidate(nums = [2000000000, 1000000000, 3000000000, 500000000, 4000000000, 600000000, 7000000000, 800000000, 9000000000, 10000000000]) == [4000000000, 7000000000, 13000000000, 16500000000, 24500000000, 29100000000, 43100000000, 50900000000, 68900000000, 88900000000]\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [2000000000, 4000000000, 6000000000, 8000000000, 10000000000]\n assert candidate(nums = [31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62, 64, 33, 83, 27]) == [62, 144, 262, 347, 459, 576, 770, 960, 1080, 1261, 1420, 1581, 1711, 1891, 2015]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1]) == [18, 35, 51, 66, 80, 93, 105, 116, 126, 136, 147, 159, 172, 186, 201, 217, 234, 252, 262, 272]\n assert candidate(nums = [100, 200, 100, 300, 200, 400, 300, 500, 400, 600, 500, 700, 600, 800, 700]) == [200, 600, 900, 1500, 2000, 2800, 3500, 4500, 5400, 6600, 7700, 9100, 10400, 12000, 13500]\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, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [2, 8, 18, 32, 50, 72, 98, 128, 162, 200, 242, 288, 338, 392, 450]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == [2, 8, 13, 23, 32, 46, 59, 77, 94, 114]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == [6, 10, 18, 23, 33, 51, 62, 77, 91, 103, 117, 135, 151, 169, 181, 192, 204, 221, 234, 249]\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, 8, 18, 32, 50, 72, 98, 128, 162, 200, 242, 288, 338, 392, 450, 512, 578, 648, 722, 800]\n assert candidate(nums = [5, 3, 8, 1, 4, 9, 2, 7, 6, 10]) == [10, 18, 34, 43, 55, 73, 84, 100, 115, 135]\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]) == [50, 99, 147, 194, 240, 285, 329, 372, 414, 455, 495, 534, 572, 609, 645, 680, 714, 747, 779, 810, 840, 869, 897, 924, 950]\n assert candidate(nums = [999999999, 1, 999999998, 2, 999999997, 3, 999999996, 4, 999999995, 5, 999999994, 6, 999999993, 7, 999999992, 8]) == [1999999998, 2999999998, 4999999995, 5999999996, 7999999992, 8999999994, 10999999989, 11999999992, 13999999986, 14999999990, 16999999983, 17999999988, 19999999980, 20999999986, 22999999977, 23999999984]\n assert candidate(nums = [5, 1, 4, 2, 8, 6, 3, 7, 9]) == [10, 16, 25, 32, 48, 62, 73, 88, 106]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [20, 40, 60, 80, 100, 120, 140, 160, 180, 200]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [20, 60, 90, 130, 160, 200, 230, 270, 300, 340, 370, 410, 440, 480, 510, 550, 580, 620, 650, 690]\n assert candidate(nums = [5, 3, 8, 6, 2, 9, 1, 4, 7, 10]) == [10, 18, 34, 48, 58, 76, 86, 99, 115, 135]\n assert candidate(nums = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000]) == [2000000000, 3900000000, 5700000000, 7400000000, 9000000000, 10500000000, 11900000000, 13200000000, 14400000000, 15500000000]\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]) == [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, 122, 124, 126]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == [2, 6, 12, 16, 21, 27, 31, 36, 42, 46]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == [6, 10, 18, 23, 33, 51, 62, 77, 91, 103, 117, 135]\n assert candidate(nums = [5, 3, 8, 1, 9, 2, 7, 6, 4, 10]) == [10, 18, 34, 43, 61, 72, 88, 103, 116, 136]\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10]) == [20, 31, 71, 93, 153, 186, 266, 310, 410, 465, 585, 651, 791, 868, 1028, 1116, 1296, 1395, 1595, 1705]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [2, 4, 8, 12, 18, 24, 32, 40, 50, 60, 72, 84, 98, 112, 128, 144, 162, 180, 200, 220]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5]) == [18, 35, 51, 66, 80, 93, 105, 116, 126, 146, 165, 183, 200, 216, 231]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [2, 4, 8, 12, 18, 24, 32, 40, 50, 60]\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == [10, 19, 27, 34, 40, 46, 53, 61, 70, 80]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == [2000000000, 3999999999, 5999999997, 7999999994, 9999999990, 11999999985, 13999999979, 15999999972, 17999999964, 19999999955]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [30, 59, 87, 114, 140, 165, 189, 212, 234, 255, 275, 294, 312, 329, 345, 360, 374, 387, 399, 410, 420, 429, 437, 444, 450, 455]\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [78, 154, 228, 300, 370, 438, 504, 568, 630, 690, 748, 804, 858, 910, 960, 1008, 1054, 1098, 1140, 1180]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [18, 35, 51, 66, 80, 93, 105, 116, 126, 146, 165, 183, 200, 216, 231, 245, 258, 270, 281]\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, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046, 4094, 8190, 16382, 32766, 65534]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [200, 390, 570, 740, 900, 1050, 1190, 1320, 1440, 1550]\n assert candidate(nums = [500, 250, 125, 62, 31, 15, 7, 3, 1, 0]) == [1000, 1750, 2375, 2937, 3468, 3983, 4490, 4993, 5494, 5994]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [2, 6, 10, 16, 22, 28, 36, 44, 52, 60, 70, 80, 90, 100, 110]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182, 196, 210, 224, 238, 252, 266, 280]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [2, 4, 6, 8, 10, 14, 18, 22, 26, 30, 36, 42, 48, 54, 60, 68, 76, 84, 92, 100]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [2, 8, 20, 40, 70, 112, 168, 240, 330, 440]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [2, 6, 12, 20, 30, 36, 43, 51, 60, 70, 76, 83, 91, 100, 110, 116, 123, 131, 140, 150]\n assert candidate(nums = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [4, 12, 24, 40, 60, 71, 84, 99, 116, 135, 157, 183, 213, 247, 285, 327, 373, 423, 477, 535]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [2, 22, 222, 2222, 22222, 222222, 2222222, 22222222, 222222222, 2222222222]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [2, 8, 18, 32, 50, 72, 98, 128, 162, 200]\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]) == [2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462, 506, 552, 600, 650]\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10]) == [20, 60, 90, 150, 190, 270, 320, 420, 480, 600, 670, 810, 890, 1050, 1140]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [18, 35, 51, 66, 80, 93, 105, 116, 126, 135, 145, 156, 168, 181, 195, 210, 226, 243, 261, 281]\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, 60, 120, 200, 300, 420, 560, 720, 900, 1100, 1320, 1560, 1820, 2100, 2400, 2720, 3060, 3420, 3800, 4200]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [18, 35, 51, 66, 80, 93, 105, 116, 126, 135, 153, 170, 186, 201, 215, 228, 240, 251, 261, 270]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [200, 390, 570, 740, 900, 1050, 1190, 1320, 1440, 1550, 1750, 1940, 2120, 2290, 2450, 2600, 2740, 2870, 2990, 3100]\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == [2, 4, 8, 14, 24, 40, 66, 108, 176, 286, 464, 752, 1218, 1972, 3192, 5166, 8360, 13528, 21890, 35420]\n assert candidate(nums = [20, 10, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110, 105]) == [40, 70, 130, 185, 265, 340, 440, 535, 655, 770, 910, 1045, 1205, 1360, 1540, 1715, 1915, 2110, 2330, 2545]\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, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [20, 60, 120, 200, 300, 420, 560, 720, 900, 1100, 1290, 1470, 1640, 1800, 1950, 2090, 2220, 2340, 2450]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == [2, 6, 12, 22, 38, 64, 106, 174, 284, 462, 750, 1216, 1970, 3190, 5164]\n assert candidate(nums = [10, 20, 30, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == [20, 60, 120, 200, 270, 330, 380, 440, 510, 590, 690, 810, 950, 1110, 1290]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [200, 390, 570, 740, 900, 1050, 1190, 1320, 1440, 1550]\n assert candidate(nums = [1, 100, 10000, 1000000, 100000000]) == [2, 202, 20202, 2020202, 202020202]\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000]) == [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000, 10000000000]\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, 8, 18, 32, 50, 72, 98, 128, 162, 200, 242, 288, 338, 392, 450, 512, 578, 648, 722, 800]\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [2, 22, 33, 53, 64, 84, 95, 115, 126, 146, 157, 177, 188, 208, 219, 239, 250, 270, 281, 301]\n assert candidate(nums = [5, 3, 9, 2, 8, 1, 7, 6, 4, 10]) == [10, 18, 36, 47, 64, 74, 90, 105, 118, 138]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046, 4094]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [20, 60, 120, 200, 300, 420, 560, 720, 900, 1100]\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, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [18, 35, 51, 66, 80, 93, 105, 116, 126, 135]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046, 4094, 8190, 16382]\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]) == [30, 90, 180, 300, 450, 630, 840, 1080, 1350, 1650, 1980, 2340, 2730, 3150, 3600, 4080, 4590, 5130, 5700, 6300]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [2, 8, 13, 23, 32, 46, 59, 77, 94, 116, 137, 163, 188, 218, 247, 281, 314, 352, 389, 429]\n assert candidate(nums = [5, 1, 3, 7, 2, 8, 4, 6, 10, 9, 11, 12, 13, 14, 15]) == [10, 16, 24, 38, 47, 63, 75, 89, 109, 128, 150, 174, 200, 228, 258]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [200, 600, 1200, 2000, 3000, 4200, 5600, 7200, 9000, 11000]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findPrefixScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long[] findPrefixScore(int[] nums) {", "container": "Solution", "callable": "findPrefixScore", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2641, "task_id": "cousins-in-binary-tree-ii", "difficulty": "Medium", "problem_description": "Given the root of a binary tree, replace the value of each node in the tree with the sum of all its cousins' values.\nTwo nodes of a binary tree are cousins if they have the same depth with different parents.\nReturn the root of the modified tree.\nNote that the depth of a node is the number of edges in the path from the root node to it.\n \nExample 1:\n\n\nInput: root = [5,4,9,1,10,null,7]\nOutput: [0,0,0,7,7,null,11]\nExplanation: The diagram above shows the initial binary tree and the binary tree after changing the value of each node.\n- Node with value 5 does not have any cousins so its sum is 0.\n- Node with value 4 does not have any cousins so its sum is 0.\n- Node with value 9 does not have any cousins so its sum is 0.\n- Node with value 1 has a cousin with value 7 so its sum is 7.\n- Node with value 10 has a cousin with value 7 so its sum is 7.\n- Node with value 7 has cousins with values 1 and 10 so its sum is 11.\n\nExample 2:\n\n\nInput: root = [3,1,2]\nOutput: [0,0,0]\nExplanation: The diagram above shows the initial binary tree and the binary tree after changing the value of each node.\n- Node with value 3 does not have any cousins so its sum is 0.\n- Node with value 1 does not have any cousins so its sum is 0.\n- Node with value 2 does not have any cousins so its sum is 0.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 105].\n1 <= Node.val <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7])), tree_node([0, 0, 0, 13, 13, 9, 9]))\n assert is_same_tree(candidate(root = tree_node([5, 4, 9, 1, 10, None, 7])), tree_node([0, 0, 0, 7, 7, None, 11]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 5, None, None, 6, 6, None, None, 7, 7])), tree_node([0, 0, 0, None, None, 0, 0, None, None, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([3, 1, 2])), tree_node([0, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([1])), tree_node([0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, None, None, 16, 17])), tree_node([0, 0, 0, 13, 13, 9, 9, 46, 46, 42, 42, 38, 38, None, None, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([5, 4, 9, 1, 10, None, 7, 11, None, 12, 13, None, 14, None, 15])), tree_node([0, 0, 0, 7, 7, None, 11, 39, None, 25, 25, None, 36, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])), tree_node([0, None, 0, None, 0, None, 0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), tree_node([0, 0, 0, 13, 13, 9, 9, 75, 75, 71, 71, 67, 67, 63, 63]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])), tree_node([0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([7, 3, 9, None, 8, 10, None, 11, None, None, 12, None, 13, None, 14])), tree_node([0, 0, 0, None, 10, 8, None, 12, None, None, 11, None, 14, None, 13]))\n assert is_same_tree(candidate(root = tree_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])), tree_node([0, 0, 0, 13, 13, 9, 9, 75, 75, 71, 71, 67, 67, 63, 63, 172, 172, 168, 168, 164, 164, 160, 160, 156, 156]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])), tree_node([0, 0, 0, 13, 13, 9, 9, 75, 75, 71, 71, 67, 67, 63, 63]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 2, None, 3, None, 3, None, 4, None, 4])), tree_node([0, 0, 0, None, 3, None, 3, None, 4, None, 4]))\n assert is_same_tree(candidate(root = tree_node([7, 3, 11, 2, 5, 8, 13, None, None, 4, 6, 9, 12, None, None, None, None, None, 10])), tree_node([0, 0, 0, 21, 21, 7, 7, None, None, 21, 21, 10, 10, None, None, None, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, None, 3, None, None, 4, None, None, 5, None, None, 6, None, None, 7, None, None, 8, None, None, 9, None, None, 10])), tree_node([0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])), tree_node([0, 0, 0, 8, 8, 8, 8, 18, 18, 18, 18, 18, 18, 18, 18, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 28]))\n assert is_same_tree(candidate(root = tree_node([5, 4, 9, 1, 10, None, 7, 8, None, None, None, 9, None, None, 10])), tree_node([0, 0, 0, 7, 7, None, 11, 9, None, None, None, 8, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, None, 4, 5, None, None, 8, 9, None, 12, None, 15, None, None, None, None, 32, None, None, 64, None, None, 128])), tree_node([0, 0, None, 0, 0, None, None, 0, 0, None, 15, None, 12]))\n assert is_same_tree(candidate(root = tree_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])), tree_node([0, 0, 0, 13, 13, 9, 9, 75, 75, 71, 71, 67, 67, 63, 63, 343, 343, 339, 339, 335, 335, 331, 331, 327, 327, 323, 323, 319, 319, 315, 315, 259, 259, 255, 255, 251, 251, 247, 247, 284]))\n assert is_same_tree(candidate(root = tree_node([10, 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])), tree_node([0, 0, 0, 14, 14, 12, 12, 60, 60, 58, 58, 56, 56, 54, 54, 224, 224, 222, 222, 220, 220, 218, 218, 216, 216, 214, 214, 212, 212, 210, 210, 230, 230, 228, 228, 226, 226, 224, 224, 222, 222, 220, 220]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, None, 6, 7, 8, 9, None, None, 12, 13, None, None, 16, 17])), tree_node([0, 0, 0, 13, None, 4, 4, 25, 25, None, None, 17, 17, None, None, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 8, 9, 10, 11, None, None, 16, 17, 18, 19, 20, None, None, 25, 26, 27, 28, 29, 30, None, None, 35, 36, 37, 38, 39, 40, None, None, 45, 46, 47, 48, 49, 50])), tree_node([0, 0, 0, 0, 0, None, None, 21, 21, 17, 17, None, None, 57, 57, 53, 53, 70, None, None, 175, 147, 147, 143, 143, 170, None, None, 165, 402, 402, 398, 398, 435, None, None, 430, 382, 382, 378, 378, 425]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 5, None, 7, 8, None, 10, None, None, 13, None, None, 16, None, None, None, None, None, 19])), tree_node([0, 0, 0, None, 7, None, 5, 10, None, 8, None, None, 0, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, None, 4, 5, None, None, 8, 9, 10, 11, 12, 13, 14, 15])), tree_node([0, 0, None, 0, 0, None, None, 0, 0, 25, 25, 21, 21, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 5, None, 7, None, None, 10, None, None, 14])), tree_node([0, 0, 0, None, 7, None, 5, None, None, 0, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, None, None, None, None, None, 9])), tree_node([0, 0, 0, 13, 13, 9, 9, 9, None, None, None, None, None, None, 8]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, 10, None, 12, None, 14, None, 16, None, 18])), tree_node([0, 0, 0, 13, 13, 9, 9, 36, None, 34, None, 32, None, 30, None, 18, None, 16]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, None, 7, 8, 9, None, 10, 11, None, 12])), tree_node([0, 0, 0, 6, 6, 9, None, 30, 30, 36, None, 24, 24, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, None, 6, None, 8, 9, None, 12, None, 15, None, None, None, None, 32, None, None, 64])), tree_node([0, 0, 0, 6, None, 4, None, 12, 12, None, 17, None, 0, None, None, None, None, 0, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([100, 50, 50, 25, 25, 25, 25, 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])), tree_node([0, 0, 0, 50, 50, 50, 50, 99, 99, 95, 95, 91, 91, 87, 87, 399, 399, 395, 395, 391, 391, 387, 387, 383, 383, 379, 379, 375, 375, 371, 371, 572, 572, 568, 568, 564, 564, 560, 560, 556, 556, 552, 552, 548, 548, 595]))\n assert is_same_tree(candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 90, 110, 140, 160, 190])), tree_node([0, 0, 0, 300, 300, 100, 100, 750, 750, 640, 640, 540, 540, 440, 440]))\n assert is_same_tree(candidate(root = tree_node([50, 25, 75, 12, 38, 63, 88, 6, 18, 30, 45, 55, 65, 80, 95, 3, 9, 15, 21, 27, 33, 39, 42, 48, 51, 57, 60, 66, 69, 72, 78, 81, 84, 87, 90, 93, 96, 99])), tree_node([0, 0, 0, 151, 151, 50, 50, 370, 370, 319, 319, 274, 274, 219, 219, 678, 678, 654, 654, 630, 630, 609, 609, 591, 591, 573, 573, 555, 555, 540, 540, 465, 465, 453, 453, 441, 441, 531]))\n assert is_same_tree(candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])), tree_node([0, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([3, 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18])), tree_node([0, 0, 0, 15, 15, 11, 11, 81, 81, 77, 77, 73, 73, 69, 69, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([5, 4, 9, 1, 10, None, 7, 11, None, None, None, None, 12])), tree_node([0, 0, 0, 7, 7, None, 11, 12, None, None, None, None, 11]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])), tree_node([0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0]))\n assert is_same_tree(candidate(root = tree_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])), tree_node([0, 0, 0, 13, 13, 9, 9, 75, 75, 71, 71, 67, 67, 63, 63, 343, 343, 339, 339, 335, 335, 331, 331, 327, 327, 323, 323, 319, 319, 315, 315, 1455, 1455, 1451, 1451, 1447, 1447, 1443, 1443, 1439, 1439, 1435, 1435, 1431, 1431, 1427, 1427, 1423, 1423, 1419, 1419, 1415, 1415, 1411, 1411, 1407, 1407, 1403, 1403, 1399, 1399, 1395, 1395]))\n assert is_same_tree(candidate(root = tree_node([25, 12, 38, 6, 18, 26, 40, 3, 9, 15, 21, 27, 41, None, None, 1, 5, 8, 14, 17, 20, 22, 25, 28, 39, 42, None, None, None, None, None, 2, 4, 7, 10, 13, 16, 19, 23, 24, 26, 30, 32, 35, 43, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])), tree_node([0, 0, 0, 66, 66, 24, 24, 104, 104, 80, 80, 48, 48, None, None, 215, 215, 199, 199, 184, 184, 174, 174, 154, 154, 179, None, None, None, None, None, 278, 278, 267, 267, 255, 255, 242, 242, 234, 234, 222, 222, 206, 206]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 4, 6, 14, 21, 26, 31, 36, None, 3, 7, 8, 11, 13, 16, 19, 22, 24, 27, 29, 32, 33, 34, None, None, None, None, None, 2, 9, 10, 12, 15, 17, 18, 20, 23, 28, 30, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])), tree_node([0, 0, 0, 60, 60, 20, 20, 134, 134, 119, 119, 92, 92, 72, 72, None, 275, 263, 263, 254, 254, 243, 243, 232, 232, 222, 222, 213, 213, 244, None, None, None, None, None, 173, 173, 162, 162, 152, 152, 146, 146, 133, 133, 154]))\n assert is_same_tree(candidate(root = tree_node([8, 3, 10, 1, 6, None, 14, 2, None, 4, 5, None, None, 11, 12])), tree_node([0, 0, 0, 14, 14, None, 7, 9, None, 2, 2, None, None, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])), tree_node([0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, None, 6, None, None, 7, None, 8, None, None, 9, None, None, 10])), tree_node([0, 0, 0, None, 5, None, 4, None, None, 0, None, None, 0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8])), tree_node([0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])), tree_node([0, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, None, 3, None, None, None, 4, None, None, None, 5, None, None, None, 6, None, None, None, 7])), tree_node([0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, None, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), tree_node([0, 0, None, 0, 0, 17, 17, 13, 13, 54, 54, 50, 50, 46, 46]))\n assert is_same_tree(candidate(root = tree_node([15, 10, 20, 5, 12, 16, 25, 1, 6, None, 8, 17, 18, None, None, None, None, 9, 7])), tree_node([0, 0, 0, 41, 41, 17, 17, 43, 43, None, 42, 15, 15, None, None, None, None, 0, 0]))\n assert is_same_tree(candidate(root = tree_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])), tree_node([0, 0, 0, 13, 13, 9, 9, 75, 75, 71, 71, 67, 67, 63, 63, 312, 312, 308, 308, 304, 304, 300, 300, 296, 296, 292, 292, 288, 288, 315]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 4, 5, None, 6, None, 7, 8, None, 9, None, 10, 11, 12])), tree_node([0, 0, 0, None, 5, 4, None, 15, None, 6, 6, None, 33, None, 32, 19, 19]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, None, None, 3, None, None, None, None, None, 4, None, None, None, None, None, 5])), tree_node([0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, 8, 9, None, None, 10, 11, None, None, None, None, 12, None, None, None, None, 13, None, None, None, None, 14, None, None])), tree_node([0, 0, 0, 13, 13, 9, 9, None, None, 21, 21, None, None, 17, 17, None, None, None, None, 0, None, None, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, None, 25, 35, 3, None, 22, 28, None, None, 33, None])), tree_node([0, 0, 0, 60, None, 5, 5, 50, None, 3, 3, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11, None, None, 12, 13])), tree_node([0, 0, 0, None, None, 0, 0, None, None, 0, 0, None, None, 0, 0, None, None, 0, 0, None, None, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 4, None, 5, 6, None, None, None, None, 7])), tree_node([0, 0, 0, None, 5, None, 4, 0, None, None, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 4, 5, 6, None, None, 7, 8, 9, 10, None, None, None, None, 11, 12])), tree_node([0, 0, 0, None, 11, 4, 4, None, None, 19, 19, 15, 15, None, None, None, None, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, 8, 9, 10, 11, 12, 13, 14])), tree_node([0, 0, 0, 13, 13, 9, 9, None, 69, 58, 58, 54, 54, 50, 50]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), tree_node([0, 0, 0, 13, 13, 9, 9, 75, 75, 71, 71, 67, 67, 63, 63]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, None, 6, 7, None, None, None, None, 12, 13, None, None, None, None, 18, 19])), tree_node([0, 0, 0, None, None, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, None, 4, 5, None, 7, None, None, 8, 9, None, None, 10, 11])), tree_node([0, 0, None, 0, 0, None, 0, None, None, 0, 0, None, None, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 4, None, None, 5, 6, 7, 8, 9, 10, None, None, None, None, 11, 12, 13, 14, 15, 16, 17])), tree_node([0, 0, 0, None, 0, None, None, 0, 0, 19, 19, 15, 15, None, None, None, None, 27, 27, 23, 23, 17, 17, 31]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4])), tree_node([0, 0, 0, 6, 6, 6, 6, 24, 24, 24, 24, 24, 24, 24, 24]))\n assert is_same_tree(candidate(root = tree_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])), tree_node([0, 0, 0, 13, 13, 9, 9, 75, 75, 71, 71, 67, 67, 63, 63, 343, 343, 339, 339, 335, 335, 331, 331, 327, 327, 323, 323, 319, 319, 315, 315]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, None, 4, None, None, 5, None, None, 6, None, None, 7, None, None, 8, None, None, 9, None, None, 10, None, None, 11, None, None, 12, None, None, 13, None, None, 14, None, None, 15, None, None, 16, None, None, 17, None, None, 18, None, None, 19, None, None, 20])), tree_node([0, 0, 0, None, None, 0, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11])), tree_node([0, 0, 0, 0, 0, None, None, 0, 0, None, None, 0, 0, None, None, 0, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5])), tree_node([0, 0, None, 0, None, 0, None, 0]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 5, None, None, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10])), tree_node([0, 0, 0, None, None, 0, 0, 16, 16, 14, 14, 20, 20, 18, 18]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, None, None, 5, 6, None, 7, None, 8, None, 9, None, 10])), tree_node([0, 0, 0, 5, None, None, 4, 7, None, 6, None, 9, None, 8, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, None, None, 4, None, None, None, None, None, None, None, 5])), tree_node([0, 0, 0, None, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])), tree_node([0, 0, 0, None, 5, None, 4, None, 7, None, 6, None, 9, None, 8]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, None, None, None, 16, None, None, 17, None, None, 18, None, None, 19, None, None, 20])), tree_node([0, 0, 0, 13, 13, 9, 9, 75, 75, 71, 71, 67, 67, 63, 63, None, None, None, None, None, None, None, None, None, None, None, None, None, 0, None, None, 0, None, None, 0]))\n assert is_same_tree(candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 88, 112, 137, 162, 188, 6, 9, 23, 41, 59, 76, 89, 108, 126, 143, 157, 172, 190, 24, 36, 50, 64, 85, 102, 118, 134, 149, 164, 179, 195])), tree_node([0, 0, 0, 300, 300, 100, 100, 749, 749, 648, 648, 549, 549, 448, 448, 1294, 1294, 1245, 1245, 1174, 1174, 1112, 1112, 1040, 1040, 980, 980, 1095, 1095, 1223, 1223, 1041, 1041, 970, 970, 907, 907, 847, 847, 995]))\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().replaceValueInTree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {", "container": "Solution", "callable": "TreeNode", "parameters": [], "return_type": "class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2643, "task_id": "row-with-maximum-ones", "difficulty": "Easy", "problem_description": "Given a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row.\nIn case there are multiple rows that have the maximum count of ones, the row with the smallest row number should be selected.\nReturn an array containing the index of the row, and the number of ones in it.\n \nExample 1:\n\nInput: mat = [[0,1],[1,0]]\nOutput: [0,1]\nExplanation: Both rows have the same number of 1's. So we return the index of the smaller row, 0, and the maximum count of ones (1). So, the answer is [0,1]. \n\nExample 2:\n\nInput: mat = [[0,0,0],[0,1,1]]\nOutput: [1,2]\nExplanation: The row indexed 1 has the maximum count of ones (2). So we return its index, 1, and the count. So, the answer is [1,2].\n\nExample 3:\n\nInput: mat = [[0,0],[1,1],[0,0]]\nOutput: [1,2]\nExplanation: The row indexed 1 has the maximum count of ones (2). So the answer is [1,2].\n\n \nConstraints:\n\nm == mat.length \nn == mat[i].length \n1 <= m, n <= 100 \nmat[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[0, 1], [1, 0]]) == [0, 1]\n assert candidate(mat = [[1, 1, 1], [0, 1, 1], [1, 0, 0]]) == [0, 3]\n assert candidate(mat = [[1, 1, 1, 0], [0, 1, 1, 1], [1, 1, 1, 1], [0, 0, 1, 1]]) == [2, 4]\n assert candidate(mat = [[0, 0, 0], [0, 1, 1]]) == [1, 2]\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 0]]) == [2, 1]\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == [0, 0]\n assert candidate(mat = [[0, 0], [1, 1], [0, 0]]) == [1, 2]\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1]]) == [3, 3]\n assert candidate(mat = [[1, 1, 1], [0, 1, 0], [1, 0, 0]]) == [0, 3]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == [0, 4]\n assert candidate(mat = [[1, 1, 1], [1, 0, 1], [0, 0, 0]]) == [0, 3]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [1, 31]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]]) == [4, 11]\n assert candidate(mat = [[0, 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, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0]]) == [1, 10]\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 0, 0, 0]]) == [2, 5]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1, 1, 0]]) == [0, 5]\n assert candidate(mat = [[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, 1, 1], [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, 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(mat = [[1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == [3, 8]\n assert candidate(mat = [[1, 1, 1, 0, 0, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [1, 8]\n assert candidate(mat = [[1, 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, 1, 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, 1, 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, 1, 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, 1, 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, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [0, 1]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 0, 0, 0, 0, 1, 1]]) == [2, 4]\n assert candidate(mat = [[0, 0, 0, 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(mat = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == [2, 6]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1]]) == [0, 5]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1, 1]]) == [0, 4]\n assert candidate(mat = [[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]]) == [2, 10]\n assert candidate(mat = [[1, 0, 0, 1, 0, 0, 1], [0, 0, 1, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == [2, 4]\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [3, 10]\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 0, 1], [0, 0, 0, 1, 0]]) == [0, 3]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == [3, 1]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 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, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == [0, 5]\n assert candidate(mat = [[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, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]]) == [4, 4]\n assert candidate(mat = [[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, 0, 0, 0, 0, 0, 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, 20]\n assert candidate(mat = [[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, 1]]) == [0, 2]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 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]]) == [6, 7]\n assert candidate(mat = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1]]) == [0, 4]\n assert candidate(mat = [[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, 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, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]]) == [0, 15]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [0, 12]\n assert candidate(mat = [[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, 3]\n assert candidate(mat = [[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, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == [0, 10]\n assert candidate(mat = [[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, 1]]) == [1, 11]\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 1, 0, 1], [0, 1, 1, 0, 1, 1], [1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0]]) == [0, 4]\n assert candidate(mat = [[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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [0, 1]\n assert candidate(mat = [[0, 1, 1, 1, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0]]) == [1, 8]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0], [1, 1, 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, 3]\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == [5, 5]\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1]]) == [0, 4]\n assert candidate(mat = [[0, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1]]) == [0, 5]\n assert candidate(mat = [[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, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0]]) == [0, 10]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0]]) == [2, 6]\n assert candidate(mat = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0]]) == [3, 8]\n assert candidate(mat = [[1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1], [0, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == [3, 6]\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1, 0]]) == [0, 5]\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 0, 1], [0, 0, 0, 0, 1]]) == [0, 3]\n assert candidate(mat = [[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, 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], [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, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [0, 20]\n assert candidate(mat = [[0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1]]) == [3, 3]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1]]) == [9, 20]\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [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, 0, 0, 0, 0, 0]]) == [2, 11]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0]]) == [0, 7]\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], [0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 0, 1, 0, 1, 0, 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, 32]\n assert candidate(mat = [[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]]) == [3, 7]\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, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [0, 20]\n assert candidate(mat = [[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, 0, 0, 0, 0, 0]]) == [0, 10]\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]]) == [0, 6]\n assert candidate(mat = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [3, 10]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [0, 3]\n assert candidate(mat = [[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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == [0, 20]\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [2, 10]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == [9, 9]\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == [2, 6]\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().rowAndMaximumOnes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] rowAndMaximumOnes(int[][] mat) {", "container": "Solution", "callable": "rowAndMaximumOnes", "parameters": [{"name": "mat", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2644, "task_id": "find-the-maximum-divisibility-score", "difficulty": "Easy", "problem_description": "You are given two integer arrays nums and divisors.\nThe divisibility score of divisors[i] is the number of indices j such that nums[j] is divisible by divisors[i].\nReturn the integer divisors[i] with the maximum divisibility score. If multiple integers have the maximum score, return the smallest one.\n \nExample 1:\n\nInput: nums = [2,9,15,50], divisors = [5,3,7,2]\nOutput: 2\nExplanation:\nThe divisibility score of divisors[0] is 2 since nums[2] and nums[3] are divisible by 5.\nThe divisibility score of divisors[1] is 2 since nums[1] and nums[2] are divisible by 3.\nThe divisibility score of divisors[2] is 0 since none of the numbers in nums is divisible by 7.\nThe divisibility score of divisors[3] is 2 since nums[0] and nums[3] are divisible by 2.\nAs divisors[0], divisors[1], and divisors[3] have the same divisibility score, we return the smaller one which is divisors[3].\n\nExample 2:\n\nInput: nums = [4,7,9,3,9], divisors = [5,2,3]\nOutput: 3\nExplanation:\nThe divisibility score of divisors[0] is 0 since none of numbers in nums is divisible by 5.\nThe divisibility score of divisors[1] is 1 since only nums[0] is divisible by 2.\nThe divisibility score of divisors[2] is 3 since nums[2], nums[3] and nums[4] are divisible by 3.\n\nExample 3:\n\nInput: nums = [20,14,21,10], divisors = [10,16,20]\nOutput: 10\nExplanation:\nThe divisibility score of divisors[0] is 2 since nums[0] and nums[3] are divisible by 10.\nThe divisibility score of divisors[1] is 0 since none of the numbers in nums is divisible by 16.\nThe divisibility score of divisors[2] is 1 since nums[0] is divisible by 20.\n\n \nConstraints:\n\n1 <= nums.length, divisors.length <= 1000\n1 <= nums[i], divisors[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [20, 14, 21, 10],divisors = [10, 16, 20]) == 10\n assert candidate(nums = [7, 14, 28, 35],divisors = [7, 14, 28, 35]) == 7\n assert candidate(nums = [12, 24, 36, 48],divisors = [3, 6, 12, 24]) == 3\n assert candidate(nums = [15, 30, 45, 60, 75],divisors = [5, 10, 15, 20, 25]) == 5\n assert candidate(nums = [100, 200, 300],divisors = [10, 20, 50]) == 10\n assert candidate(nums = [9, 18, 27, 36, 45],divisors = [9, 18, 27]) == 9\n assert candidate(nums = [11, 22, 33, 44, 55],divisors = [11, 22, 33, 44, 55]) == 11\n assert candidate(nums = [9, 18, 27, 36],divisors = [3, 6, 9, 18]) == 3\n assert candidate(nums = [3, 6, 9, 12],divisors = [3, 6, 9]) == 3\n assert candidate(nums = [7, 14, 21, 28],divisors = [7, 14]) == 7\n assert candidate(nums = [7, 14, 21, 28, 35],divisors = [7, 14]) == 7\n assert candidate(nums = [12, 24, 36, 48, 60],divisors = [2, 3, 4, 5, 6]) == 2\n assert candidate(nums = [8, 16, 24, 32, 40],divisors = [2, 4, 8, 16, 32]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],divisors = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6],divisors = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55],divisors = [11, 22, 33]) == 11\n assert candidate(nums = [5, 10, 15, 20, 25],divisors = [5]) == 5\n assert candidate(nums = [5, 10, 15, 20, 25],divisors = [5, 10, 15, 20, 25]) == 5\n assert candidate(nums = [100, 200, 300, 400, 500],divisors = [10, 20, 30, 40, 50]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1],divisors = [1]) == 1\n assert candidate(nums = [13, 17, 19, 23, 29],divisors = [13, 17, 19, 23, 29]) == 13\n assert candidate(nums = [15, 30, 45, 60],divisors = [5, 10, 15, 30]) == 5\n assert candidate(nums = [100, 200, 300],divisors = [10, 20, 30, 40]) == 10\n assert candidate(nums = [100, 200, 300, 400],divisors = [10, 20, 30, 40]) == 10\n assert candidate(nums = [5, 5, 5, 5],divisors = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [7, 14, 21, 28],divisors = [7, 14, 28]) == 7\n assert candidate(nums = [2, 9, 15, 50],divisors = [5, 3, 7, 2]) == 2\n assert candidate(nums = [8, 16, 24, 32, 40],divisors = [4, 8, 16, 24, 32]) == 4\n assert candidate(nums = [8, 16, 24, 32],divisors = [2, 4, 8, 16]) == 2\n assert candidate(nums = [3, 6, 9, 12],divisors = [2, 3, 4]) == 3\n assert candidate(nums = [13, 17, 19],divisors = [2, 3, 5, 7, 11]) == 2\n assert candidate(nums = [7, 7, 7, 7, 7],divisors = [2, 3, 5, 7, 11]) == 7\n assert candidate(nums = [4, 7, 9, 3, 9],divisors = [5, 2, 3]) == 3\n assert candidate(nums = [12, 24, 36],divisors = [2, 3, 4, 6, 8]) == 2\n assert candidate(nums = [101, 202, 303, 404, 505],divisors = [1, 2, 3, 4, 5, 101]) == 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],divisors = [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 = [500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],divisors = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 2\n assert candidate(nums = [101, 202, 303, 404, 505],divisors = [1, 101, 202, 303, 404]) == 1\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],divisors = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 101\n assert candidate(nums = [100, 200, 300, 400, 500],divisors = [10, 20, 30, 40, 50, 100]) == 10\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],divisors = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 101\n assert candidate(nums = [1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012, 10123, 11234, 12345, 13456, 14567, 15678, 16789, 17890, 18901, 19012, 20123],divisors = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1012]) == 234\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],divisors = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == 11\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110],divisors = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 101\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555],divisors = [11, 22, 33, 44, 55, 111111111]) == 111111111\n assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54],divisors = [2, 3, 4, 6, 9, 12, 18, 24, 36]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],divisors = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],divisors = [100000000, 50000000, 25000000, 12500000]) == 12500000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],divisors = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [29, 58, 87, 116, 145],divisors = [1, 29, 58, 87, 116, 145, 5, 11, 19, 23]) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],divisors = [13, 26, 39, 52, 65]) == 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],divisors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],divisors = [2, 3, 4, 5, 6, 7, 8, 9, 10, 12]) == 2\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049],divisors = [3, 9, 27, 81, 243, 729]) == 3\n assert candidate(nums = [987, 654, 321, 654, 987],divisors = [13, 29, 37, 53, 17]) == 13\n assert candidate(nums = [101, 202, 303, 404, 505],divisors = [1, 2, 3, 4, 5, 10, 20, 50]) == 1\n assert candidate(nums = [98, 196, 294, 392, 490],divisors = [7, 14, 28, 49, 98]) == 7\n assert candidate(nums = [1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093, 1000000099],divisors = [1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093, 1000000099]) == 1000000007\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],divisors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [8, 15, 24, 35, 48, 63, 80, 99, 120, 143, 168, 195, 224, 253, 288, 325, 364, 405, 448, 495],divisors = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]) == 8\n assert candidate(nums = [1000000001, 2000000002, 3000000003, 4000000004],divisors = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],divisors = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 100\n assert candidate(nums = [123456789, 987654321, 246813579, 864209753],divisors = [3, 9, 27, 81, 243]) == 3\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],divisors = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207],divisors = [23, 46, 69, 92, 115, 138, 161, 184, 207]) == 23\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],divisors = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300]) == 30\n assert candidate(nums = [55, 110, 220, 440, 880, 1760, 3520, 7040, 14080, 28160],divisors = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120]) == 10\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543],divisors = [98765, 87654, 76543, 65432, 54321, 43210, 32109, 21098, 10987]) == 10987\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],divisors = [2, 4, 5, 8, 10, 20, 25, 40, 50, 100]) == 2\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890],divisors = [123, 234, 345, 456, 567]) == 123\n assert candidate(nums = [123456789, 246913578, 370370370, 493827162],divisors = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 9\n assert candidate(nums = [13, 19, 23, 29, 31, 37, 41, 43, 47, 53],divisors = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 13\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000],divisors = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 1000\n assert candidate(nums = [123456, 789012, 345678, 901234, 567890],divisors = [123, 456, 789, 101112, 131415]) == 123\n assert candidate(nums = [29, 29, 29, 29, 29],divisors = [29, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],divisors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [777777777, 888888888, 999999999, 1111111111, 2222222222, 3333333333],divisors = [7, 8, 9, 11, 13, 17, 19]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],divisors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],divisors = [3, 5, 6, 9, 10]) == 3\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],divisors = [1, 2, 3, 4, 5, 10, 20, 50, 100, 101]) == 1\n assert candidate(nums = [9, 81, 729, 6561, 59049],divisors = [3, 9, 27, 81, 243]) == 3\n assert candidate(nums = [17, 19, 23, 29, 31],divisors = [2, 3, 5, 7, 11, 13, 17]) == 17\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149],divisors = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500],divisors = [10, 20, 25, 50, 100]) == 10\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],divisors = [2, 3, 4, 6, 8, 12, 16, 24, 32, 48]) == 2\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333],divisors = [1, 3, 9, 27, 81, 243, 729]) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],divisors = [1, 2, 3, 4, 5, 10, 13, 26, 52, 65, 130]) == 1\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60],divisors = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 2, 3, 4, 5]) == 2\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],divisors = [101, 202, 303, 404, 505]) == 101\n assert candidate(nums = [12345, 12345, 12345, 12345, 12345],divisors = [1, 2, 3, 5, 15, 30, 4115, 12345]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],divisors = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 2\n assert candidate(nums = [81, 162, 243, 324, 405, 486, 567, 648, 729, 810],divisors = [3, 6, 9, 18, 27, 54, 81, 162, 243, 486, 810]) == 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],divisors = [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 = [999999999, 888888888, 777777777, 666666666],divisors = [3, 9, 27, 81]) == 3\n assert candidate(nums = [42, 84, 126, 168, 210, 252],divisors = [6, 12, 18, 24, 30, 36]) == 6\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579],divisors = [123, 456, 789, 1234, 5678, 9876]) == 123\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260],divisors = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130]) == 13\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111],divisors = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 111\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],divisors = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [123456789, 987654321, 1122334455, 2233445566, 3344556677, 4455667788],divisors = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666]) == 111111111\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987],divisors = [98765432, 87654321, 76543210, 65432109, 54321098]) == 87654321\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],divisors = [3, 4, 6, 8, 12, 15, 20, 24, 30, 40]) == 3\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555],divisors = [99999999, 88888888, 77777777, 66666666, 55555555]) == 55555555\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],divisors = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],divisors = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43]) == 11\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],divisors = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],divisors = [11, 22, 33, 44, 55]) == 11\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909],divisors = [101, 202, 303, 404]) == 101\n assert candidate(nums = [49, 98, 147, 196, 245, 294, 343, 392, 441, 490],divisors = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 7\n assert candidate(nums = [97, 89, 83, 79, 73, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],divisors = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 73, 79, 83, 89, 97]) == 2\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],divisors = [125000000, 250000000, 500000000, 1000000000]) == 125000000\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378],divisors = [6, 12, 18, 24]) == 6\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],divisors = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],divisors = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [37, 74, 111, 148, 185],divisors = [37, 74, 111, 148, 185, 35, 142, 194, 226, 370]) == 37\n assert candidate(nums = [1000000007, 2000000014, 3000000021],divisors = [1, 1000000007, 2000000014, 3000000021]) == 1\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555],divisors = [111, 222, 333, 444, 555]) == 111\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],divisors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666],divisors = [1000000000, 999999999, 500000000, 250000000, 100000000]) == 100000000\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],divisors = [2, 3, 5, 7, 11]) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],divisors = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 3\n assert candidate(nums = [1000000007, 2000000014, 3000000021, 4000000028, 5000000035],divisors = [1000000007, 2000000014, 3000000021, 4000000028, 5000000035]) == 1000000007\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],divisors = [1, 13, 26, 39, 52, 65, 78, 91, 104, 117, 130]) == 1\n assert candidate(nums = [33, 66, 99, 132, 165],divisors = [11, 22, 33, 44, 55]) == 11\n assert candidate(nums = [4294967295, 2147483647, 1073741823, 536870911],divisors = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 3\n assert candidate(nums = [17, 19, 23, 29, 31, 37, 41, 43, 47],divisors = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 17\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],divisors = [1, 2, 3, 4, 5, 6, 8, 9, 10, 12]) == 1\n assert candidate(nums = [123456789, 987654321, 1122334455, 5544332211, 9988776655],divisors = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 1\n assert candidate(nums = [77, 77, 77, 77, 77, 77, 77, 77, 77, 77],divisors = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41]) == 7\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220],divisors = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == 11\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 1012345],divisors = [11111, 22222, 33333, 44444, 55555]) == 11111\n"}, "metadata": {"canonical_parameter_names": ["nums", "divisors"], "leetcode_dataset_entry_point": "Solution().maxDivScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxDivScore(int[] nums, int[] divisors) {", "container": "Solution", "callable": "maxDivScore", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "divisors", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2645, "task_id": "minimum-additions-to-make-valid-string", "difficulty": "Medium", "problem_description": "Given a string word to which you can insert letters \"a\", \"b\" or \"c\" anywhere and any number of times, return the minimum number of letters that must be inserted so that word becomes valid.\nA string is called valid if it can be formed by concatenating the string \"abc\" several times.\n \nExample 1:\n\nInput: word = \"b\"\nOutput: 2\nExplanation: Insert the letter \"a\" right before \"b\", and the letter \"c\" right next to \"b\" to obtain the valid string \"abc\".\n\nExample 2:\n\nInput: word = \"aaa\"\nOutput: 6\nExplanation: Insert letters \"b\" and \"c\" next to each \"a\" to obtain the valid string \"abcabcabc\".\n\nExample 3:\n\nInput: word = \"abc\"\nOutput: 0\nExplanation: word is already valid. No modifications are needed. \n\n \nConstraints:\n\n1 <= word.length <= 50\nword consists of letters \"a\", \"b\" and \"c\" only. \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aab\") == 3\n assert candidate(word = \"abc\") == 0\n assert candidate(word = \"bacbac\") == 6\n assert candidate(word = \"aabbcc\") == 6\n assert candidate(word = \"acbac\") == 4\n assert candidate(word = \"aababacaba\") == 8\n assert candidate(word = \"abcabc\") == 0\n assert candidate(word = \"bbcc\") == 5\n assert candidate(word = \"cccc\") == 8\n assert candidate(word = \"aaaaa\") == 10\n assert candidate(word = \"cab\") == 3\n assert candidate(word = \"bb\") == 4\n assert candidate(word = \"aaa\") == 6\n assert candidate(word = \"b\") == 2\n assert candidate(word = \"ac\") == 1\n assert candidate(word = \"aaabbbccc\") == 12\n assert candidate(word = \"abac\") == 2\n assert candidate(word = \"bbbbbbb\") == 14\n assert candidate(word = \"aabccba\") == 8\n assert candidate(word = \"bbccaa\") == 9\n assert candidate(word = \"cba\") == 6\n assert candidate(word = \"ccbaab\") == 9\n assert candidate(word = \"ccc\") == 6\n assert candidate(word = \"bcab\") == 2\n assert candidate(word = \"ccccab\") == 9\n assert candidate(word = \"aababab\") == 5\n assert candidate(word = \"aaaaaabbbbbc\") == 18\n assert candidate(word = \"cccbbaaa\") == 16\n assert candidate(word = \"cbac\") == 5\n assert candidate(word = \"abcabcabc\") == 0\n assert candidate(word = \"ba\") == 4\n assert candidate(word = \"cccccccc\") == 16\n assert candidate(word = \"abbbccca\") == 10\n assert candidate(word = \"abcbac\") == 3\n assert candidate(word = \"bbbb\") == 8\n assert candidate(word = \"caabbac\") == 8\n assert candidate(word = \"babbabcabcbacbacbacb\") == 16\n assert candidate(word = \"aaaab\") == 7\n assert candidate(word = \"bcaabc\") == 3\n assert candidate(word = \"bbbbbb\") == 12\n assert candidate(word = \"cabababc\") == 4\n assert candidate(word = \"bacbacbac\") == 9\n assert candidate(word = \"bcaacb\") == 6\n assert candidate(word = \"abcababc\") == 1\n assert candidate(word = \"abacbacbac\") == 8\n assert candidate(word = \"bcbcbc\") == 3\n assert candidate(word = \"aaaaaaaa\") == 16\n assert candidate(word = \"bbbaccc\") == 11\n assert candidate(word = \"babcbcbcabc\") == 4\n assert candidate(word = \"bcbcb\") == 4\n assert candidate(word = \"aacaabbc\") == 7\n assert candidate(word = \"abacbac\") == 5\n assert candidate(word = \"aaaaaa\") == 12\n assert candidate(word = \"acb\") == 3\n assert candidate(word = \"ababab\") == 3\n assert candidate(word = \"cabcabc\") == 2\n assert candidate(word = \"aabbccabc\") == 6\n assert candidate(word = \"abab\") == 2\n assert candidate(word = \"abacab\") == 3\n assert candidate(word = \"bcabc\") == 1\n assert candidate(word = \"accba\") == 7\n assert candidate(word = \"aabacbac\") == 7\n assert candidate(word = \"bababab\") == 5\n assert candidate(word = \"bbbbbbbb\") == 16\n assert candidate(word = \"acbabc\") == 3\n assert candidate(word = \"aabcbc\") == 3\n assert candidate(word = \"abcaabcbacbacb\") == 10\n assert candidate(word = \"aabcbabccba\") == 10\n assert candidate(word = \"abccccba\") == 10\n assert candidate(word = \"baabbcc\") == 8\n assert candidate(word = \"cabcab\") == 3\n assert candidate(word = \"cbacba\") == 9\n assert candidate(word = \"bac\") == 3\n assert candidate(word = \"aaaa\") == 8\n assert candidate(word = \"abcbbca\") == 5\n assert candidate(word = \"bca\") == 3\n assert candidate(word = \"ababac\") == 3\n assert candidate(word = \"cbacbacb\") == 10\n assert candidate(word = \"abccba\") == 6\n assert candidate(word = \"cabcabcab\") == 3\n assert candidate(word = \"abcabcabcabcabc\") == 0\n assert candidate(word = \"bbbacabc\") == 7\n assert candidate(word = \"acbacbac\") == 7\n assert candidate(word = \"aaac\") == 5\n assert candidate(word = \"bbaaac\") == 9\n assert candidate(word = \"abcacbac\") == 4\n assert candidate(word = \"abacbc\") == 3\n assert candidate(word = \"ccca\") == 8\n assert candidate(word = \"cccccc\") == 12\n assert candidate(word = \"aabbaacc\") == 10\n assert candidate(word = \"acbacbacbac\") == 10\n assert candidate(word = \"abcba\") == 4\n assert candidate(word = \"acbacbacb\") == 9\n assert candidate(word = \"ccccbbbaaa\") == 20\n assert candidate(word = \"acabca\") == 3\n assert candidate(word = \"abbbcccaa\") == 12\n assert candidate(word = \"aabbbccc\") == 10\n assert candidate(word = \"abcabcbac\") == 3\n assert candidate(word = \"abcabca\") == 2\n assert candidate(word = \"ccababca\") == 7\n assert candidate(word = \"bababacbcabc\") == 6\n assert candidate(word = \"accab\") == 4\n assert candidate(word = \"abbbac\") == 6\n assert candidate(word = \"acbbca\") == 6\n assert candidate(word = \"bcabca\") == 3\n assert candidate(word = \"bcbcbcbc\") == 4\n assert candidate(word = \"aabcbcbc\") == 4\n assert candidate(word = \"abcabcabcabc\") == 0\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().addMinimum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int addMinimum(String word) {", "container": "Solution", "callable": "addMinimum", "parameters": [{"name": "word", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2646, "task_id": "minimize-the-total-price-of-the-trips", "difficulty": "Hard", "problem_description": "There exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1. You are given the integer n and 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.\nEach node has an associated price. You are given an integer array price, where price[i] is the price of the ith node.\nThe price sum of a given path is the sum of the prices of all nodes lying on that path.\nAdditionally, you are given a 2D integer array trips, where trips[i] = [starti, endi] indicates that you start the ith trip from the node starti and travel to the node endi by any path you like.\nBefore performing your first trip, you can choose some non-adjacent nodes and halve the prices.\nReturn the minimum total price sum to perform all the given trips.\n \nExample 1:\n\n\nInput: n = 4, edges = [[0,1],[1,2],[1,3]], price = [2,2,10,6], trips = [[0,3],[2,1],[2,3]]\nOutput: 23\nExplanation: The diagram above denotes the tree after rooting it at node 2. The first part shows the initial tree and the second part shows the tree after choosing nodes 0, 2, and 3, and making their price half.\nFor the 1st trip, we choose path [0,1,3]. The price sum of that path is 1 + 2 + 3 = 6.\nFor the 2nd trip, we choose path [2,1]. The price sum of that path is 2 + 5 = 7.\nFor the 3rd trip, we choose path [2,1,3]. The price sum of that path is 5 + 2 + 3 = 10.\nThe total price sum of all trips is 6 + 7 + 10 = 23.\nIt can be proven, that 23 is the minimum answer that we can achieve.\n\nExample 2:\n\n\nInput: n = 2, edges = [[0,1]], price = [2,2], trips = [[0,0]]\nOutput: 1\nExplanation: The diagram above denotes the tree after rooting it at node 0. The first part shows the initial tree and the second part shows the tree after choosing node 0, and making its price half.\nFor the 1st trip, we choose path [0]. The price sum of that path is 1.\nThe total price sum of all trips is 1. It can be proven, that 1 is the minimum answer that we can achieve.\n\n \nConstraints:\n\n1 <= n <= 50\nedges.length == n - 1\n0 <= ai, bi <= n - 1\nedges represents a valid tree.\nprice.length == n\nprice[i] is an even integer.\n1 <= price[i] <= 1000\n1 <= trips.length <= 100\n0 <= starti, endi <= n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,edges = [[0, 1], [1, 2]],price = [10, 10, 10],trips = [[0, 2], [0, 1], [1, 2]]) == 50\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [1, 3], [3, 4]],price = [2, 4, 6, 8, 10],trips = [[0, 4], [1, 2]]) == 25\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],price = [2, 4, 6, 8, 10, 12],trips = [[0, 3], [1, 5], [2, 4]]) == 42\n assert candidate(n = 3,edges = [[0, 1], [1, 2]],price = [6, 4, 2],trips = [[0, 2], [1, 1], [2, 0]]) == 20\n assert candidate(n = 3,edges = [[0, 1], [1, 2]],price = [6, 8, 10],trips = [[0, 1], [1, 2], [0, 2]]) == 40\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [1, 3]],price = [2, 2, 10, 6],trips = [[0, 3], [2, 1], [2, 3]]) == 23\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]],price = [2, 4, 6, 8, 10],trips = [[0, 3], [2, 4], [3, 4]]) == 37\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],price = [2, 4, 6, 8, 10, 12],trips = [[0, 5], [1, 3], [2, 4], [3, 4]]) == 50\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [1, 3], [3, 4]],price = [10, 20, 30, 40, 50],trips = [[0, 2], [1, 4], [2, 3]]) == 185\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]],price = [4, 2, 10, 3, 5],trips = [[0, 4], [1, 3], [2, 0]]) == 20\n assert candidate(n = 3,edges = [[0, 1], [1, 2]],price = [4, 6, 8],trips = [[0, 2], [1, 1]]) == 18\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]],price = [2, 4, 6, 8, 10],trips = [[0, 2], [1, 3], [2, 4]]) == 39\n assert candidate(n = 2,edges = [[0, 1]],price = [2, 2],trips = [[0, 0]]) == 1\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]],price = [4, 2, 8, 6, 3],trips = [[0, 3], [0, 4], [2, 3], [2, 4]]) == 41\n assert candidate(n = 3,edges = [[0, 1], [1, 2]],price = [4, 6, 8],trips = [[0, 2], [1, 2], [0, 1]]) == 30\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [1, 3], [3, 4]],price = [4, 2, 3, 6, 5],trips = [[0, 1], [1, 4], [2, 4]]) == 25\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5]],price = [8, 4, 2, 6, 3, 1],trips = [[0, 5], [2, 4], [1, 3]]) == 30\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],price = [1, 2, 3, 4, 5, 6, 7, 8, 9],trips = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 0]]) == 43\n assert candidate(n = 15,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]],price = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],trips = [[0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [1, 4], [2, 5], [10, 14]]) == 13750\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],price = [2, 6, 4, 10, 8, 12, 14],trips = [[0, 3], [1, 6], [2, 4], [4, 6], [5, 1]]) == 84\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],price = [100, 200, 300, 400, 500, 600, 700],trips = [[0, 3], [1, 6], [2, 4], [3, 5], [4, 6]]) == 4350\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trips = [[0, 9], [1, 5], [2, 8], [3, 7], [4, 6]]) == 595\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trips = [[0, 5], [1, 8], [2, 9], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2], [8, 3], [9, 4]]) == 1050\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],price = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],trips = [[0, 7], [1, 8], [2, 9], [3, 4], [4, 5], [5, 6], [6, 0], [7, 1], [8, 2], [9, 3]]) == 214\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7]],price = [5, 15, 25, 35, 45, 55, 65, 75],trips = [[0, 4], [1, 5], [2, 6], [3, 7], [0, 7], [1, 6], [2, 5]]) == 586\n assert candidate(n = 20,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]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],trips = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 2525\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],price = [200, 100, 50, 25, 125, 75, 150],trips = [[0, 6], [1, 5], [2, 3]]) == 774\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]],price = [5, 10, 15, 20, 25, 30, 35, 40],trips = [[0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0], [0, 4], [1, 5], [2, 6], [3, 7], [4, 0], [5, 1], [6, 2], [7, 3]]) == 620\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],price = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],trips = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == 240\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],price = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],trips = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 246\n assert candidate(n = 15,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]],price = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300],trips = [[0, 13], [1, 12], [2, 10], [3, 9]]) == 1230\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [6, 11], [7, 12], [7, 13], [8, 14]],price = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],trips = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10]]) == 860\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],price = [2, 4, 6, 8, 10, 12, 14, 16],trips = [[0, 4], [1, 6], [2, 5], [3, 7], [0, 7], [1, 5], [2, 6]]) == 117\n assert candidate(n = 15,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]],price = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],trips = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == 242\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],price = [10, 20, 30, 40, 50, 60],trips = [[0, 3], [1, 5], [2, 4], [3, 4], [5, 0]]) == 340\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],price = [10, 20, 30, 40, 50, 60, 70],trips = [[0, 6], [1, 4], [2, 3], [3, 5]]) == 295\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7]],price = [8, 16, 24, 32, 40, 48, 56, 64],trips = [[0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0]]) == 576\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],price = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],trips = [[0, 7], [1, 8], [2, 9], [3, 4], [4, 5], [5, 6], [6, 0], [7, 1], [8, 2], [9, 3], [10, 11], [11, 0]]) == 316\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],price = [8, 16, 24, 32, 40, 48, 56, 64, 72],trips = [[0, 8], [1, 7], [2, 6], [3, 5]]) == 720\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],price = [100, 200, 300, 400, 500, 600, 700, 800, 900],trips = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0], [0, 7], [1, 8], [2, 5], [3, 6], [4, 3], [5, 4], [6, 1], [7, 2], [8, 3]]) == 36100\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],price = [6, 2, 4, 10, 8, 12],trips = [[0, 3], [1, 5], [2, 4], [3, 0], [4, 5], [5, 1]]) == 82\n assert candidate(n = 15,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]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],trips = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14]]) == 2290\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],price = [100, 200, 150, 50, 120, 70],trips = [[0, 5], [3, 4], [0, 2]]) == 690\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],price = [2, 4, 6, 8, 10, 12],trips = [[0, 3], [1, 5], [2, 4], [3, 0], [4, 1], [5, 2], [0, 2], [1, 4], [2, 0]]) == 95\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],price = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],trips = [[0, 11], [1, 9], [2, 7], [3, 6]]) == 257\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7], [3, 8], [3, 9]],price = [10, 12, 15, 20, 22, 25, 30, 35, 40, 45],trips = [[0, 4], [1, 7], [2, 8], [3, 9], [5, 6]]) == 243\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],price = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],trips = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 0]]) == 15300\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],price = [500, 400, 300, 200, 100, 50],trips = [[0, 5], [1, 4], [2, 3], [3, 1], [4, 0], [5, 2], [0, 2], [1, 3]]) == 4500\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],price = [10, 20, 30, 40, 50, 60, 70],trips = [[0, 3], [1, 5], [2, 6], [3, 1], [4, 0], [5, 2], [6, 4]]) == 460\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],price = [5, 10, 15, 20, 25, 30, 35],trips = [[0, 3], [1, 6], [2, 4], [3, 5], [4, 6], [5, 0]]) == 250\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trips = [[0, 9], [3, 5], [2, 7]]) == 370\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trips = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 1230\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6]],price = [200, 400, 600, 800, 1000, 1200, 1400],trips = [[0, 6], [1, 5], [2, 4], [3, 3], [0, 3]]) == 8000\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],price = [2, 4, 6, 8, 10, 12, 14, 16],trips = [[0, 4], [1, 7], [2, 6], [3, 5], [4, 7], [5, 0], [6, 1], [7, 2]]) == 164\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],trips = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 0]]) == 153\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],price = [5, 10, 15, 20, 25, 30, 35, 40],trips = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 4], [1, 5], [2, 6], [3, 7]]) == 670\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11]],price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],trips = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 810\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],price = [2, 4, 6, 8, 10, 12, 14, 16],trips = [[0, 7], [1, 6], [2, 5], [3, 4]]) == 134\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],price = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34],trips = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7]]) == 254\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],price = [2, 4, 6, 8, 10, 12],trips = [[0, 3], [1, 5], [2, 4], [3, 0]]) == 51\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11]],price = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],trips = [[0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [0, 8], [1, 9], [2, 10], [3, 11]]) == 642\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]],price = [100, 200, 300, 400, 500, 600, 700, 800],trips = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 2]]) == 3750\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],price = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],trips = [[0, 7], [1, 8], [2, 9], [3, 4], [5, 6]]) == 279\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [5, 7]],price = [2, 4, 6, 8, 10, 12, 14, 16],trips = [[0, 7], [2, 6], [1, 5], [4, 3], [0, 3]]) == 100\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],price = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],trips = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]]) == 289\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "price", "trips"], "leetcode_dataset_entry_point": "Solution().minimumTotalPrice", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumTotalPrice(int n, int[][] edges, int[] price, int[][] trips) {", "container": "Solution", "callable": "minimumTotalPrice", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}, {"name": "price", "type": "int[]"}, {"name": "trips", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2651, "task_id": "calculate-delayed-arrival-time", "difficulty": "Easy", "problem_description": "You are given a positive integer arrivalTime denoting the arrival time of a train in hours, and another positive integer delayedTime denoting the amount of delay in hours.\nReturn the time when the train will arrive at the station.\nNote that the time in this problem is in 24-hours format.\n \nExample 1:\n\nInput: arrivalTime = 15, delayedTime = 5 \nOutput: 20 \nExplanation: Arrival time of the train was 15:00 hours. It is delayed by 5 hours. Now it will reach at 15+5 = 20 (20:00 hours).\n\nExample 2:\n\nInput: arrivalTime = 13, delayedTime = 11\nOutput: 0\nExplanation: Arrival time of the train was 13:00 hours. It is delayed by 11 hours. Now it will reach at 13+11=24 (Which is denoted by 00:00 in 24 hours format so return 0).\n\n \nConstraints:\n\n1 <= arrivaltime < 24\n1 <= delayedTime <= 24\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arrivalTime = 5,delayedTime = 19) == 0\n assert candidate(arrivalTime = 8,delayedTime = 16) == 0\n assert candidate(arrivalTime = 13,delayedTime = 11) == 0\n assert candidate(arrivalTime = 15,delayedTime = 5) == 20\n assert candidate(arrivalTime = 1,delayedTime = 1) == 2\n assert candidate(arrivalTime = 12,delayedTime = 12) == 0\n assert candidate(arrivalTime = 1,delayedTime = 23) == 0\n assert candidate(arrivalTime = 0,delayedTime = 24) == 0\n assert candidate(arrivalTime = 23,delayedTime = 2) == 1\n assert candidate(arrivalTime = 5,delayedTime = 20) == 1\n assert candidate(arrivalTime = 19,delayedTime = 5) == 0\n assert candidate(arrivalTime = 18,delayedTime = 6) == 0\n assert candidate(arrivalTime = 2,delayedTime = 22) == 0\n assert candidate(arrivalTime = 20,delayedTime = 4) == 0\n assert candidate(arrivalTime = 3,delayedTime = 21) == 0\n assert candidate(arrivalTime = 20,delayedTime = 5) == 1\n assert candidate(arrivalTime = 6,delayedTime = 18) == 0\n assert candidate(arrivalTime = 9,delayedTime = 15) == 0\n assert candidate(arrivalTime = 17,delayedTime = 8) == 1\n assert candidate(arrivalTime = 7,delayedTime = 17) == 0\n assert candidate(arrivalTime = 20,delayedTime = 8) == 4\n assert candidate(arrivalTime = 7,delayedTime = 18) == 1\n assert candidate(arrivalTime = 18,delayedTime = 7) == 1\n assert candidate(arrivalTime = 15,delayedTime = 9) == 0\n assert candidate(arrivalTime = 10,delayedTime = 14) == 0\n assert candidate(arrivalTime = 19,delayedTime = 6) == 1\n assert candidate(arrivalTime = 20,delayedTime = 6) == 2\n assert candidate(arrivalTime = 16,delayedTime = 8) == 0\n assert candidate(arrivalTime = 11,delayedTime = 14) == 1\n assert candidate(arrivalTime = 17,delayedTime = 7) == 0\n assert candidate(arrivalTime = 14,delayedTime = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["arrivalTime", "delayedTime"], "leetcode_dataset_entry_point": "Solution().findDelayedArrivalTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findDelayedArrivalTime(int arrivalTime, int delayedTime) {", "container": "Solution", "callable": "findDelayedArrivalTime", "parameters": [{"name": "arrivalTime", "type": "int"}, {"name": "delayedTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2652, "task_id": "sum-multiples", "difficulty": "Easy", "problem_description": "Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7.\nReturn an integer denoting the sum of all numbers in the given range satisfying the constraint.\n \nExample 1:\n\nInput: n = 7\nOutput: 21\nExplanation: Numbers in the range [1, 7] that are divisible by 3, 5, or 7 are 3, 5, 6, 7. The sum of these numbers is 21.\n\nExample 2:\n\nInput: n = 10\nOutput: 40\nExplanation: Numbers in the range [1, 10] that are divisible by 3, 5, or 7 are 3, 5, 6, 7, 9, 10. The sum of these numbers is 40.\n\nExample 3:\n\nInput: n = 9\nOutput: 30\nExplanation: Numbers in the range [1, 9] that are divisible by 3, 5, or 7 are 3, 5, 6, 7, 9. The sum of these numbers is 30.\n\n \nConstraints:\n\n1 <= n <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 9) == 30\n assert candidate(n = 1) == 0\n assert candidate(n = 1000) == 272066\n assert candidate(n = 7) == 21\n assert candidate(n = 10) == 40\n assert candidate(n = 210) == 12075\n assert candidate(n = 666) == 121023\n assert candidate(n = 315) == 27090\n assert candidate(n = 100) == 2838\n assert candidate(n = 50) == 691\n assert candidate(n = 300) == 24321\n assert candidate(n = 333) == 30339\n assert candidate(n = 60) == 1024\n assert candidate(n = 30) == 274\n assert candidate(n = 550) == 82614\n assert candidate(n = 103) == 2940\n assert candidate(n = 840) == 191940\n assert candidate(n = 42) == 499\n assert candidate(n = 888) == 213532\n assert candidate(n = 101) == 2838\n assert candidate(n = 250) == 17152\n assert candidate(n = 789) == 169111\n assert candidate(n = 630) == 108045\n assert candidate(n = 999) == 271066\n assert candidate(n = 256) == 17659\n assert candidate(n = 20) == 119\n assert candidate(n = 150) == 6109\n assert candidate(n = 800) == 173877\n assert candidate(n = 15) == 81\n assert candidate(n = 200) == 10845\n assert candidate(n = 512) == 70927\n assert candidate(n = 750) == 153696\n assert candidate(n = 120) == 4071\n assert candidate(n = 499) == 67389\n assert candidate(n = 700) == 133342\n assert candidate(n = 500) == 67889\n assert candidate(n = 420) == 48090\n assert candidate(n = 84) == 1904\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().sumOfMultiples", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int sumOfMultiples(int n) {", "container": "Solution", "callable": "sumOfMultiples", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2653, "task_id": "sliding-subarray-beauty", "difficulty": "Medium", "problem_description": "Given an integer array nums containing n integers, find the beauty of each subarray of size k.\nThe beauty of a subarray is the xth smallest integer in the subarray if it is negative, or 0 if there are fewer than x negative integers.\nReturn an integer array containing n - k + 1 integers, which denote the beauty of the subarrays in order from the first index in the array.\n\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\n\n \nExample 1:\n\nInput: nums = [1,-1,-3,-2,3], k = 3, x = 2\nOutput: [-1,-2,-2]\nExplanation: There are 3 subarrays with size k = 3. \nThe first subarray is [1, -1, -3] and the 2nd smallest negative integer is -1. \nThe second subarray is [-1, -3, -2] and the 2nd smallest negative integer is -2. \nThe third subarray is [-3, -2, 3] and the 2nd smallest negative integer is -2.\nExample 2:\n\nInput: nums = [-1,-2,-3,-4,-5], k = 2, x = 2\nOutput: [-1,-2,-3,-4]\nExplanation: There are 4 subarrays with size k = 2.\nFor [-1, -2], the 2nd smallest negative integer is -1.\nFor [-2, -3], the 2nd smallest negative integer is -2.\nFor [-3, -4], the 2nd smallest negative integer is -3.\nFor [-4, -5], the 2nd smallest negative integer is -4. \nExample 3:\n\nInput: nums = [-3,1,2,-3,0,-3], k = 2, x = 1\nOutput: [-3,0,-3,-3,-3]\nExplanation: There are 5 subarrays with size k = 2.\nFor [-3, 1], the 1st smallest negative integer is -3.\nFor [1, 2], there is no negative integer so the beauty is 0.\nFor [2, -3], the 1st smallest negative integer is -3.\nFor [-3, 0], the 1st smallest negative integer is -3.\nFor [0, -3], the 1st smallest negative integer is -3.\n \nConstraints:\n\nn == nums.length \n1 <= n <= 105\n1 <= k <= n\n1 <= x <= k \n-50 <= nums[i] <= 50 \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 7, 8, 9],k = 3,x = 2) == [0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 2,x = 2) == [-1, -2, -3, -4]\n assert candidate(nums = [1, -1, -3, -2, 3],k = 3,x = 2) == [-1, -2, -2]\n assert candidate(nums = [5, 6, 7, 8, 9],k = 3,x = 1) == [0, 0, 0]\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 4,x = 3) == [-20, -30]\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 3,x = 3) == [-10, -20, -30]\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 4,x = 2) == [-30, -40]\n assert candidate(nums = [5, 4, 3, 2, 1],k = 2,x = 2) == [0, 0, 0, 0]\n assert candidate(nums = [-3, 1, 2, -3, 0, -3],k = 2,x = 1) == [-3, 0, -3, -3, -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 = 8,x = 4) == [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7]\n assert candidate(nums = [-50, -49, -48, -47, -46, -45, -44, -43, -42, -41],k = 5,x = 2) == [-49, -48, -47, -46, -45, -44]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, -4, -5],k = 5,x = 1) == [0, 0, 0, 0, 0, 0, -1, -2, -3, -4, -5]\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 3,x = 1) == [-1, -1, -1, -1, -1, -1, -1, -1]\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 = 4,x = 2) == [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9]\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40],k = 5,x = 2) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5,x = 3) == [0, -1, 0, -2, 0, -3]\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],k = 5,x = 5) == [-5, -10, -15, -20, -25, -30]\n assert candidate(nums = [-5, -10, 5, -15, 20, -25, 0, 30, -35],k = 4,x = 2) == [-10, -10, -15, -15, 0, -25]\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,x = 5) == [-1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 6,x = 2) == [-5, -6, -7, -8, -9, -10, -11, -12, -13, -14]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5,x = 2) == [-1, -2, -2, -3, -3, -4]\n assert candidate(nums = [-10, -20, -30, -40, -50, 50, 40, 30, 20, 10],k = 5,x = 2) == [-40, -40, -40, -40, 0, 0]\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 = 10,x = 5) == [0, 0, 0, 0, 0, -1, -2, -3, -4, -5, -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],k = 10,x = 5) == [-6, -6, -6, -6, -6, -6, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, -50, 49, -49, 48, -48, 47, -47, 46, -46, 45, -45],k = 7,x = 4) == [0, -47, 0, -46, 0, -45]\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,x = 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, -13, 14, -14, 15, -15, 16, -16],k = 6,x = 3) == [-2, -2, -4, -4, -6, -6, -8, -8, -10, -10, -12, -12, -13, -13, -14]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5,x = 2) == [-4, -5, -6, -7, -8, -9]\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 4,x = 3) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-10, -20, -30, -40, -50, 10, 20, 30, 40, 50],k = 4,x = 3) == [-20, -30, -30, 0, 0, 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],k = 10,x = 5) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5],k = 6,x = 4) == [-2, -1, 0, 0, 0]\n assert candidate(nums = [-10, -20, -30, -40, -50, 50, 40, 30, 20, 10],k = 5,x = 3) == [-30, -30, -30, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3,x = 2) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, -1, -2, 0, -3, 0, -4, 0, -5, 0],k = 3,x = 2) == [-1, -1, -2, 0, -3, 0, -4, 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 = 10,x = 5) == [-6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]\n assert candidate(nums = [-1, -2, -3, 4, 5, -6, -7, 8, 9, -10],k = 4,x = 2) == [-2, -2, -3, -6, -6, -6, -7]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 5,x = 3) == [0, -10, 0, -20, 0, -30]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8],k = 6,x = 3) == [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6]\n assert candidate(nums = [-1, 0, 1, -2, 0, 2, -3, 0, 3, -4, 0, 4],k = 3,x = 1) == [-1, -2, -2, -2, -3, -3, -3, -4, -4, -4]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5,x = 2) == [0, 0, 0, 0, 0, 0]\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 = 10,x = 3) == [0, 0, 0, -1, -2, -3, -4, -5, -6, -7, -8]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 6,x = 4) == [0, 0, 0, 0, 0]\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4],k = 4,x = 2) == [-1, -1, -2, -2, -3, -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],k = 6,x = 3) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [50, -10, 40, -20, 30, -30, 20, -40, 10, -50, 0, 5, -5, 15, -15, 25, -25, 35, -35, 45],k = 5,x = 2) == [-10, -20, -20, -30, -30, -40, -40, -40, -5, -5, -5, -5, -15, -15, -25, -25]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 6,x = 1) == [0, 0, 0, 0, 0, 0, -1, -2, -3, -4, -5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4,x = 1) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1],k = 5,x = 2) == [0, 0, -4, -4, -4, -4]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6],k = 7,x = 5) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40],k = 4,x = 2) == [-10, -10, -20, -20, -30]\n assert candidate(nums = [-50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50],k = 5,x = 2) == [-40, -30, -20, -10, 0, 0, 0]\n assert candidate(nums = [10, -5, 3, -1, 7, -8, 2, -6, 4, -9],k = 4,x = 2) == [-1, -1, -1, -1, -6, -6, -6]\n assert candidate(nums = [5, 10, -5, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50],k = 7,x = 4) == [0, -5, -5, -10, 0, -15, 0, -20, 0, -25, 0, -30, 0, -35]\n assert candidate(nums = [-5, 0, 5, -10, 15, -20, 25, -30, 35, -40],k = 4,x = 2) == [-5, 0, -10, -10, -20, -20, -30]\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 5,x = 3) == [-1, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 6,x = 4) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, -50, 49, -49, 48, -48, 47, -47, 46, -46],k = 5,x = 3) == [0, -48, 0, -47, 0, -46]\n assert candidate(nums = [50, -50, 49, -49, 48, -48, 47, -47, 46, -46],k = 7,x = 5) == [0, 0, 0, 0]\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 5,x = 2) == [-1, -2, -2, -3, -3, -4, -4]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2,x = 1) == [0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4,x = 2) == [-2, -3, -4, -5, -6, -7, -8, -9]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5,x = 1) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, -50, 49, -49, 48, -48, 47, -47, 46, -46],k = 6,x = 4) == [0, 0, 0, 0, 0]\n assert candidate(nums = [-50, -40, -30, -20, -10, 0, 10, 20, 30, 40],k = 6,x = 4) == [-20, -10, 0, 0, 0]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50],k = 5,x = 4) == [0, 0, 0, 0, 0, -10, -20]\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 5,x = 3) == [-1, 0, -2, 0, -3, 0]\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15],k = 8,x = 4) == [-1, -3, -3, -5, -5, -7, -7, -9]\n assert candidate(nums = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4,x = 3) == [-1, -2, -3, -4, -5, -6, -7, -8]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 3,x = 2) == [0, -1, 0, -1, 0, -1, 0, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10,x = 5) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1],k = 5,x = 3) == [-1, -1, -1, -1]\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15],k = 6,x = 3) == [-1, -3, -3, -5, -5, -7, -7, -9, -9, -11]\n assert candidate(nums = [5, 10, -5, -10, 15, -15, 20, -20, 25, -25, 30],k = 4,x = 2) == [-5, -5, -10, -10, -15, -15, -20, -20]\n assert candidate(nums = [2, 3, -1, -2, 5, -3, 6, -4, 8, -5, 9, -6, 10, -7, 11, -8, 12, -9, 13, -10],k = 5,x = 3) == [0, -1, -1, -2, 0, -3, 0, -4, 0, -5, 0, -6, 0, -7, 0, -8]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 3,x = 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],k = 7,x = 5) == [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],k = 4,x = 2) == [-1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [-1, 0, 1, -2, 0, 2, -3, 0, 3, -4, 0, 4],k = 5,x = 2) == [-1, 0, -2, -2, 0, -3, -3, 0]\n assert candidate(nums = [-50, 0, 50, -49, 0, 49, -48, 0, 48, -47, 0, 47],k = 5,x = 3) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-50, 0, 50, -49, 49, -48, 48, -47, 47],k = 6,x = 4) == [0, 0, 0, 0]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],k = 5,x = 4) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5,x = 3) == [0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, -4, -5, -6, -7, -8]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 4,x = 2) == [-10, -10, -20, -20, -30, -30, -40]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40],k = 5,x = 4) == [0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7,x = 3) == [0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 4,x = 1) == [0, 0, 0, 0, 0, 0, 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],k = 5,x = 2) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-10, -20, -30, 0, 10, 20, 30, -40, 40, -50, 50],k = 6,x = 3) == [-10, 0, 0, 0, 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],k = 5,x = 3) == [-1, 0, -3, 0, -5, 0, -7, 0, -9, 0, -11, 0, -13, 0, -15, 0]\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4],k = 5,x = 3) == [0, -1, 0, -2, 0]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5,x = 5) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12],k = 8,x = 6) == [0, 0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 5,x = 3) == [-3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13]\n assert candidate(nums = [0, 0, 0, 0, 0, -1, 0, 0, 0, 0],k = 4,x = 1) == [0, 0, -1, -1, -1, -1, 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],k = 5,x = 1) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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],k = 10,x = 3) == [-5, -7, -7, -9, -9, -11, -11, -13, -13, -15, -15]\n assert candidate(nums = [3, -3, 6, -6, 9, -9, 12, -12, 15, -15],k = 7,x = 3) == [-3, -6, -6, -9]\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 5,x = 2) == [-1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, -10, -20, -30, 10, 20, 30, -10, -20, -30],k = 6,x = 3) == [-10, -10, -10, -10, -10, -10, -10]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3,x = 1) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-1, 0, 1, -2, 0, 2, -3, 0, 3, -4],k = 3,x = 1) == [-1, -2, -2, -2, -3, -3, -3, -4]\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],k = 3,x = 2) == [-10, -15, -20, -25, -30, -35, -40, -45]\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0],k = 6,x = 2) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, -2, -3, 1, -4, 5, -6, 7, -8],k = 3,x = 2) == [-2, -2, -3, 0, -4, 0, -6]\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50],k = 5,x = 3) == [-10, 0, -20, 0, -30, 0]\n"}, "metadata": {"canonical_parameter_names": ["nums", "k", "x"], "leetcode_dataset_entry_point": "Solution().getSubarrayBeauty", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] getSubarrayBeauty(int[] nums, int k, int x) {", "container": "Solution", "callable": "getSubarrayBeauty", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}, {"name": "x", "type": "int"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2654, "task_id": "minimum-number-of-operations-to-make-all-array-elements-equal-to-1", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums consisiting of positive integers. You can do the following operation on the array any number of times:\n\nSelect an index i such that 0 <= i < n - 1 and replace either of nums[i] or nums[i+1] with their gcd value.\n\nReturn the minimum number of operations to make all elements of nums equal to 1. If it is impossible, return -1.\nThe gcd of two integers is the greatest common divisor of the two integers.\n \nExample 1:\n\nInput: nums = [2,6,3,4]\nOutput: 4\nExplanation: We can do the following operations:\n- Choose index i = 2 and replace nums[2] with gcd(3,4) = 1. Now we have nums = [2,6,1,4].\n- Choose index i = 1 and replace nums[1] with gcd(6,1) = 1. Now we have nums = [2,1,1,4].\n- Choose index i = 0 and replace nums[0] with gcd(2,1) = 1. Now we have nums = [1,1,1,4].\n- Choose index i = 2 and replace nums[3] with gcd(1,4) = 1. Now we have nums = [1,1,1,1].\n\nExample 2:\n\nInput: nums = [2,10,6,14]\nOutput: -1\nExplanation: It can be shown that it is impossible to make all the elements equal to 1.\n\n \nConstraints:\n\n2 <= nums.length <= 50\n1 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 1]) == 3\n assert candidate(nums = [100, 200, 300, 400]) == -1\n assert candidate(nums = [1, 2, 2, 3]) == 3\n assert candidate(nums = [7, 21, 35, 49, 63]) == -1\n assert candidate(nums = [2, 4, 6, 8, 10, 12]) == -1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21]) == -1\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [10, 15, 25]) == -1\n assert candidate(nums = [2, 4, 6, 8, 10]) == -1\n assert candidate(nums = [3, 6, 9, 12]) == -1\n assert candidate(nums = [2, 6, 3, 4]) == 4\n assert candidate(nums = [2, 10, 6, 14]) == -1\n assert candidate(nums = [5, 15, 25, 35]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50]) == -1\n assert candidate(nums = [15, 9, 3, 6]) == -1\n assert candidate(nums = [5, 5, 5, 5]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [3, 5, 7, 11]) == 4\n assert candidate(nums = [10, 15, 20, 25]) == -1\n assert candidate(nums = [2, 3, 5, 7]) == 4\n assert candidate(nums = [3, 9, 3, 3]) == -1\n assert candidate(nums = [2, 2, 2, 2]) == -1\n assert candidate(nums = [6, 9, 12, 15]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3]) == -1\n assert candidate(nums = [7, 14, 21, 28]) == -1\n assert candidate(nums = [2, 4, 6, 8]) == -1\n assert candidate(nums = [33, 55, 11, 22, 88, 44, 66]) == -1\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330]) == -1\n assert candidate(nums = [48, 64, 80, 96, 112]) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == -1\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == -1\n assert candidate(nums = [100, 150, 200, 250, 300, 350]) == -1\n assert candidate(nums = [17, 34, 51, 68, 85]) == -1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == -1\n assert candidate(nums = [7, 14, 28, 42, 56]) == -1\n assert candidate(nums = [8, 12, 18, 24, 30, 36]) == -1\n assert candidate(nums = [9, 12, 15, 18, 21]) == -1\n assert candidate(nums = [21, 28, 35, 42, 49]) == -1\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 319, 348, 377, 406, 435, 464]) == -1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99]) == -1\n assert candidate(nums = [10, 15, 25, 50]) == -1\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37]) == 7\n assert candidate(nums = [7, 14, 21, 28, 35, 42]) == -1\n assert candidate(nums = [33, 66, 99, 132, 165]) == -1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 15\n assert candidate(nums = [42, 70, 105, 140, 210]) == -1\n assert candidate(nums = [1000, 1500, 2000, 2500]) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == -1\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500]) == -1\n assert candidate(nums = [8, 16, 24, 32, 40, 48]) == -1\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20]) == -1\n assert candidate(nums = [9, 27, 81, 243, 729]) == -1\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210]) == -1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204]) == -1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255]) == -1\n assert candidate(nums = [4, 8, 12, 16, 20, 24]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500]) == -1\n assert candidate(nums = [8, 12, 16, 20, 24, 28]) == -1\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144]) == -1\n assert candidate(nums = [3, 6, 9, 12, 15, 18]) == -1\n assert candidate(nums = [15, 25, 35, 5]) == -1\n assert candidate(nums = [3, 5, 7, 9, 11]) == 5\n assert candidate(nums = [18, 27, 36, 45, 54]) == -1\n assert candidate(nums = [14, 21, 28, 35, 42]) == -1\n assert candidate(nums = [7, 14, 21, 28, 35]) == -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 = [12, 15, 18, 21, 24]) == -1\n assert candidate(nums = [103, 206, 309, 412, 515, 618, 721, 824, 927, 1030, 1133, 1236, 1339, 1442, 1545, 1648, 1751, 1854, 1957, 2060, 2163, 2266, 2369]) == -1\n assert candidate(nums = [6, 18, 30, 42, 54, 66, 78]) == -1\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 10\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77]) == -1\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40]) == -1\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65]) == -1\n assert candidate(nums = [45, 90, 135, 180, 225, 270]) == -1\n assert candidate(nums = [5, 10, 20, 40, 80, 160]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500]) == -1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77]) == -1\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64]) == -1\n assert candidate(nums = [18, 24, 30, 36, 42]) == -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 = [21, 42, 7, 14, 28, 35]) == -1\n assert candidate(nums = [15, 25, 35, 45]) == -1\n assert candidate(nums = [13, 26, 39, 52, 65]) == -1\n assert candidate(nums = [17, 51, 85, 102, 136]) == -1\n assert candidate(nums = [109, 218, 327, 436, 545, 654, 763, 872, 981, 1090, 1199, 1308, 1417, 1526, 1635, 1744, 1853, 1962, 2071, 2180, 2289, 2398, 2507, 2616, 2725, 2834, 2943]) == -1\n assert candidate(nums = [3, 9, 27, 81, 243, 729]) == -1\n assert candidate(nums = [21, 35, 49, 63, 77, 91, 105]) == -1\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230]) == -1\n assert candidate(nums = [3, 9, 27, 81]) == -1\n assert candidate(nums = [97, 194, 291, 388, 485, 582]) == -1\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == -1\n assert candidate(nums = [3, 9, 27, 81, 243]) == -1\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 10\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130]) == -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, 483, 506]) == -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]) == 29\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890]) == 5\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128]) == -1\n assert candidate(nums = [107, 214, 321, 428, 535, 642, 749, 856, 963, 1070, 1177, 1284, 1391, 1498, 1605, 1712, 1819, 1926, 2033, 2140, 2247, 2354, 2461, 2568, 2675]) == -1\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 319, 348, 377, 406, 435, 464, 493, 522, 551, 580, 609, 638, 667, 696, 725]) == -1\n assert candidate(nums = [15, 20, 25, 30]) == -1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170]) == -1\n assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144]) == -1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21]) == -1\n assert candidate(nums = [7, 49, 91, 35, 119, 56]) == -1\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == -1\n assert candidate(nums = [49, 98, 147, 196, 245, 294]) == -1\n assert candidate(nums = [61, 122, 183, 244, 305, 366, 427, 488, 549, 610, 671, 732, 793, 854, 915, 976]) == -1\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 253, 276, 299, 322]) == -1\n assert candidate(nums = [15, 9, 21, 6, 12]) == -1\n assert candidate(nums = [12, 18, 24, 30, 36]) == -1\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96]) == -1\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31]) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 10\n assert candidate(nums = [15, 25, 35, 45, 55]) == -1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143]) == -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, 1, 1]) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128]) == -1\n assert candidate(nums = [7, 14, 21, 35, 42]) == -1\n assert candidate(nums = [8, 12, 16, 20, 24, 28, 32, 36, 40]) == -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 = [42, 56, 70, 84, 98]) == -1\n assert candidate(nums = [41, 82, 123, 164, 205, 246, 287, 328, 369, 410, 451, 492, 533, 574, 615, 656, 697, 738, 779, 820]) == -1\n assert candidate(nums = [6, 18, 30, 42, 54, 66, 78, 90]) == -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\n assert candidate(nums = [21, 42, 63, 84, 105]) == -1\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111]) == -1\n assert candidate(nums = [15, 25, 35, 45, 55]) == -1\n assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == -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 = [1023, 2046, 3069, 4092, 5115, 6138, 7161, 8184, 9207, 10230]) == -1\n assert candidate(nums = [3, 5, 7, 11, 13]) == 5\n assert candidate(nums = [49, 98, 147, 196, 245, 294, 343]) == -1\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247]) == -1\n assert candidate(nums = [4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256]) == 15\n assert candidate(nums = [100, 150, 200, 250, 300]) == -1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255]) == -1\n assert candidate(nums = [35, 55, 77, 99, 121, 143, 165]) == 8\n assert candidate(nums = [15, 25, 35, 5, 10]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == -1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49]) == -1\n assert candidate(nums = [24, 36, 48, 60, 72, 84, 96, 108, 120, 132]) == -1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 10\n assert candidate(nums = [8, 16, 32, 64, 128]) == -1\n assert candidate(nums = [7, 14, 21, 28, 35]) == -1\n assert candidate(nums = [11, 22, 33, 44, 55, 66]) == -1\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42]) == -1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == -1\n assert candidate(nums = [997, 1994, 2991, 3988, 4985, 5982, 6979, 7976, 8973, 9970]) == -1\n assert candidate(nums = [3, 5, 9, 15, 21]) == 5\n assert candidate(nums = [100, 101, 102, 103, 104]) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minOperations(int[] nums) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2656, "task_id": "maximum-sum-with-exactly-k-elements", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums and an integer k. Your task is to perform the following operation exactly k times in order to maximize your score:\n\nSelect an element m from nums.\nRemove the selected element m from the array.\nAdd a new element with a value of m + 1 to the array.\nIncrease your score by m.\n\nReturn the maximum score you can achieve after performing the operation exactly k times.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5], k = 3\nOutput: 18\nExplanation: We need to choose exactly 3 elements from nums to maximize the sum.\nFor the first iteration, we choose 5. Then sum is 5 and nums = [1,2,3,4,6]\nFor the second iteration, we choose 6. Then sum is 5 + 6 and nums = [1,2,3,4,7]\nFor the third iteration, we choose 7. Then sum is 5 + 6 + 7 = 18 and nums = [1,2,3,4,8]\nSo, we will return 18.\nIt can be proven, that 18 is the maximum answer that we can achieve.\n\nExample 2:\n\nInput: nums = [5,5,5], k = 2\nOutput: 11\nExplanation: We need to choose exactly 2 elements from nums to maximize the sum.\nFor the first iteration, we choose 5. Then sum is 5 and nums = [5,5,6]\nFor the second iteration, we choose 6. Then sum is 5 + 6 = 11 and nums = [5,5,7]\nSo, we will return 11.\nIt can be proven, that 11 is the maximum answer that we can achieve.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n1 <= k <= 100\n\n \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 18\n assert candidate(nums = [5, 5, 5],k = 2) == 11\n assert candidate(nums = [1, 1, 1, 1],k = 4) == 10\n assert candidate(nums = [10, 20, 30],k = 1) == 30\n assert candidate(nums = [100],k = 1) == 100\n assert candidate(nums = [1, 1, 1, 1, 1],k = 10) == 55\n assert candidate(nums = [100],k = 100) == 14950\n assert candidate(nums = [10, 20, 30],k = 4) == 126\n assert candidate(nums = [1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [1, 1, 1, 1],k = 5) == 15\n assert candidate(nums = [100, 100, 100, 100],k = 100) == 14950\n assert candidate(nums = [10, 20, 30],k = 5) == 160\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96],k = 60) == 7530\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],k = 50) == 6225\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42],k = 7) == 315\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 15) == 165\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50],k = 10) == 545\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 15) == 390\n assert candidate(nums = [1],k = 100) == 5050\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) == 1035\n assert candidate(nums = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140],k = 5) == 710\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 20) == 290\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 100) == 6950\n assert candidate(nums = [1, 3, 5, 7, 9],k = 7) == 84\n assert candidate(nums = [25, 50, 75, 100],k = 15) == 1605\n assert candidate(nums = [1, 3, 5, 7, 9],k = 7) == 84\n assert candidate(nums = [50, 40, 30, 20, 10],k = 30) == 1935\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 405\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 50) == 3725\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 16) == 760\n assert candidate(nums = [99, 98, 97, 96, 95],k = 10) == 1035\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],k = 50) == 1575\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 = 75) == 10275\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 145\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 1045\n assert candidate(nums = [55, 55, 55, 55, 55, 55, 55, 55, 55, 55],k = 100) == 10450\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 15) == 180\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 30) == 1035\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 91\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 6225\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 210\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 12) == 306\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100) == 14950\n assert candidate(nums = [50],k = 100) == 9950\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 50) == 6125\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 50) == 6475\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 20) == 590\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 100) == 5750\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 245\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 40) == 1980\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 50) == 6225\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 75) == 6525\n assert candidate(nums = [99, 98, 97, 96, 95],k = 20) == 2170\n assert candidate(nums = [1, 3, 5, 7, 9, 11],k = 10) == 155\n assert candidate(nums = [50, 51, 52, 53, 54],k = 8) == 460\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 25) == 550\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 = 20) == 210\n assert candidate(nums = [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],k = 11) == 1155\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 75) == 4200\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],k = 50) == 1275\n assert candidate(nums = [1, 3, 5, 7, 9],k = 10) == 135\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],k = 100) == 14950\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 2190\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == 460\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 100) == 19950\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500],k = 25) == 12800\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 15) == 1605\n assert candidate(nums = [42],k = 100) == 9150\n assert candidate(nums = [10, 20, 30, 40, 50, 60],k = 10) == 645\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 15) == 1590\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 50) == 1325\n assert candidate(nums = [1, 2, 3, 4, 5],k = 100) == 5450\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],k = 30) == 1545\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 = 100) == 14850\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) == 2225\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30],k = 9) == 306\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1) == 100\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 25) == 325\n assert candidate(nums = [91, 92, 93, 94, 95, 96, 97, 98, 99, 100],k = 75) == 10275\n assert candidate(nums = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99],k = 100) == 14850\n assert candidate(nums = [80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99],k = 75) == 10200\n assert candidate(nums = [50, 40, 30, 20, 10],k = 15) == 855\n assert candidate(nums = [2, 4, 6, 8, 10, 12],k = 15) == 285\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 1725\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) == 590\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],k = 100) == 7450\n assert candidate(nums = [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],k = 20) == 2190\n assert candidate(nums = [1, 3, 5, 7, 9],k = 5) == 55\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50],k = 7) == 371\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 25) == 2800\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 30) == 3405\n assert candidate(nums = [99, 98, 97, 96, 95],k = 25) == 2775\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) == 1605\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 25) == 2800\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 145\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 50) == 3725\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximizeSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximizeSum(int[] nums, int k) {", "container": "Solution", "callable": "maximizeSum", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2657, "task_id": "find-the-prefix-common-array-of-two-arrays", "difficulty": "Medium", "problem_description": "You are given two 0-indexed integer permutations A and B of length n.\nA prefix common array of A and B is an array C such that C[i] is equal to the count of numbers that are present at or before the index i in both A and B.\nReturn the prefix common array of A and B.\nA sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.\n \nExample 1:\n\nInput: A = [1,3,2,4], B = [3,1,2,4]\nOutput: [0,2,3,4]\nExplanation: At i = 0: no number is common, so C[0] = 0.\nAt i = 1: 1 and 3 are common in A and B, so C[1] = 2.\nAt i = 2: 1, 2, and 3 are common in A and B, so C[2] = 3.\nAt i = 3: 1, 2, 3, and 4 are common in A and B, so C[3] = 4.\n\nExample 2:\n\nInput: A = [2,3,1], B = [3,1,2]\nOutput: [0,1,3]\nExplanation: At i = 0: no number is common, so C[0] = 0.\nAt i = 1: only 3 is common in A and B, so C[1] = 1.\nAt i = 2: 1, 2, and 3 are common in A and B, so C[2] = 3.\n\n \nConstraints:\n\n1 <= A.length == B.length == n <= 50\n1 <= A[i], B[i] <= n\nIt is guaranteed that A and B are both a permutation of n integers.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(A = [1, 3, 2, 4],B = [3, 1, 2, 4]) == [0, 2, 3, 4]\n assert candidate(A = [1, 2, 3],B = [3, 2, 1]) == [0, 1, 3]\n assert candidate(A = [2, 3, 1],B = [3, 1, 2]) == [0, 1, 3]\n assert candidate(A = [5, 4, 3, 2, 1],B = [1, 2, 3, 4, 5]) == [0, 0, 1, 3, 5]\n assert candidate(A = [1, 2, 3, 4, 5],B = [5, 4, 3, 2, 1]) == [0, 0, 1, 3, 5]\n assert candidate(A = [4, 1, 3, 2],B = [2, 3, 4, 1]) == [0, 0, 2, 4]\n assert candidate(A = [4, 3, 2, 1],B = [1, 4, 2, 3]) == [0, 1, 2, 4]\n assert candidate(A = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2],B = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 2, 2, 2, 2, 2, 4, 6, 8, 10]\n assert candidate(A = [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, 29, 28, 27, 26],B = [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]) == [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, 22, 24, 26, 28, 30]\n assert candidate(A = [3, 1, 2],B = [2, 3, 1]) == [0, 1, 3]\n assert candidate(A = [1, 5, 9, 13, 17, 21, 2, 6, 10, 14, 18, 22, 3, 7, 11, 15, 19, 23, 4, 8, 12, 16, 20, 24],B = [24, 20, 16, 12, 8, 4, 23, 19, 15, 11, 7, 3, 22, 18, 14, 10, 6, 2, 21, 17, 13, 9, 5, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]\n assert candidate(A = [9, 8, 7, 6, 5, 4, 3, 2, 1],B = [2, 4, 6, 8, 1, 3, 5, 7, 9]) == [0, 0, 0, 2, 2, 3, 5, 7, 9]\n assert candidate(A = [2, 5, 4, 1, 3],B = [3, 5, 4, 1, 2]) == [0, 1, 2, 3, 5]\n assert candidate(A = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],B = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0, 2, 4, 6, 8, 10]\n assert candidate(A = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],B = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(A = [7, 6, 5, 4, 3, 2, 1],B = [1, 2, 3, 4, 5, 6, 7]) == [0, 0, 0, 1, 3, 5, 7]\n assert candidate(A = [5, 2, 9, 1, 7, 6, 8, 4, 3],B = [3, 4, 8, 6, 7, 1, 9, 2, 5]) == [0, 0, 0, 0, 1, 3, 5, 7, 9]\n assert candidate(A = [2, 1, 3, 4, 5],B = [3, 5, 1, 2, 4]) == [0, 0, 2, 3, 5]\n assert candidate(A = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],B = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 0, 0, 0, 2, 4, 6, 8, 10]\n assert candidate(A = [15, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 14],B = [14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15]) == [0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(A = [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],B = [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]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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(A = [3, 1, 4, 2],B = [4, 2, 3, 1]) == [0, 0, 2, 4]\n assert candidate(A = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],B = [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [0, 0, 0, 0, 0, 2, 4, 6, 8, 10]\n assert candidate(A = [5, 1, 2, 4, 3],B = [3, 2, 1, 5, 4]) == [0, 0, 2, 3, 5]\n assert candidate(A = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],B = [9, 10, 7, 8, 5, 6, 3, 4, 1, 2]) == [0, 0, 0, 0, 0, 2, 4, 6, 8, 10]\n assert candidate(A = [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],B = [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]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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(A = [2, 3, 5, 4, 1],B = [1, 5, 2, 3, 4]) == [0, 0, 2, 3, 5]\n assert candidate(A = [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],B = [10, 20, 30, 1, 11, 21, 2, 12, 22, 3, 13, 23, 4, 14, 24, 5, 15, 25, 6, 16, 26, 7, 17, 27, 8, 18, 28, 9, 19, 29]) == [0, 0, 0, 1, 1, 1, 2, 2, 2, 4, 5, 6, 8, 9, 9, 10, 11, 11, 12, 14, 15, 17, 19, 20, 22, 24, 25, 27, 28, 30]\n assert candidate(A = [7, 5, 3, 1, 2, 4, 6],B = [6, 4, 2, 1, 3, 5, 7]) == [0, 0, 0, 1, 3, 5, 7]\n assert candidate(A = [3, 6, 5, 1, 8, 2, 9, 4, 7],B = [7, 4, 9, 2, 1, 8, 5, 6, 3]) == [0, 0, 0, 0, 1, 3, 5, 7, 9]\n assert candidate(A = [4, 1, 7, 2, 3, 6, 5],B = [5, 6, 3, 2, 1, 4, 7]) == [0, 0, 0, 1, 3, 5, 7]\n assert candidate(A = [2, 1, 4, 3],B = [3, 4, 1, 2]) == [0, 0, 2, 4]\n assert candidate(A = [7, 5, 3, 1, 9, 6, 4, 8, 2],B = [9, 6, 4, 8, 7, 5, 3, 1, 2]) == [0, 0, 0, 0, 2, 4, 6, 8, 9]\n assert candidate(A = [15, 10, 5, 1, 6, 11, 16, 2, 7, 12, 17, 3, 8, 13, 18, 4, 9, 14, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],B = [25, 20, 15, 10, 5, 1, 6, 11, 16, 2, 7, 12, 17, 3, 8, 13, 18, 4, 9, 14, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30]) == [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30]\n assert candidate(A = [13, 1, 8, 6, 5, 12, 9, 3, 7, 4, 10, 11, 2],B = [2, 11, 10, 4, 7, 3, 9, 12, 5, 6, 8, 1, 13]) == [0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13]\n assert candidate(A = [5, 1, 4, 3, 2],B = [2, 1, 5, 4, 3]) == [0, 1, 2, 3, 5]\n assert candidate(A = [3, 1, 5, 4, 2],B = [2, 4, 1, 5, 3]) == [0, 0, 1, 3, 5]\n assert candidate(A = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],B = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 0, 0, 1, 2, 4, 6, 8, 10]\n assert candidate(A = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],B = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [0, 0, 0, 0, 0, 2, 4, 6, 8, 10]\n assert candidate(A = [5, 3, 8, 6, 2, 7, 4, 1],B = [1, 4, 7, 2, 6, 8, 3, 5]) == [0, 0, 0, 0, 2, 4, 6, 8]\n assert candidate(A = [7, 5, 9, 1, 3, 6, 8, 4, 2, 10],B = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == [0, 0, 0, 0, 0, 2, 4, 6, 8, 10]\n assert candidate(A = [1, 2, 3, 5, 4],B = [5, 4, 1, 2, 3]) == [0, 0, 1, 3, 5]\n assert candidate(A = [25, 15, 5, 1, 10, 20, 30, 2, 12, 6, 18, 3, 9, 15, 21, 7, 13, 19, 4, 8, 16, 22, 24, 26, 11, 14, 17, 23, 27, 28, 29, 30],B = [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]) == [0, 0, 0, 1, 2, 2, 2, 3, 3, 5, 5, 7, 8, 8, 9, 10, 11, 12, 14, 16, 18, 19, 19, 20, 22, 24, 25, 26, 27, 29]\n assert candidate(A = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],B = [6, 5, 7, 4, 8, 3, 9, 2, 10, 1]) == [0, 0, 0, 0, 0, 2, 4, 6, 8, 10]\n assert candidate(A = [3, 2, 1, 4, 5],B = [4, 3, 1, 2, 5]) == [0, 1, 2, 4, 5]\n assert candidate(A = [45, 37, 31, 49, 25, 21, 39, 32, 35, 34, 13, 4, 27, 41, 50, 14, 46, 3, 44, 5, 29, 17, 33, 2, 48, 42, 30, 43, 7, 10, 28, 23, 9, 36, 20, 15, 18, 1, 24, 6, 22, 19, 47, 38, 8, 11, 12, 16, 40, 26],B = [26, 40, 16, 12, 11, 8, 38, 47, 19, 22, 6, 24, 1, 18, 15, 20, 36, 9, 23, 28, 10, 7, 43, 30, 42, 29, 5, 44, 3, 46, 14, 50, 41, 27, 4, 13, 34, 35, 32, 39, 21, 25, 49, 31, 37, 45]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42]\n assert candidate(A = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],B = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(A = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],B = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(A = [1, 5, 3, 4, 2],B = [5, 3, 2, 1, 4]) == [0, 1, 2, 3, 5]\n assert candidate(A = [3, 5, 1, 4, 2],B = [2, 1, 4, 5, 3]) == [0, 0, 1, 3, 5]\n assert candidate(A = [25, 15, 5, 35, 45, 55, 65, 75, 85, 95],B = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [0, 1, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(A = [4, 1, 2, 3],B = [3, 2, 1, 4]) == [0, 0, 2, 4]\n assert candidate(A = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],B = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 0, 0, 0, 2, 4, 6, 8, 10]\n assert candidate(A = [5, 1, 4, 2, 3],B = [3, 4, 2, 5, 1]) == [0, 0, 1, 3, 5]\n assert candidate(A = [2, 1, 4, 3],B = [3, 4, 1, 2]) == [0, 0, 2, 4]\n assert candidate(A = [4, 1, 5, 3, 2],B = [2, 5, 3, 4, 1]) == [0, 0, 1, 3, 5]\n assert candidate(A = [8, 7, 6, 5, 4, 3, 2, 1],B = [1, 2, 3, 4, 5, 6, 7, 8]) == [0, 0, 0, 0, 2, 4, 6, 8]\n assert candidate(A = [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15, 19, 23, 27, 4, 8, 12, 16, 20, 24, 28, 29, 30],B = [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]) == [0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 4, 6, 6, 6, 7, 9, 10, 12, 14, 15, 16, 18, 20, 22, 24, 26, 28, 30]\n assert candidate(A = [3, 7, 5, 1, 9, 4, 2, 8, 6],B = [9, 1, 2, 5, 8, 3, 4, 7, 6]) == [0, 0, 0, 2, 3, 4, 6, 8, 9]\n assert candidate(A = [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],B = [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]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]\n assert candidate(A = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6],B = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 5, 5, 6, 8, 10]\n assert candidate(A = [8, 3, 5, 7, 2, 6, 4, 1],B = [1, 2, 3, 4, 5, 6, 7, 8]) == [0, 0, 1, 1, 3, 4, 6, 8]\n assert candidate(A = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],B = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [0, 0, 0, 0, 0, 0, 0, 2, 4, 6, 8, 10, 12, 14]\n assert candidate(A = [9, 8, 7, 6, 5, 4, 3, 2, 1],B = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 0, 0, 0, 1, 3, 5, 7, 9]\n assert candidate(A = [1, 5, 3, 2, 4],B = [2, 3, 4, 5, 1]) == [0, 0, 1, 3, 5]\n assert candidate(A = [5, 1, 9, 3, 7, 2, 8, 6, 4, 10],B = [10, 4, 6, 8, 2, 7, 3, 9, 1, 5]) == [0, 0, 0, 0, 0, 2, 4, 6, 8, 10]\n assert candidate(A = [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],B = [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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]\n assert candidate(A = [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],B = [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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]\n assert candidate(A = [5, 1, 9, 3, 7, 2, 8, 6, 4],B = [4, 6, 8, 2, 7, 3, 9, 1, 5]) == [0, 0, 0, 0, 1, 3, 5, 7, 9]\n assert candidate(A = [1, 5, 3, 2, 4],B = [4, 5, 2, 3, 1]) == [0, 1, 1, 3, 5]\n assert candidate(A = [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],B = [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]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]\n assert candidate(A = [7, 3, 5, 1, 9, 8, 2, 6, 4],B = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 0, 1, 2, 3, 3, 5, 7, 9]\n"}, "metadata": {"canonical_parameter_names": ["A", "B"], "leetcode_dataset_entry_point": "Solution().findThePrefixCommonArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] findThePrefixCommonArray(int[] A, int[] B) {", "container": "Solution", "callable": "findThePrefixCommonArray", "parameters": [{"name": "A", "type": "int[]"}, {"name": "B", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2658, "task_id": "maximum-number-of-fish-in-a-grid", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D matrix grid of size m x n, where (r, c) represents:\n\nA land cell if grid[r][c] = 0, or\nA water cell containing grid[r][c] fish, if grid[r][c] > 0.\n\nA fisher can start at any water cell (r, c) and can do the following operations any number of times:\n\nCatch all the fish at cell (r, c), or\nMove to any adjacent water cell.\n\nReturn the maximum number of fish the fisher can catch if he chooses his starting cell optimally, or 0 if no water cell exists.\nAn adjacent cell of the cell (r, c), is one of the cells (r, c + 1), (r, c - 1), (r + 1, c) or (r - 1, c) if it exists.\n \nExample 1:\n\n\nInput: grid = [[0,2,1,0],[4,0,0,3],[1,0,0,4],[0,3,2,0]]\nOutput: 7\nExplanation: The fisher can start at cell (1,3) and collect 3 fish, then move to cell (2,3) and collect 4 fish.\n\nExample 2:\n\n\nInput: grid = [[1,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,1]]\nOutput: 1\nExplanation: The fisher can start at cells (0,0) or (3,3) and collect a single fish. \n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 10\n0 <= grid[i][j] <= 10\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 = [[1, 2, 3], [0, 0, 0], [4, 5, 6]]) == 15\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 45\n assert candidate(grid = [[10, 0, 0], [0, 0, 0], [0, 0, 10]]) == 10\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 1\n assert candidate(grid = [[0, 2, 1, 0], [4, 0, 0, 3], [1, 0, 0, 4], [0, 3, 2, 0]]) == 7\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]) == 1\n assert candidate(grid = [[5, 5, 5], [5, 0, 5], [5, 5, 5]]) == 40\n assert candidate(grid = [[10, 10, 10], [10, 0, 10], [10, 10, 10]]) == 80\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[5, 0, 3], [0, 2, 0], [1, 0, 4]]) == 5\n assert candidate(grid = [[10, 0, 10], [0, 0, 0], [10, 0, 10]]) == 10\n assert candidate(grid = [[0]]) == 0\n assert candidate(grid = [[10, 0, 10], [0, 10, 0], [10, 0, 10]]) == 10\n assert candidate(grid = [[1]]) == 1\n assert candidate(grid = [[1, 2], [3, 4]]) == 10\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 16\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 4\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 45\n assert candidate(grid = [[5, 0, 0, 0, 0, 0, 0, 0, 0, 5], [0, 4, 0, 0, 0, 0, 0, 0, 4, 0], [0, 0, 3, 0, 0, 0, 0, 3, 0, 0], [0, 0, 0, 2, 0, 0, 2, 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, 2, 0, 0, 2, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 3, 0, 0], [0, 4, 0, 0, 0, 0, 0, 0, 4, 0], [5, 0, 0, 0, 0, 0, 0, 0, 0, 5]]) == 5\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, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 1, 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]]) == 8\n assert candidate(grid = [[0, 5, 0, 0, 8], [0, 0, 0, 0, 0], [4, 0, 0, 0, 7], [0, 0, 0, 0, 0], [6, 0, 0, 0, 9]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[0, 0, 1, 3, 0], [2, 0, 0, 0, 0], [0, 4, 1, 2, 0], [0, 0, 0, 0, 5], [6, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 5, 6, 5, 0], [0, 6, 0, 6, 0], [0, 5, 6, 5, 0], [0, 0, 0, 0, 0]]) == 44\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\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 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, 1, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 5, 0, 1, 0], [2, 0, 3, 0, 0], [0, 4, 0, 0, 6], [0, 0, 7, 0, 0], [0, 0, 0, 8, 0]]) == 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], [0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 2, 3, 0, 0], [0, 0, 0, 4, 0, 5, 0, 0], [0, 0, 0, 6, 7, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 28\n assert candidate(grid = [[0, 3, 0, 5, 0], [2, 0, 0, 0, 4], [0, 1, 0, 6, 0], [7, 0, 8, 0, 9], [0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[0, 0, 0, 0], [0, 9, 8, 0], [0, 7, 6, 0], [0, 5, 4, 0], [0, 3, 2, 0], [0, 1, 0, 0]]) == 45\n assert candidate(grid = [[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, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 9\n assert candidate(grid = [[0, 1, 0, 2, 0, 3, 0, 4, 0, 5], [5, 0, 4, 0, 3, 0, 2, 0, 1, 0], [0, 1, 0, 2, 0, 3, 0, 4, 0, 5], [5, 0, 4, 0, 3, 0, 2, 0, 1, 0], [0, 1, 0, 2, 0, 3, 0, 4, 0, 5], [5, 0, 4, 0, 3, 0, 2, 0, 1, 0]]) == 5\n assert candidate(grid = [[3, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 5, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 6]]) == 6\n assert candidate(grid = [[1, 0, 2, 0, 3, 0, 4, 0, 5, 0], [0, 6, 0, 7, 0, 8, 0, 9, 0, 10], [1, 0, 2, 0, 3, 0, 4, 0, 5, 0], [0, 6, 0, 7, 0, 8, 0, 9, 0, 10], [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]]) == 10\n assert candidate(grid = [[1, 0, 2, 0, 3, 0, 4, 0, 5, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [5, 0, 4, 0, 3, 0, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [9, 0, 8, 0, 7, 0, 6, 0, 5, 0]]) == 9\n assert candidate(grid = [[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, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 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]]) == 26\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 2, 3, 0], [0, 4, 0, 5, 0], [0, 6, 7, 0, 8], [0, 0, 0, 0, 0], [0, 9, 0, 10, 0], [0, 0, 0, 0, 0]]) == 28\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 5, 3, 1, 0, 0], [0, 2, 0, 0, 4, 0], [0, 0, 6, 0, 0, 0], [0, 0, 0, 7, 0, 0]]) == 11\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, 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]]) == 275\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]]) == 12\n assert candidate(grid = [[3, 3, 0, 0, 3, 3], [3, 0, 3, 3, 0, 3], [0, 3, 0, 0, 3, 0], [3, 0, 3, 3, 0, 3], [3, 3, 0, 0, 3, 3], [0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 0, 6]]) == 6\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 3, 0, 0, 0, 0], [0, 0, 5, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 7]]) == 7\n assert candidate(grid = [[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]]) == 15\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 19\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, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 55\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 0, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[5, 0, 0, 0, 0], [0, 4, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 2, 0], [0, 0, 0, 0, 1]]) == 5\n assert candidate(grid = [[0, 1, 2, 0, 1], [0, 0, 0, 0, 0], [2, 1, 0, 1, 2], [0, 0, 0, 0, 0], [1, 2, 0, 2, 1]]) == 3\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 5, 3, 0, 0], [0, 2, 0, 1, 0], [0, 0, 6, 0, 0], [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, 1, 2, 3, 0], [0, 0, 4, 5, 6, 7, 0], [0, 0, 8, 9, 10, 11, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 66\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 0], [0, 0, 3, 0, 0, 0], [0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[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]]) == 18\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 2, 0], [0, 3, 4, 0], [0, 0, 5, 0], [0, 6, 0, 0]]) == 15\n assert candidate(grid = [[3, 0, 0, 4, 0, 0, 5], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [6, 0, 0, 7, 0, 0, 8]]) == 8\n assert candidate(grid = [[1, 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]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 2, 3, 0, 0], [0, 0, 4, 0, 5, 0, 0], [0, 0, 0, 6, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[7, 0, 8, 0, 9], [0, 6, 0, 5, 0], [1, 0, 2, 0, 3], [0, 4, 0, 0, 0], [10, 0, 11, 0, 12]]) == 12\n assert candidate(grid = [[8, 0, 0, 0, 7], [0, 6, 0, 5, 0], [0, 0, 4, 0, 0], [0, 3, 0, 2, 0], [1, 0, 0, 0, 0]]) == 8\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]]) == 1\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]]) == 125\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 0], [0, 6, 7, 8, 9, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 45\n assert candidate(grid = [[7, 0, 8, 0, 9, 0, 10], [0, 0, 0, 0, 0, 0, 0], [6, 0, 7, 0, 8, 0, 9], [0, 0, 0, 0, 0, 0, 0], [5, 0, 6, 0, 7, 0, 8], [0, 0, 0, 0, 0, 0, 0], [4, 0, 5, 0, 6, 0, 7]]) == 10\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 2, 3, 0], [0, 4, 5, 6, 0], [0, 7, 8, 9, 0], [0, 0, 0, 0, 0]]) == 45\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 9, 0, 0], [0, 9, 0, 9, 0], [0, 0, 9, 0, 0], [0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 1], [3, 4, 5, 6, 7, 1, 2], [4, 5, 6, 7, 1, 2, 3], [5, 6, 7, 1, 2, 3, 4], [6, 7, 1, 2, 3, 4, 5], [7, 1, 2, 3, 4, 5, 6]]) == 196\n assert candidate(grid = [[0, 1, 0, 2, 0, 3], [1, 0, 2, 0, 3, 0], [0, 2, 0, 3, 0, 4], [2, 0, 3, 0, 4, 0], [0, 3, 0, 4, 0, 5], [3, 0, 4, 0, 5, 0]]) == 5\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 45\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 2, 3, 0], [0, 0, 4, 5, 6, 0], [0, 0, 7, 8, 9, 0], [0, 0, 0, 0, 0, 0]]) == 45\n assert candidate(grid = [[1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [5, 4, 3, 2, 1], [0, 0, 0, 0, 0], [1, 3, 5, 7, 9]]) == 25\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 8, 0, 0, 0, 0, 0, 0], [0, 0, 9, 0, 0, 0, 0, 0], [0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 0, 11, 0, 0, 0], [0, 0, 0, 0, 0, 12, 0, 0], [0, 0, 0, 0, 0, 0, 13, 0], [0, 0, 0, 0, 0, 0, 0, 14]]) == 14\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) == 90\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 0, 0, 0, 0, 5], [5, 0, 10, 10, 0, 5], [5, 0, 10, 10, 0, 5], [5, 0, 0, 0, 0, 5], [5, 5, 5, 5, 5, 5]]) == 100\n assert candidate(grid = [[0, 9, 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, 1, 0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 0], [0, 6, 7, 8, 9, 10, 0], [0, 11, 12, 0, 13, 14, 0], [0, 15, 16, 17, 18, 19, 0], [0, 0, 0, 0, 0, 0, 0]]) == 190\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 3, 2, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 2, 3, 0], [0, 4, 0, 5, 0], [0, 6, 7, 0, 8], [0, 0, 0, 0, 0]]) == 28\n assert candidate(grid = [[8, 0, 0, 0, 9], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [9, 0, 0, 0, 8]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]]) == 84\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, 10]]) == 10\n assert candidate(grid = [[5, 0, 0, 0, 0, 0, 3], [0, 0, 4, 0, 5, 0, 0], [0, 6, 0, 0, 0, 7, 0], [8, 0, 0, 9, 0, 0, 10]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 2, 0, 2, 0], [1, 0, 1, 0, 1], [0, 2, 0, 2, 0], [1, 0, 1, 0, 1]]) == 2\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 2, 3, 2, 0, 0], [0, 3, 4, 3, 0, 0], [0, 2, 3, 2, 0, 0], [0, 0, 0, 0, 0, 0]]) == 24\n assert candidate(grid = [[5, 5, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 5]]) == 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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5], [0, 1, 2, 3, 4], [5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, 9]]) == 56\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, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 21\n assert candidate(grid = [[0, 1, 0, 2, 0, 3], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 2], [0, 3, 0, 4, 0, 1], [0, 0, 0, 0, 0, 0], [2, 0, 3, 0, 1, 0]]) == 4\n assert candidate(grid = [[0, 0, 10, 0, 0], [0, 5, 0, 6, 0], [10, 0, 0, 0, 10], [0, 6, 0, 5, 0], [0, 0, 10, 0, 0]]) == 10\n assert candidate(grid = [[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]]) == 14\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 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]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 2, 1], [0, 2, 3, 4, 3, 2], [0, 1, 2, 3, 2, 1], [0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 0], [0, 2, 3, 4, 5, 6, 0], [0, 3, 4, 5, 6, 7, 0], [0, 4, 5, 6, 7, 8, 0], [0, 5, 6, 7, 8, 9, 0], [0, 0, 0, 0, 0, 0, 0]]) == 125\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]]) == 15\n assert candidate(grid = [[3, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 2]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [5, 4, 3, 2, 1], [0, 0, 0, 0, 0], [1, 2, 3, 4, 5]]) == 15\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, 0], [1, 1, 1], [1, 1, 1], [0, 0, 0], [0, 0, 0]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().findMaxFish", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findMaxFish(int[][] grid) {", "container": "Solution", "callable": "findMaxFish", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2659, "task_id": "make-array-empty", "difficulty": "Hard", "problem_description": "You are given an integer array nums containing distinct numbers, and you can perform the following operations until the array is empty:\n\nIf the first element has the smallest value, remove it\nOtherwise, put the first element at the end of the array.\n\nReturn an integer denoting the number of operations it takes to make nums empty.\n \nExample 1:\n\nInput: nums = [3,4,-1]\nOutput: 5\n\n\n\n\nOperation\nArray\n\n\n\n\n1\n[4, -1, 3]\n\n\n2\n[-1, 3, 4]\n\n\n3\n[3, 4]\n\n\n4\n[4]\n\n\n5\n[]\n\n\n\nExample 2:\n\nInput: nums = [1,2,4,3]\nOutput: 5\n\n\n\n\nOperation\nArray\n\n\n\n\n1\n[2, 4, 3]\n\n\n2\n[4, 3]\n\n\n3\n[3, 4]\n\n\n4\n[4]\n\n\n5\n[]\n\n\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: 3\n\n\n\n\nOperation\nArray\n\n\n\n\n1\n[2, 3]\n\n\n2\n[3]\n\n\n3\n[]\n\n\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-109 <= nums[i] <= 109\nAll values in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 55\n assert candidate(nums = [-3, -1, -2, -4]) == 8\n assert candidate(nums = [10, 20, -10, 0]) == 6\n assert candidate(nums = [0, 10, -10, 5, -5]) == 9\n assert candidate(nums = [-3, -1, 0, 2, 4]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 3, 2]) == 4\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == 28\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 15\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [-3, -2, -1]) == 3\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3]) == 22\n assert candidate(nums = [0, 1, -1, 2, -2]) == 12\n assert candidate(nums = [5, 1, 3, 2, 4]) == 9\n assert candidate(nums = [1, 3, 2]) == 4\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000]) == 7\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 55\n assert candidate(nums = [-3, -1, 0, 2, 5]) == 5\n assert candidate(nums = [5, 1, 2, 4, 3]) == 8\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [1, 2, 4, 3]) == 5\n assert candidate(nums = [5, 2, 6, 1, 4]) == 11\n assert candidate(nums = [1, 2, 3]) == 3\n assert candidate(nums = [3, 4, -1]) == 5\n assert candidate(nums = [-100, -200, -300, -400, -500]) == 15\n assert candidate(nums = [5, 3, 1, 2, 4]) == 9\n assert candidate(nums = [-5, -1, -3, -2, -4]) == 9\n assert candidate(nums = [50, 40, 30, 20, 10]) == 15\n assert candidate(nums = [100, 50, 25, 125, 200]) == 12\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(nums = [50, 40, 30, 20, 10, 5, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16]) == 57\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 50, 150, 250, 350, 450, 650, 750, 850, 950, 550]) == 120\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 10\n assert candidate(nums = [0, 2, 1, 4, 3, 6, 5, 8, 7, 9]) == 30\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40]) == 55\n assert candidate(nums = [1, -10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == 51\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 6, 4, 0]) == 35\n assert candidate(nums = [1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6, 7, 8, 9]) == 31\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 45\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 50\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, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [10, 20, 5, 15, 25, 30]) == 14\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4]) == 26\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == 55\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1]) == 26\n assert candidate(nums = [-100, -200, -300, -50, -25, -125, -62, -31, -156, -78, -39]) == 48\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]) == 465\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 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, 0]) == 41\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 165\n assert candidate(nums = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 3, 6, 12, 24, 48, 96]) == 132\n assert candidate(nums = [-1, -10, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000]) == 55\n assert candidate(nums = [9, 7, 5, 3, 1, 8, 6, 4, 2, 0, 11, 13, 15, 17, 19, 12, 14, 16, 18, 20]) == 115\n assert candidate(nums = [1, 11, 2, 12, 3, 13, 4, 14, 5, 15]) == 15\n assert candidate(nums = [10, 5, 20, 15, 30, 25, 40, 35, 50, 45, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [10, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == 35\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1]) == 19\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 55\n assert candidate(nums = [20, 1, 19, 2, 18, 3, 17, 4, 16, 5, 15, 6, 14, 7, 13, 8, 12, 9, 11, 10]) == 75\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 30\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 55\n assert candidate(nums = [-10, 100, -20, 200, -30, 300, -40, 400, -50, 500]) == 40\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 55\n assert candidate(nums = [5, 3, 1, 4, 2, 6, 8, 7]) == 19\n assert candidate(nums = [-9, -7, -5, -3, -1, 1, 3, 5, 7, 9]) == 10\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000]) == 12\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 55\n assert candidate(nums = [5, 3, 1, 4, 2]) == 9\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 55\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 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]) == 30\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 6, 4, 10]) == 30\n assert candidate(nums = [10, 5, 20, 15, 30, 25, 40, 35, 50, 45]) == 35\n assert candidate(nums = [-50, -40, -30, -20, -10, 0, 10, 20, 30, 40]) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 165\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 10\n assert candidate(nums = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 10\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]) == 25\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5]) == 19\n assert candidate(nums = [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, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 30\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 144\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 22\n assert candidate(nums = [7, 10, 4, 3, 20, 15]) == 16\n assert candidate(nums = [100, 50, 25, 125, 62, 31, 156, 78, 39]) == 18\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 20\n assert candidate(nums = [-1000000000, -999999999, -1000000001, -999999998, -1000000002]) == 12\n assert candidate(nums = [10, 20, 15, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110]) == 110\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, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001]) == 110\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, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 41\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 21\n assert candidate(nums = [-100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000, -10000000000, 1]) == 54\n assert candidate(nums = [3, 1, 2, 5, 4, 6, 8, 7, 9]) == 23\n assert candidate(nums = [1000000000, 999999999, 1000000001, 999999998, 1000000002]) == 12\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000]) == 8\n assert candidate(nums = [1, -1000000000, 2, -999999999, 3, -999999998, 4, -999999997]) == 12\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 98\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == 190\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 = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == 15\n assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 55\n assert candidate(nums = [1, 10, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60, 7, 70, 8, 80, 9, 90]) == 27\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 55\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]) == 165\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 45\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 1, -1]) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [-1, 1000000000, 1, -1000000000, 2, -999999999, 3, -999999998, 4, -999999997]) == 17\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == 25\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 120\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5]) == 40\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, 10]) == 54\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 55\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 15\n assert candidate(nums = [1000000000, 500000000, -500000000, -1000000000]) == 10\n assert candidate(nums = [999999999, -999999999, 999999998, -999999998, 999999997, -999999997]) == 12\n assert candidate(nums = [5, 1, 4, 2, 3]) == 8\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3]) == 7\n assert candidate(nums = [5, 2, 3, 1, 4]) == 10\n assert candidate(nums = [5, 2, 6, 1, 3, 4]) == 13\n assert candidate(nums = [1000000000, -1000000000, 0]) == 4\n assert candidate(nums = [1, 2, 4, 3]) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 55\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 0]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [-1, -2, -3, -4]) == 10\n assert candidate(nums = [1, 3, 5, 2, 4, 6]) == 12\n assert candidate(nums = [1000000000, -1000000000, 500000000, 0, 250000000]) == 8\n assert candidate(nums = [1, 3, 2, 5, 4]) == 9\n assert candidate(nums = [-10, 100, 50, 20, -20]) == 12\n assert candidate(nums = [-10, 10, 0, 5, 3]) == 8\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == 18\n assert candidate(nums = [100, -100, 50, -50, 25, -25]) == 12\n assert candidate(nums = [1, 1000000000, -1000000000]) == 5\n assert candidate(nums = [10, 20, 30, 5, 15, 25]) == 15\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 55\n assert candidate(nums = [5, 1, 2, 3, 4]) == 6\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3]) == 7\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [50, 40, 30, 20, 10]) == 15\n assert candidate(nums = [5, 3, 8, 6, 2]) == 13\n assert candidate(nums = [5, 1, 4, 2, 3]) == 8\n assert candidate(nums = [1, -2, 3, -4, 5]) == 12\n assert candidate(nums = [5]) == 1\n assert candidate(nums = [5, 2, 4, 1, 3]) == 12\n assert candidate(nums = [1000000000, -1000000000, 500000000]) == 4\n assert candidate(nums = [-10, -20, -30, -5, -15, -25]) == 12\n assert candidate(nums = [0, 1, -1, 2, -2]) == 12\n assert candidate(nums = [-5, 1, 2, 0, 3]) == 8\n assert candidate(nums = [10, 5, 3, 8, 2]) == 13\n assert candidate(nums = [-10, 100, 5, 2, 0]) == 11\n assert candidate(nums = [-10, 100, 0, 5]) == 5\n assert candidate(nums = [1000000000, -1000000000]) == 3\n assert candidate(nums = [-3, -1, -2]) == 4\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == 18\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [7, 3, 5, 2, 4, 6, 1]) == 22\n assert candidate(nums = [5, 3, 8, 1, 4]) == 11\n assert candidate(nums = [-5, 1, 2, 0]) == 6\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997]) == 10\n assert candidate(nums = [5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [5, 3, 1, 2, 4]) == 9\n assert candidate(nums = [-5, 10, 0, 7, -3]) == 9\n assert candidate(nums = [-3, -1, -4, -2]) == 8\n assert candidate(nums = [10, -10, 0]) == 4\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 10\n assert candidate(nums = [0]) == 1\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 51\n assert candidate(nums = [3, 4, -1]) == 5\n assert candidate(nums = [-10, 100, 0, 5, 3]) == 8\n assert candidate(nums = [-5, 1, 2, 0, -1]) == 10\n assert candidate(nums = [-5, -3, -1, -2, -4]) == 9\n assert candidate(nums = [10, -5, 3, 8, 2]) == 9\n assert candidate(nums = [0, -1, 1]) == 5\n assert candidate(nums = [5, 3, 2, 1, 4]) == 13\n assert candidate(nums = [-5, -3, -1, -4, -2]) == 9\n assert candidate(nums = [0, -1, 1, -2, 2]) == 12\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == 28\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2]) == 55\n assert candidate(nums = [1000000000, -1000000000, 500000000]) == 4\n assert candidate(nums = [-5, -1, -4, -2, -3]) == 8\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 15\n assert candidate(nums = [1, 2, 3]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 55\n assert candidate(nums = [-5, -3, -1, 2, 4]) == 5\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == 18\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [7, 3, 5, 1, 9, 2, 4, 6, 8]) == 25\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 15\n assert candidate(nums = [-5, -3, -1, 1, 3, 5]) == 6\n assert candidate(nums = [5, 1, 9, 3, 7]) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [9, 7, 5, 3, 1]) == 15\n assert candidate(nums = [42]) == 1\n assert candidate(nums = [-5, -3, -2, -4, -1]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) == 35\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3]) == 22\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 120\n assert candidate(nums = [-5, 3, -2, 1, 4]) == 7\n assert candidate(nums = [1, 2]) == 2\n assert candidate(nums = [7, 5, 6, 3, 4, 1, 2]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 30\n assert candidate(nums = [-10, 100, 0, 5, -5]) == 9\n assert candidate(nums = [5, 4, 3, 2, 1]) == 15\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countOperationsToEmptyArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countOperationsToEmptyArray(int[] nums) {", "container": "Solution", "callable": "countOperationsToEmptyArray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2660, "task_id": "determine-the-winner-of-a-bowling-game", "difficulty": "Easy", "problem_description": "You are given two 0-indexed integer arrays player1 and player2, representing the number of pins that player 1 and player 2 hit in a bowling game, respectively.\nThe bowling game consists of n turns, and the number of pins in each turn is exactly 10.\nAssume a player hits xi pins in the ith turn. The value of the ith turn for the player is:\n\n2xi if the player hits 10 pins in either (i - 1)th or (i - 2)th turn.\nOtherwise, it is xi.\n\nThe score of the player is the sum of the values of their n turns.\nReturn\n\n1 if the score of player 1 is more than the score of player 2,\n2 if the score of player 2 is more than the score of player 1, and\n0 in case of a draw.\n\n \nExample 1:\n\nInput: player1 = [5,10,3,2], player2 = [6,5,7,3]\nOutput: 1\nExplanation:\nThe score of player 1 is 5 + 10 + 2*3 + 2*2 = 25.\nThe score of player 2 is 6 + 5 + 7 + 3 = 21.\n\nExample 2:\n\nInput: player1 = [3,5,7,6], player2 = [8,10,10,2]\nOutput: 2\nExplanation:\nThe score of player 1 is 3 + 5 + 7 + 6 = 21.\nThe score of player 2 is 8 + 10 + 2*10 + 2*2 = 42.\n\nExample 3:\n\nInput: player1 = [2,3], player2 = [4,1]\nOutput: 0\nExplanation:\nThe score of player1 is 2 + 3 = 5.\nThe score of player2 is 4 + 1 = 5.\n\nExample 4:\n\nInput: player1 = [1,1,1,10,10,10,10], player2 = [10,10,10,10,1,1,1]\nOutput: 2\nExplanation:\nThe score of player1 is 1 + 1 + 1 + 10 + 2*10 + 2*10 + 2*10 = 73.\nThe score of player2 is 10 + 2*10 + 2*10 + 2*10 + 2*1 + 2*1 + 1 = 75.\n\n \nConstraints:\n\nn == player1.length == player2.length\n1 <= n <= 1000\n0 <= player1[i], player2[i] <= 10\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(player1 = [5, 5, 5, 5, 5],player2 = [5, 5, 5, 5, 5]) == 0\n assert candidate(player1 = [2, 3],player2 = [4, 1]) == 0\n assert candidate(player1 = [5, 10, 3, 2],player2 = [6, 5, 7, 3]) == 1\n assert candidate(player1 = [5, 5, 5, 5],player2 = [10, 0, 10, 0]) == 2\n assert candidate(player1 = [10, 10, 10],player2 = [10, 10, 10]) == 0\n assert candidate(player1 = [3, 5, 7, 6],player2 = [8, 10, 10, 2]) == 2\n assert candidate(player1 = [0, 0, 0, 0],player2 = [0, 0, 0, 0]) == 0\n assert candidate(player1 = [1, 1, 1, 10, 10, 10, 10],player2 = [10, 10, 10, 10, 1, 1, 1]) == 2\n assert candidate(player1 = [10, 10, 10, 10],player2 = [10, 10, 10, 10]) == 0\n assert candidate(player1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],player2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(player1 = [10, 0, 10, 0, 10],player2 = [0, 10, 0, 10, 0]) == 1\n assert candidate(player1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],player2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(player1 = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10],player2 = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0]) == 0\n assert candidate(player1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],player2 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(player1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10],player2 = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(player1 = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5],player2 = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == 1\n assert candidate(player1 = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],player2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 1]) == 1\n assert candidate(player1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],player2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(player1 = [3, 6, 9, 10, 3, 6, 9, 10, 3, 6, 9, 10],player2 = [10, 3, 6, 9, 10, 3, 6, 9, 10, 3, 6, 9]) == 2\n assert candidate(player1 = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],player2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5]) == 2\n assert candidate(player1 = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9],player2 = [9, 8, 7, 6, 10, 5, 4, 3, 2, 1]) == 1\n assert candidate(player1 = [0, 10, 5, 10, 3, 0, 10, 2],player2 = [10, 0, 10, 5, 10, 3, 0, 10]) == 2\n assert candidate(player1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],player2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(player1 = [0, 0, 10, 0, 0, 0, 0, 0, 0, 0],player2 = [0, 0, 0, 0, 10, 0, 0, 0, 0, 0]) == 0\n assert candidate(player1 = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5],player2 = [0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 1\n assert candidate(player1 = [5, 5, 5, 5, 10, 5, 5, 5, 5, 10],player2 = [10, 5, 5, 5, 5, 10, 5, 5, 5, 5]) == 2\n assert candidate(player1 = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],player2 = [7, 7, 7, 7, 10, 7, 7, 7, 7, 7]) == 2\n assert candidate(player1 = [9, 10, 10, 9, 10, 9, 10],player2 = [10, 9, 10, 9, 10, 9, 9]) == 2\n assert candidate(player1 = [1, 10, 2, 10, 3, 10, 4, 10],player2 = [10, 1, 10, 2, 10, 3, 10, 4]) == 2\n assert candidate(player1 = [10, 10, 10, 0, 0, 0, 0, 0, 0, 0],player2 = [0, 0, 0, 0, 0, 0, 10, 10, 10, 0]) == 0\n assert candidate(player1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],player2 = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10]) == 2\n assert candidate(player1 = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],player2 = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10]) == 0\n assert candidate(player1 = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10],player2 = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == 2\n assert candidate(player1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],player2 = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0]) == 2\n assert candidate(player1 = [0, 0, 10, 0, 0, 10, 0, 0],player2 = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(player1 = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10],player2 = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == 2\n assert candidate(player1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],player2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(player1 = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],player2 = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(player1 = [7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],player2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 7]) == 2\n assert candidate(player1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],player2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(player1 = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0],player2 = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(player1 = [7, 8, 9, 10, 8, 7, 6, 5, 4, 3, 2, 1],player2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 8, 7]) == 0\n assert candidate(player1 = [3, 6, 9, 2, 5, 8, 1, 4, 7, 10],player2 = [10, 7, 4, 1, 8, 5, 2, 9, 6, 3]) == 2\n assert candidate(player1 = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0],player2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]) == 0\n assert candidate(player1 = [0, 0, 0, 0, 10, 0, 0, 0],player2 = [0, 0, 0, 0, 0, 10, 0, 0]) == 0\n assert candidate(player1 = [10, 0, 0, 10, 0, 0, 10, 0, 0, 10],player2 = [0, 0, 10, 0, 0, 10, 0, 0, 10, 0]) == 1\n assert candidate(player1 = [10, 10, 0, 10, 10, 0, 10, 10, 0, 10, 10, 0, 10, 10, 0],player2 = [0, 10, 10, 0, 10, 10, 0, 10, 10, 0, 10, 10, 0, 10, 10]) == 0\n assert candidate(player1 = [0, 10, 0, 0, 10, 0, 0, 10, 0, 0],player2 = [0, 0, 10, 0, 0, 10, 0, 0, 10, 0]) == 0\n assert candidate(player1 = [5, 6, 7, 8, 9, 10],player2 = [10, 9, 8, 7, 6, 5]) == 2\n assert candidate(player1 = [5, 0, 10, 5, 2, 3],player2 = [3, 0, 0, 10, 10, 1]) == 2\n assert candidate(player1 = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],player2 = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10]) == 0\n assert candidate(player1 = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10],player2 = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0]) == 1\n assert candidate(player1 = [5, 10, 5, 10, 5, 10, 5, 10],player2 = [10, 5, 10, 5, 10, 5, 10, 5]) == 2\n assert candidate(player1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],player2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(player1 = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0],player2 = [0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5]) == 0\n assert candidate(player1 = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0],player2 = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10]) == 0\n assert candidate(player1 = [5, 5, 5, 5, 5, 10, 5, 5, 5, 5],player2 = [5, 5, 5, 5, 5, 5, 5, 10, 5, 5]) == 0\n assert candidate(player1 = [0, 10, 0, 10, 0, 10, 0, 10],player2 = [10, 0, 10, 0, 10, 0, 10, 0]) == 0\n assert candidate(player1 = [3, 6, 9, 10, 2, 5, 8, 10, 4, 7],player2 = [7, 4, 8, 10, 5, 2, 10, 9, 6, 3]) == 2\n assert candidate(player1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],player2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 1\n assert candidate(player1 = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0],player2 = [0, 5, 0, 5, 0, 5, 0, 5, 0, 5]) == 0\n assert candidate(player1 = [10, 10, 0, 10, 0, 10, 0, 10, 0, 10],player2 = [0, 10, 10, 0, 10, 10, 0, 10, 10, 0]) == 0\n assert candidate(player1 = [0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0],player2 = [10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0]) == 2\n assert candidate(player1 = [5, 5, 10, 5, 5],player2 = [10, 5, 5, 5, 5]) == 0\n assert candidate(player1 = [3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],player2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == 1\n assert candidate(player1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],player2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(player1 = [5, 0, 10, 3, 6, 10, 2],player2 = [10, 5, 0, 7, 3, 0, 10]) == 1\n assert candidate(player1 = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],player2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 1\n assert candidate(player1 = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10],player2 = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0]) == 0\n assert candidate(player1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],player2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(player1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],player2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(player1 = [10, 0, 10, 0, 10, 0, 10],player2 = [0, 10, 0, 10, 0, 10, 0]) == 1\n assert candidate(player1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],player2 = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == 2\n assert candidate(player1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],player2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(player1 = [10, 5, 5, 10, 2, 3, 4],player2 = [5, 10, 10, 5, 6, 7, 8]) == 2\n assert candidate(player1 = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10],player2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10]) == 1\n assert candidate(player1 = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0],player2 = [10, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0]) == 2\n assert candidate(player1 = [0, 10, 0, 0, 0, 10, 0, 0, 0, 10],player2 = [10, 0, 0, 0, 10, 0, 0, 0, 10, 0]) == 0\n assert candidate(player1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],player2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(player1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],player2 = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 2\n assert candidate(player1 = [5, 0, 10, 3, 2, 10, 4],player2 = [6, 5, 7, 3, 10, 1, 10]) == 2\n assert candidate(player1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],player2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 2\n assert candidate(player1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],player2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(player1 = [3, 6, 9, 10, 3, 6, 9, 10, 3, 6],player2 = [6, 3, 9, 10, 6, 3, 9, 10, 6, 3]) == 0\n assert candidate(player1 = [0, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10],player2 = [10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0]) == 0\n assert candidate(player1 = [10, 10, 0, 0, 0, 0, 0, 0, 0, 10],player2 = [0, 0, 0, 0, 0, 0, 0, 0, 10, 10]) == 1\n assert candidate(player1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],player2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(player1 = [10, 0, 0, 10, 0, 0, 10, 0, 0, 10],player2 = [0, 10, 0, 0, 10, 0, 0, 10, 0, 0]) == 1\n assert candidate(player1 = [5, 6, 7, 8, 9, 10, 3, 2],player2 = [4, 7, 6, 5, 8, 9, 4, 1]) == 1\n assert candidate(player1 = [1, 1, 1, 10, 1, 1, 1, 10, 1, 1],player2 = [1, 1, 1, 1, 10, 1, 1, 1, 10, 1]) == 1\n assert candidate(player1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],player2 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(player1 = [0, 10, 5, 0, 10, 8, 3],player2 = [10, 0, 10, 5, 0, 10, 2]) == 2\n assert candidate(player1 = [3, 3, 3, 10, 10, 3, 3],player2 = [10, 3, 3, 3, 3, 10, 3]) == 1\n"}, "metadata": {"canonical_parameter_names": ["player1", "player2"], "leetcode_dataset_entry_point": "Solution().isWinner", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int isWinner(int[] player1, int[] player2) {", "container": "Solution", "callable": "isWinner", "parameters": [{"name": "player1", "type": "int[]"}, {"name": "player2", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2661, "task_id": "first-completely-painted-row-or-column", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array arr, and an m x n integer matrix mat. arr and mat both contain all the integers in the range [1, m * n].\nGo through each index i in arr starting from index 0 and paint the cell in mat containing the integer arr[i].\nReturn the smallest index i at which either a row or a column will be completely painted in mat.\n \nExample 1:\n\n\nInput: arr = [1,3,4,2], mat = [[1,4],[2,3]]\nOutput: 2\nExplanation: The moves are shown in order, and both the first row and second column of the matrix become fully painted at arr[2].\n\nExample 2:\n\n\nInput: arr = [2,8,7,4,1,3,5,6,9], mat = [[3,2,5],[1,4,6],[8,7,9]]\nOutput: 3\nExplanation: The second column becomes fully painted at arr[3].\n\n \nConstraints:\n\nm == mat.length\nn = mat[i].length\narr.length == m * n\n1 <= m, n <= 105\n1 <= m * n <= 105\n1 <= arr[i], mat[r][c] <= m * n\nAll the integers of arr are unique.\nAll the integers of mat are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [15, 13, 14, 12, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 1],mat = [[13, 14, 15], [10, 11, 12], [7, 8, 9], [4, 5, 6], [1, 2, 3]]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == 3\n assert candidate(arr = [6, 5, 4, 3, 2, 1],mat = [[1, 2], [3, 4], [5, 6]]) == 1\n assert candidate(arr = [5, 1, 9, 11, 2, 6, 3, 10, 7, 4, 8, 12],mat = [[5, 1, 9, 11], [2, 6, 3, 10], [7, 4, 8, 12]]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 2\n assert candidate(arr = [5, 1, 9, 3, 2, 6, 8, 7, 4],mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 4\n assert candidate(arr = [2, 8, 7, 4, 1, 3, 5, 6, 9],mat = [[3, 2, 5], [1, 4, 6], [8, 7, 9]]) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 0, 0]]) == 3\n assert candidate(arr = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 0, 0]]) == 3\n assert candidate(arr = [1, 3, 4, 2],mat = [[1, 4], [2, 3]]) == 2\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 2\n assert candidate(arr = [15, 13, 14, 12, 10, 11, 8, 9, 7, 5, 6, 3, 4, 2, 1],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],mat = [[1, 5, 9, 13], [2, 6, 10, 14], [3, 7, 11, 15], [4, 8, 12, 16]]) == 3\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 0, 0]]) == 4\n assert candidate(arr = [1, 11, 21, 31, 2, 12, 22, 32, 3, 13, 23, 33, 4, 14, 24, 34, 5, 15, 25, 35, 6, 16, 26, 36, 7, 17, 27, 37, 8, 18, 28, 38, 9, 19, 29, 39, 10, 20, 30, 40],mat = [[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]]) == 16\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 2, 5, 8, 11, 14, 17, 20, 23, 26, 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 29, 30],mat = [[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]]) == 8\n assert candidate(arr = [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, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48],mat = [[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]]) == 20\n assert candidate(arr = [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],mat = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20], [21, 22, 23, 24, 25]]) == 16\n assert candidate(arr = [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],mat = [[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]]) == 4\n assert candidate(arr = [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],mat = [[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]]) == 4\n assert candidate(arr = [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],mat = [[21, 22, 23, 24, 25], [16, 17, 18, 19, 20], [11, 12, 13, 14, 15], [6, 7, 8, 9, 10], [1, 2, 3, 4, 5]]) == 4\n assert candidate(arr = [5, 10, 15, 20, 25, 4, 9, 14, 19, 24, 3, 8, 13, 18, 23, 2, 7, 12, 17, 22, 1, 6, 11, 16, 21],mat = [[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]]) == 4\n assert candidate(arr = [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],mat = [[5, 4, 3, 2, 1], [10, 9, 8, 7, 6], [15, 14, 13, 12, 11], [20, 19, 18, 17, 16], [25, 24, 23, 22, 21]]) == 4\n assert candidate(arr = [20, 15, 10, 5, 1, 25, 20, 15, 10, 5, 30, 25, 20, 15, 10, 35, 30, 25, 20, 15, 40, 35, 30, 25, 20],mat = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20], [21, 25, 29, 33, 37], [22, 26, 30, 34, 38], [23, 27, 31, 35, 39], [24, 28, 32, 36, 40]]) == 24\n assert candidate(arr = [1, 16, 2, 17, 3, 18, 4, 19, 5, 20, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 8\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 4\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 4\n assert candidate(arr = [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],mat = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20], [21, 22, 23, 24, 25]]) == 4\n assert candidate(arr = [25, 1, 24, 2, 23, 3, 22, 4, 21, 5, 20, 6, 19, 7, 18, 8, 17, 9, 16, 10, 15, 11, 14, 12, 13],mat = [[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(arr = [5, 10, 15, 20, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 25],mat = [[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]]) == 7\n assert candidate(arr = [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],mat = [[1, 6, 11, 16, 21], [2, 7, 12, 17, 22], [3, 8, 13, 18, 23], [4, 9, 14, 19, 24], [5, 10, 15, 20, 25]]) == 4\n assert candidate(arr = [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],mat = [[1, 2, 3, 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, 31], [32, 33, 34, 35, 36]]) == 4\n assert candidate(arr = [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],mat = [[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]]) == 18\n assert candidate(arr = [6, 2, 8, 4, 10, 1, 3, 5, 7, 9],mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 6\n assert candidate(arr = [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],mat = [[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]]) == 4\n assert candidate(arr = [1, 5, 9, 13, 17, 2, 6, 10, 14, 18, 3, 7, 11, 15, 19, 4, 8, 12, 16, 20],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 15\n assert candidate(arr = [45, 1, 42, 33, 14, 30, 52, 29, 3, 26, 35, 15, 2, 6, 44, 48, 50, 39, 41, 28, 34, 46, 38, 51, 32, 37, 40, 47, 49, 5, 7, 13, 31, 43, 8, 27, 20, 10, 11, 23, 16, 9, 21, 22, 24, 18, 12, 25, 17, 36, 19, 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],mat = [[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]]) == 26\n assert candidate(arr = [1, 17, 33, 49, 5, 21, 37, 53, 3, 19, 35, 51, 9, 25, 41, 57, 7, 23, 39, 55, 11, 27, 43, 59, 13, 29, 45, 61, 15, 31, 47, 63, 2, 18, 34, 50, 6, 22, 38, 54, 4, 20, 36, 52, 8, 24, 40, 56, 10, 26, 42, 58, 12, 28, 44, 60, 14, 30, 46, 62, 16, 32, 48, 64],mat = [[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]]) == 15\n assert candidate(arr = [1, 7, 13, 19, 25, 2, 8, 14, 20, 21, 3, 9, 15, 22, 4, 10, 16, 23, 5, 11, 17, 24, 6, 12, 18],mat = [[1, 6, 11, 16, 21], [2, 7, 12, 17, 22], [3, 8, 13, 18, 23], [4, 9, 14, 19, 24], [5, 10, 15, 20, 25]]) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 11\n assert candidate(arr = [30, 28, 27, 29, 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],mat = [[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]]) == 10\n assert candidate(arr = [96, 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],mat = [[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]]) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 12, 14, 16, 18, 20],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 6\n assert candidate(arr = [5, 25, 13, 1, 29, 3, 17, 19, 7, 21, 11, 23, 9, 27, 15, 2, 26, 14, 28, 6, 20, 12, 24, 8, 30, 4, 18, 10, 22, 16],mat = [[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]]) == 8\n assert candidate(arr = [1, 6, 11, 16, 21, 2, 7, 12, 17, 22, 3, 8, 13, 18, 23, 4, 9, 14, 19, 24, 5, 10, 15, 20, 25],mat = [[1, 6, 11, 16, 21], [2, 7, 12, 17, 22], [3, 8, 13, 18, 23], [4, 9, 14, 19, 24], [5, 10, 15, 20, 25]]) == 4\n assert candidate(arr = [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],mat = [[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]]) == 4\n assert candidate(arr = [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],mat = [[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]]) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 12, 14, 16, 18, 20, 21, 23, 25, 22, 24],mat = [[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]]) == 6\n assert candidate(arr = [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],mat = [[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]]) == 5\n assert candidate(arr = [20, 18, 19, 17, 15, 16, 13, 14, 11, 12, 9, 10, 7, 8, 5, 6, 3, 4, 1, 2],mat = [[18, 19, 20], [15, 16, 17], [12, 13, 14], [9, 10, 11], [6, 7, 8], [3, 4, 5], [1, 2, 3]]) == 2\n assert candidate(arr = [25, 18, 19, 20, 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],mat = [[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]]) == 7\n assert candidate(arr = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 11\n assert candidate(arr = [1, 5, 9, 13, 17, 2, 6, 10, 14, 18, 3, 7, 11, 15, 19, 4, 8, 12, 16, 20],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 15\n assert candidate(arr = [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],mat = [[5, 10, 15, 20, 25], [4, 9, 14, 19, 24], [3, 8, 13, 18, 23], [2, 7, 12, 17, 22], [1, 6, 11, 16, 30]]) == 5\n assert candidate(arr = [10, 20, 30, 40, 50, 11, 21, 31, 41, 51, 12, 22, 32, 42, 52, 13, 23, 33, 43, 53, 14, 24, 34, 44, 54, 15, 25, 35, 45, 55],mat = [[10, 11, 12, 13, 14, 15], [20, 21, 22, 23, 24, 25], [30, 31, 32, 33, 34, 35], [40, 41, 42, 43, 44, 45], [50, 51, 52, 53, 54, 55]]) == 4\n assert candidate(arr = [81, 66, 71, 76, 86, 91, 96, 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 62, 67, 72, 77, 82, 87, 92, 97, 2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 63, 68, 73, 78, 83, 88, 93, 98, 3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 64, 69, 74, 79, 84, 89, 94, 99, 4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 65, 70, 75, 80, 85, 90, 95, 100],mat = [[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]]) == 18\n assert candidate(arr = [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, 25],mat = [[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]]) == 14\n assert candidate(arr = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 11\n assert candidate(arr = [1, 9, 17, 25, 2, 10, 18, 24, 3, 11, 19, 23, 4, 12, 20, 22, 5, 13, 16, 21, 6, 14, 15, 7, 8],mat = [[1, 6, 11, 16, 21], [2, 7, 12, 17, 22], [3, 8, 13, 18, 23], [4, 9, 14, 19, 24], [5, 10, 15, 20, 25]]) == 16\n assert candidate(arr = [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],mat = [[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]]) == 3\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16, 25, 24, 23, 22, 21],mat = [[1, 6, 11, 16, 21], [2, 7, 12, 17, 22], [3, 8, 13, 18, 23], [4, 9, 14, 19, 24], [5, 10, 15, 20, 25]]) == 4\n assert candidate(arr = [9, 18, 27, 36, 45, 1, 10, 19, 28, 37, 46, 2, 11, 20, 29, 38, 47, 3, 12, 21, 30, 39, 48, 4, 13, 22, 31, 40, 49, 5, 14, 23, 32, 41, 50, 6, 15, 24, 33, 42, 51, 7, 16, 25, 34, 43, 52, 8, 17, 26, 35, 44, 53],mat = [[9, 18, 27, 36, 45], [1, 10, 19, 28, 37], [2, 11, 20, 29, 38], [3, 12, 21, 30, 39], [4, 13, 22, 31, 40], [5, 14, 23, 32, 41], [6, 15, 24, 33, 42], [7, 16, 25, 34, 43], [8, 17, 26, 35, 44]]) == 4\n assert candidate(arr = [4, 8, 12, 16, 1, 2, 3, 5, 9, 13, 17, 21, 6, 10, 14, 18, 22, 7, 11, 15, 19, 23, 20, 24, 25],mat = [[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, 0, 0]]) == 6\n assert candidate(arr = [1, 13, 25, 37, 49, 61, 73, 85, 97, 2, 14, 26, 38, 50, 62, 74, 86, 98, 3, 15, 27, 39, 51, 63, 75, 87, 99, 4, 16, 28, 40, 52, 64, 76, 88, 100, 5, 17, 29, 41, 53, 65, 77, 89, 6, 18, 30, 42, 54, 66, 78, 90, 7, 19, 31, 43, 55, 67, 79, 91, 8, 20, 32, 44, 56, 68, 80, 92, 9, 21, 33, 45, 57, 69, 81, 93, 10, 22, 34, 46, 58, 70, 82, 94, 11, 23, 35, 47, 59, 71, 83, 95, 12, 24, 36, 48, 60, 72, 84, 96],mat = [[1, 13, 25, 37, 49], [61, 73, 85, 97, 2], [14, 26, 38, 50, 62], [74, 86, 98, 3, 15], [27, 39, 51, 63, 75], [87, 99, 4, 16, 28], [40, 52, 64, 76, 88], [90, 5, 17, 29, 41], [53, 65, 77, 89, 6], [18, 30, 42, 54, 66], [78, 90, 7, 19, 31], [43, 55, 67, 79, 91], [8, 20, 32, 44, 56], [68, 80, 92, 9, 21], [33, 45, 57, 69, 81], [93, 10, 22, 34, 46], [58, 70, 82, 94, 11], [23, 35, 47, 59, 71], [83, 95, 12, 24, 36], [48, 60, 72, 84, 96]]) == 4\n assert candidate(arr = [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],mat = [[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]]) == 4\n assert candidate(arr = [25, 1, 24, 2, 23, 3, 22, 4, 21, 5, 20, 6, 19, 7, 18, 8, 17, 9, 16, 10, 15, 11, 14, 12, 13],mat = [[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(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 11, 13, 15, 17, 19],mat = [[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]]) == 7\n assert candidate(arr = [1, 6, 11, 16, 2, 7, 12, 17, 3, 8, 13, 18, 4, 9, 14, 19, 5, 10, 15, 20],mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 3\n"}, "metadata": {"canonical_parameter_names": ["arr", "mat"], "leetcode_dataset_entry_point": "Solution().firstCompleteIndex", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int firstCompleteIndex(int[] arr, int[][] mat) {", "container": "Solution", "callable": "firstCompleteIndex", "parameters": [{"name": "arr", "type": "int[]"}, {"name": "mat", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2662, "task_id": "minimum-cost-of-a-path-with-special-roads", "difficulty": "Medium", "problem_description": "You are given an array start where start = [startX, startY] represents your initial position (startX, startY) in a 2D space. You are also given the array target where target = [targetX, targetY] represents your target position (targetX, targetY).\nThe cost of going from a position (x1, y1) to any other position in the space (x2, y2) is |x2 - x1| + |y2 - y1|.\nThere are also some special roads. You are given a 2D array specialRoads where specialRoads[i] = [x1i, y1i, x2i, y2i, costi] indicates that the ith special road goes in one direction from (x1i, y1i) to (x2i, y2i) with a cost equal to costi. You can use each special road any number of times.\nReturn the minimum cost required to go from (startX, startY) to (targetX, targetY).\n \nExample 1:\n\nInput: start = [1,1], target = [4,5], specialRoads = [[1,2,3,3,2],[3,4,4,5,1]]\nOutput: 5\nExplanation:\n\n(1,1) to (1,2) with a cost of |1 - 1| + |2 - 1| = 1.\n(1,2) to (3,3). Use specialRoads[0] with the cost 2.\n(3,3) to (3,4) with a cost of |3 - 3| + |4 - 3| = 1.\n(3,4) to (4,5). Use specialRoads[1] with the cost 1.\n\nSo the total cost is 1 + 2 + 1 + 1 = 5.\n\nExample 2:\n\nInput: start = [3,2], target = [5,7], specialRoads = [[5,7,3,2,1],[3,2,3,4,4],[3,3,5,5,5],[3,4,5,6,6]]\nOutput: 7\nExplanation:\nIt is optimal not to use any special edges and go directly from the starting to the ending position with a cost |5 - 3| + |7 - 2| = 7.\nNote that the specialRoads[0] is directed from (5,7) to (3,2).\n\nExample 3:\n\nInput: start = [1,1], target = [10,4], specialRoads = [[4,2,1,1,3],[1,2,7,4,4],[10,3,6,1,2],[6,1,1,2,3]]\nOutput: 8\nExplanation:\n\n(1,1) to (1,2) with a cost of |1 - 1| + |2 - 1| = 1.\n(1,2) to (7,4). Use specialRoads[1] with the cost 4.\n(7,4) to (10,4) with a cost of |10 - 7| + |4 - 4| = 3.\n\n\n \nConstraints:\n\nstart.length == target.length == 2\n1 <= startX <= targetX <= 105\n1 <= startY <= targetY <= 105\n1 <= specialRoads.length <= 200\nspecialRoads[i].length == 5\nstartX <= x1i, x2i <= targetX\nstartY <= y1i, y2i <= targetY\n1 <= costi <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(start = [3, 2],target = [5, 7],specialRoads = [[5, 7, 3, 2, 1], [3, 2, 3, 4, 4], [3, 3, 5, 5, 5], [3, 4, 5, 6, 6]]) == 7\n assert candidate(start = [1, 1],target = [4, 5],specialRoads = [[1, 2, 3, 3, 2], [3, 4, 4, 5, 1]]) == 5\n assert candidate(start = [1, 1],target = [10, 4],specialRoads = [[4, 2, 1, 1, 3], [1, 2, 7, 4, 4], [10, 3, 6, 1, 2], [6, 1, 1, 2, 3]]) == 8\n assert candidate(start = [1, 1],target = [100, 100],specialRoads = [[10, 10, 20, 20, 10], [20, 20, 30, 30, 15], [30, 30, 40, 40, 20], [40, 40, 50, 50, 25], [50, 50, 60, 60, 30], [60, 60, 70, 70, 35], [70, 70, 80, 80, 40], [80, 80, 90, 90, 45], [90, 90, 100, 100, 50]]) == 183\n assert candidate(start = [1, 1],target = [200, 200],specialRoads = [[10, 10, 30, 30, 15], [30, 30, 50, 50, 20], [50, 50, 70, 70, 25], [70, 70, 90, 90, 30], [90, 90, 110, 110, 35], [110, 110, 130, 130, 40], [130, 130, 150, 150, 45], [150, 150, 170, 170, 50], [170, 170, 190, 190, 55], [190, 190, 200, 200, 60], [10, 50, 30, 70, 20], [30, 70, 50, 90, 25], [50, 90, 70, 110, 30], [70, 110, 90, 130, 35], [90, 130, 110, 150, 40], [110, 150, 130, 170, 45], [130, 170, 150, 190, 50], [150, 190, 170, 200, 55]]) == 323\n assert candidate(start = [1, 1],target = [20, 20],specialRoads = [[2, 2, 3, 3, 1], [3, 3, 4, 4, 1], [4, 4, 5, 5, 1], [5, 5, 6, 6, 1], [6, 6, 7, 7, 1], [7, 7, 8, 8, 1], [8, 8, 9, 9, 1], [9, 9, 10, 10, 1], [10, 10, 11, 11, 1], [11, 11, 12, 12, 1], [12, 12, 13, 13, 1], [13, 13, 14, 14, 1], [14, 14, 15, 15, 1], [15, 15, 16, 16, 1], [16, 16, 17, 17, 1], [17, 17, 18, 18, 1], [18, 18, 19, 19, 1], [19, 19, 20, 20, 1]]) == 20\n assert candidate(start = [5, 5],target = [20, 20],specialRoads = [[5, 5, 10, 10, 5], [10, 10, 15, 15, 3], [15, 15, 20, 20, 2], [10, 15, 15, 20, 4]]) == 10\n assert candidate(start = [1, 1],target = [100, 100],specialRoads = [[1, 2, 3, 4, 2], [5, 6, 7, 8, 3], [9, 10, 11, 12, 4], [13, 14, 15, 16, 5], [17, 18, 19, 20, 6]]) == 195\n assert candidate(start = [1, 1],target = [100, 100],specialRoads = [[1, 1, 25, 25, 50], [25, 25, 50, 50, 100], [50, 50, 75, 75, 150], [75, 75, 100, 100, 200], [1, 1, 50, 50, 150], [50, 50, 100, 100, 250], [100, 100, 75, 75, 200], [75, 75, 50, 50, 150], [50, 50, 25, 25, 100]]) == 198\n assert candidate(start = [10, 10],target = [100, 100],specialRoads = [[10, 10, 20, 20, 30], [20, 20, 30, 30, 35], [30, 30, 40, 40, 40], [40, 40, 50, 50, 45], [50, 50, 60, 60, 50], [60, 60, 70, 70, 55], [70, 70, 80, 80, 60], [80, 80, 90, 90, 65], [90, 90, 100, 100, 70]]) == 180\n assert candidate(start = [1, 1],target = [15, 15],specialRoads = [[1, 1, 5, 5, 8], [5, 5, 10, 10, 10], [10, 10, 15, 15, 12], [1, 5, 5, 10, 15], [5, 10, 10, 15, 20]]) == 28\n assert candidate(start = [1, 1],target = [20, 20],specialRoads = [[2, 2, 18, 18, 10], [3, 3, 17, 17, 10], [4, 4, 16, 16, 10], [5, 5, 15, 15, 10], [6, 6, 14, 14, 10], [7, 7, 13, 13, 10], [8, 8, 12, 12, 10], [9, 9, 11, 11, 10], [10, 10, 10, 10, 10], [11, 11, 9, 9, 10], [12, 12, 8, 8, 10], [13, 13, 7, 7, 10], [14, 14, 6, 6, 10], [15, 15, 5, 5, 10], [16, 16, 4, 4, 10], [17, 17, 3, 3, 10], [18, 18, 2, 2, 10]]) == 16\n assert candidate(start = [10, 10],target = [50, 50],specialRoads = [[15, 15, 25, 25, 10], [25, 25, 35, 35, 20], [35, 35, 45, 45, 30], [45, 45, 55, 55, 40], [15, 25, 25, 35, 5], [25, 35, 35, 45, 15], [35, 45, 45, 55, 25], [15, 35, 35, 45, 35], [25, 45, 45, 55, 45], [15, 45, 45, 55, 55], [10, 25, 25, 35, 5], [25, 35, 35, 45, 15], [35, 45, 45, 55, 25], [15, 45, 45, 55, 35], [25, 55, 55, 65, 45], [35, 55, 55, 65, 55], [45, 55, 55, 65, 65], [15, 55, 55, 65, 75], [25, 55, 55, 65, 85], [10, 50, 50, 50, 10], [20, 50, 50, 50, 20], [30, 50, 50, 50, 30], [40, 50, 50, 50, 40], [50, 50, 50, 50, 50], [60, 50, 50, 50, 60], [70, 50, 50, 50, 70]]) == 50\n assert candidate(start = [10, 10],target = [30, 30],specialRoads = [[15, 15, 20, 20, 10], [20, 20, 25, 25, 5], [25, 25, 30, 30, 2], [12, 12, 18, 18, 8], [18, 18, 24, 24, 6], [24, 24, 29, 29, 4]]) == 22\n assert candidate(start = [5, 5],target = [95, 95],specialRoads = [[10, 10, 20, 20, 10], [20, 20, 30, 30, 20], [30, 30, 40, 40, 30], [40, 40, 50, 50, 40], [50, 50, 60, 60, 50], [60, 60, 70, 70, 60], [70, 70, 80, 80, 70], [80, 80, 90, 90, 80], [90, 90, 100, 100, 90], [100, 100, 110, 110, 100], [110, 110, 120, 120, 110], [120, 120, 130, 130, 120], [130, 130, 140, 140, 130], [140, 140, 150, 150, 140], [150, 150, 160, 160, 150], [160, 160, 170, 170, 160], [170, 170, 180, 180, 170], [180, 180, 190, 190, 180], [190, 190, 200, 200, 190], [200, 200, 210, 210, 200], [210, 210, 220, 220, 210], [220, 220, 230, 230, 220], [230, 230, 240, 240, 230], [240, 240, 250, 250, 240], [250, 250, 260, 260, 250], [260, 260, 270, 270, 260], [270, 270, 280, 280, 270], [280, 280, 290, 290, 280], [290, 290, 300, 300, 290], [300, 300, 310, 310, 300], [310, 310, 320, 320, 310], [320, 320, 330, 330, 320], [330, 330, 340, 340, 330], [340, 340, 350, 350, 340], [350, 350, 360, 360, 350], [360, 360, 370, 370, 360], [370, 370, 380, 380, 370], [380, 380, 390, 390, 380], [390, 390, 400, 400, 390], [400, 400, 410, 410, 400], [410, 410, 420, 420, 410], [420, 420, 430, 430, 420], [430, 430, 440, 440, 430], [440, 440, 450, 450, 440], [450, 450, 460, 460, 450], [460, 460, 470, 470, 460], [470, 470, 480, 480, 470], [480, 480, 490, 490, 480], [490, 490, 500, 500, 490], [500, 500, 510, 510, 500], [510, 510, 520, 520, 510], [520, 520, 530, 530, 520], [530, 530, 540, 540, 530], [540, 540, 550, 550, 540], [550, 550, 560, 560, 550], [560, 560, 570, 570, 560], [570, 570, 580, 580, 570], [580, 580, 590, 590, 580], [590, 590, 600, 600, 590], [600, 600, 610, 610, 600], [610, 610, 620, 620, 610], [620, 620, 630, 630, 620], [630, 630, 640, 640, 630], [640, 640, 650, 650, 640], [650, 650, 660, 660, 650], [660, 660, 670, 670, 660], [670, 670, 680, 680, 670], [680, 680, 690, 690, 680], [690, 690, 700, 700, 690], [700, 700, 710, 710, 700], [710, 710, 720, 720, 710], [720, 720, 730, 730, 720], [730, 730, 740, 740, 730], [740, 740, 750, 750, 740], [750, 750, 760, 760, 750], [760, 760, 770, 770, 760], [770, 770, 780, 780, 770], [780, 780, 790, 790, 780], [790, 790, 800, 800, 790], [800, 800, 810, 810, 800], [810, 810, 820, 820, 810], [820, 820, 830, 830, 820], [830, 830, 840, 840, 830], [840, 840, 850, 850, 840], [850, 850, 860, 860, 850], [860, 860, 870, 870, 860], [870, 870, 880, 880, 870], [880, 880, 890, 890, 880], [890, 890, 900, 900, 890], [900, 900, 910, 910, 900], [910, 910, 920, 920, 910], [920, 920, 930, 930, 920], [930, 930, 940, 940, 930], [940, 940, 950, 950, 940]]) == 170\n assert candidate(start = [1, 1],target = [200, 200],specialRoads = [[10, 10, 30, 30, 20], [50, 50, 70, 70, 30], [90, 90, 110, 110, 40], [130, 130, 150, 150, 50], [170, 170, 190, 190, 60]]) == 368\n assert candidate(start = [2, 2],target = [20, 20],specialRoads = [[2, 2, 6, 6, 5], [6, 6, 10, 10, 7], [10, 10, 14, 14, 6], [14, 14, 18, 18, 8], [18, 18, 20, 20, 9]]) == 30\n assert candidate(start = [1, 1],target = [10, 10],specialRoads = [[2, 2, 3, 3, 1], [3, 3, 4, 4, 2], [4, 4, 5, 5, 3], [5, 5, 6, 6, 4], [6, 6, 7, 7, 5], [7, 7, 8, 8, 6], [8, 8, 9, 9, 7], [9, 9, 10, 10, 8]]) == 17\n assert candidate(start = [10, 10],target = [50, 50],specialRoads = [[10, 10, 20, 20, 15], [20, 20, 30, 30, 10], [30, 30, 40, 40, 5], [40, 40, 50, 50, 3], [20, 30, 30, 40, 2], [30, 40, 40, 50, 1]]) == 33\n assert candidate(start = [10, 10],target = [150, 150],specialRoads = [[20, 20, 40, 40, 10], [40, 40, 60, 60, 15], [60, 60, 80, 80, 20], [80, 80, 100, 100, 25], [100, 100, 120, 120, 30], [120, 120, 140, 140, 35], [140, 140, 160, 160, 40], [160, 160, 180, 180, 45], [180, 180, 200, 200, 50], [20, 60, 40, 80, 20], [40, 80, 60, 100, 25], [60, 100, 80, 120, 30], [80, 120, 100, 140, 35], [100, 140, 120, 160, 40], [120, 160, 140, 180, 45], [140, 180, 160, 200, 50]]) == 175\n assert candidate(start = [10, 10],target = [90, 90],specialRoads = [[10, 10, 20, 20, 15], [20, 20, 30, 30, 10], [30, 30, 40, 40, 5], [40, 40, 50, 50, 3], [50, 50, 60, 60, 15], [60, 60, 70, 70, 10], [70, 70, 80, 80, 5], [80, 80, 90, 90, 3], [20, 30, 30, 40, 2], [30, 40, 40, 50, 1], [40, 50, 50, 60, 2], [50, 60, 60, 70, 1], [60, 70, 70, 80, 2], [70, 80, 80, 90, 1]]) == 44\n assert candidate(start = [1, 1],target = [12, 12],specialRoads = [[1, 1, 3, 3, 4], [3, 3, 6, 6, 5], [6, 6, 9, 9, 6], [9, 9, 12, 12, 7], [1, 6, 6, 11, 8], [6, 11, 11, 16, 9], [11, 16, 16, 21, 10]]) == 20\n assert candidate(start = [50, 50],target = [100, 100],specialRoads = [[50, 50, 60, 60, 5], [60, 60, 70, 70, 5], [70, 70, 80, 80, 5], [80, 80, 90, 90, 5], [90, 90, 100, 100, 5], [50, 60, 70, 80, 10], [60, 70, 80, 90, 10], [70, 80, 90, 100, 10]]) == 25\n assert candidate(start = [1, 1],target = [50, 50],specialRoads = [[1, 2, 3, 3, 1], [3, 4, 4, 5, 1], [5, 6, 6, 7, 1], [7, 8, 8, 9, 1], [9, 10, 10, 11, 1], [11, 12, 12, 13, 1], [13, 14, 14, 15, 1], [15, 16, 16, 17, 1], [17, 18, 18, 19, 1], [19, 20, 20, 21, 1], [21, 22, 22, 23, 1], [23, 24, 24, 25, 1], [25, 26, 26, 27, 1], [27, 28, 28, 29, 1], [29, 30, 30, 31, 1], [31, 32, 32, 33, 1], [33, 34, 34, 35, 1], [35, 36, 36, 37, 1], [37, 38, 38, 39, 1], [39, 40, 40, 41, 1], [41, 42, 42, 43, 1], [43, 44, 44, 45, 1], [45, 46, 46, 47, 1], [47, 48, 48, 49, 1], [49, 50, 50, 51, 1]]) == 73\n assert candidate(start = [1, 1],target = [10, 10],specialRoads = [[1, 1, 5, 5, 10], [5, 5, 10, 10, 10], [1, 5, 5, 10, 10], [5, 1, 10, 5, 10], [1, 1, 10, 10, 30]]) == 18\n assert candidate(start = [5, 5],target = [50, 50],specialRoads = [[5, 5, 20, 20, 10], [20, 20, 30, 30, 5], [30, 30, 40, 40, 12], [40, 40, 50, 50, 7], [5, 50, 25, 25, 18]]) == 34\n assert candidate(start = [1, 1],target = [15, 15],specialRoads = [[1, 1, 4, 4, 5], [5, 5, 8, 8, 6], [9, 9, 12, 12, 7], [13, 13, 15, 15, 8]]) == 27\n assert candidate(start = [5, 5],target = [20, 20],specialRoads = [[6, 6, 10, 10, 15], [10, 10, 15, 15, 10], [15, 15, 20, 20, 5], [5, 5, 10, 10, 20], [10, 10, 12, 12, 1], [12, 12, 15, 15, 5]]) == 21\n assert candidate(start = [1, 1],target = [10, 10],specialRoads = [[1, 2, 3, 4, 5], [4, 5, 6, 7, 6], [7, 8, 9, 10, 7], [1, 5, 3, 9, 8], [5, 6, 8, 10, 9], [2, 6, 4, 10, 10]]) == 18\n assert candidate(start = [1, 1],target = [100, 1],specialRoads = [[10, 1, 20, 1, 5], [20, 1, 30, 1, 5], [30, 1, 40, 1, 5], [40, 1, 50, 1, 5], [50, 1, 60, 1, 5], [60, 1, 70, 1, 5], [70, 1, 80, 1, 5], [80, 1, 90, 1, 5], [90, 1, 100, 1, 5]]) == 54\n assert candidate(start = [10, 10],target = [100, 100],specialRoads = [[10, 10, 20, 20, 50], [20, 20, 30, 30, 55], [30, 30, 40, 40, 60], [40, 40, 50, 50, 65], [50, 50, 60, 60, 70], [60, 60, 70, 70, 75], [70, 70, 80, 80, 80], [80, 80, 90, 90, 85], [90, 90, 100, 100, 90]]) == 180\n assert candidate(start = [1, 1],target = [100, 100],specialRoads = [[10, 10, 20, 20, 50], [20, 20, 30, 30, 40], [30, 30, 40, 40, 30], [40, 40, 50, 50, 20], [50, 50, 60, 60, 10], [60, 60, 70, 70, 15], [70, 70, 80, 80, 25], [80, 80, 90, 90, 35], [90, 90, 100, 100, 45]]) == 183\n assert candidate(start = [1, 1],target = [50, 50],specialRoads = [[1, 1, 10, 10, 10], [10, 10, 20, 20, 20], [20, 20, 30, 30, 30], [30, 30, 40, 40, 40], [40, 40, 50, 50, 50], [50, 50, 45, 45, 60], [45, 45, 40, 40, 70], [40, 40, 35, 35, 80], [35, 35, 30, 30, 90], [30, 30, 25, 25, 100], [25, 25, 20, 20, 110], [20, 20, 15, 15, 120], [15, 15, 10, 10, 130], [10, 10, 1, 1, 140]]) == 90\n assert candidate(start = [1, 1],target = [50, 50],specialRoads = [[2, 2, 3, 3, 1], [3, 3, 4, 4, 2], [4, 4, 5, 5, 3], [5, 5, 6, 6, 4], [6, 6, 7, 7, 5], [7, 7, 8, 8, 6], [8, 8, 9, 9, 7], [9, 9, 10, 10, 8], [10, 10, 11, 11, 9], [11, 11, 12, 12, 10], [12, 12, 13, 13, 11], [13, 13, 14, 14, 12], [14, 14, 15, 15, 13], [15, 15, 16, 16, 14], [16, 16, 17, 17, 15], [17, 17, 18, 18, 16], [18, 18, 19, 19, 17], [19, 19, 20, 20, 18], [20, 20, 21, 21, 19], [21, 21, 22, 22, 20], [22, 22, 23, 23, 21], [23, 23, 24, 24, 22], [24, 24, 25, 25, 23], [25, 25, 26, 26, 24], [26, 26, 27, 27, 25], [27, 27, 28, 28, 26], [28, 28, 29, 29, 27], [29, 29, 30, 30, 28], [30, 30, 31, 31, 29], [31, 31, 32, 32, 30], [32, 32, 33, 33, 31], [33, 33, 34, 34, 32], [34, 34, 35, 35, 33], [35, 35, 36, 36, 34], [36, 36, 37, 37, 35], [37, 37, 38, 38, 36], [38, 38, 39, 39, 37], [39, 39, 40, 40, 38], [40, 40, 41, 41, 39], [41, 41, 42, 42, 40], [42, 42, 43, 43, 41], [43, 43, 44, 44, 42], [44, 44, 45, 45, 43], [45, 45, 46, 46, 44], [46, 46, 47, 47, 45], [47, 47, 48, 48, 46], [48, 48, 49, 49, 47], [49, 49, 50, 50, 48]]) == 97\n assert candidate(start = [10, 10],target = [100, 100],specialRoads = [[15, 15, 20, 20, 5], [20, 20, 25, 25, 5], [25, 25, 30, 30, 5], [30, 30, 35, 35, 5], [35, 35, 40, 40, 5], [40, 40, 45, 45, 5], [45, 45, 50, 50, 5], [50, 50, 55, 55, 5], [55, 55, 60, 60, 5], [60, 60, 65, 65, 5], [65, 65, 70, 70, 5], [70, 70, 75, 75, 5], [75, 75, 80, 80, 5], [80, 80, 85, 85, 5], [85, 85, 90, 90, 5], [90, 90, 95, 95, 5], [95, 95, 100, 100, 5], [10, 30, 20, 40, 10], [20, 40, 30, 50, 10], [30, 50, 40, 60, 10], [40, 60, 50, 70, 10], [50, 70, 60, 80, 10], [60, 80, 70, 90, 10], [70, 90, 80, 100, 10]]) == 95\n assert candidate(start = [1, 1],target = [15, 15],specialRoads = [[1, 2, 2, 3, 1], [2, 3, 3, 4, 1], [3, 4, 4, 5, 1], [4, 5, 5, 6, 1], [5, 6, 6, 7, 1], [6, 7, 7, 8, 1], [7, 8, 8, 9, 1], [8, 9, 9, 10, 1], [9, 10, 10, 11, 1], [10, 11, 11, 12, 1], [11, 12, 12, 13, 1], [12, 13, 13, 14, 1], [13, 14, 14, 15, 1]]) == 15\n assert candidate(start = [1, 1],target = [100, 100],specialRoads = [[1, 1, 50, 50, 50], [50, 50, 75, 75, 40], [75, 75, 100, 100, 60], [1, 1, 75, 75, 100], [50, 50, 100, 100, 150]]) == 140\n assert candidate(start = [5, 5],target = [95, 95],specialRoads = [[10, 10, 20, 20, 15], [20, 20, 30, 30, 20], [30, 30, 40, 40, 25], [40, 40, 50, 50, 30], [50, 50, 60, 60, 35], [60, 60, 70, 70, 40], [70, 70, 80, 80, 45], [80, 80, 90, 90, 50], [90, 90, 100, 100, 55], [10, 30, 20, 40, 10], [20, 40, 30, 50, 15], [30, 50, 40, 60, 20], [40, 60, 50, 70, 25], [50, 70, 60, 80, 30], [60, 80, 70, 90, 35], [70, 90, 80, 100, 40], [80, 100, 90, 95, 45], [90, 95, 100, 95, 50]]) == 165\n assert candidate(start = [50, 50],target = [100, 100],specialRoads = [[50, 50, 60, 60, 10], [60, 60, 70, 70, 10], [70, 70, 80, 80, 10], [80, 80, 90, 90, 10], [90, 90, 100, 100, 10], [60, 60, 70, 70, 5], [70, 70, 80, 80, 5], [80, 80, 90, 90, 5], [90, 90, 100, 100, 5], [70, 70, 80, 80, 2], [80, 80, 90, 90, 2], [90, 90, 100, 100, 2]]) == 21\n assert candidate(start = [5, 5],target = [50, 50],specialRoads = [[5, 5, 15, 15, 20], [15, 15, 25, 25, 25], [25, 25, 35, 35, 30], [35, 35, 45, 45, 35], [45, 45, 50, 50, 40], [5, 15, 15, 25, 50], [15, 25, 25, 35, 55], [25, 35, 35, 45, 60], [35, 45, 45, 50, 65]]) == 90\n assert candidate(start = [10, 10],target = [100, 100],specialRoads = [[10, 20, 30, 40, 15], [30, 50, 60, 70, 20], [60, 80, 90, 100, 25]]) == 100\n assert candidate(start = [1, 1],target = [100, 100],specialRoads = [[2, 2, 50, 50, 100], [50, 50, 75, 75, 150], [75, 75, 100, 100, 50], [50, 50, 100, 100, 200], [75, 75, 25, 25, 50], [25, 25, 1, 1, 10]]) == 198\n assert candidate(start = [10, 10],target = [10, 30],specialRoads = [[10, 11, 10, 15, 5], [10, 16, 10, 20, 4], [10, 21, 10, 25, 3], [10, 26, 10, 30, 2]]) == 17\n assert candidate(start = [10, 10],target = [50, 50],specialRoads = [[15, 15, 20, 20, 5], [25, 25, 30, 30, 5], [35, 35, 40, 40, 5], [45, 45, 50, 50, 5], [5, 5, 10, 10, 5], [10, 10, 15, 15, 5], [15, 15, 10, 10, 5], [20, 20, 15, 15, 5], [25, 25, 20, 20, 5], [30, 30, 25, 25, 5], [35, 35, 30, 30, 5], [40, 40, 35, 35, 5], [45, 45, 40, 40, 5]]) == 55\n assert candidate(start = [1, 1],target = [100000, 100000],specialRoads = [[1, 1, 100000, 100000, 50000], [50000, 50000, 75000, 75000, 10000]]) == 50000\n assert candidate(start = [10, 10],target = [50, 50],specialRoads = [[10, 20, 30, 40, 25], [30, 50, 40, 60, 30], [40, 60, 50, 70, 35], [50, 70, 60, 80, 40], [60, 80, 70, 90, 45]]) == 65\n assert candidate(start = [1, 1],target = [100, 100],specialRoads = [[10, 10, 20, 20, 15], [20, 20, 30, 30, 25], [50, 50, 70, 70, 45], [70, 70, 90, 90, 55], [90, 90, 100, 100, 5]]) == 178\n assert candidate(start = [3, 3],target = [30, 30],specialRoads = [[3, 3, 9, 9, 15], [9, 9, 15, 15, 20], [15, 15, 21, 21, 25], [21, 21, 27, 27, 30], [27, 27, 30, 30, 35], [3, 9, 9, 15, 40], [9, 15, 15, 21, 45], [15, 21, 21, 27, 50], [21, 27, 27, 30, 55]]) == 54\n assert candidate(start = [5, 5],target = [150, 150],specialRoads = [[10, 10, 15, 15, 10], [15, 15, 20, 20, 12], [20, 20, 25, 25, 14], [25, 25, 30, 30, 16], [30, 30, 35, 35, 18], [35, 35, 40, 40, 20], [40, 40, 45, 45, 22], [45, 45, 50, 50, 24], [50, 50, 55, 55, 26], [55, 55, 60, 60, 28], [60, 60, 65, 65, 30], [65, 65, 70, 70, 32], [70, 70, 75, 75, 34], [75, 75, 80, 80, 36], [80, 80, 85, 85, 38], [85, 85, 90, 90, 40], [90, 90, 95, 95, 42], [95, 95, 100, 100, 44], [100, 100, 105, 105, 46], [105, 105, 110, 110, 48], [110, 110, 115, 115, 50], [115, 115, 120, 120, 52], [120, 120, 125, 125, 54], [125, 125, 130, 130, 56], [130, 130, 135, 135, 58], [135, 135, 140, 140, 60], [140, 140, 145, 145, 62], [145, 145, 150, 150, 64]]) == 290\n assert candidate(start = [5, 5],target = [30, 5],specialRoads = [[6, 5, 10, 5, 5], [11, 5, 15, 5, 4], [16, 5, 20, 5, 3], [21, 5, 25, 5, 2], [26, 5, 30, 5, 1]]) == 19\n assert candidate(start = [10, 10],target = [50, 50],specialRoads = [[10, 10, 20, 20, 20], [20, 20, 30, 30, 30], [30, 30, 40, 40, 40], [40, 40, 50, 50, 50], [50, 50, 40, 40, 60], [40, 40, 30, 30, 70], [30, 30, 20, 20, 80], [20, 20, 10, 10, 90]]) == 80\n assert candidate(start = [5, 5],target = [200, 200],specialRoads = [[10, 10, 20, 20, 5], [20, 20, 30, 30, 5], [30, 30, 40, 40, 5], [40, 40, 50, 50, 5], [50, 50, 60, 60, 5], [60, 60, 70, 70, 5], [70, 70, 80, 80, 5], [80, 80, 90, 90, 5], [90, 90, 100, 100, 5], [100, 100, 110, 110, 5], [110, 110, 120, 120, 5], [120, 120, 130, 130, 5], [130, 130, 140, 140, 5], [140, 140, 150, 150, 5], [150, 150, 160, 160, 5], [160, 160, 170, 170, 5], [170, 170, 180, 180, 5], [180, 180, 190, 190, 5], [190, 190, 200, 200, 5], [1, 1, 200, 200, 1000]]) == 105\n assert candidate(start = [5, 5],target = [50, 50],specialRoads = [[5, 5, 10, 10, 10], [10, 10, 15, 15, 10], [15, 15, 20, 20, 10], [20, 20, 25, 25, 10], [25, 25, 30, 30, 10], [30, 30, 35, 35, 10], [35, 35, 40, 40, 10], [40, 40, 45, 45, 10], [45, 45, 50, 50, 10]]) == 90\n assert candidate(start = [5, 5],target = [25, 25],specialRoads = [[5, 5, 10, 10, 10], [10, 10, 15, 15, 15], [15, 15, 20, 20, 20], [20, 20, 25, 25, 25]]) == 40\n"}, "metadata": {"canonical_parameter_names": ["start", "target", "specialRoads"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumCost(int[] start, int[] target, int[][] specialRoads) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "start", "type": "int[]"}, {"name": "target", "type": "int[]"}, {"name": "specialRoads", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2663, "task_id": "lexicographically-smallest-beautiful-string", "difficulty": "Hard", "problem_description": "A string is beautiful if:\n\nIt consists of the first k letters of the English lowercase alphabet.\nIt does not contain any substring of length 2 or more which is a palindrome.\n\nYou are given a beautiful string s of length n and a positive integer k.\nReturn the lexicographically smallest string of length n, which is larger than s and is beautiful. If there is no such string, return an empty string.\nA string a is lexicographically larger than a string b (of the same length) if in the first position where a and b differ, a has a character strictly larger than the corresponding character in b.\n\nFor example, \"abcd\" is lexicographically larger than \"abcc\" because the first position they differ is at the fourth character, and d is greater than c.\n\n \nExample 1:\n\nInput: s = \"abcz\", k = 26\nOutput: \"abda\"\nExplanation: The string \"abda\" is beautiful and lexicographically larger than the string \"abcz\".\nIt can be proven that there is no string that is lexicographically larger than the string \"abcz\", beautiful, and lexicographically smaller than the string \"abda\".\n\nExample 2:\n\nInput: s = \"dc\", k = 4\nOutput: \"\"\nExplanation: It can be proven that there is no string that is lexicographically larger than the string \"dc\" and is beautiful.\n\n \nConstraints:\n\n1 <= n == s.length <= 105\n4 <= k <= 26\ns is a beautiful string.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",k = 5) == \"abce\"\n assert candidate(s = \"aabbcc\",k = 6) == \"aabbcd\"\n assert candidate(s = \"zyx\",k = 26) == \"\"\n assert candidate(s = \"abcz\",k = 26) == \"abda\"\n assert candidate(s = \"aaa\",k = 4) == \"aab\"\n assert candidate(s = \"dc\",k = 4) == \"\"\n assert candidate(s = \"aab\",k = 3) == \"aac\"\n assert candidate(s = \"abcd\",k = 4) == \"abda\"\n assert candidate(s = \"xyz\",k = 26) == \"xza\"\n assert candidate(s = \"zyx\",k = 3) == \"\"\n assert candidate(s = \"aabb\",k = 4) == \"aabc\"\n assert candidate(s = \"azzzz\",k = 26) == \"bacba\"\n assert candidate(s = \"abcabcabcabc\",k = 3) == \"acbacbacbacb\"\n assert candidate(s = \"abcabca\",k = 26) == \"abcabcd\"\n assert candidate(s = \"aabababa\",k = 6) == \"aabababc\"\n assert candidate(s = \"zzzzz\",k = 26) == \"\"\n assert candidate(s = \"abcabcabcabc\",k = 26) == \"abcabcabcabd\"\n assert candidate(s = \"zyxzyxzyxzyx\",k = 26) == \"\"\n assert candidate(s = \"wxyz\",k = 26) == \"wxza\"\n assert candidate(s = \"zzzzzzzzzz\",k = 26) == \"\"\n assert candidate(s = \"mnopqrstuvw\",k = 21) == \"mnopqrsuabc\"\n assert candidate(s = \"zyxwvutsr\",k = 19) == \"\"\n assert candidate(s = \"abcdefg\",k = 7) == \"abcdega\"\n assert candidate(s = \"abcdefghijklmnop\",k = 26) == \"abcdefghijklmnoq\"\n assert candidate(s = \"mnopqr\",k = 18) == \"mnopra\"\n assert candidate(s = \"lkjihgf\",k = 12) == \"lkjihgi\"\n assert candidate(s = \"abcabc\",k = 3) == \"acbacb\"\n assert candidate(s = \"abcdefghij\",k = 10) == \"abcdefghja\"\n assert candidate(s = \"aabccba\",k = 15) == \"aabccbd\"\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\",k = 26) == \"mnbvcxzlkjhgfdsapoiuytrewr\"\n assert candidate(s = \"ababababababab\",k = 3) == \"ababababababac\"\n assert candidate(s = \"abcabcabcabcabc\",k = 3) == \"acbacbacbacbacb\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",k = 26) == \"abcdefghijklmnopqrstuvwxyzb\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20) == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrstabcabcabcabcab\"\n assert candidate(s = \"abcdefghijklmnopqrstuv\",k = 21) == \"abcdefghijklmnopqrsuab\"\n assert candidate(s = \"zzzzzz\",k = 4) == \"\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyzab\"\n assert candidate(s = \"abcdabcd\",k = 4) == \"abcdabda\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzz\",k = 26) == \"\"\n assert candidate(s = \"abcaabcd\",k = 26) == \"abcaabce\"\n assert candidate(s = \"mnopqrlmno\",k = 14) == \"mnopqrlnab\"\n assert candidate(s = \"abcdcba\",k = 10) == \"abcdcbd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxzz\",k = 26) == \"abcdefghijklmnopqrstuvwyab\"\n assert candidate(s = \"abcdefghijk\",k = 12) == \"abcdefghijl\"\n assert candidate(s = \"abcdefghijk\",k = 11) == \"abcdefghika\"\n assert candidate(s = \"abba\",k = 26) == \"abbc\"\n assert candidate(s = \"abababababab\",k = 26) == \"abababababac\"\n assert candidate(s = \"aaaabbbbccccdddd\",k = 26) == \"aaaabbbbccccddde\"\n assert candidate(s = \"abcabcabc\",k = 3) == \"acbacbacb\"\n assert candidate(s = \"abcdcba\",k = 26) == \"abcdcbd\"\n assert candidate(s = \"abcdexyz\",k = 26) == \"abcdexza\"\n assert candidate(s = \"pqrs\",k = 18) == \"prab\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 26) == \"qwertyuiopasdfghjklzxcvbno\"\n assert candidate(s = \"xyzabc\",k = 26) == \"xyzabd\"\n assert candidate(s = \"abacabadabacaba\",k = 26) == \"abacabadabacabc\"\n assert candidate(s = \"aabbccdd\",k = 6) == \"aabbccde\"\n assert candidate(s = \"zzzz\",k = 4) == \"\"\n assert candidate(s = \"aabbaabbaabb\",k = 6) == \"aabbaabbaabc\"\n assert candidate(s = \"abcde\",k = 5) == \"abcea\"\n assert candidate(s = \"mnopqrstuvw\",k = 22) == \"mnopqrstvab\"\n assert candidate(s = \"abcdexyzabcd\",k = 26) == \"abcdexyzabce\"\n assert candidate(s = \"abacabacabacaba\",k = 3) == \"abacabacabacabc\"\n assert candidate(s = \"abacabadabc\",k = 26) == \"abacabadabd\"\n assert candidate(s = \"xyzxyzxyzxyz\",k = 26) == \"xzabcabcabca\"\n assert candidate(s = \"abcbabcba\",k = 3) == \"abcbacbac\"\n assert candidate(s = \"abcdefghij\",k = 26) == \"abcdefghik\"\n assert candidate(s = \"abac\",k = 4) == \"abad\"\n assert candidate(s = \"abcabcabc\",k = 26) == \"abcabcabd\"\n assert candidate(s = \"abcba\",k = 3) == \"acbac\"\n assert candidate(s = \"abcdefghi\",k = 10) == \"abcdefghj\"\n assert candidate(s = \"aabbaa\",k = 6) == \"aabbac\"\n assert candidate(s = \"abcdefghi\",k = 9) == \"abcdefgia\"\n assert candidate(s = \"zyxcba\",k = 6) == \"zyxcbd\"\n assert candidate(s = \"mnopqrstuvwxyzz\",k = 26) == \"mnopqrstuvwxzab\"\n assert candidate(s = \"zzzzzzzzz\",k = 26) == \"\"\n assert candidate(s = \"aabbccddeeffgg\",k = 6) == \"aabbccddefabca\"\n assert candidate(s = \"abacabadabacaba\",k = 15) == \"abacabadabacabc\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxy\",k = 26) == \"abcdefghijklmnopqrstuvwxz\"\n assert candidate(s = \"abcdabc\",k = 26) == \"abcdabd\"\n assert candidate(s = \"fedcba\",k = 6) == \"fedcbd\"\n assert candidate(s = \"aabbccddeeffgg\",k = 10) == \"aabbccddeeffgh\"\n assert candidate(s = \"mnopqrstu\",k = 20) == \"mnopqrtab\"\n assert candidate(s = \"abcdefg\",k = 8) == \"abcdefh\"\n assert candidate(s = \"abababababab\",k = 2) == \"baababababab\"\n assert candidate(s = \"abcddcba\",k = 20) == \"abcddcbd\"\n assert candidate(s = \"abacaba\",k = 7) == \"abacabc\"\n assert candidate(s = \"abacabadabacaba\",k = 3) == \"abacabadabacabc\"\n assert candidate(s = \"abcdefghijklmnop\",k = 20) == \"abcdefghijklmnoq\"\n assert candidate(s = \"aabababacababaca\",k = 26) == \"aabababacababacb\"\n assert candidate(s = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhaaggeeffddccbb\",k = 26) == \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhaaggeeffddccbd\"\n assert candidate(s = \"abacabad\",k = 4) == \"abacabca\"\n assert candidate(s = \"acb\",k = 3) == \"bac\"\n assert candidate(s = \"zyxzyxzyx\",k = 26) == \"\"\n assert candidate(s = \"aabbccddeeff\",k = 26) == \"aabbccddeefg\"\n assert candidate(s = \"abcbac\",k = 26) == \"abcbad\"\n assert candidate(s = \"abcdefghijklmnop\",k = 16) == \"abcdefghijklmnpa\"\n assert candidate(s = \"abcabcabcabc\",k = 6) == \"abcabcabcabd\"\n assert candidate(s = \"abacaba\",k = 26) == \"abacabc\"\n assert candidate(s = \"abacbacbac\",k = 5) == \"abacbacbad\"\n assert candidate(s = \"abcdcba\",k = 5) == \"abcdcbd\"\n assert candidate(s = \"abcdefgabcdefg\",k = 26) == \"abcdefgabcdefh\"\n assert candidate(s = \"abcdabcdabcd\",k = 4) == \"abcdabcdabda\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 26) == \"zyxwvutsrqponmlkjihgfedcbd\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().smallestBeautifulString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String smallestBeautifulString(String s, int k) {", "container": "Solution", "callable": "smallestBeautifulString", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2670, "task_id": "find-the-distinct-difference-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array nums of length n.\nThe distinct difference array of nums is an array diff of length n such that diff[i] is equal to the number of distinct elements in the suffix nums[i + 1, ..., n - 1] subtracted from the number of distinct elements in the prefix nums[0, ..., i].\nReturn the distinct difference array of nums.\nNote that nums[i, ..., j] denotes the subarray of nums starting at index i and ending at index j inclusive. Particularly, if i > j then nums[i, ..., j] denotes an empty subarray.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5]\nOutput: [-3,-1,1,3,5]\nExplanation: For index i = 0, there is 1 element in the prefix and 4 distinct elements in the suffix. Thus, diff[0] = 1 - 4 = -3.\nFor index i = 1, there are 2 distinct elements in the prefix and 3 distinct elements in the suffix. Thus, diff[1] = 2 - 3 = -1.\nFor index i = 2, there are 3 distinct elements in the prefix and 2 distinct elements in the suffix. Thus, diff[2] = 3 - 2 = 1.\nFor index i = 3, there are 4 distinct elements in the prefix and 1 distinct element in the suffix. Thus, diff[3] = 4 - 1 = 3.\nFor index i = 4, there are 5 distinct elements in the prefix and no elements in the suffix. Thus, diff[4] = 5 - 0 = 5.\n\nExample 2:\n\nInput: nums = [3,2,3,4,2]\nOutput: [-2,-1,0,2,3]\nExplanation: For index i = 0, there is 1 element in the prefix and 3 distinct elements in the suffix. Thus, diff[0] = 1 - 3 = -2.\nFor index i = 1, there are 2 distinct elements in the prefix and 3 distinct elements in the suffix. Thus, diff[1] = 2 - 3 = -1.\nFor index i = 2, there are 2 distinct elements in the prefix and 2 distinct elements in the suffix. Thus, diff[2] = 2 - 2 = 0.\nFor index i = 3, there are 3 distinct elements in the prefix and 1 distinct element in the suffix. Thus, diff[3] = 3 - 1 = 2.\nFor index i = 4, there are 3 distinct elements in the prefix and no elements in the suffix. Thus, diff[4] = 3 - 0 = 3.\n\n \nConstraints:\n\n1 <= n == 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]) == [-3, -1, 1, 3, 5]\n assert candidate(nums = [10, 20, 10, 20, 10]) == [-1, 0, 0, 1, 2]\n assert candidate(nums = [1, 1, 2, 2, 3]) == [-2, -1, 0, 1, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-8, -6, -4, -2, 0, 2, 4, 6, 8, 10]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [50, 49, 48, 47, 46]) == [-3, -1, 1, 3, 5]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [-3, -1, 1, 3, 5]\n assert candidate(nums = [5, 5, 5, 5, 5]) == [0, 0, 0, 0, 1]\n assert candidate(nums = [42, 42, 42, 42, 42]) == [0, 0, 0, 0, 1]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [-3, -1, 1, 3, 5]\n assert candidate(nums = [1, 2, 2, 3, 3]) == [-1, 0, 1, 2, 3]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 1]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == [-8, -6, -4, -2, 0, 2, 4, 6, 8, 10]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [-8, -6, -4, -2, 0, 2, 4, 6, 8, 10]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [-2, -1, 0, 1, 1, 2, 3, 3, 3, 4]\n assert candidate(nums = [3, 2, 3, 4, 2]) == [-2, -1, 0, 2, 3]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == [-8, -6, -4, -2, 0, 2, 4, 6, 8, 10]\n assert candidate(nums = [1, 2, 3, 2, 1]) == [-2, -1, 1, 2, 3]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(nums = [1, 2, 1, 2, 1]) == [-1, 0, 0, 1, 2]\n assert candidate(nums = [50, 40, 30, 20, 10]) == [-3, -1, 1, 3, 5]\n assert candidate(nums = [34, 23, 12, 34, 56, 78, 90, 12, 34, 56]) == [-5, -3, -2, -2, -1, 1, 3, 4, 5, 6]\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [-13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(nums = [42, 13, 24, 35, 42, 13, 24, 35]) == [-3, -2, -1, 0, 1, 2, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 30, 20, 10, 30, 20, 10]) == [-2, -1, 0, 0, 0, 1, 2, 3]\n assert candidate(nums = [34, 23, 12, 45, 56, 78, 89, 90, 12, 23]) == [-6, -5, -4, -2, 0, 2, 4, 6, 7, 8]\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]) == [-2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5]) == [-4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == [-3, -3, -3, -2, -1, -1, -1, 0, 1, 1, 1, 2, 3, 3, 3, 4]\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == [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, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == [-2, -1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [-2, -2, -2, -2, -1, 0, 0, 0, 0, 1, 2, 2, 2, 2, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [-4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 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]) == [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, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [-13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == [-4, -3, -2, -1, 1, 2, 3, 4, 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]) == [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 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]) == [-28, -26, -24, -22, -20, -18, -16, -14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == [-2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 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, -4, -3, -3, -2, -2, -1, -1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 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, 4, 4, 5, 5, 5, 5, 5]) == [-4, -4, -4, -4, -3, -2, -2, -2, -2, -1, 0, 0, 0, 0, 1, 2, 2, 2, 2, 3, 4, 4, 4, 4, 5]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 1, 3, 2, 4, 5]) == [-9, -8, -7, -6, -5, -3, -1, 1, 3, 5, 6, 7, 8, 9, 10]\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]) == [-9, -9, -8, -7, -7, -6, -5, -5, -4, -3, -3, -2, -1, -1, 0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [-1, 0, 0, 0, 0, 0, 0, 0, 1, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1]) == [-4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [-13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60]) == [-5, -4, -3, -2, -1, 0, 1, 3, 4, 6]\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == [-3, -2, -1, 0, 0, 0, 0, 0, 1, 2, 3, 4]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == [-2, -1, 0, 0, 0, 0, 0, 1, 2, 3]\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60]) == [-5, -4, -3, -2, -1, 0, 1, 3, 4, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [-9, -8, -7, -6, -5, -3, -1, 1, 3, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == [-2, -1, 0, 0, 0, 0, 0, 0, 1, 2, 3]\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1, 4, 4, 3, 3, 2, 2, 1, 1, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [-4, -4, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 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, 1]) == [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 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]) == [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\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]) == [0, 0, 0, 0, 0, 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, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 3, 2, 3, 4, 3, 5, 6, 7, 8, 9]) == [-7, -6, -4, -4, -2, -1, 1, 3, 5, 7, 9]\n assert candidate(nums = [1, 3, 2, 3, 1, 4, 1, 3, 2, 3, 4, 2, 1, 3, 4, 2, 1, 3, 2, 4, 1]) == [-3, -2, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == [-8, -7, -6, -5, -4, -3, -2, -1, -1, -1, 0, 0, 2, 3, 3, 4, 5, 7, 8, 9]\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, 19]) == [-19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -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, 16, 17, 19, 20]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [-3, -3, -3, -3, -2, -1, -1, -1, -1, 0, 1, 1, 1, 1, 2, 3, 3, 3, 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]) == [-2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3]\n assert candidate(nums = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10]) == [-10, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 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]) == [-18, -16, -14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40]) == [-9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [-13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(nums = [42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21]) == [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3]) == [-4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == [-5, -4, -3, -2, -1, 0, 1, 3, 4, 6]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-8, -6, -4, -2, 0, 2, 4, 6, 8, 10]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == [-3, -3, -2, -1, -1, 0, 1, 1, 2, 3, 3, 4]\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]) == [-28, -26, -24, -22, -20, -18, -16, -14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-8, -6, -4, -2, 0, 2, 4, 6, 8, 10]\n assert candidate(nums = [50, 40, 30, 20, 10, 10, 20, 30, 40, 50]) == [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 40, 40, 50, 50]) == [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\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, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == [-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, 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(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-8, -6, -4, -2, 0, 2, 4, 6, 8, 10]\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [-4, -2, -2, 0, 0, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [-4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2, 3, 4, 5]) == [-4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [-4, -4, -3, -2, -2, -1, 0, 0, 1, 2, 2, 3, 4, 4, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [-4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [-4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == [-3, -3, -2, -1, -1, 0, 1, 1, 2, 3, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == [-4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 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]) == [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 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]) == [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [15, 15, 10, 10, 5, 5, 1, 1, 20, 20, 25, 25, 30, 30, 35, 35]) == [-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8]\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, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7]) == [-2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3]\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [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, 2, 3, 1, 2, 3, 1, 2, 3]) == [-2, -1, 0, 0, 0, 0, 1, 2, 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]) == [-4, -3, -2, -1, 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]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [-4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 9, 9, 9, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [-7, -7, -6, -5, -5, -4, -3, -3, -2, -1, -1, 0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [-9, -8, -7, -6, -5, -3, -1, 1, 3, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1]) == [-4, -3, -2, -2, -2, -1, 1, 2, 3, 4, 5]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().distinctDifferenceArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] distinctDifferenceArray(int[] nums) {", "container": "Solution", "callable": "distinctDifferenceArray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2672, "task_id": "number-of-adjacent-elements-with-the-same-color", "difficulty": "Medium", "problem_description": "You are given an integer n representing an array colors of length n where all elements are set to 0's meaning uncolored. You are also given a 2D integer array queries where queries[i] = [indexi, colori]. For the ith query:\n\nSet colors[indexi] to colori.\nCount adjacent pairs in colors set to the same color (regardless of colori).\n\nReturn an array answer of the same length as queries where answer[i] is the answer to the ith query.\n \nExample 1:\n\nInput: n = 4, queries = [[0,2],[1,2],[3,1],[1,1],[2,1]]\nOutput: [0,1,1,0,2]\nExplanation:\n\nInitially array colors = [0,0,0,0], where 0 denotes uncolored elements of the array.\nAfter the 1st query colors = [2,0,0,0]. The count of adjacent pairs with the same color is 0.\nAfter the 2nd query colors = [2,2,0,0]. The count of adjacent pairs with the same color is 1.\nAfter the 3rd query colors = [2,2,0,1]. The count of adjacent pairs with the same color is 1.\nAfter the 4th query colors = [2,1,0,1]. The count of adjacent pairs with the same color is 0.\nAfter the 5th query colors = [2,1,1,1]. The count of adjacent pairs with the same color is 2.\n\n\nExample 2:\n\nInput: n = 1, queries = [[0,100000]]\nOutput: [0]\nExplanation:\nAfter the 1st query colors = [100000]. The count of adjacent pairs with the same color is 0.\n\n \nConstraints:\n\n1 <= n <= 105\n1 <= queries.length <= 105\nqueries[i].length == 2\n0 <= indexi <= n - 1\n1 <=  colori <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,queries = [[0, 2], [1, 2], [2, 2]]) == [0, 1, 2]\n assert candidate(n = 1,queries = [[0, 100000]]) == [0]\n assert candidate(n = 10,queries = [[5, 3], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [8, 3], [9, 3]]) == [0, 1, 1, 2, 3, 4, 5, 6, 6, 7]\n assert candidate(n = 6,queries = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [0, 2]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 3,queries = [[0, 1], [1, 2], [2, 1], [1, 1]]) == [0, 0, 0, 2]\n assert candidate(n = 10,queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 3,queries = [[0, 1], [1, 2], [2, 3]]) == [0, 0, 0]\n assert candidate(n = 5,queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1]]) == [0, 1, 2, 3, 4]\n assert candidate(n = 4,queries = [[0, 2], [1, 2], [3, 1], [1, 1], [2, 1]]) == [0, 1, 1, 0, 2]\n assert candidate(n = 6,queries = [[0, 2], [1, 2], [2, 2], [3, 3], [4, 3], [5, 3]]) == [0, 1, 2, 2, 3, 4]\n assert candidate(n = 5,queries = [[0, 3], [1, 3], [1, 4], [2, 4], [3, 3], [4, 3], [0, 4], [1, 3]]) == [0, 1, 0, 1, 1, 2, 3, 1]\n assert candidate(n = 6,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [0, 6]]) == [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]\n assert candidate(n = 10,queries = [[0, 1], [1, 1], [2, 1], [3, 2], [4, 2], [5, 2], [6, 3], [7, 3], [8, 3], [9, 3]]) == [0, 1, 2, 2, 3, 4, 4, 5, 6, 7]\n assert candidate(n = 7,queries = [[0, 3], [1, 3], [2, 4], [3, 4], [4, 3], [5, 4], [6, 3]]) == [0, 1, 1, 2, 2, 2, 2]\n assert candidate(n = 5,queries = [[0, 1], [1, 1], [2, 2], [1, 2], [2, 1], [1, 1], [2, 2], [1, 2], [0, 1], [4, 1]]) == [0, 1, 1, 1, 0, 2, 1, 1, 1, 1]\n assert candidate(n = 10,queries = [[0, 1], [1, 2], [2, 1], [1, 1], [2, 1], [3, 2], [4, 2], [3, 2], [4, 2], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [0, 0, 0, 2, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7]\n assert candidate(n = 50000,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 10,queries = [[0, 100000], [1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000], [6, 100000], [7, 100000], [8, 100000], [9, 100000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 12,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 1]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 6,queries = [[0, 3], [1, 3], [2, 4], [3, 4], [4, 3], [5, 4], [2, 3], [3, 3], [4, 4], [5, 3]]) == [0, 1, 1, 2, 2, 2, 2, 4, 4, 3]\n assert candidate(n = 5,queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1]]) == [0, 1, 2, 3, 4, 4, 4, 4, 4, 4]\n assert candidate(n = 6,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(n = 20,queries = [[0, 5], [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], [16, 5], [17, 5], [18, 5], [19, 5]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 10,queries = [[0, 1], [9, 1], [0, 2], [9, 2], [4, 3], [5, 3], [4, 4], [5, 4], [3, 5], [6, 5]]) == [0, 0, 0, 0, 0, 1, 0, 1, 1, 1]\n assert candidate(n = 15,queries = [[0, 3], [1, 3], [2, 3], [3, 3], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 4], [10, 4], [11, 4], [12, 4], [13, 4], [14, 4]]) == [0, 1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(n = 20,queries = [[0, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 1], [11, 1], [12, 2], [13, 3], [14, 4], [15, 5], [16, 6], [17, 7], [18, 8], [19, 9]]) == [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 20,queries = [[0, 9], [1, 9], [2, 10], [3, 10], [4, 9], [5, 10], [6, 9], [7, 10], [8, 9], [9, 10], [10, 9], [11, 10], [12, 9], [13, 10], [14, 9], [15, 10], [16, 9], [17, 10], [18, 9], [19, 10]]) == [0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 10,queries = [[0, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [8, 9], [7, 9], [6, 9], [5, 9], [4, 9], [3, 9], [2, 9], [1, 9], [0, 9]]) == [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9]\n assert candidate(n = 7,queries = [[0, 2], [1, 2], [2, 3], [3, 2], [4, 2], [5, 3], [6, 2]]) == [0, 1, 1, 1, 2, 2, 2]\n assert candidate(n = 1000,queries = [[500, 1], [501, 1], [502, 1], [500, 2], [501, 2], [502, 2], [500, 1], [501, 1], [502, 1]]) == [0, 1, 2, 1, 1, 2, 1, 1, 2]\n assert candidate(n = 6,queries = [[0, 1], [1, 1], [2, 2], [3, 2], [4, 2], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == [0, 1, 1, 2, 3, 3, 3, 3, 5, 5, 5, 3, 3, 3, 3, 4]\n assert candidate(n = 6,queries = [[0, 3], [1, 3], [2, 3], [3, 4], [4, 4], [5, 4], [2, 3], [3, 3], [4, 3]]) == [0, 1, 2, 2, 3, 4, 4, 4, 4]\n assert candidate(n = 5,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(n = 7,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(n = 5,queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2]]) == [0, 1, 2, 3, 4, 3, 3, 3, 3, 4]\n assert candidate(n = 20,queries = [[0, 1], [1, 1], [2, 2], [3, 2], [4, 1], [5, 1], [6, 2], [7, 2], [8, 1], [9, 1], [10, 3], [11, 3], [12, 4], [13, 4], [14, 5], [15, 5], [16, 3], [17, 3], [18, 4], [19, 4]]) == [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]\n assert candidate(n = 10,queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [3, 2], [2, 2], [1, 2], [0, 2], [5, 2]]) == [0, 1, 2, 3, 4, 2, 2, 2, 3, 3]\n assert candidate(n = 5,queries = [[0, 1], [1, 2], [2, 1], [3, 2], [4, 1], [0, 2], [1, 1], [2, 2], [3, 1], [4, 2]]) == [0, 0, 0, 0, 0, 1, 1, 1, 1, 0]\n assert candidate(n = 10,queries = [[0, 1], [1, 1], [2, 2], [3, 2], [4, 3], [5, 4], [6, 4], [7, 3], [8, 2], [9, 1]]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3]\n assert candidate(n = 9,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100000,queries = [[0, 100000], [1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000], [6, 100000], [7, 100000], [8, 100000], [9, 100000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,queries = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 10,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,queries = [[0, 2], [1, 3], [2, 2], [3, 2], [4, 3], [5, 3], [6, 2], [7, 2], [2, 3], [3, 3], [4, 2], [5, 2]]) == [0, 0, 0, 1, 1, 2, 2, 3, 3, 5, 3, 5]\n assert candidate(n = 5,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1]]) == [0, 0, 0, 0, 0, 1, 2, 4, 4]\n assert candidate(n = 10,queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 5,queries = [[0, 1], [1, 2], [1, 3], [2, 2], [2, 3]]) == [0, 0, 0, 0, 1]\n assert candidate(n = 10,queries = [[0, 5], [1, 5], [2, 6], [3, 6], [4, 6], [5, 7], [6, 7], [7, 7], [8, 8], [9, 8], [5, 6]]) == [0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 6]\n assert candidate(n = 7,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1]]) == [0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 6]\n assert candidate(n = 100,queries = [[0, 1], [99, 2], [49, 3], [50, 3], [48, 3], [51, 3], [25, 4], [75, 4], [50, 5], [49, 5]]) == [0, 0, 0, 1, 2, 3, 3, 3, 1, 1]\n assert candidate(n = 6,queries = [[0, 2], [1, 2], [2, 3], [3, 3], [4, 2], [5, 2]]) == [0, 1, 1, 2, 2, 3]\n assert candidate(n = 5,queries = [[0, 1], [1, 1], [2, 1], [3, 2], [4, 2], [3, 1], [4, 1]]) == [0, 1, 2, 2, 3, 3, 4]\n assert candidate(n = 7,queries = [[0, 1], [1, 1], [2, 2], [3, 2], [4, 3], [5, 3], [6, 3], [1, 2], [2, 2], [3, 2], [4, 4], [5, 4], [6, 4]]) == [0, 1, 1, 2, 2, 3, 4, 4, 4, 4, 3, 3, 4]\n assert candidate(n = 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]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 5,queries = [[0, 1], [1, 1], [2, 1], [1, 2], [1, 1]]) == [0, 1, 2, 0, 2]\n assert candidate(n = 9,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 1], [1, 2], [2, 3], [3, 4]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 10,queries = [[0, 1], [1, 2], [2, 1], [3, 2], [4, 1], [5, 2], [6, 1], [7, 2], [8, 1], [9, 2]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,queries = [[0, 1], [1, 2], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1]]) == [0, 0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 15,queries = [[0, 7], [1, 7], [2, 8], [3, 8], [4, 7], [5, 8], [6, 7], [7, 8], [8, 7], [9, 8], [10, 7], [11, 8], [12, 7], [13, 8], [14, 7]]) == [0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 7,queries = [[0, 3], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [0, 4], [1, 4], [2, 4]]) == [0, 1, 2, 3, 4, 5, 6, 5, 5, 5]\n assert candidate(n = 15,queries = [[0, 3], [1, 3], [2, 3], [3, 3], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 4], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5]]) == [0, 1, 2, 3, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12]\n assert candidate(n = 20,queries = [[0, 1], [2, 1], [4, 1], [6, 1], [8, 1], [10, 1], [12, 1], [14, 1], [16, 1], [18, 1], [19, 1], [19, 2], [18, 2], [17, 2], [16, 2], [15, 2], [14, 2], [13, 2], [12, 2], [11, 2]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(n = 5,queries = [[0, 1], [1, 1], [2, 2], [3, 2], [4, 2], [1, 2], [2, 2]]) == [0, 1, 1, 2, 3, 3, 3]\n assert candidate(n = 1000,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]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 5,queries = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(n = 10,queries = [[0, 10], [1, 10], [2, 20], [3, 20], [4, 10], [5, 10], [6, 20], [7, 20], [8, 10], [9, 10]]) == [0, 1, 1, 2, 2, 3, 3, 4, 4, 5]\n assert candidate(n = 5,queries = [[0, 1], [1, 2], [2, 1], [1, 1], [2, 1], [3, 2], [4, 2], [3, 2], [4, 2]]) == [0, 0, 0, 2, 2, 2, 3, 3, 3]\n assert candidate(n = 8,queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 2], [5, 2], [6, 2], [7, 2], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1]]) == [0, 1, 2, 3, 3, 4, 5, 6, 6, 6, 6, 6, 7]\n assert candidate(n = 20,queries = [[0, 1], [1, 2], [2, 1], [3, 2], [4, 1], [5, 2], [6, 1], [7, 2], [8, 1], [9, 2], [10, 1], [11, 2], [12, 1], [13, 2], [14, 1], [15, 2], [16, 1], [17, 2], [18, 1], [19, 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 = 8,queries = [[0, 1], [1, 1], [2, 1], [3, 2], [4, 2], [5, 1], [6, 1], [7, 2]]) == [0, 1, 2, 2, 3, 3, 4, 4]\n assert candidate(n = 10,queries = [[0, 1], [2, 1], [4, 1], [6, 1], [8, 1], [1, 2], [3, 2], [5, 2], [7, 2], [9, 2]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 10,queries = [[0, 1], [1, 1], [2, 2], [3, 2], [4, 1], [5, 1], [6, 2], [7, 2], [8, 1], [9, 1]]) == [0, 1, 1, 2, 2, 3, 3, 4, 4, 5]\n assert candidate(n = 15,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], [14, 2], [13, 2], [12, 2], [11, 2], [10, 2], [9, 2], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14]\n assert candidate(n = 7,queries = [[0, 2], [1, 2], [2, 3], [3, 3], [4, 3], [5, 2], [6, 2]]) == [0, 1, 1, 2, 3, 3, 4]\n"}, "metadata": {"canonical_parameter_names": ["n", "queries"], "leetcode_dataset_entry_point": "Solution().colorTheArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] colorTheArray(int n, int[][] queries) {", "container": "Solution", "callable": "colorTheArray", "parameters": [{"name": "n", "type": "int"}, {"name": "queries", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2673, "task_id": "make-costs-of-paths-equal-in-a-binary-tree", "difficulty": "Medium", "problem_description": "You are given an integer n representing the number of nodes in a perfect binary tree consisting of nodes numbered from 1 to n. The root of the tree is node 1 and each node i in the tree has two children where the left child is the node 2 * i and the right child is 2 * i + 1.\nEach node in the tree also has a cost represented by a given 0-indexed integer array cost of size n where cost[i] is the cost of node i + 1. You are allowed to increment the cost of any node by 1 any number of times.\nReturn the minimum number of increments you need to make the cost of paths from the root to each leaf node equal.\nNote:\n\nA perfect binary tree is a tree where each node, except the leaf nodes, has exactly 2 children.\nThe cost of a path is the sum of costs of nodes in the path.\n\n \nExample 1:\n\n\nInput: n = 7, cost = [1,5,2,2,3,3,1]\nOutput: 6\nExplanation: We can do the following increments:\n- Increase the cost of node 4 one time.\n- Increase the cost of node 3 three times.\n- Increase the cost of node 7 two times.\nEach path from the root to a leaf will have a total cost of 9.\nThe total increments we did is 1 + 3 + 2 = 6.\nIt can be shown that this is the minimum answer we can achieve.\n\nExample 2:\n\n\nInput: n = 3, cost = [5,3,3]\nOutput: 0\nExplanation: The two paths already have equal total costs, so no increments are needed.\n\n \nConstraints:\n\n3 <= n <= 105\nn + 1 is a power of 2\ncost.length == n\n1 <= cost[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 31,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]) == 0\n assert candidate(n = 7,cost = [1, 5, 2, 2, 3, 3, 1]) == 6\n assert candidate(n = 31,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, 31]) == 49\n assert candidate(n = 15,cost = [1, 3, 2, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == 11\n assert candidate(n = 15,cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 17\n assert candidate(n = 3,cost = [5, 3, 3]) == 0\n assert candidate(n = 31,cost = [1, 3, 2, 2, 3, 3, 1, 5, 4, 4, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3]) == 16\n assert candidate(n = 7,cost = [10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(n = 7,cost = [10, 9, 9, 8, 8, 8, 8]) == 0\n assert candidate(n = 31,cost = [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000, 1, 10]) == 127494\n assert candidate(n = 31,cost = [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(n = 31,cost = [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]) == 32\n assert candidate(n = 63,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(n = 15,cost = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 21\n assert candidate(n = 31,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, 270, 280, 290, 300, 310]) == 490\n assert candidate(n = 7,cost = [1000, 200, 300, 400, 500, 600, 700]) == 500\n assert candidate(n = 15,cost = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 21\n assert candidate(n = 15,cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 17\n assert candidate(n = 63,cost = [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]) == 0\n assert candidate(n = 31,cost = [1, 10, 100, 1000, 10000, 9, 99, 999, 9999, 8, 88, 888, 8888, 7, 77, 777, 7777, 6, 66, 666, 6666, 5, 55, 555, 5555, 4, 44, 444, 4444, 3, 33, 333, 3333, 2, 22, 222, 2222, 1, 11, 111, 1111]) == 54473\n assert candidate(n = 31,cost = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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(n = 63,cost = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 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]) == 106\n assert candidate(n = 255,cost = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980, 9979, 9978, 9977, 9976, 9975, 9974, 9973, 9972, 9971, 9970, 9969, 9968, 9967, 9966, 9965, 9964, 9963, 9962, 9961, 9960, 9959, 9958, 9957, 9956, 9955, 9954, 9953, 9952, 9951, 9950, 9949, 9948, 9947, 9946, 9945, 9944, 9943, 9942, 9941, 9940, 9939, 9938, 9937, 9936, 9935, 9934, 9933, 9932, 9931, 9930, 9929, 9928, 9927, 9926, 9925, 9924, 9923, 9922, 9921, 9920, 9919, 9918, 9917, 9916, 9915, 9914, 9913, 9912, 9911, 9910, 9909, 9908, 9907, 9906, 9905, 9904, 9903, 9902, 9901, 9900, 9899, 9898, 9897, 9896, 9895, 9894, 9893, 9892, 9891, 9890, 9889, 9888, 9887, 9886, 9885, 9884, 9883, 9882, 9881, 9880, 9879, 9878, 9877, 9876, 9875, 9874, 9873, 9872, 9871, 9870, 9869, 9868, 9867, 9866, 9865, 9864, 9863, 9862, 9861, 9860, 9859, 9858, 9857, 9856, 9855, 9854, 9853, 9852, 9851, 9850, 9849, 9848, 9847, 9846, 9845, 9844, 9843, 9842, 9841, 9840, 9839, 9838, 9837, 9836, 9835, 9834, 9833, 9832, 9831, 9830, 9829, 9828, 9827, 9826, 9825, 9824, 9823, 9822, 9821, 9820, 9819, 9818, 9817, 9816, 9815, 9814, 9813, 9812, 9811, 9810, 9809, 9808, 9807, 9806, 9805, 9804, 9803, 9802, 9801, 9800, 9799, 9798, 9797, 9796, 9795, 9794, 9793, 9792, 9791, 9790, 9789, 9788, 9787, 9786, 9785, 9784, 9783, 9782, 9781, 9780, 9779, 9778, 9777, 9776, 9775, 9774, 9773, 9772, 9771, 9770, 9769, 9768, 9767, 9766, 9765, 9764, 9763, 9762, 9761, 9760, 9759, 9758, 9757, 9756, 9755, 9754, 9753, 9752, 9751, 9750, 9749, 9748, 9747, 9746, 9745, 9744, 9743, 9742, 9741, 9740, 9739, 9738, 9737, 9736, 9735, 9734, 9733, 9732, 9731, 9730, 9729, 9728, 9727, 9726, 9725, 9724, 9723, 9722, 9721, 9720, 9719, 9718, 9717, 9716, 9715, 9714, 9713, 9712, 9711, 9710, 9709, 9708, 9707, 9706, 9705, 9704, 9703, 9702, 9701, 9700, 9699, 9698, 9697, 9696, 9695, 9694, 9693, 9692, 9691, 9690, 9689, 9688, 9687, 9686, 9685, 9684, 9683, 9682, 9681, 9680, 9679, 9678, 9677, 9676, 9675, 9674, 9673, 9672, 9671, 9670, 9669, 9668, 9667, 9666, 9665, 9664, 9663, 9662, 9661, 9660, 9659, 9658, 9657, 9656, 9655, 9654, 9653, 9652, 9651, 9650, 9649, 9648, 9647, 9646, 9645, 9644, 9643, 9642, 9641, 9640, 9639, 9638, 9637, 9636, 9635, 9634, 9633, 9632, 9631, 9630, 9629, 9628, 9627, 9626, 9625, 9624, 9623, 9622, 9621, 9620, 9619, 9618, 9617, 9616, 9615, 9614, 9613, 9612, 9611, 9610, 9609, 9608, 9607, 9606, 9605, 9604, 9603, 9602, 9601, 9600]) == 769\n assert candidate(n = 63,cost = [1, 10, 100, 1000, 10000, 100000, 1000000, 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]) == 1899214\n assert candidate(n = 63,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, 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]) == 129\n assert candidate(n = 15,cost = [100, 10, 50, 20, 30, 60, 40, 70, 80, 90, 100, 110, 120, 130, 140]) == 160\n assert candidate(n = 15,cost = [1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17]) == 17\n assert candidate(n = 7,cost = [100, 200, 300, 400, 500, 600, 700]) == 500\n assert candidate(n = 31,cost = [10, 10, 10, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 0\n assert candidate(n = 15,cost = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 10\n assert candidate(n = 127,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(n = 127,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, 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, 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]) == 321\n assert candidate(n = 63,cost = [1, 2, 2, 3, 3, 3, 3, 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, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(n = 63,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(n = 63,cost = [1, 10, 100, 1000, 10000, 100000, 1000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 1, 10, 100, 1000, 10000, 100000, 1000000]) == 23474133\n assert candidate(n = 63,cost = [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]) == 129\n assert candidate(n = 15,cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 170\n assert candidate(n = 15,cost = [1, 3, 2, 4, 5, 6, 2, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(n = 31,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]) == 0\n assert candidate(n = 15,cost = [1, 3, 2, 4, 6, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 16\n assert candidate(n = 31,cost = [1, 5, 2, 2, 3, 3, 1, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 10\n assert candidate(n = 15,cost = [1, 3, 2, 1, 3, 2, 1, 2, 3, 1, 4, 2, 3, 4, 5]) == 12\n assert candidate(n = 15,cost = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(n = 31,cost = [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]) == 49\n assert candidate(n = 63,cost = [500, 250, 250, 125, 125, 125, 125, 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]) == 124\n assert candidate(n = 15,cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(n = 127,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, 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, 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]) == 321\n assert candidate(n = 63,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, 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]) == 1290\n assert candidate(n = 31,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, 31]) == 49\n assert candidate(n = 3,cost = [100, 99, 99]) == 0\n"}, "metadata": {"canonical_parameter_names": ["n", "cost"], "leetcode_dataset_entry_point": "Solution().minIncrements", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minIncrements(int n, int[] cost) {", "container": "Solution", "callable": "minIncrements", "parameters": [{"name": "n", "type": "int"}, {"name": "cost", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2678, "task_id": "number-of-senior-citizens", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array of strings details. Each element of details provides information about a given passenger compressed into a string of length 15. The system is such that:\n\nThe first ten characters consist of the phone number of passengers.\nThe next character denotes the gender of the person.\nThe following two characters are used to indicate the age of the person.\nThe last two characters determine the seat allotted to that person.\n\nReturn the number of passengers who are strictly more than 60 years old.\n \nExample 1:\n\nInput: details = [\"7868190130M7522\",\"5303914400F9211\",\"9273338290F4010\"]\nOutput: 2\nExplanation: The passengers at indices 0, 1, and 2 have ages 75, 92, and 40. Thus, there are 2 people who are over 60 years old.\n\nExample 2:\n\nInput: details = [\"1313579440F2036\",\"2921522980M5644\"]\nOutput: 0\nExplanation: None of the passengers are older than 60.\n\n \nConstraints:\n\n1 <= details.length <= 100\ndetails[i].length == 15\ndetails[i] consists of digits from '0' to '9'.\ndetails[i][10] is either 'M' or 'F' or 'O'.\nThe phone numbers and seat numbers of the passengers are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(details = ['0000000000M5500', '1111111111F5999', '2222222222O6100']) == 1\n assert candidate(details = ['1234567890M5999', '0987654321F6000']) == 0\n assert candidate(details = ['1111111111M5999', '2222222222F6000', '3333333333M6001']) == 0\n assert candidate(details = ['1234567890M6100', '0987654321F6501', '1122334455O6602']) == 3\n assert candidate(details = ['1234567890M6100', '0987654321F6200', '1122334455O6300']) == 3\n assert candidate(details = ['7868190130M7522', '5303914400F9211', '9273338290F4010']) == 2\n assert candidate(details = ['1111111111F5999', '2222222222M6000', '3333333333F6001']) == 0\n assert candidate(details = ['0000000000M5999', '1111111111F6000', '2222222222O6001']) == 0\n assert candidate(details = ['1234567890M6101', '0987654321F6202', '1122334455O6303']) == 3\n assert candidate(details = ['8473928467M6585', '3748293748F6143', '9374583947M8921', '2937458394F7823']) == 4\n assert candidate(details = ['8456123450M6112', '1234567890F6213', '0987654321O6314']) == 3\n assert candidate(details = ['1313579440F2036', '2921522980M5644']) == 0\n assert candidate(details = ['1234567890M6000', '0987654321F6101', '9876543210M6202', '8765432109F6303', '7654321098O6404', '6543210987M6505', '5432109876F6606', '4321098765O6707']) == 7\n assert candidate(details = ['1010101010M6011', '2020202020F6022', '3030303030O6033', '4040404040M6044', '5050505050F6055', '6060606060O6066', '7070707070M6077', '8080808080F6088', '9090909090O6099']) == 0\n assert candidate(details = ['9876543210F6101', '1111111111M6202', '2222222222O6303', '3333333333F6404', '4444444444M6505', '5555555555O6606', '6666666666F6707', '7777777777M6808', '8888888888O6909', '9999999999F7010']) == 10\n assert candidate(details = ['1111111111M4545', '2222222222F4949', '3333333333O5555', '4444444444M5959', '5555555555F6060', '6666666666O6161', '7777777777M6262', '8888888888F6363', '9999999999O6464', '0000000000M6565']) == 5\n assert candidate(details = ['9876543210F6512', '1234567890M6134', '0987654321O6600', '1122334455F5999', '5566778899M6245']) == 4\n assert candidate(details = ['9876543210F2021', '1234567890M6522', '5555555555O6623', '1111111111M6724']) == 3\n assert candidate(details = ['1234567890M5999', '0987654321F5998', '1122334455O5997', '2233445566M5996', '3344556677F5995', '4455667788O5994', '5566778899M5993', '6677889900F5992', '7788990011O5991', '8899001122M6000']) == 0\n assert candidate(details = ['1010101010F2011', '2020202020M2112', '3030303030O2213', '4040404040F2314', '5050505050M7215', '6060606060O7316']) == 2\n assert candidate(details = ['1098765432F6500', '2109876543M6601', '3210987654F6702', '4321098765M6803', '5432109876F6904']) == 5\n assert candidate(details = ['9876543210F7007', '8765432109M7108', '7654321098F7209', '6543210987M7310', '5432109876F7411', '4321098765O7512', '3210987654M7613', '2109876543F7714', '1098765432O7815']) == 9\n assert candidate(details = ['1111111111M5999', '2222222222F6000', '3333333333O6001', '4444444444M6002', '5555555555F6003', '6666666666O6004', '7777777777M6005', '8888888888F6006', '9999999999O6007', '0000000000M6008', '1111111111F6009', '2222222222O6010', '3333333333M6011', '4444444444F6012', '5555555555O6013', '6666666666M6014', '7777777777F6015', '8888888888O6016', '9999999999M6017', '0000000000F6018', '1111111111O6019']) == 0\n assert candidate(details = ['1234567890M5500', '0987654321F6600', '1122334455O6700', '2233445566M6800', '3344556677F6900', '4455667788O7000', '5566778899M7100', '6677889900F7200', '7788990011O7300', '8899001122M7400', '9900112233F7500', '0011223344O7600', '1122334455M7700', '2233445566F7800', '3344556677O7900']) == 14\n assert candidate(details = ['1234567890M6000', '0987654321F6001', '1122334455O6002', '2233445566M6003', '3344556677F6004', '4455667788O6005', '5566778899M6006', '6677889900F6007', '7788990011O6008', '8899001122M6009', '9900112233F6010']) == 0\n assert candidate(details = ['1234567890M5999', '0987654321F6101', '1122334455O7522', '2233445566M8000', '3344556677F9001']) == 4\n assert candidate(details = ['2222222222M6000', '3333333333F6001', '4444444444M5999', '5555555555O7000', '6666666666F7101']) == 2\n assert candidate(details = ['1122334455M5500', '2233445566F5601', '3344556677M5702', '4455667788F5803', '5566778899M5904', '6677889900F6005', '7788990011O6106', '8899001122M6207', '9900112233F6308', '0011223344O6409', '1122334455M6510', '2233445566F6611', '3344556677M6712', '4455667788F6813', '5566778899O6914']) == 9\n assert candidate(details = ['1234567890M5999', '0987654321F6000', '9876543210M6101', '8765432109F6202', '7654321098O6303', '6543210987M6404', '5432109876F6505', '4321098765O6606', '3210987654M6707', '2109876543F6808', '1098765432O6909', '0987654321M7010']) == 10\n assert candidate(details = ['1111111111F5555', '2222222222F5656', '3333333333F5757', '4444444444F5858', '5555555555F5959', '6666666666M6161', '7777777777M6262', '8888888888M6363', '9999999999M6464', '0000000000M6565', '1234567890M6666', '0987654321F6767', '1122334455O6868', '2233445566M6969', '3344556677F7070']) == 10\n assert candidate(details = ['9012345678M6060', '8012345678F6161', '7012345678M6262', '6012345678F6363', '5012345678O6464', '4012345678M6565', '3012345678F6666', '2012345678O6767', '1012345678M6868', '0012345678F6969', '9112345678O7070', '8112345678M7171', '7112345678F7272', '6112345678O7373', '5112345678M7474', '4112345678F7575', '3112345678O7676', '2112345678M7777', '1112345678F7878', '0112345678O7979']) == 19\n assert candidate(details = ['1010101010M6222', '2020202020F6333', '3030303030O6444', '4040404040F6555', '5050505050M6666']) == 5\n assert candidate(details = ['1111111111F6001', '2222222222M6002', '3333333333F6003', '4444444444O6004', '5555555555M6005', '6666666666F6006', '7777777777O6007', '8888888888M6008', '9999999999F6009']) == 0\n assert candidate(details = ['1234567890M5501', '0987654321F6502', '1122334455O7003', '2468013579F6204', '9753108642M6805']) == 4\n assert candidate(details = ['1111111111F6111', '2222222222M6222', '3333333333F6333', '4444444444O6444', '5555555555M6555', '6666666666F6666']) == 6\n assert candidate(details = ['1111111111F5999', '2222222222M6000', '3333333333F6001', '4444444444O6002', '5555555555M6003', '6666666666F6004', '7777777777O6005']) == 0\n assert candidate(details = ['1111111111M5999', '2222222222M6000', '3333333333F6001', '4444444444M6202', '5555555555F6303', '6666666666O6404', '7777777777M6505', '8888888888F6606', '9999999999O6707']) == 6\n assert candidate(details = ['1212121212M6777', '2121212121F6888', '3131313131O6999', '4141414141F7000', '5151515151M7111']) == 5\n assert candidate(details = ['6677889900F6060', '7788990011M6161', '8899001122O6262', '9900112233F6363', '0011223344M6464']) == 4\n assert candidate(details = ['1111111111F5022', '2222222222M6133', '3333333333O6244', '4444444444M6355', '5555555555F6466', '6666666666M6577', '7777777777F6688', '8888888888O6799', '9999999999M6800', '0000000000F6911']) == 9\n assert candidate(details = ['8888888888M7025', '7777777777F6524', '6666666666O7123', '5555555555M6322', '4444444444F6021']) == 4\n assert candidate(details = ['5432109876O6550', '6543210987F7000', '7654321098M7450', '8765432109F7500', '9876543210O7550', '0987654321M7600', '1098765432F7650', '2109876543O7700', '3210987654M7750', '4321098765F7800', '5432109876O7850']) == 11\n assert candidate(details = ['1111111111F5999', '2222222222M6000', '3333333333F6001', '4444444444M6101', '5555555555F6202', '6666666666O6303', '7777777777M6404', '8888888888F6505', '9999999999O6606']) == 6\n assert candidate(details = ['1111111111M6522', '2222222222F6633', '3333333333O6744', '4444444444M6855', '5555555555F6966']) == 5\n assert candidate(details = ['1111111111M7101', '2222222222M7202', '3333333333M7303', '4444444444M7404', '5555555555M7505', '6666666666M7606', '7777777777M7707', '8888888888M7808', '9999999999M7909', '0000000000F8080', '1234567890F8181', '0987654321F8282', '1122334455O8383', '2233445566M8484', '3344556677F8585', '4455667788M8686', '5566778899F8787', '6677889900O8888', '7788990011M8989', '8899001122F9090']) == 20\n assert candidate(details = ['0000000000F6000', '9999999999M6100', '1111111111O6001', '2222222222F5999', '3333333333M6222']) == 2\n assert candidate(details = ['9876543210M5959', '8765432109F5858', '7654321098O5757', '6543210987M5656', '5432109876F5555', '4321098765M5454', '3210987654F5353', '2109876543M5252', '1098765432F5151', '0987654321O5050']) == 0\n assert candidate(details = ['1313579440F6000', '2921522980M5999', '9876543210F7000', '0123456789M6101', '1122334455O6202']) == 3\n assert candidate(details = ['1111111111F5899', '2222222222M5900', '3333333333F6001', '4444444444O6102', '5555555555M6203', '6666666666F6304', '7777777777O6405', '8888888888M6506', '9999999999F6607', '0000000000O6708']) == 7\n assert candidate(details = ['1122334455F6767', '9988776655M6868', '4433221100F5555', '6655443322M6363', '7766554433O6464']) == 4\n assert candidate(details = ['1111111111M7000', '2222222222F6000', '3333333333F6000', '4444444444F6000', '5555555555F6000', '6666666666F6000', '7777777777F6000', '8888888888F6000', '9999999999F6000', '0000000000F6000']) == 1\n assert candidate(details = ['1231231231F5001', '3213213213M6702', '5555555555O7003', '4444444444F5504', '6666666666M5705', '7777777777O5806', '8888888888F5907', '9999999999M6008', '0000000000O6109', '1111111111F6210', '2222222222M6311', '3333333333O6412', '4444444444F6513', '5555555555M6614', '6666666666O6715']) == 9\n assert candidate(details = ['1234567890M6501', '0987654321F6402', '9876543210M6303', '8765432109F6204', '7654321098O6105', '6543210987M6006']) == 5\n assert candidate(details = ['1111111111M6500', '2222222222F7001', '3333333333O6102', '4444444444M5999', '5555555555F6603']) == 4\n assert candidate(details = ['5555555555M7000', '6666666666F7111', '7777777777O7222', '8888888888M7333', '9999999999F7444']) == 5\n assert candidate(details = ['8888888888F7222', '7777777777M7333', '6666666666O7444', '5555555555F7555', '4444444444M7666']) == 5\n assert candidate(details = ['1234567890M6111', '0987654321F6222', '1122334455O6333', '2233445566M6444', '3344556677F6555', '4455667788O6666', '5566778899M6777']) == 7\n assert candidate(details = ['0000000000F6010', '1111111111M6011', '2222222222F6012', '3333333333O6013', '4444444444M6014', '5555555555F6015', '6666666666O6016', '7777777777M6017', '8888888888F6018', '9999999999O6019']) == 0\n assert candidate(details = ['1122334455F7890', '2233445566M7901', '3344556677O8012', '4455667788F8123', '5566778899M8234']) == 5\n assert candidate(details = ['1234567890M6060', '0987654321F6161', '1122334455O6262', '2468013579F6363', '9753108642M6464', '8642097531F6565', '0864209753M6666']) == 6\n assert candidate(details = ['1111111111F5999', '2222222222M6000', '3333333333F6101', '4444444444M6202', '5555555555F6303', '6666666666M6404', '7777777777F6505', '8888888888M6606', '9999999999F6707', '0000000000M6808']) == 8\n assert candidate(details = ['1234567890M4500', '0987654321F5501', '1122334455O6502', '2233445566M7503', '3344556677F8504', '4455667788O9505']) == 4\n assert candidate(details = ['2222222222F7345', '1111111111M7456', '3333333333O7567', '4444444444F7678', '5555555555M7789']) == 5\n assert candidate(details = ['9876543210M7220', '8765432109F7521', '7654321098O7822', '6543210987M8023']) == 4\n assert candidate(details = ['1111111111M6501', '2222222222F6602', '3333333333O6703', '4444444444M6804', '5555555555F6905']) == 5\n assert candidate(details = ['1111111111F6000', '2222222222M6001', '3333333333O6002', '4444444444F6003', '5555555555M6004', '6666666666O6005', '7777777777F6006', '8888888888M6007', '9999999999O6008', '0000000000F6009']) == 0\n assert candidate(details = ['1234567890M4501', '0987654321F5502', '1122334455O6003', '2233445566M6104', '3344556677F6205', '4455667788O6306', '5566778899M6407', '6677889900F6508', '7788990011O6609', '8899001122M6710', '9900112233F6811']) == 8\n assert candidate(details = ['1234567890M6000', '0987654321F6001', '9876543210M6002', '8765432109F6003', '7654321098O6004', '6543210987M6005', '5432109876F6006', '4321098765O6007', '3210987654M6008', '2109876543F6009', '1098765432O6010', '0987654321M6011', '9876543210F6012', '8765432109O6013', '7654321098M6014', '6543210987F6015', '5432109876O6016', '4321098765M6017', '3210987654F6018', '2109876543O6019']) == 0\n assert candidate(details = ['0000000000M5999', '1111111111F6000', '2222222222M6101', '3333333333F6202', '4444444444O6303', '5555555555M6404', '6666666666F6505', '7777777777O6606', '8888888888M6707', '9999999999F6808', '0000000000O6909', '1111111111M7010', '2222222222F7111', '3333333333O7212', '4444444444M7313', '5555555555F7414', '6666666666O7515', '7777777777M7616', '8888888888F7717', '9999999999O7818']) == 18\n assert candidate(details = ['0000000000M5999', '0000000001F6000', '0000000002M6101', '0000000003F6202', '0000000004O6303', '0000000005M6404', '0000000006F6505', '0000000007O6606', '0000000008M6707', '0000000009F6808', '0000000010O6909', '0000000011M7010', '0000000012F7111', '0000000013O7212', '0000000014M7313', '0000000015F7414', '0000000016O7515', '0000000017M7616', '0000000018F7717', '0000000019O7818', '0000000020M7919']) == 19\n assert candidate(details = ['9999999999M5001', '8888888888F5502', '7777777777O5903', '6666666666M6004', '5555555555F6105']) == 1\n assert candidate(details = ['1234567890M5999', '1234567891F6000', '1234567892M6001', '1234567893F6002', '1234567894O6003', '1234567895M6004', '1234567896F6005', '1234567897O6006', '1234567898M6007', '1234567899F6008', '1234567800O6009', '1234567801M6010', '1234567802F6011', '1234567803O6012', '1234567804M6013', '1234567805F6014', '1234567806O6015', '1234567807M6016', '1234567808F6017', '1234567809O6018']) == 0\n assert candidate(details = ['1234567890M6000', '0987654321F6101', '1122334455O6202', '2233445566M6303', '3344556677F6404', '4455667788O6505', '5566778899M6606', '6677889900F6707', '7788990011O6808', '8899001122M6909', '9900112233F7010', '0011223344O7111', '1122334455M7212', '2233445566F7313', '3344556677O7414', '4455667788M7515', '5566778899F7616', '6677889900O7717', '7788990011M7818', '8899001122F7919', '9900112233O8020']) == 20\n assert candidate(details = ['1234567890M5959', '0987654321F6000', '1122334455O6001', '9876543210M7002', '8765432109F6103', '7654321098O7504']) == 3\n assert candidate(details = ['0123456789F5899', '9876543210M5998', '1357924680O6097', '8642097531F6196', '0864209753M6295', '1975308642F6394', '2097531864O6493']) == 4\n assert candidate(details = ['5555555555F5900', '6666666666M6001', '7777777777F6102', '8888888888O6203', '9999999999M6304', '0000000000F6405', '1111111111O6506']) == 5\n assert candidate(details = ['0000000000M5999', '1111111111F6000', '2222222222O6100', '3333333333M6200', '4444444444F6300', '5555555555O6400', '6666666666M6500', '7777777777F6600', '8888888888O6700', '9999999999M6800', '0102030405F6900']) == 9\n assert candidate(details = ['0000000000F2000', '1111111111M2101', '2222222222F2202', '3333333333O2303', '4444444444M2404', '5555555555F6105']) == 1\n"}, "metadata": {"canonical_parameter_names": ["details"], "leetcode_dataset_entry_point": "Solution().countSeniors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countSeniors(String[] details) {", "container": "Solution", "callable": "countSeniors", "parameters": [{"name": "details", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2679, "task_id": "sum-in-a-matrix", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D integer array nums. Initially, your score is 0. Perform the following operations until the matrix becomes empty:\n\nFrom each row in the matrix, select the largest number and remove it. In the case of a tie, it does not matter which number is chosen.\nIdentify the highest number amongst all those removed in step 1. Add that number to your score.\n\nReturn the final score.\n \nExample 1:\n\nInput: nums = [[7,2,1],[6,4,2],[6,5,3],[3,2,1]]\nOutput: 15\nExplanation: In the first operation, we remove 7, 6, 6, and 3. We then add 7 to our score. Next, we remove 2, 4, 5, and 2. We add 5 to our score. Lastly, we remove 1, 2, 3, and 1. We add 3 to our score. Thus, our final score is 7 + 5 + 3 = 15.\n\nExample 2:\n\nInput: nums = [[1]]\nOutput: 1\nExplanation: We remove 1 and add it to the answer. We return 1.\n \nConstraints:\n\n1 <= nums.length <= 300\n1 <= nums[i].length <= 500\n0 <= nums[i][j] <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [[1]]) == 1\n assert candidate(nums = [[5, 4, 3], [1, 2, 3], [3, 2, 1]]) == 12\n assert candidate(nums = [[5, 3, 1], [4, 2, 1], [3, 2, 1]]) == 9\n assert candidate(nums = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(nums = [[10, 6, 9, 1], [7, 5, 8, 2], [12, 11, 10, 3]]) == 36\n assert candidate(nums = [[3, 1, 4], [1, 5, 9], [2, 6, 5]]) == 16\n assert candidate(nums = [[100, 99, 98], [97, 96, 95], [94, 93, 92]]) == 297\n assert candidate(nums = [[10, 20, 30], [5, 15, 25], [1, 2, 3]]) == 60\n assert candidate(nums = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 24\n assert candidate(nums = [[5, 4, 3], [8, 7, 6], [9, 8, 7]]) == 24\n assert candidate(nums = [[5, 2, 3], [1, 6, 4], [7, 8, 9]]) == 24\n assert candidate(nums = [[7, 2, 1], [6, 4, 2], [6, 5, 3], [3, 2, 1]]) == 15\n assert candidate(nums = [[1, 2], [3, 4], [5, 6]]) == 11\n assert candidate(nums = [[3, 6, 9, 12], [2, 5, 8, 11], [1, 4, 7, 10]]) == 30\n assert candidate(nums = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == 25\n assert candidate(nums = [[10, 10, 10], [10, 10, 10], [10, 10, 10]]) == 30\n assert candidate(nums = [[10, 6, 9, 1], [7, 5, 8, 1], [4, 3, 7, 1]]) == 26\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]]) == 579\n assert candidate(nums = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 39\n assert candidate(nums = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [0, 11, 12, 13, 14], [15, 16, 17, 18, 19]]) == 85\n assert candidate(nums = [[10, 20, 30], [5, 15, 25], [1, 11, 21], [6, 16, 26], [11, 21, 31]]) == 63\n assert candidate(nums = [[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]]) == 155\n assert candidate(nums = [[300, 200, 100, 0], [250, 150, 50, 0], [200, 100, 0, 0], [150, 50, 0, 0]]) == 600\n assert candidate(nums = [[5, 3, 8], [2, 6, 9], [1, 7, 4], [10, 1, 12], [11, 0, 13]]) == 27\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], [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 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], [5, 5, 5, 5, 5]]) == 25\n assert candidate(nums = [[100, 200, 300], [50, 150, 250], [10, 80, 160]]) == 600\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\n assert candidate(nums = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 4\n assert candidate(nums = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [10, 9, 8, 7, 6], [5, 4, 3, 2, 1]]) == 40\n assert candidate(nums = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2], [3, 1, 2]]) == 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]]) == 5\n assert candidate(nums = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(nums = [[500, 501, 502, 503, 504, 505, 506, 507, 508, 509], [510, 511, 512, 513, 514, 515, 516, 517, 518, 519], [520, 521, 522, 523, 524, 525, 526, 527, 528, 529]]) == 5245\n assert candidate(nums = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [9, 8, 7, 6, 5]]) == 150\n assert candidate(nums = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [7, 5, 3, 1, 0]]) == 25\n assert candidate(nums = [[100, 99, 98, 97], [96, 95, 94, 93], [92, 91, 90, 89], [88, 87, 86, 85]]) == 394\n assert candidate(nums = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [9, 8, 7, 6, 5]]) == 36\n assert candidate(nums = [[3, 2, 1], [2, 1, 0], [1, 0, 0], [0, 0, 0]]) == 6\n assert candidate(nums = [[9, 8, 7], [6, 5, 4], [3, 2, 1], [0, 0, 0], [0, 0, 0]]) == 24\n assert candidate(nums = [[500, 400, 300, 200, 100], [450, 350, 250, 150, 50], [400, 300, 200, 100, 0], [350, 250, 150, 50, -50]]) == 1500\n assert candidate(nums = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [0, 10, 20, 30, 40]]) == 150\n assert candidate(nums = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39]]) == 175\n assert candidate(nums = [[50, 25, 0], [49, 24, 1], [48, 23, 2], [47, 22, 3], [46, 21, 4]]) == 79\n assert candidate(nums = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0]]) == 35\n assert candidate(nums = [[100, 200, 300, 400], [400, 300, 200, 100], [1, 2, 3, 4], [4, 3, 2, 1]]) == 1000\n assert candidate(nums = [[100, 200, 300, 400], [150, 250, 350, 450], [125, 225, 325, 425], [175, 275, 375, 475]]) == 1300\n assert candidate(nums = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 20\n assert candidate(nums = [[15, 20, 25, 30], [14, 19, 24, 29], [13, 18, 23, 28], [12, 17, 22, 27], [11, 16, 21, 26]]) == 90\n assert candidate(nums = [[300, 299, 298, 297, 296, 295, 294, 293, 292, 291], [290, 289, 288, 287, 286, 285, 284, 283, 282, 281], [280, 279, 278, 277, 276, 275, 274, 273, 272, 271], [270, 269, 268, 267, 266, 265, 264, 263, 262, 261], [260, 259, 258, 257, 256, 255, 254, 253, 252, 251], [250, 249, 248, 247, 246, 245, 244, 243, 242, 241], [240, 239, 238, 237, 236, 235, 234, 233, 232, 231], [230, 229, 228, 227, 226, 225, 224, 223, 222, 221], [220, 219, 218, 217, 216, 215, 214, 213, 212, 211], [210, 209, 208, 207, 206, 205, 204, 203, 202, 201]]) == 2955\n assert candidate(nums = [[300, 200, 100], [299, 199, 99], [298, 198, 98], [297, 197, 97], [296, 196, 96]]) == 600\n assert candidate(nums = [[3, 2, 1], [6, 5, 4], [9, 8, 7], [12, 11, 10], [15, 14, 13], [18, 17, 16], [21, 20, 19]]) == 60\n assert candidate(nums = [[500, 400, 300, 200, 100], [499, 399, 299, 199, 99], [498, 398, 298, 198, 98], [497, 397, 297, 197, 97]]) == 1500\n assert candidate(nums = [[100, 99, 98], [97, 96, 95], [94, 93, 92], [91, 90, 89]]) == 297\n assert candidate(nums = [[5, 5, 5, 5, 5], [4, 4, 4, 4, 4], [3, 3, 3, 3, 3], [2, 2, 2, 2, 2], [1, 1, 1, 1, 1]]) == 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], [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 = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 55\n assert candidate(nums = [[1000, 900, 800], [700, 600, 500], [400, 300, 200], [100, 0, 1]]) == 2700\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, 4, 6, 8, 10, 12, 14, 16, 18, 20], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]]) == 110\n assert candidate(nums = [[9, 5, 1, 8], [7, 4, 2, 6], [3, 8, 6, 4], [10, 3, 7, 5]]) == 26\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]]) == 20\n assert candidate(nums = [[3], [2], [1], [4], [5], [6]]) == 6\n assert candidate(nums = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(nums = [[999, 1000, 998, 997, 996], [995, 994, 993, 992, 991], [990, 989, 988, 987, 986], [985, 984, 983, 982, 981]]) == 4990\n assert candidate(nums = [[1, 1000, 999], [2, 998, 997], [3, 996, 995], [4, 994, 993], [5, 992, 991]]) == 2004\n assert candidate(nums = [[1000, 500, 250, 125, 62, 31, 15, 7, 3, 1], [999, 499, 249, 124, 62, 31, 15, 7, 3, 1], [998, 498, 248, 124, 62, 31, 15, 7, 3, 1], [997, 497, 247, 123, 61, 31, 15, 7, 3, 1]]) == 1994\n assert candidate(nums = [[500, 499, 498, 497, 496, 495, 494, 493, 492, 491], [490, 489, 488, 487, 486, 485, 484, 483, 482, 481], [480, 479, 478, 477, 476, 475, 474, 473, 472, 471]]) == 4955\n assert candidate(nums = [[5, 10, 15, 20, 25], [25, 20, 15, 10, 5], [30, 35, 40, 45, 50], [50, 45, 40, 35, 30], [55, 60, 65, 70, 75]]) == 325\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, 4, 3, 2, 1, 10, 9, 8, 7, 6]]) == 55\n assert candidate(nums = [[300, 200, 100], [250, 150, 50], [200, 100, 0], [150, 50, -50], [100, 0, -100]]) == 600\n assert candidate(nums = [[1000, 0, 0], [0, 1000, 0], [0, 0, 1000]]) == 1000\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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 1, 0, 5, 3, 0, 9, 8, 9, 9, 9, 0, 1, 2, 3, 8, 5, 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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8]]) == 835\n assert candidate(nums = [[3, 1, 4, 1, 5], [9, 2, 6, 5, 3], [5, 8, 9, 7, 9], [2, 6, 5, 3, 5]]) == 38\n assert candidate(nums = [[5, 15, 25, 35], [10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50]]) == 140\n assert candidate(nums = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [20, 10, 40, 30, 50], [30, 50, 10, 40, 20], [40, 30, 50, 20, 10]]) == 150\n assert candidate(nums = [[15, 25, 5, 10], [30, 20, 25, 15], [5, 5, 5, 5], [40, 10, 30, 20]]) == 105\n assert candidate(nums = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 9, 8, 7, 6, 5, 4, 3, 2]]) == 54\n assert candidate(nums = [[300, 200, 100], [250, 150, 50], [200, 100, 0], [150, 50, 0]]) == 600\n assert candidate(nums = [[999, 998, 997], [996, 995, 994], [993, 992, 991], [990, 989, 988], [987, 986, 985]]) == 2994\n assert candidate(nums = [[10, 20], [20, 10], [30, 40], [40, 30], [50, 60], [60, 50], [70, 80], [80, 70]]) == 150\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, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 55\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]]) == 25\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, 4, 6, 8, 10, 1, 3, 5, 7, 9], [9, 7, 5, 3, 1, 10, 8, 6, 4, 2]]) == 55\n assert candidate(nums = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 4\n assert candidate(nums = [[300, 200, 100], [299, 199, 99], [298, 198, 98], [297, 197, 97], [296, 196, 96], [295, 195, 95], [294, 194, 94], [293, 193, 93], [292, 192, 92], [291, 191, 91]]) == 600\n assert candidate(nums = [[10, 20, 30], [30, 20, 10], [10, 30, 20]]) == 60\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, 10, 15, 20, 25, 30, 35, 40, 45, 50], [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]]) == 275\n assert candidate(nums = [[1000, 999, 998, 997], [996, 995, 994, 993], [992, 991, 990, 989], [988, 987, 986, 985], [984, 983, 982, 981]]) == 3994\n assert candidate(nums = [[1, 1000], [1, 999], [1, 998], [1, 997], [1, 996], [1, 995], [1, 994], [1, 993], [1, 992], [1, 991], [1, 990], [1, 989], [1, 988], [1, 987], [1, 986], [1, 985], [1, 984], [1, 983], [1, 982], [1, 981]]) == 1001\n assert candidate(nums = [[9, 15, 3, 11], [8, 14, 4, 12], [7, 13, 5, 10], [6, 10, 6, 9], [5, 9, 7, 8], [4, 8, 8, 7], [3, 7, 9, 6], [2, 6, 10, 5], [1, 5, 11, 4]]) == 42\n assert candidate(nums = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]) == 4\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, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 55\n assert candidate(nums = [[100, 101, 102, 103, 104], [200, 201, 202, 203, 204], [300, 301, 302, 303, 304], [400, 401, 402, 403, 404], [500, 501, 502, 503, 504]]) == 2510\n assert candidate(nums = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15]]) == 65\n assert candidate(nums = [[99, 98, 97], [96, 95, 94], [93, 92, 91], [90, 89, 88], [87, 86, 85]]) == 294\n assert candidate(nums = [[1, 1000, 1], [1, 1000, 1], [1, 1000, 1], [1, 1000, 1], [1, 1000, 1]]) == 1002\n assert candidate(nums = [[100, 200, 300], [50, 150, 250], [20, 120, 220], [10, 110, 210]]) == 600\n assert candidate(nums = [[100, 200, 300], [90, 180, 270], [80, 160, 240], [70, 140, 210], [60, 120, 180], [50, 100, 150]]) == 600\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]]) == 255\n assert candidate(nums = [[999, 998, 997, 996, 995, 994, 993, 992, 991, 990], [989, 988, 987, 986, 985, 984, 983, 982, 981, 980], [979, 978, 977, 976, 975, 974, 973, 972, 971, 970]]) == 9945\n assert candidate(nums = [[50, 40, 30, 20, 10], [51, 41, 31, 21, 11], [52, 42, 32, 22, 12], [53, 43, 33, 23, 13], [54, 44, 34, 24, 14], [55, 45, 35, 25, 15], [56, 46, 36, 26, 16], [57, 47, 37, 27, 17], [58, 48, 38, 28, 18], [59, 49, 39, 29, 19]]) == 195\n assert candidate(nums = [[100, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 100], [100, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 100], [21, 22, 23, 24, 25, 100]]) == 215\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().matrixSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int matrixSum(int[][] nums) {", "container": "Solution", "callable": "matrixSum", "parameters": [{"name": "nums", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2680, "task_id": "maximum-or", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of length n and an integer k. In an operation, you can choose an element and multiply it by 2.\nReturn the maximum possible value of nums[0] | nums[1] | ... | nums[n - 1] that can be obtained after applying the operation on nums at most k times.\nNote that a | b denotes the bitwise or between two integers a and b.\n \nExample 1:\n\nInput: nums = [12,9], k = 1\nOutput: 30\nExplanation: If we apply the operation to index 1, our new array nums will be equal to [12,18]. Thus, we return the bitwise or of 12 and 18, which is 30.\n\nExample 2:\n\nInput: nums = [8,1,2], k = 2\nOutput: 35\nExplanation: If we apply the operation twice on index 0, we yield a new array of [32,1,2]. Thus, we return 32|1|2 = 35.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= k <= 15\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 31\n assert candidate(nums = [1, 2, 4, 8, 16],k = 3) == 143\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 8) == 256554748416\n assert candidate(nums = [3, 5, 7, 9],k = 4) == 151\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 11) == 10245\n assert candidate(nums = [5, 10, 15],k = 5) == 495\n assert candidate(nums = [1, 2, 4, 8],k = 3) == 71\n assert candidate(nums = [31, 15, 7, 3, 1],k = 7) == 3983\n assert candidate(nums = [127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127],k = 15) == 4161663\n assert candidate(nums = [8, 1, 2],k = 2) == 35\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 9231\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31],k = 13) == 253983\n assert candidate(nums = [1000000000],k = 15) == 32768000000000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 12) == 118815\n assert candidate(nums = [1, 1000000000, 1],k = 5) == 32000000001\n assert candidate(nums = [1, 1, 1, 1, 1],k = 6) == 65\n assert candidate(nums = [2, 4, 6, 8, 10],k = 10) == 10254\n assert candidate(nums = [9, 18, 27, 36],k = 13) == 294939\n assert candidate(nums = [11, 22, 33, 44, 55],k = 14) == 901183\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) == 513\n assert candidate(nums = [12, 9],k = 1) == 30\n assert candidate(nums = [1024, 512, 256],k = 5) == 33536\n assert candidate(nums = [7, 11, 13, 17],k = 7) == 2191\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 5125\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 11) == 2098174\n assert candidate(nums = [3, 3, 3, 3],k = 4) == 51\n assert candidate(nums = [63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63],k = 14) == 1032255\n assert candidate(nums = [13, 14, 15, 16],k = 9) == 8207\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 6) == 455\n assert candidate(nums = [1023, 512, 256, 128, 64],k = 7) == 131008\n assert candidate(nums = [6, 12, 18, 24, 30],k = 15) == 983070\n assert candidate(nums = [7, 14, 21, 28],k = 12) == 114719\n assert candidate(nums = [1000000000, 500000000, 250000000],k = 8) == 256086374272\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],k = 8) == 12607\n assert candidate(nums = [21, 42, 84, 168, 336, 672, 1344, 2688, 5376, 10752],k = 7) == 1384447\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127],k = 10) == 67108863\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 = 13) == 8590983167\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1111, 2222, 3333],k = 10) == 3416063\n assert candidate(nums = [13, 26, 52, 104, 208, 416, 832, 1664, 3328, 6656],k = 15) == 218107903\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 5) == 16895\n assert candidate(nums = [987654321, 876543219, 765432198, 654321987, 543219876],k = 8) == 253403069943\n assert candidate(nums = [987654321, 123456789, 876543210, 98765432, 8765432, 765432, 65432, 5432, 432, 32],k = 10) == 1011464798207\n assert candidate(nums = [15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143],k = 10) == 268435455\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 15) == 16777727\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 10) == 92287\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],k = 7) == 128849005055\n assert candidate(nums = [3, 5, 9, 15, 31, 63, 127, 255, 511, 1023],k = 10) == 1048063\n assert candidate(nums = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],k = 3) == 255\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 15) == 32768452971519\n assert candidate(nums = [31, 15, 7, 3, 1],k = 15) == 1015823\n assert candidate(nums = [1, 1000000000, 2, 2000000000, 3, 3000000000, 4, 4000000000, 5, 5000000000],k = 15) == 163840117440007\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095],k = 10) == 4194303\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 12) == 127007\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 = 12) == 4296015870\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000],k = 5) == 32142772737\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888],k = 7) == 126701535231\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888],k = 10) == 1011464798207\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 2048, 4096, 8192, 16384],k = 13) == 134234111\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 8) == 257020\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 15) == 2147483647\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 1049599\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 5) == 2097151\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 15) == 33555455\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 10) == 30751\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 = 1) == 27\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55],k = 7) == 7103\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 14) == 16778239\n assert candidate(nums = [23, 47, 94, 188, 376, 752, 1504, 3008, 6016, 12032],k = 5) == 393215\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 = 14) == 17180917758\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 32764\n assert candidate(nums = [131071, 262143, 524287, 1048575],k = 12) == 4294967295\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 10) == 1024278055424\n assert candidate(nums = [999999999, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89],k = 15) == 32768016775167\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],k = 8) == 231420\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 10) == 1024349700095\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 5) == 1023\n assert candidate(nums = [536870911, 268435455, 134217727, 67108863, 33554431],k = 10) == 549755813887\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 15) == 17180392448\n assert candidate(nums = [233, 322, 411, 500, 599, 688, 777, 866, 955],k = 5) == 30719\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 = 10) == 1074790399\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],k = 8) == 72613887\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],k = 12) == 4096318765567\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 4) == 24572\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) == 3702911\n assert candidate(nums = [13, 29, 41, 53, 67, 83, 97],k = 12) == 397439\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],k = 15) == 1073725439\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 10) == 524799\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 8) == 262143\n assert candidate(nums = [2147483647, 2147483646, 2147483645],k = 5) == 68719476735\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 10) == 1049599\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 335\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13],k = 3) == 109\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 12) == 67125247\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555],k = 15) == 32768452984571\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999],k = 15) == 32768452971007\n assert candidate(nums = [131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 14) == 2147614719\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 = 10) == 6930431\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 7) == 128312147936\n assert candidate(nums = [1023, 2047, 4095, 8191],k = 10) == 8388607\n assert candidate(nums = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 14) == 8389119\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255],k = 14) == 4178175\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 12) == 268435455\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999],k = 5) == 32142786559\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383],k = 3) == 131071\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 864201357],k = 5) == 32212254719\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) == 20511\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 12) == 204863\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000],k = 10) == 1024349700088\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 491535\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 369258147],k = 15) == 32363652317183\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 8) == 38654\n assert candidate(nums = [31, 62, 124, 248, 496, 992, 1984, 3968, 7936, 15872],k = 5) == 516095\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 14) == 1474687\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 = 13) == 55427071\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumOr", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumOr(int[] nums, int k) {", "container": "Solution", "callable": "maximumOr", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2681, "task_id": "power-of-heroes", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums representing the strength of some heroes. The power of a group of heroes is defined as follows:\n\nLet i0, i1, ... ,ik be the indices of the heroes in a group. Then, the power of this group is max(nums[i0], nums[i1], ... ,nums[ik])2 * min(nums[i0], nums[i1], ... ,nums[ik]).\n\nReturn the sum of the power of all non-empty groups of heroes possible. Since the sum could be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [2,1,4]\nOutput: 141\nExplanation: \n1st group: [2] has power = 22 * 2 = 8.\n2nd group: [1] has power = 12 * 1 = 1. \n3rd group: [4] has power = 42 * 4 = 64. \n4th group: [2,1] has power = 22 * 1 = 4. \n5th group: [2,4] has power = 42 * 2 = 32. \n6th group: [1,4] has power = 42 * 1 = 16. \n​​​​​​​7th group: [2,1,4] has power = 42​​​​​​​ * 1 = 16. \nThe sum of powers of all groups is 8 + 1 + 64 + 4 + 32 + 16 + 16 = 141.\n\n\nExample 2:\n\nInput: nums = [1,1,1]\nOutput: 7\nExplanation: A total of 7 groups are possible, and the power of each group will be 1. Therefore, the sum of the powers of all groups is 7.\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 = [3, 5, 7, 2]) == 1627\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1000000000]) == 999999664\n assert candidate(nums = [3, 2, 5, 6]) == 1253\n assert candidate(nums = [3, 5, 2, 8]) == 2081\n assert candidate(nums = [2, 4, 6, 8, 10]) == 8728\n assert candidate(nums = [2, 1, 4]) == 141\n assert candidate(nums = [1, 1, 1]) == 7\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 999997606\n assert candidate(nums = [10, 20, 30, 40, 50]) == 1091000\n assert candidate(nums = [3, 2, 1]) == 76\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 169593\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1091\n assert candidate(nums = [10, 9, 8, 7, 6]) == 18136\n assert candidate(nums = [1, 3, 5, 7, 9]) == 5091\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 169593\n assert candidate(nums = [5, 5, 5, 5]) == 1875\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 166909229\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 903174621\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 157911835\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 36487\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 592998817\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 832697741\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 737896832\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 161550\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 67293\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == 917238506\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 1328831\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 12974882\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]) == 531216836\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 106980543\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 393212152\n assert candidate(nums = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005]) == 124999698\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 230175231\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 26056\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 1023000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 12974882\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 1]) == 790083522\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 294671159\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 998989732\n assert candidate(nums = [29, 23, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137]) == 238366021\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 350889\n assert candidate(nums = [5, 2, 8, 3, 6]) == 4581\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995, 7, 999999994, 8, 999999993]) == 8160960\n assert candidate(nums = [999999999, 1, 999999998, 2, 999999997, 3, 999999996, 4, 999999995, 5]) == 113649\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500]) == 738979242\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 131265795\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 686474720\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 131265795\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993]) == 999864374\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 998644298\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]) == 2097151\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 169593\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 998989732\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 234860208\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]) == 788917595\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 381440876\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 113709125\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 127875\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]) == 991029025\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 761263300\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 686474720\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 13545400\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]) == 328693133\n assert candidate(nums = [999999937, 999999938, 999999939, 999999940, 999999941]) == 990418583\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 282942875\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 9123243\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 473671145\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 661581886\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 999649118\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 169593000\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]) == 273859741\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 12974882\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 263294673\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 90106358\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 751798588\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 761263300\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 169593\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5]) == 16421\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 473671145\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000]) == 874956145\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 67293\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 331646057\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 210, 311, 412, 513, 614, 715, 816, 917, 1018, 1119]) == 219998389\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 975216922\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 169593000\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 127875\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994]) == 999900627\n assert candidate(nums = [2, 5, 3, 10, 1, 8, 4]) == 18451\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 974881916\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000]) == 56941830\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 4095875\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000]) == 36487\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfPower", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int sumOfPower(int[] nums) {", "container": "Solution", "callable": "sumOfPower", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2682, "task_id": "find-the-losers-of-the-circular-game", "difficulty": "Easy", "problem_description": "There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings you to the (i+1)th friend for 1 <= i < n, and moving clockwise from the nth friend brings you to the 1st friend.\nThe rules of the game are as follows:\n1st friend receives the ball.\n\nAfter that, 1st friend passes it to the friend who is k steps away from them in the clockwise direction.\nAfter that, the friend who receives the ball should pass it to the friend who is 2 * k steps away from them in the clockwise direction.\nAfter that, the friend who receives the ball should pass it to the friend who is 3 * k steps away from them in the clockwise direction, and so on and so forth.\n\nIn other words, on the ith turn, the friend holding the ball should pass it to the friend who is i * k steps away from them in the clockwise direction.\nThe game is finished when some friend receives the ball for the second time.\nThe losers of the game are friends who did not receive the ball in the entire game.\nGiven the number of friends, n, and an integer k, return the array answer, which contains the losers of the game in the ascending order.\n \nExample 1:\n\nInput: n = 5, k = 2\nOutput: [4,5]\nExplanation: The game goes as follows:\n1) Start at 1st friend and pass the ball to the friend who is 2 steps away from them - 3rd friend.\n2) 3rd friend passes the ball to the friend who is 4 steps away from them - 2nd friend.\n3) 2nd friend passes the ball to the friend who is 6 steps away from them - 3rd friend.\n4) The game ends as 3rd friend receives the ball for the second time.\n\nExample 2:\n\nInput: n = 4, k = 4\nOutput: [2,3,4]\nExplanation: The game goes as follows:\n1) Start at the 1st friend and pass the ball to the friend who is 4 steps away from them - 1st friend.\n2) The game ends as 1st friend receives the ball for the second time.\n\n \nConstraints:\n\n1 <= k <= n <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,k = 5) == [2, 3, 4, 5, 7, 8, 9, 10]\n assert candidate(n = 4,k = 4) == [2, 3, 4]\n assert candidate(n = 5,k = 2) == [4, 5]\n assert candidate(n = 7,k = 3) == [2, 6, 7]\n assert candidate(n = 6,k = 1) == [3, 5, 6]\n assert candidate(n = 10,k = 3) == [2, 3, 5, 6, 7, 8]\n assert candidate(n = 7,k = 5) == [4, 5, 7]\n assert candidate(n = 40,k = 9) == [2, 3, 4, 7, 8, 9, 12, 14, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(n = 35,k = 17) == [2, 3, 4, 5, 6, 7, 9, 10, 12, 13, 14, 15, 16, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 32, 34, 35]\n assert candidate(n = 22,k = 7) == [2, 3, 4, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 19, 20]\n assert candidate(n = 37,k = 5) == [3, 7, 10, 11, 13, 18, 19, 20, 22, 23, 24, 25, 27, 28, 29, 34, 36, 37]\n assert candidate(n = 15,k = 14) == [2, 3, 4, 5, 7, 8, 9, 11, 12, 14]\n assert candidate(n = 35,k = 6) == [3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 23, 24, 25, 27, 28, 30, 31, 32, 33, 34, 35]\n assert candidate(n = 28,k = 10) == [2, 4, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]\n assert candidate(n = 50,k = 1) == [3, 5, 8, 9, 10, 12, 13, 14, 15, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50]\n assert candidate(n = 20,k = 19) == [2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 16, 17, 19]\n assert candidate(n = 40,k = 15) == [2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 24, 25, 27, 28, 29, 30, 32, 33, 34, 35, 37, 38, 39, 40]\n assert candidate(n = 25,k = 7) == [2, 3, 4, 5, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20, 24, 25]\n assert candidate(n = 25,k = 10) == [2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 35,k = 12) == [4, 5, 7, 9, 10, 11, 12, 14, 15, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]\n assert candidate(n = 50,k = 7) == [2, 4, 5, 7, 9, 10, 11, 12, 14, 15, 17, 18, 19, 20, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 44, 45, 46, 49, 50]\n assert candidate(n = 20,k = 11) == [2, 3, 4, 5, 8, 9, 10, 13, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 30,k = 9) == [2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30]\n assert candidate(n = 49,k = 16) == [2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 39, 40, 41, 42, 44, 46, 47]\n assert candidate(n = 12,k = 8) == [2, 3, 4, 5, 6, 7, 8, 10, 11, 12]\n assert candidate(n = 30,k = 7) == [2, 3, 4, 5, 6, 7, 9, 10, 12, 14, 15, 18, 19, 20, 21, 23, 24, 25, 26, 27, 29, 30]\n assert candidate(n = 40,k = 20) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(n = 50,k = 10) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(n = 18,k = 6) == [2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n assert candidate(n = 49,k = 15) == [3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 43, 44, 45, 47, 48, 49]\n assert candidate(n = 17,k = 13) == [3, 4, 5, 7, 13, 15, 16, 17]\n assert candidate(n = 15,k = 4) == [2, 3, 4, 6, 7, 8, 9, 12, 14, 15]\n assert candidate(n = 18,k = 2) == [2, 4, 5, 6, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18]\n assert candidate(n = 45,k = 11) == [2, 3, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 35, 36, 38, 40, 41, 42, 43, 44, 45]\n assert candidate(n = 45,k = 10) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]\n assert candidate(n = 45,k = 8) == [2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 32, 33, 35, 37, 38, 39, 40, 41, 42, 43, 44]\n assert candidate(n = 45,k = 13) == [2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 15, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 42, 43, 44, 45]\n assert candidate(n = 38,k = 19) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38]\n assert candidate(n = 28,k = 14) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]\n assert candidate(n = 49,k = 13) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 31, 32, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 48]\n assert candidate(n = 40,k = 17) == [2, 3, 4, 5, 7, 8, 9, 10, 14, 15, 17, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 39, 40]\n assert candidate(n = 49,k = 14) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49]\n assert candidate(n = 35,k = 9) == [2, 3, 4, 5, 6, 7, 9, 11, 12, 13, 14, 16, 17, 18, 19, 22, 23, 24, 25, 26, 27, 29, 30, 32, 33, 34, 35]\n assert candidate(n = 20,k = 7) == [4, 5, 7, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 13,k = 5) == [4, 7, 8, 9, 10, 13]\n assert candidate(n = 25,k = 5) == [2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 30,k = 6) == [2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(n = 49,k = 5) == [3, 4, 5, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 32, 33, 35, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49]\n assert candidate(n = 20,k = 5) == [2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20]\n assert candidate(n = 25,k = 6) == [3, 4, 5, 6, 8, 9, 10, 13, 14, 15, 17, 18, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 25,k = 23) == [2, 3, 4, 5, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 19, 22, 23, 25]\n assert candidate(n = 25,k = 9) == [2, 4, 6, 7, 8, 9, 12, 13, 14, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 15,k = 5) == [2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(n = 40,k = 13) == [2, 3, 4, 6, 7, 8, 9, 10, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 30, 31, 32, 33, 35, 37, 38]\n assert candidate(n = 40,k = 11) == [2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 30, 33, 35, 36, 38, 39, 40]\n assert candidate(n = 37,k = 13) == [2, 6, 9, 10, 12, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 33, 35, 36]\n assert candidate(n = 50,k = 13) == [2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 17, 18, 20, 21, 22, 23, 25, 26, 27, 28, 30, 32, 33, 34, 35, 37, 38, 39, 41, 42, 43, 44, 45, 47, 48, 49, 50]\n assert candidate(n = 28,k = 13) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 16, 17, 18, 20, 21, 24, 25, 26, 27]\n assert candidate(n = 31,k = 29) == [3, 6, 10, 11, 13, 14, 16, 17, 18, 19, 23, 25, 27, 28, 29]\n assert candidate(n = 22,k = 6) == [2, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 21, 22]\n assert candidate(n = 12,k = 4) == [2, 3, 4, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 30,k = 8) == [2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 24, 26, 27, 28, 29, 30]\n assert candidate(n = 40,k = 3) == [2, 3, 7, 8, 9, 11, 12, 13, 14, 15, 17, 18, 20, 21, 22, 23, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(n = 50,k = 11) == [2, 3, 4, 5, 7, 8, 10, 13, 14, 15, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 48, 49, 50]\n assert candidate(n = 30,k = 11) == [2, 3, 5, 6, 8, 10, 11, 13, 14, 15, 17, 18, 19, 20, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(n = 18,k = 4) == [2, 3, 4, 6, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18]\n assert candidate(n = 45,k = 15) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 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]\n assert candidate(n = 30,k = 17) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 17, 19, 20, 23, 24, 25, 26, 29, 30]\n assert candidate(n = 50,k = 17) == [4, 5, 7, 9, 10, 11, 12, 14, 15, 17, 19, 20, 22, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(n = 30,k = 29) == [2, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 24, 26, 27, 29]\n assert candidate(n = 49,k = 6) == [2, 3, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 20, 23, 24, 25, 27, 28, 30, 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49]\n assert candidate(n = 50,k = 25) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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(n = 48,k = 14) == [2, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 16, 17, 18, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 42, 44, 46, 47, 48]\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().circularGameLosers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] circularGameLosers(int n, int k) {", "container": "Solution", "callable": "circularGameLosers", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2683, "task_id": "neighboring-bitwise-xor", "difficulty": "Medium", "problem_description": "A 0-indexed array derived with length n is derived by computing the bitwise XOR (⊕) of adjacent values in a binary array original of length n.\nSpecifically, for each index i in the range [0, n - 1]:\n\nIf i = n - 1, then derived[i] = original[i] ⊕ original[0].\nOtherwise, derived[i] = original[i] ⊕ original[i + 1].\n\nGiven an array derived, your task is to determine whether there exists a valid binary array original that could have formed derived.\nReturn true if such an array exists or false otherwise.\n\nA binary array is an array containing only 0's and 1's\n\n \nExample 1:\n\nInput: derived = [1,1,0]\nOutput: true\nExplanation: A valid original array that gives derived is [0,1,0].\nderived[0] = original[0] ⊕ original[1] = 0 ⊕ 1 = 1 \nderived[1] = original[1] ⊕ original[2] = 1 ⊕ 0 = 1\nderived[2] = original[2] ⊕ original[0] = 0 ⊕ 0 = 0\n\nExample 2:\n\nInput: derived = [1,1]\nOutput: true\nExplanation: A valid original array that gives derived is [0,1].\nderived[0] = original[0] ⊕ original[1] = 1\nderived[1] = original[1] ⊕ original[0] = 1\n\nExample 3:\n\nInput: derived = [1,0]\nOutput: false\nExplanation: There is no valid original array that gives derived.\n\n \nConstraints:\n\nn == derived.length\n1 <= n <= 105\nThe values in derived are either 0's or 1's\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(derived = [0, 0, 0]) == True\n assert candidate(derived = [0, 0, 1, 1]) == True\n assert candidate(derived = [0, 1, 1, 0, 1]) == False\n assert candidate(derived = [1, 0, 1, 0]) == True\n assert candidate(derived = [0, 1, 0, 1]) == True\n assert candidate(derived = [1, 0, 0, 1]) == True\n assert candidate(derived = [0, 1, 1, 0]) == True\n assert candidate(derived = [1]) == False\n assert candidate(derived = [0]) == True\n assert candidate(derived = [1, 1, 1, 1, 1]) == False\n assert candidate(derived = [1, 0]) == False\n assert candidate(derived = [1, 1, 1, 1]) == True\n assert candidate(derived = [1, 0, 1, 0, 1]) == False\n assert candidate(derived = [1, 1]) == True\n assert candidate(derived = [0, 1, 0, 1, 0]) == True\n assert candidate(derived = [1, 1, 0]) == True\n assert candidate(derived = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == True\n assert candidate(derived = [1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1]) == False\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == True\n assert candidate(derived = [0, 0, 1, 0, 1, 0, 1, 0]) == False\n assert candidate(derived = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == True\n assert candidate(derived = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == True\n assert candidate(derived = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == True\n assert candidate(derived = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(derived = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(derived = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == False\n assert candidate(derived = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == True\n assert candidate(derived = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == True\n assert candidate(derived = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(derived = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == False\n assert candidate(derived = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == True\n assert candidate(derived = [0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0, 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(derived = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0]) == True\n assert candidate(derived = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == False\n assert candidate(derived = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) == True\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0, 1]) == False\n assert candidate(derived = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == False\n assert candidate(derived = [1, 1, 0, 1, 0, 1, 1, 0]) == False\n assert candidate(derived = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == True\n assert candidate(derived = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(derived = [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]) == True\n assert candidate(derived = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == True\n assert candidate(derived = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1]) == False\n assert candidate(derived = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == False\n assert candidate(derived = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == True\n assert candidate(derived = [1, 0, 1, 1, 0, 1, 1, 0]) == False\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == False\n assert candidate(derived = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == True\n assert candidate(derived = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == False\n assert candidate(derived = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == True\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == False\n assert candidate(derived = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) == True\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == False\n assert candidate(derived = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == True\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == True\n assert candidate(derived = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == False\n assert candidate(derived = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == True\n assert candidate(derived = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1]) == False\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1]) == True\n assert candidate(derived = [0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0]) == True\n assert candidate(derived = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == True\n assert candidate(derived = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == False\n assert candidate(derived = [1, 1, 0, 0, 1, 1, 0, 0, 1]) == False\n assert candidate(derived = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == True\n assert candidate(derived = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == False\n assert candidate(derived = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1]) == False\n assert candidate(derived = [0, 1, 0, 1, 0, 1, 0, 1]) == True\n assert candidate(derived = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == True\n assert candidate(derived = [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1]) == False\n assert candidate(derived = [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == False\n assert candidate(derived = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1]) == False\n assert candidate(derived = [0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0]) == True\n assert candidate(derived = [1, 0, 1, 1, 0, 1, 0, 1, 0, 1]) == True\n assert candidate(derived = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == True\n assert candidate(derived = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == True\n assert candidate(derived = [1, 1, 0, 0, 1, 1, 0, 0]) == True\n assert candidate(derived = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(derived = [1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1]) == False\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == True\n assert candidate(derived = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == False\n assert candidate(derived = [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]) == True\n assert candidate(derived = [0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0]) == True\n assert candidate(derived = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == True\n assert candidate(derived = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1]) == True\n assert candidate(derived = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == False\n assert candidate(derived = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1]) == True\n assert candidate(derived = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == True\n assert candidate(derived = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1]) == True\n"}, "metadata": {"canonical_parameter_names": ["derived"], "leetcode_dataset_entry_point": "Solution().doesValidArrayExist", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean doesValidArrayExist(int[] derived) {", "container": "Solution", "callable": "doesValidArrayExist", "parameters": [{"name": "derived", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2684, "task_id": "maximum-number-of-moves-in-a-grid", "difficulty": "Medium", "problem_description": "You are given a 0-indexed m x n matrix grid consisting of positive integers.\nYou can start at any cell in the first column of the matrix, and traverse the grid in the following way:\n\nFrom a cell (row, col), you can move to any of the cells: (row - 1, col + 1), (row, col + 1) and (row + 1, col + 1) such that the value of the cell you move to, should be strictly bigger than the value of the current cell.\n\nReturn the maximum number of moves that you can perform.\n \nExample 1:\n\n\nInput: grid = [[2,4,3,5],[5,4,9,3],[3,4,2,11],[10,9,13,15]]\nOutput: 3\nExplanation: We can start at the cell (0, 0) and make the following moves:\n- (0, 0) -> (0, 1).\n- (0, 1) -> (1, 2).\n- (1, 2) -> (2, 3).\nIt can be shown that it is the maximum number of moves that can be made.\nExample 2:\n\n\nInput: grid = [[3,2,4],[2,1,9],[1,1,7]]\nOutput: 0\nExplanation: Starting from any cell in the first column we cannot perform any moves.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n2 <= m, n <= 1000\n4 <= m * n <= 105\n1 <= grid[i][j] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 3, 5, 7], [2, 4, 6, 8], [1, 3, 5, 7]]) == 3\n assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 2\n assert candidate(grid = [[10, 15, 20], [5, 9, 12], [7, 8, 10]]) == 2\n assert candidate(grid = [[5, 3, 2, 1], [4, 3, 2, 1], [5, 4, 3, 2], [4, 3, 2, 1]]) == 0\n assert candidate(grid = [[3, 2, 4], [2, 1, 9], [1, 1, 7]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]) == 4\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 2\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[10, 11, 16, 14, 7, 6], [9, 7, 6, 17, 4, 8], [1, 19, 5, 11, 1, 5], [14, 3, 16, 11, 22, 9]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == 4\n assert candidate(grid = [[2, 4, 3, 5], [5, 4, 9, 3], [3, 4, 2, 11], [10, 9, 13, 15]]) == 3\n assert candidate(grid = [[1, 20, 3, 40, 5], [10, 2, 30, 4, 50], [11, 12, 1, 40, 51], [20, 19, 30, 14, 52], [21, 22, 23, 4, 53]]) == 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], [1, 3, 5, 7, 9, 2, 4, 6, 8, 10], [10, 8, 6, 4, 2, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 1, 3, 5, 7, 9], [9, 7, 5, 3, 1, 10, 8, 6, 4, 2]]) == 9\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14]]) == 5\n assert candidate(grid = [[5, 8, 6, 7, 4, 9, 2, 3], [4, 7, 5, 6, 3, 8, 1, 2], [3, 6, 4, 5, 2, 7, 8, 9], [2, 5, 3, 4, 1, 6, 7, 8], [1, 4, 2, 3, 9, 5, 6, 7]]) == 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], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]]) == 9\n assert candidate(grid = [[9, 10, 1, 8, 2, 7, 3, 6, 4, 5], [10, 1, 8, 2, 7, 3, 6, 4, 5, 9], [1, 8, 2, 7, 3, 6, 4, 5, 9, 10], [8, 2, 7, 3, 6, 4, 5, 9, 10, 1], [2, 7, 3, 6, 4, 5, 9, 10, 1, 8], [7, 3, 6, 4, 5, 9, 10, 1, 8, 2], [3, 6, 4, 5, 9, 10, 1, 8, 2, 7], [6, 4, 5, 9, 10, 1, 8, 2, 7, 3], [4, 5, 9, 10, 1, 8, 2, 7, 3, 6], [5, 9, 10, 1, 8, 2, 7, 3, 6, 4]]) == 6\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 4, 3, 2, 1, 9, 8, 7, 6], [6, 7, 8, 9, 1, 5, 4, 3, 2], [2, 3, 1, 4, 6, 8, 7, 5, 9]]) == 8\n assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23], [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]]) == 10\n assert candidate(grid = [[1, 100, 200, 300, 400], [2, 99, 199, 299, 399], [3, 98, 198, 298, 398], [4, 97, 197, 297, 397], [5, 96, 196, 296, 396]]) == 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, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 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]]) == 1\n assert candidate(grid = [[1, 20, 19, 18, 17, 16, 15, 14, 13, 12], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 9\n assert candidate(grid = [[1, 3, 2, 4, 5], [2, 1, 5, 3, 4], [3, 4, 6, 2, 7], [4, 5, 7, 6, 8], [5, 6, 8, 7, 9]]) == 2\n assert candidate(grid = [[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]]) == 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], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [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]]) == 9\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 10, 19, 28, 37, 46, 55, 64, 73, 82], [3, 18, 27, 36, 45, 54, 63, 72, 81, 90], [4, 26, 35, 44, 53, 62, 71, 80, 89, 98], [5, 34, 43, 52, 61, 70, 79, 88, 97, 106], [6, 42, 51, 60, 69, 78, 87, 96, 105, 114], [7, 50, 59, 68, 77, 86, 95, 104, 113, 122], [8, 58, 67, 76, 85, 94, 103, 112, 121, 130], [9, 66, 75, 84, 93, 102, 111, 120, 129, 138], [10, 74, 83, 92, 101, 110, 119, 128, 137, 146]]) == 9\n assert candidate(grid = [[1, 100, 2, 99, 3, 98, 4, 97], [1, 96, 2, 95, 3, 94, 4, 93], [1, 92, 2, 91, 3, 90, 4, 89], [1, 88, 2, 87, 3, 86, 4, 85]]) == 1\n assert candidate(grid = [[1, 1000, 1, 1000, 1], [1000, 1, 1000, 1, 1000], [1, 1000, 1, 1000, 1], [1000, 1, 1000, 1, 1000], [1, 1000, 1, 1000, 1]]) == 1\n assert candidate(grid = [[1, 10, 20, 30, 40, 50], [10, 9, 8, 7, 6, 5], [20, 30, 40, 50, 60, 70], [30, 20, 10, 1, 2, 3]]) == 5\n assert candidate(grid = [[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3]]) == 10\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6]]) == 4\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]]) == 4\n assert candidate(grid = [[9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 8\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]]) == 0\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]]) == 9\n assert candidate(grid = [[1, 5, 3, 6, 2], [2, 4, 1, 2, 4], [6, 4, 7, 3, 5], [2, 4, 9, 6, 3]]) == 2\n assert candidate(grid = [[10, 20, 30, 40], [25, 35, 45, 50], [40, 50, 60, 70], [50, 60, 70, 80]]) == 3\n assert candidate(grid = [[5, 12, 15, 20, 25], [3, 10, 14, 18, 22], [1, 6, 9, 13, 17], [4, 7, 11, 16, 21], [2, 8, 12, 19, 24]]) == 4\n assert candidate(grid = [[1000000, 999999, 999998], [999997, 999996, 999995], [999994, 999993, 999992]]) == 2\n assert candidate(grid = [[5, 5, 5, 5, 5], [4, 4, 4, 4, 4], [3, 3, 3, 3, 3], [2, 2, 2, 2, 2], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 10, 19, 28, 37], [2, 11, 20, 29, 38], [3, 12, 21, 30, 39], [4, 13, 22, 31, 40], [5, 14, 23, 32, 41]]) == 4\n assert candidate(grid = [[1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]]) == 10\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], [1, 2, 1, 2, 1, 2]]) == 1\n assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [6, 16, 26, 36, 46], [11, 21, 31, 41, 51]]) == 4\n assert candidate(grid = [[5, 15, 25, 35, 45, 55], [4, 14, 24, 34, 44, 54], [3, 13, 23, 33, 43, 53], [2, 12, 22, 32, 42, 52], [1, 11, 21, 31, 41, 51], [6, 16, 26, 36, 46, 56]]) == 5\n assert candidate(grid = [[9, 11, 10, 12, 14, 13, 15, 17, 16, 18], [8, 7, 9, 10, 12, 11, 13, 15, 14, 16], [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 = [[9, 8, 7, 6, 5, 4], [1, 2, 3, 4, 5, 6], [2, 1, 4, 3, 6, 5], [3, 4, 1, 2, 5, 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, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2]]) == 9\n assert candidate(grid = [[1, 11, 21, 31, 41], [2, 12, 22, 32, 42], [3, 13, 23, 33, 43], [4, 14, 24, 34, 44], [5, 15, 25, 35, 45]]) == 4\n assert candidate(grid = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [11, 21, 31, 41, 51, 61, 71, 81, 91, 101], [101, 91, 81, 71, 61, 51, 41, 31, 21, 11], [12, 22, 32, 42, 52, 62, 72, 82, 92, 102], [102, 92, 82, 72, 62, 52, 42, 32, 22, 12]]) == 9\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 = [[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], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 9\n assert candidate(grid = [[9, 5, 1, 2], [10, 6, 3, 4], [11, 7, 5, 6], [12, 8, 7, 8]]) == 0\n assert candidate(grid = [[2, 3, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3]]) == 8\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20], [5, 10, 15, 20, 25]]) == 4\n assert candidate(grid = [[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]]) == 0\n assert candidate(grid = [[5, 10, 15, 20, 25], [2, 6, 12, 18, 24], [3, 8, 13, 19, 26], [4, 9, 14, 21, 23], [7, 11, 16, 22, 27]]) == 4\n assert candidate(grid = [[10, 9, 8, 7, 6], [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]]) == 0\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]]) == 3\n assert candidate(grid = [[1, 10, 11, 12, 13, 14, 15, 16, 17, 18], [2, 9, 8, 7, 6, 5, 4, 3, 2, 1], [3, 10, 11, 12, 13, 14, 15, 16, 17, 18], [4, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 10, 11, 12, 13, 14, 15, 16, 17, 18]]) == 9\n assert candidate(grid = [[20, 21, 22, 23, 24, 25], [15, 16, 17, 18, 19, 26], [10, 11, 12, 13, 14, 27], [5, 6, 7, 8, 9, 28], [1, 2, 3, 4, 29, 30]]) == 5\n assert candidate(grid = [[5, 15, 25, 35, 45], [4, 14, 24, 34, 44], [3, 13, 23, 33, 43], [2, 12, 22, 32, 42], [1, 11, 21, 31, 41]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [8, 9, 10, 11, 12, 13, 14], [14, 13, 12, 11, 10, 9, 8]]) == 6\n assert candidate(grid = [[3, 3, 3, 10], [1, 1, 1, 1], [3, 3, 3, 5], [1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]]) == 9\n assert candidate(grid = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 111], [1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 112], [113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 124]]) == 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], [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], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 19\n assert candidate(grid = [[5, 10, 15, 20, 25], [2, 7, 12, 17, 22], [1, 6, 11, 16, 21], [3, 8, 13, 18, 23], [4, 9, 14, 19, 24]]) == 4\n assert candidate(grid = [[5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6]]) == 9\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], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]]) == 5\n assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]]) == 9\n assert candidate(grid = [[1, 5, 9, 13, 17, 21, 25, 29, 33, 37], [2, 6, 10, 14, 18, 22, 26, 30, 34, 38], [3, 7, 11, 15, 19, 23, 27, 31, 35, 39], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]]) == 9\n assert candidate(grid = [[3, 1, 2, 3, 4, 5], [1, 3, 4, 5, 6, 7], [2, 4, 5, 6, 7, 8], [3, 5, 6, 7, 8, 9], [4, 6, 7, 8, 9, 10]]) == 5\n assert candidate(grid = [[5, 3, 8, 7, 9], [6, 2, 9, 5, 10], [7, 1, 10, 6, 11], [8, 4, 11, 7, 12], [9, 5, 12, 8, 13]]) == 0\n assert candidate(grid = [[5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [5, 6, 7, 8, 9], [4, 5, 6, 7, 8], [3, 4, 5, 6, 7]]) == 4\n assert candidate(grid = [[1, 2, 10, 4, 5, 6], [2, 3, 11, 5, 6, 7], [3, 4, 12, 6, 7, 8], [4, 5, 13, 7, 8, 9], [5, 6, 14, 8, 9, 10]]) == 2\n assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == 4\n assert candidate(grid = [[1, 10, 19, 28, 37, 46], [2, 9, 18, 27, 36, 45], [3, 8, 17, 26, 35, 44], [4, 7, 16, 25, 34, 43], [5, 6, 15, 24, 33, 42], [6, 5, 14, 23, 32, 41], [7, 4, 13, 22, 31, 40], [8, 3, 12, 21, 30, 39], [9, 2, 11, 20, 29, 38]]) == 5\n assert candidate(grid = [[1, 5, 9, 14, 20], [2, 6, 10, 15, 21], [3, 7, 11, 16, 22], [4, 8, 12, 17, 23], [5, 9, 13, 18, 24]]) == 4\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxMoves", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxMoves(int[][] grid) {", "container": "Solution", "callable": "maxMoves", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2685, "task_id": "count-the-number-of-complete-components", "difficulty": "Medium", "problem_description": "You are given an integer n. There is an undirected graph with n vertices, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting vertices ai and bi.\nReturn the number of complete connected components of the graph.\nA connected component is a subgraph of a graph in which there exists a path between any two vertices, and no vertex of the subgraph shares an edge with a vertex outside of the subgraph.\nA connected component is said to be complete if there exists an edge between every pair of its vertices.\n \nExample 1:\n\n\nInput: n = 6, edges = [[0,1],[0,2],[1,2],[3,4]]\nOutput: 3\nExplanation: From the picture above, one can see that all of the components of this graph are complete.\n\nExample 2:\n\n\nInput: n = 6, edges = [[0,1],[0,2],[1,2],[3,4],[3,5]]\nOutput: 1\nExplanation: The component containing vertices 0, 1, and 2 is complete since there is an edge between every pair of two vertices. On the other hand, the component containing vertices 3, 4, and 5 is not complete since there is no edge between vertices 4 and 5. Thus, the number of complete components in this graph is 1.\n\n \nConstraints:\n\n1 <= n <= 50\n0 <= edges.length <= n * (n - 1) / 2\nedges[i].length == 2\n0 <= ai, bi <= n - 1\nai != bi\nThere are no repeated edges.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,edges = [[0, 1]]) == 1\n assert candidate(n = 1,edges = []) == 1\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [2, 4], [1, 3]]) == 0\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5]]) == 1\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]]) == 0\n assert candidate(n = 4,edges = [[0, 1], [2, 3]]) == 2\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(n = 3,edges = [[0, 1], [1, 2], [2, 0]]) == 1\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3], [3, 0]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 3]]) == 1\n assert candidate(n = 4,edges = [[0, 1], [1, 2]]) == 1\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == 0\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9]]) == 2\n assert candidate(n = 5,edges = []) == 5\n assert candidate(n = 3,edges = [[0, 1], [1, 2]]) == 0\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 2], [3, 4]]) == 3\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 0], [3, 4]]) == 2\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [7, 9]]) == 3\n assert candidate(n = 30,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15], [20, 21], [21, 22], [22, 23], [23, 24], [24, 20], [25, 26], [26, 27], [27, 28], [28, 29], [29, 25], [3, 15], [10, 25]]) == 0\n assert candidate(n = 40,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]]) == 0\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 5], [8, 9], [9, 10], [10, 11], [11, 8], [12, 13], [13, 14], [14, 12], [1, 5], [1, 11]]) == 1\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [0, 9], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14]]) == 1\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [5, 7], [6, 7], [8, 9], [9, 10], [10, 11], [11, 8], [12, 13], [13, 14], [14, 15], [15, 12], [16, 17], [17, 18], [18, 19], [19, 16], [20, 21], [21, 22], [22, 23], [23, 24], [24, 20]]) == 1\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15]]) == 2\n assert candidate(n = 40,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 11], [15, 16], [16, 17], [17, 18], [18, 15], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 25], [25, 22], [26, 27], [27, 28], [28, 29], [29, 26], [30, 31], [31, 32], [32, 33], [33, 30], [34, 35], [35, 36], [36, 37], [37, 38], [38, 34], [39, 39]]) == 1\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 4], [1, 5], [2, 6], [3, 7]]) == 0\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22]]) == 7\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [3, 6], [4, 7], [5, 8]]) == 1\n assert candidate(n = 40,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [3, 5], [6, 7], [7, 8], [6, 8], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [12, 14], [15, 16], [16, 17], [15, 17], [18, 19], [19, 20], [18, 20], [21, 22], [22, 23], [21, 23], [24, 25], [25, 26], [24, 26], [27, 28], [28, 29], [27, 29], [30, 31], [31, 32], [30, 32], [33, 34], [34, 35], [33, 35], [36, 37], [37, 38], [36, 38], [39, 39]]) == 13\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [0, 5]]) == 2\n assert candidate(n = 30,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 5], [8, 9], [9, 10], [10, 8], [11, 12], [12, 13], [13, 11], [14, 15], [15, 16], [16, 14], [17, 18], [18, 19], [19, 17], [20, 21], [21, 22], [22, 20], [23, 24], [24, 25], [25, 23], [26, 27], [27, 28], [28, 26], [29, 29]]) == 8\n assert candidate(n = 35,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15], [20, 21], [21, 22], [22, 23], [23, 24], [24, 20], [25, 26], [26, 27], [27, 28], [28, 29], [29, 25], [30, 31], [31, 32], [32, 33], [33, 34], [34, 30], [3, 9], [14, 29], [24, 34]]) == 0\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [8, 9], [9, 10], [10, 11], [11, 8], [0, 8], [1, 9], [2, 10], [3, 11]]) == 0\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [8, 9], [9, 10], [10, 8], [11, 12], [12, 13], [13, 14], [14, 11]]) == 1\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 19]]) == 5\n assert candidate(n = 35,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 18], [18, 15], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28], [31, 32], [32, 33], [33, 34], [34, 31], [3, 6], [9, 12], [15, 18], [24, 27], [30, 33]]) == 1\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 0], [1, 19], [2, 18], [3, 17], [4, 16], [5, 15]]) == 2\n assert candidate(n = 35,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 15], [18, 19], [19, 20], [20, 18], [21, 22], [22, 23], [23, 21], [24, 25], [25, 26], [26, 24], [27, 28], [28, 29], [29, 27], [30, 31], [31, 32], [32, 30], [33, 34], [34, 33]]) == 11\n assert candidate(n = 40,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15], [20, 21], [21, 22], [22, 23], [23, 24], [24, 20], [25, 26], [26, 27], [27, 28], [28, 29], [29, 25], [30, 31], [31, 32], [32, 33], [33, 34], [34, 30], [35, 36], [36, 37], [37, 38], [38, 39], [39, 35]]) == 0\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 15], [18, 19], [19, 18], [0, 15], [1, 16], [2, 17], [3, 18], [4, 19], [5, 18], [6, 19], [7, 18], [8, 19]]) == 2\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 6], [6, 3], [4, 6]]) == 1\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [0, 9], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 11], [7, 12], [8, 13]]) == 0\n assert candidate(n = 30,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]]) == 0\n assert candidate(n = 30,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 19], [20, 21], [21, 22], [22, 20], [23, 24], [24, 25], [25, 23], [26, 27], [27, 28], [28, 26], [29, 29]]) == 8\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [15, 18], [15, 19], [16, 17], [16, 18], [16, 19], [17, 18], [17, 19], [18, 19], [20, 21], [20, 22], [20, 23], [20, 24], [21, 22], [21, 23], [21, 24], [22, 23], [22, 24], [23, 24], [25, 26], [25, 27], [25, 28], [25, 29], [26, 27], [26, 28], [26, 29], [27, 28], [27, 29], [28, 29]]) == 6\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 15], [18, 19], [19, 20], [20, 18], [21, 22], [22, 23], [23, 21], [24, 0]]) == 7\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [16, 17], [16, 18], [16, 19], [17, 18], [17, 19], [18, 19], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23], [22, 23], [24, 23]]) == 5\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [3, 5], [6, 7], [7, 8], [6, 8], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [12, 14]]) == 5\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 6], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 12]]) == 0\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [16, 17], [16, 18], [16, 19], [16, 20], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20]]) == 8\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [16, 17], [16, 18], [16, 19], [16, 20], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 21]]) == 4\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11], [13, 14], [14, 13]]) == 1\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14]]) == 4\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 15], [18, 19], [19, 20], [20, 18], [21, 22], [22, 23], [23, 21], [24, 0], [1, 24], [2, 23], [3, 22], [4, 21], [5, 20]]) == 4\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 0\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 15], [18, 19], [19, 20], [20, 18], [21, 22], [22, 23], [23, 21], [24, 24]]) == 8\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [4, 6], [5, 7]]) == 1\n assert candidate(n = 30,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 15], [18, 19], [19, 20], [20, 18], [21, 22], [22, 23], [23, 21], [24, 25], [25, 26], [26, 24], [27, 28], [28, 29], [29, 27], [0, 27], [1, 28], [2, 29], [3, 26], [4, 25], [5, 24]]) == 6\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [3, 5], [6, 7], [7, 8], [6, 8], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [12, 14], [15, 16], [16, 17], [15, 17], [18, 19], [19, 20], [18, 20], [21, 22], [22, 23], [21, 23], [24, 24]]) == 8\n assert candidate(n = 30,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [3, 5], [6, 7], [7, 8], [6, 8], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [12, 14], [15, 16], [16, 17], [15, 17], [18, 19], [19, 20], [18, 20], [21, 22], [22, 23], [21, 23], [24, 25], [25, 26], [24, 26], [27, 28], [28, 29], [27, 29]]) == 10\n assert candidate(n = 20,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]]) == 0\n assert candidate(n = 40,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15], [20, 21], [21, 22], [22, 23], [23, 24], [24, 20], [25, 26], [26, 27], [27, 28], [28, 29], [29, 25], [30, 31], [31, 32], [32, 33], [33, 34], [34, 30], [35, 36], [36, 37], [37, 38], [38, 39], [39, 35], [1, 25], [10, 30]]) == 0\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [3, 5], [6, 7], [7, 8], [6, 8], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [12, 14], [15, 16], [16, 17], [15, 17], [18, 19]]) == 7\n assert candidate(n = 50,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15], [20, 21], [21, 22], [22, 23], [23, 24], [24, 20], [25, 26], [26, 27], [27, 28], [28, 29], [29, 25], [30, 31], [31, 32], [32, 33], [33, 34], [34, 30], [35, 36], [36, 37], [37, 38], [38, 39], [39, 35], [40, 41], [41, 42], [42, 43], [43, 44], [44, 40], [45, 46], [46, 47], [47, 48], [48, 49], [49, 45]]) == 0\n assert candidate(n = 30,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12], [15, 16], [16, 17], [17, 15], [18, 19], [19, 20], [20, 18], [21, 22], [22, 23], [23, 21], [24, 25], [25, 26], [26, 24], [27, 28], [28, 29], [29, 27]]) == 10\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]]) == 8\n assert candidate(n = 50,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], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49]]) == 0\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 13], [13, 10], [14, 15], [15, 16], [16, 17], [17, 14], [18, 19]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().countCompleteComponents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countCompleteComponents(int n, int[][] edges) {", "container": "Solution", "callable": "countCompleteComponents", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2696, "task_id": "minimum-string-length-after-removing-substrings", "difficulty": "Easy", "problem_description": "You are given a string s consisting only of uppercase English letters.\nYou can apply some operations to this string where, in one operation, you can remove any occurrence of one of the substrings \"AB\" or \"CD\" from s.\nReturn the minimum possible length of the resulting string that you can obtain.\nNote that the string concatenates after removing the substring and could produce new \"AB\" or \"CD\" substrings.\n \nExample 1:\n\nInput: s = \"ABFCACDB\"\nOutput: 2\nExplanation: We can do the following operations:\n- Remove the substring \"ABFCACDB\", so s = \"FCACDB\".\n- Remove the substring \"FCACDB\", so s = \"FCAB\".\n- Remove the substring \"FCAB\", so s = \"FC\".\nSo the resulting length of the string is 2.\nIt can be shown that it is the minimum length that we can obtain.\nExample 2:\n\nInput: s = \"ACBBD\"\nOutput: 5\nExplanation: We cannot do any operations on the string so the length remains the same.\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consists only of uppercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"ABCDBA\") == 2\n assert candidate(s = \"CDCDCD\") == 0\n assert candidate(s = \"ABABAB\") == 0\n assert candidate(s = \"ACBBD\") == 5\n assert candidate(s = \"ABFCACDB\") == 2\n assert candidate(s = \"AAAA\") == 4\n assert candidate(s = \"\") == 0\n assert candidate(s = \"BACD\") == 2\n assert candidate(s = \"ABCDABCD\") == 0\n assert candidate(s = \"ABACDBACDB\") == 0\n assert candidate(s = \"ABABABABABABABABAB\") == 0\n assert candidate(s = \"ACDBABCDACDB\") == 0\n assert candidate(s = \"ABCDBCDBCDCDBABCDB\") == 4\n assert candidate(s = \"FCABABCDABCDF\") == 3\n assert candidate(s = \"CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD\") == 0\n assert candidate(s = \"ABCABCABCABC\") == 4\n assert candidate(s = \"CDCDCDCDCDCDCD\") == 0\n assert candidate(s = \"ABABCDABABCD\") == 0\n assert candidate(s = \"ABCDABCDBABCDABCDB\") == 2\n assert candidate(s = \"CCCCCCCC\") == 8\n assert candidate(s = \"CDABCDAB\") == 0\n assert candidate(s = \"DDDDDDDD\") == 8\n assert candidate(s = \"CDCDCDCD\") == 0\n assert candidate(s = \"ACBDCDBDCB\") == 8\n assert candidate(s = \"ABABABAB\") == 0\n assert candidate(s = \"CDCDCDCDCDCDCDCD\") == 0\n assert candidate(s = \"AAABBBCCCDDD\") == 0\n assert candidate(s = \"CDCDCDCDABABABAB\") == 0\n assert candidate(s = \"ABABABABAB\") == 0\n assert candidate(s = \"ABABABCDCDABCDCD\") == 0\n assert candidate(s = \"ABCDABCDBACDBACDABCD\") == 2\n assert candidate(s = \"AABBCCDDBBAA\") == 4\n assert candidate(s = \"ABCDABCDAB\") == 0\n assert candidate(s = \"DCABDCABDCABDCAB\") == 2\n assert candidate(s = \"DCABDCABDCABDCABDCABDCABDCABDCAB\") == 2\n assert candidate(s = \"CDCDCDCDCDAB\") == 0\n assert candidate(s = \"DCBADCBAABCDDC\") == 10\n assert candidate(s = \"ABCDABCDCDABCDABCDCD\") == 0\n assert candidate(s = \"ABCDBACDBACD\") == 2\n assert candidate(s = \"DCBA\") == 4\n assert candidate(s = \"FCABFCABFCABFCABFCABFCABFCABFCABFCAB\") == 18\n assert candidate(s = \"DBABABCD\") == 2\n assert candidate(s = \"ABABABABABAB\") == 0\n assert candidate(s = \"BACDBACDBACDAB\") == 2\n assert candidate(s = \"AAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBB\") == 0\n assert candidate(s = \"ACDBCDABABCD\") == 0\n assert candidate(s = \"ACDBABABCDACDB\") == 0\n assert candidate(s = \"BACDBACD\") == 2\n assert candidate(s = \"ABCDBACDAB\") == 2\n assert candidate(s = \"ABCDBCDBCDAB\") == 2\n assert candidate(s = \"BACDBACDBACDBACDB\") == 1\n assert candidate(s = \"ABCDABCDCDABCD\") == 0\n assert candidate(s = \"ABCDABCDCD\") == 0\n assert candidate(s = \"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\") == 40\n assert candidate(s = \"ABCDCDAB\") == 0\n assert candidate(s = \"ABABABABABCDABCD\") == 0\n assert candidate(s = \"ABCDABCDBABCDBAB\") == 2\n assert candidate(s = \"CDCDCDCDCD\") == 0\n assert candidate(s = \"ABABABABABABABABABCDCDCDCD\") == 0\n assert candidate(s = \"ABCDABCDBAB\") == 1\n assert candidate(s = \"CDCDCDABABCDABABCDABABCD\") == 0\n assert candidate(s = \"ABABCDABABCDABABCDABABCDAB\") == 0\n assert candidate(s = \"ACDBACDBACDBACDBACDB\") == 0\n assert candidate(s = \"CDABCDABCDABCD\") == 0\n assert candidate(s = \"ACDBABABABCDAB\") == 0\n assert candidate(s = \"DCABDCAB\") == 2\n assert candidate(s = \"ABABABABABABAB\") == 0\n assert candidate(s = \"ABCDCBAABCDBCDABCDCBAABCDBCD\") == 4\n assert candidate(s = \"ABCDABCDBABCDABCDBABCDABCDBABCDABCDB\") == 4\n assert candidate(s = \"ACDBACDBACDBACDBACDBACDBACDBACDBACDB\") == 0\n assert candidate(s = \"DBACBADC\") == 8\n assert candidate(s = \"ACDBACDBACDBACDB\") == 0\n assert candidate(s = \"BACDBACDBACDBACDBACD\") == 2\n assert candidate(s = \"AAAAAAAA\") == 8\n assert candidate(s = \"CDABCDABCDABCDABCDAB\") == 0\n assert candidate(s = \"CDABCDABCDABCDABCDABCDABCDABCDABCDAB\") == 0\n assert candidate(s = \"CDCDCDCDCDCD\") == 0\n assert candidate(s = \"ABACBCADCD\") == 6\n assert candidate(s = \"ABCDABCDBACDBACD\") == 2\n assert candidate(s = \"ABABCDABABCDAB\") == 0\n assert candidate(s = \"ABCDDCBA\") == 4\n assert candidate(s = \"ABCDABCDABCDABCDABCDABCDABCDABCD\") == 0\n assert candidate(s = \"BACDBACDBACDBACD\") == 2\n assert candidate(s = \"XYZ\") == 3\n assert candidate(s = \"ABABABABABABABABABAB\") == 0\n assert candidate(s = \"BBBBBBBBBBBBBBBB\") == 16\n assert candidate(s = \"CDCDCDABABCD\") == 0\n assert candidate(s = \"AAAAAAAAAAAAAAAA\") == 16\n assert candidate(s = \"BBBBBBBB\") == 8\n assert candidate(s = \"CDCDABAB\") == 0\n assert candidate(s = \"CDABCDABCDAB\") == 0\n assert candidate(s = \"ABCDABCDABCD\") == 0\n assert candidate(s = \"CDABCDABCD\") == 0\n assert candidate(s = \"ABCDABCDABCDBACD\") == 2\n assert candidate(s = \"ACBDCDBDCBDCB\") == 11\n assert candidate(s = \"ABABABABABCD\") == 0\n assert candidate(s = \"AAAAABBBBB\") == 0\n assert candidate(s = \"ABCDBCDABCDBCDABCDBCDABCDBCD\") == 4\n assert candidate(s = \"ABABABABABABABABABABABABABABABABABAB\") == 0\n assert candidate(s = \"BBCCCDDDAABB\") == 2\n assert candidate(s = \"ABCCBAABCCBA\") == 8\n assert candidate(s = \"ACBDABFCDC\") == 6\n assert candidate(s = \"ABCDABCDABCDAB\") == 0\n assert candidate(s = \"BBBBBAAAAA\") == 10\n assert candidate(s = \"FFFFFFFFFFFFFFFF\") == 16\n assert candidate(s = \"CABACDBABC\") == 2\n assert candidate(s = \"CDCDCDCDCDABABABAB\") == 0\n assert candidate(s = \"ABABDCDCCCDA\") == 4\n assert candidate(s = \"ACBDACBDACBD\") == 12\n assert candidate(s = \"AACBBCCDAD\") == 8\n assert candidate(s = \"ABCDCBAABCDBCD\") == 2\n assert candidate(s = \"ABCDABCDBACD\") == 2\n assert candidate(s = \"DCBADCBABC\") == 8\n assert candidate(s = \"BACDBACDBACDB\") == 1\n assert candidate(s = \"ABCDABCDBACDAB\") == 2\n assert candidate(s = \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\") == 40\n assert candidate(s = \"FCABFCABFCABFCABFCAB\") == 10\n assert candidate(s = \"FCABFCABFCAB\") == 6\n assert candidate(s = \"BACDBACDBACDBACDBACDBACDBACDBACDBACDB\") == 1\n assert candidate(s = \"ABCDABCDBABD\") == 2\n assert candidate(s = \"ACBACDBCDB\") == 4\n assert candidate(s = \"ABACDABACDABACD\") == 3\n assert candidate(s = \"BACDBACDBACDBACDBACDBACD\") == 2\n assert candidate(s = \"ABABABABABABABABABABABABAB\") == 0\n assert candidate(s = \"BACDBACDBACD\") == 2\n assert candidate(s = \"CDCDCDCDCDCDCDCDCD\") == 0\n assert candidate(s = \"ABCDBCDBCDABCDBCDABCDBCDABCDBCD\") == 5\n assert candidate(s = \"ABCDABCDBABC\") == 2\n assert candidate(s = \"ABCDABCDBABCDABCDBABCDABCDBAB\") == 3\n assert candidate(s = \"ABCDABCDCDAB\") == 0\n assert candidate(s = \"ABCDEFGHABCD\") == 4\n assert candidate(s = \"AAAAAAAAAABBBBBBBBBB\") == 0\n assert candidate(s = \"BBBBBBBBBAAAAAAAAABBBBBBBBBBAAAAAAAAAA\") == 20\n assert candidate(s = \"AABABBCCDDBBCC\") == 4\n assert candidate(s = \"ABCDABCDABCDABCD\") == 0\n assert candidate(s = \"ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\") == 0\n assert candidate(s = \"ACDBACDBACDB\") == 0\n assert candidate(s = \"BACDBACDBABCDABCD\") == 1\n assert candidate(s = \"DCABDCABDCABDCABDCABDCABDCABDCABDCABDCABDCAB\") == 2\n assert candidate(s = \"ABACADABAD\") == 6\n assert candidate(s = \"ABCD\") == 0\n assert candidate(s = \"BBBBBBBBBAAAAAAAAA\") == 18\n assert candidate(s = \"ABCDABCDABCDABCDABCD\") == 0\n assert candidate(s = \"ABABABABABCDABCDBACDBACD\") == 2\n assert candidate(s = \"DCDABABABABABABCD\") == 1\n assert candidate(s = \"ABABABABCDABCDBACDBACDABABABAB\") == 2\n assert candidate(s = \"CDCDCDCDCDCDCDCDCDCDCDCD\") == 0\n assert candidate(s = \"ACDBACDB\") == 0\n assert candidate(s = \"ABABCDABCD\") == 0\n assert candidate(s = \"AACBBCCCDD\") == 6\n assert candidate(s = \"ABABABABABABCD\") == 0\n assert candidate(s = \"AACCBBAADD\") == 10\n assert candidate(s = \"ABABCDABABCDABCD\") == 0\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minLength(String s) {", "container": "Solution", "callable": "minLength", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2697, "task_id": "lexicographically-smallest-palindrome", "difficulty": "Easy", "problem_description": "You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a character in s with another lowercase English letter.\nYour task is to make s a palindrome with the minimum number of operations possible. If there are multiple palindromes that can be made using the minimum number of operations, make the lexicographically smallest one.\nA string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\nReturn the resulting palindrome string.\n \nExample 1:\n\nInput: s = \"egcfe\"\nOutput: \"efcfe\"\nExplanation: The minimum number of operations to make \"egcfe\" a palindrome is 1, and the lexicographically smallest palindrome string we can get by modifying one character is \"efcfe\", by changing 'g'.\n\nExample 2:\n\nInput: s = \"abcd\"\nOutput: \"abba\"\nExplanation: The minimum number of operations to make \"abcd\" a palindrome is 2, and the lexicographically smallest palindrome string we can get by modifying two characters is \"abba\".\n\nExample 3:\n\nInput: s = \"seven\"\nOutput: \"neven\"\nExplanation: The minimum number of operations to make \"seven\" a palindrome is 1, and the lexicographically smallest palindrome string we can get by modifying one character is \"neven\".\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == \"abcba\"\n assert candidate(s = \"madam\") == \"madam\"\n assert candidate(s = \"abac\") == \"aaaa\"\n assert candidate(s = \"aabbaa\") == \"aabbaa\"\n assert candidate(s = \"abcdcba\") == \"abcdcba\"\n assert candidate(s = \"zyxwvutsrponmlkjihgfedcba\") == \"abcdefghijklmlkjihgfedcba\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"xyzyx\") == \"xyzyx\"\n assert candidate(s = \"ab\") == \"aa\"\n assert candidate(s = \"abcde\") == \"abcba\"\n assert candidate(s = \"zyxwvutsrqp\") == \"pqrstutsrqp\"\n assert candidate(s = \"racecar\") == \"racecar\"\n assert candidate(s = \"egcfe\") == \"efcfe\"\n assert candidate(s = \"race\") == \"eaae\"\n assert candidate(s = \"abc\") == \"aba\"\n assert candidate(s = \"abcd\") == \"abba\"\n assert candidate(s = \"pqrqs\") == \"pqrqp\"\n assert candidate(s = \"hello\") == \"heleh\"\n assert candidate(s = \"seven\") == \"neven\"\n assert candidate(s = \"xyzzyx\") == \"xyzzyx\"\n assert candidate(s = \"abcdefg\") == \"abcdcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijklnopqrsrqpnlkjihgfedcba\") == \"abcdefghijklnopqrrqponlkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijklnopqrstuvutsrqpnlkjihgfedcba\") == \"abcdefghijklnopqrstuutsrqponlkjihgfedcba\"\n assert candidate(s = \"thisisaverylongstringthatneedstobemadeapalindromebutitisnotyetanditwilltakealotofchangesanditwillbeinterestingtosolveanditwillbeaveryinterestingproblemtofigureoutanditwillbeanevenmoreinterestingproblemtosolveanditwillrequirealotofthoughtandcreativity\") == \"thisisaeecdlanggtohnfohalaeedsqebeladeadaaendoomebelboipgniteeaediieillnakeaaeblfchaideaanderugifbeielboepgiigserelneandiaebllbeaidnaenleresgiigpeobleiebfigurednaaediahcflbeaaekanllieiideaeetingpioblebemoodneaadaedalebeqsdeealahofnhotggnaldceeasisiht\"\n assert candidate(s = \"reddering\") == \"geddeddeg\"\n assert candidate(s = \"abcdefghijklnopqrstuvwxyyxwvutsrqpnlkjihgfedcba\") == \"abcdefghijklnopqrstuvwxyxwvutsrqponlkjihgfedcba\"\n assert candidate(s = \"kooking\") == \"gniking\"\n assert candidate(s = \"rotorrotor\") == \"rotorrotor\"\n assert candidate(s = \"abracadabra\") == \"abbacacabba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"palindromeisaveryinterestingwordandshouldbecomeapalindromewithevenmorecharacters\") == \"paeicarahcerameevehteremoidgiladaedocebddbecodeadaligdiomeretheveemarecharacieap\"\n assert candidate(s = \"thisisaverylongstringthatwillrequiremanychangesandshouldresultinastrongpalindrome\") == \"ehirdnalapglongsaningthardillhednaregaahchaagerandehllidrahtgninasgnolgpalandrihe\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"thisisaverylongstringthatweneedtopalindromify\") == \"tfimiranelalondeenengahagneneednolalenarimift\"\n assert candidate(s = \"racecarx\") == \"raaccaar\"\n assert candidate(s = \"referenced\") == \"deceeeeced\"\n assert candidate(s = \"leveling\") == \"geieeieg\"\n assert candidate(s = \"zxyyz\") == \"zxyxz\"\n assert candidate(s = \"abcdpqrsstuvqponmlkjihgfedcba\") == \"abcdefghijklmnonmlkjihgfedcba\"\n assert candidate(s = \"zzzzzzzzzz\") == \"zzzzzzzzzz\"\n assert candidate(s = \"xyzzzzyxzyxzyzxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxz\") == \"xxyzxyyxyyxyyxxzxxzxxzxxzxxzxxzxxzxxzxxzxxzxxyyxyyxyyxzyxx\"\n assert candidate(s = \"xyzzzxy\") == \"xxzzzxx\"\n assert candidate(s = \"repaid\") == \"deaaed\"\n assert candidate(s = \"palindromemordnilap\") == \"palindromemordnilap\"\n assert candidate(s = \"palindromeisaveryinterestingword\") == \"daligdiomeieanerrenaeiemoidgilad\"\n assert candidate(s = \"qwertyuiopoiuytrewq\") == \"qwertyuiopoiuytrewq\"\n assert candidate(s = \"algorithm\") == \"ahgirigha\"\n assert candidate(s = \"wow\") == \"wow\"\n assert candidate(s = \"abcdefghijkllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllkjihgfedcba\"\n assert candidate(s = \"redder\") == \"redder\"\n assert candidate(s = \"aaaaabbbbbccccdddd\") == \"aaaaabbbbbbbbaaaaa\"\n assert candidate(s = \"zzzzz\") == \"zzzzz\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"zxcvbnmnbvcxz\") == \"zxcvbnmnbvcxz\"\n assert candidate(s = \"peep\") == \"peep\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"rotavator\") == \"rotavator\"\n assert candidate(s = \"aabbccddeeeeffgghhiijj\") == \"aabbccddeeeeeeddccbbaa\"\n assert candidate(s = \"releveler\") == \"releveler\"\n assert candidate(s = \"sagas\") == \"sagas\"\n assert candidate(s = \"abcdefghijkllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"palindrome\") == \"ealiddilae\"\n assert candidate(s = \"kook\") == \"kook\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"aaaaabaaaa\") == \"aaaaaaaaaa\"\n assert candidate(s = \"kayak\") == \"kayak\"\n assert candidate(s = \"abcdefghijklnmlkjihgfedcba\") == \"abcdefghijklmmlkjihgfedcba\"\n assert candidate(s = \"palindromeisaveryinterestingwordandshouldbecomeapalindromewithaverylongstringandmorecharacters\") == \"paeicarahceramdnagnieregnilgreraandsemoldbecamaamacebdlomesdnaarerglingereingandmarecharacieap\"\n assert candidate(s = \"racecarxracecar\") == \"racecarxracecar\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"aabbbaaa\") == \"aaabbaaa\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"xyzzzyx\") == \"xyzzzyx\"\n assert candidate(s = \"referencing\") == \"gefcnencfeg\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllkjihgfedcba\") == \"abcdefghijkllllllkjihgfedcba\"\n assert candidate(s = \"thisisaverylongstringthatneedstobemadeapalindromebutitisnotyetanditwilltakealotofchangesanditwillbeinterestingtosolveanditwillbeaveryinterestingproblemtofigureout\") == \"thieisaieotlelborpgngthareeedsrebaeadeapaidnaeolebotgnisnereenaebiliilidaaeagnahcchangaeaadiliilibeaneerensingtobeloeandiapaedaeabersdeeerahtgngprobleltoeiasieiht\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"abcdeedcba\") == \"abcdeedcba\"\n assert candidate(s = \"deeding\") == \"deedeed\"\n assert candidate(s = \"noon\") == \"noon\"\n assert candidate(s = \"abacaxbba\") == \"abacacaba\"\n assert candidate(s = \"aabbccddeeeeffgg\") == \"aabbccddddccbbaa\"\n assert candidate(s = \"deeee\") == \"deeed\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"revileddidilver\") == \"reviidddddiiver\"\n assert candidate(s = \"abacaxabayabaz\") == \"aaaaaaaaaaaaaa\"\n assert candidate(s = \"reviling\") == \"geiiiieg\"\n assert candidate(s = \"revolover\") == \"revolover\"\n assert candidate(s = \"thisisaverylongstringthatneedstobemadeapalindromebutitisnotyet\") == \"teisinaieitlbegordiigahaedaedboobdeadeahagiidrogebltieianisiet\"\n assert candidate(s = \"abcdeffedcba\") == \"abcdeffedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"wasitacaroracatisaw\") == \"wasitacaroracatisaw\"\n assert candidate(s = \"levellevel\") == \"levellevel\"\n assert candidate(s = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == \"aabbccddeeffgghhiijjkkllmmmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"xerox\") == \"xerex\"\n assert candidate(s = \"aibohphobia\") == \"aibohphobia\"\n assert candidate(s = \"abcdefghijklnopqponmlkjihgfedcba\") == \"abcdefghijklmnopponmlkjihgfedcba\"\n assert candidate(s = \"abcdefedcba\") == \"abcdefedcba\"\n assert candidate(s = \"programming\") == \"gnigmamging\"\n assert candidate(s = \"level\") == \"level\"\n assert candidate(s = \"abcdefghijklnopqrstuvwxyzzyxwvutsrqpnlkjihgfedcba\") == \"abcdefghijklnopqrstuvwxyzyxwvutsrqponlkjihgfedcba\"\n assert candidate(s = \"aabbccdd\") == \"aabbbbaa\"\n assert candidate(s = \"stats\") == \"stats\"\n assert candidate(s = \"deedful\") == \"deedeed\"\n assert candidate(s = \"thisisaverylongstringthatneedstobemadeapalindromebutitisnotyetanditwilltakealotofchangesanditwillbeinterestingtosolve\") == \"ehioioageitlenesniebglhatideasegbahadeaoaaekarllebtidnaseotoesanditbellrakeaaoaedahabgesaeditahlgbeinseneltiegaoioihe\"\n assert candidate(s = \"xyxzyxzyxzyx\") == \"xyxxyxxyxxyx\"\n assert candidate(s = \"abcdefghijjihgfedcba\") == \"abcdefghijjihgfedcba\"\n assert candidate(s = \"abcdefghijk\") == \"abcdefedcba\"\n assert candidate(s = \"aabccbaa\") == \"aabccbaa\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyxwwvvuuttssrrqppoonnmlllkkkjjjiihhggffeeeeddccbbaa\") == \"aabbccddeeeeffgghhiijjjkkklllmnnooppqrrssttuuvvwwxyyzyyxwwvvuuttssrrqppoonnmlllkkkjjjiihhggffeeeeddccbbaa\"\n assert candidate(s = \"abcdefgihgfedcba\") == \"abcdefghhgfedcba\"\n assert candidate(s = \"palindromeisaveryinterestingwordandshouldbecomeapalindrome\") == \"ealiddilaeaeaocebdltehednadgoogdandehetldbecoaeaealiddilae\"\n assert candidate(s = \"abacabadabacaba\") == \"abacabadabacaba\"\n assert candidate(s = \"abcdefghijkjihgfedcba\") == \"abcdefghijkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"sommersommers\") == \"soemeosoemeos\"\n assert candidate(s = \"rotator\") == \"rotator\"\n assert candidate(s = \"aabbccddeeeeffgghhiijjkkll\") == \"aabbccddeeeeffeeeeddccbbaa\"\n assert candidate(s = \"redivider\") == \"redivider\"\n assert candidate(s = \"racecarabc\") == \"caaeaaeaac\"\n assert candidate(s = \"abcdefghijihgfedcba\") == \"abcdefghijihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllkjihgfedcba\"\n assert candidate(s = \"peeping\") == \"geepeeg\"\n assert candidate(s = \"abcdefghijklnopqrstuvwxwvutsrqpnlkjihgfedcba\") == \"abcdefghijklnopqrstuvwwvutsrqponlkjihgfedcba\"\n assert candidate(s = \"thisisaverylongstringthatwillrequiremanychangesandshouldresultinastrongpalindromewithlongtext\") == \"thesgnalerilemgrdnilapgaorilaneqliremaluchadgasagdahculamerilqenaliroagpalindrgmelirelangseht\"\n assert candidate(s = \"deifiedly\") == \"dedeieded\"\n assert candidate(s = \"abcdefghijkllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllkjihgfedcba\"\n assert candidate(s = \"banana\") == \"aaaaaa\"\n assert candidate(s = \"abcdefghijkmlkjihgfedcba\") == \"abcdefghijkllkjihgfedcba\"\n assert candidate(s = \"palindromeisaveryinterestingwordandshouldbecomeapalindromewithaverylongstring\") == \"gaiindgnmeiravahtineeoednilapaedacdbdluldbdcadeapalindeoeenithavariemngdniiag\"\n assert candidate(s = \"radar\") == \"radar\"\n assert candidate(s = \"aabaaa\") == \"aaaaaa\"\n assert candidate(s = \"reviledly\") == \"redeleder\"\n assert candidate(s = \"aabbccddeeffgg\") == \"aabbccddccbbaa\"\n assert candidate(s = \"detartrated\") == \"detartrated\"\n assert candidate(s = \"abccba\") == \"abccba\"\n assert candidate(s = \"amazingracecar\") == \"aaaecaggaceaaa\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"repapering\") == \"geiaeeaieg\"\n assert candidate(s = \"reviver\") == \"reviver\"\n assert candidate(s = \"palindromic\") == \"calindnilac\"\n assert candidate(s = \"madamimadam\") == \"madamimadam\"\n assert candidate(s = \"aabbccddeeeeffgghhiijjkkllmm\") == \"aabbccddeeeeffffeeeeddccbbaa\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhiijjkkllmmmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"aabbccddeeeeffgghh\") == \"aabbccddeeddccbbaa\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"amanaplanacanalpanama\") == \"amanaplanacanalpanama\"\n assert candidate(s = \"thisisaverylongstringthatneedstobemadeapalindromebutitisnotyetanditwilltakealotofchangesanditwillbeinterestingtosolveanditwillbeaveryinterestingproblem\") == \"meibirageitlenesniinetaableedsidbaeadeaoagiidremebniebiliotidnandgnahcfoakeaekaofchangdnanditoilibeinbemerdiigaoaedaeabdisdeelbaateniinseneltiegaribiem\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmmlkjihgfedcba\"\n assert candidate(s = \"aaaabbbbccccdddd\") == \"aaaabbbbbbbbaaaa\"\n assert candidate(s = \"rotorst\") == \"rororor\"\n assert candidate(s = \"zxyxzyxzyxz\") == \"zxyxxyxxyxz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmmlkjihgfedcba\"\n assert candidate(s = \"deified\") == \"deified\"\n assert candidate(s = \"abcdefghijkllllllllkjihgfedcba\") == \"abcdefghijkllllllllkjihgfedcba\"\n assert candidate(s = \"aabbccddeeddffgg\") == \"aabbccddddccbbaa\"\n assert candidate(s = \"repaper\") == \"repaper\"\n assert candidate(s = \"rotated\") == \"detated\"\n assert candidate(s = \"abcdedcba\") == \"abcdedcba\"\n assert candidate(s = \"abcdefghijkllkjihgfedcba\") == \"abcdefghijkllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"xyloxyloxyloxylo\") == \"olloolloolloollo\"\n assert candidate(s = \"palindromeisaveryinterestingwordandshouldbecomeapalindromewithadditionalcharacters\") == \"paeicarahciaaoeriddaereseingdnidanaehocebbecoheanadindgniesereaddireoaaicharacieap\"\n assert candidate(s = \"kayaking\") == \"gaiaaiag\"\n assert candidate(s = \"abcdefghijkllllkjihgfedcba\") == \"abcdefghijkllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijklnopqrqponmlkjihgfedcba\") == \"abcdefghijklmnopqqponmlkjihgfedcba\"\n assert candidate(s = \"abcddcba\") == \"abcddcba\"\n assert candidate(s = \"aaaaabaaa\") == \"aaaaaaaaa\"\n assert candidate(s = \"rotor\") == \"rotor\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz\") == \"aabbccddeeffgghhiijjkkllmmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"civic\") == \"civic\"\n assert candidate(s = \"abcdefghihgfedcba\") == \"abcdefghihgfedcba\"\n assert candidate(s = \"aaabbbbccccc\") == \"aaabbbbbbaaa\"\n assert candidate(s = \"abcdefghijkmmmlkjihgfedcba\") == \"abcdefghijklmmlkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\") == \"aodicabehtneoojpmpjooenthebacidoa\"\n assert candidate(s = \"xyxzyx\") == \"xyxxyx\"\n assert candidate(s = \"noonday\") == \"nadndan\"\n assert candidate(s = \"thisisaverylongstringthatneedstobemadeapalindrome\") == \"ehirdnalapaedageboindeeataeedniobegadeapalandrihe\"\n assert candidate(s = \"reviled\") == \"deliled\"\n assert candidate(s = \"aabbccddeeaabbccdd\") == \"aabbbbaaeeaabbbbaa\"\n assert candidate(s = \"thisisaverylongstringthatneedstobemadeapalindromebutitisnotyetanditwilltakealotofchangesanditwillbeinterestingtosolveanditwillbeaveryinterestingproblemtofigureoutanditwillbeanevenmoreinterestingproblemtosolve\") == \"ehioioamelblongniriegehaieeedneobeaabeaialiddaomebrtgifonmelboandiitieleakealetaebhaigeianaetlillbeiiteeeetiiebllilteanaiegiahbeatelaekaeleitiidnaoblemnofigtrbemoaddilaiaebaaeboendeeeiahegeiringnolblemaoioihe\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"civicly\") == \"cicicic\"\n assert candidate(s = \"abcdefghijklimnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklimnopqrstuvwxyyxwvutsrqponmilkjihgfedcba\"\n assert candidate(s = \"aabbccddeeeeffgghhiijjkk\") == \"aabbccddeeeeeeeeddccbbaa\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijhgfedcba\") == \"abcdefghiihgfedcba\"\n assert candidate(s = \"aabbcc\") == \"aabbaa\"\n assert candidate(s = \"mississippi\") == \"iipiisiipii\"\n assert candidate(s = \"abcdefghijklnopqrstuvwutvqpnlkjihgfedcba\") == \"abcdefghijklnopqrstuutsrqponlkjihgfedcba\"\n assert candidate(s = \"solos\") == \"solos\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyxwwvvttuussrrqqponnmlllkkjjiihhggffeeddccbaabbaa\") == \"aabbaabccddeeffgghhiijjkklllmnnopqqrrsstuttvvwwxyyzzzyyxwwvvttutssrrqqponnmlllkkjjiihhggffeeddccbaabbaa\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"abcdefghijkllllllllllllllllllllllllllllkjihgfedcba\") == \"abcdefghijkllllllllllllllllllllllllllllkjihgfedcba\"\n assert candidate(s = \"aabbccddeeeffggghhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeeffggghhiiijjkkllmllkkjjiiihhgggffeeeddccbbaa\"\n assert candidate(s = \"thisisaverylongstringthatneedstobemadeapalindromebutitisnotyetanditwilltakealotofchanges\") == \"segnahaferolaegatliigthanaeedsonbemadeaealiddilaeaedamebnosdeeanahtgiiltagealorefahanges\"\n assert candidate(s = \"abcdefdcba\") == \"abcdeedcba\"\n assert candidate(s = \"deed\") == \"deed\"\n assert candidate(s = \"abacaxaba\") == \"abacacaba\"\n assert candidate(s = \"neveroddoreven\") == \"neveroddoreven\"\n assert candidate(s = \"abcdefghijklnopqrstsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrssrqponmlkjihgfedcba\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"refer\") == \"refer\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().makeSmallestPalindrome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String makeSmallestPalindrome(String s) {", "container": "Solution", "callable": "makeSmallestPalindrome", "parameters": [{"name": "s", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2698, "task_id": "find-the-punishment-number-of-an-integer", "difficulty": "Medium", "problem_description": "Given a positive integer n, return the punishment number of n.\nThe punishment number of n is defined as the sum of the squares of all integers i such that:\n\n1 <= i <= n\nThe decimal representation of i * i can be partitioned into contiguous substrings such that the sum of the integer values of these substrings equals i.\n\n \nExample 1:\n\nInput: n = 10\nOutput: 182\nExplanation: There are exactly 3 integers i in the range [1, 10] that satisfy the conditions in the statement:\n- 1 since 1 * 1 = 1\n- 9 since 9 * 9 = 81 and 81 can be partitioned into 8 and 1 with a sum equal to 8 + 1 == 9.\n- 10 since 10 * 10 = 100 and 100 can be partitioned into 10 and 0 with a sum equal to 10 + 0 == 10.\nHence, the punishment number of 10 is 1 + 81 + 100 = 182\n\nExample 2:\n\nInput: n = 37\nOutput: 1478\nExplanation: There are exactly 4 integers i in the range [1, 37] that satisfy the conditions in the statement:\n- 1 since 1 * 1 = 1. \n- 9 since 9 * 9 = 81 and 81 can be partitioned into 8 + 1. \n- 10 since 10 * 10 = 100 and 100 can be partitioned into 10 + 0. \n- 36 since 36 * 36 = 1296 and 1296 can be partitioned into 1 + 29 + 6.\nHence, the punishment number of 37 is 1 + 81 + 100 + 1296 = 1478\n\n \nConstraints:\n\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 700) == 1660140\n assert candidate(n = 800) == 3353149\n assert candidate(n = 100) == 41334\n assert candidate(n = 600) == 772866\n assert candidate(n = 37) == 1478\n assert candidate(n = 200) == 41334\n assert candidate(n = 400) == 601470\n assert candidate(n = 900) == 3353149\n assert candidate(n = 9) == 82\n assert candidate(n = 2) == 1\n assert candidate(n = 25) == 182\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 772866\n assert candidate(n = 1000) == 10804657\n assert candidate(n = 10) == 182\n assert candidate(n = 300) == 184768\n assert candidate(n = 50) == 3503\n assert candidate(n = 625) == 772866\n assert candidate(n = 999) == 9804657\n assert candidate(n = 750) == 2154349\n assert candidate(n = 150) == 41334\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().punishmentNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int punishmentNumber(int n) {", "container": "Solution", "callable": "punishmentNumber", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2699, "task_id": "modify-graph-edge-weights", "difficulty": "Hard", "problem_description": "You are given an undirected weighted connected graph containing n nodes labeled from 0 to n - 1, and an integer array edges where edges[i] = [ai, bi, wi] indicates that there is an edge between nodes ai and bi with weight wi.\nSome edges have a weight of -1 (wi = -1), while others have a positive weight (wi > 0).\nYour task is to modify all edges with a weight of -1 by assigning them positive integer values in the range [1, 2 * 109] so that the shortest distance between the nodes source and destination becomes equal to an integer target. If there are multiple modifications that make the shortest distance between source and destination equal to target, any of them will be considered correct.\nReturn an array containing all edges (even unmodified ones) in any order if it is possible to make the shortest distance from source to destination equal to target, or an empty array if it's impossible.\nNote: You are not allowed to modify the weights of edges with initial positive weights.\n \nExample 1:\n\n\nInput: n = 5, edges = [[4,1,-1],[2,0,-1],[0,3,-1],[4,3,-1]], source = 0, destination = 1, target = 5\nOutput: [[4,1,1],[2,0,1],[0,3,3],[4,3,1]]\nExplanation: The graph above shows a possible modification to the edges, making the distance from 0 to 1 equal to 5.\n\nExample 2:\n\n\nInput: n = 3, edges = [[0,1,-1],[0,2,5]], source = 0, destination = 2, target = 6\nOutput: []\nExplanation: The graph above contains the initial edges. It is not possible to make the distance from 0 to 2 equal to 6 by modifying the edge with weight -1. So, an empty array is returned.\n\nExample 3:\n\n\nInput: n = 4, edges = [[1,0,4],[1,2,3],[2,3,5],[0,3,-1]], source = 0, destination = 2, target = 6\nOutput: [[1,0,4],[1,2,3],[2,3,5],[0,3,1]]\nExplanation: The graph above shows a modified graph having the shortest distance from 0 to 2 as 6.\n\n \nConstraints:\n\n1 <= n <= 100\n1 <= edges.length <= n * (n - 1) / 2\nedges[i].length == 3\n0 <= ai, bi < n\nwi = -1 or 1 <= wi <= 107\nai != bi\n0 <= source, destination < n\nsource != destination\n1 <= target <= 109\nThe graph is connected, and there are no self-loops or repeated edges\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,edges = [[0, 1, -1]],source = 0,destination = 1,target = 1) == [[0, 1, 1]]\n assert candidate(n = 4,edges = [[1, 0, 4], [1, 2, 3], [2, 3, 5], [0, 3, -1]],source = 0,destination = 2,target = 6) == [[1, 0, 4], [1, 2, 3], [2, 3, 5], [0, 3, 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]],source = 0,destination = 3,target = 12) == [[0, 1, 1], [1, 2, 1], [2, 3, 10], [3, 4, 2000000000], [4, 5, 2000000000], [5, 0, 2000000000]]\n assert candidate(n = 4,edges = [[0, 1, 2], [1, 2, -1], [2, 3, -1], [3, 0, -1]],source = 0,destination = 3,target = 5) == [[0, 1, 2], [1, 2, 1], [2, 3, 2], [3, 0, 2000000000]]\n assert candidate(n = 3,edges = [[0, 1, 1], [1, 2, -1]],source = 0,destination = 2,target = 4) == [[0, 1, 1], [1, 2, 3]]\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 3], [2, 3, -1], [3, 4, -1], [4, 5, -1]],source = 0,destination = 5,target = 15) == [[0, 1, 2], [1, 2, 3], [2, 3, 1], [3, 4, 1], [4, 5, 8]]\n assert candidate(n = 4,edges = [[0, 1, -1], [0, 2, -1], [1, 2, -1], [1, 3, -1], [2, 3, -1]],source = 0,destination = 3,target = 3) == [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 2], [2, 3, 2000000000]]\n assert candidate(n = 5,edges = [[4, 1, -1], [2, 0, -1], [0, 3, -1], [4, 3, -1]],source = 0,destination = 1,target = 5) == [[4, 1, 1], [2, 0, 1], [0, 3, 1], [4, 3, 3]]\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 3], [2, 3, -1], [3, 4, -1], [4, 5, -1]],source = 0,destination = 5,target = 12) == [[0, 1, 2], [1, 2, 3], [2, 3, 1], [3, 4, 1], [4, 5, 5]]\n assert candidate(n = 3,edges = [[0, 1, -1], [0, 2, 5]],source = 0,destination = 2,target = 6) == []\n assert candidate(n = 4,edges = [[0, 1, 1], [1, 2, -1], [2, 3, -1], [0, 3, -1]],source = 0,destination = 3,target = 3) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [0, 3, 2000000000]]\n assert candidate(n = 9,edges = [[0, 1, 1], [1, 2, 2], [2, 3, -1], [3, 4, -1], [4, 5, -1], [5, 6, 3], [6, 7, -1], [7, 8, -1], [8, 0, 4], [0, 3, -1], [1, 4, -1], [2, 5, -1], [3, 6, 5], [4, 7, -1], [5, 8, -1]],source = 0,destination = 8,target = 25) == []\n assert candidate(n = 9,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, 0, -1], [0, 4, 8]],source = 0,destination = 5,target = 25) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 21], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 0, 2000000000], [0, 4, 8]]\n assert candidate(n = 10,edges = [[0, 1, 5], [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, 0, -1]],source = 0,destination = 5,target = 30) == [[0, 1, 5], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 22], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 9, 2000000000], [9, 0, 2000000000]]\n assert candidate(n = 7,edges = [[0, 1, -1], [1, 2, -1], [2, 3, -1], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 0, -1], [0, 3, 5], [1, 4, 6], [2, 5, 7]],source = 0,destination = 6,target = 28) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 23], [6, 0, 2000000000], [0, 3, 5], [1, 4, 6], [2, 5, 7]]\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], [9, 0, -1], [0, 5, 10]],source = 0,destination = 7,target = 30) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 24], [7, 8, 2000000000], [8, 9, 2000000000], [9, 0, 2000000000], [0, 5, 10]]\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, -1], [1, 3, -1], [1, 4, -1], [2, 5, 3], [2, 6, -1], [3, 4, 2], [4, 5, -1], [5, 6, 1]],source = 0,destination = 6,target = 18) == [[0, 1, 1], [0, 2, 14], [1, 3, 2000000000], [1, 4, 2000000000], [2, 5, 3], [2, 6, 2000000000], [3, 4, 2], [4, 5, 2000000000], [5, 6, 1]]\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, -1], [2, 3, 2], [3, 4, -1], [4, 5, 3], [5, 6, -1], [6, 7, 4], [7, 8, -1], [8, 9, -1], [9, 0, -1]],source = 0,destination = 5,target = 20) == [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 13], [4, 5, 3], [5, 6, 2000000000], [6, 7, 4], [7, 8, 2000000000], [8, 9, 2000000000], [9, 0, 2000000000]]\n assert candidate(n = 13,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, 0, -1]],source = 0,destination = 12,target = 52) == [[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, 41], [12, 0, 2000000000]]\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 0, 1]],source = 0,destination = 3,target = 10) == []\n assert candidate(n = 15,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, 0, -1]],source = 2,destination = 11,target = 30) == [[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, 22], [11, 12, 2000000000], [12, 13, 2000000000], [13, 14, 2000000000], [14, 0, 2000000000]]\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], [7, 0, -1], [0, 2, -1], [1, 3, -1], [2, 4, -1], [3, 5, -1], [4, 6, -1], [5, 7, -1]],source = 0,destination = 7,target = 32) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 26], [7, 0, 2000000000], [0, 2, 2000000000], [1, 3, 2000000000], [2, 4, 2000000000], [3, 5, 2000000000], [4, 6, 2000000000], [5, 7, 2000000000]]\n assert candidate(n = 12,edges = [[0, 1, -1], [1, 2, -1], [2, 3, 2], [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]],source = 0,destination = 6,target = 20) == [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 5, 1], [5, 6, 14], [6, 7, 2000000000], [7, 8, 2000000000], [8, 9, 2000000000], [9, 10, 2000000000], [10, 11, 2000000000], [11, 0, 2000000000]]\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], [19, 0, -1]],source = 0,destination = 15,target = 60) == [[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, 46], [15, 16, 2000000000], [16, 17, 2000000000], [17, 18, 2000000000], [18, 19, 2000000000], [19, 0, 2000000000]]\n assert candidate(n = 15,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, 0, -1]],source = 0,destination = 14,target = 60) == [[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, 47], [14, 0, 2000000000]]\n assert candidate(n = 9,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, 0, -1], [1, 3, 6], [3, 5, 7], [5, 7, 8]],source = 0,destination = 7,target = 35) == [[0, 1, 14], [1, 2, 2000000000], [2, 3, 2000000000], [3, 4, 2000000000], [4, 5, 2000000000], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 0, 2000000000], [1, 3, 6], [3, 5, 7], [5, 7, 8]]\n assert candidate(n = 9,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, 0, -1], [0, 4, -1], [4, 8, -1], [8, 3, -1], [3, 7, -1], [7, 1, -1], [1, 5, -1], [5, 2, -1], [2, 6, -1]],source = 0,destination = 6,target = 30) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 25], [6, 7, 2000000000], [7, 8, 2000000000], [8, 0, 2000000000], [0, 4, 2000000000], [4, 8, 2000000000], [8, 3, 2000000000], [3, 7, 2000000000], [7, 1, 2000000000], [1, 5, 2000000000], [5, 2, 2000000000], [2, 6, 2000000000]]\n assert candidate(n = 15,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, 0, -1], [0, 7, 10], [2, 9, 11], [4, 11, 12], [6, 13, 13]],source = 0,destination = 10,target = 50) == [[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, 41], [10, 11, 2000000000], [11, 12, 2000000000], [12, 13, 2000000000], [13, 14, 2000000000], [14, 0, 2000000000], [0, 7, 10], [2, 9, 11], [4, 11, 12], [6, 13, 13]]\n assert candidate(n = 9,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, 0, -1], [0, 4, 5], [1, 5, -1], [2, 6, -1], [3, 7, -1], [4, 8, -1], [5, 0, -1], [6, 1, -1], [7, 2, -1], [8, 3, -1]],source = 0,destination = 4,target = 15) == []\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, -1], [2, 3, -1], [3, 4, 4], [4, 5, -1], [5, 6, -1], [6, 7, -1], [7, 8, -1], [8, 9, -1], [9, 0, -1]],source = 0,destination = 6,target = 18) == [[0, 1, 2], [1, 2, 1], [2, 3, 1], [3, 4, 4], [4, 5, 1], [5, 6, 9], [6, 7, 2000000000], [7, 8, 2000000000], [8, 9, 2000000000], [9, 0, 2000000000]]\n assert candidate(n = 11,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, 0, -1]],source = 0,destination = 5,target = 15) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 11], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 9, 2000000000], [9, 10, 2000000000], [10, 0, 2000000000]]\n assert candidate(n = 9,edges = [[0, 1, 7], [1, 2, -1], [2, 3, 5], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 7, -1], [7, 8, -1], [8, 0, -1]],source = 0,destination = 5,target = 20) == [[0, 1, 7], [1, 2, 1], [2, 3, 5], [3, 4, 1], [4, 5, 6], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 0, 2000000000]]\n assert candidate(n = 7,edges = [[0, 1, -1], [1, 2, 1], [2, 3, -1], [3, 4, 2], [4, 5, -1], [5, 6, 3], [6, 0, -1], [0, 3, -1], [1, 4, -1], [2, 5, -1], [3, 6, -1], [4, 0, -1], [5, 1, -1], [6, 2, -1]],source = 0,destination = 5,target = 20) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 2], [4, 5, 15], [5, 6, 3], [6, 0, 2000000000], [0, 3, 2000000000], [1, 4, 2000000000], [2, 5, 2000000000], [3, 6, 2000000000], [4, 0, 2000000000], [5, 1, 2000000000], [6, 2, 2000000000]]\n assert candidate(n = 11,edges = [[0, 1, -1], [1, 2, -1], [2, 3, 3], [3, 4, -1], [4, 5, 5], [5, 6, -1], [6, 7, -1], [7, 8, -1], [8, 9, 9], [9, 10, -1]],source = 0,destination = 10,target = 40) == [[0, 1, 1], [1, 2, 1], [2, 3, 3], [3, 4, 1], [4, 5, 5], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 9], [9, 10, 17]]\n assert candidate(n = 9,edges = [[0, 1, -1], [1, 2, -1], [2, 3, -1], [3, 4, -1], [4, 5, 5], [5, 6, 3], [6, 7, 2], [7, 8, -1], [8, 0, -1]],source = 0,destination = 7,target = 13) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 5], [5, 6, 3], [6, 7, 2], [7, 8, 1], [8, 0, 12]]\n assert candidate(n = 7,edges = [[0, 1, 5], [1, 2, 3], [2, 3, -1], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 0, -1]],source = 0,destination = 4,target = 12) == [[0, 1, 5], [1, 2, 3], [2, 3, 1], [3, 4, 3], [4, 5, 2000000000], [5, 6, 2000000000], [6, 0, 2000000000]]\n assert candidate(n = 8,edges = [[0, 1, 5], [1, 2, -1], [2, 3, -1], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 7, -1], [7, 0, -1], [0, 3, 7]],source = 0,destination = 6,target = 20) == [[0, 1, 5], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 11], [6, 7, 2000000000], [7, 0, 2000000000], [0, 3, 7]]\n assert candidate(n = 10,edges = [[0, 1, 7], [1, 2, -1], [2, 3, 10], [3, 4, -1], [4, 5, -1], [5, 6, 8], [6, 7, -1], [7, 8, -1], [8, 9, -1], [0, 9, -1]],source = 0,destination = 9,target = 40) == [[0, 1, 7], [1, 2, 1], [2, 3, 10], [3, 4, 1], [4, 5, 1], [5, 6, 8], [6, 7, 1], [7, 8, 1], [8, 9, 10], [0, 9, 2000000000]]\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, -1], [2, 3, 3], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 7, -1], [7, 0, -1], [0, 4, -1], [1, 5, -1], [2, 6, -1], [3, 7, -1]],source = 0,destination = 6,target = 25) == [[0, 1, 2], [1, 2, 1], [2, 3, 3], [3, 4, 1], [4, 5, 1], [5, 6, 17], [6, 7, 2000000000], [7, 0, 2000000000], [0, 4, 2000000000], [1, 5, 2000000000], [2, 6, 2000000000], [3, 7, 2000000000]]\n assert candidate(n = 7,edges = [[0, 1, -1], [1, 2, -1], [2, 3, -1], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 0, -1], [0, 3, 7], [1, 4, 8], [2, 5, 9]],source = 0,destination = 4,target = 20) == [[0, 1, 12], [1, 2, 2000000000], [2, 3, 2000000000], [3, 4, 2000000000], [4, 5, 2000000000], [5, 6, 2000000000], [6, 0, 2000000000], [0, 3, 7], [1, 4, 8], [2, 5, 9]]\n assert candidate(n = 7,edges = [[0, 1, 5], [1, 2, -1], [2, 3, 7], [3, 4, -1], [4, 5, 9], [5, 6, -1], [6, 0, -1]],source = 0,destination = 4,target = 20) == [[0, 1, 5], [1, 2, 1], [2, 3, 7], [3, 4, 7], [4, 5, 9], [5, 6, 2000000000], [6, 0, 2000000000]]\n assert candidate(n = 12,edges = [[0, 1, 3], [1, 2, -1], [2, 3, 2], [3, 4, -1], [4, 5, 4], [5, 6, -1], [6, 7, -1], [7, 8, -1], [8, 9, -1], [9, 10, -1], [10, 11, -1], [11, 0, -1], [0, 6, 5], [1, 7, 6], [2, 8, -1], [3, 9, -1], [4, 10, -1], [5, 11, -1]],source = 0,destination = 8,target = 30) == [[0, 1, 3], [1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 5, 4], [5, 6, 1], [6, 7, 1], [7, 8, 24], [8, 9, 2000000000], [9, 10, 2000000000], [10, 11, 2000000000], [11, 0, 2000000000], [0, 6, 5], [1, 7, 6], [2, 8, 2000000000], [3, 9, 2000000000], [4, 10, 2000000000], [5, 11, 2000000000]]\n assert candidate(n = 7,edges = [[0, 1, -1], [1, 2, -1], [2, 3, -1], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 0, -1], [0, 3, -1], [1, 4, -1], [2, 5, -1]],source = 0,destination = 5,target = 15) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 11], [5, 6, 2000000000], [6, 0, 2000000000], [0, 3, 2000000000], [1, 4, 2000000000], [2, 5, 2000000000]]\n assert candidate(n = 11,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, 0, -1], [0, 6, 12]],source = 0,destination = 8,target = 35) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 28], [8, 9, 2000000000], [9, 10, 2000000000], [10, 0, 2000000000], [0, 6, 12]]\n assert candidate(n = 10,edges = [[0, 1, -1], [1, 2, -1], [2, 3, 5], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 7, 9], [7, 8, -1], [8, 9, -1], [9, 0, -1]],source = 1,destination = 8,target = 40) == [[0, 1, 1], [1, 2, 1], [2, 3, 5], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 9], [7, 8, 22], [8, 9, 2000000000], [9, 0, 2000000000]]\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]],source = 1,destination = 9,target = 25) == [[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, 18], [9, 10, 2000000000], [10, 11, 2000000000], [11, 0, 2000000000]]\n assert candidate(n = 12,edges = [[0, 1, 3], [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], [0, 6, 5], [2, 8, 4]],source = 0,destination = 8,target = 30) == [[0, 1, 3], [1, 2, 23], [2, 3, 2000000000], [3, 4, 2000000000], [4, 5, 2000000000], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 9, 2000000000], [9, 10, 2000000000], [10, 11, 2000000000], [11, 0, 2000000000], [0, 6, 5], [2, 8, 4]]\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], [7, 0, -1]],source = 0,destination = 7,target = 24) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 18], [7, 0, 2000000000]]\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], [19, 0, -1]],source = 5,destination = 15,target = 50) == [[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, 41], [15, 16, 2000000000], [16, 17, 2000000000], [17, 18, 2000000000], [18, 19, 2000000000], [19, 0, 2000000000]]\n assert candidate(n = 5,edges = [[0, 1, 1], [1, 2, -1], [2, 3, -1], [3, 4, -1], [4, 0, -1], [0, 2, -1], [1, 3, -1], [2, 4, -1]],source = 0,destination = 4,target = 10) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 7], [4, 0, 2000000000], [0, 2, 2000000000], [1, 3, 2000000000], [2, 4, 2000000000]]\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], [9, 0, 1]],source = 0,destination = 5,target = 12) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 8], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 9, 2000000000], [9, 0, 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], [0, 7, 15]],source = 0,destination = 9,target = 40) == [[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, 32], [9, 10, 2000000000], [10, 11, 2000000000], [11, 0, 2000000000], [0, 7, 15]]\n assert candidate(n = 15,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, 0, -1]],source = 0,destination = 7,target = 49) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 43], [7, 8, 2000000000], [8, 9, 2000000000], [9, 10, 2000000000], [10, 11, 2000000000], [11, 12, 2000000000], [12, 13, 2000000000], [13, 14, 2000000000], [14, 0, 2000000000]]\n assert candidate(n = 15,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, 0, -1]],source = 0,destination = 7,target = 50) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 44], [7, 8, 2000000000], [8, 9, 2000000000], [9, 10, 2000000000], [10, 11, 2000000000], [11, 12, 2000000000], [12, 13, 2000000000], [13, 14, 2000000000], [14, 0, 2000000000]]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, -1], [2, 3, 3], [3, 4, -1], [4, 5, 5], [5, 6, -1], [6, 7, 7], [7, 8, -1], [8, 9, 9], [9, 10, -1], [10, 11, -1], [11, 0, -1]],source = 0,destination = 10,target = 45) == [[0, 1, 1], [1, 2, 1], [2, 3, 3], [3, 4, 1], [4, 5, 5], [5, 6, 1], [6, 7, 7], [7, 8, 1], [8, 9, 9], [9, 10, 16], [10, 11, 2000000000], [11, 0, 2000000000]]\n assert candidate(n = 8,edges = [[0, 1, -1], [1, 2, -1], [2, 3, 6], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 7, -1], [7, 0, -1]],source = 1,destination = 6,target = 15) == [[0, 1, 1], [1, 2, 1], [2, 3, 6], [3, 4, 1], [4, 5, 1], [5, 6, 6], [6, 7, 2000000000], [7, 0, 2000000000]]\n assert candidate(n = 13,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, 0, -1], [0, 8, 20]],source = 0,destination = 10,target = 45) == [[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, 36], [10, 11, 2000000000], [11, 12, 2000000000], [12, 0, 2000000000], [0, 8, 20]]\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], [9, 0, -1]],source = 0,destination = 5,target = 20) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 16], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 9, 2000000000], [9, 0, 2000000000]]\n assert candidate(n = 7,edges = [[0, 1, -1], [1, 2, -1], [2, 3, 2], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 0, -1]],source = 0,destination = 4,target = 10) == [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 6], [4, 5, 2000000000], [5, 6, 2000000000], [6, 0, 2000000000]]\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], [9, 0, -1]],source = 0,destination = 5,target = 25) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 21], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 9, 2000000000], [9, 0, 2000000000]]\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, 3], [2, 3, -1], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 7, -1], [7, 8, -1], [8, 9, -1], [9, 0, -1]],source = 0,destination = 5,target = 25) == [[0, 1, 2], [1, 2, 3], [2, 3, 1], [3, 4, 1], [4, 5, 18], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 9, 2000000000], [9, 0, 2000000000]]\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, 3], [2, 3, -1], [3, 4, -1], [4, 5, 5], [5, 6, -1], [6, 7, -1], [7, 0, -1]],source = 1,destination = 6,target = 25) == [[0, 1, 2], [1, 2, 3], [2, 3, 1], [3, 4, 1], [4, 5, 5], [5, 6, 15], [6, 7, 2000000000], [7, 0, 2000000000]]\n assert candidate(n = 12,edges = [[0, 1, 3], [1, 2, 2], [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]],source = 0,destination = 6,target = 18) == [[0, 1, 3], [1, 2, 2], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 10], [6, 7, 2000000000], [7, 8, 2000000000], [8, 9, 2000000000], [9, 10, 2000000000], [10, 11, 2000000000], [11, 0, 2000000000]]\n assert candidate(n = 5,edges = [[0, 1, 10], [1, 2, -1], [2, 3, -1], [3, 4, -1], [4, 0, -1]],source = 0,destination = 2,target = 15) == [[0, 1, 10], [1, 2, 5], [2, 3, 2000000000], [3, 4, 2000000000], [4, 0, 2000000000]]\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], [19, 0, -1], [0, 10, 15], [2, 12, 16], [4, 14, 17], [6, 16, 18], [8, 18, 19]],source = 0,destination = 15,target = 75) == [[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, 61], [15, 16, 2000000000], [16, 17, 2000000000], [17, 18, 2000000000], [18, 19, 2000000000], [19, 0, 2000000000], [0, 10, 15], [2, 12, 16], [4, 14, 17], [6, 16, 18], [8, 18, 19]]\n assert candidate(n = 9,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, 0, -1]],source = 0,destination = 4,target = 15) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 12], [4, 5, 2000000000], [5, 6, 2000000000], [6, 7, 2000000000], [7, 8, 2000000000], [8, 0, 2000000000]]\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, -1], [2, 3, -1], [3, 4, 4], [4, 5, -1], [5, 6, 6], [6, 7, -1], [7, 0, 8]],source = 0,destination = 6,target = 20) == [[0, 1, 2], [1, 2, 1], [2, 3, 1], [3, 4, 4], [4, 5, 6], [5, 6, 6], [6, 7, 2000000000], [7, 0, 8]]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, -1], [2, 3, 2], [3, 4, -1], [4, 5, 3], [5, 6, -1], [6, 7, 4], [7, 8, -1], [8, 9, 5], [9, 10, -1], [10, 11, -1], [11, 0, -1]],source = 0,destination = 10,target = 33) == [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 5, 3], [5, 6, 1], [6, 7, 4], [7, 8, 1], [8, 9, 5], [9, 10, 14], [10, 11, 2000000000], [11, 0, 2000000000]]\n assert candidate(n = 8,edges = [[0, 1, -1], [1, 2, 5], [2, 3, -1], [3, 4, -1], [4, 5, 3], [5, 6, -1], [6, 7, -1], [7, 0, -1]],source = 0,destination = 5,target = 12) == [[0, 1, 1], [1, 2, 5], [2, 3, 1], [3, 4, 2], [4, 5, 3], [5, 6, 2000000000], [6, 7, 2000000000], [7, 0, 2000000000]]\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], [0, 5, -1], [5, 10, -1], [10, 3, -1], [3, 8, -1]],source = 0,destination = 8,target = 50) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 43], [8, 9, 2000000000], [9, 10, 2000000000], [10, 11, 2000000000], [11, 0, 2000000000], [0, 5, 2000000000], [5, 10, 2000000000], [10, 3, 2000000000], [3, 8, 2000000000]]\n assert candidate(n = 10,edges = [[0, 1, 2], [0, 2, -1], [1, 3, 4], [1, 4, -1], [2, 5, 6], [2, 6, -1], [3, 7, -1], [4, 8, -1], [5, 9, -1], [6, 8, -1], [7, 9, 5]],source = 0,destination = 9,target = 20) == [[0, 1, 2], [0, 2, 1], [1, 3, 4], [1, 4, 1], [2, 5, 6], [2, 6, 1], [3, 7, 9], [4, 8, 2000000000], [5, 9, 2000000000], [6, 8, 2000000000], [7, 9, 5]]\n assert candidate(n = 7,edges = [[0, 1, -1], [1, 2, -1], [2, 3, -1], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 0, -1]],source = 0,destination = 4,target = 18) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 15], [4, 5, 2000000000], [5, 6, 2000000000], [6, 0, 2000000000]]\n assert candidate(n = 9,edges = [[0, 1, -1], [1, 2, -1], [2, 3, 4], [3, 4, -1], [4, 5, -1], [5, 6, -1], [6, 7, 6], [7, 8, -1], [8, 0, -1]],source = 0,destination = 5,target = 30) == [[0, 1, 1], [1, 2, 1], [2, 3, 4], [3, 4, 1], [4, 5, 23], [5, 6, 2000000000], [6, 7, 6], [7, 8, 2000000000], [8, 0, 2000000000]]\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], [7, 0, -1], [0, 2, -1], [2, 4, -1], [4, 6, -1], [6, 1, -1]],source = 0,destination = 6,target = 25) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 20], [6, 7, 2000000000], [7, 0, 2000000000], [0, 2, 2000000000], [2, 4, 2000000000], [4, 6, 2000000000], [6, 1, 2000000000]]\n assert candidate(n = 10,edges = [[0, 1, -1], [1, 2, -1], [2, 3, -1], [3, 4, -1], [4, 5, 7], [5, 6, 8], [6, 7, -1], [7, 8, -1], [8, 9, -1], [9, 0, -1]],source = 2,destination = 7,target = 35) == [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 7], [5, 6, 8], [6, 7, 18], [7, 8, 2000000000], [8, 9, 2000000000], [9, 0, 2000000000]]\n assert candidate(n = 7,edges = [[0, 1, 2], [1, 2, -1], [2, 3, 4], [3, 4, -1], [4, 5, -1], [5, 6, 1], [6, 0, -1]],source = 0,destination = 4,target = 10) == [[0, 1, 2], [1, 2, 1], [2, 3, 4], [3, 4, 3], [4, 5, 2000000000], [5, 6, 1], [6, 0, 2000000000]]\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], [7, 0, -1], [1, 3, 4], [3, 6, 5]],source = 0,destination = 6,target = 20) == [[0, 1, 11], [1, 2, 2000000000], [2, 3, 2000000000], [3, 4, 2000000000], [4, 5, 2000000000], [5, 6, 2000000000], [6, 7, 2000000000], [7, 0, 2000000000], [1, 3, 4], [3, 6, 5]]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "source", "destination", "target"], "leetcode_dataset_entry_point": "Solution().modifiedGraphEdges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] modifiedGraphEdges(int n, int[][] edges, int source, int destination, int target) {", "container": "Solution", "callable": "modifiedGraphEdges", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}, {"name": "source", "type": "int"}, {"name": "destination", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2706, "task_id": "buy-two-chocolates", "difficulty": "Easy", "problem_description": "You are given an integer array prices representing the prices of various chocolates in a store. You are also given a single integer money, which represents your initial amount of money.\nYou must buy exactly two chocolates in such a way that you still have some non-negative leftover money. You would like to minimize the sum of the prices of the two chocolates you buy.\nReturn the amount of money you will have leftover after buying the two chocolates. If there is no way for you to buy two chocolates without ending up in debt, return money. Note that the leftover must be non-negative.\n \nExample 1:\n\nInput: prices = [1,2,2], money = 3\nOutput: 0\nExplanation: Purchase the chocolates priced at 1 and 2 units respectively. You will have 3 - 3 = 0 units of money afterwards. Thus, we return 0.\n\nExample 2:\n\nInput: prices = [3,2,3], money = 3\nOutput: 3\nExplanation: You cannot buy 2 chocolates without going in debt, so we return 3.\n\n \nConstraints:\n\n2 <= prices.length <= 50\n1 <= prices[i] <= 100\n1 <= money <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prices = [99, 99],money = 198) == 0\n assert candidate(prices = [99, 1],money = 100) == 0\n assert candidate(prices = [5, 4, 3, 2, 1],money = 10) == 7\n assert candidate(prices = [1, 1, 1, 1],money = 2) == 0\n assert candidate(prices = [1, 1],money = 3) == 1\n assert candidate(prices = [1, 2, 2],money = 3) == 0\n assert candidate(prices = [1, 1, 1, 1, 1],money = 1) == 1\n assert candidate(prices = [1, 1, 1, 1, 1],money = 1) == 1\n assert candidate(prices = [50, 50],money = 100) == 0\n assert candidate(prices = [1, 2, 3, 4, 5],money = 8) == 5\n assert candidate(prices = [99, 99],money = 198) == 0\n assert candidate(prices = [5, 5, 5, 5],money = 10) == 0\n assert candidate(prices = [10, 5, 7, 3],money = 15) == 7\n assert candidate(prices = [100, 1, 100],money = 199) == 98\n assert candidate(prices = [10, 20, 30],money = 50) == 20\n assert candidate(prices = [10, 20, 30, 40],money = 60) == 30\n assert candidate(prices = [100, 1, 1, 1, 1],money = 101) == 99\n assert candidate(prices = [3, 2, 3],money = 3) == 3\n assert candidate(prices = [10, 20, 30],money = 50) == 20\n assert candidate(prices = [10, 20, 30],money = 25) == 25\n assert candidate(prices = [5, 5, 5, 5],money = 10) == 0\n assert candidate(prices = [2, 2, 2, 2, 2],money = 5) == 1\n assert candidate(prices = [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],money = 98) == 87\n assert candidate(prices = [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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],money = 8) == 0\n assert candidate(prices = [4, 1, 2, 3, 5, 6, 7, 8, 9, 10],money = 11) == 8\n assert candidate(prices = [50, 50, 50, 50, 50],money = 99) == 99\n assert candidate(prices = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],money = 100) == 0\n assert candidate(prices = [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, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],money = 199) == 199\n assert candidate(prices = [5, 3, 7, 9, 2, 6, 8, 1, 4, 10],money = 12) == 9\n assert candidate(prices = [50, 1, 50, 2, 3, 4, 5],money = 52) == 49\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],money = 11) == 8\n assert candidate(prices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],money = 110) == 80\n assert candidate(prices = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],money = 50) == 45\n assert candidate(prices = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],money = 180) == 19\n assert candidate(prices = [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],money = 300) == 285\n assert candidate(prices = [5, 4, 3, 2, 1],money = 10) == 7\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],money = 10) == 0\n assert candidate(prices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],money = 190) == 160\n assert candidate(prices = [1, 99, 1, 98, 1, 97, 1, 96, 1, 95],money = 100) == 98\n assert candidate(prices = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],money = 150) == 150\n assert candidate(prices = [1, 1, 1, 1],money = 2) == 0\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],money = 11) == 8\n assert candidate(prices = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],money = 199) == 199\n assert candidate(prices = [50, 50, 50, 50, 50],money = 100) == 0\n assert candidate(prices = [45, 23, 67, 89, 12, 34, 56, 78, 90, 100],money = 140) == 105\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],money = 2) == 0\n assert candidate(prices = [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, 8, 8],money = 16) == 0\n assert candidate(prices = [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],money = 29) == 26\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],money = 2) == 0\n assert candidate(prices = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200],money = 150) == 90\n assert candidate(prices = [50, 25, 75, 100, 20],money = 100) == 55\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],money = 2) == 0\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],money = 18) == 15\n assert candidate(prices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],money = 90) == 75\n assert candidate(prices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19],money = 200) == 197\n assert candidate(prices = [5, 4, 3, 2, 1],money = 3) == 0\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],money = 10) == 10\n assert candidate(prices = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],money = 100) == 100\n assert candidate(prices = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],money = 99) == 99\n assert candidate(prices = [50, 51, 49, 48, 52, 53, 47, 46, 54, 55],money = 100) == 7\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],money = 10) == 0\n assert candidate(prices = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99],money = 198) == 0\n assert candidate(prices = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],money = 101) == 99\n assert candidate(prices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],money = 5) == 5\n assert candidate(prices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],money = 105) == 75\n assert candidate(prices = [50, 10, 15, 20, 25],money = 55) == 30\n assert candidate(prices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],money = 150) == 120\n assert candidate(prices = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],money = 60) == 51\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],money = 30) == 27\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],money = 179) == 16\n assert candidate(prices = [40, 30, 20, 10, 5, 15, 25, 35, 45, 50],money = 60) == 45\n assert candidate(prices = [99, 100, 99, 100],money = 199) == 1\n assert candidate(prices = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],money = 150) == 150\n assert candidate(prices = [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],money = 101) == 98\n assert candidate(prices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],money = 150) == 120\n assert candidate(prices = [45, 22, 13, 8, 3],money = 60) == 49\n assert candidate(prices = [80, 10, 50, 20, 30],money = 60) == 30\n assert candidate(prices = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],money = 101) == 98\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],money = 2) == 0\n assert candidate(prices = [10, 15, 20, 25, 30, 35, 40],money = 60) == 35\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],money = 39) == 36\n assert candidate(prices = [75, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],money = 100) == 50\n assert candidate(prices = [1, 99, 1, 98],money = 100) == 98\n assert candidate(prices = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33],money = 66) == 0\n assert candidate(prices = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],money = 5) == 1\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],money = 15) == 12\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],money = 20) == 0\n assert candidate(prices = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],money = 100) == 80\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],money = 2) == 0\n assert candidate(prices = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],money = 100) == 0\n assert candidate(prices = [100, 99, 98, 97, 96, 95],money = 193) == 2\n assert candidate(prices = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],money = 180) == 180\n assert candidate(prices = [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],money = 3) == 1\n assert candidate(prices = [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],money = 100) == 97\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],money = 2) == 0\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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],money = 3) == 1\n assert candidate(prices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],money = 80) == 65\n assert candidate(prices = [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],money = 31) == 28\n assert candidate(prices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],money = 190) == 160\n assert candidate(prices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],money = 105) == 90\n assert candidate(prices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],money = 200) == 170\n assert candidate(prices = [100, 1, 100, 2, 100, 3, 100, 4, 100, 5],money = 200) == 197\n assert candidate(prices = [99, 50, 50, 1, 1],money = 100) == 98\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],money = 11) == 1\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],money = 2) == 0\n assert candidate(prices = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],money = 180) == 180\n assert candidate(prices = [49, 50, 51, 52, 53, 54, 55, 56, 57, 58],money = 108) == 9\n assert candidate(prices = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],money = 100) == 96\n assert candidate(prices = [5, 8, 12, 18, 22, 25],money = 40) == 27\n assert candidate(prices = [3, 6, 5, 8, 9, 2, 4, 7, 1, 10],money = 12) == 9\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],money = 198) == 15\n"}, "metadata": {"canonical_parameter_names": ["prices", "money"], "leetcode_dataset_entry_point": "Solution().buyChoco", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int buyChoco(int[] prices, int money) {", "container": "Solution", "callable": "buyChoco", "parameters": [{"name": "prices", "type": "int[]"}, {"name": "money", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2707, "task_id": "extra-characters-in-a-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that each substring is present in dictionary. There may be some extra characters in s which are not present in any of the substrings.\nReturn the minimum number of extra characters left over if you break up s optimally.\n \nExample 1:\n\nInput: s = \"leetscode\", dictionary = [\"leet\",\"code\",\"leetcode\"]\nOutput: 1\nExplanation: We can break s in two substrings: \"leet\" from index 0 to 3 and \"code\" from index 5 to 8. There is only 1 unused character (at index 4), so we return 1.\n\n\nExample 2:\n\nInput: s = \"sayhelloworld\", dictionary = [\"hello\",\"world\"]\nOutput: 3\nExplanation: We can break s in two substrings: \"hello\" from index 3 to 7 and \"world\" from index 8 to 12. The characters at indices 0, 1, 2 are not used in any substring and thus are considered as extra characters. Hence, we return 3.\n\n \nConstraints:\n\n1 <= s.length <= 50\n1 <= dictionary.length <= 50\n1 <= dictionary[i].length <= 50\ndictionary[i] and s consists of only lowercase English letters\ndictionary contains distinct words\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",dictionary = ['a', 'b', 'c']) == 0\n assert candidate(s = \"sayhelloworld\",dictionary = ['hello', 'world']) == 3\n assert candidate(s = \"abc\",dictionary = ['d', 'e']) == 3\n assert candidate(s = \"abcabcabc\",dictionary = ['abcabc', 'abc']) == 0\n assert candidate(s = \"abracadabra\",dictionary = ['abra', 'cadabra', 'abc']) == 0\n assert candidate(s = \"abc\",dictionary = ['d', 'e', 'f']) == 3\n assert candidate(s = \"applepenapple\",dictionary = ['apple', 'pen']) == 0\n assert candidate(s = \"catsandog\",dictionary = ['cats', 'dog', 'sand', 'and', 'cat']) == 2\n assert candidate(s = \"ab\",dictionary = ['abc', 'def']) == 2\n assert candidate(s = \"abcde\",dictionary = ['a', 'b', 'c', 'd', 'e']) == 0\n assert candidate(s = \"programming\",dictionary = ['pro', 'gram', 'ming']) == 0\n assert candidate(s = \"a\",dictionary = ['b']) == 1\n assert candidate(s = \"mississippi\",dictionary = ['mis', 'is', 'ip', 'i', 'p']) == 2\n assert candidate(s = \"leetscode\",dictionary = ['leet', 'code', 'leetcode']) == 1\n assert candidate(s = \"aabbcc\",dictionary = ['a', 'b', 'c']) == 0\n assert candidate(s = \"programmingisfun\",dictionary = ['pro', 'gram', 'ming', 'is', 'fun', 'prog', 'am', 'ing', 'pr', 'gramm', 'ingis', 'funs']) == 0\n assert candidate(s = \"dynamicprogramming\",dictionary = ['dyn', 'ami', 'cpro', 'gram', 'ming', 'pro', 'gramming']) == 0\n assert candidate(s = \"algorithm\",dictionary = ['algo', 'rith', 'm', 'alg', 'ith', 'o', 'g', 'a', 'l', 'th', 'or', 'thm', 'al']) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",dictionary = ['a', 'z', 'abc', 'xyz', 'mnopqr', 'uvw', 'def', 'jkl']) == 5\n assert candidate(s = \"substringsearch\",dictionary = ['sub', 'string', 'search', 'substri', 'ngsea', 'rch', 'str', 'sea', 'subsearc', 'ubstringse']) == 0\n assert candidate(s = \"encyclopedia\",dictionary = ['ency', 'clop', 'edia', 'lo', 'pedia', 'cycle', 'en', 'dec', 'clo', 'opaedia']) == 0\n assert candidate(s = \"thisisateststring\",dictionary = ['this', 'is', 'a', 'test', 'string', 'isatest', 'teststr', 'str', 'ring', 'thi', 'sta', 'tes', 'ing', 'est', 'at']) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",dictionary = ['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']) == 0\n assert candidate(s = \"optimization\",dictionary = ['opt', 'imiz', 'tio', 'n', 'zat', 'ion', 'optim']) == 1\n assert candidate(s = \"programmingisfun\",dictionary = ['pro', 'gram', 'ming', 'is', 'fun', 'gramm', 'ing', 'program', 'mingis', 'funn']) == 0\n assert candidate(s = \"thisisatest\",dictionary = ['this', 'is', 'a', 'test', 'ate', 'st']) == 0\n assert candidate(s = \"programmingchallenge\",dictionary = ['pro', 'gram', 'ming', 'chall', 'lenge', 'ge']) == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",dictionary = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == 0\n assert candidate(s = \"encyclopedia\",dictionary = ['ency', 'clopedia', 'encyclo', 'pedia', 'encyclope', 'dopia', 'edia', 'a', 'ei', 'lo', 'ope', 'dic', 'lope', 'dia', 'edia']) == 0\n assert candidate(s = \"minimizingextra\",dictionary = ['mini', 'min', 'zing', 'extra', 'ze', 'tra', 'minimize']) == 2\n assert candidate(s = \"repeatedcharacters\",dictionary = ['re', 'pe', 'at', 'ed', 'cha', 'rac', 'ters', 'ter', 'char', 'acters']) == 0\n assert candidate(s = \"findingthesolution\",dictionary = ['find', 'ing', 'the', 'solu', 'tion', 'solution', 'thesolu', 'tingthe', 'thesolu', 'solu', 'tionfind', 'ingthe', 'thesolution', 'ingthes']) == 0\n assert candidate(s = \"mississippi\",dictionary = ['mis', 'sis', 'ip', 'i', 'ss', 'p']) == 1\n assert candidate(s = \"aaaaabbbbb\",dictionary = ['a', 'b', 'aa', 'bb', 'ab', 'ba', 'aaa', 'bbb', 'aab', 'bba', 'aba', 'bab']) == 0\n assert candidate(s = \"mississippi\",dictionary = ['issi', 'ssippi', 'miss', 'ippi', 'is', 's', 'pi', 'p']) == 0\n assert candidate(s = \"subsequences\",dictionary = ['sub', 'seq', 'uen', 'ce', 's', 'quence', 'quencece']) == 0\n assert candidate(s = \"backtracking\",dictionary = ['back', 'track', 'ing', 'backtr', 'acking', 'tracki', 'ing']) == 0\n assert candidate(s = \"abcdefghijk\",dictionary = ['abc', 'def', 'gh', 'ijk', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']) == 0\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",dictionary = ['abc', 'def', 'ghi', 'j', 'abcdefghij', 'abcdefgh', 'abcde', 'fghij', 'ab', 'cd', 'ef', 'gh', 'ij']) == 0\n assert candidate(s = \"thisisaverylongstring\",dictionary = ['this', 'is', 'a', 'very', 'long', 'string', 'thi', 'sis', 'verylong']) == 0\n assert candidate(s = \"optimallybreakingstrings\",dictionary = ['opti', 'mally', 'breaking', 'strings', 'opt', 'im', 'ally', 'break', 'ing', 'str', 'ing', 's', 'optimal', 'breaks', 'allybreak']) == 0\n assert candidate(s = \"abracadabra\",dictionary = ['abra', 'cad', 'bra', 'abc', 'rac']) == 0\n assert candidate(s = \"mississippi\",dictionary = ['mis', 'si', 'issi', 'pi', 'ppi', 'pis', 'missis', 'sippi', 'ippi', 'issipp']) == 0\n assert candidate(s = \"xylophone\",dictionary = ['xy', 'lo', 'phone', 'ph', 'one', 'xo', 'xyl', 'ylo', 'ho', 'ne', 'pho']) == 0\n assert candidate(s = \"subsequences\",dictionary = ['sub', 'seq', 'en', 'ce', 'qu', 'subseq', 'quence']) == 2\n assert candidate(s = \"thecodinginterview\",dictionary = ['the', 'coding', 'in', 'terview', 'inter', 'view', 'codingin', 'erview', 'viewint', 'nterview', 'inerview']) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",dictionary = ['a', 'z', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == 0\n assert candidate(s = \"abracadabra\",dictionary = ['abra', 'cad', 'bra', 'rac', 'ab', 'ad', 'a', 'b', 'c', 'd', 'r']) == 0\n assert candidate(s = \"optimization\",dictionary = ['opti', 'miz', 'ation', 'iza', 'ti', 'on']) == 0\n assert candidate(s = \"mississippi\",dictionary = ['mis', 'sis', 'ip', 'i', 'ss', 'is', 'pi', 'pp']) == 1\n assert candidate(s = \"dynamicprogramming\",dictionary = ['dynamic', 'program', 'gram', 'ming', 'pro', 'gramming']) == 0\n assert candidate(s = \"constraints\",dictionary = ['con', 'straint', 'stra', 'ints', 't', 'res', 'trai', 'ns', 'constra']) == 0\n assert candidate(s = \"abcdabcdabcd\",dictionary = ['ab', 'cd', 'abcd', 'abc', 'bcd', 'dabc']) == 0\n assert candidate(s = \"watermelon\",dictionary = ['water', 'melon', 'wa', 'ter', 'melon', 'wa', 'me', 'lo', 'on', 'terme', 'lono', 'wate', 'rme', 'lo', 'non', 'w', 'a', 't', 'e', 'r', 'm', 'e', 'l', 'o', 'n']) == 0\n assert candidate(s = \"breakfast\",dictionary = ['break', 'fast', 'bre', 'ak', 'fastbreak', 'breakfa', 'st']) == 0\n assert candidate(s = \"subsequence\",dictionary = ['sub', 'sequence', 'seq', 'uen', 'ce', 'subse', 'quen']) == 0\n assert candidate(s = \"optimization\",dictionary = ['opti', 'mize', 'optim', 'on', 'ize', 'miz', 'ization']) == 0\n assert candidate(s = \"programming\",dictionary = ['pro', 'gram', 'ming', 'ing', 'progr', 'amming']) == 0\n assert candidate(s = \"alibabacloud\",dictionary = ['ali', 'ba', 'bacloud', 'cloud', 'ib', 'baclou', 'bacla', 'baba', 'clouds', 'alibaba']) == 0\n assert candidate(s = \"segmentation\",dictionary = ['seg', 'men', 'tation', 'ment', 'entation', 'segmen', 't', 'ation']) == 0\n assert candidate(s = \"algorithm\",dictionary = ['algo', 'rithm', 'log', 'ith', 'm', 'a', 'thm', 'gor', 'orithm', 'ithm', 'gori', 'thmi']) == 0\n assert candidate(s = \"beautiful\",dictionary = ['be', 'autiful', 'aut', 'ful', 'at', 'beau', 'ti', 'ful', 'b', 'e', 'a', 'u', 't', 'i', 'f', 'u', 'l', 'beauti', 'ful', 'auti', 'ful', 'beaut', 'iful', 'bea', 'utiful', 'be', 'autiful', 'ti', 'ful', 'bea', 'ut', 'iful', 'beau', 'tiful', 'beaut', 'ifu', 'l']) == 0\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",dictionary = ['quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog', 'qu', 'ick', 'br', 'own', 'fo', 'x', 'ump', 'so', 'ver', 'el', 'az', 'y']) == 0\n assert candidate(s = \"example\",dictionary = ['ex', 'ample', 'am', 'ple', 'e', 'xample']) == 0\n assert candidate(s = \"dynamicprogramming\",dictionary = ['dyn', 'amic', 'prog', 'ram', 'ming', 'gramming', 'pro', 'dynamic', 'grampro', 'mingprog', 'rammi']) == 0\n assert candidate(s = \"mississippi\",dictionary = ['mis', 'sis', 'sip', 'issi', 'ippi']) == 1\n assert candidate(s = \"subsequence\",dictionary = ['sub', 'seq', 'en', 'ce', 'subse', 'quence']) == 0\n assert candidate(s = \"overlapping\",dictionary = ['over', 'lap', 'ping', 'lap', 'pingo', 'ver', 'lap', 'laplap']) == 0\n assert candidate(s = \"dynamicprogramming\",dictionary = ['dyn', 'amic', 'pro', 'gram', 'ming', 'prog', 'dyna', 'micpro', 'grammi', 'amming']) == 0\n assert candidate(s = \"programming\",dictionary = ['pro', 'gram', 'ming', 'gramming', 'prog', 'program', 'mming', 'progr', 'gram', 'ming', 'gramm', 'pro', 'gram', 'ming', 'programming', 'gram', 'ming', 'pro', 'gram', 'ming', 'gramming', 'pro', 'gram', 'ming', 'gramm', 'pro', 'gram', 'ming', 'program', 'ming', 'pro', 'gramming', 'gram', 'ming', 'gramm', 'prog', 'ming', 'pro', 'gramming', 'pro', 'gram', 'ming', 'gramm', 'pro', 'gram', 'ming', 'gramming', 'prog', 'gram', 'ming', 'pro', 'gramming']) == 0\n assert candidate(s = \"partitioning\",dictionary = ['parti', 'tion', 'ion', 'part', 'itioning', 'parti', 'tion', 'ing']) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",dictionary = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == 0\n assert candidate(s = \"optimization\",dictionary = ['opt', 'im', 'iz', 'ation', 'iza', 'tio']) == 0\n assert candidate(s = \"breakintothepieces\",dictionary = ['break', 'into', 'the', 'pie', 'ces', 'iece', 'to', 'pieces', 'breakin', 'intothep']) == 0\n assert candidate(s = \"fuzzywuzzy\",dictionary = ['fuz', 'zy', 'wuz', 'z', 'wuzz', 'fuzzy', 'wuzzywuzz']) == 0\n assert candidate(s = \"programmingcontest\",dictionary = ['pro', 'gram', 'ming', 'con', 'test', 'gramming', 'est']) == 0\n assert candidate(s = \"abcdefgabcdefg\",dictionary = ['abc', 'def', 'gh', 'abcdef', 'bcde', 'fgh', 'abcd', 'efg', 'fg', 'abcdab', 'bcdefg']) == 0\n assert candidate(s = \"pythonprogramming\",dictionary = ['py', 'thon', 'pro', 'gram', 'ming', 'prog', 'python', 'gramming', 'ron', 'th', 'ing']) == 0\n assert candidate(s = \"helloworld\",dictionary = ['hello', 'wor', 'ld', 'hell', 'world', 'owor', 'orl', 'rld', 'hel', 'wo', 'rld', 'worl', 'hello', 'world', 'worldly', 'or', 'wor', 'ld', 'hell', 'world', 'hellworld', 'hell', 'wo', 'rld', 'hello', 'world']) == 0\n assert candidate(s = \"programmingcontest\",dictionary = ['pro', 'gram', 'ming', 'con', 'test', 'gramming', 'est', 'on', 'gramcon', 'estcontest']) == 0\n assert candidate(s = \"onomatopoeia\",dictionary = ['ono', 'mato', 'poei', 'a', 'ia', 'oeia', 'opoe', 'oe', 'onom', 'atopoeia']) == 0\n assert candidate(s = \"mississippi\",dictionary = ['mis', 'issi', 'ippi', 'sip', 'iss', 'is', 'i', 'pi', 'missis', 'sippi']) == 0\n assert candidate(s = \"loremipsum\",dictionary = ['lor', 'em', 'ip', 'sum', 'lorem', 'rem', 'ems', 'mip', 'ips', 'pum', 'ipsum']) == 0\n assert candidate(s = \"interview\",dictionary = ['inter', 'view', 'ter', 'iew', 'in', 'terview', 'nterv', 'vieww']) == 0\n assert candidate(s = \"abracadabra\",dictionary = ['ab', 'ra', 'cad', 'abra', 'brac']) == 0\n assert candidate(s = \"programmingcontest\",dictionary = ['pro', 'gram', 'ming', 'con', 'test', 'est', 'contest']) == 0\n assert candidate(s = \"mississippi\",dictionary = ['mis', 'sis', 'sip', 'i', 'ss', 'pi', 'pp']) == 0\n assert candidate(s = \"dynamicprogramming\",dictionary = ['dyn', 'amic', 'pro', 'gram', 'ming', 'gramm', 'prog', 'dyna', 'progr']) == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",dictionary = ['super', 'cali', 'fragilistic', 'expiali', 'docious', 'ex', 'pi', 'ali', 'ous']) == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",dictionary = ['super', 'cali', 'fragilistic', 'expiali', 'docious', 'superca', 'lifrag', 'istic', 'expialido', 'cious', 'superca', 'li', 'frag', 'ilistic', 'ex', 'pialido', 'california', 'super', 'superdocus']) == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",dictionary = ['super', 'cali', 'fragilistic', 'expiali', 'docious', 'frag', 'listic', 'exp', 'ali', 'do', 'cious', 'superca', 'li', 'fragi', 'list', 'expialidoc', 'supercalifrag', 'supercalifragilisticexpi', 'alidocious', 'istic', 'expialidoci', 'superca', 'lifragilisti', 'cexpialid', 'alidoc', 'expialido', 'fragilisticexpialidocious']) == 0\n assert candidate(s = \"optimizationproblems\",dictionary = ['opt', 'im', 'ization', 'prob', 'lems', 'ob', 'lem', 'pro', 'blem', 'blempro']) == 0\n assert candidate(s = \"breakfast\",dictionary = ['break', 'fast', 'bre', 'ak', 'fast', 'reak']) == 0\n assert candidate(s = \"dictionary\",dictionary = ['dic', 'tion', 'tio', 'nary', 'dict', 'ionar', 'ictionary', 'dictio', 'n']) == 0\n assert candidate(s = \"backtracking\",dictionary = ['back', 'track', 'ing', 'bac', 'ktrack', 'king']) == 0\n assert candidate(s = \"algorithms\",dictionary = ['algo', 'rithm', 'thms', 'log', 'rith', 'ms', 'algothm', 'rithms']) == 0\n assert candidate(s = \"optimization\",dictionary = ['opt', 'im', 'ization', 'iz', 'ation', 'optim', 'ize']) == 0\n"}, "metadata": {"canonical_parameter_names": ["s", "dictionary"], "leetcode_dataset_entry_point": "Solution().minExtraChar", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minExtraChar(String s, String[] dictionary) {", "container": "Solution", "callable": "minExtraChar", "parameters": [{"name": "s", "type": "String"}, {"name": "dictionary", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2708, "task_id": "maximum-strength-of-a-group", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums representing the score of students in an exam. The teacher would like to form one non-empty group of students with maximal strength, where the strength of a group of students of indices i0, i1, i2, ... , ik is defined as nums[i0] * nums[i1] * nums[i2] * ... * nums[ik​].\nReturn the maximum strength of a group the teacher can create.\n \nExample 1:\n\nInput: nums = [3,-1,-5,2,5,-9]\nOutput: 1350\nExplanation: One way to form a group of maximal strength is to group the students at indices [0,2,3,4,5]. Their strength is 3 * (-5) * 2 * 5 * (-9) = 1350, which we can show is optimal.\n\nExample 2:\n\nInput: nums = [-4,-5,-4]\nOutput: 20\nExplanation: Group the students at indices [0, 1] . Then, we’ll have a resulting strength of 20. We cannot achieve greater strength.\n\n \nConstraints:\n\n1 <= nums.length <= 13\n-9 <= nums[i] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == 36\n assert candidate(nums = [-9]) == -9\n assert candidate(nums = [0, 0, 0, 1, -1]) == 1\n assert candidate(nums = [-4, -5, -4]) == 20\n assert candidate(nums = [0, 2, 3, 4]) == 24\n assert candidate(nums = [0, 1, -1]) == 1\n assert candidate(nums = [-1]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 362880\n assert candidate(nums = [-3, 0, 3]) == 3\n assert candidate(nums = [9]) == 9\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, -1, 1, -1]) == 1\n assert candidate(nums = [1, -1]) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13]) == 6227020800\n assert candidate(nums = [10, 0, -10, 0]) == 10\n assert candidate(nums = [1, 2, 0, 3, 4]) == 24\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 120\n assert candidate(nums = [5, 5, 5, 5, 5]) == 3125\n assert candidate(nums = [1, 2, 3, 4, 5]) == 120\n assert candidate(nums = [0, 1, -1, 2, -2]) == 4\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [-1, -1, 0, 1, 1]) == 1\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9]) == 362880\n assert candidate(nums = [2, 3, -1, -2, -3]) == 36\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-1, -2, -3, -4]) == 24\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13]) == 6227020800\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1]) == 362880\n assert candidate(nums = [3, -1, -5, 2, 5, -9]) == 1350\n assert candidate(nums = [-1, 1, 0]) == 1\n assert candidate(nums = [-1, 0, 1]) == 1\n assert candidate(nums = [-9, 9, -8, 8, -7, 7, -6, 6, -5, 5, -4, 4, -3, 3]) == 10973491200\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0]) == 362880\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -9, -8, -7, -6]) == 1097349120\n assert candidate(nums = [7, 3, -2, -5, 0, 1, 4, -6]) == 2520\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 531441\n assert candidate(nums = [-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]) == 4096\n assert candidate(nums = [-9, 9, 0, -1, 1, -2, 2]) == 324\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23]) == 223092870\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [3, -1, -5, 2, 5, -9, 7]) == 9450\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1220703125\n assert candidate(nums = [9, -8, 7, -6, 5, -4, 3, -2, 1, -9]) == 1632960\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6]) == 360\n assert candidate(nums = [0, 1, -1, 2, -2, 3]) == 12\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1]) == 362880\n assert candidate(nums = [0, -1, 2, -2, 3, -3]) == 36\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3]) == 36\n assert candidate(nums = [-1, 0, 1]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [9, 7, 5, 3, 1, -1, -3, -5, -7, -9]) == 893025\n assert candidate(nums = [-1, -3, -5, -7, -9]) == 945\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3]) == 21772800\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [-8, -6, -4, -2, 0, 2, 4, 6, 8]) == 147456\n assert candidate(nums = [0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 131681894400\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3]) == 2177280\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [7, -8, 9, -2, 3, 0, 4, -5, 6, -1]) == 362880\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2]) == 725760\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [9, -9, 8, -8, 7, -7]) == 36288\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 14400\n assert candidate(nums = [-3, -3, -3, -3, -3, -3, -3, -3, -3]) == 6561\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 362880\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4]) == 576\n assert candidate(nums = [3, -1, 0, -5, 2, 5, -9, 0, 4, -2, 6, -8, 7]) == 3628800\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, -1, 2, -2, 3, -3, 4]) == 144\n assert candidate(nums = [-9, 9, -8, 8, -7, 7, -6, 6, -5, 5, -4, 4, -3, 3, -2, 2, -1, 1]) == 131681894400\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == 518400\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3]) == 36\n assert candidate(nums = [-5, 0, 5]) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 120\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7]) == 5040\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7]) == 2520\n assert candidate(nums = [-2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8]) == 101606400\n assert candidate(nums = [-1, 0, 0, 0, 0, 0, -2]) == 2\n assert candidate(nums = [-1, 1, 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\n assert candidate(nums = [3, -1, -5, 2, 5, -9, 7, -8]) == 75600\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2177280\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8192\n assert candidate(nums = [3, -3, 3, -3, 3, -3, 3, -3, 3, -3, 3, -3, 3]) == 1594323\n assert candidate(nums = [1, 0, -1, 0, 1, 0, -1, 0]) == 1\n assert candidate(nums = [9, -8, 7, -6, 5, -4, 3, -2, 1, 0, -1, 2, -3]) == 2177280\n assert candidate(nums = [9, 0, -9, 0, 9, -9, 9, -9, 9]) == 531441\n assert candidate(nums = [-3, -5, 0, 2, 4, 6, 8, 10]) == 57600\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -4]) == 8709120\n assert candidate(nums = [3, -1, 0, 5, -2, 4, -6]) == 720\n assert candidate(nums = [-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3]) == 531441\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [2, 4, -6, 8, -10, 12, -14, 16, -18]) == 185794560\n assert candidate(nums = [-2, -3, -4, 0, 0, 0, 0, 0, 0]) == 12\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3]) == 2177280\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [-1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [-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, -1, 1, -1]) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7]) == 3628800\n assert candidate(nums = [-1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5]) == 14400\n assert candidate(nums = [5, -1, 3, -2, 0, 4, -3]) == 360\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 362880\n assert candidate(nums = [-3, 3, -3, 3, -3, 3, -3, 3, -3, 3, -3, 3, -3]) == 531441\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 14400\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9]) == 362880\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 131681894400\n assert candidate(nums = [5, 6, 7, 8, 9, -1, -2, -3, -4, -5, -6, -7, -8]) == 609638400\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9]) == 362880\n assert candidate(nums = [9, -8, 7, -6, 5, -4, 3, -2, 1]) == 362880\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1594323\n assert candidate(nums = [2, -3, 4, -5, 6, -7, 8, -9, 1]) == 362880\n assert candidate(nums = [-2, -3, -4, -5, -6, -7, -8, -9]) == 362880\n assert candidate(nums = [-9, 9, -8, 8, -7, 7, -6, 6, -5, 5, -4, 4, -3]) == 3657830400\n assert candidate(nums = [-2, -3, -5, 0, 0, 0, 0, 0, 0]) == 15\n assert candidate(nums = [9, -8, 7, -6, 5, -4, 3, -2, 1, -1, 0]) == 362880\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3]) == 36\n assert candidate(nums = [-9, 8, -7, 6, -5, 4, -3, 2, -1]) == 362880\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4]) == 8709120\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxStrength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxStrength(int[] nums) {", "container": "Solution", "callable": "maxStrength", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2709, "task_id": "greatest-common-divisor-traversal", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums, and you are allowed to traverse between its indices. You can traverse between index i and index j, i != j, if and only if gcd(nums[i], nums[j]) > 1, where gcd is the greatest common divisor.\nYour task is to determine if for every pair of indices i and j in nums, where i < j, there exists a sequence of traversals that can take us from i to j.\nReturn true if it is possible to traverse between all such pairs of indices, or false otherwise.\n \nExample 1:\n\nInput: nums = [2,3,6]\nOutput: true\nExplanation: In this example, there are 3 possible pairs of indices: (0, 1), (0, 2), and (1, 2).\nTo go from index 0 to index 1, we can use the sequence of traversals 0 -> 2 -> 1, where we move from index 0 to index 2 because gcd(nums[0], nums[2]) = gcd(2, 6) = 2 > 1, and then move from index 2 to index 1 because gcd(nums[2], nums[1]) = gcd(6, 3) = 3 > 1.\nTo go from index 0 to index 2, we can just go directly because gcd(nums[0], nums[2]) = gcd(2, 6) = 2 > 1. Likewise, to go from index 1 to index 2, we can just go directly because gcd(nums[1], nums[2]) = gcd(3, 6) = 3 > 1.\n\nExample 2:\n\nInput: nums = [3,9,5]\nOutput: false\nExplanation: No sequence of traversals can take us from index 0 to index 2 in this example. So, we return false.\n\nExample 3:\n\nInput: nums = [4,3,12,8]\nOutput: true\nExplanation: There are 6 possible pairs of indices to traverse between: (0, 1), (0, 2), (0, 3), (1, 2), (1, 3), and (2, 3). A valid sequence of traversals exists for each pair, so we return true.\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 = [2, 3, 6]) == True\n assert candidate(nums = [100, 200, 300, 400]) == True\n assert candidate(nums = [1, 1, 1]) == False\n assert candidate(nums = [1, 1, 1, 1]) == False\n assert candidate(nums = [7, 14, 21, 35]) == True\n assert candidate(nums = [30, 15, 10, 5]) == True\n assert candidate(nums = [2, 4, 6, 8, 10]) == True\n assert candidate(nums = [2, 6, 8, 12, 18, 24]) == True\n assert candidate(nums = [3, 9, 5]) == False\n assert candidate(nums = [7, 11, 13, 17]) == False\n assert candidate(nums = [1]) == True\n assert candidate(nums = [2, 5, 7, 11, 13]) == False\n assert candidate(nums = [1, 2, 3, 4, 5]) == False\n assert candidate(nums = [2, 4, 8, 16]) == True\n assert candidate(nums = [13, 17, 19, 23, 29]) == False\n assert candidate(nums = [60, 120, 180, 240]) == True\n assert candidate(nums = [10, 15, 20, 25]) == True\n assert candidate(nums = [4, 3, 12, 8]) == True\n assert candidate(nums = [2, 2, 2, 2]) == True\n assert candidate(nums = [7, 11, 13, 17, 19]) == False\n assert candidate(nums = [60, 30, 20, 10]) == True\n assert candidate(nums = [100000]) == True\n assert candidate(nums = [5, 10, 15, 20, 25]) == True\n assert candidate(nums = [5, 10, 15, 20]) == True\n assert candidate(nums = [11, 22, 33, 44, 55]) == True\n assert candidate(nums = [3, 5, 7, 11, 13, 17]) == False\n assert candidate(nums = [30, 42, 70, 105]) == True\n assert candidate(nums = [7, 14, 28, 35]) == True\n assert candidate(nums = [100000, 100000, 100000, 100000]) == True\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == False\n assert candidate(nums = [30, 42, 70, 105, 210]) == True\n assert candidate(nums = [30, 42, 56, 70, 84, 98, 112, 126, 140, 154]) == True\n assert candidate(nums = [220, 330, 440, 550, 660, 770, 880, 990, 1100, 1210]) == True\n assert candidate(nums = [143, 169, 187, 221, 247, 299, 323, 341, 377, 391, 413, 437, 451, 473, 517, 551, 583, 611, 629, 667]) == False\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(nums = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == False\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125]) == 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 = [49, 147, 245, 343, 7203]) == True\n assert candidate(nums = [30, 45, 60, 75, 90, 105]) == True\n assert candidate(nums = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240]) == True\n assert candidate(nums = [20, 25, 40, 50, 100]) == True\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [44, 55, 66, 77, 88, 99, 110, 121]) == True\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(nums = [2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480]) == True\n assert candidate(nums = [121, 143, 169, 187, 209, 221, 247, 253]) == True\n assert candidate(nums = [101, 103, 107, 109, 113, 127]) == False\n assert candidate(nums = [49, 98, 147, 196, 245, 294, 343, 392, 441, 490]) == True\n assert candidate(nums = [105, 210, 315, 420, 525, 630, 735]) == True\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400]) == True\n assert candidate(nums = [10, 15, 21, 35, 70, 105]) == True\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197]) == False\n assert candidate(nums = [30, 42, 70, 105]) == True\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == False\n assert candidate(nums = [2, 3, 5, 6, 10, 15, 30]) == True\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == True\n assert candidate(nums = [840, 1680, 2520, 3360, 4200]) == True\n assert candidate(nums = [42, 56, 70, 84, 98, 112, 126, 140]) == True\n assert candidate(nums = [31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == False\n assert candidate(nums = [100, 200, 300, 400, 500]) == True\n assert candidate(nums = [81, 121, 169, 225, 289, 361, 441, 529, 625, 729, 841, 961, 1089]) == False\n assert candidate(nums = [6, 10, 15, 21, 26, 33, 35, 39, 42, 55]) == True\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 31, 33]) == False\n assert candidate(nums = [83160, 166320, 249480, 332640, 415800, 498960, 582120, 665280, 748440, 831600]) == False\n assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126]) == True\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(nums = [21, 35, 70, 105]) == True\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == False\n assert candidate(nums = [14, 21, 28, 35, 42, 49, 56]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == False\n assert candidate(nums = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165]) == True\n assert candidate(nums = [30, 45, 60, 75, 90]) == True\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105]) == False\n assert candidate(nums = [84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672]) == True\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131]) == False\n assert candidate(nums = [6, 10, 15, 21, 25, 35]) == True\n assert candidate(nums = [49, 98, 147, 196, 245, 294]) == True\n assert candidate(nums = [12345, 54321, 67890, 98765, 123456, 234567, 345678]) == False\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == True\n assert candidate(nums = [4, 6, 8, 12, 18, 24, 36, 48, 72, 144]) == True\n assert candidate(nums = [10001, 10003, 10007, 10009, 10013, 10021, 10031, 10037, 10039, 10061]) == False\n assert candidate(nums = [10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009]) == False\n assert candidate(nums = [72, 108, 144, 180, 216, 252, 288, 324, 360, 396, 432, 468, 504, 540, 576]) == True\n assert candidate(nums = [24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192]) == True\n assert candidate(nums = [33, 55, 77, 99, 121, 143, 165, 187, 209, 231]) == True\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == False\n assert candidate(nums = [84, 90, 120, 140, 210]) == True\n assert candidate(nums = [9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147]) == False\n assert candidate(nums = [24, 36, 48, 60, 72, 84, 96, 108, 120]) == True\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == True\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114]) == False\n assert candidate(nums = [6, 10, 15, 30, 60, 120]) == True\n assert candidate(nums = [210, 330, 420, 550, 660, 770, 880, 990, 1100, 1210]) == 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]) == False\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == True\n assert candidate(nums = [210, 231, 273, 308, 330, 364]) == True\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [49, 441, 729, 1029, 1323, 1681, 2079, 2521, 2997, 3529, 4041, 4561]) == False\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == False\n assert candidate(nums = [15, 25, 35, 45, 55]) == True\n assert candidate(nums = [2310, 2730, 2310, 2730, 2310, 2730, 2310, 2730, 2310, 2730]) == True\n assert candidate(nums = [18, 24, 30, 36, 42, 48, 54, 60]) == True\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]) == False\n assert candidate(nums = [15, 21, 35, 105]) == True\n assert candidate(nums = [42, 77, 105, 140, 175, 210, 245, 280, 315, 350]) == True\n assert candidate(nums = [21, 35, 49, 63, 105]) == True\n assert candidate(nums = [48, 72, 108, 144, 180, 216]) == True\n assert candidate(nums = [18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102]) == True\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 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]) == False\n assert candidate(nums = [84, 126, 168, 210, 252, 294, 336, 378, 420, 462]) == True\n assert candidate(nums = [210, 420, 630, 840, 1050, 1260, 1470, 1680, 1890, 2100, 2310, 2520, 2730, 2940, 3150, 3360, 3570, 3780, 3990, 4200]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(nums = [36, 48, 60, 72, 84, 96, 108, 120, 132, 144]) == True\n assert candidate(nums = [210, 154, 385, 770]) == True\n assert candidate(nums = [315, 630, 945, 1260, 1575, 1890, 2205, 2520, 2835, 3150]) == True\n assert candidate(nums = [44, 88, 132, 176, 220]) == True\n assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 60]) == True\n assert candidate(nums = [1, 1, 1, 1, 1]) == False\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == True\n assert candidate(nums = [9, 27, 81, 243, 729, 2187, 6561, 19683]) == True\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125]) == True\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173]) == False\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == False\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == True\n assert candidate(nums = [6, 15, 10, 30, 21, 42, 70, 105, 140, 210]) == True\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == True\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19]) == False\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().canTraverseAllPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean canTraverseAllPairs(int[] nums) {", "container": "Solution", "callable": "canTraverseAllPairs", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2710, "task_id": "remove-trailing-zeros-from-a-string", "difficulty": "Easy", "problem_description": "Given a positive integer num represented as a string, return the integer num without trailing zeros as a string.\n \nExample 1:\n\nInput: num = \"51230100\"\nOutput: \"512301\"\nExplanation: Integer \"51230100\" has 2 trailing zeros, we remove them and return integer \"512301\".\n\nExample 2:\n\nInput: num = \"123\"\nOutput: \"123\"\nExplanation: Integer \"123\" has no trailing zeros, we return integer \"123\".\n\n \nConstraints:\n\n1 <= num.length <= 1000\nnum consists of only digits.\nnum doesn't have any leading zeros.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"10\") == \"1\"\n assert candidate(num = \"100100\") == \"1001\"\n assert candidate(num = \"1111111111\") == \"1111111111\"\n assert candidate(num = \"1000\") == \"1\"\n assert candidate(num = \"1\") == \"1\"\n assert candidate(num = \"9876543210\") == \"987654321\"\n assert candidate(num = \"10500\") == \"105\"\n assert candidate(num = \"0\") == \"\"\n assert candidate(num = \"51230100\") == \"512301\"\n assert candidate(num = \"10101000\") == \"10101\"\n assert candidate(num = \"987654321000\") == \"987654321\"\n assert candidate(num = \"000000000000000000000\") == \"\"\n assert candidate(num = \"123\") == \"123\"\n assert candidate(num = \"999999999999999999999\") == \"999999999999999999999\"\n assert candidate(num = \"1000000000000000000001\") == \"1000000000000000000001\"\n assert candidate(num = \"1010101010\") == \"101010101\"\n assert candidate(num = \"999999999900\") == \"9999999999\"\n assert candidate(num = \"10000\") == \"1\"\n assert candidate(num = \"1001001000\") == \"1001001\"\n assert candidate(num = \"1000000000\") == \"1\"\n assert candidate(num = \"100100100\") == \"1001001\"\n assert candidate(num = \"9999999999\") == \"9999999999\"\n assert candidate(num = \"00001\") == \"00001\"\n assert candidate(num = \"100000\") == \"1\"\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().removeTrailingZeros", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String removeTrailingZeros(String num) {", "container": "Solution", "callable": "removeTrailingZeros", "parameters": [{"name": "num", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2711, "task_id": "difference-of-number-of-distinct-values-on-diagonals", "difficulty": "Medium", "problem_description": "Given a 2D grid of size m x n, you should find the matrix answer of size m x n.\nThe cell answer[r][c] is calculated by looking at the diagonal values of the cell grid[r][c]:\n\nLet leftAbove[r][c] be the number of distinct values on the diagonal to the left and above the cell grid[r][c] not including the cell grid[r][c] itself.\nLet rightBelow[r][c] be the number of distinct values on the diagonal to the right and below the cell grid[r][c], not including the cell grid[r][c] itself.\nThen answer[r][c] = |leftAbove[r][c] - rightBelow[r][c]|.\n\nA matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until the end of the matrix is reached.\n\nFor example, in the below diagram the diagonal is highlighted using the cell with indices (2, 3) colored gray:\n\n\t\nRed-colored cells are left and above the cell.\nBlue-colored cells are right and below the cell.\n\n\n\n\nReturn the matrix answer.\n \nExample 1:\n\nInput: grid = [[1,2,3],[3,1,5],[3,2,1]]\nOutput: Output: [[1,1,0],[1,0,1],[0,1,1]]\nExplanation:\nTo calculate the answer cells:\n\n\n\nanswer\nleft-above elements\nleftAbove\nright-below elements\nrightBelow\n|leftAbove - rightBelow|\n\n\n\n\n[0][0]\n[]\n0\n[grid[1][1], grid[2][2]]\n|{1, 1}| = 1\n1\n\n\n[0][1]\n[]\n0\n[grid[1][2]]\n|{5}| = 1\n1\n\n\n[0][2]\n[]\n0\n[]\n0\n0\n\n\n[1][0]\n[]\n0\n[grid[2][1]]\n|{2}| = 1\n1\n\n\n[1][1]\n[grid[0][0]]\n|{1}| = 1\n[grid[2][2]]\n|{1}| = 1\n0\n\n\n[1][2]\n[grid[0][1]]\n|{2}| = 1\n[]\n0\n1\n\n\n[2][0]\n[]\n0\n[]\n0\n0\n\n\n[2][1]\n[grid[1][0]]\n|{3}| = 1\n[]\n0\n1\n\n\n[2][2]\n[grid[0][0], grid[1][1]]\n|{1, 1}| = 1\n[]\n0\n1\n\n\n\n\nExample 2:\n\nInput: grid = [[1]]\nOutput: Output: [[0]]\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n, grid[i][j] <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == [[1, 1, 0], [1, 0, 1], [0, 1, 1]]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(grid = [[1, 1, 2, 2], [1, 1, 2, 2], [3, 3, 4, 4], [3, 3, 4, 4]]) == [[2, 2, 1, 0], [2, 0, 0, 1], [1, 0, 0, 2], [0, 1, 2, 2]]\n assert candidate(grid = [[1, 2], [2, 1], [3, 4]]) == [[1, 0], [1, 1], [0, 1]]\n assert candidate(grid = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [[1, 0], [1, 1], [1, 1], [0, 1]]\n assert candidate(grid = [[1]]) == [[0]]\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]]) == [[1, 1, 0], [1, 0, 1], [0, 1, 1]]\n assert candidate(grid = [[4, 5], [5, 4]]) == [[1, 0], [0, 1]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(grid = [[1, 2], [3, 4]]) == [[1, 0], [0, 1]]\n assert candidate(grid = [[4, 4], [4, 4]]) == [[1, 0], [0, 1]]\n assert candidate(grid = [[1, 2], [2, 3]]) == [[1, 0], [0, 1]]\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == [[2, 1, 0], [1, 0, 1], [0, 1, 2]]\n assert candidate(grid = [[1, 3, 5, 7], [2, 4, 6, 8], [3, 5, 7, 9]]) == [[2, 2, 1, 0], [1, 0, 0, 1], [0, 1, 2, 2]]\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(grid = [[1, 2, 3], [3, 1, 5], [3, 2, 1]]) == [[1, 1, 0], [1, 0, 1], [0, 1, 1]]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [[2, 1, 0], [1, 0, 1], [0, 1, 2]]\n assert candidate(grid = [[4, 3, 2, 1], [5, 6, 7, 8], [9, 10, 11, 12]]) == [[2, 2, 1, 0], [1, 0, 0, 1], [0, 1, 2, 2]]\n assert candidate(grid = [[1, 1, 2, 2, 3], [1, 2, 2, 3, 3], [2, 2, 3, 3, 4], [2, 3, 3, 4, 4], [3, 3, 4, 4, 5]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) == [[2, 1, 0], [2, 0, 1], [2, 0, 2], [2, 0, 2], [1, 0, 2], [0, 1, 2]]\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == [[1, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 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], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == [[4, 4, 3, 4, 3, 4, 3, 2, 1, 0], [3, 2, 2, 1, 2, 2, 2, 1, 0, 1], [2, 1, 0, 0, 0, 0, 1, 0, 1, 2], [1, 0, 1, 2, 2, 2, 2, 1, 2, 3], [0, 1, 2, 3, 4, 4, 3, 4, 2, 4]]\n assert candidate(grid = [[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]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == [[1, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 1]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\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]]) == [[3, 2, 2, 1, 0], [2, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 2], [0, 1, 2, 2, 3]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 1, 1, 1, 1]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[5, 9, 3, 7], [3, 4, 8, 6], [1, 7, 2, 5], [6, 8, 4, 3]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(grid = [[5, 3, 8, 3, 9], [3, 5, 9, 10, 8], [8, 9, 5, 3, 3], [3, 10, 5, 3, 8], [9, 8, 3, 5, 9]]) == [[3, 3, 2, 1, 0], [2, 2, 1, 0, 1], [2, 0, 1, 1, 2], [1, 0, 1, 0, 2], [0, 1, 2, 3, 2]]\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], [5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7]]) == [[6, 5, 4, 3, 2, 1, 0], [5, 4, 3, 2, 1, 0, 1], [4, 3, 2, 1, 0, 1, 2], [3, 2, 1, 0, 1, 2, 3], [2, 1, 0, 1, 2, 3, 4], [1, 0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6]]\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]]) == [[4, 3, 4, 3, 4, 3, 2, 1, 0], [3, 2, 2, 2, 2, 2, 1, 0, 1], [2, 1, 0, 0, 0, 0, 0, 1, 2], [1, 0, 1, 2, 1, 2, 2, 2, 3], [0, 1, 2, 3, 4, 3, 4, 3, 4]]\n assert candidate(grid = [[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]]) == [[5, 4, 3, 2, 1, 0], [4, 3, 2, 1, 0, 1], [3, 2, 1, 0, 1, 2], [2, 1, 0, 1, 2, 3], [1, 0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]]) == [[3, 4, 4, 4, 4, 3, 4, 3, 2, 1, 0], [3, 2, 2, 2, 2, 2, 2, 2, 1, 0, 1], [2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2], [1, 0, 1, 2, 2, 2, 2, 2, 2, 2, 3], [0, 1, 2, 3, 4, 4, 4, 4, 4, 3, 4]]\n assert candidate(grid = [[5, 1, 3], [4, 1, 5], [1, 5, 1], [3, 5, 4]]) == [[1, 1, 0], [2, 0, 1], [1, 0, 2], [0, 1, 2]]\n assert candidate(grid = [[5, 3, 8, 1], [3, 5, 1, 8], [8, 1, 3, 5], [1, 8, 5, 3]]) == [[2, 2, 1, 0], [2, 0, 0, 1], [1, 0, 0, 2], [0, 1, 2, 2]]\n assert candidate(grid = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 2], [1, 2, 2, 1]]) == [[3, 1, 1, 0], [1, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\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]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == [[5, 4, 3, 2, 2, 2, 1, 0], [4, 4, 3, 1, 1, 1, 0, 1], [4, 2, 3, 1, 0, 1, 1, 2], [3, 2, 1, 1, 0, 1, 2, 2], [3, 1, 1, 0, 1, 2, 2, 3], [2, 1, 0, 1, 2, 3, 3, 3], [1, 0, 1, 2, 3, 3, 4, 4], [0, 1, 2, 3, 3, 4, 4, 5]]\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(grid = [[1, 1, 2, 2], [1, 2, 2, 1], [2, 1, 1, 2], [2, 2, 1, 1]]) == [[2, 1, 1, 0], [1, 0, 0, 1], [1, 0, 1, 2], [0, 1, 1, 2]]\n assert candidate(grid = [[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]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[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]]) == [[5, 4, 3, 2, 1, 0], [4, 3, 2, 1, 0, 1], [3, 2, 1, 0, 1, 2], [2, 1, 0, 1, 2, 3], [1, 0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 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, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 1]]\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]]) == [[4, 4, 4, 4, 4, 4, 3, 2, 1, 0], [3, 2, 2, 2, 2, 2, 2, 1, 0, 1], [2, 1, 0, 0, 0, 0, 0, 0, 1, 2], [1, 0, 1, 2, 2, 2, 2, 2, 2, 3], [0, 1, 2, 3, 4, 4, 4, 4, 4, 4]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 4, 3, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == [[4, 3, 3, 2, 2, 1, 0], [3, 3, 2, 2, 1, 0, 1], [3, 2, 2, 1, 0, 1, 2], [2, 2, 1, 0, 1, 2, 2], [2, 1, 0, 1, 2, 2, 3], [1, 0, 1, 2, 2, 3, 3], [0, 1, 2, 2, 3, 3, 4]]\n assert candidate(grid = [[1, 1, 2, 2, 3, 3], [3, 3, 1, 1, 2, 2], [2, 2, 3, 3, 1, 1], [1, 1, 2, 2, 3, 3], [3, 3, 1, 1, 2, 2]]) == [[2, 3, 2, 2, 1, 0], [2, 1, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 2], [0, 1, 2, 2, 3, 2]]\n assert candidate(grid = [[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]]) == [[5, 4, 3, 2, 1, 0], [4, 3, 2, 1, 0, 1], [3, 2, 1, 0, 1, 2], [2, 1, 0, 1, 2, 3], [1, 0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 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, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]) == [[4, 3, 3, 4, 4, 4, 3, 2, 1, 0], [3, 2, 2, 1, 2, 2, 2, 1, 0, 1], [2, 1, 0, 0, 0, 0, 1, 0, 1, 2], [1, 0, 1, 2, 2, 2, 2, 1, 2, 3], [0, 1, 2, 3, 4, 4, 3, 4, 3, 4]]\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 5], [3, 2, 1, 5, 4], [2, 1, 5, 4, 3], [1, 5, 4, 3, 2]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[1, 1, 2, 2, 3, 3, 4, 4, 5, 5], [5, 5, 4, 4, 3, 3, 2, 2, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [[3, 2, 2, 3, 2, 2, 3, 2, 1, 0], [2, 1, 1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1, 1, 2], [0, 1, 2, 3, 2, 3, 3, 2, 3, 3]]\n assert candidate(grid = [[1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [2, 2, 2, 1, 1, 1], [2, 2, 2, 1, 1, 1], [2, 2, 2, 1, 1, 1]]) == [[1, 2, 2, 1, 1, 0], [2, 0, 1, 1, 0, 1], [2, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 2], [1, 0, 1, 1, 0, 2], [0, 1, 1, 2, 2, 1]]\n assert candidate(grid = [[7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 17, 18], [19, 20, 21, 22]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(grid = [[3, 2, 1], [6, 5, 4], [9, 8, 7], [12, 11, 10]]) == [[2, 1, 0], [2, 0, 1], [1, 0, 2], [0, 1, 2]]\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]]) == [[1, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 1]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 2, 4], [4, 2, 1, 3, 5], [5, 1, 4, 2, 3]]) == [[3, 3, 2, 1, 0], [3, 1, 1, 0, 1], [2, 1, 1, 1, 2], [1, 0, 1, 2, 2], [0, 1, 2, 3, 4]]\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]]) == [[3, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 3]]\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], [19, 17, 15, 13, 11, 9, 7, 5, 3, 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], [30, 27, 24, 21, 18, 15, 12, 9, 6, 3], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40], [40, 36, 32, 28, 24, 20, 16, 12, 8, 4]]) == [[7, 7, 6, 6, 4, 4, 3, 2, 1, 0], [6, 6, 6, 4, 4, 3, 2, 1, 0, 1], [6, 4, 4, 4, 3, 2, 2, 0, 1, 2], [5, 4, 2, 2, 2, 1, 0, 0, 2, 3], [4, 3, 2, 1, 1, 0, 0, 2, 1, 4], [3, 2, 2, 0, 0, 1, 2, 2, 4, 3], [3, 1, 0, 0, 1, 2, 2, 3, 4, 5], [2, 1, 0, 2, 2, 3, 4, 4, 5, 6], [1, 0, 1, 2, 3, 4, 4, 5, 5, 7], [0, 1, 2, 3, 4, 5, 6, 6, 7, 7]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1], [3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3], [5, 6, 1, 2, 3, 4], [6, 1, 2, 3, 4, 5]]) == [[3, 3, 3, 2, 1, 0], [3, 2, 2, 1, 0, 1], [3, 2, 1, 0, 1, 2], [2, 1, 0, 1, 2, 3], [1, 0, 1, 2, 2, 3], [0, 1, 2, 3, 3, 3]]\n assert candidate(grid = [[10, 11, 12, 13, 14, 15], [9, 10, 11, 12, 13, 14], [8, 9, 10, 11, 12, 13], [7, 8, 9, 10, 11, 12], [6, 7, 8, 9, 10, 11], [5, 6, 7, 8, 9, 10]]) == [[1, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[9, 2, 8, 6], [3, 5, 7, 1], [4, 6, 3, 5], [8, 7, 4, 6]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(grid = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 1], [1, 1, 1, 1]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\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]]) == [[1, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 1]]\n assert candidate(grid = [[10, 20, 30, 40, 50], [40, 30, 20, 10, 60], [70, 80, 90, 100, 110], [120, 130, 140, 150, 160]]) == [[3, 3, 2, 1, 0], [2, 1, 1, 0, 1], [1, 0, 1, 0, 2], [0, 1, 2, 3, 2]]\n assert candidate(grid = [[7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12]]) == [[2, 1, 0], [2, 0, 1], [1, 0, 2], [0, 1, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3]]) == [[4, 4, 3, 2, 1, 0], [4, 2, 2, 1, 0, 1], [2, 2, 1, 0, 0, 2], [2, 0, 0, 1, 2, 2], [1, 0, 1, 2, 2, 4], [0, 1, 2, 3, 3, 4]]\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 9, 8, 7, 6, 5, 4, 3, 2], [2, 1, 9, 8, 7, 6, 5, 4, 3], [3, 2, 1, 9, 8, 7, 6, 5, 4], [4, 3, 2, 1, 9, 8, 7, 6, 5], [5, 4, 3, 2, 1, 9, 8, 7, 6], [6, 5, 4, 3, 2, 1, 9, 8, 7], [7, 6, 5, 4, 3, 2, 1, 9, 8], [8, 7, 6, 5, 4, 3, 2, 1, 9]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 0], [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, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[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]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 30, 50, 70], [70, 50, 30, 10]]) == [[3, 2, 1, 0], [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 2, 3]]\n assert candidate(grid = [[7, 1, 4, 9], [5, 2, 6, 3], [10, 8, 11, 12], [1, 4, 7, 8]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]]) == [[3, 3, 2, 1, 0], [2, 1, 1, 0, 1], [1, 0, 1, 1, 2], [0, 1, 2, 3, 3]]\n assert candidate(grid = [[7, 7, 7, 7, 7, 7], [7, 8, 8, 8, 8, 7], [7, 8, 9, 9, 8, 7], [7, 8, 9, 10, 9, 8], [7, 8, 9, 9, 8, 7], [7, 8, 8, 8, 8, 7]]) == [[4, 3, 1, 2, 1, 0], [2, 3, 1, 0, 0, 1], [2, 1, 1, 0, 1, 2], [1, 1, 0, 1, 2, 2], [1, 0, 1, 2, 3, 3], [0, 1, 2, 3, 3, 4]]\n assert candidate(grid = [[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]]) == [[1, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 10], [30, 40, 50, 10, 20], [40, 50, 10, 20, 30], [50, 10, 20, 30, 40]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(grid = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 30, 20, 40], [40, 20, 30, 10]]) == [[3, 2, 1, 0], [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 2, 3]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [2, 4, 6, 8, 10]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 2, 4]]\n assert candidate(grid = [[7, 7, 7, 7], [7, 8, 8, 8], [7, 8, 9, 9], [7, 8, 9, 10]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\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]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [2, 4, 6, 8, 0], [0, 8, 6, 4, 2]]) == [[4, 3, 2, 1, 0], [3, 2, 1, 0, 1], [2, 1, 0, 1, 2], [1, 0, 1, 2, 3], [0, 1, 2, 3, 4]]\n assert candidate(grid = [[1, 5, 3, 7], [8, 2, 6, 4], [3, 7, 1, 5], [4, 6, 8, 2], [5, 1, 4, 7]]) == [[2, 2, 1, 0], [2, 1, 0, 1], [2, 1, 1, 2], [1, 0, 1, 2], [0, 1, 2, 2]]\n assert candidate(grid = [[5, 4, 3, 2, 1], [6, 5, 4, 3, 2], [7, 6, 5, 4, 3], [8, 7, 6, 5, 4], [9, 8, 7, 6, 5]]) == [[1, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 1]]\n assert candidate(grid = [[1, 10, 3, 8], [9, 2, 5, 6], [4, 7, 1, 3], [2, 8, 6, 4]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 2]]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [[1, 0], [1, 1], [1, 1], [1, 1], [0, 1]]\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0]]) == [[3, 3, 2, 1, 0], [2, 1, 1, 0, 1], [1, 0, 1, 1, 2], [0, 1, 2, 3, 3]]\n assert candidate(grid = [[7, 7, 7, 7, 7, 7], [7, 6, 6, 6, 6, 7], [7, 6, 5, 5, 6, 7], [7, 6, 5, 4, 5, 7], [7, 6, 5, 5, 6, 7], [7, 7, 7, 7, 7, 7]]) == [[4, 3, 2, 2, 1, 0], [3, 3, 1, 1, 0, 1], [3, 1, 1, 0, 1, 2], [2, 1, 0, 1, 2, 2], [1, 0, 1, 2, 3, 3], [0, 1, 2, 3, 3, 4]]\n assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == [[2, 1, 0], [2, 0, 1], [2, 0, 2], [1, 0, 2], [0, 1, 2]]\n assert candidate(grid = [[10, 20, 30, 40, 50], [20, 10, 40, 30, 60], [30, 40, 10, 20, 50], [40, 30, 20, 10, 40], [50, 60, 50, 40, 10]]) == [[1, 2, 2, 1, 0], [2, 0, 1, 0, 1], [2, 1, 0, 1, 1], [1, 0, 1, 0, 2], [0, 1, 1, 2, 1]]\n assert candidate(grid = [[7, 6, 5, 4], [8, 7, 6, 5], [9, 8, 7, 6], [10, 9, 8, 7]]) == [[1, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 1]]\n assert candidate(grid = [[1, 1, 2, 2], [2, 2, 1, 1], [1, 1, 2, 2], [2, 2, 1, 1]]) == [[2, 2, 1, 0], [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 2, 2]]\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 30, 50, 20, 40], [40, 20, 10, 50, 30]]) == [[2, 2, 2, 1, 0], [2, 0, 1, 0, 1], [1, 0, 1, 1, 2], [0, 1, 2, 3, 2]]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().differenceOfDistinctValues", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] differenceOfDistinctValues(int[][] grid) {", "container": "Solution", "callable": "differenceOfDistinctValues", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2712, "task_id": "minimum-cost-to-make-all-characters-equal", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary string s of length n on which you can apply two types of operations:\n\nChoose an index i and invert all characters from index 0 to index i (both inclusive), with a cost of i + 1\nChoose an index i and invert all characters from index i to index n - 1 (both inclusive), with a cost of n - i\n\nReturn the minimum cost to make all characters of the string equal.\nInvert a character means if its value is '0' it becomes '1' and vice-versa.\n \nExample 1:\n\nInput: s = \"0011\"\nOutput: 2\nExplanation: Apply the second operation with i = 2 to obtain s = \"0000\" for a cost of 2. It can be shown that 2 is the minimum cost to make all characters equal.\n\nExample 2:\n\nInput: s = \"010101\"\nOutput: 9\nExplanation: Apply the first operation with i = 2 to obtain s = \"101101\" for a cost of 3.\nApply the first operation with i = 1 to obtain s = \"011101\" for a cost of 2. \nApply the first operation with i = 0 to obtain s = \"111101\" for a cost of 1. \nApply the second operation with i = 4 to obtain s = \"111110\" for a cost of 2.\nApply the second operation with i = 5 to obtain s = \"111111\" for a cost of 1. \nThe total cost to make all characters equal is 9. It can be shown that 9 is the minimum cost to make all characters equal.\n\n \nConstraints:\n\n1 <= s.length == n <= 105\ns[i] is either '0' or '1'\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"100100100\") == 13\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"110011\") == 4\n assert candidate(s = \"11110000\") == 4\n assert candidate(s = \"1000100010001\") == 20\n assert candidate(s = \"111000\") == 3\n assert candidate(s = \"101010101010\") == 36\n assert candidate(s = \"0100100100\") == 17\n assert candidate(s = \"1111111111\") == 0\n assert candidate(s = \"000111\") == 3\n assert candidate(s = \"11111\") == 0\n assert candidate(s = \"0101010101010101010101010101\") == 196\n assert candidate(s = \"01010101010\") == 30\n assert candidate(s = \"1010101010\") == 25\n assert candidate(s = \"010101\") == 9\n assert candidate(s = \"010101010101010101\") == 81\n assert candidate(s = \"0000000000\") == 0\n assert candidate(s = \"1100110011\") == 12\n assert candidate(s = \"101010\") == 9\n assert candidate(s = \"0011\") == 2\n assert candidate(s = \"0101010101\") == 25\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"101010101010101010\") == 81\n assert candidate(s = \"0000111100001111000011110000111100001111000011110000111100001111\") == 256\n assert candidate(s = \"101010101010101\") == 56\n assert candidate(s = \"000000111111000000\") == 12\n assert candidate(s = \"00000000001\") == 1\n assert candidate(s = \"10101010101\") == 30\n assert candidate(s = \"010101010101010101010101010101010101\") == 324\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111101\") == 3\n assert candidate(s = \"0110011001100110011001100110\") == 98\n assert candidate(s = \"1111100001111100001111100001111100001111100001111100001111100001\") == 228\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111010\") == 6\n assert candidate(s = \"010101010101010101010101\") == 144\n assert candidate(s = \"0100100100100100100100100100\") == 131\n assert candidate(s = \"0110110110\") == 16\n assert candidate(s = \"10101010101010101010101010\") == 169\n assert candidate(s = \"00000111111\") == 5\n assert candidate(s = \"111000111000111\") == 18\n assert candidate(s = \"0000000000000000000000000000000011111111111111111111\") == 20\n assert candidate(s = \"101010101010101010101010\") == 144\n assert candidate(s = \"00000000001000000000\") == 19\n assert candidate(s = \"00000000000000\") == 0\n assert candidate(s = \"11001100110011001100110011001100\") == 128\n assert candidate(s = \"101010101010101010101010101010\") == 225\n assert candidate(s = \"000000111111000000111111000000111111\") == 54\n assert candidate(s = \"111100001111000011110000111100001111\") == 80\n assert candidate(s = \"111100001111000011110000\") == 36\n assert candidate(s = \"111111111111111111110\") == 1\n assert candidate(s = \"000000000000000000001\") == 1\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000010\") == 3\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"100100100100100100100100\") == 96\n assert candidate(s = \"0011001100110011001100110011001100110011\") == 200\n assert candidate(s = \"0000111100001111000011110000\") == 48\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"00110011001100110011001100110011\") == 128\n assert candidate(s = \"111111111111\") == 0\n assert candidate(s = \"1001001001001001001001001001001\") == 160\n assert candidate(s = \"11110000111100001111\") == 24\n assert candidate(s = \"01010101010101010101010101\") == 169\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000000000000001\") == 1\n assert candidate(s = \"1011011011011011011011011011\") == 131\n assert candidate(s = \"010101010101010101010101010101010101010101010101\") == 576\n assert candidate(s = \"111111111100000000001111111111\") == 20\n assert candidate(s = \"111111000000111111\") == 12\n assert candidate(s = \"010010010010010010010010010010\") == 150\n assert candidate(s = \"1111000011110000111100001111000011110000111100001111000011110000\") == 256\n assert candidate(s = \"0000011111\") == 5\n assert candidate(s = \"11111111111111111111\") == 0\n assert candidate(s = \"000011110000\") == 8\n assert candidate(s = \"101010010101010\") == 50\n assert candidate(s = \"1001001001\") == 16\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"111111111111111111\") == 0\n assert candidate(s = \"11110000001111000000\") == 20\n assert candidate(s = \"000001111000001111000001111000001111000001111000001111000001111\") == 220\n assert candidate(s = \"1010101010101010101010101010101010\") == 289\n assert candidate(s = \"10010010010010\") == 33\n assert candidate(s = \"111111000000111111000000111111\") == 36\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010\") == 1024\n assert candidate(s = \"000000000000\") == 0\n assert candidate(s = \"010101010101010101010101010101\") == 225\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010100\") == 1055\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"1001001001001001\") == 42\n assert candidate(s = \"1111111111111111000000000000\") == 12\n assert candidate(s = \"0110011001100110011001100\") == 78\n assert candidate(s = \"11001100110011001100\") == 50\n assert candidate(s = \"110011110011001111001100111100110011\") == 130\n assert candidate(s = \"01010101010101010101010101010101\") == 256\n assert candidate(s = \"0101010101010101010101010101010101010101\") == 400\n assert candidate(s = \"1010101010101010101010101010\") == 196\n assert candidate(s = \"1000000000000000000000000000000000000000\") == 1\n assert candidate(s = \"111000111000\") == 12\n assert candidate(s = \"1111111100000000\") == 8\n assert candidate(s = \"111100001111\") == 8\n assert candidate(s = \"1100110011001100110011001100\") == 98\n assert candidate(s = \"10101001010101010101010101010101\") == 250\n assert candidate(s = \"11110000111100001111000011110000\") == 64\n assert candidate(s = \"010101010101\") == 36\n assert candidate(s = \"111111111100000000111111111100000000\") == 36\n assert candidate(s = \"11011011011011011011\") == 66\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101011\") == 1088\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000101\") == 6\n assert candidate(s = \"0101010101010101\") == 64\n assert candidate(s = \"1111111111111111111111111111\") == 0\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101\") == 1024\n assert candidate(s = \"111111110000000011111111\") == 16\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101\") == 729\n assert candidate(s = \"01001010010100101001010010100101001010010100101001010010100101000\") == 843\n assert candidate(s = \"111100001111000011\") == 20\n assert candidate(s = \"011001100110\") == 18\n assert candidate(s = \"000011110000111100001111\") == 36\n assert candidate(s = \"000000000011111111110000000000\") == 20\n assert candidate(s = \"10011001100110011001100110011001\") == 128\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"00001111000011110000111100001111\") == 64\n assert candidate(s = \"0100110011001100110011\") == 61\n assert candidate(s = \"1100101100\") == 17\n assert candidate(s = \"00110011001100110011\") == 50\n assert candidate(s = \"11111111110\") == 1\n assert candidate(s = \"00000000000000000000\") == 0\n assert candidate(s = \"1111100000\") == 5\n assert candidate(s = \"0000000011111111\") == 8\n assert candidate(s = \"1001001001001001001001001\") == 104\n assert candidate(s = \"0000000000000000111111111111\") == 12\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"000000000000000000\") == 0\n assert candidate(s = \"01010101010101\") == 49\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"01010110101010101010101010101010\") == 250\n assert candidate(s = \"001100110011001\") == 28\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 400\n assert candidate(s = \"0100101001010010100101001010010100101001010010100101001010010100\") == 819\n assert candidate(s = \"000001111111\") == 5\n assert candidate(s = \"100100100100\") == 24\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010\") == 1056\n assert candidate(s = \"11111000001111\") == 9\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\") == 676\n assert candidate(s = \"110011001100110011001100110011\") == 112\n assert candidate(s = \"01010101010101010101\") == 100\n assert candidate(s = \"01111111111111111110\") == 2\n assert candidate(s = \"11001100110011\") == 24\n assert candidate(s = \"111110000000\") == 5\n assert candidate(s = \"0110011001100110011001100110011\") == 120\n assert candidate(s = \"10000000000000000001\") == 2\n assert candidate(s = \"11111000000\") == 5\n assert candidate(s = \"0000000000000000000000000000000000000001\") == 1\n assert candidate(s = \"11111111111111\") == 0\n assert candidate(s = \"010101010101010\") == 56\n assert candidate(s = \"11111111111111110000000000000000\") == 16\n assert candidate(s = \"10101010101010101010\") == 100\n assert candidate(s = \"1101010101\") == 24\n assert candidate(s = \"000000111111000000111111000000\") == 36\n assert candidate(s = \"00100100100100100100\") == 66\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111110\") == 1\n assert candidate(s = \"0110110110110110110110110110110\") == 160\n assert candidate(s = \"0000000000000000000000000000\") == 0\n assert candidate(s = \"001100110011001100110011001100\") == 112\n assert candidate(s = \"000111000111000\") == 18\n assert candidate(s = \"0000111100001111\") == 16\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumCost(String s) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "s", "type": "String"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2713, "task_id": "maximum-strictly-increasing-cells-in-a-matrix", "difficulty": "Hard", "problem_description": "Given a 1-indexed m x n integer matrix mat, you can select any cell in the matrix as your starting cell.\nFrom the starting cell, you can move to any other cell in the same row or column, but only if the value of the destination cell is strictly greater than the value of the current cell. You can repeat this process as many times as possible, moving from cell to cell until you can no longer make any moves.\nYour task is to find the maximum number of cells that you can visit in the matrix by starting from some cell.\nReturn an integer denoting the maximum number of cells that can be visited.\n \nExample 1:\n\n\nInput: mat = [[3,1],[3,4]]\nOutput: 2\nExplanation: The image shows how we can visit 2 cells starting from row 1, column 2. It can be shown that we cannot visit more than 2 cells no matter where we start from, so the answer is 2. \n\nExample 2:\n\n\nInput: mat = [[1,1],[1,1]]\nOutput: 1\nExplanation: Since the cells must be strictly increasing, we can only visit one cell in this example. \n\nExample 3:\n\n\nInput: mat = [[3,1,6],[-9,5,7]]\nOutput: 4\nExplanation: The image above shows how we can visit 4 cells starting from row 2, column 1. It can be shown that we cannot visit more than 4 cells no matter where we start from, so the answer is 4. \n\n \nConstraints:\n\nm == mat.length \nn == mat[i].length \n1 <= m, n <= 105\n1 <= m * n <= 105\n-105 <= mat[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[10, 20, 30], [15, 25, 35], [20, 30, 40]]) == 5\n assert candidate(mat = [[1]]) == 1\n assert candidate(mat = [[-100000, 100000], [-100000, 100000]]) == 2\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 1\n assert candidate(mat = [[10, 9, 8, 7, 6], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10]]) == 10\n assert candidate(mat = [[3, 1], [3, 4]]) == 2\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == 6\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == 6\n assert candidate(mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 5\n assert candidate(mat = [[10, 9, 8, 7], [6, 5, 4, 3], [2, 1, 0, -1]]) == 6\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 5\n assert candidate(mat = [[-1, -2, -3], [-2, -3, -4], [-3, -4, -5]]) == 5\n assert candidate(mat = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == 5\n assert candidate(mat = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]) == 6\n assert candidate(mat = [[1, 1], [1, 1]]) == 1\n assert candidate(mat = [[1, 3, 5], [2, 4, 6], [3, 5, 7]]) == 5\n assert candidate(mat = [[10, 9, 8], [7, 6, 5], [4, 3, 2], [1, 1, 1]]) == 6\n assert candidate(mat = [[3, 1, 6], [-9, 5, 7]]) == 4\n assert candidate(mat = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]]) == 6\n assert candidate(mat = [[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, 17, 19, 21, 23, 25, 27, 29], [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]]) == 21\n assert candidate(mat = [[-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20]]) == 8\n assert candidate(mat = [[1, 10, 3, 4, 5], [10, 1, 8, 7, 6], [3, 8, 1, 14, 15], [18, 7, 14, 1, 16]]) == 10\n assert candidate(mat = [[10, 20, 30], [30, 20, 10], [10, 20, 30], [30, 20, 10], [10, 20, 30]]) == 3\n assert candidate(mat = [[-5, -4, -3, -2, -1], [-4, -3, -2, -1, 0], [-3, -2, -1, 0, 1], [-2, -1, 0, 1, 2], [-1, 0, 1, 2, 3]]) == 9\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [9, 10, 11, 12, 13, 14, 15, 16], [16, 15, 14, 13, 12, 11, 10, 9]]) == 16\n assert candidate(mat = [[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], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 12\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]]) == 14\n assert candidate(mat = [[-5, -4, -3, -2, -1], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) == 7\n assert candidate(mat = [[-1, -2, -3, -4], [-4, -3, -2, -1], [-5, -6, -7, -8], [-8, -7, -6, -5]]) == 8\n assert candidate(mat = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 1\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 1\n assert candidate(mat = [[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]]) == 13\n assert candidate(mat = [[100, 200, 300], [150, 250, 350], [200, 300, 400]]) == 5\n assert candidate(mat = [[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]]) == 9\n assert candidate(mat = [[100, 200, 300], [150, 250, 350], [200, 300, 400]]) == 5\n assert candidate(mat = [[1, 10, 1, 10, 1, 10], [10, 1, 10, 1, 10, 1], [1, 10, 1, 10, 1, 10], [10, 1, 10, 1, 10, 1], [1, 10, 1, 10, 1, 10]]) == 2\n assert candidate(mat = [[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\n assert candidate(mat = [[-10, -9, -8, -7], [-6, -5, -4, -3], [-2, -1, 0, 1], [2, 3, 4, 5]]) == 7\n assert candidate(mat = [[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]]) == 12\n assert candidate(mat = [[1, 1, 1, 1], [1, 2, 3, 1], [1, 3, 1, 1], [1, 1, 1, 1]]) == 3\n assert candidate(mat = [[-1, 0, 1, 2], [3, 4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14]]) == 7\n assert candidate(mat = [[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]]) == 9\n assert candidate(mat = [[5, 3, 1, 4], [6, 2, 8, 7], [9, 11, 13, 12], [10, 15, 14, 16]]) == 12\n assert candidate(mat = [[1, 10, 3, 11, 5], [12, 6, 7, 8, 9], [13, 14, 15, 16, 17], [18, 19, 20, 21, 22]]) == 12\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 7\n assert candidate(mat = [[10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10]]) == 1\n assert candidate(mat = [[5, 3, 8, 2, 9], [1, 6, 4, 7, 3], [9, 1, 8, 2, 5], [2, 7, 3, 8, 4], [8, 2, 9, 4, 1]]) == 7\n assert candidate(mat = [[1, 2, 3, 4, 5], [4, 3, 2, 1, 0], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 1, 1, 1, 1]]) == 8\n assert candidate(mat = [[1, 2, 3, 4, 5], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [10, 8, 6, 4, 2], [9, 7, 5, 3, 1]]) == 7\n assert candidate(mat = [[-10, -20, -30], [-20, -30, -40], [-30, -40, -50]]) == 5\n assert candidate(mat = [[1, 3, 2, 4, 5], [6, 5, 4, 3, 2], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16]]) == 11\n assert candidate(mat = [[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]]) == 9\n assert candidate(mat = [[5, 5, 5, 5, 5], [5, 1, 5, 1, 5], [5, 1, 10, 1, 5], [5, 1, 5, 1, 5], [5, 5, 5, 5, 5]]) == 3\n assert candidate(mat = [[1, 3, 2, 4, 5], [6, 8, 7, 9, 10], [11, 13, 12, 15, 14], [19, 18, 17, 20, 21], [22, 23, 24, 25, 26]]) == 12\n assert candidate(mat = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]) == 7\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 5\n assert candidate(mat = [[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]]) == 3\n assert candidate(mat = [[5, 5, 5, 5, 5], [5, 1, 2, 3, 5], [5, 4, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 4\n assert candidate(mat = [[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]]) == 5\n assert candidate(mat = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == 10\n assert candidate(mat = [[3, 1, 4, 1, 5], [9, 2, 6, 5, 3], [5, 8, 9, 7, 9], [3, 2, 3, 8, 4]]) == 7\n assert candidate(mat = [[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]]) == 3\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 100]]) == 2\n assert candidate(mat = [[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]]) == 17\n assert candidate(mat = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 1], [1, 1, 1, 1]]) == 3\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11], [12, 10, 8, 6, 4, 2]]) == 8\n assert candidate(mat = [[3, 3, 3, 3, 3], [3, 2, 2, 2, 3], [3, 2, 1, 2, 3], [3, 2, 2, 2, 3], [3, 3, 3, 3, 3]]) == 3\n assert candidate(mat = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 7\n assert candidate(mat = [[3, 1, 4, 1, 5, 9], [2, 6, 5, 3, 5, 9], [5, 8, 9, 7, 9, 3], [2, 8, 0, 3, 1, 4]]) == 9\n assert candidate(mat = [[10, 15, 20], [25, 30, 35], [40, 45, 50], [55, 60, 65], [70, 75, 80]]) == 7\n assert candidate(mat = [[1, 100, 2, 99, 3, 98, 4, 97, 5, 96], [6, 95, 7, 94, 8, 93, 9, 92, 10, 91]]) == 12\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]) == 12\n assert candidate(mat = [[1, 100, 1], [100, 1, 100], [1, 100, 1]]) == 2\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]]) == 9\n assert candidate(mat = [[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, 2, 4, 6, 8, 10]]) == 10\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [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], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 14\n assert candidate(mat = [[5, 2, 3, 4, 1], [1, 2, 6, 7, 8], [3, 4, 5, 6, 9], [9, 8, 7, 6, 5]]) == 8\n assert candidate(mat = [[-10, -20, -30], [-30, -20, -10], [-10, -30, -20]]) == 3\n assert candidate(mat = [[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, 2, 4, 6, 8, 10], [10, 8, 6, 4, 2, 9, 7, 5, 3, 1]]) == 10\n assert candidate(mat = [[-10, -20, -30, -40], [-40, -30, -20, -10], [-50, -60, -70, -80], [-80, -70, -60, -50]]) == 8\n assert candidate(mat = [[1, 5, 3, 6, 2], [9, 8, 7, 10, 11], [4, 13, 12, 15, 14], [19, 18, 17, 20, 21]]) == 12\n assert candidate(mat = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 7\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1]]) == 6\n assert candidate(mat = [[5, 3, 1, 2], [4, 6, 2, 3], [7, 5, 3, 4], [8, 6, 4, 5]]) == 7\n assert candidate(mat = [[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]]) == 5\n assert candidate(mat = [[10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55]]) == 7\n assert candidate(mat = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 1\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [2, 4, 6, 8, 10]]) == 7\n assert candidate(mat = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16]]) == 20\n assert candidate(mat = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 6\n assert candidate(mat = [[-10, -20, -30, -40], [-35, -25, -15, -5], [-50, -45, -40, -35], [-60, -55, -50, -45]]) == 8\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [30, 29, 28, 27, 26, 25, 24, 23, 22, 21]]) == 21\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18]]) == 8\n assert candidate(mat = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == 25\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 5\n assert candidate(mat = [[1, 1000, 2, 999], [3, 998, 4, 997], [5, 996, 6, 995], [7, 994, 8, 993]]) == 10\n assert candidate(mat = [[5, 3, 9, 1], [1, 7, 6, 8], [2, 9, 5, 1], [8, 5, 4, 6]]) == 6\n assert candidate(mat = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30]]) == 26\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]]) == 11\n assert candidate(mat = [[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], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 14\n assert candidate(mat = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]) == 4\n assert candidate(mat = [[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\n assert candidate(mat = [[-1, -2, -3], [-3, -2, -1], [1, 0, -1], [-2, -3, -4]]) == 5\n assert candidate(mat = [[100, -100, 200, -200, 300], [-300, 300, -400, 400, -500], [500, -500, 600, -600, 700]]) == 7\n assert candidate(mat = [[100, -100, 200, -200, 300], [-100, 200, -200, 300, -300], [200, -200, 300, -300, 400], [0, 0, 0, 0, 0]]) == 8\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().maxIncreasingCells", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxIncreasingCells(int[][] mat) {", "container": "Solution", "callable": "maxIncreasingCells", "parameters": [{"name": "mat", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2716, "task_id": "minimize-string-length", "difficulty": "Easy", "problem_description": "Given a string s, you have two types of operation:\n\nChoose an index i in the string, and let c be the character in position i. Delete the closest occurrence of c to the left of i (if exists).\nChoose an index i in the string, and let c be the character in position i. Delete the closest occurrence of c to the right of i (if exists).\n\nYour task is to minimize the length of s by performing the above operations zero or more times.\nReturn an integer denoting the length of the minimized string.\n \nExample 1:\n\nInput: s = \"aaabc\"\nOutput: 3\nExplanation:\n\nOperation 2: we choose i = 1 so c is 'a', then we remove s[2] as it is closest 'a' character to the right of s[1].\ns becomes \"aabc\" after this.\nOperation 1: we choose i = 1 so c is 'a', then we remove s[0] as it is closest 'a' character to the left of s[1].\ns becomes \"abc\" after this.\n\n\nExample 2:\n\nInput: s = \"cbbd\"\nOutput: 3\nExplanation:\n\nOperation 1: we choose i = 2 so c is 'b', then we remove s[1] as it is closest 'b' character to the left of s[1].\ns becomes \"cbd\" after this.\n\n\nExample 3:\n\nInput: s = \"baadccab\"\nOutput: 4\nExplanation:\n\nOperation 1: we choose i = 6 so c is 'a', then we remove s[2] as it is closest 'a' character to the left of s[6].\ns becomes \"badccab\" after this.\nOperation 2: we choose i = 0 so c is 'b', then we remove s[6] as it is closest 'b' character to the right of s[0].\ns becomes \"badcca\" fter this.\nOperation 2: we choose i = 3 so c is 'c', then we remove s[4] as it is closest 'c' character to the right of s[3].\ns becomes \"badca\" after this.\nOperation 1: we choose i = 4 so c is 'a', then we remove s[1] as it is closest 'a' character to the left of s[4].\ns becomes \"bdca\" after this.\n\n\n \nConstraints:\n\n1 <= s.length <= 100\ns contains only lowercase English letters\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabc\") == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"abacabadabacaba\") == 4\n assert candidate(s = \"abcabcabc\") == 3\n assert candidate(s = \"zzzz\") == 1\n assert candidate(s = \"cbbd\") == 3\n assert candidate(s = \"abcabc\") == 3\n assert candidate(s = \"xyz\") == 3\n assert candidate(s = \"aabb\") == 2\n assert candidate(s = \"world\") == 5\n assert candidate(s = \"zyxzyxzyx\") == 3\n assert candidate(s = \"baadccab\") == 4\n assert candidate(s = \"abcd\") == 4\n assert candidate(s = \"hello\") == 4\n assert candidate(s = \"abcdeabcde\") == 5\n assert candidate(s = \"aabbcc\") == 3\n assert candidate(s = \"zzzzz\") == 1\n assert candidate(s = \"programming\") == 8\n assert candidate(s = \"aabbccdd\") == 4\n assert candidate(s = \"abcdefg\") == 7\n assert candidate(s = \"aaaaaabbbbbcccccdddddeeeeeffffffggggg\") == 7\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\") == 3\n assert candidate(s = \"abracadabra\") == 5\n assert candidate(s = \"abcabcabcabc\") == 3\n assert candidate(s = \"tattarrattat\") == 3\n assert candidate(s = \"abcdefghigklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"abracadabraabracadabraabracadabraabracadabra\") == 5\n assert candidate(s = \"nervosysystem\") == 9\n assert candidate(s = \"bbaaccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 26\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 3\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == 10\n assert candidate(s = \"aaaaabbbbccccdddd\") == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"xyzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxz\") == 3\n assert candidate(s = \"fakemakesfakeakesakesakefake\") == 6\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 3\n assert candidate(s = \"kayak\") == 3\n assert candidate(s = \"aaaabbbbccccdddeeefffggghhhhiiijjjjkkkkllllmmmmmnnnnnooooo\") == 15\n assert candidate(s = \"xyzzzxyyyxyxxxyyxx\") == 3\n assert candidate(s = \"mnopqrspomnopqrspomnopqrspomnopqrspomnopqrspomnopqrspomnopqrspomn\") == 7\n assert candidate(s = \"aabcccccaaaa\") == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyyy\") == 26\n assert candidate(s = \"abracadabraabracadabraabracadabra\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == 26\n assert candidate(s = \"noon\") == 2\n assert candidate(s = \"abcdefghijkabcdefghi\") == 11\n assert candidate(s = \"ababababababababab\") == 2\n assert candidate(s = \"abcdefghijkabcdefghijk\") == 11\n assert candidate(s = \"nanaanananananananana\") == 2\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijk\") == 11\n assert candidate(s = \"abcdabcdabcdabcd\") == 4\n assert candidate(s = \"level\") == 3\n assert candidate(s = \"abababababababababababababab\") == 2\n assert candidate(s = \"aaaaabbbbbbccccccccdddddddd\") == 4\n assert candidate(s = \"zzzyyyyyxxxxwwwvvvuuutttsssrrqqppoonnmmmlllkkkjjjiiihhggffeeddccbbaa\") == 26\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 3\n assert candidate(s = \"abababababababababab\") == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxy\") == 2\n assert candidate(s = \"abcdefghijkabcdefg\") == 11\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"xyzzzzyx\") == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"hellohellohellohellohellohellohellohellohellohello\") == 4\n assert candidate(s = \"aabaaabbbcccddddeeeeffffgggghhhhiiiiijjjjkkkklllmmnnnnooopppqqrrrsssttttuuuuvvvvwwwwxxxxxyyyyzzzz\") == 26\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefgabcdefg\") == 7\n assert candidate(s = \"aabbccddeeefffggghhhhiiiiijjjjjkkkkklmmmmmnnnnnoooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 26\n assert candidate(s = \"banana\") == 3\n assert candidate(s = \"thisisaverylongstringwithseveralcharacters\") == 15\n assert candidate(s = \"thisisaverylongstringwithmanyalphabetsandduplicates\") == 20\n assert candidate(s = \"aaaaaabbbbbbccccccdddddeeeeeeffffffff\") == 6\n assert candidate(s = \"ababababababababababababab\") == 2\n assert candidate(s = \"elephant\") == 7\n assert candidate(s = \"abcdefghijkab\") == 11\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 26\n assert candidate(s = \"nnnaaaabbbcccdddddeeefffgggghhhhiiiiijjjjjkkkkkkllllllmmmmmmmnnnnnnnnooooooooooppppppppppqrrrrrrrrrrsssssssssss\") == 19\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 6\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\") == 26\n assert candidate(s = \"aaaabbbbccccdddd\") == 4\n assert candidate(s = \"zzyyxwwvvuuttssrrqqppoonnmlkjihgfedcba\") == 26\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 26\n assert candidate(s = \"deified\") == 4\n assert candidate(s = \"repaper\") == 4\n assert candidate(s = \"ppppqqqqrrrrssssttttuuuuvvvvwwwwwxxxxxyyyyyzzzzz\") == 11\n assert candidate(s = \"aabbaabbccddeeffaabbccddeeff\") == 6\n assert candidate(s = \"nolemonnomelon\") == 5\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(s = \"ababababab\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiiiiijjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkllllllllllllllllllmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnoooooookkkkkkkkkkkkkkkkkkkkkkppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrrssssssssssssssssssssstttttttttttttttttttuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzz\") == 26\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == 3\n assert candidate(s = \"abcdefghijkabcde\") == 11\n assert candidate(s = \"civic\") == 3\n assert candidate(s = \"rotor\") == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz\") == 26\n assert candidate(s = \"racecar\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == 2\n assert candidate(s = \"abbcccddddeeeee\") == 5\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"aabbccddeeefff\") == 6\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzz\") == 26\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghij\") == 11\n assert candidate(s = \"mississippi\") == 4\n assert candidate(s = \"unique\") == 5\n assert candidate(s = \"abcabcabcabcabc\") == 3\n assert candidate(s = \"aabbbcccddd\") == 4\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\") == 4\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimizedStringLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimizedStringLength(String s) {", "container": "Solution", "callable": "minimizedStringLength", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2717, "task_id": "semi-ordered-permutation", "difficulty": "Easy", "problem_description": "You are given a 0-indexed permutation of n integers nums.\nA permutation is called semi-ordered if the first number equals 1 and the last number equals n. You can perform the below operation as many times as you want until you make nums a semi-ordered permutation:\n\nPick two adjacent elements in nums, then swap them.\n\nReturn the minimum number of operations to make nums a semi-ordered permutation.\nA permutation is a sequence of integers from 1 to n of length n containing each number exactly once.\n \nExample 1:\n\nInput: nums = [2,1,4,3]\nOutput: 2\nExplanation: We can make the permutation semi-ordered using these sequence of operations: \n1 - swap i = 0 and j = 1. The permutation becomes [1,2,4,3].\n2 - swap i = 2 and j = 3. The permutation becomes [1,2,3,4].\nIt can be proved that there is no sequence of less than two operations that make nums a semi-ordered permutation. \n\nExample 2:\n\nInput: nums = [2,4,1,3]\nOutput: 3\nExplanation: We can make the permutation semi-ordered using these sequence of operations:\n1 - swap i = 1 and j = 2. The permutation becomes [2,1,4,3].\n2 - swap i = 0 and j = 1. The permutation becomes [1,2,4,3].\n3 - swap i = 2 and j = 3. The permutation becomes [1,2,3,4].\nIt can be proved that there is no sequence of less than three operations that make nums a semi-ordered permutation.\n\nExample 3:\n\nInput: nums = [1,3,4,2,5]\nOutput: 0\nExplanation: The permutation is already a semi-ordered permutation.\n\n \nConstraints:\n\n2 <= nums.length == n <= 50\n1 <= nums[i] <= 50\nnums is a permutation.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [2, 4, 1, 3]) == 3\n assert candidate(nums = [3, 5, 4, 1, 2]) == 5\n assert candidate(nums = [3, 1, 2, 5, 4]) == 2\n assert candidate(nums = [1, 5, 4, 3, 2]) == 3\n assert candidate(nums = [3, 2, 5, 4, 1]) == 5\n assert candidate(nums = [4, 1, 2, 5, 3]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [2, 3, 4, 5, 1]) == 4\n assert candidate(nums = [4, 5, 3, 1, 2]) == 5\n assert candidate(nums = [1, 3, 4, 2, 5]) == 0\n assert candidate(nums = [2, 1, 4, 3]) == 2\n assert candidate(nums = [3, 2, 1, 5, 4]) == 3\n assert candidate(nums = [10, 1, 9, 8, 7, 6, 5, 4, 3, 2]) == 9\n assert candidate(nums = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 20, 19, 18, 17, 2]) == 18\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16]) == 18\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 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]) == 14\n assert candidate(nums = [4, 2, 5, 1, 3]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 2, 1]) == 10\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 37\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 37\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == 9\n assert candidate(nums = [5, 1, 2, 3, 4, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [4, 3, 5, 1, 2]) == 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, 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]) == 97\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]) == 47\n assert candidate(nums = [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]) == 49\n assert candidate(nums = [48, 29, 10, 34, 32, 15, 19, 2, 25, 47, 35, 13, 44, 12, 8, 41, 17, 40, 21, 4, 42, 18, 33, 36, 22, 39, 26, 7, 5, 43, 6, 37, 31, 27, 30, 24, 20, 1, 23, 38, 9, 28, 16, 3, 11, 14, 45, 46, 49, 50]) == 37\n assert candidate(nums = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 8\n assert candidate(nums = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 8\n assert candidate(nums = [1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 18\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]) == 57\n assert candidate(nums = [15, 1, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 14\n assert candidate(nums = [4, 5, 1, 3, 2]) == 4\n assert candidate(nums = [5, 3, 2, 1, 4]) == 6\n assert candidate(nums = [23, 15, 32, 1, 10, 45, 2, 11, 50, 8, 13, 19, 6, 9, 17, 27, 20, 21, 22, 3, 24, 25, 26, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49]) == 8\n assert candidate(nums = [1, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 23\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]) == 29\n assert candidate(nums = [49, 1, 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]) == 48\n assert candidate(nums = [49, 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, 1, 50]) == 48\n assert candidate(nums = [48, 49, 50, 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, 1, 2, 3]) == 93\n assert candidate(nums = [4, 5, 2, 3, 1]) == 6\n assert candidate(nums = [7, 5, 6, 4, 1, 3, 2]) == 9\n assert candidate(nums = [5, 1, 4, 2, 3]) == 4\n assert candidate(nums = [5, 2, 3, 4, 1]) == 7\n assert candidate(nums = [4, 5, 3, 2, 1]) == 6\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]) == 97\n assert candidate(nums = [2, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1]) == 46\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 9\n assert candidate(nums = [4, 1, 3, 5, 2]) == 2\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == 9\n assert candidate(nums = [2, 10, 9, 8, 7, 6, 5, 4, 3, 1]) == 16\n assert candidate(nums = [10, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 17\n assert candidate(nums = [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, 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\n assert candidate(nums = [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]) == 77\n assert candidate(nums = [2, 5, 4, 1, 3]) == 5\n assert candidate(nums = [49, 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, 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, 1]) == 48\n assert candidate(nums = [45, 1, 2, 3, 46, 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]) == 1\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]) == 9\n assert candidate(nums = [2, 19, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1]) == 35\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(nums = [3, 5, 2, 4, 1]) == 6\n assert candidate(nums = [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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46]) == 48\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(nums = [2, 5, 4, 1, 3]) == 5\n assert candidate(nums = [2, 3, 5, 4, 1]) == 5\n assert candidate(nums = [5, 2, 3, 1, 4]) == 6\n assert candidate(nums = [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, 46]) == 44\n assert candidate(nums = [5, 1, 2, 3, 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [2, 5, 4, 3, 1]) == 6\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, 26, 27, 28, 29, 30, 1]) == 29\n assert candidate(nums = [5, 3, 4, 1, 2]) == 6\n assert candidate(nums = [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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) == 48\n assert candidate(nums = [3, 5, 1, 4, 2]) == 4\n assert candidate(nums = [1, 50, 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]) == 48\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, 26]) == 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]) == 0\n assert candidate(nums = [5, 1, 2, 3, 4]) == 4\n assert candidate(nums = [45, 1, 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]) == 44\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == 9\n assert candidate(nums = [3, 2, 5, 4, 1, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [2, 3, 1, 5, 4]) == 3\n assert candidate(nums = [4, 3, 2, 1, 5]) == 3\n assert candidate(nums = [47, 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, 48, 49, 50, 1]) == 49\n assert candidate(nums = [3, 5, 1, 4, 2]) == 4\n assert candidate(nums = [1, 5, 3, 4, 2]) == 3\n assert candidate(nums = [4, 2, 3, 1, 5]) == 3\n assert candidate(nums = [10, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 17\n assert candidate(nums = [2, 1, 3, 5, 4, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [47, 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, 1]) == 91\n assert candidate(nums = [4, 3, 5, 1, 2]) == 4\n assert candidate(nums = [4, 5, 1, 2, 3]) == 4\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 7, 8, 9, 10]) == 5\n assert candidate(nums = [5, 1, 4, 3, 2]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().semiOrderedPermutation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int semiOrderedPermutation(int[] nums) {", "container": "Solution", "callable": "semiOrderedPermutation", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2718, "task_id": "sum-of-matrix-after-queries", "difficulty": "Medium", "problem_description": "You are given an integer n and a 0-indexed 2D array queries where queries[i] = [typei, indexi, vali].\nInitially, there is a 0-indexed n x n matrix filled with 0's. For each query, you must apply one of the following changes:\n\nif typei == 0, set the values in the row with indexi to vali, overwriting any previous values.\nif typei == 1, set the values in the column with indexi to vali, overwriting any previous values.\n\nReturn the sum of integers in the matrix after all queries are applied.\n \nExample 1:\n\n\nInput: n = 3, queries = [[0,0,1],[1,2,2],[0,2,3],[1,0,4]]\nOutput: 23\nExplanation: The image above describes the matrix after each query. The sum of the matrix after all queries are applied is 23. \n\nExample 2:\n\n\nInput: n = 3, queries = [[0,0,4],[0,1,2],[1,0,1],[0,2,3],[1,2,1]]\nOutput: 17\nExplanation: The image above describes the matrix after each query. The sum of the matrix after all queries are applied is 17.\n\n \nConstraints:\n\n1 <= n <= 104\n1 <= queries.length <= 5 * 104\nqueries[i].length == 3\n0 <= typei <= 1\n0 <= indexi < n\n0 <= vali <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,queries = [[0, 0, 1], [1, 0, 2], [0, 1, 3], [1, 1, 4]]) == 13\n assert candidate(n = 5,queries = [[0, 1, 10], [1, 2, 5], [0, 4, 7], [1, 0, 3]]) == 93\n assert candidate(n = 4,queries = [[1, 3, 2], [0, 1, 5], [1, 0, 3], [0, 2, 4]]) == 44\n assert candidate(n = 1,queries = [[0, 0, 10], [1, 0, 20]]) == 20\n assert candidate(n = 2,queries = [[0, 0, 1], [0, 1, 2], [1, 0, 3], [1, 1, 4]]) == 14\n assert candidate(n = 1,queries = [[0, 0, 100]]) == 100\n assert candidate(n = 3,queries = [[0, 0, 4], [0, 1, 2], [1, 0, 1], [0, 2, 3], [1, 2, 1]]) == 17\n assert candidate(n = 2,queries = [[1, 0, 5], [1, 1, 10], [0, 0, 15], [0, 1, 20]]) == 70\n assert candidate(n = 5,queries = [[1, 0, 10], [0, 2, 3], [1, 4, 5]]) == 77\n assert candidate(n = 3,queries = [[0, 0, 1], [1, 2, 2], [0, 2, 3], [1, 0, 4]]) == 23\n assert candidate(n = 4,queries = [[0, 1, 5], [1, 3, 2], [0, 3, 1]]) == 25\n assert candidate(n = 5,queries = [[0, 1, 5], [1, 3, 4], [0, 2, 6], [1, 0, 2], [0, 0, 3]]) == 74\n assert candidate(n = 10000,queries = [[0, 0, 1], [1, 0, 2], [0, 1, 3], [1, 1, 4], [0, 2, 5], [1, 2, 6], [0, 3, 7], [1, 3, 8], [0, 4, 9], [1, 4, 10]]) == 549905\n assert candidate(n = 5,queries = [[1, 0, 10], [0, 0, 5], [1, 1, 20], [0, 1, 10], [1, 2, 30], [0, 2, 15], [1, 3, 40], [0, 3, 20], [1, 4, 50], [0, 4, 25]]) == 675\n assert candidate(n = 10,queries = [[0, 0, 10], [1, 0, 20], [0, 1, 30], [1, 1, 40], [0, 2, 50], [1, 2, 60], [0, 3, 70], [1, 3, 80], [0, 4, 90], [1, 4, 100], [0, 5, 110], [1, 5, 120], [0, 6, 130], [1, 6, 140], [0, 7, 150], [1, 7, 160], [0, 8, 170], [1, 8, 180], [0, 9, 190], [1, 9, 200]]) == 13850\n assert candidate(n = 8,queries = [[0, 0, 1], [0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [0, 6, 7], [0, 7, 8], [1, 0, 9], [1, 1, 10], [1, 2, 11], [1, 3, 12], [1, 4, 13], [1, 5, 14], [1, 6, 15], [1, 7, 16]]) == 800\n assert candidate(n = 4,queries = [[0, 0, 5], [1, 1, 3], [0, 2, 2], [1, 3, 1], [0, 0, 4], [1, 2, 6]]) == 49\n assert candidate(n = 6,queries = [[0, 0, 1], [0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [1, 0, 1], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6]]) == 126\n assert candidate(n = 1000,queries = [[0, 0, 100000], [1, 0, 100000], [0, 1, 100000], [1, 1, 100000], [0, 2, 100000], [1, 2, 100000]]) == 599100000\n assert candidate(n = 5,queries = [[0, 0, 1], [1, 1, 2], [0, 2, 3], [1, 3, 4], [0, 4, 5]]) == 62\n assert candidate(n = 10,queries = [[0, 0, 1], [1, 1, 2], [0, 2, 3], [1, 3, 4], [0, 4, 5], [1, 5, 6], [0, 6, 7], [1, 7, 8], [0, 8, 9], [1, 9, 10]]) == 455\n assert candidate(n = 10,queries = [[0, 0, 1], [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], [1, 0, 10], [1, 1, 9], [1, 2, 8], [1, 3, 7], [1, 4, 6], [1, 5, 5], [1, 6, 4], [1, 7, 3], [1, 8, 2], [1, 9, 1]]) == 550\n assert candidate(n = 10,queries = [[0, 0, 100], [1, 1, 200], [0, 2, 300], [1, 3, 400], [0, 4, 500], [1, 0, 600], [0, 5, 700], [1, 2, 800], [0, 6, 900], [1, 3, 1000]]) == 43100\n assert candidate(n = 7,queries = [[0, 6, 1], [0, 5, 2], [0, 4, 3], [0, 3, 4], [0, 2, 5], [0, 1, 6], [0, 0, 7], [1, 0, 8], [1, 1, 9], [1, 2, 10], [1, 3, 11], [1, 4, 12], [1, 5, 13], [1, 6, 14]]) == 539\n assert candidate(n = 10,queries = [[0, 3, 7], [1, 4, 9], [0, 2, 5], [1, 1, 3], [0, 5, 6], [1, 8, 2], [0, 9, 8], [1, 0, 4]]) == 342\n assert candidate(n = 4,queries = [[0, 0, 5], [1, 0, 5], [0, 1, 10], [1, 1, 10], [0, 2, 15], [1, 2, 15], [0, 3, 20], [1, 3, 20]]) == 250\n assert candidate(n = 5,queries = [[0, 0, 10], [1, 1, 20], [0, 2, 30], [1, 3, 40], [0, 4, 50], [1, 0, 60], [0, 1, 70], [1, 2, 80], [0, 3, 90], [1, 4, 100]]) == 1800\n assert candidate(n = 5,queries = [[0, 0, 1], [1, 0, 2], [0, 1, 3], [1, 1, 4], [0, 2, 5], [1, 2, 6], [0, 3, 7], [1, 3, 8], [0, 4, 9], [1, 4, 10]]) == 180\n assert candidate(n = 8,queries = [[1, 0, 1], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [0, 0, 10], [0, 1, 20], [0, 2, 30], [0, 3, 40], [0, 4, 50], [0, 5, 60], [0, 6, 70], [0, 7, 80]]) == 2880\n assert candidate(n = 5,queries = [[0, 1, 3], [1, 2, 4], [0, 3, 5], [1, 4, 6], [0, 0, 7], [1, 0, 8], [0, 2, 9]]) == 152\n assert candidate(n = 4,queries = [[0, 0, 1], [1, 1, 2], [0, 2, 3], [1, 3, 4], [0, 1, 5], [1, 0, 6], [0, 3, 7], [1, 2, 8]]) == 94\n assert candidate(n = 8,queries = [[0, 0, 1], [1, 0, 2], [0, 1, 3], [1, 1, 4], [0, 2, 5], [1, 2, 6], [0, 3, 7], [1, 3, 8], [0, 4, 9], [1, 4, 10], [0, 5, 11], [1, 5, 12], [0, 6, 13], [1, 6, 14], [0, 7, 15], [1, 7, 16]]) == 716\n assert candidate(n = 8,queries = [[0, 0, 20], [1, 0, 21], [0, 1, 22], [1, 1, 23], [0, 2, 24], [1, 2, 25], [0, 3, 26], [1, 3, 27], [0, 4, 28], [1, 4, 29], [0, 5, 30], [1, 5, 31], [0, 6, 32], [1, 6, 33], [0, 7, 34], [1, 7, 35]]) == 1932\n assert candidate(n = 6,queries = [[0, 1, 100], [1, 3, 200], [0, 2, 50], [1, 1, 150], [0, 4, 250], [1, 0, 300]]) == 5100\n assert candidate(n = 4,queries = [[1, 0, 10], [0, 0, 20], [1, 1, 30], [0, 1, 40], [1, 2, 50], [0, 2, 60], [1, 3, 70], [0, 3, 80]]) == 940\n assert candidate(n = 4,queries = [[0, 1, 5], [1, 2, 8], [0, 3, 9], [1, 0, 4], [0, 2, 6], [1, 1, 7]]) == 97\n assert candidate(n = 3,queries = [[0, 0, 1], [1, 2, 2], [0, 2, 3], [1, 0, 4], [0, 1, 5], [1, 1, 6]]) == 41\n assert candidate(n = 3,queries = [[0, 0, 10], [1, 0, 20], [0, 1, 30], [1, 1, 40], [0, 2, 50], [1, 2, 60]]) == 410\n assert candidate(n = 5,queries = [[0, 0, 10], [1, 1, 5], [0, 2, 3], [1, 3, 7], [0, 4, 2], [1, 0, 8]]) == 120\n assert candidate(n = 8,queries = [[0, 7, 5], [1, 6, 4], [0, 5, 3], [1, 4, 2], [0, 3, 1], [1, 2, 6], [0, 1, 7], [1, 0, 8], [0, 6, 9], [1, 7, 10]]) == 335\n assert candidate(n = 7,queries = [[0, 6, 11], [1, 5, 12], [0, 4, 13], [1, 3, 14], [0, 2, 15], [1, 1, 16], [0, 0, 17], [1, 6, 18], [0, 5, 19], [1, 4, 20]]) == 740\n assert candidate(n = 10,queries = [[0, 9, 1], [1, 8, 2], [0, 7, 3], [1, 6, 4], [0, 5, 5], [1, 4, 6], [0, 3, 7], [1, 2, 8], [0, 1, 9], [1, 0, 10], [0, 8, 11], [1, 7, 12], [0, 6, 13], [1, 5, 14], [0, 4, 15], [1, 3, 16], [0, 2, 17], [1, 1, 18], [0, 0, 19], [1, 9, 20]]) == 1385\n assert candidate(n = 9,queries = [[0, 0, 2], [1, 0, 3], [0, 1, 4], [1, 1, 5], [0, 2, 6], [1, 2, 7], [0, 3, 8], [1, 3, 9], [0, 4, 10], [1, 4, 11], [0, 5, 12], [1, 5, 13], [0, 6, 14], [1, 6, 15], [0, 7, 16], [1, 7, 17], [0, 8, 18], [1, 8, 19]]) == 1095\n assert candidate(n = 5,queries = [[0, 0, 5], [1, 1, 3], [0, 2, 8], [1, 3, 2], [0, 4, 1], [1, 0, 4]]) == 75\n assert candidate(n = 6,queries = [[0, 2, 100], [1, 3, 200], [0, 0, 300], [1, 1, 400], [0, 4, 500], [1, 5, 600], [0, 5, 700], [1, 0, 800]]) == 16600\n assert candidate(n = 4,queries = [[0, 0, 1], [0, 0, 2], [0, 0, 3], [1, 0, 4], [1, 0, 5], [1, 0, 6], [0, 1, 7], [1, 1, 8], [0, 2, 9], [1, 2, 10], [0, 3, 11], [1, 3, 12]]) == 158\n assert candidate(n = 4,queries = [[0, 0, 5], [1, 1, 6], [0, 2, 7], [1, 3, 8], [0, 1, 9]]) == 103\n assert candidate(n = 5000,queries = [[0, 0, 1], [1, 1, 2], [0, 2, 3], [1, 3, 4], [0, 4, 5], [1, 0, 6], [0, 3, 7], [1, 2, 8], [0, 1, 9], [1, 4, 10]]) == 274905\n assert candidate(n = 6,queries = [[0, 0, 1], [1, 5, 2], [0, 4, 3], [1, 3, 4], [0, 2, 5], [1, 1, 6], [0, 1, 7], [1, 0, 8]]) == 166\n assert candidate(n = 3,queries = [[1, 0, 1], [0, 0, 2], [1, 1, 3], [0, 1, 4], [1, 2, 5], [0, 2, 6]]) == 41\n assert candidate(n = 4,queries = [[0, 0, 5], [1, 1, 10], [0, 2, 20], [1, 3, 30], [0, 1, 50], [1, 0, 60]]) == 545\n assert candidate(n = 3,queries = [[0, 0, 5], [0, 1, 5], [0, 2, 5], [1, 0, 5], [1, 1, 5], [1, 2, 5]]) == 45\n assert candidate(n = 7,queries = [[0, 6, 70], [1, 5, 60], [0, 4, 50], [1, 3, 40], [0, 2, 30], [1, 1, 20], [0, 0, 10], [1, 0, 0], [0, 1, 1], [1, 2, 2], [0, 3, 3], [1, 4, 4], [0, 5, 5], [1, 6, 6]]) == 465\n assert candidate(n = 5,queries = [[0, 0, 1], [0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [1, 0, 6], [1, 1, 7], [1, 2, 8], [1, 3, 9], [1, 4, 10], [0, 0, 11], [0, 1, 12], [0, 2, 13], [0, 3, 14], [0, 4, 15], [1, 0, 16], [1, 1, 17], [1, 2, 18], [1, 3, 19], [1, 4, 20]]) == 450\n assert candidate(n = 10,queries = [[1, 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]]) == 550\n assert candidate(n = 1000,queries = [[0, 500, 1], [1, 500, 2], [0, 499, 3], [1, 499, 4], [0, 498, 5], [1, 498, 6], [0, 497, 7], [1, 497, 8], [0, 496, 9], [1, 496, 10]]) == 54905\n assert candidate(n = 5000,queries = [[0, 2500, 1], [1, 2500, 2], [0, 2499, 3], [1, 2499, 4], [0, 2498, 5], [1, 2498, 6], [0, 2497, 7], [1, 2497, 8], [0, 2496, 9], [1, 2496, 10]]) == 274905\n assert candidate(n = 1000,queries = [[0, 500, 5], [1, 250, 10], [0, 750, 20], [1, 0, 30], [0, 999, 50], [1, 500, 60]]) == 174845\n assert candidate(n = 3,queries = [[0, 0, 10], [1, 0, 20], [0, 1, 30], [1, 1, 40], [0, 2, 50], [1, 2, 60], [0, 0, 70], [1, 0, 80]]) == 590\n assert candidate(n = 5,queries = [[0, 0, 1], [0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [1, 0, 6], [1, 1, 7], [1, 2, 8], [1, 3, 9], [1, 4, 10]]) == 200\n assert candidate(n = 4,queries = [[0, 0, 10], [1, 2, 5], [0, 3, 3], [1, 1, 7], [0, 2, 8], [1, 3, 2]]) == 79\n assert candidate(n = 100,queries = [[0, 50, 10], [1, 50, 20], [0, 25, 15], [1, 75, 25], [0, 75, 30], [1, 25, 35], [0, 0, 5], [1, 99, 50]]) == 18705\n assert candidate(n = 3,queries = [[0, 0, 1], [1, 2, 2], [0, 2, 3], [1, 0, 4], [0, 1, 5], [1, 1, 6], [0, 0, 7], [1, 2, 8]]) == 59\n assert candidate(n = 10,queries = [[0, 5, 9], [1, 4, 8], [0, 9, 7], [1, 3, 6], [0, 2, 5], [1, 1, 4], [0, 0, 3], [1, 8, 2], [0, 7, 1], [1, 6, 0]]) == 295\n assert candidate(n = 10,queries = [[0, 0, 10], [1, 0, 10], [0, 1, 20], [1, 1, 20], [0, 2, 30], [1, 2, 30], [0, 3, 40], [1, 3, 40], [0, 4, 50], [1, 4, 50], [0, 5, 60], [1, 5, 60], [0, 6, 70], [1, 6, 70], [0, 7, 80], [1, 7, 80], [0, 8, 90], [1, 8, 90], [0, 9, 100], [1, 9, 100]]) == 7150\n assert candidate(n = 5,queries = [[0, 0, 1], [0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [1, 0, 1], [1, 1, 1], [1, 2, 1], [1, 3, 1], [1, 4, 1]]) == 25\n assert candidate(n = 7,queries = [[0, 0, 1], [1, 1, 2], [0, 2, 3], [1, 3, 4], [0, 4, 5], [1, 5, 6], [0, 6, 7], [1, 6, 8], [0, 5, 9], [1, 4, 10]]) == 290\n assert candidate(n = 6,queries = [[0, 0, 1], [0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [1, 0, 6], [1, 1, 5], [1, 2, 4], [1, 3, 3], [1, 4, 2], [1, 5, 1]]) == 126\n assert candidate(n = 6,queries = [[0, 5, 50], [1, 4, 40], [0, 3, 30], [1, 2, 20], [0, 1, 10], [1, 0, 0], [0, 4, 400], [1, 5, 500], [0, 2, 200], [1, 3, 300]]) == 7180\n assert candidate(n = 5,queries = [[0, 0, 10], [1, 1, 20], [0, 2, 30], [1, 3, 40], [0, 4, 50]]) == 620\n assert candidate(n = 5,queries = [[1, 0, 1], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [0, 0, 1], [0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5]]) == 75\n assert candidate(n = 7,queries = [[0, 0, 1], [0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [1, 0, 1], [1, 1, 1], [1, 2, 1], [1, 3, 1], [1, 4, 1], [1, 5, 1], [1, 6, 1]]) == 49\n assert candidate(n = 10,queries = [[0, 9, 100], [1, 8, 90], [0, 7, 80], [1, 6, 70], [0, 5, 60], [1, 4, 50], [0, 3, 40], [1, 2, 30], [0, 1, 20], [1, 0, 10]]) == 3700\n assert candidate(n = 1000,queries = [[0, 500, 1], [1, 500, 2], [0, 499, 3], [1, 499, 4], [0, 501, 5], [1, 501, 6], [0, 0, 10], [1, 999, 20]]) == 50947\n assert candidate(n = 7,queries = [[0, 0, 1], [1, 0, 2], [0, 1, 3], [1, 1, 4], [0, 2, 5], [1, 2, 6], [0, 3, 7], [1, 3, 8], [0, 4, 9], [1, 4, 10], [0, 5, 11], [1, 5, 12], [0, 6, 13], [1, 6, 14]]) == 483\n assert candidate(n = 4,queries = [[0, 0, 5], [1, 1, 10], [0, 2, 15], [1, 3, 20], [0, 3, 25]]) == 235\n assert candidate(n = 10,queries = [[0, 0, 1], [0, 1, 2], [1, 0, 3], [1, 1, 4], [0, 2, 5], [1, 2, 6], [0, 3, 7], [1, 3, 8], [0, 4, 9], [1, 4, 10]]) == 456\n assert candidate(n = 6,queries = [[0, 0, 1], [1, 1, 1], [0, 2, 1], [1, 3, 1], [0, 4, 1], [1, 5, 1], [0, 5, 1], [1, 0, 1], [0, 1, 1], [1, 2, 1], [0, 3, 1], [1, 4, 1]]) == 36\n assert candidate(n = 10,queries = [[0, 0, 10], [1, 1, 20], [0, 2, 30], [1, 3, 40], [0, 4, 50], [1, 5, 60], [0, 6, 70], [1, 7, 80], [0, 8, 90], [1, 9, 100]]) == 4550\n assert candidate(n = 9,queries = [[0, 0, 1], [1, 8, 9], [0, 1, 2], [1, 7, 8], [0, 2, 3], [1, 6, 7], [0, 3, 4], [1, 5, 6], [0, 4, 5]]) == 305\n assert candidate(n = 7,queries = [[0, 0, 1], [1, 1, 2], [0, 2, 3], [1, 3, 4], [0, 4, 5], [1, 5, 6], [0, 6, 7], [1, 0, 8], [0, 1, 9], [1, 2, 10], [0, 3, 11], [1, 4, 12], [0, 5, 13], [1, 6, 14], [0, 0, 15], [1, 1, 16], [0, 2, 17], [1, 3, 18], [0, 4, 19], [1, 5, 20], [0, 6, 21], [1, 0, 22]]) == 875\n assert candidate(n = 3,queries = [[0, 0, 1], [1, 0, 2], [0, 0, 3], [1, 0, 4], [0, 0, 5], [1, 0, 6], [0, 0, 7], [1, 0, 8]]) == 38\n assert candidate(n = 4,queries = [[0, 2, 5], [1, 1, 3], [0, 0, 2], [1, 2, 8], [0, 3, 1]]) == 50\n assert candidate(n = 5,queries = [[0, 0, 1], [0, 0, 2], [0, 0, 3], [0, 0, 4], [0, 0, 5], [1, 0, 1], [1, 0, 2], [1, 0, 3], [1, 0, 4], [1, 0, 5]]) == 45\n assert candidate(n = 6,queries = [[0, 0, 1], [0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [1, 0, 10], [1, 1, 20], [1, 2, 30], [1, 3, 40], [1, 4, 50], [1, 5, 60]]) == 1260\n assert candidate(n = 10,queries = [[0, 0, 1], [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]]) == 550\n assert candidate(n = 3,queries = [[0, 0, 1], [1, 0, 2], [0, 1, 3], [1, 1, 4], [0, 2, 5], [1, 2, 6], [0, 0, 7], [1, 0, 8], [0, 1, 9], [1, 1, 10]]) == 77\n assert candidate(n = 3,queries = [[0, 0, 100], [0, 0, 200], [0, 0, 300], [1, 1, 100], [1, 1, 200], [1, 1, 300], [0, 1, 100], [0, 2, 200], [1, 0, 300], [1, 2, 400]]) == 2700\n assert candidate(n = 5000,queries = [[0, 2500, 5], [1, 1250, 10], [0, 3750, 20], [1, 0, 30], [0, 4999, 50], [1, 2500, 60]]) == 874845\n assert candidate(n = 4,queries = [[0, 0, 5], [1, 1, 2], [0, 2, 3], [1, 3, 4], [0, 3, 1], [1, 0, 6]]) == 54\n assert candidate(n = 500,queries = [[0, 0, 100], [1, 0, 200], [0, 100, 150], [1, 200, 250], [0, 300, 300], [1, 400, 400], [0, 1, 10], [1, 2, 20], [0, 3, 30], [1, 4, 40]]) == 745580\n"}, "metadata": {"canonical_parameter_names": ["n", "queries"], "leetcode_dataset_entry_point": "Solution().matrixSumQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long matrixSumQueries(int n, int[][] queries) {", "container": "Solution", "callable": "matrixSumQueries", "parameters": [{"name": "n", "type": "int"}, {"name": "queries", "type": "int[][]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2719, "task_id": "count-of-integers", "difficulty": "Hard", "problem_description": "You are given two numeric strings num1 and num2 and two integers max_sum and min_sum. We denote an integer x to be good if:\n\nnum1 <= x <= num2\nmin_sum <= digit_sum(x) <= max_sum.\n\nReturn the number of good integers. Since the answer may be large, return it modulo 109 + 7.\nNote that digit_sum(x) denotes the sum of the digits of x.\n \nExample 1:\n\nInput: num1 = \"1\", num2 = \"12\", min_sum = 1, max_sum = 8\nOutput: 11\nExplanation: There are 11 integers whose sum of digits lies between 1 and 8 are 1,2,3,4,5,6,7,8,10,11, and 12. Thus, we return 11.\n\nExample 2:\n\nInput: num1 = \"1\", num2 = \"5\", min_sum = 1, max_sum = 5\nOutput: 5\nExplanation: The 5 integers whose sum of digits lies between 1 and 5 are 1,2,3,4, and 5. Thus, we return 5.\n\n \nConstraints:\n\n1 <= num1 <= num2 <= 1022\n1 <= min_sum <= max_sum <= 400\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num1 = \"1\",num2 = \"5\",min_sum = 1,max_sum = 5) == 5\n assert candidate(num1 = \"1\",num2 = \"1000000000000000000000000000000\",min_sum = 300,max_sum = 400) == 0\n assert candidate(num1 = \"999999999999999999999999999999\",num2 = \"1000000000000000000000000000000\",min_sum = 1,max_sum = 400) == 2\n assert candidate(num1 = \"123456789012345678901234567890\",num2 = \"987654321098765432109876543210\",min_sum = 100,max_sum = 200) == 559200081\n assert candidate(num1 = \"1\",num2 = \"1000000000000000000000000000000\",min_sum = 1,max_sum = 1) == 31\n assert candidate(num1 = \"10\",num2 = \"100\",min_sum = 2,max_sum = 10) == 53\n assert candidate(num1 = \"999999999999999999999999999999\",num2 = \"999999999999999999999999999999\",min_sum = 81,max_sum = 81) == 0\n assert candidate(num1 = \"1000\",num2 = \"2000\",min_sum = 10,max_sum = 20) == 715\n assert candidate(num1 = \"50\",num2 = \"150\",min_sum = 5,max_sum = 20) == 91\n assert candidate(num1 = \"1000\",num2 = \"2000\",min_sum = 10,max_sum = 30) == 835\n assert candidate(num1 = \"50\",num2 = \"150\",min_sum = 5,max_sum = 15) == 85\n assert candidate(num1 = \"1\",num2 = \"12\",min_sum = 1,max_sum = 8) == 11\n assert candidate(num1 = \"999999999999999999999999999999\",num2 = \"1000000000000000000000000000000\",min_sum = 100,max_sum = 200) == 0\n assert candidate(num1 = \"11111111111111111111111111111\",num2 = \"22222222222222222222222222222\",min_sum = 30,max_sum = 60) == 182368529\n assert candidate(num1 = \"1000000000000000000000000000000\",num2 = \"999999999999999999999999999999\",min_sum = 1,max_sum = 400) == 0\n assert candidate(num1 = \"500000000000000000000000000000\",num2 = \"500000000000000000000000000001\",min_sum = 50,max_sum = 50) == 0\n assert candidate(num1 = \"100000000000000000000000000000\",num2 = \"200000000000000000000000000000\",min_sum = 150,max_sum = 250) == 752538386\n assert candidate(num1 = \"1\",num2 = \"100000000000000000000000000000\",min_sum = 1,max_sum = 100) == 663692512\n assert candidate(num1 = \"1000000000000000000000000000000000000000\",num2 = \"1000000000000000000000000000000000000010\",min_sum = 1,max_sum = 10) == 11\n assert candidate(num1 = \"1\",num2 = \"1000000000000000000000000000000\",min_sum = 1,max_sum = 200) == 48265017\n assert candidate(num1 = \"1010101010101010101010101010101\",num2 = \"9090909090909090909090909090909\",min_sum = 50,max_sum = 150) == 762258132\n assert candidate(num1 = \"111111111111111111111111111110\",num2 = \"111111111111111111111111111119\",min_sum = 5,max_sum = 50) == 10\n assert candidate(num1 = \"555555555555555555555555555555\",num2 = \"666666666666666666666666666666\",min_sum = 120,max_sum = 130) == 562403818\n assert candidate(num1 = \"100000000000000000000000000000\",num2 = \"200000000000000000000000000000\",min_sum = 10,max_sum = 20) == 81870141\n assert candidate(num1 = \"200000000000000000000000000000\",num2 = \"200000000000000000000000000005\",min_sum = 5,max_sum = 15) == 3\n assert candidate(num1 = \"1234567890\",num2 = \"9876543210\",min_sum = 1,max_sum = 99) == 641975265\n assert candidate(num1 = \"1000000000\",num2 = \"10000000000000000000\",min_sum = 1,max_sum = 400) == 498\n assert candidate(num1 = \"999999999999999999999999999990\",num2 = \"999999999999999999999999999999\",min_sum = 81,max_sum = 89) == 0\n assert candidate(num1 = \"2000000000000000000000000000000\",num2 = \"2999999999999999999999999999999\",min_sum = 100,max_sum = 200) == 648249887\n assert candidate(num1 = \"1000000000000000000000000000000\",num2 = \"1000000000000000000000000000001\",min_sum = 1,max_sum = 1) == 1\n assert candidate(num1 = \"1000000000000000000000000000000000000000\",num2 = \"2000000000000000000000000000000000000000\",min_sum = 100,max_sum = 200) == 416584880\n assert candidate(num1 = \"100000000000000000000000000000000000000000000000000000000000\",num2 = \"100000000000000000000000000000000000000000000000000000000001\",min_sum = 1,max_sum = 1) == 1\n assert candidate(num1 = \"123456789012345678901234567890\",num2 = \"987654321098765432109876543210\",min_sum = 180,max_sum = 220) == 514957697\n assert candidate(num1 = \"1234567890123456789012345678901\",num2 = \"9876543210987654321098765432109\",min_sum = 100,max_sum = 300) == 216561067\n assert candidate(num1 = \"111111111111111111111111111111\",num2 = \"999999999999999999999999999999\",min_sum = 200,max_sum = 300) == 838989111\n assert candidate(num1 = \"500000000000000000000000000000\",num2 = \"600000000000000000000000000000\",min_sum = 150,max_sum = 250) == 690064938\n assert candidate(num1 = \"99999999999999999999999999999\",num2 = \"999999999999999999999999999999\",min_sum = 250,max_sum = 350) == 470298279\n assert candidate(num1 = \"500000000000000000000000000000\",num2 = \"500000000000000000000000000001\",min_sum = 100,max_sum = 100) == 0\n assert candidate(num1 = \"11111111111111111111\",num2 = \"22222222222222222222\",min_sum = 20,max_sum = 30) == 14575096\n assert candidate(num1 = \"555555555555555555555555555555\",num2 = \"555555555555555555555555555560\",min_sum = 150,max_sum = 250) == 5\n assert candidate(num1 = \"999999999999999999999999999999\",num2 = \"1000000000000000000000000000000\",min_sum = 200,max_sum = 300) == 1\n assert candidate(num1 = \"123456789012345678901234567890\",num2 = \"123456789012345678901234567890\",min_sum = 45,max_sum = 45) == 0\n assert candidate(num1 = \"111111111111111111111111111111\",num2 = \"888888888888888888888888888888\",min_sum = 200,max_sum = 300) == 785167291\n assert candidate(num1 = \"1234567890123456789012345678901234567890\",num2 = \"9876543210987654321098765432109876543210\",min_sum = 150,max_sum = 250) == 254920565\n assert candidate(num1 = \"3000000000000000000000000000000\",num2 = \"3100000000000000000000000000000\",min_sum = 30,max_sum = 60) == 62608771\n assert candidate(num1 = \"111111111111111111111111111111\",num2 = \"222222222222222222222222222222\",min_sum = 36,max_sum = 72) == 886258813\n assert candidate(num1 = \"900000000000000000000000000000\",num2 = \"9000000000000000000000000000001\",min_sum = 18,max_sum = 18) == 792480562\n assert candidate(num1 = \"9999999999999999999999999999999999999999\",num2 = \"9999999999999999999999999999999999999999\",min_sum = 180,max_sum = 200) == 0\n assert candidate(num1 = \"123456789\",num2 = \"987654321\",min_sum = 10,max_sum = 50) == 748923377\n assert candidate(num1 = \"500000000000000000000000000000\",num2 = \"500000000000000000000000000001\",min_sum = 25,max_sum = 50) == 0\n assert candidate(num1 = \"999999999999999999999999999999\",num2 = \"1000000000000000000000000000000\",min_sum = 1,max_sum = 9) == 1\n assert candidate(num1 = \"100000000000000000000000000000\",num2 = \"999999999999999999999999999999\",min_sum = 1,max_sum = 400) == 999691307\n assert candidate(num1 = \"500000000000000000000000000000\",num2 = \"599999999999999999999999999999\",min_sum = 200,max_sum = 250) == 121684856\n assert candidate(num1 = \"1000000000000000000000000000000\",num2 = \"1000000000000000000000000000001\",min_sum = 1,max_sum = 9) == 2\n assert candidate(num1 = \"500000000000000000000000000000\",num2 = \"600000000000000000000000000000\",min_sum = 100,max_sum = 120) == 792681732\n assert candidate(num1 = \"50000000000000000000\",num2 = \"50000000000000000005\",min_sum = 25,max_sum = 35) == 0\n assert candidate(num1 = \"100000000000000000000000000000\",num2 = \"110000000000000000000000000000\",min_sum = 1,max_sum = 10) == 124403621\n assert candidate(num1 = \"999999999999999999999999999999\",num2 = \"1000000000000000000000000000000\",min_sum = 81,max_sum = 81) == 0\n assert candidate(num1 = \"99999999999999999999\",num2 = \"100000000000000000000\",min_sum = 90,max_sum = 100) == 0\n assert candidate(num1 = \"111111111111111111111111111111\",num2 = \"222222222222222222222222222222\",min_sum = 10,max_sum = 20) == 605921476\n assert candidate(num1 = \"100000000000000000000000000000\",num2 = \"100000000000000000000000000010\",min_sum = 1,max_sum = 10) == 11\n assert candidate(num1 = \"123456789012345678901234567890123456789012345678901234567890\",num2 = \"987654321098765432109876543210987654321098765432109876543210\",min_sum = 150,max_sum = 250) == 623296612\n assert candidate(num1 = \"999999999999999999999999999990\",num2 = \"999999999999999999999999999999\",min_sum = 270,max_sum = 280) == 1\n assert candidate(num1 = \"123456789012345678901234567890\",num2 = \"123456789012345678901234567891\",min_sum = 1,max_sum = 400) == 2\n assert candidate(num1 = \"100000000000000000000000000000\",num2 = \"200000000000000000000000000000\",min_sum = 1,max_sum = 1) == 1\n assert candidate(num1 = \"100000000000000000000000000001\",num2 = \"100000000000000000000000000010\",min_sum = 1,max_sum = 10) == 10\n assert candidate(num1 = \"111111111111111111111111111111\",num2 = \"222222222222222222222222222222\",min_sum = 33,max_sum = 66) == 780304934\n assert candidate(num1 = \"999999999999999999999999999999\",num2 = \"1000000000000000000000000000000\",min_sum = 150,max_sum = 250) == 0\n assert candidate(num1 = \"222222222222222222222222222222\",num2 = \"333333333333333333333333333333\",min_sum = 44,max_sum = 66) == 688650163\n assert candidate(num1 = \"999999999999999999999999999999\",num2 = \"1000000000000000000000000000000\",min_sum = 270,max_sum = 271) == 1\n assert candidate(num1 = \"100000000000000000000000000000\",num2 = \"200000000000000000000000000000\",min_sum = 50,max_sum = 150) == 113411552\n assert candidate(num1 = \"1111111111111111111111111111111111111111\",num2 = \"1111111111111111111111111111111111111111\",min_sum = 36,max_sum = 36) == 0\n assert candidate(num1 = \"111111111111111111111111111111\",num2 = \"222222222222222222222222222222\",min_sum = 50,max_sum = 150) == 531163588\n assert candidate(num1 = \"987654321098765432109876543210\",num2 = \"987654321098765432109876543211\",min_sum = 1,max_sum = 400) == 2\n assert candidate(num1 = \"111111111111111111111111111111\",num2 = \"222222222222222222222222222222\",min_sum = 15,max_sum = 30) == 312163769\n assert candidate(num1 = \"123456789\",num2 = \"987654321\",min_sum = 50,max_sum = 150) == 138991812\n assert candidate(num1 = \"123456789012345678901234567891\",num2 = \"987654321098765432109876543211\",min_sum = 150,max_sum = 250) == 442169096\n assert candidate(num1 = \"1\",num2 = \"1000000000000000000000000000000000000000\",min_sum = 1,max_sum = 400) == 2401000\n assert candidate(num1 = \"900000000000000000000000000000\",num2 = \"900000000000000000000000000010\",min_sum = 100,max_sum = 150) == 0\n assert candidate(num1 = \"123456789012345678901234567890\",num2 = \"234567890123456789012345678901\",min_sum = 50,max_sum = 100) == 518837468\n assert candidate(num1 = \"1000000000000000000000000000000\",num2 = \"1000000000000000000000000000000\",min_sum = 1,max_sum = 99) == 1\n assert candidate(num1 = \"123456789012345678901234567890\",num2 = \"123456789012345678901234567891\",min_sum = 45,max_sum = 45) == 0\n assert candidate(num1 = \"111111111111111111111111111111\",num2 = \"222222222222222222222222222222\",min_sum = 150,max_sum = 160) == 662198333\n assert candidate(num1 = \"888888888888888888888888888888\",num2 = \"999999999999999999999999999999\",min_sum = 250,max_sum = 260) == 162413701\n assert candidate(num1 = \"100000000000000000000000000000\",num2 = \"100000000000000000000000000001\",min_sum = 1,max_sum = 1) == 1\n"}, "metadata": {"canonical_parameter_names": ["num1", "num2", "min_sum", "max_sum"], "leetcode_dataset_entry_point": "Solution().count", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int count(String num1, String num2, int min_sum, int max_sum) {", "container": "Solution", "callable": "count", "parameters": [{"name": "num1", "type": "String"}, {"name": "num2", "type": "String"}, {"name": "min_sum", "type": "int"}, {"name": "max_sum", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2729, "task_id": "check-if-the-number-is-fascinating", "difficulty": "Easy", "problem_description": "You are given an integer n that consists of exactly 3 digits.\nWe call the number n fascinating if, after the following modification, the resulting number contains all the digits from 1 to 9 exactly once and does not contain any 0's:\n\nConcatenate n with the numbers 2 * n and 3 * n.\n\nReturn true if n is fascinating, or false otherwise.\nConcatenating two numbers means joining them together. For example, the concatenation of 121 and 371 is 121371.\n \nExample 1:\n\nInput: n = 192\nOutput: true\nExplanation: We concatenate the numbers n = 192 and 2 * n = 384 and 3 * n = 576. The resulting number is 192384576. This number contains all the digits from 1 to 9 exactly once.\n\nExample 2:\n\nInput: n = 100\nOutput: false\nExplanation: We concatenate the numbers n = 100 and 2 * n = 200 and 3 * n = 300. The resulting number is 100200300. This number does not satisfy any of the conditions.\n\n \nConstraints:\n\n100 <= n <= 999\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 933) == False\n assert candidate(n = 147) == False\n assert candidate(n = 576) == False\n assert candidate(n = 789) == False\n assert candidate(n = 579) == False\n assert candidate(n = 273) == True\n assert candidate(n = 327) == True\n assert candidate(n = 192) == True\n assert candidate(n = 369) == False\n assert candidate(n = 258) == False\n assert candidate(n = 932) == False\n assert candidate(n = 100) == False\n assert candidate(n = 819) == False\n assert candidate(n = 735) == False\n assert candidate(n = 342) == False\n assert candidate(n = 269) == False\n assert candidate(n = 135) == False\n assert candidate(n = 729) == False\n assert candidate(n = 639) == False\n assert candidate(n = 657) == False\n assert candidate(n = 846) == False\n assert candidate(n = 964) == False\n assert candidate(n = 402) == False\n assert candidate(n = 123) == False\n assert candidate(n = 396) == False\n assert candidate(n = 300) == False\n assert candidate(n = 854) == False\n assert candidate(n = 852) == False\n assert candidate(n = 439) == False\n assert candidate(n = 673) == False\n assert candidate(n = 384) == False\n assert candidate(n = 621) == False\n assert candidate(n = 270) == False\n assert candidate(n = 471) == False\n assert candidate(n = 741) == False\n assert candidate(n = 594) == False\n assert candidate(n = 783) == False\n assert candidate(n = 186) == False\n assert candidate(n = 654) == False\n assert candidate(n = 873) == False\n assert candidate(n = 297) == False\n assert candidate(n = 927) == False\n assert candidate(n = 725) == False\n assert candidate(n = 999) == False\n assert candidate(n = 294) == False\n assert candidate(n = 519) == False\n assert candidate(n = 518) == False\n assert candidate(n = 140) == False\n assert candidate(n = 513) == False\n assert candidate(n = 504) == False\n assert candidate(n = 693) == False\n assert candidate(n = 843) == False\n assert candidate(n = 918) == False\n assert candidate(n = 534) == False\n assert candidate(n = 624) == False\n assert candidate(n = 183) == False\n assert candidate(n = 753) == False\n assert candidate(n = 486) == False\n assert candidate(n = 243) == False\n assert candidate(n = 924) == False\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().isFascinating", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isFascinating(int n) {", "container": "Solution", "callable": "isFascinating", "parameters": [{"name": "n", "type": "int"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2730, "task_id": "find-the-longest-semi-repetitive-substring", "difficulty": "Medium", "problem_description": "You are given a digit string s that consists of digits from 0 to 9.\nA string is called semi-repetitive if there is at most one adjacent pair of the same digit. For example, \"0010\", \"002020\", \"0123\", \"2002\", and \"54944\" are semi-repetitive while the following are not: \"00101022\" (adjacent same digit pairs are 00 and 22), and \"1101234883\" (adjacent same digit pairs are 11 and 88).\nReturn the length of the longest semi-repetitive substring of s.\n \nExample 1:\n\nInput: s = \"52233\"\nOutput: 4\nExplanation:\nThe longest semi-repetitive substring is \"5223\". Picking the whole string \"52233\" has two adjacent same digit pairs 22 and 33, but at most one is allowed.\n\nExample 2:\n\nInput: s = \"5494\"\nOutput: 4\nExplanation:\ns is a semi-repetitive string.\n\nExample 3:\n\nInput: s = \"1111111\"\nOutput: 2\nExplanation:\nThe longest semi-repetitive substring is \"11\". Picking the substring \"111\" has two adjacent same digit pairs, but at most one is allowed.\n\n \nConstraints:\n\n1 <= s.length <= 50\n'0' <= s[i] <= '9'\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 2\n assert candidate(s = \"9876543210\") == 10\n assert candidate(s = \"111222333\") == 3\n assert candidate(s = \"88888888888\") == 2\n assert candidate(s = \"87878787878787878\") == 17\n assert candidate(s = \"101010101\") == 9\n assert candidate(s = \"10101010101\") == 11\n assert candidate(s = \"0101010\") == 7\n assert candidate(s = \"54944\") == 5\n assert candidate(s = \"122112211\") == 4\n assert candidate(s = \"22222\") == 2\n assert candidate(s = \"1234567890\") == 10\n assert candidate(s = \"0000000\") == 2\n assert candidate(s = \"1001001\") == 5\n assert candidate(s = \"1122334455\") == 4\n assert candidate(s = \"656565656565656\") == 15\n assert candidate(s = \"002020\") == 6\n assert candidate(s = \"0\") == 1\n assert candidate(s = \"52233\") == 4\n assert candidate(s = \"989898989898989898\") == 18\n assert candidate(s = \"4343434343434\") == 13\n assert candidate(s = \"1111111\") == 2\n assert candidate(s = \"323232323232\") == 12\n assert candidate(s = \"0123\") == 4\n assert candidate(s = \"999999999999\") == 2\n assert candidate(s = \"2002\") == 4\n assert candidate(s = \"0010\") == 4\n assert candidate(s = \"666666666\") == 2\n assert candidate(s = \"22\") == 2\n assert candidate(s = \"1010101010\") == 10\n assert candidate(s = \"1221221221\") == 6\n assert candidate(s = \"101010\") == 6\n assert candidate(s = \"9999999999\") == 2\n assert candidate(s = \"0101010101\") == 10\n assert candidate(s = \"333333\") == 2\n assert candidate(s = \"4444444\") == 2\n assert candidate(s = \"55555555\") == 2\n assert candidate(s = \"5494\") == 4\n assert candidate(s = \"1101234883\") == 9\n assert candidate(s = \"7676767676767676\") == 16\n assert candidate(s = \"123212321\") == 9\n assert candidate(s = \"00000\") == 2\n assert candidate(s = \"7777777777\") == 2\n assert candidate(s = \"1221221\") == 5\n assert candidate(s = \"21212121212\") == 11\n assert candidate(s = \"54545454545454\") == 14\n assert candidate(s = \"121212\") == 6\n assert candidate(s = \"9999999999111111111122222222223333333333\") == 3\n assert candidate(s = \"12121212121212121212\") == 20\n assert candidate(s = \"112233445566778899001122334455667788990011\") == 4\n assert candidate(s = \"0011223344556677889900\") == 4\n assert candidate(s = \"12321321321321321321321321321321\") == 32\n assert candidate(s = \"1233211233211233211233211233\") == 6\n assert candidate(s = \"123123123123123123123123123\") == 27\n assert candidate(s = \"123345567890\") == 9\n assert candidate(s = \"12211221122\") == 4\n assert candidate(s = \"55443322110011223344556677889900112233\") == 4\n assert candidate(s = \"5544332211009988776655\") == 4\n assert candidate(s = \"1232123212321232123212321\") == 25\n assert candidate(s = \"12345678901234567890123456789012345678901234567890\") == 50\n assert candidate(s = \"990099009900990099009900990099\") == 4\n assert candidate(s = \"123123123123123123123123123123123123123123123\") == 45\n assert candidate(s = \"12345543211234554321\") == 10\n assert candidate(s = \"000000000000000000000000000000\") == 2\n assert candidate(s = \"9876543210000000000098765432\") == 11\n assert candidate(s = \"98765432101234567890\") == 20\n assert candidate(s = \"12345678900000000000000000000000000000000000\") == 11\n assert candidate(s = \"1123456789009876543211\") == 20\n assert candidate(s = \"123455567890123456789\") == 16\n assert candidate(s = \"1122334455667788990011223344\") == 4\n assert candidate(s = \"987654321098765432109\") == 21\n assert candidate(s = \"987654321012345678909876543210\") == 30\n assert candidate(s = \"9876543210123456789876543210\") == 28\n assert candidate(s = \"123456789012345678901\") == 21\n assert candidate(s = \"101010101010101010101\") == 21\n assert candidate(s = \"12233445566778899123456789\") == 12\n assert candidate(s = \"1223344556677889900\") == 4\n assert candidate(s = \"1234567890987654321012345678909876543210\") == 40\n assert candidate(s = \"111111111111111111112\") == 3\n assert candidate(s = \"101010101010101010101010101010\") == 30\n assert candidate(s = \"112221122211222112221122211222\") == 4\n assert candidate(s = \"888877776666555544443333222211110000\") == 3\n assert candidate(s = \"1234555432123456789987654321\") == 22\n assert candidate(s = \"987654321000000000000000000000000000\") == 11\n assert candidate(s = \"9876543210000000000\") == 11\n assert candidate(s = \"98989898989898989898989898989898989898989898\") == 44\n assert candidate(s = \"11223344556677889900112233\") == 4\n assert candidate(s = \"12312312312312312312\") == 20\n assert candidate(s = \"000000000000000000000\") == 2\n assert candidate(s = \"98765432109876543210987654321098765432109876\") == 44\n assert candidate(s = \"99887766554433221100112233445566778899\") == 4\n assert candidate(s = \"987654321123456788765432112345678\") == 17\n assert candidate(s = \"0101010101010101010101010101010101\") == 34\n assert candidate(s = \"12345554321112345678998765432100\") == 19\n assert candidate(s = \"1123456789012345678901234567890\") == 31\n assert candidate(s = \"000000000011111111112222222222\") == 3\n assert candidate(s = \"121212121212121212121212121212121212\") == 36\n assert candidate(s = \"1234567890123456789012345678901234567890\") == 40\n assert candidate(s = \"543210102030405060708090090807060504030201\") == 42\n assert candidate(s = \"1001001001001001001001001001001\") == 6\n assert candidate(s = \"0000000000000000000000000000000000000000\") == 2\n assert candidate(s = \"123123123123123123123123123123\") == 30\n assert candidate(s = \"012345678987654321012345678987654321\") == 36\n assert candidate(s = \"01234567890123456789\") == 20\n assert candidate(s = \"9876543210012345678998765432100123456789\") == 20\n assert candidate(s = \"99999999999999999999\") == 2\n assert candidate(s = \"012345678901234567890123456789\") == 30\n assert candidate(s = \"11221122112211221122\") == 4\n assert candidate(s = \"10203040506070809000\") == 19\n assert candidate(s = \"11111111111111111111\") == 2\n assert candidate(s = \"55555555555555555559\") == 3\n assert candidate(s = \"11223344556677889900\") == 4\n assert candidate(s = \"1111111111111111111111111111111111111111111111\") == 2\n assert candidate(s = \"001001001001001001001001\") == 6\n assert candidate(s = \"11223344556677889900112233445566\") == 4\n assert candidate(s = \"0000123456789000\") == 12\n assert candidate(s = \"010203040506070809001\") == 21\n assert candidate(s = \"12345678901234567890123456789012\") == 32\n assert candidate(s = \"98989898989898989898\") == 20\n assert candidate(s = \"01234567890123456789012345678901234567890123\") == 44\n assert candidate(s = \"12345678901234567890\") == 20\n assert candidate(s = \"5544332211001122334455667788990011223344556677889900\") == 4\n assert candidate(s = \"55555555555555555555555555555555555555555555\") == 2\n assert candidate(s = \"1233211233211233211\") == 6\n assert candidate(s = \"9876543210987654321098765432109876543210\") == 40\n assert candidate(s = \"001122334455667788990011223344\") == 4\n assert candidate(s = \"9988776655443322110001122334455\") == 4\n assert candidate(s = \"00112233445566778899001122334455\") == 4\n assert candidate(s = \"98765432109876543210\") == 20\n assert candidate(s = \"122222333333444444555555666666777777888888999999000000\") == 3\n assert candidate(s = \"5432112345543211234554321123\") == 10\n assert candidate(s = \"22334455667788990011\") == 4\n assert candidate(s = \"000010002000300040005\") == 4\n assert candidate(s = \"123456789098765432109876543210\") == 30\n assert candidate(s = \"9876543219876543219876543219\") == 28\n assert candidate(s = \"1010101010101010101010101010\") == 28\n assert candidate(s = \"122112211221122112211221122112211221\") == 4\n assert candidate(s = \"1234567899999999999999999999999999999999\") == 10\n assert candidate(s = \"01234567898765432101234567890\") == 29\n assert candidate(s = \"98765432100123456789\") == 20\n assert candidate(s = \"111222333444555666777\") == 3\n assert candidate(s = \"12332132123123321321231233213212312332132123\") == 22\n assert candidate(s = \"000000000000000000000000000000000000000000001111\") == 3\n assert candidate(s = \"123455678990123456789012\") == 19\n assert candidate(s = \"1111112111112111112\") == 4\n assert candidate(s = \"123456789987654321123456789987654321\") == 18\n assert candidate(s = \"112233445566778899001122\") == 4\n assert candidate(s = \"12345678900123456789\") == 20\n assert candidate(s = \"000011112222333344445555\") == 3\n assert candidate(s = \"001001001001001001001001001001\") == 6\n assert candidate(s = \"1001001001001001001\") == 6\n assert candidate(s = \"122334455667788990011\") == 4\n assert candidate(s = \"111222333444555666777888999000\") == 3\n assert candidate(s = \"90909090909090909090\") == 20\n assert candidate(s = \"12345678909876543210\") == 20\n assert candidate(s = \"11111111111111111111111111111111111111111111\") == 2\n assert candidate(s = \"0011223344556677889900112233\") == 4\n assert candidate(s = \"12345678909876543210123456789098765432101234\") == 44\n assert candidate(s = \"549444444444444444444\") == 5\n assert candidate(s = \"999999999999999999991\") == 3\n assert candidate(s = \"112233445566778899009900\") == 4\n assert candidate(s = \"9876543210102030405060708090\") == 28\n assert candidate(s = \"121212121212121212121\") == 21\n assert candidate(s = \"1111111111111111111111111111111111111111\") == 2\n assert candidate(s = \"112233445544556677889900112233\") == 4\n assert candidate(s = \"55555555555555555555\") == 2\n assert candidate(s = \"111111222222333333444444555555666666\") == 3\n assert candidate(s = \"00000000000000000000\") == 2\n assert candidate(s = \"10101010101010101010101010101010\") == 32\n assert candidate(s = \"98765432100000000000\") == 11\n assert candidate(s = \"01234567899876543210\") == 20\n assert candidate(s = \"1111222233334444555566667777888899990000\") == 3\n assert candidate(s = \"11222333444555666777888999\") == 3\n assert candidate(s = \"1222222222222222222222222222222222222222\") == 3\n assert candidate(s = \"0101010101010101010101010101010101010101010101\") == 46\n assert candidate(s = \"12345678900987654321001234567890\") == 22\n assert candidate(s = \"999888777666555444333222111000111222333444\") == 3\n assert candidate(s = \"1122334455667788990011223344556677889900\") == 4\n assert candidate(s = \"987654321001234567899\") == 20\n assert candidate(s = \"112233445566778899001122334455\") == 4\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 40\n assert candidate(s = \"123456789001234567890\") == 21\n assert candidate(s = \"00112233445566778899\") == 4\n assert candidate(s = \"44444444444444444444444444444444444444444444\") == 2\n assert candidate(s = \"555555555555555555555555555555555\") == 2\n assert candidate(s = \"01010101010101010101\") == 20\n assert candidate(s = \"111122223333444455556666777788889999\") == 3\n assert candidate(s = \"000111222333444555666\") == 3\n assert candidate(s = \"000000111111222222333333444444555555\") == 3\n assert candidate(s = \"10101010101010101010\") == 20\n assert candidate(s = \"9876543210123456789012345678901234567890\") == 40\n assert candidate(s = \"987654321001234567899876543210\") == 20\n assert candidate(s = \"22223333444455556666777788889999000011112222\") == 3\n assert candidate(s = \"123456789012345678901234567890\") == 30\n assert candidate(s = \"000000111111222222333333444444555555666666777777888888\") == 3\n assert candidate(s = \"001100110011001100110011001100\") == 4\n assert candidate(s = \"010101010101010101010101010101010101010101010\") == 45\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestSemiRepetitiveSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestSemiRepetitiveSubstring(String s) {", "container": "Solution", "callable": "longestSemiRepetitiveSubstring", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2731, "task_id": "movement-of-robots", "difficulty": "Medium", "problem_description": "Some robots are standing on an infinite number line with their initial coordinates given by a 0-indexed integer array nums and will start moving once given the command to move. The robots will move a unit distance each second.\nYou are given a string s denoting the direction in which robots will move on command. 'L' means the robot will move towards the left side or negative side of the number line, whereas 'R' means the robot will move towards the right side or positive side of the number line.\nIf two robots collide, they will start moving in opposite directions.\nReturn the sum of distances between all the pairs of robots d seconds after the command. Since the sum can be very large, return it modulo 109 + 7.\nNote: \n\nFor two robots at the index i and j, pair (i,j) and pair (j,i) are considered the same pair.\nWhen robots collide, they instantly change their directions without wasting any time.\nCollision happens when two robots share the same place in a moment.\n\t\nFor example, if a robot is positioned in 0 going to the right and another is positioned in 2 going to the left, the next second they'll be both in 1 and they will change direction and the next second the first one will be in 0, heading left, and another will be in 2, heading right.\nFor example, if a robot is positioned in 0 going to the right and another is positioned in 1 going to the left, the next second the first one will be in 0, heading left, and another will be in 1, heading right.\n\n\n\n \nExample 1:\n\nInput: nums = [-2,0,2], s = \"RLL\", d = 3\nOutput: 8\nExplanation: \nAfter 1 second, the positions are [-1,-1,1]. Now, the robot at index 0 will move left, and the robot at index 1 will move right.\nAfter 2 seconds, the positions are [-2,0,0]. Now, the robot at index 1 will move left, and the robot at index 2 will move right.\nAfter 3 seconds, the positions are [-3,-1,1].\nThe distance between the robot at index 0 and 1 is abs(-3 - (-1)) = 2.\nThe distance between the robot at index 0 and 2 is abs(-3 - 1) = 4.\nThe distance between the robot at index 1 and 2 is abs(-1 - 1) = 2.\nThe sum of the pairs of all distances = 2 + 4 + 2 = 8.\n\nExample 2:\n\nInput: nums = [1,0], s = \"RL\", d = 2\nOutput: 5\nExplanation: \nAfter 1 second, the positions are [2,-1].\nAfter 2 seconds, the positions are [3,-2].\nThe distance between the two robots is abs(-2 - 3) = 5.\n\n \nConstraints:\n\n2 <= nums.length <= 105\n-2 * 109 <= nums[i] <= 2 * 109\n0 <= d <= 109\nnums.length == s.length \ns consists of 'L' and 'R' only\nnums[i] will be unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4],s = \"RLRL\",d = 5) == 24\n assert candidate(nums = [-5, 1, 4],s = \"RLR\",d = 4) == 22\n assert candidate(nums = [-5, -1, 0, 3, 7],s = \"RLLLR\",d = 5) == 82\n assert candidate(nums = [-10, -20, -30],s = \"LLL\",d = 1) == 40\n assert candidate(nums = [0, 1, 2, 3, 4],s = \"RRRRR\",d = 1) == 20\n assert candidate(nums = [-2, 0, 2],s = \"RLL\",d = 3) == 8\n assert candidate(nums = [2, -1, 0],s = \"LRR\",d = 5) == 16\n assert candidate(nums = [10, -10, 0],s = \"RLR\",d = 10) == 80\n assert candidate(nums = [-2, 0, 2],s = \"RLL\",d = 3) == 8\n assert candidate(nums = [10, 20, 30],s = \"RRR\",d = 1) == 40\n assert candidate(nums = [-1, 2, -3, 4],s = \"LRRL\",d = 5) == 42\n assert candidate(nums = [10, -10, 0],s = \"RLR\",d = 5) == 60\n assert candidate(nums = [1, 0],s = \"RL\",d = 2) == 5\n assert candidate(nums = [-5, 1, 3],s = \"RRL\",d = 4) == 12\n assert candidate(nums = [1, 0],s = \"RL\",d = 2) == 5\n assert candidate(nums = [0, 0, 0, 0],s = \"RRLL\",d = 1) == 8\n assert candidate(nums = [3, 2, 1],s = \"RRR\",d = 1) == 4\n assert candidate(nums = [10, -10, 20, -20],s = \"RLRL\",d = 10) == 220\n assert candidate(nums = [-10, -5, 0, 5, 10],s = \"RRRLL\",d = 7) == 50\n assert candidate(nums = [1, -1, 2, -2, 3, -3],s = \"RLRLRL\",d = 15) == 314\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],s = \"RLRLRLRLRL\",d = 5) == 165\n assert candidate(nums = [-1, 2, -3, 4, -5],s = \"RLLRL\",d = 3) == 76\n assert candidate(nums = [-10, -5, 0, 5, 10, 15, 20, 25, 30],s = \"LRRLLRRLL\",d = 10) == 680\n assert candidate(nums = [1, 2, 3, 4, 5],s = \"RLRLR\",d = 2) == 34\n assert candidate(nums = [0, 1, 2, 3, 4, 5],s = \"RRRRR\",d = 3) == 26\n assert candidate(nums = [-1000000000, 0, 1000000000],s = \"RLR\",d = 500000000) == 999999979\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],s = \"RRRRRRRRRR\",d = 5) == 165\n assert candidate(nums = [-1000, -800, -600, -400, -200, 200, 400, 600, 800, 1000],s = \"RRRRRRRRRR\",d = 300) == 38000\n assert candidate(nums = [-20, -10, 0, 10, 20],s = \"LRRLL\",d = 15) == 220\n assert candidate(nums = [-10, -5, -1, 0, 1, 5, 10],s = \"LRRLLRR\",d = 7) == 304\n assert candidate(nums = [-1000, -500, 0, 500, 1000],s = \"RLRLR\",d = 500) == 12000\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],s = \"RRRRRRRRRRRRRRRRRRRR\",d = 2) == 1330\n assert candidate(nums = [100, 200, 300, 400, 500],s = \"RRRRR\",d = 1) == 2000\n assert candidate(nums = [-10, -5, 0, 5, 10],s = \"LRLRL\",d = 5) == 120\n assert candidate(nums = [-10, -5, 0, 5, 10],s = \"RLRLR\",d = 7) == 136\n assert candidate(nums = [-10, -5, 0, 5, 10],s = \"RLRRL\",d = 3) == 92\n assert candidate(nums = [-5, 0, 5, 10],s = \"RLRR\",d = 20) == 160\n assert candidate(nums = [-500, -300, -100, 100, 300, 500],s = \"LLRRLR\",d = 10) == 7100\n assert candidate(nums = [-2, -1, 0, 1, 2],s = \"RLRLR\",d = 7) == 94\n assert candidate(nums = [-20, -10, 0, 10, 20, 30, 40, 50, 60, 70],s = \"LRRLLRRLLR\",d = 15) == 1840\n assert candidate(nums = [-50, -25, 0, 25, 50],s = \"LRRRL\",d = 25) == 550\n assert candidate(nums = [-9, -7, -5, -3, -1, 1, 3, 5, 7, 9],s = \"RRRRRRRRRR\",d = 2) == 330\n assert candidate(nums = [-9, -6, -3, 0, 3, 6, 9],s = \"RRRRRRR\",d = 4) == 168\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],s = \"RLRLRLRLRL\",d = 3) == 80\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],s = \"RRRRRRRRRR\",d = 1) == 165\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18],s = \"LRLRLRLRLR\",d = 5) == 468\n assert candidate(nums = [-20, -15, -10, -5, 0, 5, 10, 15, 20],s = \"RLRLRLRLR\",d = 3) == 608\n assert candidate(nums = [0, 1, 2, 3, 4, 5],s = \"RRRRRR\",d = 10) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],s = \"RRRRRRRRRL\",d = 1) == 149\n assert candidate(nums = [100, 200, 300, 400, 500],s = \"LLLLL\",d = 50) == 2000\n assert candidate(nums = [100, 101, 102, 103, 104, 105],s = \"LLLLLR\",d = 5) == 85\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],s = \"RRRRRRRRRR\",d = 1) == 210\n assert candidate(nums = [-9, -7, -5, -3, -1],s = \"RRRRR\",d = 6) == 40\n assert candidate(nums = [-50, -20, -10, 0, 10, 20, 50],s = \"LRRLLRR\",d = 10) == 900\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],s = \"RLRLRLRLRL\",d = 20) == 1110\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],s = \"RRRRRRRRRR\",d = 10) == 165\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5],s = \"LLLLLL\",d = 3) == 74\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],s = \"LRLRLRLRLRL\",d = 1) == 230\n assert candidate(nums = [-50, -30, -10, 10, 30, 50],s = \"LLRRLL\",d = 15) == 720\n assert candidate(nums = [-10, -8, -6, -4, -2, 2, 4, 6, 8, 10],s = \"LLLLLLLLLL\",d = 3) == 380\n assert candidate(nums = [-20, -15, -10, -5, 0, 5, 10, 15, 20],s = \"RRRRLLLLL\",d = 3) == 482\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],s = \"RRRRRRRRRRLLLLLLLLLL\",d = 5) == 1101\n assert candidate(nums = [-100, -200, -300, -400, -500],s = \"LLLLL\",d = 100) == 2000\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4],s = \"RLRLRLRL\",d = 1) == 68\n assert candidate(nums = [1, 3, 5, 7, 9],s = \"LLLLL\",d = 2) == 40\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],s = \"RLRLRLRLRL\",d = 4) == 390\n assert candidate(nums = [-300, -200, -100, 0, 100, 200, 300],s = \"LRRLLRR\",d = 100) == 6600\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],s = \"RRRRRRRRRR\",d = 2) == 165\n assert candidate(nums = [-1000000000, 1000000000],s = \"RL\",d = 1000000000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],s = \"LLLLL\",d = 5) == 200\n assert candidate(nums = [-10, -5, 0, 5, 10],s = \"RRLRR\",d = 7) == 126\n assert candidate(nums = [-1000, -500, 0, 500, 1000],s = \"RLLRL\",d = 1000) == 14000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],s = \"LLLLLLLLLL\",d = 1) == 330\n assert candidate(nums = [5, 3, 8, 1, 6],s = \"RRLLR\",d = 7) == 98\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],s = \"RRRRRRRRRR\",d = 2) == 165\n assert candidate(nums = [-9, -6, -3, 0, 3, 6, 9],s = \"RLRLRLR\",d = 6) == 234\n assert candidate(nums = [-5, -3, 1, 4, 7],s = \"LRRRL\",d = 2) == 64\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],s = \"RRRRRRRRRRRR\",d = 3) == 286\n assert candidate(nums = [-10, -5, 0, 5, 10, 15, 20],s = \"RRRLLLL\",d = 7) == 146\n assert candidate(nums = [-19, -17, -15, -13, -11, -9, -7, -5, -3, -1],s = \"RRRRRRRRRR\",d = 2) == 330\n assert candidate(nums = [-20, -15, -10, -5, 0, 5, 10, 15, 20],s = \"RRRRLLLL\",d = 20) == 600\n assert candidate(nums = [-500000000, -250000000, 0, 250000000, 500000000],s = \"RLLLR\",d = 500000000) == 999999951\n assert candidate(nums = [-1000000000, 0, 1000000000],s = \"RL\",d = 500000000) == 999999986\n assert candidate(nums = [0, 10, 20, 30, 40],s = \"LLLLL\",d = 5) == 200\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],s = \"LRRLLRRLL\",d = 10) == 531\n assert candidate(nums = [-500, -300, -100, 100, 300, 500],s = \"RLLRLR\",d = 200) == 8200\n assert candidate(nums = [-1000000000, 1000000000],s = \"LR\",d = 500000000) == 999999986\n assert candidate(nums = [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],s = \"RLLLLRLLLL\",d = 5) == 406\n assert candidate(nums = [-500, -400, -300, -200, -100],s = \"RRRRR\",d = 100) == 2000\n assert candidate(nums = [5, 10, 15, 20],s = \"RRRR\",d = 5) == 50\n assert candidate(nums = [-100, -50, 0, 50, 100, 150, 200],s = \"RLLRLLR\",d = 150) == 4900\n assert candidate(nums = [-9, -6, -3, 0, 3, 6, 9],s = \"LRRLRL\",d = 15) == 396\n assert candidate(nums = [-9, -7, -5, -3, -1, 1, 3, 5, 7, 9],s = \"LRLRLRLRLR\",d = 10) == 710\n assert candidate(nums = [-1, 1, -2, 2, -3, 3],s = \"RLRLRL\",d = 5) == 62\n assert candidate(nums = [100, 200, 300, 400, 500],s = \"LLLLL\",d = 10) == 2000\n assert candidate(nums = [-1000000000, 1000000000],s = \"LR\",d = 1000000000) == 999999979\n assert candidate(nums = [-20, -15, -10, -5, 0, 5, 10, 15, 20],s = \"LRRRLRRRL\",d = 7) == 652\n assert candidate(nums = [5, 15, 25, 35, 45],s = \"LRRLL\",d = 10) == 180\n assert candidate(nums = [-50, -20, -10, 0, 10, 20, 50],s = \"LRLRLRL\",d = 30) == 1140\n assert candidate(nums = [-20, -10, 0, 10, 20],s = \"LRLLR\",d = 3) == 212\n assert candidate(nums = [-10, -5, 0, 5, 10, 15],s = \"RLRLRL\",d = 1) == 169\n assert candidate(nums = [100, 200, 300, 400, 500],s = \"RRRRR\",d = 50) == 2000\n assert candidate(nums = [100, 200, 300, 400, 500, 600],s = \"LLLLLR\",d = 150) == 5000\n assert candidate(nums = [-500, -400, -300, -200, -100],s = \"RRRRR\",d = 15) == 2000\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3],s = \"LLRLRLR\",d = 1) == 72\n assert candidate(nums = [-1000000000, 0, 1000000000],s = \"RLR\",d = 1000000000) == 999999965\n assert candidate(nums = [-1000000, 0, 1000000],s = \"RLR\",d = 1000000) == 6000000\n assert candidate(nums = [250, 500, 750, 1000, 1250],s = \"LLLLL\",d = 250) == 5000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],s = \"LLLLLLLLLL\",d = 500) == 16500\n assert candidate(nums = [-25, -15, -5, 5, 15, 25],s = \"RLRRRL\",d = 10) == 350\n"}, "metadata": {"canonical_parameter_names": ["nums", "s", "d"], "leetcode_dataset_entry_point": "Solution().sumDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int sumDistance(int[] nums, String s, int d) {", "container": "Solution", "callable": "sumDistance", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "s", "type": "String"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2732, "task_id": "find-a-good-subset-of-the-matrix", "difficulty": "Hard", "problem_description": "You are given a 0-indexed m x n binary matrix grid.\nLet us call a non-empty subset of rows good if the sum of each column of the subset is at most half of the length of the subset.\nMore formally, if the length of the chosen subset of rows is k, then the sum of each column should be at most floor(k / 2).\nReturn an integer array that contains row indices of a good subset sorted in ascending order.\nIf there are multiple good subsets, you can return any of them. If there are no good subsets, return an empty array.\nA subset of rows of the matrix grid is any matrix that can be obtained by deleting some (possibly none or all) rows from grid.\n \nExample 1:\n\nInput: grid = [[0,1,1,0],[0,0,0,1],[1,1,1,1]]\nOutput: [0,1]\nExplanation: We can choose the 0th and 1st rows to create a good subset of rows.\nThe length of the chosen subset is 2.\n- The sum of the 0th column is 0 + 0 = 0, which is at most half of the length of the subset.\n- The sum of the 1st column is 1 + 0 = 1, which is at most half of the length of the subset.\n- The sum of the 2nd column is 1 + 0 = 1, which is at most half of the length of the subset.\n- The sum of the 3rd column is 0 + 1 = 1, which is at most half of the length of the subset.\n\nExample 2:\n\nInput: grid = [[0]]\nOutput: [0]\nExplanation: We can choose the 0th row to create a good subset of rows.\nThe length of the chosen subset is 1.\n- The sum of the 0th column is 0, which is at most half of the length of the subset.\n\nExample 3:\n\nInput: grid = [[1,1,1],[1,1,1]]\nOutput: []\nExplanation: It is impossible to choose any subset of rows to create a good subset.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m <= 104\n1 <= n <= 5\ngrid[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0]]) == [2, 3]\n assert candidate(grid = [[0, 0, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0]]) == [0]\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [1, 0, 0]]) == [0]\n assert candidate(grid = [[0, 1, 1, 0], [0, 0, 0, 1], [1, 1, 1, 1]]) == [0, 1]\n assert candidate(grid = [[1, 1, 0], [0, 0, 1], [1, 0, 0]]) == [0, 1]\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 0]]) == [0, 1]\n assert candidate(grid = [[0]]) == [0]\n assert candidate(grid = [[1, 1, 1], [1, 1, 1]]) == []\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, 1]\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == [1, 2]\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, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [3]\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]]) == [4, 5]\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]]) == [3, 4]\n assert candidate(grid = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1]]) == [3]\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1]]) == [0, 1]\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [1]\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [0, 1]\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]\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]]) == [1]\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0]]) == [0]\n assert candidate(grid = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [0]\n assert candidate(grid = [[0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == [0]\n assert candidate(grid = [[0, 0, 0, 1, 0, 0], [1, 1, 1, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]]) == [0, 1]\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]]) == [0, 1]\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], [1, 1, 1, 1, 1, 1, 1]]) == [2]\n assert candidate(grid = [[0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == [0, 1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == [1]\n assert candidate(grid = [[0, 0, 1, 1, 1], [0, 1, 0, 1, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [1, 1, 1, 1, 1]]) == [2, 3]\n assert candidate(grid = [[0, 0, 1, 1], [0, 1, 0, 1], [1, 0, 0, 1], [1, 1, 0, 0], [1, 0, 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, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [0, 1]\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]]) == [2, 3]\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [0]\n assert candidate(grid = [[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, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == [2]\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [0, 4]\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]]) == [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], [1, 1, 1, 1, 1]]) == []\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]]) == []\n assert candidate(grid = [[0, 0, 1, 1, 1], [1, 0, 0, 1, 0], [1, 1, 0, 0, 0], [0, 0, 0, 0, 1], [0, 1, 1, 0, 0]]) == [0, 2]\n assert candidate(grid = [[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], [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]]) == []\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]]) == [2, 3]\n assert candidate(grid = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == [2]\n assert candidate(grid = [[0, 1, 1, 0, 0], [1, 0, 0, 1, 1], [0, 1, 1, 0, 0], [1, 0, 0, 1, 1], [0, 1, 1, 0, 0]]) == [3, 4]\n assert candidate(grid = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == [0]\n assert candidate(grid = [[0, 0, 1, 1, 0], [1, 0, 0, 1, 1], [0, 1, 1, 0, 0], [1, 1, 0, 0, 1]]) == [0, 3]\n assert candidate(grid = [[1, 1, 0, 1, 0], [1, 1, 0, 1, 0], [1, 1, 0, 1, 0], [1, 1, 0, 1, 0], [1, 1, 0, 1, 0]]) == []\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1]]) == [1, 5]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0]]) == [1, 2]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 1]]) == [1, 2]\n assert candidate(grid = [[0, 0, 1, 1], [0, 1, 0, 1], [1, 0, 0, 0], [0, 0, 0, 0]]) == [3]\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == [0, 1]\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [1, 1, 0, 1, 1]]) == [0, 1]\n assert candidate(grid = [[0, 0, 1, 1, 1], [0, 1, 0, 1, 1], [1, 0, 0, 1, 1], [1, 1, 1, 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]]) == [0]\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [3]\n assert candidate(grid = [[0, 1, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == [2]\n assert candidate(grid = [[0, 1, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 1], [1, 0, 1, 1, 0, 1], [0, 1, 0, 1, 1, 0]]) == [1, 2]\n assert candidate(grid = [[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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [0, 1]\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [2, 3]\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]\n assert candidate(grid = [[0, 0, 1, 1, 0], [1, 0, 0, 0, 1], [0, 1, 1, 0, 0], [1, 1, 0, 1, 1]]) == [0, 1]\n assert candidate(grid = [[0, 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]\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0]]) == [4, 5]\n assert candidate(grid = [[1, 1, 1, 1, 0], [0, 0, 0, 0, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1]]) == [0, 1]\n assert candidate(grid = [[0, 0, 0, 1, 1], [0, 1, 1, 0, 0], [1, 0, 1, 0, 1], [1, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == [4]\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, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == [1]\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == [0, 1]\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], [0, 1, 0, 1, 0, 1]]) == [3, 4]\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1]]) == [4, 5]\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 1]]) == [0, 1]\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0, 0, 1], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0]]) == [0, 1]\n assert candidate(grid = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0]]) == [2]\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 1, 1, 1]]) == [1, 3]\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 0, 1], [1, 1, 1, 1, 0]]) == []\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == []\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, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == [2]\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]]) == [2, 3]\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 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]]) == []\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [2, 3]\n assert candidate(grid = [[0, 0, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1]]) == [1, 2]\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [1, 0, 0, 1, 1], [0, 1, 1, 0, 1], [1, 0, 1, 1, 0]]) == [0, 1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == [1]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().goodSubsetofBinaryMatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List goodSubsetofBinaryMatrix(int[][] grid) {", "container": "Solution", "callable": "goodSubsetofBinaryMatrix", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2733, "task_id": "neither-minimum-nor-maximum", "difficulty": "Easy", "problem_description": "Given an integer array nums containing distinct positive integers, find and return any number from the array that is neither the minimum nor the maximum value in the array, or -1 if there is no such number.\nReturn the selected integer.\n \nExample 1:\n\nInput: nums = [3,2,1,4]\nOutput: 2\nExplanation: In this example, the minimum value is 1 and the maximum value is 4. Therefore, either 2 or 3 can be valid answers.\n\nExample 2:\n\nInput: nums = [1,2]\nOutput: -1\nExplanation: Since there is no number in nums that is neither the maximum nor the minimum, we cannot select a number that satisfies the given condition. Therefore, there is no answer.\n\nExample 3:\n\nInput: nums = [2,1,3]\nOutput: 2\nExplanation: Since 2 is neither the maximum nor the minimum value in nums, it is the only valid answer. \n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\nAll values in nums are distinct\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == -1\n assert candidate(nums = [1, 3, 2]) == 2\n assert candidate(nums = [9, 5, 6]) == 6\n assert candidate(nums = [9, 11, 10]) == 10\n assert candidate(nums = [1, 2]) == -1\n assert candidate(nums = [7, 8, 9]) == 8\n assert candidate(nums = [100, 1, 50]) == 50\n assert candidate(nums = [5, 3, 4, 1, 2]) == 3\n assert candidate(nums = [2, 1, 3]) == 2\n assert candidate(nums = [5, 10, 3, 8, 1]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50]) == 20\n assert candidate(nums = [7]) == -1\n assert candidate(nums = [5, 1, 4, 3, 2]) == 4\n assert candidate(nums = [3, 2, 1, 4]) == 3\n assert candidate(nums = [7, 8, 9]) == 8\n assert candidate(nums = [42, 24, 36, 12, 60, 72, 48]) == 42\n assert candidate(nums = [2, 1, 3, 5, 4, 6]) == 2\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35]) == 10\n assert candidate(nums = [30, 1, 29, 2, 28, 3, 27, 4, 26, 5]) == 29\n assert candidate(nums = [42, 35, 28, 21, 14, 7]) == 35\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94]) == 99\n assert candidate(nums = [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50]) == 59\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 5\n assert candidate(nums = [1, 100, 50, 75, 25]) == 50\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 8\n assert candidate(nums = [6, 4, 2, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26]) == 6\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 3\n assert candidate(nums = [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == 59\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 22\n assert candidate(nums = [33, 11, 22, 44, 55, 66, 77, 88, 99, 111, 222, 333, 444, 555]) == 33\n assert candidate(nums = [5, 10, 15, 20, 25]) == 10\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93]) == 2\n assert candidate(nums = [100, 1, 50, 25, 75, 33, 67, 88, 99, 2]) == 50\n assert candidate(nums = [7, 3, 9, 11, 5]) == 7\n assert candidate(nums = [42]) == -1\n assert candidate(nums = [45, 23, 67, 89, 12, 34, 56, 78, 90, 10, 20]) == 45\n assert candidate(nums = [100]) == -1\n assert candidate(nums = [42, 3, 7, 18, 29, 1]) == 3\n assert candidate(nums = [8, 6, 4, 2, 1, 3, 5, 7, 9, 10]) == 8\n assert candidate(nums = [7, 77, 777, 7777]) == 77\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 22\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 25\n assert candidate(nums = [100, 1, 50, 25, 75]) == 50\n assert candidate(nums = [8, 6, 4, 2, 0, -2, -4]) == 6\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88]) == 16\n assert candidate(nums = [101, 99, 98, 100, 97, 96, 95, 94, 93, 92, 91]) == 99\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 98\n assert candidate(nums = [4, 1, 3, 2, 5, 7, 6, 8]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 20\n assert candidate(nums = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 12\n assert candidate(nums = [88, 99, 77, 66, 55, 44]) == 88\n assert candidate(nums = [45, 30, 15, 60, 75, 90]) == 45\n assert candidate(nums = [31, 1, 41, 59, 26, 53, 58, 97, 93, 23]) == 31\n assert candidate(nums = [5, 1, 9, 3, 7]) == 5\n assert candidate(nums = [5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [55, 45, 35, 25, 15, 5, 10, 20, 30, 40]) == 45\n assert candidate(nums = [7, 3, 5, 1, 9, 11]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50]) == 20\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 3\n assert candidate(nums = [45, 30, 60, 20, 70]) == 45\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 4\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 3\n assert candidate(nums = [5, 3, 7, 1, 9, 11, 13, 15, 17, 19, 21]) == 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]) == 2\n assert candidate(nums = [100, 1, 50, 2, 99]) == 50\n assert candidate(nums = [33, 22, 11, 44, 55, 66, 77, 88, 99]) == 33\n assert candidate(nums = [7, 1, 5, 3, 6, 4]) == 5\n assert candidate(nums = [10, 5, 15, 20, 25]) == 10\n assert candidate(nums = [42, 27, 58, 19, 33, 49, 21]) == 42\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70]) == 20\n assert candidate(nums = [99, 100]) == -1\n assert candidate(nums = [25, 20, 15, 10, 5]) == 20\n assert candidate(nums = [7, 14, 21, 28, 35, 42]) == 14\n assert candidate(nums = [100, 1, 2, 3, 99, 50]) == 2\n assert candidate(nums = [66, 33, 99, 22, 44, 77, 55, 11, 88]) == 66\n assert candidate(nums = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53]) == 34\n assert candidate(nums = [5, 3, 8, 1, 4]) == 5\n assert candidate(nums = [100, 1, 50, 99, 2, 98]) == 50\n assert candidate(nums = [8, 15, 3, 12, 7, 18]) == 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]) == 29\n assert candidate(nums = [7, 14, 9, 11, 6, 12]) == 7\n assert candidate(nums = [5, 1, 100, 10, 50, 20, 60, 30, 40, 70, 80, 90]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 10\n assert candidate(nums = [3, 1, 2, 4, 5]) == 3\n assert candidate(nums = [50, 40]) == -1\n assert candidate(nums = [10, 5, 3, 8, 2]) == 5\n assert candidate(nums = [100, 1, 50, 75, 25, 125, 62]) == 100\n assert candidate(nums = [97, 98, 95, 96, 99]) == 97\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9]) == 8\n assert candidate(nums = [100, 1, 50, 99, 2]) == 50\n assert candidate(nums = [47, 29, 83, 61, 95, 17, 53]) == 47\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findNonMinOrMax", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findNonMinOrMax(int[] nums) {", "container": "Solution", "callable": "findNonMinOrMax", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2734, "task_id": "lexicographically-smallest-string-after-substring-operation", "difficulty": "Medium", "problem_description": "Given a string s consisting of lowercase English letters. Perform the following operation:\n\nSelect any non-empty substring then replace every letter of the substring with the preceding letter of the English alphabet. For example, 'b' is converted to 'a', and 'a' is converted to 'z'.\n\nReturn the lexicographically smallest string after performing the operation.\n \nExample 1:\n\nInput: s = \"cbabc\"\nOutput: \"baabc\"\nExplanation:\nPerform the operation on the substring starting at index 0, and ending at index 1 inclusive.\n\nExample 2:\n\nInput: s = \"aa\"\nOutput: \"az\"\nExplanation:\nPerform the operation on the last letter.\n\nExample 3:\n\nInput: s = \"acbbc\"\nOutput: \"abaab\"\nExplanation:\nPerform the operation on the substring starting at index 1, and ending at index 4 inclusive.\n\nExample 4:\n\nInput: s = \"leetcode\"\nOutput: \"kddsbncd\"\nExplanation:\nPerform the operation on the entire string.\n\n \nConstraints:\n\n1 <= s.length <= 3 * 105\ns consists of lowercase English letters\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abz\") == \"aay\"\n assert candidate(s = \"azazaz\") == \"ayazaz\"\n assert candidate(s = \"zzzz\") == \"yyyy\"\n assert candidate(s = \"azaza\") == \"ayaza\"\n assert candidate(s = \"acbbc\") == \"abaab\"\n assert candidate(s = \"cbabc\") == \"baabc\"\n assert candidate(s = \"azaz\") == \"ayaz\"\n assert candidate(s = \"z\") == \"y\"\n assert candidate(s = \"aaa\") == \"aaz\"\n assert candidate(s = \"aa\") == \"az\"\n assert candidate(s = \"abcdzxyz\") == \"aabcywxy\"\n assert candidate(s = \"abcd\") == \"aabc\"\n assert candidate(s = \"zzz\") == \"yyy\"\n assert candidate(s = \"leetcode\") == \"kddsbncd\"\n assert candidate(s = \"xyz\") == \"wxy\"\n assert candidate(s = \"mnopqrstuvsxyz\") == \"lmnopqrsturwxy\"\n assert candidate(s = \"zzabcd\") == \"yyabcd\"\n assert candidate(s = \"zazbzczdz\") == \"yazbzczdz\"\n assert candidate(s = \"aaaaaabbbbb\") == \"aaaaaaaaaaa\"\n assert candidate(s = \"abczzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"aabyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\"\n assert candidate(s = \"abxyzmnopqrstu\") == \"aawxylmnopqrst\"\n assert candidate(s = \"aczzzzza\") == \"abyyyyya\"\n assert candidate(s = \"aabbaabbaabb\") == \"aaaaaabbaabb\"\n assert candidate(s = \"aabbaabb\") == \"aaaaaabb\"\n assert candidate(s = \"abcabcabc\") == \"aababcabc\"\n assert candidate(s = \"abracadabra\") == \"aaqacadabra\"\n assert candidate(s = \"aaaaazzzzz\") == \"aaaaayyyyy\"\n assert candidate(s = \"aaaaz\") == \"aaaay\"\n assert candidate(s = \"zaz\") == \"yaz\"\n assert candidate(s = \"cbabczzzz\") == \"baabczzzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\"\n assert candidate(s = \"aaabaaab\") == \"aaaaaaab\"\n assert candidate(s = \"aaaabbbbcccc\") == \"aaaaaaaabbbb\"\n assert candidate(s = \"zzzzzzzzzz\") == \"yyyyyyyyyy\"\n assert candidate(s = \"abcdabcdabcd\") == \"aabcabcdabcd\"\n assert candidate(s = \"zzzzzaa\") == \"yyyyyaa\"\n assert candidate(s = \"zzzzz\") == \"yyyyy\"\n assert candidate(s = \"aaabaaaabaaa\") == \"aaaaaaaabaaa\"\n assert candidate(s = \"zzyyzzyyzzyy\") == \"yyxxyyxxyyxx\"\n assert candidate(s = \"aaaabaaa\") == \"aaaaaaaa\"\n assert candidate(s = \"xyzyxzyzyxzyz\") == \"wxyxwyxyxwyxy\"\n assert candidate(s = \"leetcodeisfun\") == \"kddsbncdhretm\"\n assert candidate(s = \"aaaaaaaabczzzzzzzz\") == \"aaaaaaaaabyyyyyyyy\"\n assert candidate(s = \"babababababababab\") == \"aabababababababab\"\n assert candidate(s = \"zaa\") == \"yaa\"\n assert candidate(s = \"mnopqrstu\") == \"lmnopqrst\"\n assert candidate(s = \"aaaaaz\") == \"aaaaay\"\n assert candidate(s = \"abacabad\") == \"aaacabad\"\n assert candidate(s = \"leetcodez\") == \"kddsbncdy\"\n assert candidate(s = \"zabz\") == \"yabz\"\n assert candidate(s = \"abzab\") == \"aayab\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaz\"\n assert candidate(s = \"azz\") == \"ayy\"\n assert candidate(s = \"qwertypoiuytrewq\") == \"pvdqsxonhtxsqdvp\"\n assert candidate(s = \"aabbccdd\") == \"aaaabbcc\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabc\") == \"aabcdefghijklmnopqrstuvwxyabc\"\n assert candidate(s = \"zzabc\") == \"yyabc\"\n assert candidate(s = \"zzzzza\") == \"yyyyya\"\n assert candidate(s = \"abczzzzabc\") == \"aabyyyyabc\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzz\") == \"yyyyyyyyyyyyyyyyyyyyyyyy\"\n assert candidate(s = \"abzabzabz\") == \"aayabzabz\"\n assert candidate(s = \"azzzzzz\") == \"ayyyyyy\"\n assert candidate(s = \"hellozworld\") == \"gdkknyvnqkc\"\n assert candidate(s = \"abacabadabacaba\") == \"aaacabadabacaba\"\n assert candidate(s = \"abcxyzzyxabc\") == \"aabwxyyxwabc\"\n assert candidate(s = \"zabcdefghijklmnopqrstuvwxyz\") == \"yabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == \"yyyyyyyyyyyyyyyyyyyy\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\"\n assert candidate(s = \"aaaabczzzz\") == \"aaaaabyyyy\"\n assert candidate(s = \"abcdz\") == \"aabcy\"\n assert candidate(s = \"aabbccddeeffgg\") == \"aaaabbccddeeff\"\n assert candidate(s = \"bbbb\") == \"aaaa\"\n assert candidate(s = \"abcdefghij\") == \"aabcdefghi\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aaaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyy\"\n assert candidate(s = \"aaaazzzz\") == \"aaaayyyy\"\n assert candidate(s = \"bababababab\") == \"aababababab\"\n assert candidate(s = \"abcxyzabc\") == \"aabwxyabc\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"yxwvutsrqponmlkjihgfedcbaa\"\n assert candidate(s = \"abcdefg\") == \"aabcdef\"\n assert candidate(s = \"baaaaaaaaaa\") == \"aaaaaaaaaaa\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"aabcdefghijklmnopqrstuvwxy\"\n assert candidate(s = \"xyzabcdefghijklmnopqrstu\") == \"wxyabcdefghijklmnopqrstu\"\n assert candidate(s = \"abzzz\") == \"aayyy\"\n assert candidate(s = \"abcxyz\") == \"aabwxy\"\n assert candidate(s = \"abczyx\") == \"aabyxw\"\n assert candidate(s = \"zabxyzmnopqrstu\") == \"yabxyzmnopqrstu\"\n assert candidate(s = \"aaaab\") == \"aaaaa\"\n assert candidate(s = \"zzzzzyyyy\") == \"yyyyyxxxx\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"aabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcz\") == \"aaby\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaz\"\n assert candidate(s = \"zzzabzzz\") == \"yyyabzzz\"\n assert candidate(s = \"xyzaabbcc\") == \"wxyaabbcc\"\n assert candidate(s = \"mississippi\") == \"lhrrhrrhooh\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == \"yxwvutsrqponmlkjihgfedcbaazyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"abcabcabcabcabc\") == \"aababcabcabcabc\"\n assert candidate(s = \"hello world\") == \"gdkkn\u001fvnqkc\"\n assert candidate(s = \"baaaa\") == \"aaaaa\"\n assert candidate(s = \"zzzzzzzz\") == \"yyyyyyyy\"\n assert candidate(s = \"aaaazzzzzzzzzz\") == \"aaaayyyyyyyyyy\"\n assert candidate(s = \"zyxzyxzyxzyx\") == \"yxwyxwyxwyxw\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().smallestString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String smallestString(String s) {", "container": "Solution", "callable": "smallestString", "parameters": [{"name": "s", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2735, "task_id": "collecting-chocolates", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of size n representing the cost of collecting different chocolates. The cost of collecting the chocolate at the index i is nums[i]. Each chocolate is of a different type, and initially, the chocolate at the index i is of ith type.\nIn one operation, you can do the following with an incurred cost of x:\n\nSimultaneously change the chocolate of ith type to ((i + 1) mod n)th type for all chocolates.\n\nReturn the minimum cost to collect chocolates of all types, given that you can perform as many operations as you would like.\n \nExample 1:\n\nInput: nums = [20,1,15], x = 5\nOutput: 13\nExplanation: Initially, the chocolate types are [0,1,2]. We will buy the 1st type of chocolate at a cost of 1.\nNow, we will perform the operation at a cost of 5, and the types of chocolates will become [1,2,0]. We will buy the 2nd type of chocolate at a cost of 1.\nNow, we will again perform the operation at a cost of 5, and the chocolate types will become [2,0,1]. We will buy the 0th type of chocolate at a cost of 1. \nThus, the total cost will become (1 + 5 + 1 + 5 + 1) = 13. We can prove that this is optimal.\n\nExample 2:\n\nInput: nums = [1,2,3], x = 4\nOutput: 6\nExplanation: We will collect all three types of chocolates at their own price without performing any operations. Therefore, the total cost is 1 + 2 + 3 = 6.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 109\n1 <= x <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],x = 10) == 90\n assert candidate(nums = [10, 20, 30, 40],x = 10) == 70\n assert candidate(nums = [1, 1, 1, 1, 1],x = 1) == 5\n assert candidate(nums = [7, 7, 7, 7, 7, 7],x = 2) == 42\n assert candidate(nums = [10, 20, 30, 40, 50],x = 1) == 54\n assert candidate(nums = [3, 1, 2],x = 3) == 6\n assert candidate(nums = [100, 200, 300],x = 50) == 400\n assert candidate(nums = [1, 2, 3],x = 4) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 1) == 10\n assert candidate(nums = [1000000000, 1000000000, 1000000000],x = 1000000000) == 3000000000\n assert candidate(nums = [1],x = 100) == 1\n assert candidate(nums = [5, 5, 5, 5],x = 10) == 20\n assert candidate(nums = [1, 3, 5, 7, 9],x = 2) == 13\n assert candidate(nums = [20, 1, 15],x = 5) == 13\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 10) == 45\n assert candidate(nums = [5, 5, 5, 5],x = 1) == 20\n assert candidate(nums = [10, 20, 30, 40],x = 5) == 55\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],x = 1) == 21\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],x = 30) == 540\n assert candidate(nums = [100, 200, 300, 400, 500],x = 500) == 1500\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],x = 10) == 190\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 3) == 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],x = 1) == 39\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 100) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 2) == 27\n assert candidate(nums = [5, 8, 6, 3, 4, 7, 2, 9, 1],x = 3) == 26\n assert candidate(nums = [8, 6, 4, 2, 0, 2, 4, 6, 8],x = 1) == 8\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],x = 10) == 100\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 100) == 10\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10],x = 10) == 55\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3],x = 7) == 52\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],x = 2) == 70\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 5) == 75\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],x = 20) == 200\n assert candidate(nums = [1000000000, 1000000000, 1000000000],x = 1000000000) == 3000000000\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],x = 15) == 55\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 2) == 28\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 100) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],x = 3) == 62\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 5) == 45\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 1) == 10\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1],x = 500000000) == 500000005\n assert candidate(nums = [10, 20, 30, 40, 50],x = 15) == 105\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000],x = 500000000) == 1000000005\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 5) == 105\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],x = 5) == 96\n assert candidate(nums = [7, 8, 9, 10, 11, 7, 8, 9, 10, 11],x = 2) == 78\n assert candidate(nums = [100, 200, 150, 100, 50],x = 75) == 500\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 5) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 7) == 92\n assert candidate(nums = [3, 1, 2, 1, 3, 1, 2, 1, 3, 1],x = 1) == 11\n assert candidate(nums = [1, 10, 100, 1000, 10000],x = 1000) == 2112\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 3) == 34\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1],x = 100000000) == 100000010\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 1) == 17\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],x = 2) == 24\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],x = 25) == 525\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 16, 17, 18, 19, 20],x = 10) == 165\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],x = 1) == 10000\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8],x = 2) == 23\n assert candidate(nums = [5, 9, 3, 8, 2, 7, 4, 6, 1],x = 10) == 35\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],x = 7) == 34\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 25) == 305\n assert candidate(nums = [29, 10, 6, 3, 5, 30, 50, 100, 3, 8, 9, 12, 15, 16, 20, 23, 25, 28, 30, 32],x = 15) == 220\n assert candidate(nums = [1, 3, 2, 4, 5],x = 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],x = 1) == 20\n assert candidate(nums = [7, 8, 9, 1, 2, 3, 4, 5, 6],x = 3) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 10) == 190\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 1) == 17\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],x = 500000000) == 4000000000\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7],x = 8) == 56\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 500) == 4500\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 15) == 55\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],x = 7) == 248\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],x = 5) == 145\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],x = 7) == 34\n assert candidate(nums = [10, 20, 30, 40, 50],x = 7) == 78\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],x = 5) == 145\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 5) == 51\n assert candidate(nums = [5, 4, 3, 2, 1],x = 1) == 9\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],x = 1000000000) == 4000000000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],x = 10) == 135\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 0],x = 4) == 21\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 10) == 80\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1],x = 100000000) == 100000010\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],x = 3) == 140\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 10) == 45\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 50) == 1450\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 2) == 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],x = 100) == 100\n assert candidate(nums = [3, 2, 1, 4, 5],x = 2) == 12\n assert candidate(nums = [10, 1, 10, 1, 10],x = 5) == 15\n assert candidate(nums = [10, 10, 1, 10, 10],x = 2) == 13\n assert candidate(nums = [50, 40, 30, 20, 10, 100, 90, 80, 70, 60],x = 15) == 230\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],x = 20) == 231\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000],x = 50000) == 61112\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 100) == 1900\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],x = 1) == 19\n assert candidate(nums = [1000000000, 1000000000, 1000000000],x = 500000000) == 3000000000\n assert candidate(nums = [10, 20, 30, 40, 50],x = 5) == 70\n"}, "metadata": {"canonical_parameter_names": ["nums", "x"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minCost(int[] nums, int x) {", "container": "Solution", "callable": "minCost", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "x", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2736, "task_id": "maximum-sum-queries", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2, each of length n, and a 1-indexed 2D array queries where queries[i] = [xi, yi].\nFor the ith query, find the maximum value of nums1[j] + nums2[j] among all indices j (0 <= j < n), where nums1[j] >= xi and nums2[j] >= yi, or -1 if there is no j satisfying the constraints.\nReturn an array answer where answer[i] is the answer to the ith query.\n \nExample 1:\n\nInput: nums1 = [4,3,1,2], nums2 = [2,4,9,5], queries = [[4,1],[1,3],[2,5]]\nOutput: [6,10,7]\nExplanation: \nFor the 1st query xi = 4 and yi = 1, we can select index j = 0 since nums1[j] >= 4 and nums2[j] >= 1. The sum nums1[j] + nums2[j] is 6, and we can show that 6 is the maximum we can obtain.\n\nFor the 2nd query xi = 1 and yi = 3, we can select index j = 2 since nums1[j] >= 1 and nums2[j] >= 3. The sum nums1[j] + nums2[j] is 10, and we can show that 10 is the maximum we can obtain. \n\nFor the 3rd query xi = 2 and yi = 5, we can select index j = 3 since nums1[j] >= 2 and nums2[j] >= 5. The sum nums1[j] + nums2[j] is 7, and we can show that 7 is the maximum we can obtain.\n\nTherefore, we return [6,10,7].\n\nExample 2:\n\nInput: nums1 = [3,2,5], nums2 = [2,3,4], queries = [[4,4],[3,2],[1,1]]\nOutput: [9,9,9]\nExplanation: For this example, we can use index j = 2 for all the queries since it satisfies the constraints for each query.\n\nExample 3:\n\nInput: nums1 = [2,1], nums2 = [2,3], queries = [[3,3]]\nOutput: [-1]\nExplanation: There is one query in this example with xi = 3 and yi = 3. For every index, j, either nums1[j] < xi or nums2[j] < yi. Hence, there is no solution. \n\n \nConstraints:\n\nnums1.length == nums2.length \nn == nums1.length \n1 <= n <= 105\n1 <= nums1[i], nums2[i] <= 109 \n1 <= queries.length <= 105\nqueries[i].length == 2\nxi == queries[i][1]\nyi == queries[i][2]\n1 <= xi, yi <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [4, 3, 1, 2],nums2 = [2, 4, 9, 5],queries = [[4, 1], [1, 3], [2, 5]]) == [6, 10, 7]\n assert candidate(nums1 = [2, 1],nums2 = [2, 3],queries = [[3, 3]]) == [-1]\n assert candidate(nums1 = [3, 2, 5],nums2 = [2, 3, 4],queries = [[4, 4], [3, 2], [1, 1]]) == [9, 9, 9]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [9, 7, 5, 3, 1],queries = [[2, 8], [4, 6], [6, 4], [8, 2], [10, 0]]) == [-1, -1, -1, -1, -1]\n assert candidate(nums1 = [1000000000, 1000000000, 1000000000],nums2 = [1000000000, 1000000000, 1000000000],queries = [[1000000000, 1000000000], [999999999, 999999999]]) == [2000000000, 2000000000]\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [2, -1, -1, -1, -1]\n assert candidate(nums1 = [9, 18, 27, 36, 45],nums2 = [45, 36, 27, 18, 9],queries = [[15, 30], [18, 18], [21, 24], [24, 21], [30, 15]]) == [54, 54, 54, 54, 54]\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [10, 20, 30, 40, 50],queries = [[150, 15], [250, 25], [350, 35], [450, 45], [550, 55]]) == [550, 550, 550, 550, -1]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [10, 20, 30, 40, 50],queries = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55]]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, -1]\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],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],queries = [[150, 850], [250, 750], [350, 650], [450, 550], [550, 450], [650, 350], [750, 250], [850, 150], [950, 50], [1050, -50]]) == [1100, 1100, 1100, 1100, 1100, 1100, 1100, 1100, 1100, -1]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],queries = [[2, 18], [4, 16], [6, 14], [8, 12], [10, 10], [12, 8], [14, 6], [16, 4], [18, 2], [20, 0]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[15, 85], [25, 75], [35, 65], [45, 55], [55, 45], [65, 35], [75, 25], [85, 15]]) == [110, 110, 110, 110, 110, 110, 110, 110]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],queries = [[15, 35], [25, 25], [35, 15], [45, 5], [55, 55]]) == [60, 60, 60, 60, -1]\n assert candidate(nums1 = [500, 400, 300, 200, 100],nums2 = [100, 200, 300, 400, 500],queries = [[150, 350], [250, 250], [350, 150], [450, 50], [550, 500]]) == [600, 600, 600, 600, -1]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9], [8, 8], [9, 7], [10, 6], [11, 5], [12, 4], [13, 3], [14, 2], [15, 1]]) == [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]\n assert candidate(nums1 = [1000000000, 999999999, 999999998, 999999997, 999999996],nums2 = [1, 2, 3, 4, 5],queries = [[999999999, 1], [999999998, 2], [999999997, 3], [999999996, 4], [999999995, 5]]) == [1000000001, 1000000001, 1000000001, 1000000001, 1000000001]\n assert candidate(nums1 = [5, 8, 12, 16, 20],nums2 = [20, 16, 12, 8, 5],queries = [[10, 10], [15, 5], [5, 20], [8, 12]]) == [24, 25, 25, 24]\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],queries = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0]]) == [11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],queries = [[2, 18], [18, 2], [10, 10], [5, 15], [15, 5]]) == [-1, -1, -1, 20, 20]\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [[5, 5], [4, 6], [3, 7], [2, 8], [1, 9], [10, 0], [0, 10]]) == [10, 10, 10, 10, 10, -1, -1]\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5],queries = [[5, 5], [6, 5], [5, 6], [4, 4]]) == [10, -1, -1, 10]\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(nums1 = [1, 10, 100, 1000, 10000],nums2 = [10000, 1000, 100, 10, 1],queries = [[1, 10000], [10, 1000], [100, 100], [1000, 10], [10000, 1]]) == [10001, 1010, 200, 1010, 10001]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[5, 95], [15, 85], [25, 75], [35, 65], [45, 55], [55, 45], [65, 35], [75, 25], [85, 15], [95, 5], [105, 0]]) == [110, 110, 110, 110, 110, 110, 110, 110, 110, 110, -1]\n assert candidate(nums1 = [500000, 400000, 300000, 200000, 100000],nums2 = [1, 2, 3, 4, 5],queries = [[400000, 2], [500000, 5], [300000, 3], [100000, 1]]) == [400002, -1, 300003, 500001]\n assert candidate(nums1 = [10, 10, 10, 10, 10],nums2 = [10, 10, 10, 10, 10],queries = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]) == [20, 20, -1, -1, -1]\n assert candidate(nums1 = [1000000000, 1000000000, 1000000000],nums2 = [1000000000, 1000000000, 1000000000],queries = [[1000000000, 1000000000], [500000000, 500000000], [1000000000, 999999999]]) == [2000000000, 2000000000, 2000000000]\n assert candidate(nums1 = [1000000000, 1000000000, 1000000000, 1000000000],nums2 = [1000000000, 1000000000, 1000000000, 1000000000],queries = [[1000000000, 1000000000], [1, 1]]) == [2000000000, 2000000000]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],queries = [[1, 20], [3, 18], [5, 16], [7, 14], [9, 12], [11, 10], [13, 8], [15, 6], [17, 4], [19, 2]]) == [21, 21, 21, 21, 21, 21, 21, 21, 21, 21]\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5],queries = [[5, 5], [5, 4], [4, 5], [4, 4], [3, 3]]) == [10, 10, 10, 10, 10]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],queries = [[15, 35], [25, 25], [35, 15], [5, 45], [45, 5], [10, 50], [50, 10]]) == [60, 60, 60, 60, 60, 60, 60]\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums1 = [1000000000, 500000000, 250000000],nums2 = [250000000, 500000000, 1000000000],queries = [[500000000, 250000000], [250000000, 500000000], [750000000, 750000000]]) == [1250000000, 1250000000, -1]\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums2 = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5],queries = [[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10], [100, 0]]) == [-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 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5],queries = [[1, 48], [6, 43], [11, 38], [16, 33], [21, 28], [26, 23], [31, 18], [36, 13], [41, 8], [46, 3], [51, -2]]) == [55, 55, 55, 55, 55, 55, 55, 55, 55, 55, -1]\n assert candidate(nums1 = [5, 15, 25, 35, 45],nums2 = [45, 35, 25, 15, 5],queries = [[10, 40], [20, 30], [30, 20], [40, 10], [50, 0]]) == [-1, -1, -1, -1, -1]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],queries = [[10, 50], [30, 30], [25, 25], [45, 5], [55, 55]]) == [60, 60, 60, 60, -1]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],queries = [[500, 500], [150, 850], [950, 50], [200, 700], [400, 600]]) == [1100, 1100, 1100, 1100, 1100]\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5],queries = [[5, 5], [5, 6], [6, 5], [4, 4], [6, 6]]) == [10, -1, -1, 10, -1]\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],queries = [[1, 10], [10, 1], [5, 5], [3, 7], [7, 3]]) == [11, 11, 11, 11, 11]\n assert candidate(nums1 = [1000000000, 999999999, 1, 2, 3],nums2 = [3, 4, 1000000000, 5, 6],queries = [[999999999, 2], [1, 3], [5, 4], [1000000000, 1000000000]]) == [1000000003, 1000000003, 1000000003, -1]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],queries = [[10, 5], [25, 15], [30, 25], [45, 35], [55, 50]]) == [95, 95, 95, 95, -1]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[2, 14], [4, 12], [6, 10], [8, 8], [10, 6], [12, 4], [14, 2], [16, 0]]) == [16, 16, 16, 16, 16, 16, 16, -1]\n assert candidate(nums1 = [1000000000, 999999999, 999999998, 999999997, 999999996],nums2 = [999999996, 999999997, 999999998, 999999999, 1000000000],queries = [[999999997, 999999998], [999999998, 999999999], [1000000000, 1000000000], [999999995, 999999995], [999999996, 999999997]]) == [1999999996, -1, -1, 1999999996, 1999999996]\n assert candidate(nums1 = [1, 5, 7, 9, 11, 13],nums2 = [15, 13, 11, 9, 7, 5],queries = [[1, 15], [7, 9], [10, 10], [12, 12], [14, 14], [16, 16]]) == [16, 18, -1, -1, -1, -1]\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[100, 1], [90, 2], [80, 3], [70, 4], [60, 5], [50, 6], [40, 7], [30, 8], [20, 9], [10, 10]]) == [101, 92, 83, 74, 65, 56, 47, 38, 29, 20]\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100],queries = [[50, 450], [150, 350], [250, 250], [350, 150], [450, 50], [550, 0]]) == [600, 600, 600, 600, 600, -1]\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],nums2 = [30, 27, 24, 21, 18, 15, 12, 9, 6, 3],queries = [[3, 30], [6, 27], [9, 24], [12, 21], [15, 18], [18, 15], [21, 12], [24, 9], [27, 6], [30, 3]]) == [33, 33, 33, 33, 33, 33, 33, 33, 33, 33]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10], [100, 0]]) == [110, 110, 110, 110, 110, 110, 110, 110, 110, 110]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],queries = [[15, 35], [25, 25], [35, 15], [45, 5]]) == [60, 60, 60, 60]\n assert candidate(nums1 = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[500, 1], [500, 2], [500, 3], [500, 4], [500, 5], [500, 6], [500, 7], [500, 8], [500, 9], [500, 10]]) == [510, 510, 510, 510, 510, 510, 510, 510, 510, 510]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],queries = [[15, 45], [25, 25], [35, 15], [5, 50]]) == [-1, 60, 60, 60]\n assert candidate(nums1 = [5, 15, 25, 35, 45],nums2 = [45, 35, 25, 15, 5],queries = [[5, 45], [15, 35], [25, 25], [35, 15], [45, 5]]) == [50, 50, 50, 50, 50]\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 10]]) == [11, 11, 11, 11, 11, 11, 11]\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],queries = [[5, 6], [6, 5], [4, 7], [7, 4], [3, 8], [8, 3], [2, 9], [9, 2], [1, 10], [10, 1]]) == [11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(nums1 = [500, 400, 300, 200, 100],nums2 = [100, 200, 300, 400, 500],queries = [[300, 200], [200, 300], [400, 100], [100, 400], [250, 250]]) == [600, 600, 600, 600, 600]\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],queries = [[5, 6], [6, 5], [7, 4], [4, 7], [8, 3], [3, 8], [9, 2], [2, 9], [10, 1], [1, 10]]) == [11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],queries = [[100, 1000], [200, 900], [300, 800], [400, 700], [500, 600], [600, 500], [700, 400], [800, 300], [900, 200], [1000, 100]]) == [1100, 1100, 1100, 1100, 1100, 1100, 1100, 1100, 1100, 1100]\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [5000, 4000, 3000, 2000, 1000],queries = [[1500, 4500], [2500, 3500], [3500, 2500], [4500, 1500]]) == [-1, -1, -1, -1]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]]) == [110, 110, 110, 110, 110, 110, 110, 110, 110, 110]\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],queries = [[5, 6], [6, 5], [1, 10], [10, 1], [3, 8], [8, 3], [2, 9], [9, 2]]) == [11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(nums1 = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10],nums2 = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [17, 17, 17, 17, 17, 17, 17, 17, -1, -1]\n assert candidate(nums1 = [5, 8, 3, 9, 2],nums2 = [6, 4, 10, 1, 7],queries = [[3, 4], [6, 6], [2, 8], [9, 1], [7, 7], [5, 5]]) == [13, -1, 13, 10, -1, 11]\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],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 0], [0, 11]]) == [11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -1, -1]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],queries = [[15, 45], [25, 25], [35, 15], [45, 5], [55, 55]]) == [-1, 60, 60, 60, -1]\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100],queries = [[150, 450], [250, 350], [350, 250], [450, 150], [550, 50]]) == [-1, -1, -1, -1, -1]\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6],queries = [[1, 11], [1, 10], [1, 9], [1, 8], [1, 7]]) == [-1, 11, 11, 11, 11]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10],queries = [[55, 5], [5, 55], [25, 25], [35, 15], [15, 35]]) == [-1, -1, 60, 60, 60]\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5],queries = [[5, 5], [6, 5], [5, 6], [4, 4], [6, 6]]) == [10, -1, -1, 10, -1]\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],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [2, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],queries = [[10, 10], [20, 20], [1, 1], [19, 1], [1, 19]]) == [-1, -1, 20, 20, 20]\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],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [2, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums1 = [1, 10, 100, 1000, 10000],nums2 = [10000, 1000, 100, 10, 1],queries = [[5000, 5000], [500, 500], [50, 50], [5, 5], [1, 1]]) == [-1, -1, 200, 1010, 10001]\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[5, 5], [1, 10], [10, 1], [6, 4], [4, 6]]) == [11, 11, 11, 11, 11]\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],queries = [[1, 1], [2, 2], [0, 0]]) == [2, -1, 2]\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],queries = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == [110, 110, 110, 110, 110, 110, 110, 110, 110, 110]\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "queries"], "leetcode_dataset_entry_point": "Solution().maximumSumQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] maximumSumQueries(int[] nums1, int[] nums2, int[][] queries) {", "container": "Solution", "callable": "maximumSumQueries", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}, {"name": "queries", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2739, "task_id": "total-distance-traveled", "difficulty": "Easy", "problem_description": "A truck has two fuel tanks. You are given two integers, mainTank representing the fuel present in the main tank in liters and additionalTank representing the fuel present in the additional tank in liters.\nThe truck has a mileage of 10 km per liter. Whenever 5 liters of fuel get used up in the main tank, if the additional tank has at least 1 liters of fuel, 1 liters of fuel will be transferred from the additional tank to the main tank.\nReturn the maximum distance which can be traveled.\nNote: Injection from the additional tank is not continuous. It happens suddenly and immediately for every 5 liters consumed.\n \nExample 1:\n\nInput: mainTank = 5, additionalTank = 10\nOutput: 60\nExplanation: \nAfter spending 5 litre of fuel, fuel remaining is (5 - 5 + 1) = 1 litre and distance traveled is 50km.\nAfter spending another 1 litre of fuel, no fuel gets injected in the main tank and the main tank becomes empty.\nTotal distance traveled is 60km.\n\nExample 2:\n\nInput: mainTank = 1, additionalTank = 2\nOutput: 10\nExplanation: \nAfter spending 1 litre of fuel, the main tank becomes empty.\nTotal distance traveled is 10km.\n\n\n \nConstraints:\n\n1 <= mainTank, additionalTank <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mainTank = 10,additionalTank = 0) == 100\n assert candidate(mainTank = 100,additionalTank = 100) == 1240\n assert candidate(mainTank = 5,additionalTank = 10) == 60\n assert candidate(mainTank = 3,additionalTank = 0) == 30\n assert candidate(mainTank = 7,additionalTank = 3) == 80\n assert candidate(mainTank = 0,additionalTank = 5) == 0\n assert candidate(mainTank = 1,additionalTank = 2) == 10\n assert candidate(mainTank = 0,additionalTank = 10) == 0\n assert candidate(mainTank = 10,additionalTank = 5) == 120\n assert candidate(mainTank = 0,additionalTank = 50) == 0\n assert candidate(mainTank = 20,additionalTank = 0) == 200\n assert candidate(mainTank = 20,additionalTank = 20) == 240\n assert candidate(mainTank = 5,additionalTank = 0) == 50\n assert candidate(mainTank = 45,additionalTank = 5) == 500\n assert candidate(mainTank = 80,additionalTank = 10) == 900\n assert candidate(mainTank = 55,additionalTank = 0) == 550\n assert candidate(mainTank = 15,additionalTank = 1) == 160\n assert candidate(mainTank = 1,additionalTank = 50) == 10\n assert candidate(mainTank = 3,additionalTank = 20) == 30\n assert candidate(mainTank = 50,additionalTank = 50) == 620\n assert candidate(mainTank = 25,additionalTank = 30) == 310\n assert candidate(mainTank = 25,additionalTank = 10) == 310\n assert candidate(mainTank = 5,additionalTank = 25) == 60\n assert candidate(mainTank = 80,additionalTank = 20) == 990\n assert candidate(mainTank = 30,additionalTank = 3) == 330\n assert candidate(mainTank = 50,additionalTank = 15) == 620\n assert candidate(mainTank = 49,additionalTank = 5) == 540\n assert candidate(mainTank = 45,additionalTank = 50) == 560\n assert candidate(mainTank = 3,additionalTank = 4) == 30\n assert candidate(mainTank = 30,additionalTank = 30) == 370\n assert candidate(mainTank = 7,additionalTank = 1) == 80\n assert candidate(mainTank = 99,additionalTank = 99) == 1230\n assert candidate(mainTank = 75,additionalTank = 15) == 900\n assert candidate(mainTank = 9,additionalTank = 3) == 110\n assert candidate(mainTank = 60,additionalTank = 30) == 740\n assert candidate(mainTank = 9,additionalTank = 2) == 110\n assert candidate(mainTank = 15,additionalTank = 2) == 170\n assert candidate(mainTank = 50,additionalTank = 10) == 600\n assert candidate(mainTank = 75,additionalTank = 20) == 930\n assert candidate(mainTank = 5,additionalTank = 50) == 60\n assert candidate(mainTank = 8,additionalTank = 1) == 90\n assert candidate(mainTank = 30,additionalTank = 0) == 300\n assert candidate(mainTank = 99,additionalTank = 1) == 1000\n assert candidate(mainTank = 30,additionalTank = 8) == 370\n assert candidate(mainTank = 40,additionalTank = 30) == 490\n assert candidate(mainTank = 10,additionalTank = 99) == 120\n assert candidate(mainTank = 80,additionalTank = 3) == 830\n assert candidate(mainTank = 3,additionalTank = 7) == 30\n assert candidate(mainTank = 9,additionalTank = 10) == 110\n assert candidate(mainTank = 15,additionalTank = 0) == 150\n assert candidate(mainTank = 75,additionalTank = 25) == 930\n assert candidate(mainTank = 49,additionalTank = 10) == 590\n assert candidate(mainTank = 25,additionalTank = 0) == 250\n assert candidate(mainTank = 75,additionalTank = 30) == 930\n assert candidate(mainTank = 24,additionalTank = 6) == 290\n assert candidate(mainTank = 45,additionalTank = 30) == 560\n assert candidate(mainTank = 99,additionalTank = 100) == 1230\n assert candidate(mainTank = 25,additionalTank = 5) == 300\n assert candidate(mainTank = 45,additionalTank = 10) == 550\n assert candidate(mainTank = 80,additionalTank = 8) == 880\n assert candidate(mainTank = 49,additionalTank = 2) == 510\n assert candidate(mainTank = 50,additionalTank = 25) == 620\n assert candidate(mainTank = 30,additionalTank = 15) == 370\n assert candidate(mainTank = 100,additionalTank = 1) == 1010\n assert candidate(mainTank = 25,additionalTank = 25) == 310\n assert candidate(mainTank = 25,additionalTank = 15) == 310\n assert candidate(mainTank = 60,additionalTank = 25) == 740\n assert candidate(mainTank = 60,additionalTank = 0) == 600\n assert candidate(mainTank = 8,additionalTank = 7) == 90\n assert candidate(mainTank = 5,additionalTank = 20) == 60\n assert candidate(mainTank = 2,additionalTank = 10) == 20\n assert candidate(mainTank = 5,additionalTank = 5) == 60\n assert candidate(mainTank = 30,additionalTank = 10) == 370\n assert candidate(mainTank = 8,additionalTank = 3) == 90\n assert candidate(mainTank = 60,additionalTank = 15) == 740\n assert candidate(mainTank = 10,additionalTank = 9) == 120\n assert candidate(mainTank = 100,additionalTank = 0) == 1000\n assert candidate(mainTank = 5,additionalTank = 4) == 60\n assert candidate(mainTank = 4,additionalTank = 5) == 40\n"}, "metadata": {"canonical_parameter_names": ["mainTank", "additionalTank"], "leetcode_dataset_entry_point": "Solution().distanceTraveled", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int distanceTraveled(int mainTank, int additionalTank) {", "container": "Solution", "callable": "distanceTraveled", "parameters": [{"name": "mainTank", "type": "int"}, {"name": "additionalTank", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2740, "task_id": "find-the-value-of-the-partition", "difficulty": "Medium", "problem_description": "You are given a positive integer array nums.\nPartition nums into two arrays, nums1 and nums2, such that:\n\nEach element of the array nums belongs to either the array nums1 or the array nums2.\nBoth arrays are non-empty.\nThe value of the partition is minimized.\n\nThe value of the partition is |max(nums1) - min(nums2)|.\nHere, max(nums1) denotes the maximum element of the array nums1, and min(nums2) denotes the minimum element of the array nums2.\nReturn the integer denoting the value of such partition.\n \nExample 1:\n\nInput: nums = [1,3,2,4]\nOutput: 1\nExplanation: We can partition the array nums into nums1 = [1,2] and nums2 = [3,4].\n- The maximum element of the array nums1 is equal to 2.\n- The minimum element of the array nums2 is equal to 3.\nThe value of the partition is |2 - 3| = 1. \nIt can be proven that 1 is the minimum value out of all partitions.\n\nExample 2:\n\nInput: nums = [100,1,10]\nOutput: 9\nExplanation: We can partition the array nums into nums1 = [10] and nums2 = [100,1].\n- The maximum element of the array nums1 is equal to 10.\n- The minimum element of the array nums2 is equal to 1.\nThe value of the partition is |10 - 1| = 9.\nIt can be proven that 9 is the minimum value out of all partitions.\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 = [1, 1000000000]) == 999999999\n assert candidate(nums = [5, 1, 3, 2, 4]) == 1\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [5, 1, 3, 19, 18]) == 1\n assert candidate(nums = [5, 6, 1, 4, 2]) == 1\n assert candidate(nums = [4, 2, 1, 3]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 10\n assert candidate(nums = [5, 2, 3, 1, 4]) == 1\n assert candidate(nums = [2, 3, 1, 2]) == 0\n assert candidate(nums = [2, 2, 2, 2]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [100, 1, 10]) == 9\n assert candidate(nums = [1, 3, 2, 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, 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\n assert candidate(nums = [500000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1000000000]) == 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]) == 5\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 100\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [50, 20, 30, 10, 40, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 10\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 = [50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [99, 100, 98, 97, 96, 95]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 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, 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]) == 1\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == 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]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 999999999, 99999999, 9999999, 999999, 99999, 9999, 999, 99, 9, 8]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\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\n assert candidate(nums = [5, 3, 1, 9, 7, 2, 8, 6, 4, 10, 12, 11, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [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, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995, 7, 999999994, 8, 999999993, 9, 999999992]) == 1\n assert candidate(nums = [7, 12, 1, 5, 3, 8, 6, 10, 2, 4, 9, 11]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 2\n assert candidate(nums = [999999999, 1000000000, 1, 2, 3, 4, 5, 6, 7, 8]) == 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]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 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 = [500000000, 400000000, 300000000, 200000000, 100000000, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 0\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 1\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 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\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1]) == 9\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 10\n assert candidate(nums = [1000000000, 1, 999999999, 2, 999999998, 3, 999999997, 4, 999999996, 5]) == 1\n assert candidate(nums = [1, 500000000, 2, 400000000, 3, 300000000, 4, 200000000, 5, 100000000]) == 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]) == 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, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 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]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(nums = [7, 3, 10, 1, 5, 8, 6, 9, 2, 4]) == 1\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, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 9\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 0\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 10000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 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]) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1000000000]) == 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, 10, 10, 10]) == 0\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 1\n assert candidate(nums = [9, 7, 5, 3, 1, 10, 8, 6, 4, 2]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5]) == 5\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]) == 1\n assert candidate(nums = [1, 2, 3, 1000000000]) == 1\n assert candidate(nums = [100, 50, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600]) == 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]) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == 0\n assert candidate(nums = [1000000000, 1, 999999999, 2, 999999998, 3, 999999997]) == 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, 42, 44, 46, 48, 50]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 1\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 1\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 1\n assert candidate(nums = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005, 500000006, 500000007, 500000008, 500000009]) == 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]) == 2\n assert candidate(nums = [7, 15, 2, 8, 9, 10, 11, 12, 3, 6, 4, 5]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 51, 60, 70, 80, 90]) == 1\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 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]) == 0\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [1000000000, 1, 2, 3, 999999999]) == 1\n assert candidate(nums = [7, 10, 3, 15, 8, 12]) == 1\n assert candidate(nums = [10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [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, 1000000000]) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 10\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findValueOfPartition", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findValueOfPartition(int[] nums) {", "container": "Solution", "callable": "findValueOfPartition", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2741, "task_id": "special-permutations", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums containing n distinct positive integers. A permutation of nums is called special if:\n\nFor all indexes 0 <= i < n - 1, either nums[i] % nums[i+1] == 0 or nums[i+1] % nums[i] == 0.\n\nReturn the total number of special permutations. As the answer could be large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [2,3,6]\nOutput: 2\nExplanation: [3,6,2] and [2,6,3] are the two special permutations of nums.\n\nExample 2:\n\nInput: nums = [1,4,3]\nOutput: 2\nExplanation: [3,1,4] and [4,1,3] are the two special permutations of nums.\n\n \nConstraints:\n\n2 <= nums.length <= 14\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [31, 62, 93, 124, 155]) == 0\n assert candidate(nums = [2, 3, 6]) == 2\n assert candidate(nums = [17, 34, 51, 68, 85]) == 0\n assert candidate(nums = [7, 14, 28, 56, 112]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 0\n assert candidate(nums = [5, 10, 20, 40]) == 24\n assert candidate(nums = [11, 22, 33, 44]) == 4\n assert candidate(nums = [1, 4, 3]) == 2\n assert candidate(nums = [2, 4, 8, 16]) == 24\n assert candidate(nums = [19, 38, 57, 76, 95]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 0\n assert candidate(nums = [3, 5, 15, 7]) == 0\n assert candidate(nums = [4, 2, 6, 3]) == 2\n assert candidate(nums = [7, 14, 28, 56, 112, 224]) == 720\n assert candidate(nums = [2, 4, 8, 16, 32]) == 120\n assert candidate(nums = [7, 14, 28, 21]) == 4\n assert candidate(nums = [13, 26, 39, 52, 65]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25]) == 0\n assert candidate(nums = [29, 58, 87, 116, 145]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55]) == 0\n assert candidate(nums = [23, 46, 69, 92, 115]) == 0\n assert candidate(nums = [3, 9, 27, 81]) == 24\n assert candidate(nums = [3, 5, 15, 75]) == 12\n assert candidate(nums = [4, 6, 12, 24]) == 12\n assert candidate(nums = [2, 4, 6, 8]) == 4\n assert candidate(nums = [2, 3, 6, 12, 18, 36]) == 336\n assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480]) == 227020758\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126]) == 0\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182]) == 0\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238]) == 0\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112]) == 0\n assert candidate(nums = [2, 3, 5, 6, 10, 15, 30]) == 120\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 0\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56]) == 0\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238]) == 0\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969]) == 178290591\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154]) == 0\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126]) == 0\n assert candidate(nums = [5, 10, 20, 25, 50, 100, 125, 200, 250, 500]) == 136208\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]) == 0\n assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133]) == 0\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969]) == 178290591\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]) == 0\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35]) == 0\n assert candidate(nums = [12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304]) == 178290591\n assert candidate(nums = [2, 3, 6, 9, 12, 18, 24]) == 280\n assert candidate(nums = [1, 3, 9, 27, 81, 243]) == 720\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 0\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350]) == 0\n assert candidate(nums = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512]) == 334499784\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 178290591\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 178290591\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 3628800\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 0\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182]) == 0\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323]) == 178290591\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99]) == 0\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512]) == 40320\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125]) == 362880\n assert candidate(nums = [2, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78]) == 0\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 253, 276, 299, 322]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42]) == 4\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]) == 0\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024]) == 40320\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294]) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 3628800\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240]) == 39916800\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135]) == 0\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 178290591\n assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960]) == 178290591\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 253, 276, 299, 322]) == 0\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344]) == 178290591\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 0\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266, 285]) == 0\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == 3628800\n assert candidate(nums = [2, 3, 5, 6, 10, 15, 30, 60, 120, 240, 480, 720, 1440, 2880]) == 180479895\n assert candidate(nums = [5, 10, 20, 25, 50]) == 20\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154]) == 0\n assert candidate(nums = [2, 6, 18, 54, 162, 486, 1458, 4374, 13122, 39366, 118098, 354294, 1062882, 3188646]) == 178290591\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 178290591\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156]) == 0\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112]) == 0\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, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]) == 0\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 319, 348, 377, 406]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().specialPerm", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int specialPerm(int[] nums) {", "container": "Solution", "callable": "specialPerm", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2742, "task_id": "painting-the-walls", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays, cost and time, of size n representing the costs and the time taken to paint n different walls respectively. There are two painters available:\n\nA paid painter that paints the ith wall in time[i] units of time and takes cost[i] units of money.\nA free painter that paints any wall in 1 unit of time at a cost of 0. But the free painter can only be used if the paid painter is already occupied.\n\nReturn the minimum amount of money required to paint the n walls.\n \nExample 1:\n\nInput: cost = [1,2,3,2], time = [1,2,3,2]\nOutput: 3\nExplanation: The walls at index 0 and 1 will be painted by the paid painter, and it will take 3 units of time; meanwhile, the free painter will paint the walls at index 2 and 3, free of cost in 2 units of time. Thus, the total cost is 1 + 2 = 3.\n\nExample 2:\n\nInput: cost = [2,3,4,2], time = [1,1,1,1]\nOutput: 4\nExplanation: The walls at index 0 and 3 will be painted by the paid painter, and it will take 2 units of time; meanwhile, the free painter will paint the walls at index 1 and 2, free of cost in 2 units of time. Thus, the total cost is 2 + 2 = 4.\n\n \nConstraints:\n\n1 <= cost.length <= 500\ncost.length == time.length\n1 <= cost[i] <= 106\n1 <= time[i] <= 500\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cost = [4, 4, 4, 4],time = [4, 4, 4, 4]) == 4\n assert candidate(cost = [5, 8, 4, 3],time = [2, 3, 1, 2]) == 7\n assert candidate(cost = [10, 20, 30, 40],time = [5, 4, 3, 2]) == 10\n assert candidate(cost = [10, 20, 30, 40, 50],time = [5, 4, 3, 2, 1]) == 10\n assert candidate(cost = [5, 1, 4, 9],time = [2, 1, 3, 4]) == 4\n assert candidate(cost = [100, 200, 300],time = [1, 2, 3]) == 200\n assert candidate(cost = [1000000, 500000, 750000],time = [500, 250, 375]) == 500000\n assert candidate(cost = [10, 15, 10],time = [3, 4, 2]) == 10\n assert candidate(cost = [2, 3, 4, 2],time = [1, 1, 1, 1]) == 4\n assert candidate(cost = [3, 2, 1],time = [1, 2, 3]) == 1\n assert candidate(cost = [1, 2, 3, 2],time = [1, 2, 3, 2]) == 3\n assert candidate(cost = [10, 15, 10],time = [2, 3, 2]) == 10\n assert candidate(cost = [1000, 2000, 3000],time = [10, 20, 30]) == 1000\n assert candidate(cost = [1, 3, 5, 7, 9],time = [9, 7, 5, 3, 1]) == 1\n assert candidate(cost = [1, 1, 1, 1, 1],time = [1, 1, 1, 1, 1]) == 3\n assert candidate(cost = [5, 10, 15],time = [2, 3, 4]) == 5\n assert candidate(cost = [3, 1, 7, 8, 5],time = [2, 1, 4, 5, 3]) == 4\n assert candidate(cost = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250],time = [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]) == 750\n assert candidate(cost = [500000, 400000, 300000, 200000, 100000],time = [100, 200, 300, 400, 500]) == 100000\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(cost = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600],time = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(cost = [12, 18, 15, 25, 30, 20],time = [2, 3, 4, 5, 6, 7]) == 20\n assert candidate(cost = [1000000, 999999, 888888, 777777, 666666],time = [1, 2, 3, 4, 5]) == 666666\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1500\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(cost = [999999, 999998, 999997, 999996, 999995, 999994],time = [500, 499, 498, 497, 496, 495]) == 999994\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],time = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(cost = [10, 20, 30, 20, 10, 30],time = [2, 1, 3, 1, 2, 3]) == 20\n assert candidate(cost = [5, 15, 10, 20, 25],time = [1, 3, 2, 4, 5]) == 15\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],time = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(cost = [500, 250, 125, 63, 32, 16, 8, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 200, 300, 400, 500, 1, 2, 3, 4, 5]) == 1\n assert candidate(cost = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 25\n assert candidate(cost = [5000, 4000, 3000, 2000, 1000, 500, 400, 300, 200, 100],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(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],time = [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]) == 20\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],time = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110\n assert candidate(cost = [100, 200, 150, 300, 250],time = [2, 3, 1, 4, 2]) == 250\n assert candidate(cost = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500],time = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 1000\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 150\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 70\n assert candidate(cost = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],time = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(cost = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 100\n assert candidate(cost = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 999990\n assert candidate(cost = [10000, 20000, 30000, 40000, 50000],time = [1, 1, 1, 1, 1]) == 60000\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],time = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 300\n assert candidate(cost = [100000, 200000, 150000, 50000, 120000, 300000],time = [300, 400, 200, 100, 500, 600]) == 50000\n assert candidate(cost = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 75\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 1\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],time = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 300\n assert candidate(cost = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 70000\n assert candidate(cost = [5, 10, 15, 20, 25, 30],time = [2, 3, 4, 5, 6, 7]) == 15\n assert candidate(cost = [1000000, 500000, 250000, 125000],time = [10, 20, 30, 40]) == 125000\n assert candidate(cost = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],time = [29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 3, 5, 7, 11, 13]) == 2\n assert candidate(cost = [10000, 20000, 30000, 40000, 50000],time = [1, 2, 3, 4, 5]) == 30000\n assert candidate(cost = [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995, 5],time = [5, 4, 3, 2, 1, 500, 400, 300, 200, 100]) == 3\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 700\n assert candidate(cost = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],time = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 500000\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(cost = [300, 200, 100, 400, 500, 150, 250],time = [3, 2, 1, 4, 5, 2, 3]) == 400\n assert candidate(cost = [3, 7, 8, 6, 5, 4, 2, 1, 9],time = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(cost = [999999, 1000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 66\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(cost = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1000\n assert candidate(cost = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 75\n assert candidate(cost = [100000, 200000, 300000, 400000, 500000],time = [10, 20, 30, 40, 50]) == 100000\n assert candidate(cost = [500, 100, 200, 300, 400, 600],time = [1, 2, 3, 4, 5, 6]) == 300\n assert candidate(cost = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],time = [15, 10, 5, 15, 10, 5, 15, 10, 5, 15, 10, 5, 15, 10, 5]) == 1\n assert candidate(cost = [1, 5, 8, 10, 3, 7],time = [2, 4, 3, 1, 2, 5]) == 4\n assert candidate(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],time = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 483, 482, 481, 480, 479, 478, 477, 476, 475, 474, 473, 472, 471, 470]) == 1\n assert candidate(cost = [300, 200, 100, 400, 300],time = [5, 4, 3, 2, 1]) == 200\n assert candidate(cost = [100, 200, 300, 400, 500, 600],time = [1, 2, 3, 4, 5, 6]) == 400\n assert candidate(cost = [5, 8, 3, 12, 7, 10, 6, 9, 2, 4],time = [4, 3, 5, 2, 3, 1, 4, 5, 6, 2]) == 5\n assert candidate(cost = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 10\n assert candidate(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, 270, 280, 290, 300],time = [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]) == 240\n assert candidate(cost = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(cost = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100000\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],time = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],time = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(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],time = [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\n assert candidate(cost = [1, 10, 100, 1000, 10000, 100000, 1000000, 500000, 500000, 500000],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1011\n assert candidate(cost = [120, 110, 100, 90, 80, 70, 60, 50],time = [3, 2, 1, 4, 3, 2, 1, 4]) == 120\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],time = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(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],time = [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\n assert candidate(cost = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 20, 22, 21, 23, 25, 24, 26, 28, 27, 29, 30],time = [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\n assert candidate(cost = [20, 30, 25, 40, 15, 35, 45, 10, 50, 5],time = [5, 4, 3, 2, 1, 3, 4, 5, 2, 1]) == 30\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 150\n assert candidate(cost = [999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1999998\n assert candidate(cost = [50, 60, 70, 80, 90, 100, 110],time = [1, 1, 1, 1, 1, 1, 1]) == 260\n"}, "metadata": {"canonical_parameter_names": ["cost", "time"], "leetcode_dataset_entry_point": "Solution().paintWalls", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int paintWalls(int[] cost, int[] time) {", "container": "Solution", "callable": "paintWalls", "parameters": [{"name": "cost", "type": "int[]"}, {"name": "time", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2744, "task_id": "find-maximum-number-of-string-pairs", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array words consisting of distinct strings.\nThe string words[i] can be paired with the string words[j] if:\n\nThe string words[i] is equal to the reversed string of words[j].\n0 <= i < j < words.length.\n\nReturn the maximum number of pairs that can be formed from the array words.\nNote that each string can belong in at most one pair.\n \nExample 1:\n\nInput: words = [\"cd\",\"ac\",\"dc\",\"ca\",\"zz\"]\nOutput: 2\nExplanation: In this example, we can form 2 pair of strings in the following way:\n- We pair the 0th string with the 2nd string, as the reversed string of word[0] is \"dc\" and is equal to words[2].\n- We pair the 1st string with the 3rd string, as the reversed string of word[1] is \"ca\" and is equal to words[3].\nIt can be proven that 2 is the maximum number of pairs that can be formed.\nExample 2:\n\nInput: words = [\"ab\",\"ba\",\"cc\"]\nOutput: 1\nExplanation: In this example, we can form 1 pair of strings in the following way:\n- We pair the 0th string with the 1st string, as the reversed string of words[1] is \"ab\" and is equal to words[0].\nIt can be proven that 1 is the maximum number of pairs that can be formed.\n\nExample 3:\n\nInput: words = [\"aa\",\"ab\"]\nOutput: 0\nExplanation: In this example, we are unable to form any pair of strings.\n\n \nConstraints:\n\n1 <= words.length <= 50\nwords[i].length == 2\nwords consists of distinct strings.\nwords[i] contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji']) == 5\n assert candidate(words = ['mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts']) == 4\n assert candidate(words = ['uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'ab', 'ba']) == 4\n assert candidate(words = ['xy', 'yx', 'zw', 'wz', 'mn']) == 2\n assert candidate(words = ['xy', 'yx', 'za', 'az', 'bw', 'wb', 'cc']) == 3\n assert candidate(words = ['lm', 'ml', 'no', 'on', 'pq', 'qp', 'rs', 'sr']) == 4\n assert candidate(words = ['ef', 'fe', 'gh', 'hg', 'ij', 'ji']) == 3\n assert candidate(words = ['st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy']) == 4\n assert candidate(words = ['xy', 'yx', 'zz', 'zx', 'yx', 'xy']) == 4\n assert candidate(words = ['xy', 'yx', 'za', 'az', 'bw', 'wb']) == 3\n assert candidate(words = ['tu', 'ut', 'vw', 'wv', 'xy', 'yx', 'za', 'az']) == 4\n assert candidate(words = ['kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq']) == 4\n assert candidate(words = ['cd', 'ac', 'dc', 'ca', 'zz']) == 2\n assert candidate(words = ['de', 'ed', 'fg', 'gf', 'hi', 'ih', 'jk', 'kj']) == 4\n assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj']) == 0\n assert candidate(words = ['aa', 'ab']) == 0\n assert candidate(words = ['mn', 'nm', 'op', 'po', 'qr', 'rq']) == 3\n assert candidate(words = ['xy', 'yx', 'za', 'az', 'bw', 'wb', 'cd', 'dc']) == 4\n assert candidate(words = ['ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk']) == 4\n assert candidate(words = ['qq', 'rr', 'ss', 'tt', 'uu']) == 0\n assert candidate(words = ['ab', 'ba', 'cc']) == 1\n assert candidate(words = ['qp', 'pq', 'rs', 'sr', 'tu', 'ut']) == 3\n assert candidate(words = ['ab', 'cd', 'ef', 'gh', 'ij', 'kl', 'mn', 'op', 'qr', 'st', 'uv', 'wx', 'yz']) == 0\n assert candidate(words = ['xy', 'yx', 'zz', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']) == 2\n assert candidate(words = ['xy', 'yx', 'pq', 'qp', 'rs', 'sr', 'tu', 'ut', 'vw', 'wv', 'xy', 'yx', 'zz', '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']) == 9\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'hgef', 'ijkl', 'lkji', 'mnop', 'ponm', 'qrst', 'tqrs', 'uvwx', 'xwvu', 'yzab', 'bazY']) == 4\n assert candidate(words = ['aabb', 'bbaa', 'ccdd', 'ddcc', 'eeff', 'ffee', 'gghh', 'hhgg', 'iijj', 'jjii', 'kkll', 'llkk', 'mmnn', 'nntt', 'oopp', 'ppoo', 'qqr', 'rqq', 'ss tt', 'ttss', 'uuvv', 'vvuu', 'wwxx', 'xxww', 'yyzz', 'zzyy', 'aacc', 'ccaa', 'ddeeff', 'ffeedd', 'gghhiijj', 'jjihhg', 'kkllmm', 'mmllkk', 'nnooppqq', 'qqpoonnn', 'rrssttuu', 'uuttsrrr', 'vvwwxx', 'xxwwvv', 'yyzzxx', 'xxzzyy']) == 16\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'h gef', 'ijkl', 'lkij', 'mnop', 'ponm', 'qrst', 't srq', 'uvwx', 'xwvu', 'yzxy', 'zyzx', 'abcd', 'dcba', 'efgh', 'h gef', 'ijkl', 'lkij', 'mnop', 'ponm', 'qrst', 't srq', 'uvwx', 'xwvu', 'yzxy', 'zyzx', 'mnop', 'ponm', 'qrst', 't srq', 'ijkl', 'lkij', 'efgh', 'h gef', 'abcd', 'dcba']) == 22\n assert candidate(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', 'za', 'az', 'zb', 'bz', 'zc', 'cz', 'zd', 'dz', 'ze', 'ez', 'zf', 'fz', 'zg', 'gz', 'zh', 'hz', 'zi', 'iz', 'zj', 'jz', 'zk', 'kz', 'zl', 'lz', 'zm', 'mz', 'zn', 'nz', 'zo', 'oz', 'zp', 'pz', 'zq', 'qz', 'zr', 'rz', 'zs', 'sz', 'zt', 'tz', 'zu', 'uz', 'zv', 'vz', 'zw', 'wz', 'zx', 'xz', 'zy', 'yz']) == 25\n assert candidate(words = ['xy', 'yx', 'zz', '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']) == 2\n assert candidate(words = ['xy', 'yx', 'zw', 'wz', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk']) == 15\n assert candidate(words = ['xy', 'yx', 'zz', 'wz', 'zw', 'uv', 'vu', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'ab', 'ba', 'ef', 'fe']) == 16\n assert candidate(words = ['st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq']) == 13\n assert candidate(words = ['bc', 'cb', 'de', 'ed', 'fg', 'gf', 'hi', 'ih', 'jk', 'kj', 'lm', 'ml', 'no', 'on', 'pq', 'qp', 'rs', 'sr', 'tu', 'ut']) == 10\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', 'zz', 'zzz', 'zzzz']) == 13\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'hgf', 'ijkl', 'lkji', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvwx', 'xwvu', 'yzab', 'baz', 'mnop', 'ponm', 'qrst', 'tsrq', 'mnop', 'ponm', 'qrst', 'tsrq', 'mnop', 'ponm', 'qrst', 'tsrq', 'mnop', 'ponm', 'qrst', 'tsrq', 'mnop', 'ponm']) == 64\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'hgf', 'ijkl', 'lkji', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvwx', 'xwvu', 'yzab', 'baz', 'mnop', 'ponm', 'qrst', 'tsrq', 'mnop', 'ponm']) == 16\n assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm']) == 7\n assert candidate(words = ['xy', 'yx', 'zv', 'vz', 'ws', 'sw', 'tr', 'rt', 'qu', 'uq', 'kp', 'pk', 'jo', 'oj', 'in', 'ni', 'mh', 'hm', 'lg', 'gl', 'kf', 'fk', 'je', 'ej', 'id', 'di', 'hc', 'ch', 'gb', 'bg', 'fa', 'af', 'xy', 'yx', 'zv', 'vz', 'ws', 'sw', 'tr', 'rt', 'qu', 'uq', 'kp', 'pk', 'jo', 'oj', 'in', 'ni', 'mh', 'hm', 'lg', 'gl', 'kf', 'fk', 'je', 'ej', 'id', 'di', 'hc', 'ch', 'gb', 'bg', 'fa', 'af']) == 64\n assert candidate(words = ['xy', 'yx', 'zx', 'xz', 'ay', 'ya', 'by', 'yb']) == 4\n assert candidate(words = ['qp', 'pq', 'rs', 'sr', 'tu', 'ut', 'vw', 'wv', 'xy', 'yx', 'za', 'az', 'by', 'yb', 'cx', 'xc', 'dl', 'ld', 'em', 'me', 'fn', 'nf', 'go', 'og', 'hp', 'ph', 'iq', 'qi', 'jr', 'rj', 'ks', 'sk', 'lt', 'tl', 'mu', 'um', 'nv', 'vn', 'ow', 'wo', 'px', 'xp', 'qy', 'yq', 'rz', 'zr', 'sa', 'as', 'tb', 'bt', 'uc', 'cu', 'vd', 'dv', 'we', 'ew', 'xf', 'fx', 'yg', 'gy', 'zh', 'hz']) == 31\n assert candidate(words = ['xy', 'yx', 'zxyx', 'xzzy', 'mn', 'nm', 'abcd', 'dcba', 'efgh', 'hgfe', 'ijkl', 'lkji', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvwx', 'xwvu', 'yzab', 'bazy']) == 9\n assert candidate(words = ['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']) == 13\n assert candidate(words = ['ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm']) == 5\n assert candidate(words = ['aabb', 'bbaa', 'ccdd', 'ddcc', 'eefg', 'gfee', 'hhi j', 'jjih', 'kklm', 'mllk', 'nno p', 'p onn', 'qqrs', 'srqq', 'tuvw', 'xwvt', 'yzxy', 'yzzy', 'zzyz', 'xzyz', 'zyzx', 'zyzy', 'yxzx', 'zxxy', 'xyyx', 'yxyx', 'xyxy', 'yxxy', 'xyyx', 'yxyx', 'xyxy']) == 11\n assert candidate(words = ['zz', 'zz', 'zy', 'yz', 'zx', 'xz', 'zw', 'wz', 'za', 'az', 'zb', 'bz', 'zc', 'cz', 'zd', 'dz', 'ze', 'ez', 'zf', 'fz', 'zg', 'gz', 'zh', 'hz', 'zi', 'iz', 'zj', 'jz', 'zk', 'kz', 'zl', 'lz', 'zm', 'mz', 'zn', 'nz', 'zo', 'oz', 'zp', 'pz', 'zq', 'qz', 'zr', 'rz', 'zs', 'sz', 'zt', 'tz', 'zu', 'uz', 'zv', 'vz', 'zw', 'wz', 'zx', 'xz', 'zy', 'yz']) == 35\n assert candidate(words = ['xy', 'yx', 'zv', 'vz', 'ws', 'sw', 'tr', 'rt', 'qu', 'uq', 'kp', 'pk', 'jo', 'oj', 'in', 'ni', 'mh', 'hm', 'lg', 'gl', 'kf', 'fk', 'je', 'ej', 'id', 'di', 'hc', 'ch', 'gb', 'bg', 'fa', 'af']) == 16\n assert candidate(words = ['xyyx', 'yxxy', 'zwwz', 'wzzw', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvwx', 'xwvu', 'yz', 'zy', 'abcd', 'dcba', 'efgh', 'hgf', 'ijk', 'kij', 'lmn', 'nml', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm']) == 21\n assert candidate(words = ['ba', 'ab', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'zz', 'za', 'az', 'bz', 'zb', 'cz', 'zc', 'dz', 'zd']) == 17\n assert candidate(words = ['xy', 'yz', 'zx', 'wx', 'vu', 'ts', 'rq', 'po', 'nm', 'lk', 'ji', 'hg', 'fe', 'dc', 'ba', 'za', 'zb', 'zc', 'zd', 'ze', 'zf', 'zg', 'zh', 'zi', 'zj', 'zk', 'zl', 'zm', 'zn', 'zo', 'zp', 'zq', 'zr', 'zs', 'zt', 'zu', 'zv', 'zw', 'zx', 'zy', 'zz', 'az', 'bz', 'cz', 'dz', 'ez', 'fz', 'gz', 'hz', 'iz', 'jz', 'kz', 'lz', 'mz', 'nz', 'oz', 'pz', 'qz', 'rz', 'sz', 'tz', 'uz', 'vz', 'wz', 'xz', 'yy', 'xx', 'ww', 'vv', 'uu', 'tt', 'ss', 'rr', 'qq', 'pp', 'oo', 'nn', 'mm', 'll', 'kk', 'jj', 'ii', 'hh', 'gg', 'ff', 'ee', 'dd', 'cc', 'bb', 'aa']) == 26\n assert candidate(words = ['st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', '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']) == 25\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', 'ac', 'ca', 'bd', 'db']) == 15\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'h gef', 'ijkl', 'lkij', 'mnop', 'ponm', 'qrst', 't srq', 'uvwx', 'xwvu', 'yzab', 'baz y', 'mnop', 'ponm', 'qrst', 't srq', 'ijkl', 'lkij', 'efgh', 'h gef', 'abcd', 'dcba']) == 9\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']) == 25\n assert candidate(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', 'xy', 'yx', 'zw', 'wz', 'mn', 'nm']) == 3\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']) == 13\n assert candidate(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']) == 0\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']) == 13\n assert candidate(words = ['ab', 'cd', 'ef', 'gh', 'ij', 'kl', 'mn', 'op', 'qr', 'st', 'uv', 'wx', 'yz', 'za', 'zb', 'zc', 'zd', 'ze', 'zf', 'zg', 'zh', 'zi', 'zj', 'zk', 'zl', 'zm', 'zn', 'zo', 'zp', 'zq', 'zr', 'zs', 'zt', 'zu', 'zv', 'zw', 'zx', 'zy', 'zz', 'yx', 'wz', 'vz', 'uz', 'tz', 'sz', 'rz', 'qz', 'pz', 'oz', 'nz', 'mz', 'lz', 'kz', 'jz', 'iz', 'hz', 'gz', 'fz', 'ez', 'dz', 'cz', 'bz', 'az', 'ba', 'dc', 'fe', 'hg', 'ji', 'lk', 'nm', 'po', 'rq', 'st', 'vu', 'wx', 'yz']) == 35\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', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy']) == 52\n assert candidate(words = ['pq', 'qp', 'rs', 'sr', 'tu', 'ut', 'vw', 'wv', 'xy', 'yx', 'za', 'az']) == 6\n assert candidate(words = ['xy', 'yx', 'zw', 'wz', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', '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', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy']) == 89\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', 'abcd', 'dcba', 'efgh', 'hgfe', 'ijkl', 'lkji']) == 16\n assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'ae', 'ea', 'af', 'fa', 'ag', 'ga', 'ah', 'ha', 'ai', 'ia']) == 8\n assert candidate(words = ['abc', 'cba', 'bcd', 'dcb', 'cde', 'edc', 'def', 'fed', 'efg', 'gfe', 'fgh', 'hgf', 'ghi', 'ihg', 'hij', 'jih', 'ijk', 'kji', 'jkl', 'lkj', 'klm', 'mlk', 'lmn', 'nml', 'mno', 'onm', 'nop', 'pon', 'opq', 'qpo', 'pqr', 'rqp', 'qrs', 'srq', 'rst', 'tsr', 'stu', 'uts', 'tuv', 'vut', 'uvw', 'wvu', 'vwx', 'xwv', 'wxy', 'yxw', 'xyz', 'zyx']) == 24\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().maximumNumberOfStringPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumNumberOfStringPairs(String[] words) {", "container": "Solution", "callable": "maximumNumberOfStringPairs", "parameters": [{"name": "words", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2745, "task_id": "construct-the-longest-new-string", "difficulty": "Medium", "problem_description": "You are given three integers x, y, and z.\nYou have x strings equal to \"AA\", y strings equal to \"BB\", and z strings equal to \"AB\". You want to choose some (possibly all or none) of these strings and concatenate them in some order to form a new string. This new string must not contain \"AAA\" or \"BBB\" as a substring.\nReturn the maximum possible length of the new string.\nA substring is a contiguous non-empty sequence of characters within a string.\n \nExample 1:\n\nInput: x = 2, y = 5, z = 1\nOutput: 12\nExplanation: We can concatenate the strings \"BB\", \"AA\", \"BB\", \"AA\", \"BB\", and \"AB\" in that order. Then, our new string is \"BBAABBAABBAB\". \nThat string has length 12, and we can show that it is impossible to construct a string of longer length.\n\nExample 2:\n\nInput: x = 3, y = 2, z = 2\nOutput: 14\nExplanation: We can concatenate the strings \"AB\", \"AB\", \"AA\", \"BB\", \"AA\", \"BB\", and \"AA\" in that order. Then, our new string is \"ABABAABBAABBAA\". \nThat string has length 14, and we can show that it is impossible to construct a string of longer length.\n\n \nConstraints:\n\n1 <= x, y, z <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(x = 1,y = 10,z = 10) == 26\n assert candidate(x = 50,y = 50,z = 50) == 300\n assert candidate(x = 10,y = 1,z = 10) == 26\n assert candidate(x = 20,y = 10,z = 5) == 52\n assert candidate(x = 10,y = 10,z = 100) == 240\n assert candidate(x = 10,y = 10,z = 1) == 42\n assert candidate(x = 2,y = 5,z = 1) == 12\n assert candidate(x = 1,y = 1,z = 1) == 6\n assert candidate(x = 3,y = 2,z = 2) == 14\n assert candidate(x = 49,y = 50,z = 1) == 200\n assert candidate(x = 40,y = 1,z = 2) == 10\n assert candidate(x = 40,y = 40,z = 30) == 220\n assert candidate(x = 50,y = 49,z = 49) == 296\n assert candidate(x = 5,y = 1,z = 5) == 16\n assert candidate(x = 50,y = 1,z = 1) == 8\n assert candidate(x = 2,y = 1,z = 10) == 26\n assert candidate(x = 10,y = 10,z = 30) == 100\n assert candidate(x = 25,y = 25,z = 10) == 120\n assert candidate(x = 10,y = 15,z = 8) == 58\n assert candidate(x = 2,y = 10,z = 0) == 10\n assert candidate(x = 0,y = 5,z = 10) == 22\n assert candidate(x = 35,y = 15,z = 5) == 72\n assert candidate(x = 25,y = 1,z = 25) == 56\n assert candidate(x = 2,y = 50,z = 25) == 60\n assert candidate(x = 7,y = 7,z = 14) == 56\n assert candidate(x = 30,y = 30,z = 25) == 170\n assert candidate(x = 25,y = 20,z = 10) == 102\n assert candidate(x = 5,y = 5,z = 45) == 110\n assert candidate(x = 5,y = 5,z = 10) == 40\n assert candidate(x = 30,y = 20,z = 10) == 102\n assert candidate(x = 33,y = 33,z = 34) == 200\n assert candidate(x = 30,y = 15,z = 25) == 112\n assert candidate(x = 40,y = 10,z = 30) == 102\n assert candidate(x = 15,y = 15,z = 25) == 110\n assert candidate(x = 30,y = 25,z = 30) == 162\n assert candidate(x = 1,y = 30,z = 5) == 16\n assert candidate(x = 10,y = 5,z = 15) == 52\n assert candidate(x = 15,y = 15,z = 5) == 70\n assert candidate(x = 20,y = 20,z = 1) == 82\n assert candidate(x = 50,y = 10,z = 1) == 44\n assert candidate(x = 20,y = 1,z = 30) == 66\n assert candidate(x = 20,y = 15,z = 20) == 102\n assert candidate(x = 40,y = 30,z = 20) == 162\n assert candidate(x = 10,y = 15,z = 20) == 82\n assert candidate(x = 20,y = 30,z = 40) == 162\n assert candidate(x = 5,y = 5,z = 50) == 120\n assert candidate(x = 10,y = 10,z = 10) == 60\n assert candidate(x = 40,y = 10,z = 1) == 44\n assert candidate(x = 10,y = 35,z = 5) == 52\n assert candidate(x = 1,y = 1,z = 50) == 104\n assert candidate(x = 30,y = 20,z = 30) == 142\n assert candidate(x = 15,y = 25,z = 30) == 122\n assert candidate(x = 5,y = 5,z = 40) == 100\n assert candidate(x = 2,y = 2,z = 4) == 16\n assert candidate(x = 10,y = 1,z = 50) == 106\n assert candidate(x = 45,y = 40,z = 45) == 252\n assert candidate(x = 45,y = 5,z = 5) == 32\n assert candidate(x = 45,y = 30,z = 25) == 172\n assert candidate(x = 5,y = 10,z = 40) == 102\n assert candidate(x = 10,y = 10,z = 15) == 70\n assert candidate(x = 10,y = 10,z = 40) == 120\n assert candidate(x = 2,y = 2,z = 3) == 14\n assert candidate(x = 20,y = 20,z = 30) == 140\n assert candidate(x = 40,y = 10,z = 10) == 62\n assert candidate(x = 25,y = 25,z = 1) == 102\n assert candidate(x = 49,y = 50,z = 49) == 296\n assert candidate(x = 15,y = 15,z = 30) == 120\n assert candidate(x = 4,y = 3,z = 6) == 26\n assert candidate(x = 10,y = 10,z = 5) == 50\n assert candidate(x = 10,y = 40,z = 20) == 82\n assert candidate(x = 1,y = 50,z = 1) == 8\n assert candidate(x = 20,y = 15,z = 25) == 112\n assert candidate(x = 1,y = 50,z = 49) == 104\n assert candidate(x = 25,y = 25,z = 25) == 150\n assert candidate(x = 20,y = 20,z = 20) == 120\n assert candidate(x = 20,y = 20,z = 10) == 100\n assert candidate(x = 25,y = 20,z = 30) == 142\n assert candidate(x = 1,y = 50,z = 50) == 106\n assert candidate(x = 30,y = 40,z = 35) == 192\n assert candidate(x = 30,y = 30,z = 1) == 122\n assert candidate(x = 10,y = 30,z = 10) == 62\n assert candidate(x = 30,y = 10,z = 20) == 82\n assert candidate(x = 20,y = 25,z = 30) == 142\n assert candidate(x = 15,y = 15,z = 1) == 62\n assert candidate(x = 35,y = 5,z = 10) == 42\n assert candidate(x = 40,y = 10,z = 20) == 82\n assert candidate(x = 50,y = 1,z = 50) == 106\n assert candidate(x = 10,y = 20,z = 15) == 72\n"}, "metadata": {"canonical_parameter_names": ["x", "y", "z"], "leetcode_dataset_entry_point": "Solution().longestString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestString(int x, int y, int z) {", "container": "Solution", "callable": "longestString", "parameters": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}, {"name": "z", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2746, "task_id": "decremental-string-concatenation", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array words containing n strings.\nLet's define a join operation join(x, y) between two strings x and y as concatenating them into xy. However, if the last character of x is equal to the first character of y, one of them is deleted.\nFor example join(\"ab\", \"ba\") = \"aba\" and join(\"ab\", \"cde\") = \"abcde\".\nYou are to perform n - 1 join operations. Let str0 = words[0]. Starting from i = 1 up to i = n - 1, for the ith operation, you can do one of the following:\n\nMake stri = join(stri - 1, words[i])\nMake stri = join(words[i], stri - 1)\n\nYour task is to minimize the length of strn - 1.\nReturn an integer denoting the minimum possible length of strn - 1.\n \nExample 1:\n\nInput: words = [\"aa\",\"ab\",\"bc\"]\nOutput: 4\nExplanation: In this example, we can perform join operations in the following order to minimize the length of str2: \nstr0 = \"aa\"\nstr1 = join(str0, \"ab\") = \"aab\"\nstr2 = join(str1, \"bc\") = \"aabc\" \nIt can be shown that the minimum possible length of str2 is 4.\nExample 2:\n\nInput: words = [\"ab\",\"b\"]\nOutput: 2\nExplanation: In this example, str0 = \"ab\", there are two ways to get str1: \njoin(str0, \"b\") = \"ab\" or join(\"b\", str0) = \"bab\". \nThe first string, \"ab\", has the minimum length. Hence, the answer is 2.\n\nExample 3:\n\nInput: words = [\"aaa\",\"c\",\"aba\"]\nOutput: 6\nExplanation: In this example, we can perform join operations in the following order to minimize the length of str2: \nstr0 = \"aaa\"\nstr1 = join(str0, \"c\") = \"aaac\"\nstr2 = join(\"aba\", str1) = \"abaaac\"\nIt can be shown that the minimum possible length of str2 is 6.\n\n \n \nConstraints:\n\n1 <= words.length <= 1000\n1 <= words[i].length <= 50\nEach character in words[i] is an English lowercase letter\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abcd', 'de', 'efg', 'gh']) == 8\n assert candidate(words = ['abcd', 'dcba', 'abdc', 'cdab']) == 13\n assert candidate(words = ['x', 'y', 'z', 'x', 'y', 'z']) == 4\n assert candidate(words = ['ab', 'bc', 'cd', 'da']) == 5\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd']) == 16\n assert candidate(words = ['abc', 'cba', 'bca', 'acb']) == 9\n assert candidate(words = ['abc', 'cba', 'bac', 'bca']) == 10\n assert candidate(words = ['a', 'b', 'c', 'd', 'e']) == 5\n assert candidate(words = ['ab', 'b']) == 2\n assert candidate(words = ['aabb', 'bbaa', 'abab', 'baba']) == 13\n assert candidate(words = ['zz', 'za', 'az', 'zzz']) == 6\n assert candidate(words = ['xyz', 'zyx', 'xyz']) == 7\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']) == 35\n assert candidate(words = ['a', 'a', 'a', 'a']) == 1\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']) == 14\n assert candidate(words = ['same', 'emag', 'game', 'emerge', 'merge']) == 20\n assert candidate(words = ['hello', 'ollie', 'elephant']) == 16\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 10\n assert candidate(words = ['abc', 'abc', 'abc', 'abc']) == 12\n assert candidate(words = ['abc', 'bcd', 'cde']) == 8\n assert candidate(words = ['xyz', 'zyx', 'abc']) == 8\n assert candidate(words = ['aa', 'ab', 'bc']) == 4\n assert candidate(words = ['abc', 'cba', 'bac', 'bca', 'cab', 'acb']) == 14\n assert candidate(words = ['zzzz', 'zzz', 'zz', 'z']) == 7\n assert candidate(words = ['hello', 'ocean', 'nest']) == 12\n assert candidate(words = ['aaa', 'c', 'aba']) == 6\n assert candidate(words = ['abc', 'cab', 'bca', 'acb', 'bac', 'cba', 'abc', 'cab', 'bca', 'acb', 'bac', 'cba', 'abc', 'cab', 'bca', 'acb', 'bac', 'cba', 'abc', 'cab', 'bca', 'acb', 'bac', 'cba']) == 49\n assert candidate(words = ['abc', 'cab', 'bac', 'acb', 'bca', 'cba', 'abc', 'cab', 'bac', 'acb', 'bca', 'cba', 'abc', 'cab', 'bac', 'acb', 'bca', 'cba', 'abc', 'cab', 'bac', 'acb', 'bca', 'cba', 'abc', 'cab', 'bac', 'acb', 'bca', 'cba']) == 62\n assert candidate(words = ['abcde', 'edcba', 'bcdea', 'aebcd', 'defab', 'baced', 'cdefa', 'abced', 'decba', 'edabc']) == 43\n assert candidate(words = ['zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz']) == 16\n assert candidate(words = ['zzz', 'zyz', 'yzy', 'xyx', 'wxw', 'vuw', 'utv', 'tsu', 'rtr', 'qsp', 'pon', 'omn', 'nml', 'lmk', 'kjl', 'jik', 'ihg', 'hgf', 'ged', 'fcd', 'ebc', 'dad', 'cac', 'bcb', 'aba', 'aaa']) == 67\n assert candidate(words = ['aaaa', 'aaab', 'aaba', 'abaa', 'abab', 'baba', 'bbaa', 'bbba', 'bbbb', 'baaa']) == 34\n assert candidate(words = ['abc', 'cba', 'bca', 'acb', 'cab', 'bac', 'aab', 'abb', 'bab', 'bba', 'aba', 'baa']) == 26\n assert candidate(words = ['aaaaabbbbbcccccdddddeeeee', 'eeeeedddddccccbbbbbaaaaa', 'ffffffffgggggghhhhhiiiii', 'iiiiihihhhhgggggffffffff']) == 95\n assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'ae', 'ea', 'af', 'fa', 'ag', 'ga', 'ah', 'ha', 'ai', 'ia', 'aj', 'ja', 'ak', 'ka']) == 21\n assert candidate(words = ['aaaaa', 'aaabb', 'aabbb', 'abbbb', 'bbbbb', 'bbbb', 'bbb', 'bb', 'b', 'a', 'aaaab', 'aaabb', 'aabbb', 'abbbb', 'bbbbb']) == 53\n assert candidate(words = ['abcdef', 'fedcba', 'ghijkl', 'lkjihg', 'mnopqr', 'rqponm', 'stuvwx', 'xwvuts', 'yzabcd', 'dcba']) == 53\n assert candidate(words = ['aabbcc', 'ccbbcc', 'ddccbb', 'bbaadd', 'aaddcc', 'ccddaabb', 'bbccddaa', 'aaddbbcc', 'ccddaabb', 'bbaadddc', 'ccbbccaa', 'aaddbbcc', 'ccbbccdd', 'ddeebbaa', 'aabbccdd', 'bbccddeea', 'aaddccdde', 'bbccddeea', 'aadddccb', 'bbccddeea', 'ccdddeebb', 'ddeebbaac', 'aaddccdde', 'bbccddeea', 'ccdddeebb', 'ddeebbaac', 'aaddccdde', 'bbccddeea', 'ccdddeebb', 'ddeebbaac']) == 220\n assert candidate(words = ['abcde', 'edcba', 'abc', 'cba', 'a', 'b', 'c', 'd', 'e']) == 17\n assert candidate(words = ['xyzz', 'zzyx', 'yxzz', 'zzzy', 'xyyx', 'yxyx', 'xzyx', 'zyxy', 'zzxx', 'xxzz', 'xyxy', 'yxyy', 'yyxy', 'xyxy', 'zyyx', 'xzyz', 'zzyz', 'yzyz', 'zyzy', 'xyzx', 'yxzx', 'xzyy', 'yzyx', 'xyyz', 'zyzy']) == 82\n assert candidate(words = ['repeat', 'eatrep', 'peatre', 'eatrep', 'peatre', 'eatrep', 'peatre', 'eatrep', 'peatre', 'eatrep', 'peatre']) == 57\n assert candidate(words = ['aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa']) == 289\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', 'aaab', 'bbac', 'ccad', 'ddae', 'eeaf', 'ffag', 'ggbh', 'hhih', 'iiji', 'jjik', 'kkil', 'llim', 'mmim', 'njin', 'okin', 'plin', 'qlin', 'rlin', 'slin', 'tlia', 'ulia', 'vlia', 'wlia', 'xlia', 'ylia', 'zlkb', 'alib', 'blib', 'clib', 'dlib', 'elib', 'flib', 'glib', 'hlid', 'ilid', 'jlid', 'klid', 'llie', 'mlie', 'nlie', 'olie', 'plie', 'qlie', 'rlie', 'slie', 'tlif', 'ulif', 'vlif', 'wlif', 'xlif', 'ylif', 'zlif', 'almg', 'blmg', 'clmg', 'dlog', 'elog', 'flmg', 'glog', 'hlmg', 'ilmg', 'jlog', 'klmg', 'llmg', 'mlmh', 'nlmh', 'olmh', 'plmh', 'qlmh', 'rlmh', 'slmh', 'tlmh', 'ulmh', 'vlim', 'wlim', 'xlmn', 'ylmn', 'zlmn', 'amno', 'bmno', 'cmno', 'dmno', 'emno', 'fmno', 'gmno', 'hmno', 'imno', 'jmno', 'kmno', 'lmno', 'mmnp', 'nmnp', 'omnp', 'pmnp', 'qmnp', 'rmnp', 'smnp', 'tmnp', 'umnp', 'vmno', 'wmno', 'xmno', 'ymno', 'zmno', 'anop', 'bnop', 'cnop', 'dnop', 'enop', 'fnop', 'gnop', 'hnop', 'inop', 'jnop', 'knop', 'lnop', 'mnop', 'mnoq', 'nnoq', 'onno', 'pnno', 'qnno', 'rnno', 'snno', 'tnno', 'unno', 'vnno', 'wnno', 'xnno', 'ynno', 'znno', 'aonr', 'bonr', 'conr', 'donr', 'eonr', 'fonr', 'gonr', 'honr', 'ionr', 'jonr', 'konr', 'lonr', 'monr', 'nonr', 'onrs', 'pnrs', 'qnrs', 'rnrs', 'snrs', 'tnrs', 'unrs', 'vnrs', 'wnrs', 'xnrs', 'ynrs', 'znrs', 'aors', 'bors', 'cors', 'dors', 'eors', 'fors', 'gors', 'hors', 'iors', 'jors', 'kors', 'lors', 'mors', 'nors', 'orsp', 'nosp', 'ospp', 'pspq', 'qspq', 'rspq', 'sspq', 'tspq', 'uspq', 'vspq', 'wspq', 'xspq', 'yspq', 'zspq', 'atpq', 'btpq', 'ctpq', 'dtpq', 'etpq', 'ftpq', 'gtpq', 'htpq', 'itpq', 'jtpq', 'ktpq', 'ltpq', 'mtpq', 'nspq', 'ntpq', 'optq', 'ptpr', 'qtpr', 'rtpr', 'stpr', 'ttpr', 'utpr', 'vtpr', 'wtpr', 'xtpr', 'ytpr', 'ztpr', 'aotr', 'botr', 'cotr', 'dotr', 'eotr', 'fotr', 'gotr', 'hotr', 'iotr', 'jotr', 'kotr', 'lotr', 'motr', 'notr', 'ootr', 'potr', 'qotr', 'rotr', 'sotr', 'totr', 'uotr', 'votr', 'wotr', 'xotr', 'yotr', 'zotr', 'aupt', 'bupt', 'aupt', 'cutr', 'dutr', 'eutr', 'futr', 'gutr', 'hutr', 'iutr', 'jutr', 'kutr', 'lutr', 'mutr', 'nctr', 'nutr', 'outr', 'pout', 'qout', 'rout', 'sout', 'tout', 'uout', 'vout', 'wout', 'xout', 'yout', 'zout']) == 1130\n assert candidate(words = ['zzzz', 'zzz', 'zz', 'z', 'z', 'zz', 'zzz', 'zzzz']) == 13\n assert candidate(words = ['aaaaaab', 'baaaaaa', 'aaabaaa', 'aaaabaa', 'aaaaaba', 'aaaaaab', 'baaaaaa', 'aaabaaa', 'aaaabaa', 'aaaaaba']) == 61\n assert candidate(words = ['abcde', 'edcba', 'fghij', 'jihgf', 'klmno', 'onmlk', 'pqrst', 'tsrqp', 'uvwxy', 'yxwvu', 'zyxwv', 'vwxyz', 'utsrq', 'qponm', 'lkjih', 'ihgfe', 'edcba']) == 76\n assert candidate(words = ['pqr', 'rst', 'tuv', 'vwx', 'xyz', 'zyx', 'wxy', 'uvw', 'tsr', 'qrp', 'pqr', 'rst', 'tuv', 'vwx', 'xyz']) == 34\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyza', 'zyxwvutsrqponmlkjihgfedcbaz', 'abcdefghijklmnopqrstuvwxy', 'zyxwvutsrqponmlkjihgfedcba']) == 154\n assert candidate(words = ['aaaabbbb', 'bbbbcccc', 'ccccdddd', 'ddddaaaa']) == 29\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'xyz', 'zyx', 'xyz', 'zyx', 'xyz', 'zyx', 'xyz']) == 21\n assert candidate(words = ['abcdefg', 'ghijklm', 'mnopqr', 'rstuvw', 'wxyzabc', 'defghij', 'klmnopq', 'rstuvwx', 'yzabcd', 'efghijk', 'lmnopqr']) == 69\n assert candidate(words = ['aabb', 'bbaa', 'abab', 'baba', 'aabb', 'bbaa', 'abab', 'baba', 'aabb', 'bbaa', 'abab', 'baba', 'aabb', 'bbaa', 'abab', 'baba', 'aabb', 'bbaa', 'abab', 'baba']) == 61\n assert candidate(words = ['abcde', 'edcba', 'bcdef', 'fedcb', 'cdefg', 'gfedc', 'defgh', 'hgfed', 'efghi', 'ihgfe']) == 44\n assert candidate(words = ['abc', 'cba', 'bac', 'cab', 'acb', 'bca', 'xyz', 'zyx', 'yxz', 'zxy', 'yzx', 'xzy', 'uvw', 'vwu', 'wuv', 'uwv']) == 37\n assert candidate(words = ['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', 'za']) == 27\n assert candidate(words = ['zzzz', 'zzz', 'zz', 'z', 'z']) == 7\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'mnopqrstuv', 'vutsrqponm', 'wxyzabcd', 'dcbaefgh', 'ijklmnop', 'ponmlkji', 'qrstuvwxyz', 'zyxwvutsrq']) == 87\n assert candidate(words = ['aabb', 'bbcc', 'ccdd', 'ddee', 'eemm', 'mmnn', 'nnoo', 'oopp', 'ppqq', 'qqrr', 'rrss', 'sstt', 'ttuu', 'uuvv', 'vvww', 'wwxx', 'xxyy', 'yyzz', 'zzaa', 'aabb']) == 61\n assert candidate(words = ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', 'tttttttttttttttttttttttttttttttttttttttt', 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq']) == 198\n assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'ae', 'ea', 'af', 'fa']) == 11\n assert candidate(words = ['ababab', 'bababa', 'ababab', 'bababa', 'ababab', 'bababa', 'ababab', 'bababa', 'ababab', 'bababa']) == 51\n assert candidate(words = ['aabbcc', 'ccbbaa', 'aabbaa', 'bbaacc', 'ccabba', 'baacca', 'abbccc', 'ccabbb', 'bbbaac', 'acccbb']) == 52\n assert candidate(words = ['xyzz', 'zzxy', 'yzzx', 'zxyy', 'xyyx', 'yxzx', 'xzyz', 'zyzx', 'zyxz', 'yzzx', 'xyzz', 'zzxy']) == 39\n assert candidate(words = ['xy', 'yx', 'xz', 'zx', 'xw', 'wx', 'xv', 'vx', 'xu', 'ux', 'xt', 'tx', 'xs', 'sx', 'xr', 'rx', 'xq', 'qx', 'xp', 'px', 'xo', 'ox', 'xn', 'nx', 'xm', 'mx', 'xl', 'lx', 'xk', 'kx', 'xj', 'jx', 'xi', 'ix', 'xh', 'hx', 'xg', 'gx', 'xf', 'fx', 'xe', 'ex', 'xd', 'dx', 'xc', 'cx', 'xb', 'bx', 'xa', 'ax']) == 51\n assert candidate(words = ['aaaa', 'aaab', 'aaba', 'abaa', 'baaa']) == 16\n assert candidate(words = ['abcabcabc', 'cbacbacba', 'bcabcbcab', 'abcbabcbc', 'cbacbacba', 'bcabcbcab', 'abcbabcbc', 'cbacbacba', 'bcabcbcab', 'abcbabcbc', 'cbacbacba', 'bcabcbcab', 'abcbabcbc', 'cbacbacba', 'bcabcbcab', 'abcbabcbc']) == 130\n assert candidate(words = ['abc', 'cba', 'bac', 'acb', 'cab', 'bca']) == 13\n assert candidate(words = ['abcdabcdabcd', 'dcbaabcdabcd', 'abcdabcdabcd', 'dcbaabcdabcd', 'abcdabcdabcd', 'dcbaabcdabcd', 'abcdabcdabcd', 'dcbaabcdabcd', 'abcdabcdabcd', 'dcbaabcdabcd', 'abcdabcdabcd', 'dcbaabcdabcd']) == 138\n assert candidate(words = ['abcabc', 'bcbcbc', 'cbacba', 'bababa', 'acbacb', 'bacbac', 'cabacb', 'bcbacb', 'cbacba', 'abcabc', 'bcbcbc']) == 58\n assert candidate(words = ['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b']) == 2\n assert candidate(words = ['abcdefghijklmnopqrstuvwxy', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxy', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxy', 'zyxwvutsrqponmlkjihgfedcba']) == 150\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff', 'ggggg', 'hhhhh', 'iiiii', 'jjjjj']) == 50\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst']) == 209\n assert candidate(words = ['zzzzz', 'zzzz', 'zzz', 'zz', 'z']) == 11\n assert candidate(words = ['abac', 'bcad', 'cada', 'dadb', 'babc', 'acab', 'baca', 'caba', 'abcd', 'dcba', 'fedc', 'dcfe', 'dcde', 'edcd', 'dede', 'eeee', 'ee', 'e', 'a']) == 54\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyzabcdefghijkl', 'pqonmlkjihgfedcbazyxwvutsr']) == 103\n assert candidate(words = ['aaaaab', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff', 'ggggg', 'hhhhh', 'iiiii', 'jjjjj', 'kkkkk', 'lllll', 'mmmmm', 'nnnnn', 'ooooo', 'ppppp', 'qqqqq', 'rrrrr', 'sssss', 'ttttt']) == 100\n assert candidate(words = ['zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz']) == 31\n assert candidate(words = ['abcdabcdabcdabcdabcd', 'abcdeabcdeabcdeabcde', 'ababcababcababcab', 'abacabadabacabadaba', 'abacabadabacabadaba', 'abacabadabacabadaba', 'abacabadabacabadaba', 'abacabadabacabadaba']) == 147\n assert candidate(words = ['abcdef', 'fedcba', 'bcdefa', 'afedcb', 'cdefab', 'bafedc', 'defabc', 'cbafed', 'efabcd', 'dcbafe']) == 51\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 = ['abc', 'cab', 'bac', 'bca', 'acb', 'cba', 'aba', 'bab', 'aab', 'abb', 'bba', 'baa', 'aba', 'abb', 'bab', 'aab', 'abb', 'bba', 'baa', 'aba', 'abb', 'bab', 'aab', 'abb', 'bba', 'baa', 'aba', 'abb', 'bab', 'aab', 'abb', 'bba', 'baa', 'aba', 'abb', 'bab', 'aab', 'abb', 'bba', 'baa', 'aba', 'abb', 'bab']) == 92\n assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 61\n assert candidate(words = ['abc', 'cab', 'bac', 'acb', 'bca', 'cba']) == 14\n assert candidate(words = ['abcde', 'edcba', 'bcdea', 'aecdb', 'dbeca', 'cedba', 'bedca', 'aebcd', 'decba', 'cbade', 'bacde', 'acdeb']) == 53\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().minimizeConcatenatedLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimizeConcatenatedLength(String[] words) {", "container": "Solution", "callable": "minimizeConcatenatedLength", "parameters": [{"name": "words", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2747, "task_id": "count-zero-request-servers", "difficulty": "Medium", "problem_description": "You are given an integer n denoting the total number of servers and a 2D 0-indexed integer array logs, where logs[i] = [server_id, time] denotes that the server with id server_id received a request at time time.\nYou are also given an integer x and a 0-indexed integer array queries.\nReturn a 0-indexed integer array arr of length queries.length where arr[i] represents the number of servers that did not receive any requests during the time interval [queries[i] - x, queries[i]].\nNote that the time intervals are inclusive.\n \nExample 1:\n\nInput: n = 3, logs = [[1,3],[2,6],[1,5]], x = 5, queries = [10,11]\nOutput: [1,2]\nExplanation: \nFor queries[0]: The servers with ids 1 and 2 get requests in the duration of [5, 10]. Hence, only server 3 gets zero requests.\nFor queries[1]: Only the server with id 2 gets a request in duration of [6,11]. Hence, the servers with ids 1 and 3 are the only servers that do not receive any requests during that time period.\n\n\nExample 2:\n\nInput: n = 3, logs = [[2,4],[2,1],[1,2],[3,1]], x = 2, queries = [3,4]\nOutput: [0,1]\nExplanation: \nFor queries[0]: All servers get at least one request in the duration of [1, 3].\nFor queries[1]: Only server with id 3 gets no request in the duration [2,4].\n\n\n \nConstraints:\n\n1 <= n <= 105\n1 <= logs.length <= 105\n1 <= queries.length <= 105\nlogs[i].length == 2\n1 <= logs[i][0] <= n\n1 <= logs[i][1] <= 106\n1 <= x <= 105\nx < queries[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,logs = [[1, 1]],x = 1,queries = [2]) == [0]\n assert candidate(n = 10,logs = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],x = 10,queries = [20, 50, 80, 110]) == [8, 8, 8, 9]\n assert candidate(n = 4,logs = [[1, 10], [2, 15], [3, 20], [4, 25]],x = 10,queries = [15, 20, 25, 30]) == [2, 1, 1, 2]\n assert candidate(n = 3,logs = [[1, 3], [2, 6], [1, 5]],x = 5,queries = [10, 11]) == [1, 2]\n assert candidate(n = 3,logs = [[2, 4], [2, 1], [1, 2], [3, 1]],x = 2,queries = [3, 4]) == [0, 1]\n assert candidate(n = 5,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],x = 1,queries = [1, 2, 3, 4, 5]) == [4, 3, 3, 3, 3]\n assert candidate(n = 4,logs = [[1, 10], [2, 20], [3, 30], [4, 40]],x = 15,queries = [15, 25, 35, 45]) == [3, 2, 2, 2]\n assert candidate(n = 5,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],x = 1,queries = [2, 3]) == [3, 3]\n assert candidate(n = 5,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],x = 1,queries = [2, 3, 4, 5, 6]) == [3, 3, 3, 3, 4]\n assert candidate(n = 2,logs = [[1, 1], [1, 2], [1, 3], [2, 4], [2, 5]],x = 2,queries = [3, 5, 7]) == [1, 0, 1]\n assert candidate(n = 2,logs = [[1, 1], [1, 2], [1, 3], [2, 4], [2, 5]],x = 2,queries = [3, 4, 5]) == [1, 0, 0]\n assert candidate(n = 2,logs = [[1, 1], [1, 2], [2, 3]],x = 2,queries = [4, 5]) == [0, 1]\n assert candidate(n = 4,logs = [[1, 1], [2, 2], [3, 3], [4, 4]],x = 4,queries = [5, 6, 7, 8]) == [0, 1, 2, 3]\n assert candidate(n = 5,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],x = 1,queries = [2, 3, 4, 5]) == [3, 3, 3, 3]\n assert candidate(n = 15,logs = [[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]],x = 1,queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\n assert candidate(n = 5,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]],x = 5,queries = [5, 10, 15, 20, 25]) == [0, 0, 4, 5, 5]\n assert candidate(n = 10,logs = [[1, 1], [1, 5], [1, 10], [2, 1], [2, 5], [2, 10], [3, 1], [3, 5], [3, 10], [4, 1], [4, 5], [4, 10], [5, 1], [5, 5], [5, 10], [6, 1], [6, 5], [6, 10], [7, 1], [7, 5], [7, 10], [8, 1], [8, 5], [8, 10], [9, 1], [9, 5], [9, 10], [10, 1], [10, 5], [10, 10]],x = 10,queries = [10, 20, 30]) == [0, 0, 10]\n assert candidate(n = 9,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [1, 19], [2, 20], [3, 21], [4, 22], [5, 23], [6, 24], [7, 25], [8, 26], [9, 27]],x = 15,queries = [20, 30, 40, 50]) == [0, 0, 6, 9]\n assert candidate(n = 10,logs = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],x = 10,queries = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == [8, 8, 8, 8, 8, 8, 8, 8, 8, 9]\n assert candidate(n = 9,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]],x = 5,queries = [5, 10, 15, 20]) == [4, 0, 0, 9]\n assert candidate(n = 10,logs = [[1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [10, 55]],x = 10,queries = [15, 25, 35, 45, 55]) == [8, 7, 7, 7, 7]\n assert candidate(n = 100,logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 3], [12, 3], [13, 3], [14, 3], [15, 3], [16, 4], [17, 4], [18, 4], [19, 4], [20, 4], [21, 5], [22, 5], [23, 5], [24, 5], [25, 5], [26, 6], [27, 6], [28, 6], [29, 6], [30, 6], [31, 7], [32, 7], [33, 7], [34, 7], [35, 7]],x = 2,queries = [1, 2, 3, 4, 5, 6, 7]) == [95, 90, 85, 85, 85, 85, 85]\n assert candidate(n = 8,logs = [[1, 10], [1, 20], [2, 15], [2, 25], [3, 12], [3, 18], [4, 16], [4, 22], [5, 14], [5, 24], [6, 11], [6, 21], [7, 13], [7, 23], [8, 17], [8, 27]],x = 10,queries = [15, 20, 25, 30]) == [2, 0, 0, 1]\n assert candidate(n = 5,logs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],x = 5,queries = [7, 8, 9, 10, 11]) == [0, 0, 0, 0, 0]\n assert candidate(n = 10,logs = [[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]],x = 2,queries = [3, 6, 9]) == [5, 10, 10]\n assert candidate(n = 10,logs = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]],x = 5,queries = [10, 15, 20]) == [4, 5, 10]\n assert candidate(n = 10,logs = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],x = 10,queries = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(n = 10,logs = [[1, 5], [2, 7], [3, 9], [4, 11], [5, 13], [6, 15], [7, 17], [8, 19], [9, 21], [10, 23]],x = 10,queries = [10, 20, 30, 40]) == [7, 5, 8, 10]\n assert candidate(n = 20,logs = [[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]],x = 2,queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [19, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]\n assert candidate(n = 10,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],x = 3,queries = [1, 4, 7, 10, 13]) == [9, 6, 6, 6, 9]\n assert candidate(n = 20,logs = [[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]],x = 1,queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18]\n assert candidate(n = 10,logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],x = 5,queries = [10, 15, 20]) == [10, 10, 10]\n assert candidate(n = 50,logs = [[1, 100], [2, 101], [3, 102], [4, 103], [5, 104], [1, 200], [2, 201], [3, 202], [4, 203], [5, 204], [1, 300], [2, 301], [3, 302], [4, 303], [5, 304], [1, 400], [2, 401], [3, 402], [4, 403], [5, 404], [1, 500], [2, 501], [3, 502], [4, 503], [5, 504]],x = 150,queries = [150, 300, 450, 600, 750]) == [45, 45, 45, 45, 50]\n assert candidate(n = 5,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15]],x = 5,queries = [10, 15, 20, 25]) == [0, 0, 4, 5]\n assert candidate(n = 20,logs = [[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]],x = 10,queries = [11, 21, 31, 41]) == [9, 10, 20, 20]\n assert candidate(n = 5,logs = [[1, 1], [1, 2], [1, 3], [2, 2], [2, 3], [3, 3]],x = 2,queries = [3, 4, 5]) == [2, 2, 2]\n assert candidate(n = 15,logs = [[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]],x = 5,queries = [6, 11, 16, 21, 26, 31]) == [9, 9, 10, 15, 15, 15]\n assert candidate(n = 100,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],x = 1,queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [99, 98, 98, 98, 98, 98, 98, 98, 98, 98]\n assert candidate(n = 10,logs = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50]],x = 5,queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [9, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(n = 5,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]],x = 5,queries = [10, 15]) == [0, 4]\n assert candidate(n = 6,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12]],x = 5,queries = [12, 15, 20]) == [0, 3, 6]\n assert candidate(n = 10,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],x = 5,queries = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [4, 4, 4, 4, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,logs = [[1, 1], [2, 2], [1, 11], [2, 12], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],x = 10,queries = [15, 20, 25, 30]) == [2, 7, 10, 10]\n assert candidate(n = 7,logs = [[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], [6, 1], [6, 2], [6, 3], [7, 1], [7, 2], [7, 3]],x = 2,queries = [3, 6, 9, 12]) == [0, 7, 7, 7]\n assert candidate(n = 5,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7]],x = 3,queries = [4, 7, 10, 13]) == [1, 0, 0, 5]\n assert candidate(n = 10,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],x = 10,queries = [10, 20, 30, 40, 50]) == [0, 9, 10, 10, 10]\n assert candidate(n = 6,logs = [[1, 1], [1, 3], [2, 2], [2, 4], [3, 3], [3, 5], [4, 4], [4, 6], [5, 5], [5, 7], [6, 6], [6, 8]],x = 2,queries = [3, 6, 9, 12]) == [3, 1, 4, 6]\n assert candidate(n = 5,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]],x = 5,queries = [1, 6, 11, 16]) == [4, 0, 0, 5]\n assert candidate(n = 20,logs = [[1, 10], [2, 12], [3, 14], [4, 16], [5, 18], [6, 20], [7, 22], [8, 24], [9, 26], [10, 28], [11, 30], [12, 32], [13, 34], [14, 36], [15, 38], [16, 40], [17, 42], [18, 44], [19, 46], [20, 48]],x = 5,queries = [15, 25, 35, 45, 55]) == [17, 17, 17, 17, 20]\n assert candidate(n = 7,logs = [[1, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12], [5, 13], [5, 14], [5, 15], [6, 16], [6, 17], [6, 18], [7, 19], [7, 20], [7, 21]],x = 5,queries = [5, 10, 15, 20, 25]) == [5, 4, 5, 4, 6]\n assert candidate(n = 9,logs = [[1, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12], [5, 13], [5, 14], [5, 15]],x = 3,queries = [5, 10, 15, 20]) == [7, 7, 7, 9]\n assert candidate(n = 10,logs = [[1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [10, 55]],x = 10,queries = [12, 22, 32, 42, 52, 62]) == [9, 8, 8, 8, 8, 9]\n assert candidate(n = 12,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [1, 13], [2, 14], [3, 15], [4, 16], [5, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24]],x = 10,queries = [15, 25, 35, 45]) == [1, 2, 12, 12]\n assert candidate(n = 7,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [1, 15], [2, 16], [3, 17], [4, 18], [5, 19], [6, 20], [7, 21]],x = 10,queries = [10, 20, 30, 40]) == [0, 0, 5, 7]\n assert candidate(n = 11,logs = [[1, 1], [1, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [4, 11], [5, 12], [5, 13], [5, 14], [6, 15], [6, 16], [6, 17], [7, 18], [7, 19], [7, 20], [8, 21], [8, 22], [8, 23], [9, 24], [9, 25], [9, 26], [10, 27], [10, 28], [10, 29], [11, 30], [11, 31], [11, 32]],x = 10,queries = [10, 20, 30, 40]) == [7, 7, 6, 10]\n assert candidate(n = 50,logs = [[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, 1]],x = 1,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, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [0, 0, 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]\n assert candidate(n = 15,logs = [[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]],x = 5,queries = [6, 11, 16, 21]) == [9, 9, 10, 15]\n assert candidate(n = 8,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],x = 1,queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [6, 6, 6, 6, 8, 8, 8, 8, 8, 8]\n assert candidate(n = 100,logs = [[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]],x = 50,queries = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == [50, 49, 99, 100, 100, 100, 100, 100, 100, 100]\n assert candidate(n = 10,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],x = 3,queries = [5, 6, 7, 8, 9, 10, 11]) == [6, 6, 6, 6, 6, 6, 7]\n assert candidate(n = 7,logs = [[1, 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]],x = 5,queries = [5, 10, 15, 20]) == [4, 4, 4, 7]\n assert candidate(n = 10,logs = [[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]],x = 5,queries = [6, 7, 8, 9, 10]) == [7, 7, 7, 7, 7]\n assert candidate(n = 20,logs = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110], [12, 120], [13, 130], [14, 140], [15, 150], [16, 160], [17, 170], [18, 180], [19, 190], [20, 200]],x = 50,queries = [150, 200, 250, 300]) == [14, 14, 19, 20]\n assert candidate(n = 12,logs = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24]],x = 10,queries = [12, 22, 32, 42]) == [6, 6, 10, 12]\n assert candidate(n = 25,logs = [[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]],x = 1,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]) == [24, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23]\n assert candidate(n = 10,logs = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],x = 20,queries = [50, 60, 70, 80, 90, 100]) == [7, 7, 7, 7, 7, 7]\n assert candidate(n = 15,logs = [[1, 10], [2, 12], [3, 14], [4, 16], [5, 18], [6, 20], [7, 22], [8, 24], [9, 26], [10, 28], [11, 30], [12, 32], [13, 34], [14, 36], [15, 38]],x = 10,queries = [15, 25, 35, 45]) == [12, 10, 10, 13]\n assert candidate(n = 12,logs = [[1, 1], [1, 2], [2, 2], [2, 3], [3, 3], [3, 4], [4, 4], [4, 5], [5, 5], [5, 6], [6, 6], [6, 7]],x = 3,queries = [4, 5, 6, 7, 8]) == [8, 7, 7, 8, 9]\n assert candidate(n = 6,logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2]],x = 2,queries = [3, 4, 5, 6]) == [0, 0, 6, 6]\n assert candidate(n = 15,logs = [[1, 5], [1, 15], [2, 10], [2, 20], [3, 15], [3, 25], [4, 20], [4, 30], [5, 25], [5, 35]],x = 10,queries = [10, 20, 30, 40, 50]) == [13, 11, 11, 13, 15]\n assert candidate(n = 10,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],x = 3,queries = [4, 7, 10, 13]) == [6, 6, 6, 9]\n assert candidate(n = 15,logs = [[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]],x = 2,queries = [2, 4, 6, 8, 10, 12, 14, 16]) == [13, 12, 12, 12, 12, 12, 12, 13]\n assert candidate(n = 10,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]],x = 10,queries = [15, 20, 25, 30]) == [0, 0, 4, 9]\n assert candidate(n = 10,logs = [[1, 1], [1, 5], [2, 6], [2, 10], [3, 11], [3, 15], [4, 16], [4, 20], [5, 21], [5, 25], [6, 26], [6, 30], [7, 31], [7, 35], [8, 36], [8, 40], [9, 41], [9, 45], [10, 46], [10, 50]],x = 5,queries = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48]) == [9, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(n = 15,logs = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 20], [12, 20], [13, 20], [14, 20], [15, 20]],x = 10,queries = [15, 20, 25]) == [5, 0, 5]\n assert candidate(n = 10,logs = [[1, 1], [2, 2], [1, 3], [2, 4], [1, 5], [2, 6], [1, 7], [2, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [3, 19], [4, 20]],x = 5,queries = [10, 15, 20, 25]) == [8, 4, 4, 9]\n assert candidate(n = 10,logs = [[1, 2], [2, 5], [3, 5], [4, 10], [5, 15], [6, 20], [7, 25], [8, 30], [9, 35], [10, 40]],x = 5,queries = [10, 15, 20, 25, 30, 35, 40]) == [7, 8, 8, 8, 8, 8, 8]\n assert candidate(n = 15,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20]],x = 10,queries = [10, 20, 30, 40, 50]) == [10, 4, 14, 15, 15]\n assert candidate(n = 12,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]],x = 6,queries = [6, 12, 18, 24]) == [6, 5, 11, 12]\n assert candidate(n = 20,logs = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000], [11, 1100], [12, 1200], [13, 1300], [14, 1400], [15, 1500], [16, 1600], [17, 1700], [18, 1800], [19, 1900], [20, 2000]],x = 1000,queries = [500, 1000, 1500, 2000, 2500]) == [15, 10, 9, 9, 14]\n assert candidate(n = 50,logs = [[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]],x = 5,queries = [6, 11, 16, 21, 26, 31, 36, 41, 46, 51]) == [44, 44, 44, 44, 44, 44, 44, 44, 44, 45]\n assert candidate(n = 6,logs = [[1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17]],x = 5,queries = [10, 15, 20, 25]) == [3, 3, 4, 6]\n assert candidate(n = 10,logs = [[1, 5], [1, 10], [1, 15], [1, 20], [1, 25], [2, 5], [2, 10], [2, 15], [2, 20], [2, 25]],x = 10,queries = [10, 15, 20, 25, 30]) == [8, 8, 8, 8, 8]\n assert candidate(n = 8,logs = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [1, 18], [2, 20]],x = 10,queries = [25, 30, 35]) == [5, 7, 8]\n assert candidate(n = 5,logs = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],x = 10,queries = [5, 15, 25, 35, 45, 55]) == [5, 4, 4, 4, 4, 4]\n assert candidate(n = 7,logs = [[1, 1], [2, 2], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [1, 9], [2, 10]],x = 5,queries = [5, 10, 15, 20]) == [3, 1, 6, 7]\n assert candidate(n = 8,logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15], [8, 16]],x = 10,queries = [10, 20, 30, 40]) == [0, 1, 8, 8]\n assert candidate(n = 20,logs = [[1, 100], [2, 100], [3, 100], [4, 100], [5, 100], [6, 100], [7, 100], [8, 100], [9, 100], [10, 100], [11, 100], [12, 100], [13, 100], [14, 100], [15, 100], [16, 100], [17, 100], [18, 100], [19, 100], [20, 100]],x = 50,queries = [150, 200, 250]) == [0, 20, 20]\n assert candidate(n = 5,logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9]],x = 5,queries = [6, 10]) == [3, 0]\n assert candidate(n = 10,logs = [[1, 10], [1, 20], [1, 30], [2, 15], [2, 25], [3, 10], [3, 20], [4, 10], [4, 30], [5, 5], [5, 15], [5, 25], [5, 35]],x = 10,queries = [20, 25, 30, 35, 40]) == [5, 6, 5, 6, 7]\n assert candidate(n = 8,logs = [[1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45]],x = 5,queries = [15, 25, 35, 45]) == [6, 6, 6, 6]\n assert candidate(n = 10,logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],x = 1,queries = [2, 3]) == [0, 5]\n"}, "metadata": {"canonical_parameter_names": ["n", "logs", "x", "queries"], "leetcode_dataset_entry_point": "Solution().countServers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] countServers(int n, int[][] logs, int x, int[] queries) {", "container": "Solution", "callable": "countServers", "parameters": [{"name": "n", "type": "int"}, {"name": "logs", "type": "int[][]"}, {"name": "x", "type": "int"}, {"name": "queries", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2748, "task_id": "number-of-beautiful-pairs", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. A pair of indices i, j where 0 <= i < j < nums.length is called beautiful if the first digit of nums[i] and the last digit of nums[j] are coprime.\nReturn the total number of beautiful pairs in nums.\nTwo integers x and y are coprime if there is no integer greater than 1 that divides both of them. In other words, x and y are coprime if gcd(x, y) == 1, where gcd(x, y) is the greatest common divisor of x and y.\n \nExample 1:\n\nInput: nums = [2,5,1,4]\nOutput: 5\nExplanation: There are 5 beautiful pairs in nums:\nWhen i = 0 and j = 1: the first digit of nums[0] is 2, and the last digit of nums[1] is 5. We can confirm that 2 and 5 are coprime, since gcd(2,5) == 1.\nWhen i = 0 and j = 2: the first digit of nums[0] is 2, and the last digit of nums[2] is 1. Indeed, gcd(2,1) == 1.\nWhen i = 1 and j = 2: the first digit of nums[1] is 5, and the last digit of nums[2] is 1. Indeed, gcd(5,1) == 1.\nWhen i = 1 and j = 3: the first digit of nums[1] is 5, and the last digit of nums[3] is 4. Indeed, gcd(5,4) == 1.\nWhen i = 2 and j = 3: the first digit of nums[2] is 1, and the last digit of nums[3] is 4. Indeed, gcd(1,4) == 1.\nThus, we return 5.\n\nExample 2:\n\nInput: nums = [11,21,12]\nOutput: 2\nExplanation: There are 2 beautiful pairs:\nWhen i = 0 and j = 1: the first digit of nums[0] is 1, and the last digit of nums[1] is 1. Indeed, gcd(1,1) == 1.\nWhen i = 0 and j = 2: the first digit of nums[0] is 1, and the last digit of nums[2] is 2. Indeed, gcd(1,2) == 1.\nThus, we return 2.\n\n \nConstraints:\n\n2 <= nums.length <= 100\n1 <= nums[i] <= 9999\nnums[i] % 10 != 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 200, 300, 400]) == 3\n assert candidate(nums = [34, 23, 12, 45, 56]) == 5\n assert candidate(nums = [33, 14, 25, 78]) == 5\n assert candidate(nums = [123, 456, 789, 101, 202]) == 9\n assert candidate(nums = [13, 31, 17, 71]) == 6\n assert candidate(nums = [78, 89, 90, 12]) == 3\n assert candidate(nums = [111, 222, 333, 444]) == 5\n assert candidate(nums = [34, 23, 12, 45]) == 4\n assert candidate(nums = [12, 23, 34, 45, 56]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [11, 21, 12]) == 2\n assert candidate(nums = [2, 5, 1, 4]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 27\n assert candidate(nums = [29, 97, 79, 92]) == 4\n assert candidate(nums = [123, 456, 789, 101]) == 6\n assert candidate(nums = [33, 14, 25, 77]) == 6\n assert candidate(nums = [987, 876, 765, 654, 543]) == 6\n assert candidate(nums = [9876, 6543, 3210, 1234]) == 2\n assert candidate(nums = [98, 17, 31, 44]) == 6\n assert candidate(nums = [991, 992, 993, 994, 995, 996, 997, 998, 999]) == 21\n assert candidate(nums = [987, 876, 765, 654, 543, 432, 321, 210, 109]) == 20\n assert candidate(nums = [12, 21, 13, 31, 14, 41, 15, 51, 16, 61]) == 41\n assert candidate(nums = [15, 21, 33, 40, 55]) == 8\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91]) == 17\n assert candidate(nums = [111, 222, 333, 444, 555]) == 9\n assert candidate(nums = [9876, 6543, 3210, 123, 456, 789]) == 3\n assert candidate(nums = [31, 73, 17, 79, 97, 37, 71, 13, 39]) == 23\n assert candidate(nums = [2468, 1357, 8642, 7531, 9753]) == 9\n assert candidate(nums = [22, 44, 88, 16, 32, 64]) == 3\n assert candidate(nums = [89, 76, 53, 20, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [12345, 54321, 98765, 56789, 13579]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 128\n assert candidate(nums = [135, 246, 357, 468, 579, 681, 792, 813, 924]) == 25\n assert candidate(nums = [9876, 8765, 7654, 6543, 5432, 4321]) == 11\n assert candidate(nums = [12345, 23456, 34567, 45678, 56789, 67890, 78901, 89012, 90123]) == 25\n assert candidate(nums = [12, 23, 34, 45, 56, 67, 78, 89, 91]) == 27\n assert candidate(nums = [1234, 2345, 3456, 4567, 5678]) == 7\n assert candidate(nums = [9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9989, 9988, 9987, 9986]) == 40\n assert candidate(nums = [12, 34, 56, 78, 90, 21, 43, 65, 87, 99]) == 34\n assert candidate(nums = [1234, 5678, 9101, 1112, 1314]) == 10\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99]) == 27\n assert candidate(nums = [987, 654, 321, 111, 222]) == 9\n assert candidate(nums = [123, 456, 789, 101, 112, 131]) == 14\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 2020, 3030, 4040]) == 34\n assert candidate(nums = [1234, 5678, 9101, 11213, 141516]) == 8\n assert candidate(nums = [25, 50, 75, 100, 125]) == 4\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84]) == 73\n assert candidate(nums = [6789, 5678, 4567, 3456, 2345, 1234]) == 8\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 27\n assert candidate(nums = [89, 76, 54, 32, 10]) == 3\n assert candidate(nums = [123, 456, 789, 101, 202]) == 9\n assert candidate(nums = [9876, 5432, 1234, 5678, 9012]) == 10\n assert candidate(nums = [10101, 20202, 30303, 40404, 50505, 60606, 70707, 80808, 90909]) == 27\n assert candidate(nums = [12, 21, 34, 43, 56, 65, 78, 87, 90]) == 19\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901]) == 24\n assert candidate(nums = [8888, 7777, 6666, 5555]) == 5\n assert candidate(nums = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111]) == 27\n assert candidate(nums = [9876, 6543, 3210, 9876, 6543]) == 0\n assert candidate(nums = [999, 888, 777, 666, 555, 444]) == 11\n assert candidate(nums = [2357, 1113, 1719, 2329, 3137]) == 10\n assert candidate(nums = [135, 246, 357, 468, 579]) == 8\n assert candidate(nums = [29, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79]) == 57\n assert candidate(nums = [19, 29, 39, 49, 59, 69, 79, 89, 97, 98, 96, 95, 94, 93, 92, 91]) == 85\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 8\n assert candidate(nums = [1234, 4321, 5678, 8765, 9012]) == 6\n assert candidate(nums = [1234, 4321, 5678, 8765, 9876]) == 6\n assert candidate(nums = [101, 203, 305, 407, 509]) == 9\n assert candidate(nums = [9876, 8765, 7654, 6543, 5432]) == 6\n assert candidate(nums = [234, 345, 456, 567, 678, 789, 890, 901]) == 16\n assert candidate(nums = [13, 31, 37, 73, 79, 97]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 76\n assert candidate(nums = [9876, 6543, 3210, 9870]) == 0\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == 27\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 246, 642]) == 16\n assert candidate(nums = [1009, 2008, 3007, 4006, 5005]) == 8\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 59\n assert candidate(nums = [9876, 8765, 7654, 6543, 5432, 4321, 3210, 2109, 1098]) == 19\n assert candidate(nums = [89, 97, 75, 53, 31, 19, 98, 87]) == 23\n assert candidate(nums = [113, 224, 335, 446, 557]) == 8\n assert candidate(nums = [101, 234, 357, 479, 591]) == 9\n assert candidate(nums = [23, 32, 45, 54, 67, 76, 89, 98, 10]) == 15\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 27\n assert candidate(nums = [1111, 2223, 3335, 4447]) == 6\n assert candidate(nums = [1234, 5678, 9101, 1121, 2132, 3143]) == 14\n assert candidate(nums = [13579, 24680, 97531, 86420, 1029384756]) == 5\n assert candidate(nums = [911, 822, 733, 644, 555, 466]) == 10\n assert candidate(nums = [13579, 2468, 97531, 86420, 7539, 6428, 5317, 4206]) == 18\n assert candidate(nums = [9876, 5432, 3210, 1098, 7654]) == 8\n assert candidate(nums = [19, 28, 37, 46, 55, 64, 73, 82, 91]) == 27\n assert candidate(nums = [89, 97, 103, 107, 109]) == 8\n assert candidate(nums = [111, 222, 333, 444, 555, 666]) == 11\n assert candidate(nums = [99, 88, 77, 66, 55, 44, 33, 22, 11]) == 27\n assert candidate(nums = [111222, 222333, 333444, 444555, 555666, 666777, 777888, 888999, 999111]) == 27\n assert candidate(nums = [101, 202, 303, 404, 505]) == 9\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909]) == 27\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96]) == 12\n assert candidate(nums = [12345, 67890, 54321, 90876, 23456]) == 7\n assert candidate(nums = [11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == 27\n assert candidate(nums = [987, 654, 321, 123, 456, 789]) == 6\n assert candidate(nums = [9998, 7775, 5552, 3337, 1111]) == 9\n assert candidate(nums = [1023, 4567, 8910, 1123]) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countBeautifulPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countBeautifulPairs(int[] nums) {", "container": "Solution", "callable": "countBeautifulPairs", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2749, "task_id": "minimum-operations-to-make-the-integer-zero", "difficulty": "Medium", "problem_description": "You are given two integers num1 and num2.\nIn one operation, you can choose integer i in the range [0, 60] and subtract 2i + num2 from num1.\nReturn the integer denoting the minimum number of operations needed to make num1 equal to 0.\nIf it is impossible to make num1 equal to 0, return -1.\n \nExample 1:\n\nInput: num1 = 3, num2 = -2\nOutput: 3\nExplanation: We can make 3 equal to 0 with the following operations:\n- We choose i = 2 and subtract 22 + (-2) from 3, 3 - (4 + (-2)) = 1.\n- We choose i = 2 and subtract 22 + (-2) from 1, 1 - (4 + (-2)) = -1.\n- We choose i = 0 and subtract 20 + (-2) from -1, (-1) - (1 + (-2)) = 0.\nIt can be proven, that 3 is the minimum number of operations that we need to perform.\n\nExample 2:\n\nInput: num1 = 5, num2 = 7\nOutput: -1\nExplanation: It can be proven, that it is impossible to make 5 equal to 0 with the given operation.\n\n \nConstraints:\n\n1 <= num1 <= 109\n-109 <= num2 <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num1 = 8,num2 = 2) == 2\n assert candidate(num1 = 8,num2 = -1) == 2\n assert candidate(num1 = 7,num2 = -3) == 3\n assert candidate(num1 = 1,num2 = 0) == 1\n assert candidate(num1 = 15,num2 = -3) == 3\n assert candidate(num1 = 10,num2 = -3) == 2\n assert candidate(num1 = 1,num2 = 1) == -1\n assert candidate(num1 = 15,num2 = -5) == 4\n assert candidate(num1 = 31,num2 = -2) == 3\n assert candidate(num1 = 123456789,num2 = 987654321) == -1\n assert candidate(num1 = 100,num2 = -10) == 3\n assert candidate(num1 = 64,num2 = -1) == 2\n assert candidate(num1 = 1000000000,num2 = -1000000000) == 12\n assert candidate(num1 = 5,num2 = 7) == -1\n assert candidate(num1 = 3,num2 = -2) == 3\n assert candidate(num1 = 10,num2 = -1) == 2\n assert candidate(num1 = 8,num2 = -3) == 3\n assert candidate(num1 = 1048576,num2 = -512) == 2\n assert candidate(num1 = 1000000000,num2 = 1) == 19\n assert candidate(num1 = 1,num2 = 2) == -1\n assert candidate(num1 = 1073741824,num2 = -536870912) == 2\n assert candidate(num1 = 123456789,num2 = 10000000) == -1\n assert candidate(num1 = 1048576,num2 = -1024) == 2\n assert candidate(num1 = 1024,num2 = -255) == 8\n assert candidate(num1 = 127,num2 = -1) == 1\n assert candidate(num1 = 123456789,num2 = -987654321) == 16\n assert candidate(num1 = 1000000000,num2 = -500000000) == 11\n assert candidate(num1 = 511,num2 = -1) == 1\n assert candidate(num1 = 536870912,num2 = 268435456) == 1\n assert candidate(num1 = 999999999,num2 = -999999998) == 17\n assert candidate(num1 = 32767,num2 = -2) == 3\n assert candidate(num1 = 63,num2 = -1) == 1\n assert candidate(num1 = 2147483647,num2 = 1) == 27\n assert candidate(num1 = 262143,num2 = 1) == 15\n assert candidate(num1 = 1023,num2 = -10) == 5\n assert candidate(num1 = 1000000000,num2 = -999999999) == 19\n assert candidate(num1 = 999999999,num2 = 0) == 21\n assert candidate(num1 = 1023,num2 = 1) == 7\n assert candidate(num1 = 1048575,num2 = -1) == 1\n assert candidate(num1 = 2047,num2 = -2) == 3\n assert candidate(num1 = 513,num2 = 2) == 7\n assert candidate(num1 = 16383,num2 = 1) == 11\n assert candidate(num1 = 1000000000,num2 = 100000000) == -1\n assert candidate(num1 = 2,num2 = -2) == 1\n assert candidate(num1 = 682,num2 = -1) == 6\n assert candidate(num1 = 1023,num2 = -1) == 1\n assert candidate(num1 = 4095,num2 = 3) == 9\n assert candidate(num1 = 63,num2 = -31) == 5\n assert candidate(num1 = 4503599627370496,num2 = -1024) == 2\n assert candidate(num1 = 1073741824,num2 = 268435456) == 2\n assert candidate(num1 = 1073741823,num2 = 1) == 27\n assert candidate(num1 = 1048576,num2 = -65536) == 2\n assert candidate(num1 = 98765,num2 = -49382) == 9\n assert candidate(num1 = 2048,num2 = -1024) == 2\n assert candidate(num1 = 511,num2 = -255) == 7\n assert candidate(num1 = 4095,num2 = -10) == 5\n assert candidate(num1 = 2048,num2 = 512) == 2\n assert candidate(num1 = 100,num2 = 50) == -1\n assert candidate(num1 = 1073741824,num2 = 2147483648) == -1\n assert candidate(num1 = 1023,num2 = -3) == 3\n assert candidate(num1 = 2147483647,num2 = -2147483647) == 31\n assert candidate(num1 = 1024,num2 = 0) == 1\n assert candidate(num1 = 15,num2 = 1) == 3\n assert candidate(num1 = 524287,num2 = -2) == 3\n assert candidate(num1 = 15,num2 = 3) == 2\n assert candidate(num1 = 131071,num2 = -1) == 1\n assert candidate(num1 = 1048575,num2 = 3) == 17\n assert candidate(num1 = 1073741824,num2 = 1073741823) == 1\n assert candidate(num1 = 1073741823,num2 = 2) == 27\n assert candidate(num1 = 1024,num2 = -128) == 2\n assert candidate(num1 = 128,num2 = -32) == 2\n assert candidate(num1 = 2048,num2 = 1024) == 1\n assert candidate(num1 = 2048,num2 = -512) == 2\n assert candidate(num1 = 549755813888,num2 = 1000000) == 22\n assert candidate(num1 = 255,num2 = -1) == 1\n assert candidate(num1 = 1048576,num2 = 1048576) == -1\n assert candidate(num1 = 987654321,num2 = -98765432) == 12\n assert candidate(num1 = 65535,num2 = 3) == 13\n assert candidate(num1 = 999999999,num2 = 1) == 19\n assert candidate(num1 = 42,num2 = -21) == 5\n assert candidate(num1 = 1048576,num2 = 1048575) == 1\n assert candidate(num1 = 1024,num2 = -100) == 4\n assert candidate(num1 = 1000000000,num2 = -100000000) == 12\n assert candidate(num1 = 512,num2 = -512) == 1\n assert candidate(num1 = 127,num2 = -2) == 3\n assert candidate(num1 = 1000,num2 = 333) == -1\n assert candidate(num1 = 500000000,num2 = 250000000) == -1\n assert candidate(num1 = 1048576,num2 = -262144) == 2\n assert candidate(num1 = 1048576,num2 = -524288) == 2\n assert candidate(num1 = 31,num2 = -1) == 1\n assert candidate(num1 = 68719476736,num2 = 1) == 32\n assert candidate(num1 = 1048576,num2 = -1) == 2\n assert candidate(num1 = 2,num2 = 1) == 1\n assert candidate(num1 = 100000,num2 = 10000) == 6\n assert candidate(num1 = 15,num2 = -1) == 1\n assert candidate(num1 = 999999999,num2 = 1000000000) == -1\n assert candidate(num1 = 1048576,num2 = 1024) == 8\n assert candidate(num1 = 1023,num2 = -512) == 11\n assert candidate(num1 = 268435456,num2 = -33554432) == 2\n assert candidate(num1 = 1073741824,num2 = -1073741824) == 1\n assert candidate(num1 = 999999999,num2 = -999999999) == 17\n assert candidate(num1 = 2147483647,num2 = -1000000000) == 21\n assert candidate(num1 = 1048576,num2 = -1048576) == 1\n assert candidate(num1 = 1,num2 = -1000000000) == 13\n assert candidate(num1 = 4294967295,num2 = -1) == 1\n assert candidate(num1 = 512,num2 = -256) == 2\n assert candidate(num1 = 63,num2 = 1) == 5\n assert candidate(num1 = 1048576,num2 = 1) == 16\n assert candidate(num1 = 255,num2 = 3) == 5\n assert candidate(num1 = 1048576,num2 = -1000) == 8\n assert candidate(num1 = 1048576,num2 = 0) == 1\n assert candidate(num1 = 1024,num2 = 512) == 1\n assert candidate(num1 = 1000000000,num2 = 500000000) == -1\n assert candidate(num1 = 1,num2 = -1) == 1\n assert candidate(num1 = 1023,num2 = -511) == 7\n assert candidate(num1 = 123456789,num2 = 123456789) == -1\n assert candidate(num1 = 8191,num2 = -1) == 1\n assert candidate(num1 = 1048575,num2 = 1) == 18\n assert candidate(num1 = 134217727,num2 = -1) == 1\n assert candidate(num1 = 999999999,num2 = 100000000) == -1\n assert candidate(num1 = 500000000,num2 = 500000000) == -1\n assert candidate(num1 = 123456789,num2 = -98765432) == 12\n"}, "metadata": {"canonical_parameter_names": ["num1", "num2"], "leetcode_dataset_entry_point": "Solution().makeTheIntegerZero", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int makeTheIntegerZero(int num1, int num2) {", "container": "Solution", "callable": "makeTheIntegerZero", "parameters": [{"name": "num1", "type": "int"}, {"name": "num2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2750, "task_id": "ways-to-split-array-into-good-subarrays", "difficulty": "Medium", "problem_description": "You are given a binary array nums.\nA subarray of an array is good if it contains exactly one element with the value 1.\nReturn an integer denoting the number of ways to split the array nums into good subarrays. As the number may be too large, return it modulo 109 + 7.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [0,1,0,0,1]\nOutput: 3\nExplanation: There are 3 ways to split nums into good subarrays:\n- [0,1] [0,0,1]\n- [0,1,0] [0,1]\n- [0,1,0,0] [1]\n\nExample 2:\n\nInput: nums = [0,1,0]\nOutput: 1\nExplanation: There is 1 way to split nums into good subarrays:\n- [0,1,0]\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, 0, 1]) == 3\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 1]) == 8\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1]) == 9\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0]) == 4\n assert candidate(nums = [1, 0, 1, 0, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 0, 0, 0, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0]) == 1\n assert candidate(nums = [0, 1, 0]) == 1\n assert candidate(nums = [0, 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, 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, 1]) == 63\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1]) == 60\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]) == 63\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]) == 38\n assert candidate(nums = [1, 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, 1, 0]) == 75\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]) == 96\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, 1]) == 31\n assert candidate(nums = [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]) == 59049\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]) == 25\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1]) == 36\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == 900\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 16\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [0, 0, 1, 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, 1, 0, 0, 1]) == 423\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 36\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 128\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0]) == 60\n assert candidate(nums = [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, 1, 0]) == 41\n assert candidate(nums = [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, 1]) == 17\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, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0]) == 25\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, 1]) == 39\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, 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, 1]) == 43\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 32\n assert candidate(nums = [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, 1]) == 18\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]) == 59049\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 128\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 16\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 100\n assert candidate(nums = [0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]) == 30\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 32\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]) == 60\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 320\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, 1]) == 22\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 17\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, 1]) == 54\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]) == 4096\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 486\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 1]) == 8\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]) == 16384\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]) == 9\n assert candidate(nums = [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]) == 19683\n assert candidate(nums = [0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]) == 49\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, 1]) == 1\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 15\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 729\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]) == 177147\n assert candidate(nums = [1, 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, 1]) == 147\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 19\n assert candidate(nums = [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, 1]) == 17\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == 16\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == 288\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 729\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, 1]) == 47\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\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\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]) == 20\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]) == 29\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 32\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]) == 2048\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1]) == 288\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0]) == 20\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]) == 16384\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 110\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]) == 18\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, 1]) == 30\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 268435456\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numberOfGoodSubarraySplits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfGoodSubarraySplits(int[] nums) {", "container": "Solution", "callable": "numberOfGoodSubarraySplits", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2751, "task_id": "robot-collisions", "difficulty": "Hard", "problem_description": "There are n 1-indexed robots, each having a position on a line, health, and movement direction.\nYou are given 0-indexed integer arrays positions, healths, and a string directions (directions[i] is either 'L' for left or 'R' for right). All integers in positions are unique.\nAll robots start moving on the line simultaneously at the same speed in their given directions. If two robots ever share the same position while moving, they will collide.\nIf two robots collide, the robot with lower health is removed from the line, and the health of the other robot decreases by one. The surviving robot continues in the same direction it was going. If both robots have the same health, they are both removed from the line.\nYour task is to determine the health of the robots that survive the collisions, in the same order that the robots were given, i.e. final health of robot 1 (if survived), final health of robot 2 (if survived), and so on. If there are no survivors, return an empty array.\nReturn an array containing the health of the remaining robots (in the order they were given in the input), after no further collisions can occur.\nNote: The positions may be unsorted.\n \n \nExample 1:\n\n\nInput: positions = [5,4,3,2,1], healths = [2,17,9,15,10], directions = \"RRRRR\"\nOutput: [2,17,9,15,10]\nExplanation: No collision occurs in this example, since all robots are moving in the same direction. So, the health of the robots in order from the first robot is returned, [2, 17, 9, 15, 10].\n\nExample 2:\n\n\nInput: positions = [3,5,2,6], healths = [10,10,15,12], directions = \"RLRL\"\nOutput: [14]\nExplanation: There are 2 collisions in this example. Firstly, robot 1 and robot 2 will collide, and since both have the same health, they will be removed from the line. Next, robot 3 and robot 4 will collide and since robot 4's health is smaller, it gets removed, and robot 3's health becomes 15 - 1 = 14. Only robot 3 remains, so we return [14].\n\nExample 3:\n\n\nInput: positions = [1,2,5,6], healths = [10,10,11,11], directions = \"RLRL\"\nOutput: []\nExplanation: Robot 1 and robot 2 will collide and since both have the same health, they are both removed. Robot 3 and 4 will collide and since both have the same health, they are both removed. So, we return an empty array, [].\n \nConstraints:\n\n1 <= positions.length == healths.length == directions.length == n <= 105\n1 <= positions[i], healths[i] <= 109\ndirections[i] == 'L' or directions[i] == 'R'\nAll values in positions are distinct\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(positions = [2, 4, 6, 8, 10],healths = [30, 25, 20, 15, 10],directions = \"LLRRR\") == [30, 25, 20, 15, 10]\n assert candidate(positions = [2, 4, 6, 8],healths = [1, 2, 3, 4],directions = \"LLLL\") == [1, 2, 3, 4]\n assert candidate(positions = [5, 4, 3, 2, 1],healths = [2, 17, 9, 15, 10],directions = \"RRRRR\") == [2, 17, 9, 15, 10]\n assert candidate(positions = [1, 2, 3, 4],healths = [10, 20, 30, 40],directions = \"RLRL\") == [19, 39]\n assert candidate(positions = [100, 200, 300],healths = [10, 20, 30],directions = \"LRL\") == [10, 29]\n assert candidate(positions = [1, 2, 3, 4, 5],healths = [5, 5, 5, 5, 5],directions = \"RRRLR\") == [5, 5, 5]\n assert candidate(positions = [10, 20, 30],healths = [1, 2, 3],directions = \"RRR\") == [1, 2, 3]\n assert candidate(positions = [1, 2, 3, 4, 5, 6],healths = [1, 2, 3, 4, 5, 6],directions = \"RRLLRR\") == [1, 4, 5, 6]\n assert candidate(positions = [1, 3, 5, 7, 9],healths = [5, 8, 2, 6, 4],directions = \"RRRLL\") == [5, 6]\n assert candidate(positions = [1, 2, 3, 4, 5],healths = [1, 2, 3, 4, 5],directions = \"RRRRR\") == [1, 2, 3, 4, 5]\n assert candidate(positions = [1, 2, 3, 4, 5],healths = [10, 10, 10, 10, 10],directions = \"RLRLR\") == [10]\n assert candidate(positions = [10, 20, 30, 40],healths = [1, 1, 1, 1],directions = \"RRRR\") == [1, 1, 1, 1]\n assert candidate(positions = [1, 3, 5, 7],healths = [5, 5, 5, 5],directions = \"RLRL\") == []\n assert candidate(positions = [10, 20, 30],healths = [3, 2, 1],directions = \"LLL\") == [3, 2, 1]\n assert candidate(positions = [4, 2, 6, 8],healths = [5, 5, 5, 5],directions = \"LRLR\") == [5, 5]\n assert candidate(positions = [6, 5, 4, 3, 2, 1],healths = [6, 5, 4, 3, 2, 1],directions = \"LLRRLL\") == [6, 3, 2, 1]\n assert candidate(positions = [50, 40, 30, 20, 10],healths = [1, 2, 3, 4, 5],directions = \"LLLLL\") == [1, 2, 3, 4, 5]\n assert candidate(positions = [1, 2, 3, 4, 5],healths = [10, 9, 8, 7, 6],directions = \"RRRLL\") == [10, 9, 6]\n assert candidate(positions = [50, 40, 30, 20, 10],healths = [1, 2, 3, 4, 5],directions = \"RRRRR\") == [1, 2, 3, 4, 5]\n assert candidate(positions = [2, 3, 4, 5, 6],healths = [10, 9, 8, 7, 6],directions = \"LLLLL\") == [10, 9, 8, 7, 6]\n assert candidate(positions = [1, 2, 3, 4, 5],healths = [1, 2, 3, 4, 5],directions = \"RLRLR\") == [1, 3, 5]\n assert candidate(positions = [1, 10, 20, 30, 40],healths = [10, 9, 8, 7, 6],directions = \"RRRRR\") == [10, 9, 8, 7, 6]\n assert candidate(positions = [1, 2, 3, 4, 5],healths = [1, 2, 3, 4, 5],directions = \"LLRRL\") == [1, 2, 3]\n assert candidate(positions = [3, 5, 2, 6],healths = [10, 10, 15, 12],directions = \"RLRL\") == [14]\n assert candidate(positions = [1, 3, 5, 7],healths = [20, 15, 10, 5],directions = \"RRRR\") == [20, 15, 10, 5]\n assert candidate(positions = [1, 3, 5, 7, 9],healths = [5, 10, 15, 20, 25],directions = \"RRRLL\") == [17, 25]\n assert candidate(positions = [1, 3, 5, 7, 9],healths = [1, 3, 2, 4, 5],directions = \"RLRLR\") == [2, 3, 5]\n assert candidate(positions = [3, 5, 2, 6],healths = [10, 10, 15, 12],directions = \"RLRL\") == [14]\n assert candidate(positions = [2, 4, 6, 8, 10],healths = [5, 4, 3, 2, 1],directions = \"RRRRR\") == [5, 4, 3, 2, 1]\n assert candidate(positions = [1, 2, 5, 6],healths = [10, 10, 11, 11],directions = \"RLRL\") == []\n assert candidate(positions = [5, 4, 3, 2, 1],healths = [2, 17, 9, 15, 10],directions = \"RRRRR\") == [2, 17, 9, 15, 10]\n assert candidate(positions = [1, 2, 5, 6],healths = [10, 10, 11, 11],directions = \"RLRL\") == []\n assert candidate(positions = [1, 3, 5, 7, 9],healths = [5, 5, 5, 5, 5],directions = \"RLRLR\") == [5]\n assert candidate(positions = [10, 20, 30, 40, 50],healths = [1, 2, 3, 4, 5],directions = \"LLLLL\") == [1, 2, 3, 4, 5]\n assert candidate(positions = [10, 20, 30, 40, 50],healths = [5, 10, 15, 20, 25],directions = \"RLLRR\") == [9, 15, 20, 25]\n assert candidate(positions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],healths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],directions = \"LLRRLLRRLL\") == [10, 10]\n assert candidate(positions = [1, 10, 20, 30, 40, 50],healths = [10, 9, 8, 7, 6, 5],directions = \"RLRLRL\") == [9, 7, 5]\n assert candidate(positions = [10, 20, 30, 40, 50, 60],healths = [5, 4, 3, 2, 1, 6],directions = \"RLRLRL\") == []\n assert candidate(positions = [1, 3, 5, 7, 9],healths = [1, 3, 5, 7, 9],directions = \"RLRLRL\") == [2, 6, 9]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],directions = \"LRRLRLRLRL\") == [10, 11, 14, 16, 18]\n assert candidate(positions = [1, 10, 20, 30, 40],healths = [100, 50, 200, 150, 250],directions = \"RRRRL\") == [246]\n assert candidate(positions = [3, 6, 9, 12, 15, 18],healths = [100, 200, 300, 400, 500, 600],directions = \"RLRLRL\") == [199, 399, 599]\n assert candidate(positions = [100, 200, 300, 400, 500, 600, 700],healths = [1, 2, 3, 4, 5, 6, 7],directions = \"RLLRLRR\") == [1, 3, 4, 6, 7]\n assert candidate(positions = [5, 15, 25, 35, 45],healths = [10, 20, 30, 40, 50],directions = \"LRRRL\") == [10, 47]\n assert candidate(positions = [5, 4, 3, 2, 1],healths = [1, 2, 3, 4, 5],directions = \"LLLLR\") == [1]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],directions = \"RRRRRRRRRL\") == [991]\n assert candidate(positions = [3, 7, 11, 15, 19],healths = [10, 15, 20, 25, 30],directions = \"RLRLR\") == [14, 24, 30]\n assert candidate(positions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],healths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],directions = \"RRLLRRLLRR\") == [1, 2, 3, 6, 7, 10]\n assert candidate(positions = [20, 30, 40, 50, 60],healths = [100, 80, 90, 70, 60],directions = \"RRRRR\") == [100, 80, 90, 70, 60]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],directions = \"RRRRRLLLLL\") == []\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],directions = \"LRRLLRRLLR\") == [1, 1]\n assert candidate(positions = [10, 20, 30, 40, 50],healths = [60, 70, 80, 90, 100],directions = \"LLLLL\") == [60, 70, 80, 90, 100]\n assert candidate(positions = [1, 3, 6, 8, 10],healths = [10, 15, 20, 25, 30],directions = \"RLRLR\") == [14, 24, 30]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],directions = \"RRRRRRRRRR\") == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(positions = [5, 15, 25, 35, 45, 55],healths = [5, 10, 15, 20, 25, 30],directions = \"LRRRLR\") == [5, 22, 30]\n assert candidate(positions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],healths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],directions = \"RRRRRRRRRR\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(positions = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],healths = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],directions = \"LRRLLRLRLL\") == [10, 38, 50, 69, 89, 100]\n assert candidate(positions = [50, 40, 30, 20, 10],healths = [1, 2, 3, 4, 5],directions = \"RRRRR\") == [1, 2, 3, 4, 5]\n assert candidate(positions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],healths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],directions = \"RRLLLLRRLL\") == [10, 10]\n assert candidate(positions = [1, 5, 9, 13, 17],healths = [1, 2, 3, 4, 5],directions = \"RRRRR\") == [1, 2, 3, 4, 5]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],directions = \"RRRRRRRRRR\") == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(positions = [2, 5, 7, 10, 13, 16],healths = [10, 10, 10, 10, 10, 10],directions = \"LLRRLL\") == [10, 10]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5],directions = \"LRRRLLRLRL\") == [10, 47, 40, 29, 9]\n assert candidate(positions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],healths = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],directions = \"RRRLLLRRRLL\") == [10, 20, 30, 67, 80, 90, 100]\n assert candidate(positions = [10, 20, 30, 40, 50],healths = [100, 90, 80, 70, 60],directions = \"RRRLL\") == [100, 90, 78]\n assert candidate(positions = [1, 3, 5, 7, 9, 11],healths = [100, 90, 80, 70, 60, 50],directions = \"RLRLRL\") == [99, 79, 59]\n assert candidate(positions = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],healths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],directions = \"LRLRLRLRLR\") == [1, 2, 4, 6, 8, 10]\n assert candidate(positions = [10, 20, 30, 40, 50],healths = [5, 5, 5, 5, 5],directions = \"RLRLR\") == [5]\n assert candidate(positions = [2, 6, 10, 14, 18],healths = [5, 4, 3, 2, 1],directions = \"LLLLL\") == [5, 4, 3, 2, 1]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],directions = \"RLRLRLRLRL\") == [9, 7, 5, 3, 1]\n assert candidate(positions = [1, 6, 3, 8, 5, 10],healths = [1, 1, 1, 1, 1, 1],directions = \"RLRLRL\") == []\n assert candidate(positions = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],healths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],directions = \"RRRRRRRRRR\") == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],directions = \"RRLRLRLRLR\") == [1, 4, 6, 8, 10]\n assert candidate(positions = [1, 5, 10, 15, 20, 25, 30],healths = [30, 25, 20, 15, 10, 5, 1],directions = \"RRRRRLL\") == [30, 25, 20, 15, 8]\n assert candidate(positions = [3, 6, 9, 12, 15],healths = [15, 20, 25, 30, 35],directions = \"RRRLL\") == [27, 35]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],directions = \"RLRLRLRLRL\") == [99, 79, 59, 39, 19]\n assert candidate(positions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],healths = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],directions = \"LLLLLRRRRR\") == []\n assert candidate(positions = [5, 15, 25, 35, 45, 55],healths = [5, 10, 15, 20, 25, 30],directions = \"LRLRLR\") == [5, 14, 24, 30]\n assert candidate(positions = [10, 20, 30, 40, 50],healths = [5, 15, 25, 35, 45],directions = \"RLRLR\") == [14, 34, 45]\n assert candidate(positions = [10, 20, 30, 40, 50],healths = [100, 90, 80, 70, 60],directions = \"RLRLR\") == [99, 79, 60]\n assert candidate(positions = [50, 40, 30, 20, 10],healths = [1, 2, 3, 4, 5],directions = \"LLRRL\") == [1, 4, 5]\n assert candidate(positions = [100, 200, 300, 400, 500],healths = [1000, 900, 800, 700, 600],directions = \"RRRRR\") == [1000, 900, 800, 700, 600]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],directions = \"RRRRRRRRRR\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(positions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],healths = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],directions = \"RRRRRRRRRL\") == [91]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],directions = \"LRRRRRRRRR\") == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(positions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],healths = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],directions = \"RRRRRRRRRR\") == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]\n assert candidate(positions = [100, 90, 80, 70, 60],healths = [10, 20, 30, 40, 50],directions = \"LRRRL\") == [19, 30, 40, 50]\n assert candidate(positions = [5, 15, 25, 35, 45],healths = [10, 20, 30, 40, 50],directions = \"RLRLR\") == [19, 39, 50]\n assert candidate(positions = [100, 200, 300, 400, 500],healths = [50, 40, 30, 20, 10],directions = \"RLRLR\") == [49, 29, 10]\n assert candidate(positions = [1, 3, 5, 7, 9],healths = [10, 9, 8, 7, 6],directions = \"RLRLR\") == [9, 7, 6]\n assert candidate(positions = [1, 2, 3, 4, 5],healths = [5, 5, 5, 5, 5],directions = \"LRRRL\") == [5, 5, 5]\n assert candidate(positions = [7, 6, 5, 4, 3, 2, 1],healths = [1, 1, 1, 1, 1, 1, 1],directions = \"RLRLRLR\") == [1]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],directions = \"RLRRLLRLRR\") == [19, 48, 60, 79, 90, 100]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],directions = \"RLRLRLRLRL\") == [19, 39, 59, 79, 99]\n assert candidate(positions = [5, 4, 3, 2, 1],healths = [1, 2, 3, 4, 5],directions = \"LLLLL\") == [1, 2, 3, 4, 5]\n assert candidate(positions = [1, 5, 10, 15, 20, 25],healths = [1, 2, 3, 4, 5, 6],directions = \"RRLLLL\") == [1, 4, 5, 6]\n assert candidate(positions = [5, 10, 15, 20, 25, 30],healths = [5, 10, 15, 20, 25, 30],directions = \"RRRLLL\") == [17, 25, 30]\n assert candidate(positions = [1, 5, 9, 13, 17],healths = [2, 4, 6, 8, 10],directions = \"RRRLL\") == [5, 10]\n assert candidate(positions = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],healths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],directions = \"RLRLRLRLRL\") == []\n assert candidate(positions = [5, 4, 3, 2, 1],healths = [1, 10, 100, 1000, 10000],directions = \"LLLLL\") == [1, 10, 100, 1000, 10000]\n assert candidate(positions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],healths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],directions = \"LRRLLRLRRL\") == [1, 2, 5, 6, 8]\n assert candidate(positions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],healths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],directions = \"LLLLLLLLLL\") == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(positions = [1, 3, 5, 7, 9],healths = [100, 100, 100, 100, 100],directions = \"LLRLR\") == [100, 100, 100]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],directions = \"LLLLLLLLLL\") == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(positions = [5, 4, 3, 2, 1],healths = [1, 2, 3, 4, 5],directions = \"RRLLR\") == [1, 2, 3]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5],directions = \"RLRLRLRLRL\") == []\n assert candidate(positions = [8, 5, 2, 11, 14],healths = [10, 20, 30, 40, 50],directions = \"LRLLR\") == [30, 39, 50]\n assert candidate(positions = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10],healths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],directions = \"RLRLRLRLRL\") == []\n assert candidate(positions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],healths = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],directions = \"LRRRRRRRRR\") == [9, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(positions = [1, 5, 3, 7, 9],healths = [9, 7, 5, 3, 1],directions = \"LRRLR\") == [9, 6, 5, 1]\n assert candidate(positions = [1, 10, 20, 30, 40],healths = [1, 2, 3, 4, 5],directions = \"RLLLL\") == [1, 3, 4, 5]\n assert candidate(positions = [5, 2, 9, 3, 8],healths = [10, 20, 15, 25, 30],directions = \"RLRLR\") == [10, 20, 15, 25, 30]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],directions = \"LLLLLLLLLL\") == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(positions = [10, 20, 30, 40, 50],healths = [100, 200, 150, 50, 300],directions = \"RLRLR\") == [199, 149, 300]\n assert candidate(positions = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],healths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],directions = \"LRRLRLRLRL\") == [1, 1]\n assert candidate(positions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],healths = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],directions = \"LRRRRRRRRR\") == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],directions = \"RLRLRLRLRL\") == [1, 3, 5, 7, 9]\n assert candidate(positions = [10, 5, 15, 20, 25],healths = [100, 50, 200, 300, 150],directions = \"RLRLL\") == [50, 298, 150]\n assert candidate(positions = [10, 20, 30, 40, 50],healths = [100, 90, 80, 70, 60],directions = \"RRRRR\") == [100, 90, 80, 70, 60]\n assert candidate(positions = [10, 20, 30, 40, 50, 60],healths = [1, 1, 1, 1, 1, 1],directions = \"RLRLRL\") == []\n assert candidate(positions = [2, 4, 6, 8, 10, 12, 14, 16],healths = [1, 2, 3, 4, 5, 6, 7, 8],directions = \"LRRLLRRLL\") == [1, 2, 5, 6]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],directions = \"RLRLRLRLRL\") == []\n assert candidate(positions = [9, 7, 5, 3, 1],healths = [10, 20, 30, 40, 50],directions = \"LLLLL\") == [10, 20, 30, 40, 50]\n assert candidate(positions = [5, 4, 3, 2, 1],healths = [1, 2, 3, 4, 5],directions = \"RLRLR\") == [1, 2, 4]\n assert candidate(positions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],healths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],directions = \"RLRLRLRLRL\") == []\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],directions = \"LLLLLLLLLL\") == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(positions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],healths = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],directions = \"RLLLLLLLLL\") == [91]\n assert candidate(positions = [1, 4, 6, 8, 10, 12],healths = [5, 12, 7, 10, 3, 8],directions = \"RLRLRR\") == [11, 9, 3, 8]\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],healths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],directions = \"RLRLRLRLRL\") == []\n assert candidate(positions = [100, 90, 80, 70, 60],healths = [5, 10, 15, 20, 25],directions = \"LLRRL\") == [13, 20, 25]\n assert candidate(positions = [1, 5, 9, 13, 17, 21, 25, 29],healths = [25, 25, 25, 25, 25, 25, 25, 25],directions = \"RLRLRLRL\") == []\n assert candidate(positions = [1, 2, 3, 4, 5, 6, 7, 8, 9],healths = [9, 8, 7, 6, 5, 4, 3, 2, 1],directions = \"LRRLLRLRL\") == [9, 8, 5, 3, 1]\n assert candidate(positions = [1, 2, 3, 4, 5, 6],healths = [6, 5, 4, 3, 2, 1],directions = \"RRLLLR\") == [6, 2, 1]\n assert candidate(positions = [1, 3, 5, 7, 9],healths = [2, 4, 6, 8, 10],directions = \"LRRLL\") == [2, 6, 10]\n assert candidate(positions = [1, 2, 3, 4, 5, 6],healths = [1, 2, 3, 4, 5, 6],directions = \"RRRRRR\") == [1, 2, 3, 4, 5, 6]\n assert candidate(positions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],healths = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],directions = \"RRRRRLLLLL\") == [7, 14, 16, 18, 20]\n assert candidate(positions = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],healths = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],directions = \"RLRLRLRLRL\") == [10, 29, 49, 69, 89, 100]\n assert candidate(positions = [5, 1, 9, 3, 7],healths = [10, 20, 30, 40, 50],directions = \"RLLRL\") == [20, 30, 48]\n"}, "metadata": {"canonical_parameter_names": ["positions", "healths", "directions"], "leetcode_dataset_entry_point": "Solution().survivedRobotsHealths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List survivedRobotsHealths(int[] positions, int[] healths, String directions) {", "container": "Solution", "callable": "survivedRobotsHealths", "parameters": [{"name": "positions", "type": "int[]"}, {"name": "healths", "type": "int[]"}, {"name": "directions", "type": "String"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2760, "task_id": "longest-even-odd-subarray-with-threshold", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums and an integer threshold.\nFind the length of the longest subarray of nums starting at index l and ending at index r (0 <= l <= r < nums.length) that satisfies the following conditions:\n\nnums[l] % 2 == 0\nFor all indices i in the range [l, r - 1], nums[i] % 2 != nums[i + 1] % 2\nFor all indices i in the range [l, r], nums[i] <= threshold\n\nReturn an integer denoting the length of the longest such subarray.\nNote: A subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [3,2,5,4], threshold = 5\nOutput: 3\nExplanation: In this example, we can select the subarray that starts at l = 1 and ends at r = 3 => [2,5,4]. This subarray satisfies the conditions.\nHence, the answer is the length of the subarray, 3. We can show that 3 is the maximum possible achievable length.\nExample 2:\n\nInput: nums = [1,2], threshold = 2\nOutput: 1\nExplanation: In this example, we can select the subarray that starts at l = 1 and ends at r = 1 => [2]. \nIt satisfies all the conditions and we can show that 1 is the maximum possible achievable length.\n\nExample 3:\n\nInput: nums = [2,3,4,5], threshold = 4\nOutput: 3\nExplanation: In this example, we can select the subarray that starts at l = 0 and ends at r = 2 => [2,3,4]. \nIt satisfies all the conditions.\nHence, the answer is the length of the subarray, 3. We can show that 3 is the maximum possible achievable length.\n\n \nConstraints:\n\n1 <= nums.length <= 100 \n1 <= nums[i] <= 100 \n1 <= threshold <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 10) == 9\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],threshold = 2) == 10\n assert candidate(nums = [2, 3, 4, 5],threshold = 4) == 3\n assert candidate(nums = [6, 1, 3, 8, 2, 9],threshold = 8) == 2\n assert candidate(nums = [50, 51, 50, 51, 50],threshold = 51) == 5\n assert candidate(nums = [1],threshold = 1) == 0\n assert candidate(nums = [3, 2, 5, 4],threshold = 5) == 3\n assert candidate(nums = [2, 4, 6, 8, 10],threshold = 10) == 1\n assert candidate(nums = [1, 2],threshold = 2) == 1\n assert candidate(nums = [2, 4, 6, 8, 10],threshold = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 5) == 4\n assert candidate(nums = [6, 5, 4, 3, 2, 1],threshold = 6) == 6\n assert candidate(nums = [100, 99, 98, 97, 96],threshold = 100) == 5\n assert candidate(nums = [10, 20, 30, 40, 50],threshold = 25) == 1\n assert candidate(nums = [1, 3, 5, 7, 9],threshold = 10) == 0\n assert candidate(nums = [100, 99, 98, 97, 96, 95],threshold = 100) == 6\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],threshold = 15) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],threshold = 15) == 14\n assert candidate(nums = [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],threshold = 3) == 28\n assert candidate(nums = [2, 3, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14],threshold = 14) == 9\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69],threshold = 55) == 6\n assert candidate(nums = [2, 5, 10, 15, 20, 25, 30],threshold = 20) == 5\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 8) == 7\n assert candidate(nums = [5, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],threshold = 15) == 12\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],threshold = 95) == 5\n assert candidate(nums = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2],threshold = 5) == 23\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],threshold = 10) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],threshold = 95) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],threshold = 5) == 1\n assert candidate(nums = [4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1],threshold = 4) == 16\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],threshold = 3) == 10\n assert candidate(nums = [4, 5, 4, 5, 4, 5, 4, 5, 4, 5],threshold = 4) == 1\n assert candidate(nums = [4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],threshold = 6) == 9\n assert candidate(nums = [50, 49, 50, 49, 50, 49, 50, 49, 50, 49],threshold = 50) == 10\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],threshold = 15) == 6\n assert candidate(nums = [85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70],threshold = 85) == 15\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],threshold = 50) == 50\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],threshold = 2) == 12\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16],threshold = 8) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],threshold = 10) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],threshold = 20) == 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],threshold = 25) == 24\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1],threshold = 15) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 8) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],threshold = 15) == 1\n assert candidate(nums = [99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100],threshold = 100) == 19\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],threshold = 15) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],threshold = 20) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],threshold = 2) == 1\n assert candidate(nums = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],threshold = 15) == 8\n assert candidate(nums = [50, 49, 50, 49, 50, 49, 50, 49, 50, 49],threshold = 50) == 10\n assert candidate(nums = [10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11],threshold = 10) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],threshold = 20) == 2\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],threshold = 15) == 12\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],threshold = 28) == 25\n assert candidate(nums = [3, 6, 7, 8, 5, 4, 3, 2, 1],threshold = 7) == 4\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2],threshold = 3) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 8) == 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],threshold = 2) == 20\n assert candidate(nums = [97, 96, 95, 94, 93, 92, 91, 90, 89, 88],threshold = 95) == 7\n assert candidate(nums = [8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9],threshold = 9) == 20\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],threshold = 15) == 5\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],threshold = 20) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],threshold = 16) == 15\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],threshold = 90) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],threshold = 20) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 10) == 10\n assert candidate(nums = [10, 11, 10, 11, 10, 11, 10, 11],threshold = 11) == 8\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],threshold = 21) == 19\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],threshold = 95) == 5\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],threshold = 10) == 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],threshold = 20) == 19\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8],threshold = 8) == 17\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],threshold = 30) == 29\n assert candidate(nums = [6, 7, 8, 9, 10, 11, 12, 13, 14],threshold = 12) == 7\n assert candidate(nums = [8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9],threshold = 9) == 12\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],threshold = 2) == 20\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31],threshold = 50) == 20\n assert candidate(nums = [100, 99, 100, 99, 100, 99, 100, 99, 100, 99],threshold = 100) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 5) == 4\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10],threshold = 10) == 9\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0],threshold = 6) == 7\n assert candidate(nums = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10],threshold = 10) == 45\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, 2, 1, 2, 1, 2, 1, 2, 1, 2],threshold = 2) == 39\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 10) == 9\n assert candidate(nums = [2, 1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],threshold = 12) == 9\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],threshold = 2) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 10) == 10\n assert candidate(nums = [42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41],threshold = 42) == 16\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],threshold = 25) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 1) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],threshold = 10) == 0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],threshold = 8) == 7\n assert candidate(nums = [2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18],threshold = 18) == 15\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],threshold = 100) == 21\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],threshold = 5) == 29\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],threshold = 25) == 24\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5],threshold = 6) == 14\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],threshold = 2) == 10\n assert candidate(nums = [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46],threshold = 55) == 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],threshold = 10) == 9\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],threshold = 3) == 19\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],threshold = 3) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 10) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],threshold = 18) == 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],threshold = 20) == 19\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],threshold = 10) == 1\n assert candidate(nums = [2, 1, 3, 2, 1, 4, 5, 6, 7, 8],threshold = 5) == 4\n assert candidate(nums = [100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99],threshold = 100) == 20\n assert candidate(nums = [1, 3, 5, 7, 2, 8, 6, 4],threshold = 8) == 1\n assert candidate(nums = [8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30],threshold = 30) == 23\n assert candidate(nums = [2, 5, 4, 7, 6, 9, 8, 11, 10],threshold = 10) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],threshold = 15) == 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],threshold = 100) == 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],threshold = 20) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 7) == 6\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],threshold = 2) == 1\n assert candidate(nums = [5, 8, 7, 6, 5, 4, 3, 2, 1, 100, 99, 98],threshold = 100) == 11\n assert candidate(nums = [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52],threshold = 49) == 8\n assert candidate(nums = [42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43],threshold = 43) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20],threshold = 20) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88],threshold = 95) == 7\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],threshold = 58) == 9\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],threshold = 20) == 11\n"}, "metadata": {"canonical_parameter_names": ["nums", "threshold"], "leetcode_dataset_entry_point": "Solution().longestAlternatingSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestAlternatingSubarray(int[] nums, int threshold) {", "container": "Solution", "callable": "longestAlternatingSubarray", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "threshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2761, "task_id": "prime-pairs-with-target-sum", "difficulty": "Medium", "problem_description": "You are given an integer n. We say that two integers x and y form a prime number pair if:\n\n1 <= x <= y <= n\nx + y == n\nx and y are prime numbers\n\nReturn the 2D sorted list of prime number pairs [xi, yi]. The list should be sorted in increasing order of xi. If there are no prime number pairs at all, return an empty array.\nNote: A prime number is a natural number greater than 1 with only two factors, itself and 1.\n \nExample 1:\n\nInput: n = 10\nOutput: [[3,7],[5,5]]\nExplanation: In this example, there are two prime pairs that satisfy the criteria. \nThese pairs are [3,7] and [5,5], and we return them in the sorted order as described in the problem statement.\n\nExample 2:\n\nInput: n = 2\nOutput: []\nExplanation: We can show that there is no prime number pair that gives a sum of 2, so we return an empty array. \n\n \nConstraints:\n\n1 <= n <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 11) == []\n assert candidate(n = 20) == [[3, 17], [7, 13]]\n assert candidate(n = 2) == []\n assert candidate(n = 10) == [[3, 7], [5, 5]]\n assert candidate(n = 3) == []\n assert candidate(n = 29) == []\n assert candidate(n = 100) == [[3, 97], [11, 89], [17, 83], [29, 71], [41, 59], [47, 53]]\n assert candidate(n = 1000) == [[3, 997], [17, 983], [23, 977], [29, 971], [47, 953], [53, 947], [59, 941], [71, 929], [89, 911], [113, 887], [137, 863], [173, 827], [179, 821], [191, 809], [227, 773], [239, 761], [257, 743], [281, 719], [317, 683], [347, 653], [353, 647], [359, 641], [383, 617], [401, 599], [431, 569], [443, 557], [479, 521], [491, 509]]\n assert candidate(n = 50) == [[3, 47], [7, 43], [13, 37], [19, 31]]\n assert candidate(n = 56789) == []\n assert candidate(n = 300) == [[7, 293], [17, 283], [19, 281], [23, 277], [29, 271], [31, 269], [37, 263], [43, 257], [59, 241], [61, 239], [67, 233], [71, 229], [73, 227], [89, 211], [101, 199], [103, 197], [107, 193], [109, 191], [127, 173], [137, 163], [149, 151]]\n assert candidate(n = 5) == [[2, 3]]\n assert candidate(n = 333) == [[2, 331]]\n assert candidate(n = 60) == [[7, 53], [13, 47], [17, 43], [19, 41], [23, 37], [29, 31]]\n assert candidate(n = 28) == [[5, 23], [11, 17]]\n assert candidate(n = 1009) == []\n assert candidate(n = 30) == [[7, 23], [11, 19], [13, 17]]\n assert candidate(n = 40) == [[3, 37], [11, 29], [17, 23]]\n assert candidate(n = 4) == [[2, 2]]\n assert candidate(n = 37) == []\n assert candidate(n = 10000) == [[59, 9941], [71, 9929], [113, 9887], [149, 9851], [167, 9833], [197, 9803], [233, 9767], [251, 9749], [257, 9743], [281, 9719], [311, 9689], [449, 9551], [461, 9539], [467, 9533], [479, 9521], [503, 9497], [509, 9491], [521, 9479], [563, 9437], [569, 9431], [587, 9413], [659, 9341], [677, 9323], [719, 9281], [743, 9257], [761, 9239], [773, 9227], [797, 9203], [827, 9173], [839, 9161], [863, 9137], [941, 9059], [971, 9029], [1031, 8969], [1049, 8951], [1151, 8849], [1163, 8837], [1181, 8819], [1193, 8807], [1217, 8783], [1259, 8741], [1301, 8699], [1307, 8693], [1319, 8681], [1373, 8627], [1427, 8573], [1487, 8513], [1499, 8501], [1553, 8447], [1571, 8429], [1613, 8387], [1637, 8363], [1709, 8291], [1877, 8123], [1889, 8111], [1907, 8093], [1913, 8087], [1931, 8069], [2063, 7937], [2081, 7919], [2099, 7901], [2207, 7793], [2243, 7757], [2273, 7727], [2297, 7703], [2309, 7691], [2351, 7649], [2357, 7643], [2393, 7607], [2411, 7589], [2417, 7583], [2423, 7577], [2441, 7559], [2459, 7541], [2477, 7523], [2543, 7457], [2549, 7451], [2693, 7307], [2753, 7247], [2789, 7211], [2879, 7121], [2897, 7103], [2957, 7043], [2999, 7001], [3023, 6977], [3041, 6959], [3083, 6917], [3089, 6911], [3137, 6863], [3167, 6833], [3209, 6791], [3221, 6779], [3299, 6701], [3347, 6653], [3449, 6551], [3527, 6473], [3671, 6329], [3677, 6323], [3701, 6299], [3779, 6221], [3797, 6203], [3803, 6197], [3911, 6089], [3947, 6053], [3989, 6011], [4013, 5987], [4019, 5981], [4073, 5927], [4133, 5867], [4139, 5861], [4157, 5843], [4217, 5783], [4259, 5741], [4283, 5717], [4289, 5711], [4349, 5651], [4409, 5591], [4481, 5519], [4493, 5507], [4517, 5483], [4523, 5477], [4583, 5417], [4649, 5351], [4691, 5309], [4703, 5297], [4721, 5279], [4919, 5081]]\n assert candidate(n = 17) == []\n assert candidate(n = 1001) == []\n assert candidate(n = 200000) == [[67, 199933], [79, 199921], [127, 199873], [181, 199819], [193, 199807], [223, 199777], [271, 199729], [313, 199687], [331, 199669], [379, 199621], [397, 199603], [433, 199567], [499, 199501], [547, 199453], [571, 199429], [601, 199399], [643, 199357], [733, 199267], [739, 199261], [919, 199081], [967, 199033], [1033, 198967], [1063, 198937], [1171, 198829], [1231, 198769], [1327, 198673], [1429, 198571], [1447, 198553], [1471, 198529], [1531, 198469], [1609, 198391], [1663, 198337], [1699, 198301], [1723, 198277], [1741, 198259], [1759, 198241], [1777, 198223], [1861, 198139], [1873, 198127], [1987, 198013], [2029, 197971], [2053, 197947], [2113, 197887], [2221, 197779], [2287, 197713], [2311, 197689], [2521, 197479], [2617, 197383], [2659, 197341], [2689, 197311], [2707, 197293], [2731, 197269], [2767, 197233], [2797, 197203], [2917, 197083], [3121, 196879], [3163, 196837], [3169, 196831], [3229, 196771], [3301, 196699], [3313, 196687], [3319, 196681], [3343, 196657], [3457, 196543], [3499, 196501], [3541, 196459], [3547, 196453], [3571, 196429], [3613, 196387], [3697, 196303], [3709, 196291], [3823, 196177], [3889, 196111], [3919, 196081], [3967, 196033], [4003, 195997], [4027, 195973], [4093, 195907], [4219, 195781], [4261, 195739], [4507, 195493], [4657, 195343], [4723, 195277], [4729, 195271], [4759, 195241], [4951, 195049], [4957, 195043], [5011, 194989], [5023, 194977], [5101, 194899], [5233, 194767], [5347, 194653], [5419, 194581], [5431, 194569], [5479, 194521], [5521, 194479], [5557, 194443], [5569, 194431], [5623, 194377], [5647, 194353], [5737, 194263], [5821, 194179], [5851, 194149], [5881, 194119], [6007, 193993], [6043, 193957], [6211, 193789], [6229, 193771], [6277, 193723], [6337, 193663], [6397, 193603], [6427, 193573], [6451, 193549], [6553, 193447], [6577, 193423], [6607, 193393], [6619, 193381], [6673, 193327], [6907, 193093], [6949, 193051], [6991, 193009], [6997, 193003], [7039, 192961], [7069, 192931], [7219, 192781], [7243, 192757], [7333, 192667], [7369, 192631], [7417, 192583], [7537, 192463], [7681, 192319], [7741, 192259], [7867, 192133], [7879, 192121], [7963, 192037], [7993, 192007], [8089, 191911], [8101, 191899], [8167, 191833], [8209, 191791], [8293, 191707], [8311, 191689], [8329, 191671], [8467, 191533], [8527, 191473], [8539, 191461], [8647, 191353], [8719, 191281], [8839, 191161], [8863, 191137], [8929, 191071], [9091, 190909], [9109, 190891], [9157, 190843], [9241, 190759], [9283, 190717], [9343, 190657], [9421, 190579], [9463, 190537], [9613, 190387], [9631, 190369], [9643, 190357], [9661, 190339], [9679, 190321], [9739, 190261], [9871, 190129], [9907, 190093], [9949, 190051], [9973, 190027], [10039, 189961], [10099, 189901], [10141, 189859], [10177, 189823], [10243, 189757], [10267, 189733], [10303, 189697], [10357, 189643], [10453, 189547], [10477, 189523], [10567, 189433], [10639, 189361], [10651, 189349], [10663, 189337], [10729, 189271], [10771, 189229], [10831, 189169], [10861, 189139], [10939, 189061], [10957, 189043], [11047, 188953], [11059, 188941], [11131, 188869], [11173, 188827], [11299, 188701], [11437, 188563], [11467, 188533], [11527, 188473], [11593, 188407], [11677, 188323], [11689, 188311], [11701, 188299], [11719, 188281], [11821, 188179], [11863, 188137], [11971, 188029], [12037, 187963], [12049, 187951], [12073, 187927], [12157, 187843], [12289, 187711], [12301, 187699], [12487, 187513], [12577, 187423], [12583, 187417], [12613, 187387], [12697, 187303], [12763, 187237], [12781, 187219], [12823, 187177], [12829, 187171], [12889, 187111], [12919, 187081], [12973, 187027], [13159, 186841], [13267, 186733], [13291, 186709], [13381, 186619], [13399, 186601], [13417, 186583], [13729, 186271], [13789, 186211], [13903, 186097], [13963, 186037], [14029, 185971], [14083, 185917], [14107, 185893], [14251, 185749], [14293, 185707], [14323, 185677], [14401, 185599], [14407, 185593], [14431, 185569], [14449, 185551], [14461, 185539], [14533, 185467], [14629, 185371], [14767, 185233], [14779, 185221], [14851, 185149], [14869, 185131], [14923, 185077], [14929, 185071], [15031, 184969], [15121, 184879], [15289, 184711], [15307, 184693], [15313, 184687], [15331, 184669], [15349, 184651], [15373, 184627], [15391, 184609], [15511, 184489], [15559, 184441], [15583, 184417], [15649, 184351], [15667, 184333], [15679, 184321], [15727, 184273], [15889, 184111], [15913, 184087], [15919, 184081], [16057, 183943], [16339, 183661], [16363, 183637], [16477, 183523], [16561, 183439], [16603, 183397], [16651, 183349], [16657, 183343], [16693, 183307], [16699, 183301], [16741, 183259], [16963, 183037], [17047, 182953], [17107, 182893], [17299, 182701], [17341, 182659], [17359, 182641], [17383, 182617], [17401, 182599], [17491, 182509], [17497, 182503], [17569, 182431], [17659, 182341], [17761, 182239], [17791, 182209], [17911, 182089], [17959, 182041], [17971, 182029], [17989, 182011], [18043, 181957], [18097, 181903], [18127, 181873], [18211, 181789], [18223, 181777], [18289, 181711], [18307, 181693], [18397, 181603], [18451, 181549], [18541, 181459], [18757, 181243], [18787, 181213], [18859, 181141], [18913, 181087], [18919, 181081], [19051, 180949], [19207, 180793], [19249, 180751], [19333, 180667], [19489, 180511], [19609, 180391], [19753, 180247], [19759, 180241], [19819, 180181], [19927, 180073], [19993, 180007], [20011, 179989], [20047, 179953], [20101, 179899], [20173, 179827], [20341, 179659], [20407, 179593], [20521, 179479], [20563, 179437], [20593, 179407], [20719, 179281], [20731, 179269], [20857, 179143], [20959, 179041], [21013, 178987], [21061, 178939], [21067, 178933], [21169, 178831], [21187, 178813], [21193, 178807], [21247, 178753], [21319, 178681], [21379, 178621], [21391, 178609], [21397, 178603], [21433, 178567], [21487, 178513], [21499, 178501], [21559, 178441], [21649, 178351], [21673, 178327], [21739, 178261], [21751, 178249], [21817, 178183], [21859, 178141], [21961, 178039], [22051, 177949], [22093, 177907], [22111, 177889], [22159, 177841], [22189, 177811], [22447, 177553], [22567, 177433], [22573, 177427], [22621, 177379], [22699, 177301], [22717, 177283], [22777, 177223], [22783, 177217], [22993, 177007], [23011, 176989], [23017, 176983], [23143, 176857], [23203, 176797], [23209, 176791], [23371, 176629], [23497, 176503], [23539, 176461], [23581, 176419], [23599, 176401], [23671, 176329], [23773, 176227], [23911, 176089], [23977, 176023], [24007, 175993], [24061, 175939], [24091, 175909], [24103, 175897], [24109, 175891], [24247, 175753], [24337, 175663], [24379, 175621], [24481, 175519], [24547, 175453], [24691, 175309], [24697, 175303], [24709, 175291], [24733, 175267], [24859, 175141], [24919, 175081], [25057, 174943], [25171, 174829], [25237, 174763], [25321, 174679], [25633, 174367], [25741, 174259], [25759, 174241], [25933, 174067], [25939, 174061], [25951, 174049], [25981, 174019], [26083, 173917], [26161, 173839], [26227, 173773], [26293, 173707], [26317, 173683], [26371, 173629], [26641, 173359], [26737, 173263], [26863, 173137], [26947, 173053], [27031, 172969], [27067, 172933], [27241, 172759], [27259, 172741], [27283, 172717], [27337, 172663], [27367, 172633], [27397, 172603], [27427, 172573], [27481, 172519], [27847, 172153], [28111, 171889], [28123, 171877], [28201, 171799], [28429, 171571], [28447, 171553], [28573, 171427], [28597, 171403], [28729, 171271], [28837, 171163], [28909, 171091], [28921, 171079], [29101, 170899], [29173, 170827], [29191, 170809], [29251, 170749], [29311, 170689], [29443, 170557], [29527, 170473], [29587, 170413], [29611, 170389], [29629, 170371], [29761, 170239], [29803, 170197], [29833, 170167], [30013, 169987], [30091, 169909], [30109, 169891], [30169, 169831], [30211, 169789], [30223, 169777], [30307, 169693], [30319, 169681], [30367, 169633], [30469, 169531], [30517, 169483], [30529, 169471], [30631, 169369], [30661, 169339], [30757, 169243], [30781, 169219], [30841, 169159], [30871, 169129], [30931, 169069], [30937, 169063], [31063, 168937], [31219, 168781], [31231, 168769], [31327, 168673], [31357, 168643], [31477, 168523], [31543, 168457], [31567, 168433], [31723, 168277], [31849, 168151], [31873, 168127], [31891, 168109], [31957, 168043], [31963, 168037], [32029, 167971], [32083, 167917], [32089, 167911], [32191, 167809], [32323, 167677], [32359, 167641], [32377, 167623], [32479, 167521], [32563, 167437], [32587, 167413], [32779, 167221], [32803, 167197], [32887, 167113], [32983, 167017], [33013, 166987], [33091, 166909], [33151, 166849], [33331, 166669], [33343, 166657], [33391, 166609], [33403, 166597], [33529, 166471], [33601, 166399], [33637, 166363], [33703, 166297], [33811, 166189], [33937, 166063], [34039, 165961], [34123, 165877], [34171, 165829], [34183, 165817], [34297, 165703], [34327, 165673], [34537, 165463], [34543, 165457], [34603, 165397], [34651, 165349], [34687, 165313], [34819, 165181], [34897, 165103], [34963, 165037], [35089, 164911], [35107, 164893], [35257, 164743], [35317, 164683], [35323, 164677], [35401, 164599], [35419, 164581], [35569, 164431], [35809, 164191], [35851, 164149], [35911, 164089], [35977, 164023], [36007, 163993], [36013, 163987], [36073, 163927], [36229, 163771], [36373, 163627], [36433, 163567], [36457, 163543], [36523, 163477], [36583, 163417], [36607, 163393], [36637, 163363], [36691, 163309], [36871, 163129], [36973, 163027], [36979, 163021], [36997, 163003], [37003, 162997], [37171, 162829], [37273, 162727], [37309, 162691], [37423, 162577], [37447, 162553], [37483, 162517], [37501, 162499], [37507, 162493], [37549, 162451], [37561, 162439], [37657, 162343], [37993, 162007], [38053, 161947], [38119, 161881], [38239, 161761], [38317, 161683], [38431, 161569], [38593, 161407], [38677, 161323], [38737, 161263], [38767, 161233], [38833, 161167], [38851, 161149], [38953, 161047], [39019, 160981], [39097, 160903], [39139, 160861], [39313, 160687], [39373, 160627], [39397, 160603], [39409, 160591], [39769, 160231], [39799, 160201], [39841, 160159], [39883, 160117], [40063, 159937], [40129, 159871], [40189, 159811], [40213, 159787], [40231, 159769], [40237, 159763], [40429, 159571], [40459, 159541], [40531, 159469], [40543, 159457], [40597, 159403], [40639, 159361], [40801, 159199], [40903, 159097], [40927, 159073], [41077, 158923], [41269, 158731], [41389, 158611], [41593, 158407], [41641, 158359], [41659, 158341], [41887, 158113], [41953, 158047], [41983, 158017], [42169, 157831], [42187, 157813], [42331, 157669], [42373, 157627], [42457, 157543], [42487, 157513], [42571, 157429], [42589, 157411], [42649, 157351], [42697, 157303], [42709, 157291], [42727, 157273], [42793, 157207], [42859, 157141], [42943, 157057], [43159, 156841], [43177, 156823], [43201, 156799], [43321, 156679], [43399, 156601], [43411, 156589], [43579, 156421], [43759, 156241], [43783, 156217], [43891, 156109], [44179, 155821], [44203, 155797], [44269, 155731], [44281, 155719], [44293, 155707], [44491, 155509], [44587, 155413], [44617, 155383], [44623, 155377], [44683, 155317], [44701, 155299], [44797, 155203], [44809, 155191], [44839, 155161], [44917, 155083], [44953, 155047], [44983, 155017], [45127, 154873], [45247, 154753], [45319, 154681], [45427, 154573], [45541, 154459], [45613, 154387], [45631, 154369], [45667, 154333], [45697, 154303], [45757, 154243], [45817, 154183], [45841, 154159], [45943, 154057], [46051, 153949], [46183, 153817], [46237, 153763], [46261, 153739], [46351, 153649], [46411, 153589], [46471, 153529], [46477, 153523], [46489, 153511], [46573, 153427], [46591, 153409], [46663, 153337], [46681, 153319], [46687, 153313], [46723, 153277], [46867, 153133], [46933, 153067], [47041, 152959], [47059, 152941], [47143, 152857], [47149, 152851], [47161, 152839], [47581, 152419], [47623, 152377], [47713, 152287], [47797, 152203], [47917, 152083], [48091, 151909], [48187, 151813], [48271, 151729], [48313, 151687], [48397, 151603], [48463, 151537], [48523, 151477], [48571, 151429], [48619, 151381], [48661, 151339], [48757, 151243], [48787, 151213], [48799, 151201], [48847, 151153], [48859, 151141], [48973, 151027], [48991, 151009], [49009, 150991], [49033, 150967], [49081, 150919], [49117, 150883], [49279, 150721], [49393, 150607], [49411, 150589], [49417, 150583], [49429, 150571], [49477, 150523], [49627, 150373], [49783, 150217], [49789, 150211], [49807, 150193], [49831, 150169], [49939, 150061], [49999, 150001], [50047, 149953], [50101, 149899], [50287, 149713], [50311, 149689], [50377, 149623], [50497, 149503], [50503, 149497], [50581, 149419], [50839, 149161], [50857, 149143], [50923, 149077], [50989, 149011], [51043, 148957], [51109, 148891], [51133, 148867], [51217, 148783], [51307, 148693], [51361, 148639], [51421, 148579], [51427, 148573], [51487, 148513], [51517, 148483], [51613, 148387], [51721, 148279], [51829, 148171], [51853, 148147], [52051, 147949], [52081, 147919], [52147, 147853], [52189, 147811], [52201, 147799], [52291, 147709], [52387, 147613], [52453, 147547], [52543, 147457], [52609, 147391], [52711, 147289], [52747, 147253], [52837, 147163], [52861, 147139], [52903, 147097], [53017, 146983], [53047, 146953], [53233, 146767], [53281, 146719], [53299, 146701], [53323, 146677], [53353, 146647], [53419, 146581], [53437, 146563], [53479, 146521], [53551, 146449], [53593, 146407], [53611, 146389], [53617, 146383], [53653, 146347], [53923, 146077], [54013, 145987], [54037, 145963], [54121, 145879], [54139, 145861], [54181, 145819], [54193, 145807], [54277, 145723], [54319, 145681], [54367, 145633], [54469, 145531], [54499, 145501], [54541, 145459], [54559, 145441], [54577, 145423], [54583, 145417], [54601, 145399], [54787, 145213], [54979, 145021], [55117, 144883], [55171, 144829], [55243, 144757], [55249, 144751], [55291, 144709], [55333, 144667], [55411, 144589], [55621, 144379], [55711, 144289], [55837, 144163], [55897, 144103], [55927, 144073], [55987, 144013], [56053, 143947], [56167, 143833], [56179, 143821], [56209, 143791], [56383, 143617], [56431, 143569], [56473, 143527], [56533, 143467], [56599, 143401], [56671, 143329], [56713, 143287], [56737, 143263], [56893, 143107], [57037, 142963], [57097, 142903], [57163, 142837], [57241, 142759], [57301, 142699], [57427, 142573], [57457, 142543], [57901, 142099], [57943, 142057], [58129, 141871], [58147, 141853], [58171, 141829], [58189, 141811], [58207, 141793], [58231, 141769], [58321, 141679], [58363, 141637], [58603, 141397], [58693, 141307], [58699, 141301], [58921, 141079], [59011, 140989], [59023, 140977], [59107, 140893], [59221, 140779], [59239, 140761], [59341, 140659], [59407, 140593], [59443, 140557], [59467, 140533], [59473, 140527], [59557, 140443], [59581, 140419], [59779, 140221], [59809, 140191], [59833, 140167], [59929, 140071], [60013, 139987], [60139, 139861], [60169, 139831], [60271, 139729], [60337, 139663], [60373, 139627], [60607, 139393], [60631, 139369], [60661, 139339], [60703, 139297], [60727, 139273], [60733, 139267], [61261, 138739], [61339, 138661], [61363, 138637], [61441, 138559], [61483, 138517], [61507, 138493], [61627, 138373], [61651, 138349], [61681, 138319], [61717, 138283], [61819, 138181], [61837, 138163], [61843, 138157], [61861, 138139], [62017, 137983], [62053, 137947], [62131, 137869], [62347, 137653], [62563, 137437], [62617, 137383], [62659, 137341], [62761, 137239], [62791, 137209], [62869, 137131], [62971, 137029], [63103, 136897], [63247, 136753], [63397, 136603], [63463, 136537], [63499, 136501], [63601, 136399], [63607, 136393], [63649, 136351], [63667, 136333], [63691, 136309], [63697, 136303], [63727, 136273], [63793, 136207], [63823, 136177], [63901, 136099], [63907, 136093], [64063, 135937], [64171, 135829], [64279, 135721], [64303, 135697], [64399, 135601], [64489, 135511], [64567, 135433], [64591, 135409], [64609, 135391], [64633, 135367], [64717, 135283], [64849, 135151], [64951, 135049], [65011, 134989], [65053, 134947], [65269, 134731], [65293, 134707], [65323, 134677], [65407, 134593], [65413, 134587], [65419, 134581], [65497, 134503], [65557, 134443], [65563, 134437], [65599, 134401], [65629, 134371], [65647, 134353], [65707, 134293], [65713, 134287], [65731, 134269], [65809, 134191], [65839, 134161], [66037, 133963], [66169, 133831], [66343, 133657], [66403, 133597], [66457, 133543], [66553, 133447], [66697, 133303], [66721, 133279], [66739, 133261], [66883, 133117], [66931, 133069], [66949, 133051], [67033, 132967], [67141, 132859], [67261, 132739], [67339, 132661], [67369, 132631], [67411, 132589], [67453, 132547], [67477, 132523], [67489, 132511], [67531, 132469], [67579, 132421], [67759, 132241], [67801, 132199], [67843, 132157], [67891, 132109], [68041, 131959], [68053, 131947], [68059, 131941], [68161, 131839], [68329, 131671], [68389, 131611], [68521, 131479], [68683, 131317], [68749, 131251], [68899, 131101], [69019, 130981], [69031, 130969], [69073, 130927], [69127, 130873], [69193, 130807], [69313, 130687], [69379, 130621], [69697, 130303], [69739, 130261], [69829, 130171], [69931, 130069], [69997, 130003], [70099, 129901], [70207, 129793], [70237, 129763], [70393, 129607], [70501, 129499], [70621, 129379], [70639, 129361], [70687, 129313], [70879, 129121], [70951, 129049], [70999, 129001], [71059, 128941], [71143, 128857], [71167, 128833], [71233, 128767], [71317, 128683], [71341, 128659], [71437, 128563], [71479, 128521], [71527, 128473], [71551, 128449], [71563, 128437], [71569, 128431], [71713, 128287], [71761, 128239], [71881, 128119], [71887, 128113], [71947, 128053], [72253, 127747], [72337, 127663], [72421, 127579], [72493, 127507], [72547, 127453], [72577, 127423], [72679, 127321], [72739, 127261], [72949, 127051], [73039, 126961], [73141, 126859], [73243, 126757], [73309, 126691], [73369, 126631], [73387, 126613], [73417, 126583], [73453, 126547], [73459, 126541], [73483, 126517], [73651, 126349], [73693, 126307], [73771, 126229], [73849, 126151], [73999, 126001], [74071, 125929], [74101, 125899], [74197, 125803], [74209, 125791], [74257, 125743], [74293, 125707], [74317, 125683], [74383, 125617], [74449, 125551], [74713, 125287], [74731, 125269], [74779, 125221], [74869, 125131], [74887, 125113], [75013, 124987], [75181, 124819], [75217, 124783], [75223, 124777], [75307, 124693], [75367, 124633], [75511, 124489], [75541, 124459], [75553, 124447], [75571, 124429], [75703, 124297], [75709, 124291], [75787, 124213], [75853, 124147], [75913, 124087], [75979, 124021], [76003, 123997], [76147, 123853], [76213, 123787], [76243, 123757], [76333, 123667], [76369, 123631], [76507, 123493], [76543, 123457], [76561, 123439], [76603, 123397], [76771, 123229], [76831, 123169], [76873, 123127], [77029, 122971], [77047, 122953], [77167, 122833], [77239, 122761], [77347, 122653], [77491, 122509], [77551, 122449], [77557, 122443], [77611, 122389], [77797, 122203], [78007, 121993], [78049, 121951], [78079, 121921], [78157, 121843], [78367, 121633], [78553, 121447], [78643, 121357], [78649, 121351], [78691, 121309], [78877, 121123], [78919, 121081], [78979, 121021], [79063, 120937], [79111, 120889], [79153, 120847], [79279, 120721], [79309, 120691], [79393, 120607], [79423, 120577], [79609, 120391], [79669, 120331], [79777, 120223], [79801, 120199], [79843, 120157], [79903, 120097], [80071, 119929], [80077, 119923], [80149, 119851], [80173, 119827], [80191, 119809], [80263, 119737], [80329, 119671], [80341, 119659], [80347, 119653], [80449, 119551], [80611, 119389], [80701, 119299], [80809, 119191], [80911, 119089], [80917, 119083], [80953, 119047], [81097, 118903], [81157, 118843], [81181, 118819], [81199, 118801], [81283, 118717], [81331, 118669], [81457, 118543], [81547, 118453], [81703, 118297], [81727, 118273], [81853, 118147], [81919, 118081], [81943, 118057], [81967, 118033], [82009, 117991], [82021, 117979], [82189, 117811], [82237, 117763], [82279, 117721], [82471, 117529], [82483, 117517], [82759, 117241], [82837, 117163], [82891, 117109], [82963, 117037], [83047, 116953], [83071, 116929], [83077, 116923], [83089, 116911], [83203, 116797], [83269, 116731], [83311, 116689], [83407, 116593], [83557, 116443], [83563, 116437], [83641, 116359], [83761, 116239], [83833, 116167], [83869, 116131], [83911, 116089], [84067, 115933], [84121, 115879], [84127, 115873], [84163, 115837], [84223, 115777], [84229, 115771], [84307, 115693], [84673, 115327], [84691, 115309], [84697, 115303], [84751, 115249], [84979, 115021], [85027, 114973], [85087, 114913], [85201, 114799], [85243, 114757], [85429, 114571], [85447, 114553], [85453, 114547], [85513, 114487], [85549, 114451], [85843, 114157], [85933, 114067], [85999, 114001], [86011, 113989], [86017, 113983], [86239, 113761], [86269, 113731], [86353, 113647], [86461, 113539], [86533, 113467], [86629, 113371], [86767, 113233], [86851, 113149], [86857, 113143], [86869, 113131], [86959, 113041], [87049, 112951], [87313, 112687], [87337, 112663], [87427, 112573], [87541, 112459], [87697, 112303], [87721, 112279], [87739, 112261], [87751, 112249], [87793, 112207], [87931, 112069], [88003, 111997], [88129, 111871], [88423, 111577], [88513, 111487], [88591, 111409], [88663, 111337], [88729, 111271], [88747, 111253], [88771, 111229], [88789, 111211], [88813, 111187], [88873, 111127], [88897, 111103], [88951, 111049], [88969, 111031], [89083, 110917], [89101, 110899], [89119, 110881], [89137, 110863], [89269, 110731], [89371, 110629], [89413, 110587], [89431, 110569], [89443, 110557], [89521, 110479], [89563, 110437], [89689, 110311], [89767, 110233], [89779, 110221], [89839, 110161], [89917, 110083], [89977, 110023], [89983, 110017], [90127, 109873], [90379, 109621], [90403, 109597], [90481, 109519], [90529, 109471], [90547, 109453], [90679, 109321], [90697, 109303], [90703, 109297], [90841, 109159], [91009, 108991], [91033, 108967], [91249, 108751], [91291, 108709], [91369, 108631], [91459, 108541], [91621, 108379], [91711, 108289], [91753, 108247], [91807, 108193], [91813, 108187], [91873, 108127], [91921, 108079], [91939, 108061], [92077, 107923], [92119, 107881], [92143, 107857], [92173, 107827], [92227, 107773], [92353, 107647], [92401, 107599], [92419, 107581], [92551, 107449], [92623, 107377], [92791, 107209], [92863, 107137], [92899, 107101], [93097, 106903], [93133, 106867], [93139, 106861], [93199, 106801], [93241, 106759], [93253, 106747], [93307, 106693], [93319, 106681], [93337, 106663], [93463, 106537], [93559, 106441], [93637, 106363], [93703, 106297], [93739, 106261], [93787, 106213], [93811, 106189], [93871, 106129], [93913, 106087], [93967, 106033], [94033, 105967], [94057, 105943], [94117, 105883], [94273, 105727], [94309, 105691], [94327, 105673], [94351, 105649], [94399, 105601], [94483, 105517], [94603, 105397], [94621, 105379], [94723, 105277], [94747, 105253], [94771, 105229], [94789, 105211], [94903, 105097], [95083, 104917], [95089, 104911], [95131, 104869], [95239, 104761], [95257, 104743], [95317, 104683], [95527, 104473], [95617, 104383], [95713, 104287], [95881, 104119], [95911, 104089], [95947, 104053], [96097, 103903], [96157, 103843], [96199, 103801], [96331, 103669], [96451, 103549], [96517, 103483], [96601, 103399], [96643, 103357], [96667, 103333], [96763, 103237], [96769, 103231], [96823, 103177], [96907, 103093], [96931, 103069], [97159, 102841], [97171, 102829], [97231, 102769], [97327, 102673], [97441, 102559], [97453, 102547], [97501, 102499], [97549, 102451], [97771, 102229], [97861, 102139], [97879, 102121], [97987, 102013], [98251, 101749], [98299, 101701], [98347, 101653], [98389, 101611], [98419, 101581], [98467, 101533], [98473, 101527], [98533, 101467], [98641, 101359], [98713, 101287], [98779, 101221], [98887, 101113], [98893, 101107], [98911, 101089], [99013, 100987], [99259, 100741], [99391, 100609], [99409, 100591], [99607, 100393], [99643, 100357], [99667, 100333], [99709, 100291], [99721, 100279], [99733, 100267], [99787, 100213], [99793, 100207], [99817, 100183], [99871, 100129]]\n assert candidate(n = 23) == []\n assert candidate(n = 80) == [[7, 73], [13, 67], [19, 61], [37, 43]]\n assert candidate(n = 101) == []\n assert candidate(n = 8) == [[3, 5]]\n assert candidate(n = 250) == [[11, 239], [17, 233], [23, 227], [53, 197], [59, 191], [71, 179], [83, 167], [101, 149], [113, 137]]\n assert candidate(n = 100000) == [[11, 99989], [29, 99971], [71, 99929], [167, 99833], [191, 99809], [233, 99767], [239, 99761], [281, 99719], [293, 99707], [311, 99689], [389, 99611], [419, 99581], [449, 99551], [503, 99497], [569, 99431], [599, 99401], [653, 99347], [683, 99317], [743, 99257], [809, 99191], [827, 99173], [863, 99137], [881, 99119], [911, 99089], [947, 99053], [977, 99023], [983, 99017], [1019, 98981], [1061, 98939], [1091, 98909], [1103, 98897], [1151, 98849], [1163, 98837], [1193, 98807], [1283, 98717], [1289, 98711], [1361, 98639], [1373, 98627], [1427, 98573], [1439, 98561], [1481, 98519], [1493, 98507], [1571, 98429], [1613, 98387], [1787, 98213], [1871, 98129], [1877, 98123], [2027, 97973], [2039, 97961], [2069, 97931], [2081, 97919], [2129, 97871], [2141, 97859], [2153, 97847], [2213, 97787], [2351, 97649], [2393, 97607], [2417, 97583], [2423, 97577], [2447, 97553], [2477, 97523], [2621, 97379], [2633, 97367], [2699, 97301], [2741, 97259], [2843, 97157], [2897, 97103], [2927, 97073], [2999, 97001], [3011, 96989], [3041, 96959], [3089, 96911], [3203, 96797], [3221, 96779], [3251, 96749], [3329, 96671], [3413, 96587], [3539, 96461], [3557, 96443], [3581, 96419], [3623, 96377], [3671, 96329], [3677, 96323], [3719, 96281], [3767, 96233], [3779, 96221], [3821, 96179], [3833, 96167], [3851, 96149], [3863, 96137], [3947, 96053], [4013, 95987], [4127, 95873], [4211, 95789], [4217, 95783], [4253, 95747], [4283, 95717], [4349, 95651], [4397, 95603], [4451, 95549], [4493, 95507], [4517, 95483], [4673, 95327], [4721, 95279], [4733, 95267], [4787, 95213], [4889, 95111], [4937, 95063], [4973, 95027], [5039, 94961], [5051, 94949], [5153, 94847], [5189, 94811], [5273, 94727], [5351, 94649], [5387, 94613], [5417, 94583], [5441, 94559], [5471, 94529], [5573, 94427], [5651, 94349], [5657, 94343], [5669, 94331], [5693, 94307], [5849, 94151], [5879, 94121], [6029, 93971], [6089, 93911], [6113, 93887], [6173, 93827], [6299, 93701], [6317, 93683], [6521, 93479], [6581, 93419], [6719, 93281], [6737, 93263], [6761, 93239], [6869, 93131], [6911, 93089], [6917, 93083], [6947, 93053], [7013, 92987], [7043, 92957], [7079, 92921], [7151, 92849], [7211, 92789], [7247, 92753], [7283, 92717], [7307, 92693], [7331, 92669], [7433, 92567], [7541, 92459], [7643, 92357], [7703, 92297], [7757, 92243], [7823, 92177], [7949, 92051], [8039, 91961], [8219, 91781], [8243, 91757], [8297, 91703], [8369, 91631], [8423, 91577], [8429, 91571], [8501, 91499], [8537, 91463], [8543, 91457], [8627, 91373], [8669, 91331], [8747, 91253], [8807, 91193], [8837, 91163], [8849, 91151], [8861, 91139], [9011, 90989], [9029, 90971], [9137, 90863], [9323, 90677], [9341, 90659], [9467, 90533], [9473, 90527], [9629, 90371], [9719, 90281], [9803, 90197], [9851, 90149], [9929, 90071], [9941, 90059], [10037, 89963], [10061, 89939], [10091, 89909], [10103, 89897], [10133, 89867], [10151, 89849], [10181, 89819], [10247, 89753], [10331, 89669], [10343, 89657], [10433, 89567], [10487, 89513], [10499, 89501], [10601, 89399], [10607, 89393], [10613, 89387], [10739, 89261], [10847, 89153], [10949, 89051], [10979, 89021], [11003, 88997], [11117, 88883], [11279, 88721], [11393, 88607], [11411, 88589], [11621, 88379], [11699, 88301], [11777, 88223], [11789, 88211], [11831, 88169], [11981, 88019], [12041, 87959], [12113, 87887], [12119, 87881], [12197, 87803], [12203, 87797], [12281, 87719], [12329, 87671], [12377, 87623], [12413, 87587], [12491, 87509], [12527, 87473], [12641, 87359], [12743, 87257], [12821, 87179], [12893, 87107], [12917, 87083], [12959, 87041], [13007, 86993], [13049, 86951], [13163, 86837], [13187, 86813], [13217, 86783], [13229, 86771], [13421, 86579], [13469, 86531], [13499, 86501], [13523, 86477], [13577, 86423], [13619, 86381], [13649, 86351], [13709, 86291], [13751, 86249], [13757, 86243], [13799, 86201], [13829, 86171], [13883, 86117], [13931, 86069], [14009, 85991], [14153, 85847], [14207, 85793], [14249, 85751], [14423, 85577], [14549, 85451], [14561, 85439], [14639, 85361], [14669, 85331], [14741, 85259], [14753, 85247], [14771, 85229], [14867, 85133], [14879, 85121], [14891, 85109], [14897, 85103], [14939, 85061], [14951, 85049], [15053, 84947], [15131, 84869], [15173, 84827], [15263, 84737], [15269, 84731], [15287, 84713], [15299, 84701], [15467, 84533], [15497, 84503], [15551, 84449], [15569, 84431], [15683, 84317], [15737, 84263], [15761, 84239], [15809, 84191], [16061, 83939], [16067, 83933], [16097, 83903], [16127, 83873], [16187, 83813], [16223, 83777], [16361, 83639], [16421, 83579], [16529, 83471], [16661, 83339], [16823, 83177], [16883, 83117], [16937, 83063], [17117, 82883], [17189, 82811], [17207, 82793], [17387, 82613], [17471, 82529], [17579, 82421], [17627, 82373], [17783, 82217], [17807, 82193], [17837, 82163], [17987, 82013], [18047, 81953], [18131, 81869], [18251, 81749], [18311, 81689], [18329, 81671], [18353, 81647], [18371, 81629], [18701, 81299], [18719, 81281], [18797, 81203], [18803, 81197], [18869, 81131], [18899, 81101], [18917, 81083], [18959, 81041], [19037, 80963], [19181, 80819], [19211, 80789], [19319, 80681], [19373, 80627], [19379, 80621], [19433, 80567], [19463, 80537], [19553, 80447], [19571, 80429], [19727, 80273], [19793, 80207], [19853, 80147], [19889, 80111], [19949, 80051], [19961, 80039], [19979, 80021], [20021, 79979], [20177, 79823], [20183, 79817], [20231, 79769], [20369, 79631], [20399, 79601], [20411, 79589], [20441, 79559], [20507, 79493], [20549, 79451], [20663, 79337], [20681, 79319], [20717, 79283], [20759, 79241], [20771, 79229], [20807, 79193], [20849, 79151], [20897, 79103], [21011, 78989], [21023, 78977], [21059, 78941], [21107, 78893], [21143, 78857], [21191, 78809], [21221, 78779], [21347, 78653], [21377, 78623], [21407, 78593], [21491, 78509], [21503, 78497], [21521, 78479], [21563, 78437], [21599, 78401], [21683, 78317], [21767, 78233], [21821, 78179], [21863, 78137], [22031, 77969], [22067, 77933], [22133, 77867], [22277, 77723], [22409, 77591], [22511, 77489], [22709, 77291], [22721, 77279], [22739, 77261], [22751, 77249], [22787, 77213], [22859, 77141], [22907, 77093], [23039, 76961], [23057, 76943], [23081, 76919], [23087, 76913], [23117, 76883], [23321, 76679], [23327, 76673], [23333, 76667], [23369, 76631], [23459, 76541], [23537, 76463], [23633, 76367], [23741, 76259], [23747, 76253], [23909, 76091], [24179, 75821], [24203, 75797], [24317, 75683], [24359, 75641], [24371, 75629], [24443, 75557], [24473, 75527], [24593, 75407], [24611, 75389], [24623, 75377], [24671, 75329], [24677, 75323], [24851, 75149], [24917, 75083], [24971, 75029], [24989, 75011], [25097, 74903], [25127, 74873], [25169, 74831], [25229, 74771], [25253, 74747], [25301, 74699], [25391, 74609], [25439, 74561], [25469, 74531], [25589, 74411], [25643, 74357], [25703, 74297], [25799, 74201], [25841, 74159], [26141, 73859], [26153, 73847], [26177, 73823], [26249, 73751], [26321, 73679], [26357, 73643], [26387, 73613], [26393, 73607], [26417, 73583], [26669, 73331], [26723, 73277], [26879, 73121], [26921, 73079], [26981, 73019], [26987, 73013], [27077, 72923], [27107, 72893], [27281, 72719], [27299, 72701], [27329, 72671], [27449, 72551], [27539, 72461], [27617, 72383], [27647, 72353], [27749, 72251], [27773, 72227], [27779, 72221], [27827, 72173], [27947, 72053], [27953, 72047], [28001, 71999], [28151, 71849], [28163, 71837], [28211, 71789], [28289, 71711], [28307, 71693], [28403, 71597], [28463, 71537], [28517, 71483], [28547, 71453], [28571, 71429], [28661, 71339], [28751, 71249], [28871, 71129], [28961, 71039], [29009, 70991], [29021, 70979], [29063, 70937], [29123, 70877], [29147, 70853], [29207, 70793], [29231, 70769], [29333, 70667], [29411, 70589], [29429, 70571], [29759, 70241], [29819, 70181], [29837, 70163], [29879, 70121], [29921, 70079], [30059, 69941], [30071, 69929], [30089, 69911], [30323, 69677], [30347, 69653], [30509, 69491], [30803, 69197], [30809, 69191], [30851, 69149], [30881, 69119], [30971, 69029], [31091, 68909], [31121, 68879], [31181, 68819], [31223, 68777], [31271, 68729], [31469, 68531], [31511, 68489], [31517, 68483], [31601, 68399], [31649, 68351], [31721, 68279], [31793, 68207], [31859, 68141], [32057, 67943], [32069, 67931], [32099, 67901], [32117, 67883], [32237, 67763], [32321, 67679], [32369, 67631], [32381, 67619], [32411, 67589], [32423, 67577], [32441, 67559], [32507, 67493], [32573, 67427], [32579, 67421], [32609, 67391], [32693, 67307], [32783, 67217], [32789, 67211], [32831, 67169], [32843, 67157], [32939, 67061], [32957, 67043], [33023, 66977], [33053, 66947], [33149, 66851], [33179, 66821], [33191, 66809], [33203, 66797], [33287, 66713], [33317, 66683], [33347, 66653], [33413, 66587], [33533, 66467], [33569, 66431], [33587, 66413], [33617, 66383], [33623, 66377], [33641, 66359], [33809, 66191], [33827, 66173], [33863, 66137], [33893, 66107], [33911, 66089], [34019, 65981], [34157, 65843], [34211, 65789], [34283, 65717], [34301, 65699], [34313, 65687], [34367, 65633], [34421, 65579], [34457, 65543], [34607, 65393], [34673, 65327], [34871, 65129], [34877, 65123], [35081, 64919], [35099, 64901], [35129, 64871], [35291, 64709], [35339, 64661], [35423, 64577], [35447, 64553], [35597, 64403], [35729, 64271], [35933, 64067], [35963, 64037], [35993, 64007], [36137, 63863], [36161, 63839], [36191, 63809], [36263, 63737], [36341, 63659], [36353, 63647], [36383, 63617], [36389, 63611], [36467, 63533], [36473, 63527], [36479, 63521], [36527, 63473], [36653, 63347], [36683, 63317], [36821, 63179], [36887, 63113], [37013, 62987], [37019, 62981], [37061, 62939], [37097, 62903], [37139, 62861], [37181, 62819], [37199, 62801], [37277, 62723], [37313, 62687], [37361, 62639], [37397, 62603], [37409, 62591], [37493, 62507], [37517, 62483], [37649, 62351], [37781, 62219], [37799, 62201], [37811, 62189], [37871, 62129], [37997, 62003], [38039, 61961], [38219, 61781], [38327, 61673], [38333, 61667], [38447, 61553], [38453, 61547], [38669, 61331], [38747, 61253], [38993, 61007], [39047, 60953], [39113, 60887], [39227, 60773], [39239, 60761], [39341, 60659], [39383, 60617], [39461, 60539], [39503, 60497], [39551, 60449], [39749, 60251], [39791, 60209], [39839, 60161], [39971, 60029], [39983, 60017], [40253, 59747], [40277, 59723], [40433, 59567], [40487, 59513], [40529, 59471], [40559, 59441], [40583, 59417], [40841, 59159], [40949, 59051], [41057, 58943], [41213, 58787], [41243, 58757], [41387, 58613], [41399, 58601], [41519, 58481], [41549, 58451], [41597, 58403], [41609, 58391], [41621, 58379], [41687, 58313], [41729, 58271], [41771, 58229], [41801, 58199], [41849, 58151], [41927, 58073], [41957, 58043], [41969, 58031], [42023, 57977], [42083, 57917], [42101, 57899], [42197, 57803], [42209, 57791], [42227, 57773], [42281, 57719], [42359, 57641], [42407, 57593], [42443, 57557], [42473, 57527], [42533, 57467], [42611, 57389], [42797, 57203], [42821, 57179], [42923, 57077], [42953, 57047], [43037, 56963], [43049, 56951], [43103, 56897], [43313, 56687], [43319, 56681], [43403, 56597], [43457, 56543], [43481, 56519], [43499, 56501], [43607, 56393], [43793, 56207], [43913, 56087], [43961, 56039], [43991, 56009], [43997, 56003], [44111, 55889], [44129, 55871], [44171, 55829], [44201, 55799], [44207, 55793], [44267, 55733], [44279, 55721], [44381, 55619], [44453, 55547], [44531, 55469], [44543, 55457], [44657, 55343], [44687, 55313], [44741, 55259], [44771, 55229], [44927, 55073], [44939, 55061], [45083, 54917], [45119, 54881], [45131, 54869], [45233, 54767], [45377, 54623], [45497, 54503], [45503, 54497], [45557, 54443], [45587, 54413], [45599, 54401], [45677, 54323], [45707, 54293], [45833, 54167], [45989, 54011], [46049, 53951], [46061, 53939], [46073, 53927], [46103, 53897], [46181, 53819], [46187, 53813], [46301, 53699], [46307, 53693], [46451, 53549], [46559, 53441], [46589, 53411], [46619, 53381], [46691, 53309], [46769, 53231], [46811, 53189], [46829, 53171], [46853, 53147], [46997, 53003], [47111, 52889], [47279, 52721], [47303, 52697], [47309, 52691], [47417, 52583], [47459, 52541], [47543, 52457], [47609, 52391], [47639, 52361], [47699, 52301], [47711, 52289], [47741, 52259], [47777, 52223], [47819, 52181], [47837, 52163], [47933, 52067], [48023, 51977], [48029, 51971], [48131, 51869], [48197, 51803], [48281, 51719], [48341, 51659], [48353, 51647], [48407, 51593], [48437, 51563], [48449, 51551], [48479, 51521], [48497, 51503], [48527, 51473], [48539, 51461], [48563, 51437], [48593, 51407], [48761, 51239], [48869, 51131], [48953, 51047], [49031, 50969], [49043, 50957], [49109, 50891], [49211, 50789], [49223, 50777], [49277, 50723], [49409, 50591], [49451, 50549], [49559, 50441], [49613, 50387], [49667, 50333], [49727, 50273], [49739, 50261], [49823, 50177], [49853, 50147], [49871, 50129], [49877, 50123]]\n assert candidate(n = 22) == [[3, 19], [5, 17], [11, 11]]\n assert candidate(n = 89) == []\n assert candidate(n = 9973) == []\n assert candidate(n = 5000) == [[7, 4993], [13, 4987], [31, 4969], [43, 4957], [67, 4933], [97, 4903], [139, 4861], [199, 4801], [211, 4789], [241, 4759], [271, 4729], [277, 4723], [337, 4663], [349, 4651], [379, 4621], [397, 4603], [409, 4591], [433, 4567], [439, 4561], [487, 4513], [577, 4423], [643, 4357], [661, 4339], [673, 4327], [727, 4273], [739, 4261], [757, 4243], [769, 4231], [823, 4177], [907, 4093], [997, 4003], [1033, 3967], [1069, 3931], [1093, 3907], [1123, 3877], [1153, 3847], [1231, 3769], [1291, 3709], [1303, 3697], [1327, 3673], [1429, 3571], [1453, 3547], [1459, 3541], [1471, 3529], [1483, 3517], [1489, 3511], [1531, 3469], [1543, 3457], [1567, 3433], [1609, 3391], [1627, 3373], [1657, 3343], [1669, 3331], [1693, 3307], [1699, 3301], [1741, 3259], [1747, 3253], [1783, 3217], [1831, 3169], [1879, 3121], [1933, 3067], [1951, 3049], [1999, 3001], [2029, 2971], [2083, 2917], [2113, 2887], [2143, 2857], [2203, 2797], [2251, 2749], [2269, 2731], [2281, 2719], [2287, 2713], [2293, 2707], [2311, 2689], [2341, 2659], [2383, 2617]]\n assert candidate(n = 18) == [[5, 13], [7, 11]]\n assert candidate(n = 999983) == []\n assert candidate(n = 89765) == []\n assert candidate(n = 150) == [[11, 139], [13, 137], [19, 131], [23, 127], [37, 113], [41, 109], [43, 107], [47, 103], [53, 97], [61, 89], [67, 83], [71, 79]]\n assert candidate(n = 15) == [[2, 13]]\n assert candidate(n = 654321) == []\n assert candidate(n = 200) == [[3, 197], [7, 193], [19, 181], [37, 163], [43, 157], [61, 139], [73, 127], [97, 103]]\n assert candidate(n = 41) == []\n assert candidate(n = 26) == [[3, 23], [7, 19], [13, 13]]\n assert candidate(n = 31) == [[2, 29]]\n assert candidate(n = 1000001) == []\n assert candidate(n = 750) == [[7, 743], [11, 739], [17, 733], [23, 727], [31, 719], [41, 709], [59, 691], [67, 683], [73, 677], [89, 661], [97, 653], [103, 647], [107, 643], [109, 641], [131, 619], [137, 613], [149, 601], [151, 599], [157, 593], [163, 587], [173, 577], [179, 571], [181, 569], [193, 557], [227, 523], [229, 521], [241, 509], [251, 499], [263, 487], [271, 479], [283, 467], [293, 457], [307, 443], [311, 439], [317, 433], [331, 419], [349, 401], [353, 397], [367, 383]]\n assert candidate(n = 301) == []\n assert candidate(n = 999999) == []\n assert candidate(n = 123456) == [[7, 123449], [17, 123439], [23, 123433], [29, 123427], [37, 123419], [59, 123397], [79, 123377], [83, 123373], [149, 123307], [167, 123289], [197, 123259], [227, 123229], [239, 123217], [313, 123143], [373, 123083], [379, 123077], [397, 123059], [439, 123017], [449, 123007], [499, 122957], [503, 122953], [569, 122887], [587, 122869], [607, 122849], [617, 122839], [857, 122599], [859, 122597], [877, 122579], [929, 122527], [947, 122509], [953, 122503], [967, 122489], [1013, 122443], [1063, 122393], [1069, 122387], [1093, 122363], [1109, 122347], [1129, 122327], [1193, 122263], [1237, 122219], [1249, 122207], [1283, 122173], [1289, 122167], [1307, 122149], [1423, 122033], [1427, 122029], [1429, 122027], [1459, 121997], [1489, 121967], [1493, 121963], [1567, 121889], [1613, 121843], [1667, 121789], [1669, 121787], [1693, 121763], [1759, 121697], [1823, 121633], [1847, 121609], [1877, 121579], [1879, 121577], [1933, 121523], [1949, 121507], [1987, 121469], [2003, 121453], [2017, 121439], [2053, 121403], [2087, 121369], [2089, 121367], [2099, 121357], [2113, 121343], [2129, 121327], [2143, 121313], [2267, 121189], [2287, 121169], [2333, 121123], [2389, 121067], [2393, 121063], [2417, 121039], [2437, 121019], [2459, 120997], [2539, 120917], [2549, 120907], [2557, 120899], [2579, 120877], [2593, 120863], [2609, 120847], [2633, 120823], [2677, 120779], [2689, 120767], [2693, 120763], [2707, 120749], [2719, 120737], [2767, 120689], [2833, 120623], [2837, 120619], [2879, 120577], [2887, 120569], [2917, 120539], [2953, 120503], [3137, 120319], [3163, 120293], [3209, 120247], [3257, 120199], [3299, 120157], [3359, 120097], [3389, 120067], [3407, 120049], [3463, 119993], [3527, 119929], [3533, 119923], [3607, 119849], [3617, 119839], [3643, 119813], [3659, 119797], [3673, 119783], [3697, 119759], [3709, 119747], [3719, 119737], [3733, 119723], [3767, 119689], [3769, 119687], [3779, 119677], [3797, 119659], [3803, 119653], [3823, 119633], [3907, 119549], [3923, 119533], [3943, 119513], [3967, 119489], [4027, 119429], [4093, 119363], [4157, 119299], [4159, 119297], [4219, 119237], [4229, 119227], [4273, 119183], [4283, 119173], [4297, 119159], [4327, 119129], [4349, 119107], [4357, 119099], [4373, 119083], [4409, 119047], [4423, 119033], [4483, 118973], [4549, 118907], [4583, 118873], [4637, 118819], [4657, 118799], [4783, 118673], [4787, 118669], [4993, 118463], [4999, 118457], [5003, 118453], [5087, 118369], [5113, 118343], [5179, 118277], [5197, 118259], [5209, 118247], [5237, 118219], [5309, 118147], [5399, 118057], [5413, 118043], [5419, 118037], [5477, 117979], [5479, 117977], [5483, 117973], [5519, 117937], [5557, 117899], [5573, 117883], [5623, 117833], [5647, 117809], [5659, 117797], [5669, 117787], [5683, 117773], [5693, 117763], [5783, 117673], [5813, 117643], [5839, 117617], [5879, 117577], [5927, 117529], [5939, 117517], [5953, 117503], [6029, 117427], [6043, 117413], [6067, 117389], [6197, 117259], [6217, 117239], [6247, 117209], [6263, 117193], [6323, 117133], [6329, 117127], [6337, 117119], [6529, 116927], [6553, 116903], [6607, 116849], [6637, 116819], [6653, 116803], [6659, 116797], [6709, 116747], [6737, 116719], [6793, 116663], [6863, 116593], [6907, 116549], [6917, 116539], [6949, 116507], [7013, 116443], [7019, 116437], [7069, 116387], [7127, 116329], [7177, 116279], [7187, 116269], [7213, 116243], [7297, 116159], [7349, 116107], [7477, 115979], [7523, 115933], [7573, 115883], [7577, 115879], [7583, 115873], [7603, 115853], [7607, 115849], [7649, 115807], [7673, 115783], [7687, 115769], [7699, 115757], [7723, 115733], [7793, 115663], [7853, 115603], [7867, 115589], [7933, 115523], [8093, 115363], [8147, 115309], [8219, 115237], [8233, 115223], [8273, 115183], [8293, 115163], [8329, 115127], [8377, 115079], [8389, 115067], [8443, 115013], [8543, 114913], [8573, 114883], [8597, 114859], [8609, 114847], [8623, 114833], [8629, 114827], [8647, 114809], [8699, 114757], [8707, 114749], [8713, 114743], [8807, 114649], [8839, 114617], [8863, 114593], [8963, 114493], [8969, 114487], [9049, 114407], [9127, 114329], [9137, 114319], [9157, 114299], [9187, 114269], [9227, 114229], [9239, 114217], [9257, 114199], [9343, 114113], [9413, 114043], [9467, 113989], [9473, 113983], [9547, 113909], [9613, 113843], [9619, 113837], [9677, 113779], [9679, 113777], [9697, 113759], [9733, 113723], [9739, 113717], [9833, 113623], [9967, 113489], [10039, 113417], [10093, 113363], [10099, 113357], [10169, 113287], [10177, 113279], [10223, 113233], [10243, 113213], [10247, 113209], [10267, 113189], [10289, 113167], [10303, 113153], [10313, 113143], [10333, 113123], [10429, 113027], [10433, 113023], [10459, 112997], [10477, 112979], [10529, 112927], [10597, 112859], [10613, 112843], [10657, 112799], [10799, 112657], [10853, 112603], [10867, 112589], [10883, 112573], [10949, 112507], [11027, 112429], [11059, 112397], [11093, 112363], [11117, 112339], [11119, 112337], [11159, 112297], [11177, 112279], [11243, 112213], [11257, 112199], [11317, 112139], [11353, 112103], [11369, 112087], [11437, 112019], [11483, 111973], [11497, 111959], [11503, 111953], [11587, 111869], [11593, 111863], [11657, 111799], [11677, 111779], [11689, 111767], [11789, 111667], [11833, 111623], [11863, 111593], [11923, 111533], [11959, 111497], [11969, 111487], [12109, 111347], [12119, 111337], [12203, 111253], [12227, 111229], [12239, 111217], [12269, 111187], [12329, 111127], [12347, 111109], [12413, 111043], [12479, 110977], [12487, 110969], [12517, 110939], [12539, 110917], [12547, 110909], [12577, 110879], [12637, 110819], [12703, 110753], [12809, 110647], [12853, 110603], [12889, 110567], [12893, 110563], [12899, 110557], [12923, 110533], [12953, 110503], [12979, 110477], [13037, 110419], [13183, 110273], [13187, 110269], [13219, 110237], [13327, 110129], [13337, 110119], [13397, 110059], [13417, 110039], [13469, 109987], [13513, 109943], [13537, 109919], [13553, 109903], [13597, 109859], [13613, 109843], [13627, 109829], [13649, 109807], [13859, 109597], [13873, 109583], [13877, 109579], [14033, 109423], [14143, 109313], [14153, 109303], [14159, 109297], [14177, 109279], [14323, 109133], [14407, 109049], [14419, 109037], [14489, 108967], [14533, 108923], [14549, 108907], [14563, 108893], [14593, 108863], [14629, 108827], [14653, 108803], [14657, 108799], [14717, 108739], [14747, 108709], [14779, 108677], [14813, 108643], [14869, 108587], [14923, 108533], [14939, 108517], [14957, 108499], [15017, 108439], [15077, 108379], [15193, 108263], [15233, 108223], [15263, 108193], [15269, 108187], [15277, 108179], [15329, 108127], [15349, 108107], [15377, 108079], [15443, 108013], [15559, 107897], [15583, 107873], [15619, 107837], [15629, 107827], [15679, 107777], [15683, 107773], [15737, 107719], [15739, 107717], [15809, 107647], [16007, 107449], [16183, 107273], [16187, 107269], [16229, 107227], [16273, 107183], [16319, 107137], [16333, 107123], [16477, 106979], [16493, 106963], [16519, 106937], [16553, 106903], [16603, 106853], [16633, 106823], [16673, 106783], [16703, 106753], [16729, 106727], [16763, 106693], [16787, 106669], [16829, 106627], [17029, 106427], [17093, 106363], [17099, 106357], [17107, 106349], [17137, 106319], [17159, 106297], [17183, 106273], [17239, 106217], [17293, 106163], [17327, 106129], [17333, 106123], [17443, 106013], [17489, 105967], [17573, 105883], [17627, 105829], [17729, 105727], [17783, 105673], [17789, 105667], [17807, 105649], [17837, 105619], [17923, 105533], [17929, 105527], [17939, 105517], [17957, 105499], [17989, 105467], [18049, 105407], [18059, 105397], [18077, 105379], [18089, 105367], [18097, 105359], [18119, 105337], [18133, 105323], [18217, 105239], [18229, 105227], [18257, 105199], [18289, 105167], [18313, 105143], [18433, 105023], [18457, 104999], [18503, 104953], [18523, 104933], [18539, 104917], [18587, 104869], [18713, 104743], [18749, 104707], [18773, 104683], [18797, 104659], [18859, 104597], [18913, 104543], [18919, 104537], [19073, 104383], [19087, 104369], [19213, 104243], [19249, 104207], [19273, 104183], [19309, 104147], [19333, 104123], [19403, 104053], [19423, 104033], [19447, 104009], [19463, 103993], [19477, 103979], [19489, 103967], [19543, 103913], [19553, 103903], [19687, 103769], [19753, 103703], [19813, 103643], [19843, 103613], [19889, 103567], [19927, 103529], [19973, 103483], [20047, 103409], [20063, 103393], [20107, 103349], [20123, 103333], [20149, 103307], [20219, 103237], [20333, 103123], [20357, 103099], [20369, 103087], [20389, 103067], [20407, 103049], [20543, 102913], [20627, 102829], [20663, 102793], [20693, 102763], [20789, 102667], [20809, 102647], [20849, 102607], [20897, 102559], [20959, 102497], [21019, 102437], [21023, 102433], [21059, 102397], [21089, 102367], [21139, 102317], [21157, 102299], [21163, 102293], [21227, 102229], [21317, 102139], [21377, 102079], [21379, 102077], [21397, 102059], [21433, 102023], [21493, 101963], [21499, 101957], [21517, 101939], [21577, 101879], [21587, 101869], [21617, 101839], [21649, 101807], [21737, 101719], [21803, 101653], [21929, 101527], [21943, 101513], [22027, 101429], [22037, 101419], [22073, 101383], [22079, 101377], [22093, 101363], [22109, 101347], [22123, 101333], [22133, 101323], [22189, 101267], [22247, 101209], [22259, 101197], [22273, 101183], [22283, 101173], [22307, 101149], [22343, 101113], [22349, 101107], [22367, 101089], [22447, 101009], [22469, 100987], [22543, 100913], [22549, 100907], [22669, 100787], [22709, 100747], [22783, 100673], [22787, 100669], [22807, 100649], [22907, 100549], [22937, 100519], [22963, 100493], [22973, 100483], [23039, 100417], [23053, 100403], [23063, 100393], [23099, 100357], [23143, 100313], [23159, 100297], [23189, 100267], [23327, 100129], [23399, 100057], [23549, 99907], [23623, 99833], [23627, 99829], [23633, 99823], [23663, 99793], [23669, 99787], [23689, 99767], [23743, 99713], [23747, 99709], [23767, 99689], [23789, 99667], [23813, 99643], [23833, 99623], [23879, 99577], [23893, 99563], [23929, 99527], [24107, 99349], [24109, 99347], [24179, 99277], [24197, 99259], [24223, 99233], [24317, 99139], [24337, 99119], [24373, 99083], [24439, 99017], [24443, 99013], [24509, 98947], [24517, 98939], [24527, 98929], [24547, 98909], [24677, 98779], [24683, 98773], [24767, 98689], [24793, 98663], [24859, 98597], [24923, 98533], [24977, 98479], [24989, 98467], [25013, 98443], [25037, 98419], [25087, 98369], [25229, 98227], [25243, 98213], [25409, 98047], [25439, 98017], [25447, 98009], [25469, 97987], [25537, 97919], [25577, 97879], [25609, 97847], [25643, 97813], [25667, 97789], [25679, 97777], [25847, 97609], [25849, 97607], [25873, 97583], [25903, 97553], [25933, 97523], [25997, 97459], [26003, 97453], [26083, 97373], [26153, 97303], [26297, 97159], [26339, 97117], [26417, 97039], [26449, 97007], [26459, 96997], [26497, 96959], [26633, 96823], [26669, 96787], [26687, 96769], [26693, 96763], [26699, 96757], [26717, 96739], [26759, 96697], [26813, 96643], [26903, 96553], [26959, 96497], [26987, 96469], [27103, 96353], [27127, 96329], [27197, 96259], [27277, 96179], [27299, 96157], [27397, 96059], [27509, 95947], [27527, 95929], [27539, 95917], [27583, 95873], [27653, 95803], [27673, 95783], [27733, 95723], [27739, 95717], [27743, 95713], [27749, 95707], [27823, 95633], [27827, 95629], [27917, 95539], [28027, 95429], [28087, 95369], [28183, 95273], [28279, 95177], [28349, 95107], [28393, 95063], [28429, 95027], [28447, 95009], [28463, 94993], [28549, 94907], [28607, 94849], [28619, 94837], [28663, 94793], [28729, 94727], [28807, 94649], [28843, 94613], [28859, 94597], [28909, 94547], [28927, 94529], [28979, 94477], [29009, 94447], [29017, 94439], [29023, 94433], [29059, 94397], [29077, 94379], [29129, 94327], [29147, 94309], [29287, 94169], [29303, 94153], [29339, 94117], [29347, 94109], [29399, 94057], [29423, 94033], [29473, 93983], [29567, 93889], [29569, 93887], [29629, 93827], [29669, 93787], [29717, 93739], [29753, 93703], [29819, 93637], [29927, 93529], [29959, 93497], [30029, 93427], [30119, 93337], [30133, 93323], [30137, 93319], [30169, 93287], [30203, 93253], [30269, 93187], [30323, 93133], [30367, 93089], [30403, 93053], [30469, 92987], [30497, 92959], [30529, 92927], [30557, 92899], [30593, 92863], [30677, 92779], [30689, 92767], [30703, 92753], [30757, 92699], [30763, 92693], [30773, 92683], [30809, 92647], [30817, 92639], [30829, 92627], [30949, 92507], [30977, 92479], [31069, 92387], [31079, 92377], [31123, 92333], [31139, 92317], [31159, 92297], [31219, 92237], [31223, 92233], [31237, 92219], [31253, 92203], [31267, 92189], [31277, 92179], [31337, 92119], [31379, 92077], [31489, 91967], [31513, 91943], [31517, 91939], [31547, 91909], [31583, 91873], [31643, 91813], [31649, 91807], [31699, 91757], [31723, 91733], [31817, 91639], [31873, 91583], [31883, 91573], [31957, 91499], [31963, 91493], [32003, 91453], [32059, 91397], [32063, 91393], [32069, 91387], [32083, 91373], [32089, 91367], [32159, 91297], [32173, 91283], [32203, 91253], [32213, 91243], [32257, 91199], [32297, 91159], [32303, 91153], [32327, 91129], [32359, 91097], [32377, 91079], [32423, 91033], [32467, 90989], [32479, 90977], [32569, 90887], [32609, 90847], [32633, 90823], [32653, 90803], [32707, 90749], [32779, 90677], [32797, 90659], [32839, 90617], [32909, 90547], [32933, 90523], [32957, 90499], [32983, 90473], [32987, 90469], [33049, 90407], [33053, 90403], [33083, 90373], [33329, 90127], [33349, 90107], [33403, 90053], [33479, 89977], [33493, 89963], [33533, 89923], [33547, 89909], [33589, 89867], [33617, 89839], [33623, 89833], [33637, 89819], [33647, 89809], [33703, 89753], [33767, 89689], [33797, 89659], [33829, 89627], [33857, 89599], [33889, 89567], [33893, 89563], [33923, 89533], [33937, 89519], [33997, 89459], [34039, 89417], [34057, 89399], [34127, 89329], [34183, 89273], [34253, 89203], [34267, 89189], [34303, 89153], [34319, 89137], [34337, 89119], [34369, 89087], [34439, 89017], [34487, 88969], [34519, 88937], [34537, 88919], [34583, 88873], [34589, 88867], [34603, 88853], [34613, 88843], [34649, 88807], [34667, 88789], [34847, 88609], [34849, 88607], [34963, 88493], [35059, 88397], [35117, 88339], [35129, 88327], [35279, 88177], [35327, 88129], [35339, 88117], [35363, 88093], [35419, 88037], [35437, 88019], [35449, 88007], [35569, 87887], [35603, 87853], [35759, 87697], [35869, 87587], [35897, 87559], [35899, 87557], [35933, 87523], [35983, 87473], [36013, 87443], [36073, 87383], [36097, 87359], [36269, 87187], [36277, 87179], [36307, 87149], [36353, 87103], [36373, 87083], [36497, 86959], [36527, 86929], [36529, 86927], [36587, 86869], [36599, 86857], [36643, 86813], [36713, 86743], [36767, 86689], [36779, 86677], [36857, 86599], [36877, 86579], [36923, 86533], [36947, 86509], [36979, 86477], [37003, 86453], [37057, 86399], [37087, 86369], [37159, 86297], [37199, 86257], [37217, 86239], [37273, 86183], [37277, 86179], [37313, 86143], [37339, 86117], [37379, 86077], [37547, 85909], [37567, 85889], [37619, 85837], [37663, 85793], [37813, 85643], [37879, 85577], [37907, 85549], [37987, 85469], [38153, 85303], [38197, 85259], [38219, 85237], [38447, 85009], [38543, 84913], [38629, 84827], [38669, 84787], [38737, 84719], [38783, 84673], [38803, 84653], [38867, 84589], [38923, 84533], [38933, 84523], [38953, 84503], [38993, 84463], [39019, 84437], [39079, 84377], [39107, 84349], [39139, 84317], [39157, 84299], [39209, 84247], [39217, 84239], [39227, 84229], [39233, 84223], [39293, 84163], [39313, 84143], [39367, 84089], [39397, 84059], [39409, 84047], [39439, 84017], [39623, 83833], [39679, 83777], [39719, 83737], [39839, 83617], [39847, 83609], [39877, 83579], [39979, 83477], [40013, 83443], [40039, 83417], [40099, 83357], [40189, 83267], [40213, 83243], [40237, 83219], [40253, 83203], [40433, 83023], [40459, 82997], [40493, 82963], [40543, 82913], [40609, 82847], [40693, 82763], [40697, 82759], [40699, 82757], [40823, 82633], [40847, 82609], [40897, 82559], [40927, 82529], [40949, 82507], [40973, 82483], [40993, 82463], [41117, 82339], [41149, 82307], [41177, 82279], [41189, 82267], [41233, 82223], [41263, 82193], [41389, 82067], [41443, 82013], [41453, 82003], [41513, 81943], [41519, 81937], [41603, 81853], [41609, 81847], [41617, 81839], [41687, 81769], [41719, 81737], [41729, 81727], [41809, 81647], [41887, 81569], [41893, 81563], [41897, 81559], [41903, 81553], [41947, 81509], [41999, 81457], [42017, 81439], [42083, 81373], [42157, 81299], [42223, 81233], [42257, 81199], [42283, 81173], [42293, 81163], [42299, 81157], [42337, 81119], [42359, 81097], [42373, 81083], [42379, 81077], [42407, 81049], [42409, 81047], [42433, 81023], [42437, 81019], [42443, 81013], [42467, 80989], [42533, 80923], [42667, 80789], [42677, 80779], [42709, 80747], [42719, 80737], [42743, 80713], [42773, 80683], [42787, 80669], [42829, 80627], [42853, 80603], [42899, 80557], [42929, 80527], [42943, 80513], [42967, 80489], [43049, 80407], [43093, 80363], [43177, 80279], [43223, 80233], [43283, 80173], [43457, 79999], [43517, 79939], [43609, 79847], [43613, 79843], [43627, 79829], [43633, 79823], [43759, 79697], [43787, 79669], [43867, 79589], [43963, 79493], [44029, 79427], [44059, 79397], [44089, 79367], [44119, 79337], [44123, 79333], [44263, 79193], [44269, 79187], [44417, 79039], [44537, 78919], [44563, 78893], [44579, 78877], [44617, 78839], [44633, 78823], [44647, 78809], [44879, 78577], [44887, 78569], [44917, 78539], [44939, 78517], [44959, 78497], [45139, 78317], [45179, 78277], [45197, 78259], [45263, 78193], [45289, 78167], [45293, 78163], [45317, 78139], [45319, 78137], [45377, 78079], [45439, 78017], [45523, 77933], [45557, 77899], [45589, 77867], [45659, 77797], [45673, 77783], [45737, 77719], [45757, 77699], [45767, 77689], [45869, 77587], [45887, 77569], [45893, 77563], [45943, 77513], [45979, 77477], [46073, 77383], [46133, 77323], [46187, 77269], [46219, 77237], [46439, 77017], [46507, 76949], [46549, 76907], [46573, 76883], [46619, 76837], [46679, 76777], [46703, 76753], [46723, 76733], [46807, 76649], [46853, 76603], [46877, 76579], [46919, 76537], [46993, 76463], [47087, 76369], [47123, 76333], [47207, 76249], [47293, 76163], [47297, 76159], [47309, 76147], [47353, 76103], [47417, 76039], [47459, 75997], [47543, 75913], [47623, 75833], [47659, 75797], [47713, 75743], [47777, 75679], [47797, 75659], [47837, 75619], [47903, 75553], [47917, 75539], [47977, 75479], [48049, 75407], [48079, 75377], [48109, 75347], [48119, 75337], [48179, 75277], [48187, 75269], [48239, 75217], [48247, 75209], [48497, 74959], [48523, 74933], [48527, 74929], [48533, 74923], [48677, 74779], [48757, 74699], [48847, 74609], [48859, 74597], [48869, 74587], [48883, 74573], [48889, 74567], [48947, 74509], [49003, 74453], [49037, 74419], [49043, 74413], [49103, 74353], [49139, 74317], [49169, 74287], [49177, 74279], [49199, 74257], [49253, 74203], [49279, 74177], [49297, 74159], [49307, 74149], [49363, 74093], [49409, 74047], [49429, 74027], [49549, 73907], [49559, 73897], [49597, 73859], [49633, 73823], [49747, 73709], [49757, 73699], [49783, 73673], [49843, 73613], [49927, 73529], [49939, 73517], [50023, 73433], [50069, 73387], [50077, 73379], [50087, 73369], [50093, 73363], [50129, 73327], [50147, 73309], [50153, 73303], [50329, 73127], [50377, 73079], [50417, 73039], [50459, 72997], [50497, 72959], [50503, 72953], [50549, 72907], [50587, 72869], [50723, 72733], [50767, 72689], [50777, 72679], [50833, 72623], [50839, 72617], [50909, 72547], [50923, 72533], [50989, 72467], [51169, 72287], [51203, 72253], [51229, 72227], [51283, 72173], [51287, 72169], [51347, 72109], [51383, 72073], [51413, 72043], [51437, 72019], [51473, 71983], [51539, 71917], [51577, 71879], [51607, 71849], [51613, 71843], [51647, 71809], [51679, 71777], [51749, 71707], [51859, 71597], [51893, 71563], [51907, 71549], [51929, 71527], [51973, 71483], [51977, 71479], [52027, 71429], [52057, 71399], [52067, 71389], [52069, 71387], [52103, 71353], [52127, 71329], [52163, 71293], [52223, 71233], [52289, 71167], [52313, 71143], [52387, 71069], [52433, 71023], [52457, 70999], [52543, 70913], [52579, 70877], [52673, 70783], [52727, 70729], [52747, 70709], [52769, 70687], [52817, 70639], [52837, 70619], [52883, 70573], [52919, 70537], [52967, 70489], [52999, 70457], [53017, 70439], [53077, 70379], [53129, 70327], [53147, 70309], [53233, 70223], [53279, 70177], [53299, 70157], [53377, 70079], [53437, 70019], [53453, 70003], [53527, 69929], [53597, 69859], [53609, 69847], [53623, 69833], [53629, 69827], [53693, 69763], [53717, 69739], [53719, 69737], [53759, 69697], [53899, 69557], [53917, 69539], [53959, 69497], [53993, 69463], [54139, 69317], [54193, 69263], [54217, 69239], [54293, 69163], [54347, 69109], [54437, 69019], [54493, 68963], [54539, 68917], [54547, 68909], [54559, 68897], [54577, 68879], [54679, 68777], [54713, 68743], [54727, 68729], [54773, 68683], [54787, 68669], [54917, 68539], [54949, 68507], [54973, 68483], [54979, 68477], [54983, 68473], [55009, 68447], [55057, 68399], [55127, 68329], [55217, 68239], [55229, 68227], [55243, 68213], [55249, 68207], [55343, 68113], [55469, 67987], [55529, 67927], [55589, 67867], [55603, 67853], [55667, 67789], [55673, 67783], [55697, 67759], [55733, 67723], [55837, 67619], [55849, 67607], [55889, 67567], [55897, 67559], [55933, 67523], [55967, 67489], [56003, 67453], [56009, 67447], [56087, 67369], [56113, 67343], [56149, 67307], [56167, 67289], [56209, 67247], [56237, 67219], [56239, 67217], [56267, 67189], [56269, 67187], [56299, 67157], [56377, 67079], [56383, 67073], [56453, 67003], [56479, 66977], [56509, 66947], [56533, 66923], [56659, 66797], [56773, 66683], [56813, 66643], [56827, 66629], [56923, 66533], [56957, 66499], [56989, 66467], [56993, 66463], [56999, 66457], [57073, 66383], [57097, 66359], [57119, 66337], [57163, 66293], [57283, 66173], [57287, 66169], [57347, 66109], [57349, 66107], [57367, 66089], [57373, 66083], [57389, 66067], [57427, 66029], [57493, 65963], [57527, 65929], [57529, 65927], [57557, 65899], [57667, 65789], [57679, 65777], [57727, 65729], [57737, 65719], [57809, 65647], [57839, 65617], [57847, 65609], [57899, 65557], [57917, 65539], [57977, 65479], [58043, 65413], [58049, 65407], [58099, 65357], [58129, 65327], [58147, 65309], [58169, 65287], [58189, 65267], [58199, 65257], [58217, 65239], [58243, 65213], [58309, 65147], [58337, 65119], [58367, 65089], [58393, 65063], [58403, 65053], [58427, 65029], [58453, 65003], [58537, 64919], [58579, 64877], [58603, 64853], [58693, 64763], [58763, 64693], [58789, 64667], [58889, 64567], [58943, 64513], [58967, 64489], [59023, 64433], [59053, 64403], [59083, 64373], [59123, 64333], [59219, 64237], [59233, 64223], [59239, 64217], [59333, 64123], [59393, 64063], [59419, 64037], [59443, 64013], [59617, 63839], [59663, 63793], [59729, 63727], [59747, 63709], [59753, 63703], [59797, 63659], [59809, 63647], [59879, 63577], [59929, 63527], [59957, 63499], [60013, 63443], [60017, 63439], [60037, 63419], [60089, 63367], [60103, 63353], [60139, 63317], [60209, 63247], [60257, 63199], [60259, 63197], [60343, 63113], [60353, 63103], [60383, 63073], [60397, 63059], [60427, 63029], [60527, 62929], [60637, 62819], [60703, 62753], [60733, 62723], [60773, 62683], [60859, 62597], [60917, 62539], [60923, 62533], [61129, 62327], [61153, 62303], [61223, 62233], [61357, 62099], [61403, 62053], [61409, 62047], [61417, 62039], [61469, 61987], [61507, 61949], [61547, 61909], [61613, 61843], [61637, 61819], [61643, 61813]]\n assert candidate(n = 500) == [[13, 487], [37, 463], [43, 457], [61, 439], [67, 433], [79, 421], [103, 397], [127, 373], [151, 349], [163, 337], [193, 307], [223, 277], [229, 271]]\n assert candidate(n = 54321) == [[2, 54319]]\n assert candidate(n = 13) == [[2, 11]]\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().findPrimePairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List> findPrimePairs(int n) {", "container": "Solution", "callable": "findPrimePairs", "parameters": [{"name": "n", "type": "int"}], "return_type": "List>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2762, "task_id": "continuous-subarrays", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. A subarray of nums is called continuous if:\n\nLet i, i + 1, ..., j be the indices in the subarray. Then, for each pair of indices i <= i1, i2 <= j, 0 <= |nums[i1] - nums[i2]| <= 2.\n\nReturn the total number of continuous subarrays.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [5,4,2,4]\nOutput: 8\nExplanation: \nContinuous subarray of size 1: [5], [4], [2], [4].\nContinuous subarray of size 2: [5,4], [4,2], [2,4].\nContinuous subarray of size 3: [4,2,4].\nThere are no subarrys of size 4.\nTotal continuous subarrays = 4 + 3 + 1 = 8.\nIt can be shown that there are no more continuous subarrays.\n\n \nExample 2:\n\nInput: nums = [1,2,3]\nOutput: 6\nExplanation: \nContinuous subarray of size 1: [1], [2], [3].\nContinuous subarray of size 2: [1,2], [2,3].\nContinuous subarray of size 3: [1,2,3].\nTotal continuous subarrays = 3 + 2 + 1 = 6.\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, 2, 4]) == 8\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4]) == 27\n assert candidate(nums = [9, 7, 5, 3, 1]) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 24\n assert candidate(nums = [1, 3, 5, 7, 9]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5]) == 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]) == 210\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 6\n assert candidate(nums = [2, 2, 2, 1, 1, 3, 3, 3]) == 36\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 19\n assert candidate(nums = [10, 9, 8, 8, 7, 6, 5, 5, 4, 3, 2, 1]) == 39\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [1, 2, 2, 2, 3, 3]) == 21\n assert candidate(nums = [1, 2, 2, 2, 1]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 15\n assert candidate(nums = [1, 3, 1, 3, 1, 3]) == 21\n assert candidate(nums = [1, 2, 2, 2, 3]) == 15\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 27\n assert candidate(nums = [1, 3, 5, 4, 6, 7, 8, 2]) == 17\n assert candidate(nums = [1, 2, 3]) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 55\n assert candidate(nums = [1, 1, 1, 1, 1, 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]) == 57\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 42\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 31\n assert candidate(nums = [100, 101, 102, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 60\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 210\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5]) == 63\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 57\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4]) == 69\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 97\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 210\n assert candidate(nums = [1, 5, 2, 3, 7, 4, 8, 6, 10, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 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]) == 90\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]) == 59\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490]) == 87\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 57\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2]) == 210\n assert candidate(nums = [4, 4, 5, 4, 4, 6, 5, 4, 4, 3]) == 49\n assert candidate(nums = [1, 5, 4, 2, 4, 1, 3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 37\n assert candidate(nums = [1, 4, 2, 3, 2, 3, 4, 1, 2, 3, 2, 3, 4, 1]) == 43\n assert candidate(nums = [10, 10, 9, 11, 12, 8, 7, 6, 10, 10, 9, 11, 12, 8, 7, 6]) == 36\n assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5]) == 153\n assert candidate(nums = [2, 4, 6, 8, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 8, 6, 4, 2, 0]) == 42\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]) == 72\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == 210\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 10\n assert candidate(nums = [3, 3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 120\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, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 162\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 33\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == 210\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 = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 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]) == 98\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, 3, 2, 1]) == 325\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 210\n assert candidate(nums = [1, 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, 3, 2, 3, 2, 3]) == 1081\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4]) == 69\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]) == 57\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 45\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 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]) == 72\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == 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]) == 72\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]) == 60\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 465\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 54\n assert candidate(nums = [1000000000, 999999999, 1000000000, 999999998, 1000000000, 1000000001, 999999997, 1000000000, 1000000002, 999999996]) == 22\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4]) == 60\n assert candidate(nums = [1000000000, 999999998, 1000000001, 999999997, 1000000002, 999999996, 1000000003, 999999995, 1000000004, 999999994]) == 11\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5]) == 69\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 38\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 2, 1, 1, 1, 2, 3, 3, 2, 1]) == 120\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3]) == 117\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [1000000000, 999999998, 1000000002, 1000000001, 999999999, 1000000003, 999999997, 1000000004, 999999996, 1000000005]) == 13\n assert candidate(nums = [5, 1, 5, 3, 3, 5, 2, 4, 4, 2, 3, 5, 6, 8, 7, 9, 10, 8, 6, 4, 2, 1]) == 52\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 19\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 55\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]) == 820\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]) == 78\n assert candidate(nums = [5, 7, 8, 5, 6, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 59\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]) == 990\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 55\n assert candidate(nums = [10, 11, 12, 10, 11, 12, 10, 11, 12, 10, 11, 12, 10, 11, 12, 10, 11, 12, 10, 11]) == 210\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 39\n assert candidate(nums = [5, 4, 4, 4, 4, 5, 6, 7, 8, 7, 6, 5, 4, 4, 4, 4, 5]) == 71\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 210\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2]) == 54\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == 210\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]) == 496\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 10]) == 267\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]) == 87\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 472\n assert candidate(nums = [100, 99, 100, 98, 99, 100, 97, 98, 99, 100]) == 30\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 63\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]) == 69\n assert candidate(nums = [5, 6, 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]) == 141\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1]) == 55\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 57\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 55\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 39\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 54\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 20\n assert candidate(nums = [1, 3, 5, 3, 1, 3, 5, 3, 1, 3]) == 23\n assert candidate(nums = [5, 3, 5, 2, 5, 3, 5, 2, 5, 3, 5, 2, 5, 3, 5, 2, 5, 3, 5, 2, 5, 3, 5, 2, 5, 3, 5, 2, 5, 3, 5, 2, 5, 3, 5, 2, 5, 3, 5, 2, 5, 3, 5, 2, 5, 3]) == 80\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 81\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 55\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]) == 60\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 = [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, 2, 3, 4, 5, 4, 3, 2, 1]) == 147\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 65\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 210\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 55\n assert candidate(nums = [20, 18, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 2, 4, 6, 8, 10, 12, 14, 16]) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 48\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 210\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 7, 4, 8, 3, 9, 2, 10, 1]) == 35\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]) == 72\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]) == 84\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 210\n assert candidate(nums = [10, 11, 12, 10, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 58\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 1]) == 66\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 30\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 27\n assert candidate(nums = [4, 2, 2, 2, 3, 4, 5]) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 57\n assert candidate(nums = [1, 4, 2, 3, 2, 5, 4, 3]) == 17\n assert candidate(nums = [1, 2, 3, 2, 1]) == 15\n assert candidate(nums = [1, 3, 2, 3, 1]) == 15\n assert candidate(nums = [1000000000, 999999999, 1000000001, 999999998, 1000000002]) == 8\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 42\n assert candidate(nums = [3, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 55\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 1, 3, 2, 1]) == 55\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 48\n assert candidate(nums = [1, 2, 2, 1]) == 10\n assert candidate(nums = [3, 3, 2, 2, 1, 1, 4, 4, 5, 5]) == 31\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 6\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4]) == 45\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 55\n assert candidate(nums = [2, 2, 2, 1, 3]) == 15\n assert candidate(nums = [100, 101, 102, 99, 98, 97, 96]) == 15\n assert candidate(nums = [10, 9, 8, 7, 6]) == 12\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 30\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 42\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 4, 4, 5, 6, 6, 6, 7, 8, 8, 8, 9, 10, 10, 10]) == 102\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 10\n assert candidate(nums = [1, 2, 2, 3, 2, 1, 2, 2, 3, 2]) == 55\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [1, 2, 2, 3, 4]) == 14\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 3, 3, 3, 4, 4, 4]) == 60\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 3, 3, 3, 2, 2, 2]) == 78\n assert candidate(nums = [1, 3, 2, 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]) == 2850\n assert candidate(nums = [5, 4, 3, 4, 5]) == 15\n assert candidate(nums = [1, 1000000000]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [1, 3, 5, 7, 9]) == 9\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == 5\n assert candidate(nums = [5, 2, 2, 4, 5, 3]) == 12\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 55\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 37\n assert candidate(nums = [1, 1, 1, 1]) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 57\n assert candidate(nums = [1, 2, 3, 4, 5]) == 12\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 60\n assert candidate(nums = [1000000000, 999999999, 1000000001, 1000000002]) == 8\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000]) == 10\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 45\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1]) == 120\n assert candidate(nums = [1, 3, 5, 3, 1, 3, 5, 3, 1]) == 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3321\n assert candidate(nums = [10, 10, 10, 10, 10]) == 15\n assert candidate(nums = [10, 10, 10, 10, 10, 10]) == 21\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 4, 3, 2, 1]) == 36\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 55\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4]) == 45\n assert candidate(nums = [2, 2, 2, 1, 3, 1, 3, 2, 2, 1]) == 55\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 19\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]) == 60\n assert candidate(nums = [1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 2, 2, 1]) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 55\n assert candidate(nums = [1, 2, 2, 2, 2, 2]) == 21\n assert candidate(nums = [1, 3, 2, 2, 1, 3, 2, 2, 1]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 33\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 55\n assert candidate(nums = [3, 1]) == 3\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1]) == 45\n assert candidate(nums = [1, 3]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 21\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0]) == 117\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5]) == 23\n assert candidate(nums = [5, 7, 7, 8, 8, 10]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 29\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 28\n assert candidate(nums = [5, 6, 7, 8, 9, 5, 6, 7, 8, 9]) == 24\n assert candidate(nums = [1, 2]) == 3\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 15\n assert candidate(nums = [1, 2, 3]) == 6\n assert candidate(nums = [1, 3, 2, 3, 1, 4, 2, 3, 1]) == 24\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 27\n assert candidate(nums = [10, 10, 10, 10]) == 10\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3]) == 120\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 33\n assert candidate(nums = [1, 4, 2, 3, 5, 6, 7, 8, 9]) == 20\n assert candidate(nums = [1000000000]) == 1\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10]) == 21\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 51\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1]) == 36\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1]) == 18\n assert candidate(nums = [1, 4, 7, 10, 13]) == 5\n assert candidate(nums = [10, 9, 10, 11, 10, 9, 10, 11, 10, 9]) == 55\n assert candidate(nums = [5, 4, 2, 4]) == 8\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 55\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 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]) == 57\n assert candidate(nums = [3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6]) == 57\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 64\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == 45\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().continuousSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long continuousSubarrays(int[] nums) {", "container": "Solution", "callable": "continuousSubarrays", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2763, "task_id": "sum-of-imbalance-numbers-of-all-subarrays", "difficulty": "Hard", "problem_description": "The imbalance number of a 0-indexed integer array arr of length n is defined as the number of indices in sarr = sorted(arr) such that:\n\n0 <= i < n - 1, and\nsarr[i+1] - sarr[i] > 1\n\nHere, sorted(arr) is the function that returns the sorted version of arr.\nGiven a 0-indexed integer array nums, return the sum of imbalance numbers of all its subarrays.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [2,3,1,4]\nOutput: 3\nExplanation: There are 3 subarrays with non-zero imbalance numbers:\n- Subarray [3, 1] with an imbalance number of 1.\n- Subarray [3, 1, 4] with an imbalance number of 1.\n- Subarray [1, 4] with an imbalance number of 1.\nThe imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 3. \n\nExample 2:\n\nInput: nums = [1,3,3,3,5]\nOutput: 8\nExplanation: There are 7 subarrays with non-zero imbalance numbers:\n- Subarray [1, 3] with an imbalance number of 1.\n- Subarray [1, 3, 3] with an imbalance number of 1.\n- Subarray [1, 3, 3, 3] with an imbalance number of 1.\n- Subarray [1, 3, 3, 3, 5] with an imbalance number of 2. \n- Subarray [3, 3, 3, 5] with an imbalance number of 1. \n- Subarray [3, 3, 5] with an imbalance number of 1.\n- Subarray [3, 5] with an imbalance number of 1.\nThe imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 8. \n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [10, 1, 2, 3, 4]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 3, 1, 4]) == 3\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 3, 3, 3, 5]) == 8\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 36\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == 105\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10]) == 73\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]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 11, 12, 13, 14, 15]) == 166\n assert candidate(nums = [3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 4, 4, 4, 4, 5, 5, 5, 5]) == 64\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 46\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 84\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10, 15, 11, 14, 12, 13]) == 204\n assert candidate(nums = [500, 501, 499, 502, 498, 503, 497, 504, 496, 505, 495, 506, 494, 507, 493, 508, 492, 509, 491, 510]) == 171\n assert candidate(nums = [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 = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10]) == 69\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 262\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]) == 72\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 262\n assert candidate(nums = [3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == 6\n assert candidate(nums = [5, 3, 2, 4, 1, 6, 7, 8, 9, 10, 11, 12]) == 47\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 7, 8, 9, 10]) == 31\n assert candidate(nums = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 15, 11, 14, 12, 13]) == 118\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 = [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]) == 0\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]) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 30\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 171\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 8\n assert candidate(nums = [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 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 54\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 560\n assert candidate(nums = [50, 1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10, 60, 11, 61, 12, 62, 13, 63, 14, 64, 15]) == 435\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 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 = [7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 11, 12, 13, 14, 15]) == 68\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 0\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == 0\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1330\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == 190\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]) == 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, 1, 2, 3, 4, 5]) == 80\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == 6\n assert candidate(nums = [100, 1, 2, 101, 3, 102, 4, 103, 5, 104, 6, 105, 7, 106, 8, 107, 9, 108, 10, 109]) == 189\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93]) == 105\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 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]) == 36\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]) == 265\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 = [7, 3, 5, 9, 1, 4, 6, 8, 2, 10]) == 91\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 0\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]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13, 18, 17, 16, 21, 20, 19, 24, 23, 22, 27, 26, 25, 29, 28]) == 461\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92]) == 153\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]) == 72\n assert candidate(nums = [2, 1, 3, 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]) == 36\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 85\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, 2, 3, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 36\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 9\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 560\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 154\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 3, 2, 6, 5, 4, 10, 9, 8, 15, 14, 13, 12, 11]) == 102\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 846\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 36\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 7, 8, 10, 9]) == 39\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]) == 325\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]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 36\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 18\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [5, 1, 4, 2, 8, 6, 3, 7, 9]) == 49\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 7\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 134\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [2, 3, 1, 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]) == 391\n assert candidate(nums = [100, 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 = [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, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9]) == 560\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 560\n assert candidate(nums = [5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 3, 3, 3, 3, 3]) == 250\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1, 3, 2]) == 1\n assert candidate(nums = [1, 3, 3, 3, 5]) == 8\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 0\n assert candidate(nums = [1, 5, 3, 4, 2]) == 6\n assert candidate(nums = [1, 2, 3, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 20\n assert candidate(nums = [1, 2, 3, 5, 6, 8, 9, 10]) == 30\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 0\n assert candidate(nums = [1000, 999, 998, 997, 996]) == 0\n assert candidate(nums = [3, 1, 2]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [3, 2, 1]) == 0\n assert candidate(nums = [3, 1, 2, 4, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [10, 1, 2, 9, 3, 8, 4, 7, 5, 6]) == 35\n assert candidate(nums = [7, 9, 5, 8, 2, 6, 3, 4, 1]) == 46\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4]) == 0\n assert candidate(nums = [1, 2, 3, 4]) == 0\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6]) == 0\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(nums = [2]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 20\n assert candidate(nums = [7, 9, 7, 8, 7]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4]) == 0\n assert candidate(nums = [10, 1, 2, 9, 3, 8, 4, 7, 5, 6]) == 35\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 1]) == 0\n assert candidate(nums = [7]) == 0\n assert candidate(nums = [3, 2, 1, 2, 3]) == 0\n assert candidate(nums = [2, 3, 1, 4]) == 3\n assert candidate(nums = [1, 1000]) == 1\n assert candidate(nums = [3, 1, 2, 4, 3]) == 3\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5]) == 0\n assert candidate(nums = [2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1]) == 0\n assert candidate(nums = [3, 3, 3]) == 0\n assert candidate(nums = [999, 1000]) == 0\n assert candidate(nums = [7, 9, 5, 8, 6]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [3, 2, 1, 4, 5]) == 4\n assert candidate(nums = [7, 9, 5, 8, 6, 4]) == 15\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [4, 3, 2, 1]) == 0\n assert candidate(nums = [7, 9, 9, 7, 10, 8]) == 11\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 4, 2, 3]) == 3\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [2, 1, 3]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [3, 5, 7, 9, 11]) == 20\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5]) == 0\n assert candidate(nums = [1, 2, 2, 1, 2]) == 0\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4]) == 0\n assert candidate(nums = [1, 5, 2, 4, 3]) == 6\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == 17\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [1, 2, 3, 5, 6, 8, 9]) == 22\n assert candidate(nums = [3, 3, 2, 2, 1, 1]) == 0\n assert candidate(nums = [3, 3, 2, 2, 1, 1]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumImbalanceNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int sumImbalanceNumbers(int[] nums) {", "container": "Solution", "callable": "sumImbalanceNumbers", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2765, "task_id": "longest-alternating-subarray", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. A subarray s of length m is called alternating if:\n\nm is greater than 1.\ns1 = s0 + 1.\nThe 0-indexed subarray s looks like [s0, s1, s0, s1,...,s(m-1) % 2]. In other words, s1 - s0 = 1, s2 - s1 = -1, s3 - s2 = 1, s4 - s3 = -1, and so on up to s[m - 1] - s[m - 2] = (-1)m.\n\nReturn the maximum length of all alternating subarrays present in nums or -1 if no such subarray exists.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [2,3,4,3,4]\nOutput: 4\nExplanation:\nThe alternating subarrays are [2, 3], [3,4], [3,4,3], and [3,4,3,4]. The longest of these is [3,4,3,4], which is of length 4.\n\nExample 2:\n\nInput: nums = [4,5,6]\nOutput: 2\nExplanation:\n[4,5] and [5,6] are the only two alternating subarrays. They are both of length 2.\n\n \nConstraints:\n\n2 <= nums.length <= 100\n1 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [10, 9, 8, 9, 8, 9, 10]) == 4\n assert candidate(nums = [3, 2, 1, 2, 1, 2, 3, 2, 1]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == -1\n assert candidate(nums = [2, 2, 2, 3, 4, 3, 2, 3, 4]) == 3\n assert candidate(nums = [2, 3, 4, 3, 4]) == 4\n assert candidate(nums = [5, 4, 5, 4, 5]) == 4\n assert candidate(nums = [2, 1, 2, 1, 2]) == 4\n assert candidate(nums = [10, 9, 10, 9, 10]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [10, 9, 10, 9, 10, 9]) == 5\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 9\n assert candidate(nums = [5, 6, 7, 8, 7, 6, 7, 8]) == 3\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6]) == 3\n assert candidate(nums = [1, 3, 2, 3, 2, 3]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5]) == -1\n assert candidate(nums = [1, 3, 2, 3, 2, 3, 2]) == 5\n assert candidate(nums = [3, 2, 3, 2, 3, 2, 3]) == 6\n assert candidate(nums = [1, 3, 2, 3, 2, 3, 4, 3, 2]) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 2\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2]) == 8\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1]) == 7\n assert candidate(nums = [10, 9, 10, 9, 10, 9, 10]) == 6\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3]) == 4\n assert candidate(nums = [3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 2\n assert candidate(nums = [4, 5, 6]) == 2\n assert candidate(nums = [1, 2, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 3, 2, 3, 2, 3, 4]) == 4\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [10, 11, 10, 11, 12, 13, 12, 11, 12, 11, 10]) == 4\n assert candidate(nums = [9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10]) == 18\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9]) == 4\n assert candidate(nums = [7, 8, 9, 10, 9, 8, 9, 10, 9, 8, 9, 10, 9, 8, 9]) == 3\n assert candidate(nums = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10]) == 18\n assert candidate(nums = [3, 4, 3, 4, 3, 4, 5, 4, 3, 4, 3, 4, 5, 4, 3]) == 6\n assert candidate(nums = [3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3]) == 3\n assert candidate(nums = [10, 11, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4]) == 4\n assert candidate(nums = [10, 11, 12, 11, 10, 11, 12, 13, 14, 15, 16, 17, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 3\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\n assert candidate(nums = [10, 11, 10, 11, 10, 11, 12, 11, 10, 11, 12]) == 6\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 19\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(nums = [10, 11, 10, 11, 10, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12]) == 14\n assert candidate(nums = [5, 6, 7, 6, 5, 6, 7, 6, 5, 6, 7, 6, 5, 6, 7, 6, 5]) == 3\n assert candidate(nums = [100, 101, 102, 103, 102, 103, 102, 103, 102, 103, 102, 103, 102]) == 11\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6]) == 26\n assert candidate(nums = [2, 1, 2, 3, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2]) == 5\n assert candidate(nums = [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]) == 33\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\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, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 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, 13, 12, 14, 13, 15, 14]) == -1\n assert candidate(nums = [8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9]) == 20\n assert candidate(nums = [1, 3, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5]) == 3\n assert candidate(nums = [10, 11, 10, 11, 12, 11, 12, 13, 12, 13, 14]) == 4\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]) == 23\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3]) == 3\n assert candidate(nums = [3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8, 7, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8]) == 35\n assert candidate(nums = [1, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 4\n assert candidate(nums = [2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4]) == 3\n assert candidate(nums = [1, 3, 2, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]) == 4\n assert candidate(nums = [1, 1, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3]) == 4\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 0]) == 3\n assert candidate(nums = [10, 11, 12, 11, 10, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 7, 8, 9]) == 3\n assert candidate(nums = [7, 8, 7, 8, 7, 8, 9, 8, 9, 8, 7, 8, 7, 6, 7, 8, 7]) == 6\n assert candidate(nums = [5, 6, 7, 6, 7, 8, 7, 8, 9, 8, 9]) == 4\n assert candidate(nums = [4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6]) == 3\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [7, 8, 7, 8, 9, 8, 7, 8, 9, 10, 9, 8, 7, 8, 9, 10, 11, 10, 9, 8]) == 4\n assert candidate(nums = [3, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5]) == 4\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 7, 8, 7, 8, 9, 10, 9, 10, 9, 8, 7, 6, 5]) == 6\n assert candidate(nums = [15, 16, 17, 18, 19, 20, 21, 20, 19, 18, 17, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 16, 17]) == 3\n assert candidate(nums = [7, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9]) == 24\n assert candidate(nums = [7, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8]) == 19\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 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, 1, 2]) == 32\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6]) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 18\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 18\n assert candidate(nums = [10, 11, 10, 11, 10, 11, 12, 11, 12, 11]) == 6\n assert candidate(nums = [2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4]) == 3\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]) == 3\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]) == 3\n assert candidate(nums = [1, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == -1\n assert candidate(nums = [2, 3, 2, 1, 2, 1, 2, 3, 4, 5, 4, 3, 4, 5, 6, 7, 8, 7]) == 4\n assert candidate(nums = [7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7]) == 21\n assert candidate(nums = [1, 3, 2, 3, 4, 3, 5, 6, 5, 7, 8, 7, 9, 10, 9, 11, 12, 11, 13]) == 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, 10]) == -1\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6]) == 30\n assert candidate(nums = [7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8]) == 30\n assert candidate(nums = [2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 3, 4, 3, 4, 3, 4, 3, 4]) == 10\n assert candidate(nums = [2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4]) == 3\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6]) == 20\n assert candidate(nums = [2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2]) == 3\n assert candidate(nums = [11, 12, 13, 14, 15, 14, 13, 14, 15, 14, 13, 14, 15, 14, 13, 14, 15, 14, 13, 14, 15, 14, 13, 14, 15, 14, 13, 14]) == 3\n assert candidate(nums = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 17\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]) == 3\n assert candidate(nums = [8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7]) == 23\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, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7]) == 4\n assert candidate(nums = [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]) == 30\n assert candidate(nums = [10, 11, 12, 13, 14, 13, 14, 15, 14, 13, 14, 15, 14, 13, 14]) == 4\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8]) == 4\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 3\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, 2, 3, 4, 5, 4, 3, 2]) == 3\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 3, 2, 1, 2, 1, 2, 1]) == 6\n assert candidate(nums = [20, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22]) == 22\n assert candidate(nums = [5, 6, 5, 6, 7, 8, 7, 6, 7, 8, 9, 10, 9, 8]) == 4\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 19\n assert candidate(nums = [9, 10, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 6, 7, 8, 7, 8]) == 4\n assert candidate(nums = [4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5]) == 34\n assert candidate(nums = [4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4]) == 20\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 20\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]) == 20\n assert candidate(nums = [1, 2, 3, 4, 3, 4, 3, 4, 5, 4, 5, 4, 5, 4]) == 7\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == -1\n assert candidate(nums = [6, 5, 4, 5, 6, 5, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4]) == 3\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8]) == 4\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]) == 26\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10]) == -1\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 3\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 5]) == 4\n assert candidate(nums = [5, 4, 3, 4, 5, 6, 7, 6, 7, 8, 7, 8, 9, 10, 9, 10, 9, 10, 9]) == 7\n assert candidate(nums = [5, 6, 7, 6, 7, 8, 7, 6, 7, 8, 9, 8, 7, 6]) == 4\n assert candidate(nums = [10, 11, 10, 11, 10, 11, 12, 11, 10, 9, 10, 11, 10]) == 6\n assert candidate(nums = [9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 25\n assert candidate(nums = [6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7]) == 36\n assert candidate(nums = [2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 3\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, 2, 1]) == 3\n assert candidate(nums = [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]) == 3\n assert candidate(nums = [5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(nums = [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]) == 3\n assert candidate(nums = [3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4]) == 3\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]) == 27\n assert candidate(nums = [10, 11, 10, 9, 10, 9, 8, 7, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7]) == 3\n assert candidate(nums = [7, 8, 7, 8, 9, 10, 9, 10, 11, 12, 11, 12, 13, 14, 13, 12, 11]) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 20\n assert candidate(nums = [9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10]) == 20\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]) == 3\n assert candidate(nums = [1, 3, 2, 4, 3, 2, 5, 4, 5, 4, 6, 5, 6, 5, 7, 6, 7, 6, 8, 7, 8, 7]) == 3\n assert candidate(nums = [7, 8, 9, 8, 7, 8, 9, 8, 7, 8, 9, 8, 7, 8, 9, 8, 7, 8, 9, 8, 7, 8, 9, 8, 7]) == 3\n assert candidate(nums = [5, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7, 8, 9]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 1, 2]) == 6\n assert candidate(nums = [5, 6, 7, 8, 7, 8, 9, 10, 9, 10, 11, 12, 11, 12, 13]) == 4\n assert candidate(nums = [10, 11, 10, 11, 10, 11, 10, 11, 12, 11, 10, 9, 10, 11, 12]) == 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]) == 21\n assert candidate(nums = [8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7]) == 27\n assert candidate(nums = [7, 8, 9, 8, 9, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [5, 6, 7, 8, 7, 6, 7, 8, 9, 8, 9, 10, 9, 10, 11, 10, 11, 12]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().alternatingSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int alternatingSubarray(int[] nums) {", "container": "Solution", "callable": "alternatingSubarray", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2766, "task_id": "relocate-marbles", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums representing the initial positions of some marbles. You are also given two 0-indexed integer arrays moveFrom and moveTo of equal length.\nThroughout moveFrom.length steps, you will change the positions of the marbles. On the ith step, you will move all marbles at position moveFrom[i] to position moveTo[i].\nAfter completing all the steps, return the sorted list of occupied positions.\nNotes:\n\nWe call a position occupied if there is at least one marble in that position.\nThere may be multiple marbles in a single position.\n\n \nExample 1:\n\nInput: nums = [1,6,7,8], moveFrom = [1,7,2], moveTo = [2,9,5]\nOutput: [5,6,8,9]\nExplanation: Initially, the marbles are at positions 1,6,7,8.\nAt the i = 0th step, we move the marbles at position 1 to position 2. Then, positions 2,6,7,8 are occupied.\nAt the i = 1st step, we move the marbles at position 7 to position 9. Then, positions 2,6,8,9 are occupied.\nAt the i = 2nd step, we move the marbles at position 2 to position 5. Then, positions 5,6,8,9 are occupied.\nAt the end, the final positions containing at least one marbles are [5,6,8,9].\nExample 2:\n\nInput: nums = [1,1,3,3], moveFrom = [1,3], moveTo = [2,2]\nOutput: [2]\nExplanation: Initially, the marbles are at positions [1,1,3,3].\nAt the i = 0th step, we move all the marbles at position 1 to position 2. Then, the marbles are at positions [2,2,3,3].\nAt the i = 1st step, we move all the marbles at position 3 to position 2. Then, the marbles are at positions [2,2,2,2].\nSince 2 is the only occupied position, we return [2].\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= moveFrom.length <= 105\nmoveFrom.length == moveTo.length\n1 <= nums[i], moveFrom[i], moveTo[i] <= 109\nThe test cases are generated such that there is at least a marble in moveFrom[i] at the moment we want to apply the ith move.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],moveFrom = [1, 2, 3],moveTo = [5, 5, 5]) == [4, 5]\n assert candidate(nums = [1, 6, 7, 8],moveFrom = [1, 7, 2],moveTo = [2, 9, 5]) == [5, 6, 8, 9]\n assert candidate(nums = [5, 5, 5, 5],moveFrom = [5],moveTo = [10]) == [10]\n assert candidate(nums = [1, 1, 3, 3],moveFrom = [1, 3],moveTo = [2, 2]) == [2]\n assert candidate(nums = [5, 10, 15],moveFrom = [5, 10],moveTo = [10, 15]) == [15]\n assert candidate(nums = [10, 20, 30],moveFrom = [10, 20],moveTo = [30, 10]) == [10, 30]\n assert candidate(nums = [1, 2, 3, 4, 5],moveFrom = [1, 2, 3],moveTo = [3, 4, 5]) == [4, 5]\n assert candidate(nums = [10, 20, 30],moveFrom = [10, 20],moveTo = [15, 25]) == [15, 25, 30]\n assert candidate(nums = [10, 20, 30, 40],moveFrom = [10, 20],moveTo = [15, 25]) == [15, 25, 30, 40]\n assert candidate(nums = [100, 200, 300],moveFrom = [100, 200],moveTo = [200, 300]) == [300]\n assert candidate(nums = [1, 2, 3, 4, 5],moveFrom = [1, 2, 3],moveTo = [6, 7, 8]) == [4, 5, 6, 7, 8]\n assert candidate(nums = [1, 2, 3, 4, 5],moveFrom = [1, 2, 3, 4, 5],moveTo = [5, 4, 3, 2, 1]) == [1, 2, 3]\n assert candidate(nums = [5, 10, 15],moveFrom = [5, 15],moveTo = [10, 20]) == [10, 20]\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],moveFrom = [1, 2, 3, 4, 5],moveTo = [6, 6, 6, 6, 6]) == [6]\n assert candidate(nums = [5, 5, 5, 5, 5],moveFrom = [5],moveTo = [10]) == [10]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],moveFrom = [1, 3, 5, 7, 9],moveTo = [3, 5, 7, 9, 11]) == [11, 13, 15, 17, 19]\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 4, 5, 6, 6, 6, 6],moveFrom = [2, 4, 6],moveTo = [3, 5, 7]) == [1, 3, 5, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],moveFrom = [1, 4, 7, 10, 13],moveTo = [2, 5, 8, 11, 14]) == [2, 3, 5, 6, 8, 9, 11, 12, 14, 15]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],moveFrom = [1, 3, 5, 7, 9, 11, 13],moveTo = [2, 4, 6, 8, 10, 12, 14]) == [2, 4, 6, 8, 10, 12, 14, 15]\n assert candidate(nums = [2, 4, 6, 8, 10],moveFrom = [2, 4, 6, 8],moveTo = [1, 3, 5, 7]) == [1, 3, 5, 7, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 3, 5, 7, 9],moveTo = [2, 4, 6, 8, 10]) == [2, 4, 6, 8, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 3, 5, 7, 9],moveTo = [2, 4, 6, 8, 10]) == [2, 4, 6, 8, 10]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],moveFrom = [5, 15, 25, 35, 45],moveTo = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],moveFrom = [10, 20, 30, 40, 50],moveTo = [15, 25, 35, 45, 55]) == [15, 25, 35, 45, 55, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveTo = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == [1, 2, 3, 4]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],moveFrom = [1, 2, 3, 4, 5],moveTo = [5, 4, 3, 2, 1]) == [1, 2, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5],moveTo = [5, 6, 7, 8, 9]) == [6, 7, 8, 9, 10]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],moveFrom = [1, 3, 5, 7, 9],moveTo = [2, 4, 6, 8, 10]) == [2, 4, 6, 8, 10, 11, 13, 15, 17, 19]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],moveFrom = [10, 20, 30, 40, 50],moveTo = [50, 60, 70, 80, 90]) == [60, 70, 80, 90, 100]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],moveFrom = [1, 3, 5, 7, 9, 11, 13, 15],moveTo = [2, 4, 6, 8, 10, 12, 14, 16]) == [2, 4, 6, 8, 10, 12, 14, 16]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],moveFrom = [1, 5, 9, 13],moveTo = [2, 6, 10, 14]) == [2, 3, 6, 7, 10, 11, 14]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveTo = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 30, 40, 50],moveFrom = [10, 20, 30, 40, 50],moveTo = [20, 30, 40, 50, 60]) == [60]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],moveFrom = [1, 5, 9, 13, 17],moveTo = [2, 6, 10, 14, 18]) == [2, 3, 6, 7, 10, 11, 14, 15, 18, 19]\n assert candidate(nums = [10, 20, 30, 40, 50],moveFrom = [10, 20, 30, 40],moveTo = [50, 40, 30, 20]) == [20, 30, 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],moveFrom = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],moveTo = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],moveFrom = [100, 300, 500, 700, 900],moveTo = [200, 400, 600, 800, 1000]) == [200, 400, 600, 800, 1000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],moveFrom = [10, 30, 50, 70, 90],moveTo = [15, 45, 65, 85, 105]) == [15, 20, 40, 45, 60, 65, 80, 85, 100, 105]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],moveFrom = [3, 5, 7, 9, 11],moveTo = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 13, 15, 17, 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],moveFrom = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],moveTo = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],moveFrom = [10, 30, 50, 70, 90],moveTo = [20, 40, 60, 80, 100]) == [20, 40, 60, 80, 100]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 3, 5, 7, 9],moveTo = [9, 7, 5, 3, 1]) == [1, 2, 3, 4, 5, 6, 8, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],moveFrom = [1, 3, 5, 7, 9, 11, 13, 15],moveTo = [2, 4, 6, 8, 10, 12, 14, 16]) == [2, 4, 6, 8, 10, 12, 14, 16]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],moveFrom = [5, 15, 25, 35, 45, 55, 65, 75],moveTo = [10, 20, 30, 40, 50, 60, 70, 80]) == [10, 20, 30, 40, 50, 60, 70, 80]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],moveFrom = [1, 2, 3, 4, 5],moveTo = [6, 7, 8, 9, 10]) == [6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [2, 4, 6, 8, 10],moveTo = [1, 3, 5, 7, 9]) == [1, 3, 5, 7, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],moveFrom = [1, 3, 5, 7, 9],moveTo = [2, 4, 6, 8, 10]) == [2, 4, 6, 8, 10, 11, 13, 15, 17, 19]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],moveFrom = [10, 30, 50, 70, 90],moveTo = [20, 40, 60, 80, 100]) == [20, 40, 60, 80, 100]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],moveFrom = [10, 30, 50, 70, 90, 110, 130],moveTo = [15, 35, 55, 75, 95, 115, 135]) == [15, 20, 35, 40, 55, 60, 75, 80, 95, 100, 115, 120, 135, 140, 150]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],moveFrom = [5, 25, 45, 65, 85],moveTo = [10, 30, 50, 70, 90]) == [10, 15, 30, 35, 50, 55, 70, 75, 90, 95]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 3, 5, 7, 9],moveTo = [11, 12, 13, 14, 15]) == [2, 4, 6, 8, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],moveFrom = [100, 200, 300, 400, 500, 600, 700, 800, 900],moveTo = [101, 201, 301, 401, 501, 601, 701, 801, 901]) == [101, 201, 301, 401, 501, 601, 701, 801, 901, 1000]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],moveFrom = [1, 2, 3, 4],moveTo = [5, 5, 5, 5]) == [5]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],moveFrom = [5, 15, 25, 35, 45],moveTo = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50]\n assert candidate(nums = [1000000000, 1000000000, 1000000000],moveFrom = [1000000000],moveTo = [999999999]) == [999999999]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5, 6, 7, 8, 9],moveTo = [10, 9, 8, 7, 6, 5, 4, 3, 2]) == [2, 3, 4, 5, 10]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5],moveFrom = [1, 2, 3, 4],moveTo = [6, 7, 8, 9]) == [5, 6, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50],moveFrom = [10, 30, 50],moveTo = [20, 40, 60]) == [20, 40, 60]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],moveFrom = [100, 200, 300, 400, 500],moveTo = [150, 250, 350, 450, 550]) == [150, 250, 350, 450, 550, 600, 700, 800, 900, 1000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],moveFrom = [10, 20, 30, 40, 50],moveTo = [11, 21, 31, 41, 51]) == [11, 21, 31, 41, 51, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],moveFrom = [1, 2, 3, 4],moveTo = [3, 4, 5, 6]) == [5, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5, 6, 7, 8, 9],moveTo = [10, 9, 8, 7, 6, 5, 4, 3, 2]) == [2, 3, 4, 5, 10]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],moveFrom = [100, 200, 300, 400, 500, 600, 700, 800, 900],moveTo = [900, 800, 700, 600, 500, 400, 300, 200, 100]) == [100, 200, 300, 400, 500, 1000]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],moveFrom = [1, 2, 3, 4, 5],moveTo = [6, 6, 6, 6, 6]) == [6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5],moveTo = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 1, 1, 2, 2, 3],moveFrom = [1, 2, 3],moveTo = [4, 5, 6]) == [4, 5, 6]\n assert candidate(nums = [1, 2, 3, 4, 5],moveFrom = [1, 2, 3, 4, 5],moveTo = [5, 4, 3, 2, 1]) == [1, 2, 3]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],moveFrom = [1, 2, 3, 4, 5],moveTo = [6, 7, 8, 9, 10]) == [6, 7, 8, 9, 10]\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000],moveFrom = [1000000, 2000000, 3000000, 4000000, 5000000],moveTo = [5000000, 4000000, 3000000, 2000000, 1000000]) == [1000000, 2000000, 3000000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],moveFrom = [10, 20, 30, 40, 50],moveTo = [20, 30, 40, 50, 60]) == [60, 70, 80, 90, 100]\n assert candidate(nums = [5, 10, 15, 20, 25, 30],moveFrom = [5, 10, 15, 20, 25],moveTo = [10, 15, 20, 25, 30]) == [30]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],moveFrom = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveTo = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5],moveFrom = [1, 2, 3, 4, 5],moveTo = [5, 4, 3, 2, 1]) == [1, 2, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveTo = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],moveFrom = [5, 6, 7, 8, 9, 10],moveTo = [16, 17, 18, 19, 20, 21]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9],moveFrom = [2, 5, 8],moveTo = [10, 11, 12]) == [1, 3, 4, 6, 7, 9, 10, 11, 12]\n assert candidate(nums = [1, 3, 5, 7, 9],moveFrom = [1, 3, 5],moveTo = [2, 4, 6]) == [2, 4, 6, 7, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],moveFrom = [1, 5, 9, 13],moveTo = [2, 6, 10, 14]) == [2, 3, 6, 7, 10, 11, 14, 15]\n assert candidate(nums = [1, 1, 2, 2, 3, 3],moveFrom = [1, 2, 3],moveTo = [4, 5, 6]) == [4, 5, 6]\n assert candidate(nums = [1, 3, 5, 7, 9],moveFrom = [1, 5, 9],moveTo = [2, 6, 10]) == [2, 3, 6, 7, 10]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],moveFrom = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],moveTo = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],moveFrom = [1, 3, 5, 7],moveTo = [2, 4, 6, 8]) == [2, 4, 6, 8, 9, 11, 13, 15]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],moveFrom = [5, 10, 15, 20, 25],moveTo = [10, 15, 20, 25, 30]) == [30, 35, 40, 45, 50]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],moveFrom = [100, 300, 500, 700, 900],moveTo = [200, 400, 600, 800, 1000]) == [200, 400, 600, 800, 1000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],moveFrom = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],moveTo = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],moveFrom = [1, 3, 5, 7, 9],moveTo = [9, 7, 5, 3, 1]) == [1, 2, 3, 4, 5, 6, 8]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],moveFrom = [1, 2, 3, 4, 5, 6, 7, 8, 9],moveTo = [11, 12, 13, 14, 15, 16, 17, 18, 19]) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5],moveTo = [5, 6, 7, 8, 9]) == [6, 7, 8, 9, 10]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],moveFrom = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],moveTo = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],moveFrom = [1, 5, 9, 13, 17],moveTo = [2, 6, 10, 14, 18]) == [2, 3, 6, 7, 10, 11, 14, 15, 18, 19]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveTo = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [11]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5],moveTo = [5, 4, 3, 2, 1]) == [1, 2, 3, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],moveFrom = [10, 20, 30, 40, 50, 60, 70, 80, 90],moveTo = [5, 15, 25, 35, 45, 55, 65, 75, 85]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 100]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],moveFrom = [1, 2, 3, 4, 5],moveTo = [10, 9, 8, 7, 6]) == [6, 7, 8, 9, 10]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],moveFrom = [1, 10, 100, 1000, 10000],moveTo = [1000000000, 100000000, 10000000, 1000000, 100000]) == [100000, 1000000, 10000000, 100000000, 1000000000]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],moveFrom = [5, 10, 15, 20, 25],moveTo = [6, 11, 16, 21, 26]) == [6, 11, 16, 21, 26, 30, 35, 40, 45, 50]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000],moveFrom = [1, 10, 100, 1000, 10000],moveTo = [10, 100, 1000, 10000, 100000]) == [100000]\n"}, "metadata": {"canonical_parameter_names": ["nums", "moveFrom", "moveTo"], "leetcode_dataset_entry_point": "Solution().relocateMarbles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List relocateMarbles(int[] nums, int[] moveFrom, int[] moveTo) {", "container": "Solution", "callable": "relocateMarbles", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "moveFrom", "type": "int[]"}, {"name": "moveTo", "type": "int[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2767, "task_id": "partition-string-into-minimum-beautiful-substrings", "difficulty": "Medium", "problem_description": "Given a binary string s, partition the string into one or more substrings such that each substring is beautiful.\nA string is beautiful if:\n\nIt doesn't contain leading zeros.\nIt's the binary representation of a number that is a power of 5.\n\nReturn the minimum number of substrings in such partition. If it is impossible to partition the string s into beautiful substrings, return -1.\nA substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: s = \"1011\"\nOutput: 2\nExplanation: We can paritition the given string into [\"101\", \"1\"].\n- The string \"101\" does not contain leading zeros and is the binary representation of integer 51 = 5.\n- The string \"1\" does not contain leading zeros and is the binary representation of integer 50 = 1.\nIt can be shown that 2 is the minimum number of beautiful substrings that s can be partitioned into.\n\nExample 2:\n\nInput: s = \"111\"\nOutput: 3\nExplanation: We can paritition the given string into [\"1\", \"1\", \"1\"].\n- The string \"1\" does not contain leading zeros and is the binary representation of integer 50 = 1.\nIt can be shown that 3 is the minimum number of beautiful substrings that s can be partitioned into.\n\nExample 3:\n\nInput: s = \"0\"\nOutput: -1\nExplanation: We can not partition the given string into beautiful substrings.\n\n \nConstraints:\n\n1 <= s.length <= 15\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1100101\") == -1\n assert candidate(s = \"100000000000000\") == -1\n assert candidate(s = \"101010101010101\") == -1\n assert candidate(s = \"101010101\") == -1\n assert candidate(s = \"111\") == 3\n assert candidate(s = \"100000\") == -1\n assert candidate(s = \"111111111\") == 9\n assert candidate(s = \"0\") == -1\n assert candidate(s = \"1010101\") == -1\n assert candidate(s = \"1111111\") == 7\n assert candidate(s = \"111111111111111\") == 15\n assert candidate(s = \"1100001\") == -1\n assert candidate(s = \"1011\") == 2\n assert candidate(s = \"100111\") == -1\n assert candidate(s = \"100111011\") == -1\n assert candidate(s = \"1\") == 1\n assert candidate(s = \"110000\") == -1\n assert candidate(s = \"1000000\") == -1\n assert candidate(s = \"1110111\") == 5\n assert candidate(s = \"100000000\") == -1\n assert candidate(s = \"110011001\") == -1\n assert candidate(s = \"11001\") == 1\n assert candidate(s = \"0111000111000111000111000111000\") == -1\n assert candidate(s = \"10101010101\") == -1\n assert candidate(s = \"100010001000100\") == -1\n assert candidate(s = \"01101101101101101\") == -1\n assert candidate(s = \"1101010101010101\") == -1\n assert candidate(s = \"1010101010101010101010101\") == -1\n assert candidate(s = \"1111111111111111111\") == 19\n assert candidate(s = \"1010101010101010101\") == -1\n assert candidate(s = \"00001000010000100001\") == -1\n assert candidate(s = \"101010101010001\") == -1\n assert candidate(s = \"111011011001111\") == -1\n assert candidate(s = \"1011011011011011011\") == 7\n assert candidate(s = \"100000000000001\") == -1\n assert candidate(s = \"111000111000111\") == -1\n assert candidate(s = \"10000000000000\") == -1\n assert candidate(s = \"1001101\") == -1\n assert candidate(s = \"00110011001100110011001100110011001\") == -1\n assert candidate(s = \"110101011010101\") == -1\n assert candidate(s = \"111101111\") == 7\n assert candidate(s = \"1111111111111111111111111111111111111\") == 37\n assert candidate(s = \"101010101010101010101\") == -1\n assert candidate(s = \"1010101010\") == -1\n assert candidate(s = \"1100011\") == -1\n assert candidate(s = \"111111111111111111111\") == 21\n assert candidate(s = \"11010110101101101\") == -1\n assert candidate(s = \"10001000100010001000100010001\") == -1\n assert candidate(s = \"11000011000011000011\") == -1\n assert candidate(s = \"1010101010101010\") == -1\n assert candidate(s = \"11010101101\") == -1\n assert candidate(s = \"110011001100110011\") == -1\n assert candidate(s = \"10100001001\") == -1\n assert candidate(s = \"1111100000001\") == -1\n assert candidate(s = \"1011101110111011101110111011101\") == 15\n assert candidate(s = \"11111111111111101\") == 11\n assert candidate(s = \"111110111110111\") == 7\n assert candidate(s = \"010001\") == -1\n assert candidate(s = \"110011\") == 2\n assert candidate(s = \"10000000000000000\") == -1\n assert candidate(s = \"11110000111100001111\") == -1\n assert candidate(s = \"10011101\") == -1\n assert candidate(s = \"100100100100100\") == -1\n assert candidate(s = \"11111111111111111111111\") == 23\n assert candidate(s = \"1111111111111111111111111111111\") == 31\n assert candidate(s = \"11111111111111111111111111111111111\") == 35\n assert candidate(s = \"1011101\") == 3\n assert candidate(s = \"11001100110011001\") == -1\n assert candidate(s = \"111001110011100\") == -1\n assert candidate(s = \"1111111111111111\") == 16\n assert candidate(s = \"11101110111011101\") == 9\n assert candidate(s = \"110011001100110\") == -1\n assert candidate(s = \"10101010101010101010101010101010101\") == -1\n assert candidate(s = \"11111100111\") == 7\n assert candidate(s = \"101010101010101010101010101010101010101\") == -1\n assert candidate(s = \"1111101111101\") == 5\n assert candidate(s = \"010101010101010101010101010101\") == -1\n assert candidate(s = \"11100111001110011\") == 5\n assert candidate(s = \"1010010101010\") == -1\n assert candidate(s = \"11111111111111011\") == 11\n assert candidate(s = \"11010110111\") == -1\n assert candidate(s = \"11001101\") == 2\n assert candidate(s = \"101101001\") == -1\n assert candidate(s = \"100100010010001\") == -1\n assert candidate(s = \"111100001111\") == -1\n assert candidate(s = \"110010\") == -1\n assert candidate(s = \"1001001\") == -1\n assert candidate(s = \"100110010011001\") == -1\n assert candidate(s = \"1100110011001100110\") == -1\n assert candidate(s = \"1100100110001\") == -1\n assert candidate(s = \"1000000000000\") == -1\n assert candidate(s = \"1111100111\") == 6\n assert candidate(s = \"111111111111110\") == -1\n assert candidate(s = \"111011101110111\") == 9\n assert candidate(s = \"1011101110111011101110111\") == 13\n assert candidate(s = \"1111111111111111111111111\") == 25\n assert candidate(s = \"000000000000000\") == -1\n assert candidate(s = \"11010101010\") == -1\n assert candidate(s = \"111111111111111111111111111111111\") == 33\n assert candidate(s = \"1111111111111\") == 13\n assert candidate(s = \"111110111100001\") == -1\n assert candidate(s = \"1111000011110000111\") == -1\n assert candidate(s = \"10000100001\") == -1\n assert candidate(s = \"11101001101\") == -1\n assert candidate(s = \"0101010101\") == -1\n assert candidate(s = \"11001001001001001\") == -1\n assert candidate(s = \"11001000110101\") == -1\n assert candidate(s = \"111111111111111111111111111111111111111\") == 39\n assert candidate(s = \"10101010101010101\") == -1\n assert candidate(s = \"10110110110\") == -1\n assert candidate(s = \"11011011011\") == 5\n assert candidate(s = \"101010101010110\") == -1\n assert candidate(s = \"11111111101\") == 5\n assert candidate(s = \"101101101101101101\") == 6\n assert candidate(s = \"1010101010101\") == -1\n assert candidate(s = \"1100010000100\") == -1\n assert candidate(s = \"1110011100111\") == 5\n assert candidate(s = \"11111111101111111\") == 11\n assert candidate(s = \"1111100001\") == -1\n assert candidate(s = \"10011001\") == -1\n assert candidate(s = \"11111011111011111\") == 9\n assert candidate(s = \"110010111011101\") == -1\n assert candidate(s = \"110011101100111\") == -1\n assert candidate(s = \"111101110111011\") == 9\n assert candidate(s = \"1100110011001100110011001100110\") == -1\n assert candidate(s = \"1001001001001\") == -1\n assert candidate(s = \"11111111111\") == 11\n assert candidate(s = \"100101010100101\") == -1\n assert candidate(s = \"101111111111111\") == 13\n assert candidate(s = \"111100001111000\") == -1\n assert candidate(s = \"1100110011001100110011\") == -1\n assert candidate(s = \"111111000111111\") == -1\n assert candidate(s = \"1010101010101011\") == -1\n assert candidate(s = \"1111101\") == 1\n assert candidate(s = \"11011011011011011\") == 7\n assert candidate(s = \"000000\") == -1\n assert candidate(s = \"100100001001000100\") == -1\n assert candidate(s = \"111111000000111\") == -1\n assert candidate(s = \"10001000100010001\") == -1\n assert candidate(s = \"110110110110110\") == -1\n assert candidate(s = \"111111111111111111111111111\") == 27\n assert candidate(s = \"1000000000001\") == -1\n assert candidate(s = \"0000000000000000000000\") == -1\n assert candidate(s = \"110010111\") == -1\n assert candidate(s = \"1010010001101010\") == -1\n assert candidate(s = \"11001100110011001100110011\") == -1\n assert candidate(s = \"100000100000100\") == -1\n assert candidate(s = \"1001110001\") == 1\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumBeautifulSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumBeautifulSubstrings(String s) {", "container": "Solution", "callable": "minimumBeautifulSubstrings", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2768, "task_id": "number-of-black-blocks", "difficulty": "Medium", "problem_description": "You are given two integers m and n representing the dimensions of a 0-indexed m x n grid.\nYou are also given a 0-indexed 2D integer matrix coordinates, where coordinates[i] = [x, y] indicates that the cell with coordinates [x, y] is colored black. All cells in the grid that do not appear in coordinates are white.\nA block is defined as a 2 x 2 submatrix of the grid. More formally, a block with cell [x, y] as its top-left corner where 0 <= x < m - 1 and 0 <= y < n - 1 contains the coordinates [x, y], [x + 1, y], [x, y + 1], and [x + 1, y + 1].\nReturn a 0-indexed integer array arr of size 5 such that arr[i] is the number of blocks that contains exactly i black cells.\n \nExample 1:\n\nInput: m = 3, n = 3, coordinates = [[0,0]]\nOutput: [3,1,0,0,0]\nExplanation: The grid looks like this:\n\nThere is only 1 block with one black cell, and it is the block starting with cell [0,0].\nThe other 3 blocks start with cells [0,1], [1,0] and [1,1]. They all have zero black cells. \nThus, we return [3,1,0,0,0]. \n\nExample 2:\n\nInput: m = 3, n = 3, coordinates = [[0,0],[1,1],[0,2]]\nOutput: [0,2,2,0,0]\nExplanation: The grid looks like this:\n\nThere are 2 blocks with two black cells (the ones starting with cell coordinates [0,0] and [0,1]).\nThe other 2 blocks have starting cell coordinates of [1,0] and [1,1]. They both have 1 black cell.\nTherefore, we return [0,2,2,0,0].\n\n \nConstraints:\n\n2 <= m <= 105\n2 <= n <= 105\n0 <= coordinates.length <= 104\ncoordinates[i].length == 2\n0 <= coordinates[i][0] < m\n0 <= coordinates[i][1] < n\nIt is guaranteed that coordinates contains pairwise distinct coordinates.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 5,n = 5,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]) == [9, 3, 3, 0, 1]\n assert candidate(m = 5,n = 5,coordinates = [[2, 2], [3, 3], [1, 1]]) == [6, 8, 2, 0, 0]\n assert candidate(m = 3,n = 3,coordinates = [[0, 0], [1, 1], [0, 2]]) == [0, 2, 2, 0, 0]\n assert candidate(m = 5,n = 5,coordinates = [[1, 1], [1, 2], [2, 1], [2, 2]]) == [7, 4, 4, 0, 1]\n assert candidate(m = 10,n = 10,coordinates = [[5, 5], [4, 4], [6, 6]]) == [71, 8, 2, 0, 0]\n assert candidate(m = 3,n = 3,coordinates = [[0, 0]]) == [3, 1, 0, 0, 0]\n assert candidate(m = 4,n = 4,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [2, 4, 3, 0, 0]\n assert candidate(m = 10,n = 10,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3]]) == [71, 5, 4, 0, 1]\n assert candidate(m = 10,n = 10,coordinates = [[3, 3], [4, 4], [5, 5]]) == [71, 8, 2, 0, 0]\n assert candidate(m = 4,n = 5,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1]]) == [8, 1, 2, 0, 1]\n assert candidate(m = 5,n = 5,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1]]) == [12, 1, 2, 0, 1]\n assert candidate(m = 4,n = 5,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [4, 5, 3, 0, 0]\n assert candidate(m = 10,n = 10,coordinates = [[0, 0], [9, 9], [4, 4]]) == [75, 6, 0, 0, 0]\n assert candidate(m = 4,n = 4,coordinates = [[0, 1], [1, 0], [1, 2], [2, 1]]) == [1, 4, 4, 0, 0]\n assert candidate(m = 5,n = 5,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [6, 7, 3, 0, 0]\n assert candidate(m = 2,n = 2,coordinates = []) == [1, 0, 0, 0, 0]\n assert candidate(m = 10,n = 10,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [68, 9, 4, 0, 0]\n assert candidate(m = 7,n = 8,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == [25, 9, 7, 0, 1]\n assert candidate(m = 100,n = 100,coordinates = [[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]]) == [9743, 39, 19, 0, 0]\n assert candidate(m = 8,n = 7,coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [7, 6]]) == [25, 10, 7, 0, 0]\n assert candidate(m = 20,n = 10,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [4, 0], [4, 1], [4, 2], [5, 0], [5, 1], [5, 2], [6, 0], [6, 1], [6, 2]]) == [150, 1, 8, 0, 12]\n assert candidate(m = 10,n = 5,coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 4], [2, 0], [2, 4], [3, 0], [3, 4], [4, 0], [4, 4], [5, 0], [5, 4], [6, 0], [6, 4], [7, 0], [7, 4], [8, 0], [8, 4], [9, 0], [9, 4]]) == [16, 0, 18, 2, 0]\n assert candidate(m = 50,n = 50,coordinates = [[25, 25], [24, 24], [26, 26], [24, 25], [25, 24], [25, 26], [26, 25]]) == [2387, 6, 4, 2, 2]\n assert candidate(m = 9,n = 9,coordinates = [[0, 4], [1, 3], [1, 5], [2, 2], [2, 4], [2, 6], [3, 1], [3, 3], [3, 5], [3, 7], [4, 0], [4, 2], [4, 4], [4, 6], [4, 8], [5, 1], [5, 3], [5, 5], [5, 7], [6, 2], [6, 4], [6, 6], [7, 3], [7, 5], [8, 4]]) == [12, 12, 40, 0, 0]\n assert candidate(m = 8,n = 8,coordinates = [[0, 0], [0, 7], [7, 0], [7, 7], [1, 1], [1, 6], [6, 1], [6, 6], [2, 2], [2, 5], [5, 2], [5, 5], [3, 3], [3, 4], [4, 3], [4, 4]]) == [16, 16, 16, 0, 1]\n assert candidate(m = 7,n = 8,coordinates = [[0, 1], [1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1]]) == [30, 6, 6, 0, 0]\n assert candidate(m = 6,n = 6,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [12, 6, 6, 0, 1]\n assert candidate(m = 10,n = 10,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [56, 14, 10, 0, 1]\n assert candidate(m = 15,n = 10,coordinates = [[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]]) == [100, 17, 9, 0, 0]\n assert candidate(m = 7,n = 7,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6]]) == [12, 2, 14, 0, 8]\n assert candidate(m = 10,n = 10,coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3], [3, 0], [3, 1], [3, 2], [3, 3]]) == [65, 1, 6, 0, 9]\n assert candidate(m = 100,n = 100,coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3], [3, 0], [3, 1], [3, 2], [3, 3], [50, 50], [50, 51], [50, 52], [50, 53], [51, 50], [51, 51], [51, 52], [51, 53], [52, 50], [52, 51], [52, 52], [52, 53], [53, 50], [53, 51], [53, 52], [53, 53]]) == [9760, 5, 18, 0, 18]\n assert candidate(m = 8,n = 8,coordinates = [[0, 1], [0, 2], [1, 0], [1, 3], [2, 1], [2, 2], [3, 0], [3, 3], [4, 1], [4, 2], [5, 0], [5, 3], [6, 1], [6, 2], [7, 0], [7, 3]]) == [21, 7, 21, 0, 0]\n assert candidate(m = 9,n = 9,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == [42, 10, 8, 0, 4]\n assert candidate(m = 10,n = 20,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [4, 0], [4, 1], [4, 2]]) == [156, 1, 6, 0, 8]\n assert candidate(m = 7,n = 6,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 0], [0, 5], [6, 5], [5, 0], [4, 1], [1, 4], [2, 3], [3, 2]]) == [7, 8, 14, 0, 1]\n assert candidate(m = 9,n = 9,coordinates = [[4, 4], [3, 3], [3, 5], [5, 3], [5, 5], [2, 2], [2, 6], [6, 2], [6, 6], [1, 1], [1, 7], [7, 1], [7, 7], [0, 0], [0, 8], [8, 0], [8, 8]]) == [24, 24, 16, 0, 0]\n assert candidate(m = 10,n = 10,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [56, 16, 9, 0, 0]\n assert candidate(m = 10,n = 5,coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4]]) == [28, 0, 4, 0, 4]\n assert candidate(m = 6,n = 6,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5]]) == [8, 2, 10, 0, 5]\n assert candidate(m = 8,n = 8,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == [30, 12, 7, 0, 0]\n assert candidate(m = 9,n = 9,coordinates = [[0, 0], [0, 8], [8, 0], [8, 8], [4, 4], [3, 3], [5, 5], [2, 2], [6, 6]]) == [44, 16, 4, 0, 0]\n assert candidate(m = 9,n = 9,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 7], [7, 8]]) == [36, 6, 15, 2, 5]\n assert candidate(m = 100,n = 100,coordinates = [[10, 10], [10, 11], [11, 10], [11, 11], [20, 20], [21, 20], [20, 21], [21, 21]]) == [9783, 8, 8, 0, 2]\n assert candidate(m = 9,n = 7,coordinates = [[0, 3], [1, 2], [2, 1], [3, 0], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1]]) == [24, 16, 8, 0, 0]\n assert candidate(m = 6,n = 6,coordinates = [[0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4]]) == [8, 3, 9, 1, 4]\n assert candidate(m = 6,n = 7,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [2, 3], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4]]) == [8, 3, 2, 3, 14]\n assert candidate(m = 7,n = 8,coordinates = [[0, 0], [0, 7], [6, 0], [6, 7], [3, 3], [3, 4], [4, 3], [4, 4], [2, 2], [2, 5], [5, 2], [5, 5]]) == [17, 16, 8, 0, 1]\n assert candidate(m = 8,n = 8,coordinates = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6], [6, 5], [6, 6]]) == [19, 7, 15, 1, 7]\n assert candidate(m = 8,n = 7,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [6, 6]]) == [21, 5, 11, 0, 5]\n assert candidate(m = 10,n = 10,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == [72, 1, 4, 0, 4]\n assert candidate(m = 5,n = 6,coordinates = [[0, 0], [0, 5], [1, 1], [1, 4], [2, 2], [2, 3], [3, 3], [3, 4], [4, 1], [4, 5]]) == [2, 9, 7, 2, 0]\n assert candidate(m = 7,n = 6,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [14, 7, 5, 2, 2]\n assert candidate(m = 8,n = 8,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 7], [7, 0]]) == [28, 14, 7, 0, 0]\n assert candidate(m = 6,n = 6,coordinates = [[0, 0], [0, 5], [5, 0], [5, 5], [2, 2], [3, 3], [1, 1], [4, 4]]) == [10, 10, 5, 0, 0]\n assert candidate(m = 8,n = 6,coordinates = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5]]) == [14, 4, 12, 0, 5]\n assert candidate(m = 15,n = 20,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [238, 19, 9, 0, 0]\n assert candidate(m = 5,n = 10,coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == [27, 0, 9, 0, 0]\n assert candidate(m = 12,n = 11,coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [81, 19, 10, 0, 0]\n assert candidate(m = 10,n = 10,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]]) == [69, 3, 7, 0, 2]\n assert candidate(m = 5,n = 4,coordinates = [[0, 1], [1, 2], [2, 0], [3, 1], [3, 2], [4, 0], [4, 1]]) == [0, 7, 3, 2, 0]\n assert candidate(m = 7,n = 8,coordinates = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5]]) == [23, 16, 3, 0, 0]\n assert candidate(m = 12,n = 10,coordinates = [[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [5, 5], [6, 5], [7, 5], [5, 6], [6, 6], [7, 6]]) == [78, 5, 10, 0, 6]\n assert candidate(m = 6,n = 5,coordinates = [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 2], [4, 0], [4, 1], [4, 2], [5, 0], [5, 1]]) == [5, 1, 4, 7, 3]\n assert candidate(m = 7,n = 8,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 4], [4, 5], [4, 6], [5, 5], [5, 6], [5, 7]]) == [18, 5, 9, 4, 6]\n assert candidate(m = 6,n = 7,coordinates = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5]]) == [13, 3, 11, 0, 3]\n assert candidate(m = 7,n = 8,coordinates = [[0, 1], [0, 3], [1, 2], [1, 4], [2, 1], [2, 3], [2, 5], [3, 2], [3, 4], [3, 6], [4, 1], [4, 3], [4, 5], [5, 2], [5, 4], [6, 3]]) == [7, 12, 23, 0, 0]\n assert candidate(m = 10,n = 10,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [52, 10, 14, 0, 5]\n assert candidate(m = 5,n = 6,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4]]) == [6, 1, 8, 0, 5]\n assert candidate(m = 6,n = 7,coordinates = [[0, 0], [0, 6], [1, 1], [1, 5], [2, 2], [2, 4], [3, 3], [4, 2], [4, 4], [5, 1], [5, 5]]) == [6, 14, 10, 0, 0]\n assert candidate(m = 8,n = 8,coordinates = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [4, 4]]) == [34, 5, 6, 0, 4]\n assert candidate(m = 9,n = 9,coordinates = [[0, 1], [0, 2], [1, 0], [1, 3], [2, 1], [2, 2], [3, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == [37, 13, 12, 2, 0]\n"}, "metadata": {"canonical_parameter_names": ["m", "n", "coordinates"], "leetcode_dataset_entry_point": "Solution().countBlackBlocks", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long[] countBlackBlocks(int m, int n, int[][] coordinates) {", "container": "Solution", "callable": "countBlackBlocks", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "coordinates", "type": "int[][]"}], "return_type": "long[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2769, "task_id": "find-the-maximum-achievable-number", "difficulty": "Easy", "problem_description": "Given two integers, num and t. A number x is achievable if it can become equal to num after applying the following operation at most t times:\n\nIncrease or decrease x by 1, and simultaneously increase or decrease num by 1.\n\nReturn the maximum possible value of x.\n \nExample 1:\n\nInput: num = 4, t = 1\nOutput: 6\nExplanation:\nApply the following operation once to make the maximum achievable number equal to num:\n\nDecrease the maximum achievable number by 1, and increase num by 1.\n\n\nExample 2:\n\nInput: num = 3, t = 2\nOutput: 7\nExplanation:\nApply the following operation twice to make the maximum achievable number equal to num:\n\nDecrease the maximum achievable number by 1, and increase num by 1.\n\n\n \nConstraints:\n\n1 <= num, t <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 1,t = 50) == 101\n assert candidate(num = 10,t = 5) == 20\n assert candidate(num = 50,t = 50) == 150\n assert candidate(num = 1,t = 1) == 3\n assert candidate(num = 25,t = 25) == 75\n assert candidate(num = 3,t = 2) == 7\n assert candidate(num = 4,t = 1) == 6\n assert candidate(num = 25,t = 10) == 45\n assert candidate(num = 2,t = 45) == 92\n assert candidate(num = 28,t = 12) == 52\n assert candidate(num = 42,t = 15) == 72\n assert candidate(num = 45,t = 4) == 53\n assert candidate(num = 35,t = 28) == 91\n assert candidate(num = 7,t = 20) == 47\n assert candidate(num = 40,t = 1) == 42\n assert candidate(num = 27,t = 15) == 57\n assert candidate(num = 30,t = 15) == 60\n assert candidate(num = 28,t = 28) == 84\n assert candidate(num = 18,t = 49) == 116\n assert candidate(num = 29,t = 17) == 63\n assert candidate(num = 30,t = 29) == 88\n assert candidate(num = 35,t = 10) == 55\n assert candidate(num = 8,t = 8) == 24\n assert candidate(num = 49,t = 50) == 149\n assert candidate(num = 30,t = 45) == 120\n assert candidate(num = 28,t = 30) == 88\n assert candidate(num = 20,t = 35) == 90\n assert candidate(num = 5,t = 50) == 105\n assert candidate(num = 10,t = 40) == 90\n assert candidate(num = 29,t = 15) == 59\n assert candidate(num = 33,t = 18) == 69\n assert candidate(num = 27,t = 30) == 87\n assert candidate(num = 40,t = 10) == 60\n assert candidate(num = 2,t = 25) == 52\n assert candidate(num = 45,t = 15) == 75\n assert candidate(num = 23,t = 48) == 119\n assert candidate(num = 49,t = 10) == 69\n assert candidate(num = 20,t = 45) == 110\n assert candidate(num = 15,t = 45) == 105\n assert candidate(num = 12,t = 10) == 32\n assert candidate(num = 2,t = 30) == 62\n assert candidate(num = 12,t = 40) == 92\n assert candidate(num = 37,t = 30) == 97\n assert candidate(num = 7,t = 7) == 21\n assert candidate(num = 1,t = 20) == 41\n assert candidate(num = 7,t = 43) == 93\n assert candidate(num = 20,t = 1) == 22\n assert candidate(num = 10,t = 1) == 12\n assert candidate(num = 42,t = 9) == 60\n assert candidate(num = 45,t = 20) == 85\n assert candidate(num = 45,t = 45) == 135\n assert candidate(num = 45,t = 10) == 65\n assert candidate(num = 1,t = 25) == 51\n assert candidate(num = 30,t = 25) == 80\n assert candidate(num = 5,t = 30) == 65\n assert candidate(num = 45,t = 1) == 47\n assert candidate(num = 12,t = 38) == 88\n assert candidate(num = 15,t = 20) == 55\n assert candidate(num = 20,t = 30) == 80\n assert candidate(num = 7,t = 35) == 77\n assert candidate(num = 50,t = 2) == 54\n assert candidate(num = 40,t = 5) == 50\n assert candidate(num = 35,t = 15) == 65\n assert candidate(num = 27,t = 27) == 81\n assert candidate(num = 22,t = 35) == 92\n assert candidate(num = 50,t = 25) == 100\n assert candidate(num = 49,t = 25) == 99\n assert candidate(num = 2,t = 40) == 82\n assert candidate(num = 15,t = 30) == 75\n assert candidate(num = 30,t = 30) == 90\n assert candidate(num = 33,t = 15) == 63\n assert candidate(num = 35,t = 18) == 71\n assert candidate(num = 15,t = 40) == 95\n assert candidate(num = 23,t = 3) == 29\n assert candidate(num = 40,t = 20) == 80\n assert candidate(num = 30,t = 20) == 70\n assert candidate(num = 33,t = 17) == 67\n assert candidate(num = 7,t = 25) == 57\n assert candidate(num = 47,t = 5) == 57\n assert candidate(num = 50,t = 1) == 52\n assert candidate(num = 29,t = 21) == 71\n assert candidate(num = 20,t = 25) == 70\n"}, "metadata": {"canonical_parameter_names": ["num", "t"], "leetcode_dataset_entry_point": "Solution().theMaximumAchievableX", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int theMaximumAchievableX(int num, int t) {", "container": "Solution", "callable": "theMaximumAchievableX", "parameters": [{"name": "num", "type": "int"}, {"name": "t", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2770, "task_id": "maximum-number-of-jumps-to-reach-the-last-index", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of n integers and an integer target.\nYou are initially positioned at index 0. In one step, you can jump from index i to any index j such that:\n\n0 <= i < j < n\n-target <= nums[j] - nums[i] <= target\n\nReturn the maximum number of jumps you can make to reach index n - 1.\nIf there is no way to reach index n - 1, return -1.\n \nExample 1:\n\nInput: nums = [1,3,6,4,1,2], target = 2\nOutput: 3\nExplanation: To go from index 0 to index n - 1 with the maximum number of jumps, you can perform the following jumping sequence:\n- Jump from index 0 to index 1. \n- Jump from index 1 to index 3.\n- Jump from index 3 to index 5.\nIt can be proven that there is no other jumping sequence that goes from 0 to n - 1 with more than 3 jumps. Hence, the answer is 3. \nExample 2:\n\nInput: nums = [1,3,6,4,1,2], target = 3\nOutput: 5\nExplanation: To go from index 0 to index n - 1 with the maximum number of jumps, you can perform the following jumping sequence:\n- Jump from index 0 to index 1.\n- Jump from index 1 to index 2.\n- Jump from index 2 to index 3.\n- Jump from index 3 to index 4.\n- Jump from index 4 to index 5.\nIt can be proven that there is no other jumping sequence that goes from 0 to n - 1 with more than 5 jumps. Hence, the answer is 5. \nExample 3:\n\nInput: nums = [1,3,6,4,1,2], target = 0\nOutput: -1\nExplanation: It can be proven that there is no jumping sequence that goes from 0 to n - 1. Hence, the answer is -1. \n\n \nConstraints:\n\n2 <= nums.length == n <= 1000\n-109 <= nums[i] <= 109\n0 <= target <= 2 * 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 6, 4, 1, 2],target = 3) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],target = 9) == 9\n assert candidate(nums = [1, 5, 10, 15, 20],target = 4) == -1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],target = 9) == 9\n assert candidate(nums = [10, 8, 6, 4, 2],target = 2) == 4\n assert candidate(nums = [0, 0, 0, 0, 0],target = 0) == 4\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000],target = 500000000) == 4\n assert candidate(nums = [-1, 0, 1, 2, 3],target = 2) == 4\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000],target = 2000000000) == 3\n assert candidate(nums = [10, 8, 6, 4, 2],target = 1) == -1\n assert candidate(nums = [1, 3, 6, 4, 1, 2],target = 0) == -1\n assert candidate(nums = [1, 5, 9, 14, 20],target = 4) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 0) == 9\n assert candidate(nums = [10, 20, 30, 40, 50],target = 10) == 4\n assert candidate(nums = [1, 5, 10, 15, 20],target = 9) == 4\n assert candidate(nums = [1, 2, 3, 5, 6, 8, 9],target = 2) == 6\n assert candidate(nums = [10, 20, 30, 40, 50],target = 15) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 1) == 9\n assert candidate(nums = [1, 1, 1, 1, 1],target = 1) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 1) == 9\n assert candidate(nums = [1, 1, 1, 1, 1],target = 0) == 4\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],target = 10) == -1\n assert candidate(nums = [1, 3, 5, 7, 9],target = 2) == 4\n assert candidate(nums = [5, 4, 3, 2, 1],target = 1) == 4\n assert candidate(nums = [1, 3, 6, 4, 1, 2],target = 2) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],target = 1) == 4\n assert candidate(nums = [2, 4, 5, 7, 9, 11],target = 2) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 0) == 9\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],target = 4) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 2) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 2) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 0) == 9\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],target = 99) == 9\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],target = 1) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 4) == 19\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50],target = 5) == -1\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],target = 9) == 19\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 15) == 9\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 20) == 9\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 10) == 9\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],target = 2) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 0) == -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],target = 20) == -1\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],target = 15) == 9\n assert candidate(nums = [1, 5, 3, 7, 9, 12, 10, 15, 20, 18],target = 5) == 9\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],target = 4) == 19\n assert candidate(nums = [1, 10, 21, 32, 43, 54, 65, 76, 87, 98],target = 9) == -1\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],target = 4) == 9\n assert candidate(nums = [-10, -5, 0, 5, 10, 15],target = 10) == 5\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],target = 9) == -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],target = 1) == 19\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 0) == 9\n assert candidate(nums = [5, 15, 10, 20, 25, 30],target = 5) == -1\n assert candidate(nums = [9, 7, 5, 3, 1, 0, -2, -4, -6, -8, -10],target = 3) == 10\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 30],target = 5) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 1) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 1) == 14\n assert candidate(nums = [1, 3, 6, 4, 1, 2, 1, 3, 6, 4, 1, 2, 1, 3, 6, 4, 1, 2, 1, 3],target = 2) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1) == 21\n assert candidate(nums = [1, 4, 3, 2, 5, 6, 7, 8, 9, 10],target = 3) == 9\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 1) == 19\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 0) == -1\n assert candidate(nums = [1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4],target = 3) == 19\n assert candidate(nums = [1000000000, 999999998, 999999996, 999999994, 999999992],target = 2) == 4\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],target = 1) == 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],target = 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],target = 10) == 19\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20],target = 2) == 19\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],target = 6) == 19\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 1) == -1\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],target = 50) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 20) == 9\n assert candidate(nums = [5, 1, 4, 2, 8, 7, 3, 6],target = 3) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 15) == 9\n assert candidate(nums = [5, 15, 10, 20, 25, 30, 35],target = 10) == 6\n assert candidate(nums = [1, 3, 6, 4, 1, 2, 8, 5, 7, 10],target = 3) == 8\n assert candidate(nums = [-10, -20, -30, -40, -50],target = 10) == 4\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6],target = 1) == 5\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109],target = 10) == -1\n assert candidate(nums = [1, 5, 3, 7, 2, 6, 4, 8, 1, 9, 5, 10, 6, 11, 7],target = 4) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],target = 1) == 14\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],target = 500) == -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],target = 2) == 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],target = 0) == 19\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],target = 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],target = 1) == 19\n assert candidate(nums = [1, 4, 2, 7, 5, 9, 8, 11, 10],target = 3) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],target = 1) == 19\n assert candidate(nums = [1, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11],target = 3) == 14\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],target = 8) == 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],target = 1) == 19\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 100) == 9\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 15) == 9\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],target = 9) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 1) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3],target = 2) == 14\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 3) == 9\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],target = 0) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],target = 1000000) == 19\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 10) == 9\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],target = 20) == -1\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14],target = 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],target = 5) == 19\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],target = 30) == 9\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],target = 1) == 10\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],target = 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, 26, 27, 28, 29, 30],target = 1) == 29\n assert candidate(nums = [1, 3, 6, 4, 1, 2, 5, 7, 8, 9],target = 2) == 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],target = 1) == 19\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],target = 15) == 9\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 30],target = 5) == 6\n assert candidate(nums = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],target = 4) == 19\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 10) == 9\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4],target = 3) == 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 = 0) == -1\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],target = 1) == 4\n assert candidate(nums = [10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],target = 10) == 19\n assert candidate(nums = [2, 3, 1, 1, 4, 2, 3, 1, 1, 4, 2, 3, 1, 1, 4, 2, 3, 1, 1, 4],target = 2) == 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],target = 1) == 19\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],target = 1) == 14\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 20) == 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 = 5) == 19\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 100) == -1\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10],target = 4) == 11\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8],target = 2) == 14\n assert candidate(nums = [1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3],target = 2) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 9) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 1) == 9\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],target = 1) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 5) == 9\n assert candidate(nums = [1, 3, 6, 7, 10, 12, 15],target = 2) == -1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 2) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0],target = 10) == 19\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],target = 999999999) == 9\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],target = 999999999) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 2) == 9\n assert candidate(nums = [10, 5, 10, 15, 20, 25, 30, 35, 40, 45],target = 10) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 15) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 2) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5) == 9\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().maximumJumps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumJumps(int[] nums, int target) {", "container": "Solution", "callable": "maximumJumps", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2771, "task_id": "longest-non-decreasing-subarray-from-two-arrays", "difficulty": "Medium", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2 of length n.\nLet's define another 0-indexed integer array, nums3, of length n. For each index i in the range [0, n - 1], you can assign either nums1[i] or nums2[i] to nums3[i].\nYour task is to maximize the length of the longest non-decreasing subarray in nums3 by choosing its values optimally.\nReturn an integer representing the length of the longest non-decreasing subarray in nums3.\nNote: A subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums1 = [2,3,1], nums2 = [1,2,1]\nOutput: 2\nExplanation: One way to construct nums3 is: \nnums3 = [nums1[0], nums2[1], nums2[2]] => [2,2,1]. \nThe subarray starting from index 0 and ending at index 1, [2,2], forms a non-decreasing subarray of length 2. \nWe can show that 2 is the maximum achievable length.\nExample 2:\n\nInput: nums1 = [1,3,2,1], nums2 = [2,2,3,4]\nOutput: 4\nExplanation: One way to construct nums3 is: \nnums3 = [nums1[0], nums2[1], nums2[2], nums2[3]] => [1,2,3,4]. \nThe entire array forms a non-decreasing subarray of length 4, making it the maximum achievable length.\n\nExample 3:\n\nInput: nums1 = [1,1], nums2 = [2,2]\nOutput: 2\nExplanation: One way to construct nums3 is: \nnums3 = [nums1[0], nums1[1]] => [1,1]. \nThe entire array forms a non-decreasing subarray of length 2, making it the maximum achievable length.\n\n \nConstraints:\n\n1 <= nums1.length == nums2.length == n <= 105\n1 <= nums1[i], nums2[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [2, 3, 1],nums2 = [1, 2, 1]) == 2\n assert candidate(nums1 = [8, 6, 4, 2],nums2 = [7, 5, 3, 1]) == 1\n assert candidate(nums1 = [1, 2, 2, 2, 3],nums2 = [2, 2, 3, 3, 4]) == 5\n assert candidate(nums1 = [1000000000, 1, 1000000000],nums2 = [1, 1000000000, 1]) == 3\n assert candidate(nums1 = [1000000000, 1000000000, 1000000000],nums2 = [1000000000, 1000000000, 1000000000]) == 3\n assert candidate(nums1 = [1, 3, 5, 7],nums2 = [2, 4, 6, 8]) == 4\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == 3\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [3, 3, 3, 3]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [8, 4, 6, 2],nums2 = [7, 3, 5, 1]) == 2\n assert candidate(nums1 = [5, 3, 4, 5],nums2 = [1, 2, 3, 4]) == 4\n assert candidate(nums1 = [1],nums2 = [2]) == 1\n assert candidate(nums1 = [1, 1],nums2 = [2, 2]) == 2\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums1 = [1, 3, 2, 1],nums2 = [2, 2, 3, 4]) == 4\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [10, 10, 10],nums2 = [10, 10, 10]) == 3\n assert candidate(nums1 = [10, 9, 2, 5, 3, 7, 101, 18],nums2 = [0, 4, 1, 1, 1, 6, 8, 11]) == 6\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 = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8]) == 21\n assert candidate(nums1 = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],nums2 = [2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13]) == 20\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21],nums2 = [2, 6, 10, 14, 18, 22]) == 6\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums1 = [1, 3, 2, 1, 2, 3, 2, 1, 2, 3],nums2 = [2, 4, 3, 2, 3, 4, 3, 2, 3, 4]) == 5\n assert candidate(nums1 = [7, 7, 7, 7, 7, 7, 7],nums2 = [7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 10\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 10\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]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums1 = [10, 9, 2, 5, 3, 7, 101, 18],nums2 = [9, 8, 3, 6, 5, 8, 102, 19]) == 5\n assert candidate(nums1 = [3, 3, 2, 2, 1, 1],nums2 = [2, 2, 1, 1, 3, 3]) == 6\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums1 = [5, 7, 9, 10, 6, 8],nums2 = [6, 7, 8, 9, 10, 5]) == 5\n assert candidate(nums1 = [1, 3, 5, 2, 4, 6, 3, 5, 7],nums2 = [2, 4, 6, 1, 3, 5, 4, 6, 8]) == 3\n assert candidate(nums1 = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],nums2 = [2, 4, 3, 5, 4, 6, 5, 7, 6, 8]) == 10\n assert candidate(nums1 = [1, 2, 2, 3, 4, 4, 4, 5, 5, 5],nums2 = [2, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 10\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 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums1 = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],nums2 = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 15\n assert candidate(nums1 = [3, 6, 9, 12, 15],nums2 = [1, 4, 7, 10, 13]) == 5\n assert candidate(nums1 = [3, 3, 3, 100, 3, 3, 3, 100, 3, 3],nums2 = [100, 3, 3, 3, 100, 3, 3, 3, 100, 3]) == 10\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 5\n assert candidate(nums1 = [10, 20, 15, 25, 30, 5, 10, 20, 25, 35],nums2 = [5, 15, 10, 20, 35, 1, 5, 15, 25, 40]) == 5\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums1 = [1, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14]) == 7\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, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10],nums2 = [2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 16\n assert candidate(nums1 = [1, 2, 3, 4, 5, 100, 6, 7, 8, 9],nums2 = [1, 2, 3, 4, 5, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums1 = [10, 20, 30, 25, 20, 15, 10, 5],nums2 = [5, 10, 15, 20, 25, 30, 35, 40]) == 8\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 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]) == 10\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],nums2 = [2, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 15\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [101, 201, 301, 401, 501, 601, 701, 801, 901, 1001]) == 10\n assert candidate(nums1 = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11]) == 10\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 10\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 10\n assert candidate(nums1 = [7, 7, 7, 7, 7],nums2 = [7, 7, 7, 7, 7]) == 5\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 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, 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]) == 31\n assert candidate(nums1 = [5, 3, 5, 3, 5, 3, 5],nums2 = [3, 5, 3, 5, 3, 5, 3]) == 7\n assert candidate(nums1 = [3, 2, 4, 5, 1, 3, 4],nums2 = [4, 3, 5, 6, 2, 4, 5]) == 4\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [2, 5, 8, 11, 14, 17, 20]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [5, 10, 5, 15, 20],nums2 = [3, 8, 7, 12, 25]) == 3\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, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 17\n assert candidate(nums1 = [5, 3, 4, 5, 1, 6, 7, 8, 9, 10],nums2 = [4, 4, 5, 6, 1, 2, 3, 8, 8, 11]) == 6\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 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],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n assert candidate(nums1 = [10, 11, 10, 11, 10, 11],nums2 = [11, 10, 11, 10, 11, 10]) == 6\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, 6, 7, 8, 9, 1, 2, 3, 4, 5],nums2 = [4, 5, 6, 7, 8, 9, 1, 2, 3, 4]) == 6\n assert candidate(nums1 = [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]) == 15\n assert candidate(nums1 = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],nums2 = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 10\n assert candidate(nums1 = [9, 7, 5, 3, 1],nums2 = [10, 8, 6, 4, 2]) == 1\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums1 = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9],nums2 = [2, 6, 3, 7, 4, 8, 5, 9, 6, 10]) == 2\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == 5\n assert candidate(nums1 = [1, 4, 5, 3, 2, 6, 7],nums2 = [2, 3, 4, 5, 6, 7, 8]) == 7\n assert candidate(nums1 = [1, 5, 2, 5, 3, 6],nums2 = [2, 3, 4, 5, 6, 7]) == 6\n assert candidate(nums1 = [1, 5, 7, 3, 9, 12],nums2 = [2, 4, 6, 8, 10, 11]) == 6\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2]) == 2\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 5\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5, 6],nums2 = [2, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(nums1 = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],nums2 = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 10\n assert candidate(nums1 = [1000000000, 999999999, 999999998, 999999997, 999999996],nums2 = [999999999, 999999998, 999999997, 999999996, 999999995]) == 2\n assert candidate(nums1 = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],nums2 = [20, 10, 20, 10, 20, 10, 20, 10, 20, 10]) == 10\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [1, 3, 5, 7, 9, 11]) == 6\n assert candidate(nums1 = [1, 5, 3, 7, 9],nums2 = [2, 6, 4, 8, 10]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\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]) == 10\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums1 = [3, 5, 4, 3, 5, 6, 7],nums2 = [2, 1, 6, 5, 4, 8, 9]) == 6\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 10\n assert candidate(nums1 = [3, 4, 2, 5, 7, 8],nums2 = [2, 5, 5, 6, 5, 7]) == 6\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 10\n assert candidate(nums1 = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4],nums2 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4]) == 10\n assert candidate(nums1 = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7],nums2 = [2, 1, 3, 2, 5, 4, 7, 6, 8, 7]) == 10\n assert candidate(nums1 = [1000000000, 1, 1000000000, 2, 1000000000, 3, 1000000000, 4, 1000000000, 5],nums2 = [1, 1000000000, 2, 1000000000, 3, 1000000000, 4, 1000000000, 5, 1000000000]) == 10\n assert candidate(nums1 = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10],nums2 = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 2\n assert candidate(nums1 = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],nums2 = [999999999, 999999999, 999999999, 999999999, 999999999]) == 5\n assert candidate(nums1 = [10, 10, 10, 10, 10],nums2 = [11, 9, 11, 9, 11]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4],nums2 = [4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 4\n assert candidate(nums1 = [1, 10, 3, 10, 5, 10, 7, 10, 9, 10],nums2 = [2, 9, 4, 9, 6, 9, 8, 9, 10, 9]) == 4\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [9, 7, 5, 3, 1]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 3, 2, 1],nums2 = [2, 3, 4, 5, 4, 3, 2]) == 5\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [11, 21, 31, 41, 51, 61, 71, 81, 91, 101]) == 10\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26]) == 13\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2]) == 5\n assert candidate(nums1 = [7, 8, 9, 10, 11, 5, 6, 7, 8, 9],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 5],nums2 = [2, 2, 3, 3, 4, 4, 5]) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxNonDecreasingLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxNonDecreasingLength(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "maxNonDecreasingLength", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2772, "task_id": "apply-operations-to-make-all-array-elements-equal-to-zero", "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 subarray of size k from the array and decrease all its elements by 1.\n\nReturn true if you can make all the array elements equal to 0, or false otherwise.\nA subarray is a contiguous non-empty part of an array.\n \nExample 1:\n\nInput: nums = [2,2,3,1,1,0], k = 3\nOutput: true\nExplanation: We can do the following operations:\n- Choose the subarray [2,2,3]. The resulting array will be nums = [1,1,2,1,1,0].\n- Choose the subarray [2,1,1]. The resulting array will be nums = [1,1,1,0,0,0].\n- Choose the subarray [1,1,1]. The resulting array will be nums = [0,0,0,0,0,0].\n\nExample 2:\n\nInput: nums = [1,3,1,1], k = 2\nOutput: false\nExplanation: It is not possible to make all the array elements equal to 0.\n\n \nConstraints:\n\n1 <= k <= nums.length <= 105\n0 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 2, 3, 1, 1, 0],k = 3) == True\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == True\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == False\n assert candidate(nums = [1000000, 1000000, 1000000],k = 3) == True\n assert candidate(nums = [0, 0, 0, 0],k = 2) == True\n assert candidate(nums = [1, 3, 1, 1],k = 2) == False\n assert candidate(nums = [0, 0, 0, 0, 0],k = 5) == True\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == False\n assert candidate(nums = [1, 0, 1, 0, 1],k = 2) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == False\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1) == True\n assert candidate(nums = [10, 9, 8, 7, 6],k = 3) == False\n assert candidate(nums = [1, 1, 1, 1],k = 1) == True\n assert candidate(nums = [0, 0, 0, 0, 0],k = 1) == True\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == False\n assert candidate(nums = [3, 2, 1, 1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1],k = 3) == False\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 = 20) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == False\n assert candidate(nums = [0, 1, 2, 3, 4, 3, 2, 1, 0],k = 5) == False\n assert candidate(nums = [0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0],k = 5) == False\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 7) == False\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) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == False\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],k = 4) == True\n assert candidate(nums = [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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 10) == False\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == False\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 = 5) == False\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 3) == False\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) == False\n assert candidate(nums = [3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2],k = 5) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],k = 5) == True\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],k = 10) == False\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == False\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 = 5) == True\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],k = 7) == False\n assert candidate(nums = [0, 1, 2, 3, 4, 3, 2, 1, 0],k = 3) == False\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) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == False\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 = 7) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == False\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4],k = 6) == True\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],k = 3) == True\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 = 10) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == False\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1, 1, 1, 1],k = 3) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 7) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == False\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 3) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],k = 3) == False\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == False\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 0, 0, 0],k = 4) == True\n assert candidate(nums = [3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3],k = 3) == False\n assert candidate(nums = [3, 4, 5, 4, 3, 2, 1, 0],k = 3) == False\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2],k = 3) == False\n assert candidate(nums = [1, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0, 0],k = 3) == 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],k = 10) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 7) == True\n assert candidate(nums = [3, 4, 5, 4, 3, 4, 5, 4, 3],k = 3) == False\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 3) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == False\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 5) == False\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],k = 50) == False\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4],k = 4) == False\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 2) == False\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 2) == False\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],k = 5) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == False\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == True\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],k = 3) == False\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, 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, 4, 4, 4, 4, 4],k = 15) == False\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],k = 25) == True\n assert candidate(nums = [4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 1, 1, 0, 0, 0],k = 4) == False\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, 1],k = 1) == 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, 1, 1, 1, 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) == False\n assert candidate(nums = [5, 4, 3, 2, 1, 0],k = 3) == False\n assert candidate(nums = [4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0],k = 5) == False\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == True\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1],k = 5) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == False\n assert candidate(nums = [6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],k = 6) == False\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],k = 2) == False\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 7) == False\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == False\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1],k = 3) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == False\n assert candidate(nums = [2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2],k = 3) == False\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 = 5) == False\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 = 5) == False\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 2) == False\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 10) == True\n assert candidate(nums = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0],k = 5) == False\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 3) == False\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 4) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],k = 4) == True\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == False\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1],k = 2) == False\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 2) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == False\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().checkArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean checkArray(int[] nums, int k) {", "container": "Solution", "callable": "checkArray", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2778, "task_id": "sum-of-squares-of-special-elements", "difficulty": "Easy", "problem_description": "You are given a 1-indexed integer array nums of length n.\nAn element nums[i] of nums is called special if i divides n, i.e. n % i == 0.\nReturn the sum of the squares of all special elements of nums.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 21\nExplanation: There are exactly 3 special elements in nums: nums[1] since 1 divides 4, nums[2] since 2 divides 4, and nums[4] since 4 divides 4. \nHence, the sum of the squares of all special elements of nums is nums[1] * nums[1] + nums[2] * nums[2] + nums[4] * nums[4] = 1 * 1 + 2 * 2 + 4 * 4 = 21. \n\nExample 2:\n\nInput: nums = [2,7,1,19,18,3]\nOutput: 63\nExplanation: There are exactly 4 special elements in nums: nums[1] since 1 divides 6, nums[2] since 2 divides 6, nums[3] since 3 divides 6, and nums[6] since 6 divides 6. \nHence, the sum of the squares of all special elements of nums is nums[1] * nums[1] + nums[2] * nums[2] + nums[3] * nums[3] + nums[6] * nums[6] = 2 * 2 + 7 * 7 + 1 * 1 + 3 * 3 = 63. \n\n \nConstraints:\n\n1 <= nums.length == n <= 50\n1 <= nums[i] <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [5, 10, 15, 20, 25]) == 650\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4]) == 21\n assert candidate(nums = [49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49]) == 14406\n assert candidate(nums = [49, 25, 9, 4, 1]) == 2402\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 3250\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50]) == 2600\n assert candidate(nums = [5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [30, 20, 10]) == 1000\n assert candidate(nums = [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]) == 4083\n assert candidate(nums = [2, 7, 1, 19, 18, 3]) == 63\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 2358\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336, 357, 378, 399, 420, 441, 462, 483, 504, 525]) == 287091\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 26754\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310, 341, 372, 403, 434, 465, 496]) == 327701\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1300000\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 274878169413\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1428\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500, 525, 550, 575, 600, 625]) == 406875\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 1040\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]) == 41664\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 51332\n assert candidate(nums = [4, 16, 36, 64, 100, 144, 196, 256, 324, 400, 484, 576, 676, 784, 900, 1024, 1156, 1296, 1444, 1600]) == 2734368\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300, 315, 330, 345, 360, 375]) == 146475\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]) == 19656\n assert candidate(nums = [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]) == 68275\n assert candidate(nums = [5, 25, 45, 65, 85, 105, 125, 145, 165, 185, 205, 225, 245, 265, 285, 305, 325, 345, 365, 385]) == 194550\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266, 285, 304, 323, 342, 361, 380]) == 197106\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, 50]) == 2630\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 53268\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, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 675\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 2359\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 51332\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]) == 41664\n assert candidate(nums = [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]) == 7931\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 50, 49, 48, 47, 46]) == 3140\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]) == 9534\n assert candidate(nums = [50, 25, 12, 6, 4, 3, 2, 1]) == 3162\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 28500\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]) == 10416\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, 50]) == 2630\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]) == 75\n assert candidate(nums = [36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36]) == 5184\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]) == 2604\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260, 273, 286, 299, 312, 325]) == 110019\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 92274\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500]) == 341250\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]) == 8216\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 170898\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300]) == 117000\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 2359\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]) == 16275\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225]) == 52731\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]) == 5097\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]) == 78771\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120]) == 16640\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1, 6, 12, 18, 24, 30, 36, 42, 48, 50]) == 9175\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]) == 2483\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260, 273, 286, 299, 312, 325]) == 110019\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266, 285, 304, 323, 342, 361, 380, 399, 418, 437, 456, 475]) == 235011\n assert candidate(nums = [10, 21, 30, 42, 55, 60, 77, 84, 91, 100]) == 13566\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 4914\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195]) == 43940\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 50]) == 2509\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]) == 31899\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]) == 34944\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 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, 2116, 2209, 2304, 2401, 2500]) == 6596690\n assert candidate(nums = [42, 35, 28, 21, 14, 7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 3838\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 12740\n assert candidate(nums = [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]) == 5859\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]) == 1300\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 319, 348, 377, 406, 435, 464, 493, 522, 551, 580, 609, 638, 667, 696, 725]) == 547491\n assert candidate(nums = [30, 20, 10, 5, 25, 15, 50, 40, 35, 45, 60, 70, 80, 90, 100]) == 11625\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]) == 651\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]) == 9534\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 54600\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]) == 65100\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == 11868\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 274878169413\n assert candidate(nums = [44, 88, 132, 176, 220, 264, 308, 352, 396, 440, 484, 528, 572, 616, 660, 704, 748, 792, 836, 880]) == 1057056\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 26000\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 45768286\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 546\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 12740\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, 4, 8, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0]) == 9\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 1170\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]) == 2\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 26754\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]) == 3255\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 131\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]) == 65100\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]) == 122850\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135]) == 21060\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330, 363, 396, 429, 462, 495, 528, 561, 594, 627, 660, 693, 726, 759, 792, 825]) == 708939\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]) == 172\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]) == 391251\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]) == 165839\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]) == 27\n assert candidate(nums = [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]) == 127596\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336, 357, 378, 399, 420, 441, 462, 483, 504, 525]) == 287091\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340, 357, 374, 391, 408, 425]) == 188139\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 26000\n assert candidate(nums = [16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1, 32]) == 2720\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfSquares", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int sumOfSquares(int[] nums) {", "container": "Solution", "callable": "sumOfSquares", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2779, "task_id": "maximum-beauty-of-an-array-after-applying-operation", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums and a non-negative integer k.\nIn one operation, you can do the following:\n\nChoose an index i that hasn't been chosen before from the range [0, nums.length - 1].\nReplace nums[i] with any integer from the range [nums[i] - k, nums[i] + k].\n\nThe beauty of the array is the length of the longest subsequence consisting of equal elements.\nReturn the maximum possible beauty of the array nums after applying the operation any number of times.\nNote that you can apply the operation to each index only once.\nA subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the order of the remaining elements.\n \nExample 1:\n\nInput: nums = [4,6,1,2], k = 2\nOutput: 3\nExplanation: In this example, we apply the following operations:\n- Choose index 1, replace it with 4 (from range [4,8]), nums = [4,4,1,2].\n- Choose index 3, replace it with 4 (from range [0,4]), nums = [4,4,1,4].\nAfter the applied operations, the beauty of the array nums is 3 (subsequence consisting of indices 0, 1, and 3).\nIt can be proven that 3 is the maximum possible length we can achieve.\n\nExample 2:\n\nInput: nums = [1,1,1,1], k = 10\nOutput: 4\nExplanation: In this example we don't have to apply any operations.\nThe beauty of the array nums is 4 (whole array).\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i], k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 3) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 3\n assert candidate(nums = [10, 20, 30, 40, 50],k = 15) == 4\n assert candidate(nums = [5, 15, 25, 35],k = 5) == 2\n assert candidate(nums = [100, 100, 100],k = 5) == 3\n assert candidate(nums = [100, 200, 300, 400, 500],k = 0) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n assert candidate(nums = [3, 3, 3, 3, 3],k = 1) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 5\n assert candidate(nums = [100000, 0, 50000, 25000, 75000],k = 50000) == 5\n assert candidate(nums = [10, 20, 30, 40, 50],k = 5) == 2\n assert candidate(nums = [8, 8, 8, 8, 8, 8],k = 0) == 6\n assert candidate(nums = [1, 3, 5, 7, 9],k = 1) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == 9\n assert candidate(nums = [5, 3, 9, 8, 7],k = 1) == 3\n assert candidate(nums = [2, 4, 6, 8, 10],k = 2) == 3\n assert candidate(nums = [3, 3, 3, 3, 3],k = 5) == 5\n assert candidate(nums = [4, 6, 1, 2],k = 2) == 3\n assert candidate(nums = [10, 20, 30, 40, 50],k = 0) == 1\n assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],k = 0) == 1\n assert candidate(nums = [1, 100000],k = 50000) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 9\n assert candidate(nums = [5, 3, 15, 8, 10],k = 5) == 4\n assert candidate(nums = [100000, 100000, 100000],k = 0) == 3\n assert candidate(nums = [5, 3, 15, 8, 1],k = 3) == 3\n assert candidate(nums = [1, 1, 1, 1],k = 10) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 3\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],k = 50) == 10\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 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, 5, 6, 6, 6, 6, 6, 6, 6],k = 1) == 18\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3) == 4\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 1) == 12\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 0) == 5\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],k = 4) == 3\n assert candidate(nums = [2, 5, 9, 14, 20, 27, 35, 44, 54, 65],k = 10) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],k = 1) == 9\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 1) == 9\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],k = 4) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 3\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],k = 50000) == 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 = 1) == 6\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],k = 50) == 11\n assert candidate(nums = [100, 100, 200, 200, 300, 300, 400, 400],k = 50) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 4\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 10000) == 10\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40],k = 10) == 9\n assert candidate(nums = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 3) == 4\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15],k = 3) == 10\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 10) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 20) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 3\n assert candidate(nums = [5, 8, 12, 15, 17, 20, 23, 25, 28, 30],k = 5) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4],k = 1) == 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 = 3) == 7\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11],k = 2) == 5\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 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],k = 50000) == 20\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 = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32],k = 5) == 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],k = 0) == 20\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10],k = 1) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 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, 1],k = 100000) == 32\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) == 11\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 150) == 4\n assert candidate(nums = [5, 8, 8, 10, 12, 15, 15, 20, 22, 25],k = 3) == 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],k = 100000) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 2\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],k = 50) == 11\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 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 = 9) == 19\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500],k = 50) == 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],k = 9) == 19\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 1) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700],k = 100) == 3\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],k = 3) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10000) == 15\n assert candidate(nums = [100000, 1, 2, 3, 100000, 100000, 4, 5, 6, 7, 8, 9],k = 100000) == 12\n assert candidate(nums = [90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 25000) == 6\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40],k = 7) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 3\n assert candidate(nums = [2, 4, 4, 4, 6, 8, 8, 8, 10, 12, 12, 14, 16, 18],k = 2) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 11\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 15) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 5\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 45) == 10\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10, 0],k = 10) == 3\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 10) == 5\n assert candidate(nums = [100, 110, 120, 130, 140, 150, 160, 170, 180, 190],k = 15) == 4\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000],k = 15000) == 4\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],k = 5) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 1) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 0) == 2\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 1) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 2) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 8) == 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],k = 100000) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 2) == 15\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6],k = 1) == 14\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 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 = 2) == 3\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20],k = 3) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 8) == 9\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145],k = 25) == 6\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],k = 20) == 11\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000],k = 25000) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 4\n assert candidate(nums = [100, 100, 100, 200, 200, 200, 300, 300, 300, 400, 400, 400, 500, 500, 500],k = 100) == 9\n assert candidate(nums = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 3) == 4\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],k = 45) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n assert candidate(nums = [5, 15, 25, 35, 45, 55],k = 10) == 3\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 = 1) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 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],k = 12) == 25\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumBeauty", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumBeauty(int[] nums, int k) {", "container": "Solution", "callable": "maximumBeauty", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2780, "task_id": "minimum-index-of-a-valid-split", "difficulty": "Medium", "problem_description": "An element x of an integer array arr of length m is dominant if more than half the elements of arr have a value of x.\nYou are given a 0-indexed integer array nums of length n with one dominant element.\nYou can split nums at an index i into two arrays nums[0, ..., i] and nums[i + 1, ..., n - 1], but the split is only valid if:\n\n0 <= i < n - 1\nnums[0, ..., i], and nums[i + 1, ..., n - 1] have the same dominant element.\n\nHere, nums[i, ..., j] denotes the subarray of nums starting at index i and ending at index j, both ends being inclusive. Particularly, if j < i then nums[i, ..., j] denotes an empty subarray.\nReturn the minimum index of a valid split. If no valid split exists, return -1.\n \nExample 1:\n\nInput: nums = [1,2,2,2]\nOutput: 2\nExplanation: We can split the array at index 2 to obtain arrays [1,2,2] and [2]. \nIn array [1,2,2], element 2 is dominant since it occurs twice in the array and 2 * 2 > 3. \nIn array [2], element 2 is dominant since it occurs once in the array and 1 * 2 > 1.\nBoth [1,2,2] and [2] have the same dominant element as nums, so this is a valid split. \nIt can be shown that index 2 is the minimum index of a valid split. \nExample 2:\n\nInput: nums = [2,1,3,1,1,1,7,1,2,1]\nOutput: 4\nExplanation: We can split the array at index 4 to obtain arrays [2,1,3,1,1] and [1,7,1,2,1].\nIn array [2,1,3,1,1], element 1 is dominant since it occurs thrice in the array and 3 * 2 > 5.\nIn array [1,7,1,2,1], element 1 is dominant since it occurs thrice in the array and 3 * 2 > 5.\nBoth [2,1,3,1,1] and [1,7,1,2,1] have the same dominant element as nums, so this is a valid split.\nIt can be shown that index 4 is the minimum index of a valid split.\nExample 3:\n\nInput: nums = [3,3,3,3,7,2,2]\nOutput: -1\nExplanation: It can be shown that there is no valid split.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\nnums has exactly one dominant element.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 1]) == 0\n assert candidate(nums = [3, 3, 3, 3, 7, 2, 2]) == -1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 1]) == 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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 = [1, 2, 2, 2]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 1, 3, 1, 1, 1, 7, 1, 2, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == -1\n assert candidate(nums = [7, 7, 7, 7, 7, 1, 1, 1, 1, 1]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumIndex", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumIndex(List nums) {", "container": "Solution", "callable": "minimumIndex", "parameters": [{"name": "nums", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2781, "task_id": "length-of-the-longest-valid-substring", "difficulty": "Hard", "problem_description": "You are given a string word and an array of strings forbidden.\nA string is called valid if none of its substrings are present in forbidden.\nReturn the length of the longest valid substring of the string word.\nA substring is a contiguous sequence of characters in a string, possibly empty.\n \nExample 1:\n\nInput: word = \"cbaaaabc\", forbidden = [\"aaa\",\"cb\"]\nOutput: 4\nExplanation: There are 11 valid substrings in word: \"c\", \"b\", \"a\", \"ba\", \"aa\", \"bc\", \"baa\", \"aab\", \"ab\", \"abc\" and \"aabc\". The length of the longest valid substring is 4. \nIt can be shown that all other substrings contain either \"aaa\" or \"cb\" as a substring. \nExample 2:\n\nInput: word = \"leetcode\", forbidden = [\"de\",\"le\",\"e\"]\nOutput: 4\nExplanation: There are 11 valid substrings in word: \"l\", \"t\", \"c\", \"o\", \"d\", \"tc\", \"co\", \"od\", \"tco\", \"cod\", and \"tcod\". The length of the longest valid substring is 4.\nIt can be shown that all other substrings contain either \"de\", \"le\", or \"e\" as a substring. \n\n \nConstraints:\n\n1 <= word.length <= 105\nword consists only of lowercase English letters.\n1 <= forbidden.length <= 105\n1 <= forbidden[i].length <= 10\nforbidden[i] consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"zzzzzzzzzz\",forbidden = ['zz']) == 1\n assert candidate(word = \"abacab\",forbidden = ['ba', 'ca']) == 2\n assert candidate(word = \"leetcode\",forbidden = ['de', 'le', 'e']) == 4\n assert candidate(word = \"abcde\",forbidden = ['fgh']) == 5\n assert candidate(word = \"aaaaaaa\",forbidden = ['aa']) == 1\n assert candidate(word = \"aaaabaaa\",forbidden = ['aa']) == 3\n assert candidate(word = \"abcde\",forbidden = ['fgh', 'ijk']) == 5\n assert candidate(word = \"xyz\",forbidden = ['xy', 'yz']) == 1\n assert candidate(word = \"cbaaaabc\",forbidden = ['aaa', 'cb']) == 4\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",forbidden = ['abc', 'xyz']) == 24\n assert candidate(word = \"abcd\",forbidden = ['a', 'b', 'c', 'd']) == 0\n assert candidate(word = \"abacaba\",forbidden = ['ba', 'ca']) == 2\n assert candidate(word = \"abcde\",forbidden = ['ab', 'bc', 'cd', 'de']) == 1\n assert candidate(word = \"aaabbbcccddd\",forbidden = ['aaa', 'bbb', 'ccc', 'ddd', 'abc']) == 4\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",forbidden = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == 4\n assert candidate(word = \"pppppppppppppppppppppppppppppppppp\",forbidden = ['pp', 'p']) == 0\n assert candidate(word = \"abcdefghijabcdefghij\",forbidden = ['abc', 'def', 'ghi', 'jij', 'fed', 'cba']) == 5\n assert candidate(word = \"abcdefghijabcdefghij\",forbidden = ['abcdefghij', 'abc', 'def', 'ghi', 'jih', 'ihg', 'fed', 'cba']) == 5\n assert candidate(word = \"xyxzyzyxzyzyzxzyzx\",forbidden = ['xyz', 'zyx', 'xzy']) == 7\n assert candidate(word = \"hellothere\",forbidden = ['he', 'lo', 'th', 'er', 'ere']) == 3\n assert candidate(word = \"xyzxyzxyzxyz\",forbidden = ['xy', 'yz', 'zx', 'xyz']) == 1\n assert candidate(word = \"abcdefghij\",forbidden = ['abc', 'def', 'ghi', 'j']) == 4\n assert candidate(word = \"abcdeabcdeabcde\",forbidden = ['abc', 'cde', 'dea', 'bcd']) == 3\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",forbidden = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 2\n assert candidate(word = \"pneumonoultramicroscopicsilicovolcanoconiosis\",forbidden = ['pneumo', 'ultra', 'micro', 'scopic', 'silico', 'volcano', 'conio', 'osis', 'pneumonoultramicro', 'microscopic', 'scopicsilico', 'silicovolcano', 'volcanoconi', 'conoosis']) == 11\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnm\",forbidden = ['qwe', 'ert', 'rty', 'tyu', 'yui', 'uio', 'iop', 'asd', 'sdf', 'dfg', 'fgh', 'ghj', 'hjk', 'jkl', 'klz', 'lzx', 'zxc', 'xcv', 'cvb', 'vbn', 'bnm']) == 4\n assert candidate(word = \"mississippi\",forbidden = ['iss', 'sip', 'issi', 'ippi']) == 4\n assert candidate(word = \"abcabcabcabc\",forbidden = ['abcabc', 'bcab', 'cababc']) == 5\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbb\",forbidden = ['aaa', 'bbb', 'ab', 'ba', 'aab', 'bba']) == 2\n assert candidate(word = \"banana\",forbidden = ['na', 'an', 'ba', 'baa', 'nan', 'ban', 'anan']) == 1\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",forbidden = ['xyz', 'uvw', 'rst', 'qpo', 'lmn', 'fed', 'cba']) == 13\n assert candidate(word = \"banana\",forbidden = ['ana', 'nan', 'ba', 'na', 'an']) == 1\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnm\",forbidden = ['qwe', 'rty', 'uiop', 'asdf', 'ghjk', 'lzx', 'cvb', 'nm']) == 6\n assert candidate(word = \"xyzxyzxyzxyz\",forbidden = ['xy', 'yz', 'zx']) == 1\n assert candidate(word = \"aaaaabbbbbcccccc\",forbidden = ['aaaa', 'bbbb', 'cccc', 'ab', 'bc', 'ca']) == 3\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",forbidden = ['aabb', 'bbcc', 'ccdd', 'ddee', 'eefg', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'zyz']) == 45\n assert candidate(word = \"abcabcabcabc\",forbidden = ['abc', 'cab', 'bca']) == 2\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",forbidden = ['abc', 'xyz', 'mnop', 'qrst']) == 14\n assert candidate(word = \"ababababab\",forbidden = ['aba', 'bab', 'aaa']) == 2\n assert candidate(word = \"mississippi\",forbidden = ['issi', 'iss', 'ss', 'ssip', 'ippi']) == 4\n assert candidate(word = \"xyzxyzxyz\",forbidden = ['xyz', 'xy', 'yz']) == 2\n assert candidate(word = \"abcabcabcabcabc\",forbidden = ['abc', 'bca', 'cab']) == 2\n assert candidate(word = \"abababababababab\",forbidden = ['aba', 'bab', 'abb']) == 2\n assert candidate(word = \"hellohellohellohello\",forbidden = ['he', 'el', 'll', 'lo', 'oh']) == 1\n assert candidate(word = \"xyxyxyxyxyxyxyxy\",forbidden = ['xyx', 'yxy', 'xyxy']) == 2\n assert candidate(word = \"abacabadabacaba\",forbidden = ['aba', 'abc', 'bac']) == 5\n assert candidate(word = \"mississippi\",forbidden = ['issi', 'iss', 'is', 'mp', 'ss', 'pp']) == 3\n assert candidate(word = \"abcdefghij\",forbidden = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl']) == 2\n assert candidate(word = \"mississippi\",forbidden = ['iss', 'issi', 'ippi', 'issipp', 'missi', 'sissi', 'ssippi']) == 5\n assert candidate(word = \"nolongerforbidden\",forbidden = ['for', 'bidden', 'no', 'longer']) == 7\n assert candidate(word = \"qwertypoiuytrewq\",forbidden = ['qw', 'we', 'er', 'rt', 'ty', 'yu', 'ui', 'io', 'op']) == 11\n assert candidate(word = \"banana\",forbidden = ['na', 'ba', 'an']) == 1\n assert candidate(word = \"thisthisthisthisthis\",forbidden = ['thi', 'hist', 'isth', 'histh', 'thist']) == 3\n assert candidate(word = \"mississippi\",forbidden = ['iss', 'issi', 'ippi']) == 5\n assert candidate(word = \"abababababababab\",forbidden = ['aba', 'bab', 'aab', 'bba']) == 2\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnm\",forbidden = ['qw', 'er', 'ty', 'ui', 'op', 'as', 'df', 'gh', 'jk', 'kl', 'zx', 'cv', 'vb', 'bn', 'nm']) == 2\n assert candidate(word = \"abcdabcdabcdabcdabcdabcd\",forbidden = ['abcd', 'bcda', 'cdab', 'dabc']) == 3\n assert candidate(word = \"abacaxabcd\",forbidden = ['ab', 'ca', 'bc', 'd']) == 3\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",forbidden = ['aa', 'bb', 'cc', 'zz', 'yy']) == 44\n assert candidate(word = \"banana\",forbidden = ['ana', 'nan', 'ban', 'ana', 'naa']) == 2\n assert candidate(word = \"mississippi\",forbidden = ['issi', 'iss', 'is', 'i', 's', 'p', 'mp']) == 1\n assert candidate(word = \"abracadabra\",forbidden = ['abr', 'rac', 'ada', 'bra', 'cab', 'cad']) == 3\n assert candidate(word = \"abcdefghij\",forbidden = ['abcdefghij', 'abcdefghi', 'bcdefgh', 'cdefgh', 'defgh', 'efgh', 'fgh', 'gh', 'h', 'ij']) == 7\n assert candidate(word = \"abacabadabacaba\",forbidden = ['aba', 'bad', 'cab', 'abc']) == 4\n assert candidate(word = \"aaaaaaaaaa\",forbidden = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa']) == 0\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",forbidden = ['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']) == 2\n assert candidate(word = \"mnopqrstuvwxyzabcdefghijkl\",forbidden = ['mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz']) == 6\n assert candidate(word = \"aabbccddeeff\",forbidden = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff']) == 2\n assert candidate(word = \"abcabcabcabcabcabcabc\",forbidden = ['abcabc', 'bcabc', 'cabc', 'abca', 'bca', 'cab', 'abc']) == 2\n assert candidate(word = \"abacabadabacaba\",forbidden = ['aba', 'aca', 'bad']) == 4\n assert candidate(word = \"thisisaverylongwordthatneedstobecut\",forbidden = ['this', 'is', 'very', 'long', 'word', 'that', 'needs', 'to', 'be', 'cut']) == 7\n assert candidate(word = \"abacabacabacaba\",forbidden = ['aba', 'aca', 'bab']) == 3\n assert candidate(word = \"abacabadabacaba\",forbidden = ['aba', 'abc', 'bac']) == 5\n assert candidate(word = \"thisisateststring\",forbidden = ['test', 'string', 'is', 'a', 'this']) == 8\n assert candidate(word = \"mississippi\",forbidden = ['issi', 'sip', 'iss', 'ippi', 'ppi']) == 4\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",forbidden = ['abc', 'xyz', 'mnop']) == 14\n"}, "metadata": {"canonical_parameter_names": ["word", "forbidden"], "leetcode_dataset_entry_point": "Solution().longestValidSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestValidSubstring(String word, List forbidden) {", "container": "Solution", "callable": "longestValidSubstring", "parameters": [{"name": "word", "type": "String"}, {"name": "forbidden", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2784, "task_id": "check-if-array-is-good", "difficulty": "Easy", "problem_description": "You are given an integer array nums. We consider an array good if it is a permutation of an array base[n].\nbase[n] = [1, 2, ..., n - 1, n, n] (in other words, it is an array of length n + 1 which contains 1 to n - 1 exactly once, plus two occurrences of n). For example, base[1] = [1, 1] and base[3] = [1, 2, 3, 3].\nReturn true if the given array is good, otherwise return false.\nNote: A permutation of integers represents an arrangement of these numbers.\n \nExample 1:\n\nInput: nums = [2, 1, 3]\nOutput: false\nExplanation: Since the maximum element of the array is 3, the only candidate n for which this array could be a permutation of base[n], is n = 3. However, base[3] has four elements but array nums has three. Therefore, it can not be a permutation of base[3] = [1, 2, 3, 3]. So the answer is false.\n\nExample 2:\n\nInput: nums = [1, 3, 3, 2]\nOutput: true\nExplanation: Since the maximum element of the array is 3, the only candidate n for which this array could be a permutation of base[n], is n = 3. It can be seen that nums is a permutation of base[3] = [1, 2, 3, 3] (by swapping the second and fourth elements in nums, we reach base[3]). Therefore, the answer is true.\nExample 3:\n\nInput: nums = [1, 1]\nOutput: true\nExplanation: Since the maximum element of the array is 1, the only candidate n for which this array could be a permutation of base[n], is n = 1. It can be seen that nums is a permutation of base[1] = [1, 1]. Therefore, the answer is true.\nExample 4:\n\nInput: nums = [3, 4, 4, 1, 2, 1]\nOutput: false\nExplanation: Since the maximum element of the array is 4, the only candidate n for which this array could be a permutation of base[n], is n = 4. However, base[4] has five elements but array nums has six. Therefore, it can not be a permutation of base[4] = [1, 2, 3, 4, 4]. So the answer is false.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= num[i] <= 200\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 3, 2]) == True\n assert candidate(nums = [2, 1, 1]) == False\n assert candidate(nums = [2, 1, 2]) == True\n assert candidate(nums = [1, 2, 3, 3, 5, 4]) == False\n assert candidate(nums = [2, 2]) == False\n assert candidate(nums = [1, 2, 3, 3, 4, 4]) == False\n assert candidate(nums = [1, 2, 2]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1]) == False\n assert candidate(nums = [2, 1, 3]) == False\n assert candidate(nums = [1, 1]) == True\n assert candidate(nums = [2, 2, 1, 3]) == False\n assert candidate(nums = [1, 2, 3, 3]) == True\n assert candidate(nums = [2, 2, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 4]) == True\n assert candidate(nums = [3, 4, 4, 1, 2, 1]) == False\n assert candidate(nums = [4, 3, 4, 2, 1]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 4]) == False\n assert candidate(nums = [5, 5, 1, 2, 3, 4]) == True\n assert candidate(nums = [5, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [4, 1, 2, 3, 4]) == True\n assert candidate(nums = [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12]) == False\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [8, 1, 2, 3, 4, 5, 6, 7, 8]) == 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, 17, 17, 18, 18, 19, 19, 20, 20]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [3, 2, 1, 4, 4]) == True\n assert candidate(nums = [1, 2, 3, 4, 4, 4]) == False\n assert candidate(nums = [20, 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 = [7, 6, 5, 4, 3, 2, 1, 1, 7]) == False\n assert candidate(nums = [11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(nums = [19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19]) == 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, 21, 22, 23, 24, 24]) == True\n assert candidate(nums = [5, 1, 2, 3, 4, 4, 5]) == False\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 10]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11]) == False\n assert candidate(nums = [1, 2, 2, 3, 4, 5]) == False\n assert candidate(nums = [7, 1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(nums = [3, 1, 2, 3]) == True\n assert candidate(nums = [6, 1, 2, 3, 4, 5, 6]) == 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, 28]) == True\n assert candidate(nums = [1, 2, 3, 4, 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]) == False\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15]) == True\n assert candidate(nums = [100, 100, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 10]) == False\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [2, 1, 4, 3, 5, 6, 6]) == 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, 27]) == 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]) == 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 30]) == True\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 100]) == False\n assert candidate(nums = [6, 6, 1, 2, 3, 4, 5]) == 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, 26]) == True\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 7]) == True\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [2, 3, 1, 1, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 6, 7]) == False\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 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, 200]) == True\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 6]) == 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, 19, 20, 20]) == False\n assert candidate(nums = [6, 1, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9]) == False\n assert candidate(nums = [1, 3, 2, 5, 4, 6, 6]) == 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, 22]) == True\n assert candidate(nums = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 19]) == True\n assert candidate(nums = [6, 2, 1, 3, 4, 5, 6]) == True\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20]) == True\n assert candidate(nums = [6, 1, 2, 3, 4, 5, 6, 6, 7]) == 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, 19]) == 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, 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]) == 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, 20]) == True\n assert candidate(nums = [2, 2, 1, 3, 4]) == False\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == False\n assert candidate(nums = [18, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]) == 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, 50, 1]) == False\n assert candidate(nums = [19, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19]) == False\n assert candidate(nums = [6, 3, 2, 1, 4, 5, 6]) == True\n assert candidate(nums = [100, 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]) == False\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 10, 20]) == False\n assert candidate(nums = [13, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(nums = [5, 2, 3, 4, 4, 1, 5]) == False\n assert candidate(nums = [17, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 17]) == False\n assert candidate(nums = [7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 7]) == False\n assert candidate(nums = [18, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18]) == False\n assert candidate(nums = [5, 5, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]) == False\n assert candidate(nums = [7, 1, 2, 3, 4, 5, 6, 6]) == False\n assert candidate(nums = [11, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]) == False\n assert candidate(nums = [1, 3, 2, 5, 4, 5]) == True\n assert candidate(nums = [5, 3, 4, 5, 1, 2]) == 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, 100]) == 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, 25]) == 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, 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, 50]) == 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, 20, 21]) == False\n assert candidate(nums = [7, 1, 2, 3, 4, 5, 6, 6, 8]) == False\n assert candidate(nums = [15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 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]) == False\n assert candidate(nums = [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(nums = [18, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 18]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1]) == False\n assert candidate(nums = [200, 1, 2, 3, Ellipsis, 198, 199, 199]) == False\n assert candidate(nums = [16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16]) == False\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9]) == False\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 11]) == True\n assert candidate(nums = [15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15]) == False\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11]) == False\n assert candidate(nums = [19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == True\n assert candidate(nums = [8, 1, 2, 3, 4, 5, 6, 7, 7, 9]) == False\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20]) == 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, 19, 20]) == 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 29]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 8]) == False\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, 101, 101]) == True\n assert candidate(nums = [8, 1, 2, 3, 4, 5, 6, 7, 7, 8, 8]) == False\n assert candidate(nums = [2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == False\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, 50]) == False\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().isGood", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isGood(int[] nums) {", "container": "Solution", "callable": "isGood", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2785, "task_id": "sort-vowels-in-a-string", "difficulty": "Medium", "problem_description": "Given a 0-indexed string s, permute s to get a new string t such that:\n\nAll consonants remain in their original places. More formally, if there is an index i with 0 <= i < s.length such that s[i] is a consonant, then t[i] = s[i].\nThe vowels must be sorted in the nondecreasing order of their ASCII values. More formally, for pairs of indices i, j with 0 <= i < j < s.length such that s[i] and s[j] are vowels, then t[i] must not have a higher ASCII value than t[j].\n\nReturn the resulting string.\nThe vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in lowercase or uppercase. Consonants comprise all letters that are not vowels.\n \nExample 1:\n\nInput: s = \"lEetcOde\"\nOutput: \"lEOtcede\"\nExplanation: 'E', 'O', and 'e' are the vowels in s; 'l', 't', 'c', and 'd' are all consonants. The vowels are sorted according to their ASCII values, and the consonants remain in the same places.\n\nExample 2:\n\nInput: s = \"lYmpH\"\nOutput: \"lYmpH\"\nExplanation: There are no vowels in s (all characters in s are consonants), so we return \"lYmpH\".\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists only of letters of the English alphabet in uppercase and lowercase.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"b\") == \"b\"\n assert candidate(s = \"bCdEfGhIjK\") == \"bCdEfGhIjK\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"AEIOUaeiou\") == \"AEIOUaeiou\"\n assert candidate(s = \"uoiea\") == \"aeiou\"\n assert candidate(s = \"AbEcIdOfUg\") == \"AbEcIdOfUg\"\n assert candidate(s = \"aAeEiIoOuU\") == \"AEIOUaeiou\"\n assert candidate(s = \"ThIsIsAtEsTcAsE\") == \"ThAsAsEtEsTcIsI\"\n assert candidate(s = \"SortingVowels\") == \"SertingVowols\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aeiouAEIOU\") == \"AEIOUaeiou\"\n assert candidate(s = \"\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"AEbBcCdDIOfFgGUajJkKlLmMnNeipPqQrRsStTouvVwWxXyYzZ\"\n assert candidate(s = \"lEetcOde\") == \"lEOtcede\"\n assert candidate(s = \"ZyXwVutSrQpOnMlKjIhGfEdCbA\") == \"ZyXwVAtSrQpEnMlKjIhGfOdCbu\"\n assert candidate(s = \"ZYXWVUTSRQPONMLKJIHGFEDCBA\") == \"ZYXWVATSRQPENMLKJIHGFODCBU\"\n assert candidate(s = \"lYmpH\") == \"lYmpH\"\n assert candidate(s = \"Consonants\") == \"Cansononts\"\n assert candidate(s = \"aEIoU\") == \"EIUao\"\n assert candidate(s = \"AEIOU\") == \"AEIOU\"\n assert candidate(s = \"uUuUuUuUuUuUuUuUuUuUuUuUuUuU\") == \"UUUUUUUUUUUUUUuuuuuuuuuuuuuu\"\n assert candidate(s = \"mIxEdcAsEvOwElScOnSoNnTs\") == \"mAxEdcEsEvIwOlScOnSoNnTs\"\n assert candidate(s = \"rEvErsE\") == \"rEvErsE\"\n assert candidate(s = \"mIxEdCaSeVoWels\") == \"mExIdCaSeVeWols\"\n assert candidate(s = \"ThIsIsAVeRyLoNgStRiNgWhItHaMuLtIpLeVoWels\") == \"ThAsIsIVIRyLINgStRaNgWhetHeMeLtipLoVoWuls\"\n assert candidate(s = \"aBbAcCcAdDeE\") == \"ABbAcCcEdDae\"\n assert candidate(s = \"AeIoUeIoUaEiOuaEiOueIoU\") == \"AEEIIIOOUUUaaeeeiiooouu\"\n assert candidate(s = \"sAd\") == \"sAd\"\n assert candidate(s = \"bYpHtRfjK\") == \"bYpHtRfjK\"\n assert candidate(s = \"UnIvErSiTy\") == \"EnIvUrSiTy\"\n assert candidate(s = \"aEiOuAeIoUaEiOuAeIoUaEiOu\") == \"AAEEEIIOOOUUaaaeeiiioouuu\"\n assert candidate(s = \"UPPERCASE\") == \"APPERCESU\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"AbcdEfghIjklmnOpqrstUvwxyzaBCDeFGHiJKLMNoPQRSTuVWXYZ\"\n assert candidate(s = \"pYtHoNpRoGrAmMiNg\") == \"pYtHANpRiGromMoNg\"\n assert candidate(s = \"bBcCdDfFgGhHjJkKlLmMpPqQrRsStTvVwWxXyYzZ\") == \"bBcCdDfFgGhHjJkKlLmMpPqQrRsStTvVwWxXyYzZ\"\n assert candidate(s = \"bCdfGhjklmnpqrstvwxyz\") == \"bCdfGhjklmnpqrstvwxyz\"\n assert candidate(s = \"ThiSisAnExAmPlE\") == \"ThASAsEnEximPli\"\n assert candidate(s = \"HELLOworld\") == \"HELLOworld\"\n assert candidate(s = \"VowelsVowelsVowels\") == \"VewelsVewolsVowols\"\n assert candidate(s = \"fEaIoUeIaO\") == \"fEIIOUaaeo\"\n assert candidate(s = \"vOwElsInThEmIdDlE\") == \"vEwElsEnThImIdDlO\"\n assert candidate(s = \"uUoOiIeEaAA\") == \"AAEIOUaeiou\"\n assert candidate(s = \"ThiSisAEeIoU\") == \"ThASEsIUeiio\"\n assert candidate(s = \"VoWeLs12345\") == \"VeWoLs12345\"\n assert candidate(s = \"sTrInGwItHvErYsMaLlVoWels\") == \"sTrEnGwItHvIrYsMaLlVeWols\"\n assert candidate(s = \"cOnSoN4nt55tR1nGw1th1NoVoW3ls\") == \"cOnSoN4nt55tR1nGw1th1NoVoW3ls\"\n assert candidate(s = \"ThIsIsAVeRyLoNgStRiNgThAtCoNTaInSaLlThEvOwElScInDiFfErEnTcAsEs\") == \"ThAsAsAVERyLENgStRENgThEtCENTIInSILlThIvOwalScanDeFfirinTcosos\"\n assert candidate(s = \"uoieaUOIEA\") == \"AEIOUaeiou\"\n assert candidate(s = \"pythonProgramming\") == \"pythanPrigrommong\"\n assert candidate(s = \"vowelVowelVowel\") == \"vewelVewolVowol\"\n assert candidate(s = \"Vowels\") == \"Vewols\"\n assert candidate(s = \"Th1s1s4t3stW1thS0m3N0Nv0w3ls\") == \"Th1s1s4t3stW1thS0m3N0Nv0w3ls\"\n assert candidate(s = \"aAaAaAaAaAaA\") == \"AAAAAAaaaaaa\"\n assert candidate(s = \"MixedCASEaeiou\") == \"MAxEdCaSeeiiou\"\n assert candidate(s = \"vOwElsShOuLdBeSoRtEd\") == \"vEwElsShOOLdBeSoRtud\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"AAAAAAAAAAAAAaaaaaaaaaaaaa\"\n assert candidate(s = \"VoWaElScOlE\") == \"VEWEOlScalo\"\n assert candidate(s = \"bcdfghjklmnpqrstvwxyzAEIOU\") == \"bcdfghjklmnpqrstvwxyzAEIOU\"\n assert candidate(s = \"eEeEoOiIuUaAA\") == \"AAEEIOUaeeiou\"\n assert candidate(s = \"mEaTbAlL\") == \"mAETbalL\"\n assert candidate(s = \"uUoOiIaAeE\") == \"AEIOUaeiou\"\n assert candidate(s = \"UPPERCASEAEIOU\") == \"APPARCESEEIOUU\"\n assert candidate(s = \"ZyXwVuTsRqPoNmLkJiHgFeDcBa\") == \"ZyXwVaTsRqPeNmLkJiHgFoDcBu\"\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == \"QwArTyEOUpisDfGhJkLzXcVbNm\"\n assert candidate(s = \"bAnAnA\") == \"bAnAnA\"\n assert candidate(s = \"vOwElScOnSoNnTsWiThMiXeDcAsE\") == \"vAwElScEnSONnTsWOThMeXiDciso\"\n assert candidate(s = \"ThEQUICKBRoWNfOxJUmpEDoVERtHElAZYdOG\") == \"ThAQEECKBREWNfExJImpODOVURtHUloZYdoG\"\n assert candidate(s = \"AEIOUaeiouAEIOUaeiou\") == \"AAEEIIOOUUaaeeiioouu\"\n assert candidate(s = \"CoMpLeXsTrInGwItHoUtvOwElS\") == \"CEMpLIXsTrInGwOtHUetvowolS\"\n assert candidate(s = \"aeiouAEIOUbcdfghjklmnpqrstvwxyz\") == \"AEIOUaeioubcdfghjklmnpqrstvwxyz\"\n assert candidate(s = \"Mississippi\") == \"Mississippi\"\n assert candidate(s = \"qwertyUIOP\") == \"qwIrtyOUeP\"\n assert candidate(s = \"MixedWithVowelsAndConsonants\") == \"MAxadWethVewilsindConsononts\"\n assert candidate(s = \"Th1s1s1a1n1Ex1Am1Pl1E\") == \"Th1s1s1A1n1Ex1Em1Pl1a\"\n assert candidate(s = \"hApPy\") == \"hApPy\"\n assert candidate(s = \"bBbBbBbBbBbB\") == \"bBbBbBbBbBbB\"\n assert candidate(s = \"UoIeA\") == \"AIUeo\"\n assert candidate(s = \"fLkDjGhtY\") == \"fLkDjGhtY\"\n assert candidate(s = \"mIxEdVoWElScAsE\") == \"mAxEdVEWElScIso\"\n assert candidate(s = \"iIiIiIiIiIiIiIiIiIiIiIiIiIiI\") == \"IIIIIIIIIIIIIIiiiiiiiiiiiiii\"\n assert candidate(s = \"aAAAAAeiouuuuuuuuuuuuu\") == \"AAAAAaeiouuuuuuuuuuuuu\"\n assert candidate(s = \"vowelsAndConsonants\") == \"vAwalsendConsononts\"\n assert candidate(s = \"AeIoUxyZ\") == \"AIUeoxyZ\"\n assert candidate(s = \"mIxEdCaSe\") == \"mExIdCaSe\"\n assert candidate(s = \"Lowercaseaeiou\") == \"Lawarceseeioou\"\n assert candidate(s = \"Alphabetical\") == \"Alphabatecil\"\n assert candidate(s = \"tHeQuIcKBrOwNBrownFoxJumpsOverLaZyDog\") == \"tHIQOOcKBrawNBrewnFexJompsovorLuZyDug\"\n assert candidate(s = \"ThIsIsAVeRyLoNgStRiNgWitHaLoTofVoWels\") == \"ThAsIsIVaRyLeNgStReNgWitHiLoTofVoWols\"\n assert candidate(s = \"vowel\") == \"vewol\"\n assert candidate(s = \"aAeE\") == \"AEae\"\n assert candidate(s = \"AeIoUaEiOuAEIOUaeiouAEIOU\") == \"AAAEEEIIIOOOUUUaaeeiioouu\"\n assert candidate(s = \"tRiUmPh\") == \"tRUimPh\"\n assert candidate(s = \"sTrInGwItHmUlTiPlEvOwEl\") == \"sTrEnGwEtHmIlTIPlOvUwil\"\n assert candidate(s = \"dFdFdFdFdFdFdFdFdfDFDF\") == \"dFdFdFdFdFdFdFdFdfDFDF\"\n assert candidate(s = \"VowElScOdInG\") == \"VEwIlScOdonG\"\n assert candidate(s = \"aAeEiIoOuUaAeEiIoOuU\") == \"AAEEIIOOUUaaeeiioouu\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDaFgHeJkLmNePqRsTiVwXyZiBcDoFgHoJkLmNuPqRsTuVwXyZ\"\n assert candidate(s = \"auDiEnCe\") == \"EaDeinCu\"\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\") == \"bcdfghjklmnpqrstvwxyz\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaA\") == \"AAAAAAAAAAAAaaaaaaaaaaaa\"\n assert candidate(s = \"ProgrammingIsFun\") == \"PrIgrammingosFun\"\n assert candidate(s = \"MultipleVowels\") == \"MeltepliVowuls\"\n assert candidate(s = \"aAAAAAAAAAAAAAAAAAAAAAAAAAAAAa\") == \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAaa\"\n assert candidate(s = \"aEiOuAeIoU\") == \"AEIOUaeiou\"\n assert candidate(s = \"ThIsIsAComPlExStRiNgWitHvArIoUsVoWElS\") == \"ThAsAsECEmPlIxStRINgWItHvUriiosVoWolS\"\n assert candidate(s = \"sOrTiNg\") == \"sOrTiNg\"\n assert candidate(s = \"aEiOuBCDFG\") == \"EOaiuBCDFG\"\n assert candidate(s = \"oOoOoOoOoOoOoOoOoOoOoOoOoOoO\") == \"OOOOOOOOOOOOOOoooooooooooooo\"\n assert candidate(s = \"lowercase\") == \"lawerceso\"\n assert candidate(s = \"consonantsConsonantsVowelsVowels\") == \"cansanentsCensonontsVowolsVowols\"\n assert candidate(s = \"aEiOuAeIouAeIouAeIouAeIou\") == \"AAAAEIIIIOaeeeeioooouuuuu\"\n assert candidate(s = \"bbbbbbbbbbbbbbbbbAEIOU\") == \"bbbbbbbbbbbbbbbbbAEIOU\"\n assert candidate(s = \"abcdefgABCDEFGhijklmHIJKLmnopqrNOPQRSTuvwxyzUVWXYS\") == \"AbcdEfgIBCDOFGhUjklmHaJKLmnepqrNiPQRSTovwxyzuVWXYS\"\n assert candidate(s = \"vErYlArGeInPuTStRiNgWiThMaNyVoWels\") == \"vArYlErGIanPeTStReNgWiThMiNyVoWuls\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvatsrqpenmlkjihgfodcbu\"\n assert candidate(s = \"vowelVOWELvowelVOWEL\") == \"vEwElVOWOLvewelVoWoL\"\n assert candidate(s = \"bCdfGhJklMnpQrStVwXz\") == \"bCdfGhJklMnpQrStVwXz\"\n assert candidate(s = \"cOdInGqUeStIoN\") == \"cIdInGqOUSteoN\"\n assert candidate(s = \"ThIsIsAtEsT\") == \"ThAsEsItIsT\"\n assert candidate(s = \"pRoGrAmMiNg\") == \"pRAGrimMoNg\"\n assert candidate(s = \"Th1sStR1nGh4sN0Nv0w3l5\") == \"Th1sStR1nGh4sN0Nv0w3l5\"\n assert candidate(s = \"AaEeIiOoUuAaEeIiOoUu\") == \"AAEEIIOOUUaaeeiioouu\"\n assert candidate(s = \"mIxEdVoWelsInThEString\") == \"mExEdVIWIlsenThiStrong\"\n assert candidate(s = \"aBCdEFGhIJKLmNoPQrSTuVwXyZ\") == \"EBCdIFGhaJKLmNoPQrSTuVwXyZ\"\n assert candidate(s = \"aAAAAA\") == \"AAAAAa\"\n assert candidate(s = \"VowelsAndConsonants\") == \"VAwalsendConsononts\"\n assert candidate(s = \"UniqueVowels\") == \"UneqeiVowuls\"\n assert candidate(s = \"joyFul\") == \"joyFul\"\n assert candidate(s = \"vOwElMvOwElMvOwElMvOwElM\") == \"vEwElMvEwElMvOwOlMvOwOlM\"\n assert candidate(s = \"VowelsMixed\") == \"VewelsMixod\"\n assert candidate(s = \"vOwElS98765\") == \"vEwOlS98765\"\n assert candidate(s = \"UeOiAaUeOiAaUeOiAaUeOiAa\") == \"AAAAOOOOUUUUaaaaeeeeiiii\"\n assert candidate(s = \"cOdInG\") == \"cIdOnG\"\n assert candidate(s = \"eEeEeEeEeEeEeEeEeEeEeEeEeE\") == \"EEEEEEEEEEEEEeeeeeeeeeeeee\"\n assert candidate(s = \"bBbBbBbBbBbBbBbBbBbBbBbB\") == \"bBbBbBbBbBbBbBbBbBbBbBbB\"\n assert candidate(s = \"fghijklmno\") == \"fghijklmno\"\n assert candidate(s = \"AEIOUzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"AEIOUzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"VoWeLiInInG\") == \"VIWILeinonG\"\n assert candidate(s = \"MiXeDcAsEaeiouAEIOU\") == \"MAXADcEsEIOUaeeiiou\"\n assert candidate(s = \"QWERTYUIOPASDFGHJKLZXCVBNM\") == \"QWARTYEIOPUSDFGHJKLZXCVBNM\"\n assert candidate(s = \"zXcVbNMA\") == \"zXcVbNMA\"\n assert candidate(s = \"ConsonantsWithVowels\") == \"CansenintsWothVowols\"\n assert candidate(s = \"aAeEiIoOuUaAeEiIoOuUaAeEiIoOuU\") == \"AAAEEEIIIOOOUUUaaaeeeiiiooouuu\"\n assert candidate(s = \"aAbBcCdDeEfFgGiImMoOnNpPrRsStTuUvVwWxXyYzZ\") == \"AEbBcCdDIOfFgGUamMeinNpPrRsStTouvVwWxXyYzZ\"\n assert candidate(s = \"uUUUUU\") == \"UUUUUu\"\n assert candidate(s = \"aEiOuaEiOuaEiOuaEiOu\") == \"EEEEOOOOaaaaiiiiuuuu\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"sOrtThEvOwElS\") == \"sErtThEvOwOlS\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().sortVowels", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String sortVowels(String s) {", "container": "Solution", "callable": "sortVowels", "parameters": [{"name": "s", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2786, "task_id": "visit-array-positions-to-maximize-score", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and a positive integer x.\nYou are initially at position 0 in the array and you can visit other positions according to the following rules:\n\nIf you are currently in position i, then you can move to any position j such that i < j.\nFor each position i that you visit, you get a score of nums[i].\nIf you move from a position i to a position j and the parities of nums[i] and nums[j] differ, then you lose a score of x.\n\nReturn the maximum total score you can get.\nNote that initially you have nums[0] points.\n \nExample 1:\n\nInput: nums = [2,3,6,1,9,2], x = 5\nOutput: 13\nExplanation: We can visit the following positions in the array: 0 -> 2 -> 3 -> 4.\nThe corresponding values are 2, 6, 1 and 9. Since the integers 6 and 1 have different parities, the move 2 -> 3 will make you lose a score of x = 5.\nThe total score will be: 2 + 6 + 1 + 9 - 5 = 13.\n\nExample 2:\n\nInput: nums = [2,4,6,8], x = 3\nOutput: 20\nExplanation: All the integers in the array have the same parities, so we can visit all of them without losing any score.\nThe total score is: 2 + 4 + 6 + 8 = 20.\n\n \nConstraints:\n\n2 <= nums.length <= 105\n1 <= nums[i], x <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],x = 1) == 11\n assert candidate(nums = [10, 13, 15, 17, 19],x = 10) == 64\n assert candidate(nums = [1, 2, 3, 4, 5, 6],x = 2) == 13\n assert candidate(nums = [10, 13, 14, 15, 19],x = 10) == 48\n assert candidate(nums = [5, 3, 2, 4, 6, 7, 8, 9],x = 4) == 29\n assert candidate(nums = [5, 5, 5, 5, 5, 5],x = 1) == 30\n assert candidate(nums = [10, 15, 20, 25, 30],x = 10) == 65\n assert candidate(nums = [1, 2, 3, 4, 5],x = 2) == 9\n assert candidate(nums = [7, 8, 9, 10, 11, 12],x = 7) == 32\n assert candidate(nums = [10, 15, 20, 25, 30],x = 7) == 72\n assert candidate(nums = [2, 3, 6, 1, 9, 2],x = 5) == 13\n assert candidate(nums = [7, 11, 13, 14, 15],x = 3) == 54\n assert candidate(nums = [1, 1, 1, 1, 1],x = 10) == 5\n assert candidate(nums = [5, 3, 8, 9, 2, 4],x = 6) == 17\n assert candidate(nums = [2, 4, 6, 8],x = 3) == 20\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],x = 2) == 420\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],x = 3) == 420\n assert candidate(nums = [100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009],x = 50000) == 550045\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 150) == 5500\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],x = 3) == 240\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9],x = 3) == 73\n assert candidate(nums = [1, 3, 2, 8, 7, 4, 6, 9, 5, 10],x = 6) == 30\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],x = 5) == 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],x = 7) == 119\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],x = 10) == 520\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],x = 30) == 239\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 1) == 191\n assert candidate(nums = [12, 17, 18, 13, 20, 21, 16, 19, 14, 15],x = 8) == 98\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],x = 10) == 420\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],x = 2) == 409\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],x = 7) == 632\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],x = 15) == 240\n assert candidate(nums = [10, 30, 20, 40, 50, 70, 60, 90, 80, 100, 120, 110, 140, 130, 160, 150, 180, 170, 200, 190],x = 20) == 2100\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],x = 5) == 124\n assert candidate(nums = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11],x = 2) == 54\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994],x = 100000) == 6399979\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],x = 20) == 109\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 2) == 39\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],x = 10) == 400\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995],x = 1000) == 5994985\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],x = 2) == 10\n assert candidate(nums = [1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006, 1000007, 1000008, 1000009],x = 100000) == 9100045\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 2) == 100\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],x = 500000) == 5499975\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 1) == 46\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],x = 15) == 2100\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 100) == 11\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],x = 10) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 1) == 10\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],x = 500000) == 5499969\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],x = 2) == 256\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 100) == 5500\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],x = 100000) == 1980468\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 1000001, 1000010, 1000100, 1001000, 1010000, 1100000],x = 1000000) == 5222221\n assert candidate(nums = [500000, 499999, 499998, 499997, 499996, 499995, 499994, 499993, 499992, 499991, 499990, 499989, 499988, 499987, 499986, 499985, 499984, 499983, 499982, 499981],x = 100000) == 8099810\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],x = 100000) == 9099945\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 3) == 159\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],x = 20) == 308\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],x = 5) == 240\n assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62],x = 7) == 543\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 2) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 2) == 39\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],x = 25) == 675\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],x = 500000) == 2999994\n assert candidate(nums = [2, 3, 6, 1, 9, 2, 4, 8, 5, 7, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],x = 5) == 424\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],x = 5) == 400\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 10) == 50\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],x = 5) == 225\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],x = 1) == 74\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 1) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],x = 1) == 225\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],x = 1) == 30\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],x = 1) == 101\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 3) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],x = 15) == 660\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400],x = 50) == 2200\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],x = 1) == 101\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 15) == 30\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 1) == 20\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],x = 1000000) == 10000000\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],x = 2) == 110\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],x = 3) == 98\n assert candidate(nums = [1000000, 999999, 1000000, 999999, 1000000, 999999],x = 1000000) == 3000000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 10\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],x = 100) == 923\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22],x = 1) == 132\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],x = 5) == 110\n assert candidate(nums = [4, 2, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],x = 5) == 240\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],x = 1000) == 9990955\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 10) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 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, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 1) == 150\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 10) == 100\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],x = 1000) == 9990945\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 2) == 31\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],x = 10) == 629\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995],x = 500000) == 3499991\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],x = 5) == 144\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],x = 3) == 625\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],x = 5) == 73\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],x = 500) == 12000\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 7, 9, 8, 10, 11, 13, 12, 14, 15, 17, 16, 18, 19, 20],x = 20) == 115\n assert candidate(nums = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],x = 15) == 158\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],x = 25) == 2100\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 3) == 18\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987],x = 100000) == 12711020\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],x = 5) == 780\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],x = 10) == 225\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23],x = 10) == 90\n"}, "metadata": {"canonical_parameter_names": ["nums", "x"], "leetcode_dataset_entry_point": "Solution().maxScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxScore(int[] nums, int x) {", "container": "Solution", "callable": "maxScore", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "x", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2787, "task_id": "ways-to-express-an-integer-as-sum-of-powers", "difficulty": "Medium", "problem_description": "Given two positive integers n and x.\nReturn the number of ways n can be expressed as the sum of the xth power of unique positive integers, in other words, the number of sets of unique integers [n1, n2, ..., nk] where n = n1x + n2x + ... + nkx.\nSince the result can be very large, return it modulo 109 + 7.\nFor example, if n = 160 and x = 3, one way to express n is n = 23 + 33 + 53.\n \nExample 1:\n\nInput: n = 10, x = 2\nOutput: 1\nExplanation: We can express n as the following: n = 32 + 12 = 10.\nIt can be shown that it is the only way to express 10 as the sum of the 2nd power of unique integers.\n\nExample 2:\n\nInput: n = 4, x = 1\nOutput: 2\nExplanation: We can express n in the following ways:\n- n = 41 = 4.\n- n = 31 + 11 = 4.\n\n \nConstraints:\n\n1 <= n <= 300\n1 <= x <= 5\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 100,x = 4) == 0\n assert candidate(n = 50,x = 2) == 3\n assert candidate(n = 200,x = 2) == 9\n assert candidate(n = 300,x = 5) == 0\n assert candidate(n = 160,x = 3) == 1\n assert candidate(n = 4,x = 1) == 2\n assert candidate(n = 10,x = 2) == 1\n assert candidate(n = 20,x = 2) == 1\n assert candidate(n = 200,x = 5) == 0\n assert candidate(n = 144,x = 2) == 2\n assert candidate(n = 225,x = 4) == 0\n assert candidate(n = 180,x = 5) == 0\n assert candidate(n = 125,x = 2) == 5\n assert candidate(n = 80,x = 3) == 0\n assert candidate(n = 190,x = 5) == 0\n assert candidate(n = 300,x = 3) == 0\n assert candidate(n = 199,x = 4) == 0\n assert candidate(n = 243,x = 5) == 1\n assert candidate(n = 210,x = 5) == 0\n assert candidate(n = 290,x = 5) == 0\n assert candidate(n = 200,x = 4) == 0\n assert candidate(n = 120,x = 2) == 4\n assert candidate(n = 260,x = 4) == 0\n assert candidate(n = 100,x = 2) == 3\n assert candidate(n = 128,x = 2) == 0\n assert candidate(n = 160,x = 2) == 4\n assert candidate(n = 150,x = 4) == 0\n assert candidate(n = 180,x = 4) == 0\n assert candidate(n = 150,x = 2) == 9\n assert candidate(n = 299,x = 5) == 0\n assert candidate(n = 175,x = 3) == 0\n assert candidate(n = 180,x = 2) == 6\n assert candidate(n = 210,x = 2) == 18\n assert candidate(n = 220,x = 3) == 0\n assert candidate(n = 280,x = 3) == 1\n assert candidate(n = 275,x = 5) == 1\n assert candidate(n = 275,x = 4) == 0\n assert candidate(n = 300,x = 1) == 872471266\n assert candidate(n = 190,x = 2) == 14\n assert candidate(n = 140,x = 5) == 0\n assert candidate(n = 170,x = 3) == 0\n assert candidate(n = 299,x = 3) == 0\n assert candidate(n = 195,x = 2) == 16\n assert candidate(n = 275,x = 3) == 0\n assert candidate(n = 280,x = 4) == 0\n assert candidate(n = 140,x = 4) == 0\n assert candidate(n = 260,x = 5) == 0\n assert candidate(n = 196,x = 4) == 0\n assert candidate(n = 250,x = 3) == 0\n assert candidate(n = 289,x = 3) == 1\n assert candidate(n = 150,x = 3) == 0\n assert candidate(n = 200,x = 1) == 487067746\n assert candidate(n = 120,x = 3) == 0\n assert candidate(n = 100,x = 1) == 444793\n assert candidate(n = 175,x = 4) == 0\n assert candidate(n = 260,x = 2) == 19\n assert candidate(n = 180,x = 3) == 0\n assert candidate(n = 170,x = 5) == 0\n assert candidate(n = 290,x = 2) == 31\n assert candidate(n = 299,x = 2) == 33\n assert candidate(n = 256,x = 4) == 1\n assert candidate(n = 270,x = 3) == 0\n assert candidate(n = 90,x = 3) == 0\n assert candidate(n = 250,x = 4) == 0\n assert candidate(n = 17,x = 2) == 1\n assert candidate(n = 1,x = 5) == 1\n assert candidate(n = 3,x = 1) == 2\n assert candidate(n = 125,x = 3) == 1\n assert candidate(n = 2,x = 2) == 0\n assert candidate(n = 50,x = 3) == 0\n assert candidate(n = 81,x = 4) == 1\n assert candidate(n = 20,x = 4) == 0\n assert candidate(n = 17,x = 4) == 1\n assert candidate(n = 5,x = 1) == 3\n assert candidate(n = 15,x = 2) == 0\n assert candidate(n = 120,x = 4) == 0\n assert candidate(n = 100,x = 3) == 1\n assert candidate(n = 27,x = 3) == 1\n assert candidate(n = 64,x = 2) == 1\n assert candidate(n = 8,x = 3) == 1\n assert candidate(n = 31,x = 1) == 340\n assert candidate(n = 1,x = 1) == 1\n assert candidate(n = 256,x = 5) == 0\n assert candidate(n = 64,x = 3) == 1\n assert candidate(n = 25,x = 2) == 2\n assert candidate(n = 28,x = 2) == 0\n assert candidate(n = 9,x = 2) == 1\n assert candidate(n = 12,x = 2) == 0\n assert candidate(n = 250,x = 5) == 0\n assert candidate(n = 81,x = 2) == 3\n assert candidate(n = 70,x = 1) == 29927\n assert candidate(n = 50,x = 5) == 0\n assert candidate(n = 9,x = 4) == 0\n assert candidate(n = 15,x = 1) == 27\n assert candidate(n = 250,x = 2) == 21\n assert candidate(n = 30,x = 1) == 296\n"}, "metadata": {"canonical_parameter_names": ["n", "x"], "leetcode_dataset_entry_point": "Solution().numberOfWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfWays(int n, int x) {", "container": "Solution", "callable": "numberOfWays", "parameters": [{"name": "n", "type": "int"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2788, "task_id": "split-strings-by-separator", "difficulty": "Easy", "problem_description": "Given an array of strings words and a character separator, split each string in words by separator.\nReturn an array of strings containing the new strings formed after the splits, excluding empty strings.\nNotes\n\nseparator is used to determine where the split should occur, but it is not included as part of the resulting strings.\nA split may result in more than two strings.\nThe resulting strings must maintain the same order as they were initially given.\n\n \nExample 1:\n\nInput: words = [\"one.two.three\",\"four.five\",\"six\"], separator = \".\"\nOutput: [\"one\",\"two\",\"three\",\"four\",\"five\",\"six\"]\nExplanation: In this example we split as follows:\n\n\"one.two.three\" splits into \"one\", \"two\", \"three\"\n\"four.five\" splits into \"four\", \"five\"\n\"six\" splits into \"six\" \n\nHence, the resulting array is [\"one\",\"two\",\"three\",\"four\",\"five\",\"six\"].\nExample 2:\n\nInput: words = [\"$easy$\",\"$problem$\"], separator = \"$\"\nOutput: [\"easy\",\"problem\"]\nExplanation: In this example we split as follows: \n\n\"$easy$\" splits into \"easy\" (excluding empty strings)\n\"$problem$\" splits into \"problem\" (excluding empty strings)\n\nHence, the resulting array is [\"easy\",\"problem\"].\n\nExample 3:\n\nInput: words = [\"|||\"], separator = \"|\"\nOutput: []\nExplanation: In this example the resulting split of \"|||\" will contain only empty strings, so we return an empty array []. \n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 20\ncharacters in words[i] are either lowercase English letters or characters from the string \".,|$#@\" (excluding the quotes)\nseparator is a character from the string \".,|$#@\" (excluding the quotes)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['no-separator'],separator = \",\") == ['no-separator']\n assert candidate(words = ['hello.world', 'foo.bar.baz'],separator = \".\") == ['hello', 'world', 'foo', 'bar', 'baz']\n assert candidate(words = ['test|test|test'],separator = \"|\") == ['test', 'test', 'test']\n assert candidate(words = ['#a#b#', 'c#d', 'e#f#g'],separator = \"#\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n assert candidate(words = ['a,b,c', 'd,e', 'f,g,h'],separator = \",\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n assert candidate(words = ['...'],separator = \".\") == []\n assert candidate(words = ['multiple,,,commas'],separator = \",\") == ['multiple', 'commas']\n assert candidate(words = ['@a@', 'b@c@d', 'e@f@g@h'],separator = \"@\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n assert candidate(words = ['no-separator-here'],separator = \"-\") == ['no', 'separator', 'here']\n assert candidate(words = ['|a|b|c|', 'd|e|f', 'g|h|i|j'],separator = \"|\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']\n assert candidate(words = ['|a|b|c|d|'],separator = \"|\") == ['a', 'b', 'c', 'd']\n assert candidate(words = ['abc', 'def', 'ghi'],separator = \".\") == ['abc', 'def', 'ghi']\n assert candidate(words = ['hello.world', 'how.are.you'],separator = \".\") == ['hello', 'world', 'how', 'are', 'you']\n assert candidate(words = ['1.2.3', '4.5.6.7'],separator = \".\") == ['1', '2', '3', '4', '5', '6', '7']\n assert candidate(words = ['test|string|data'],separator = \"|\") == ['test', 'string', 'data']\n assert candidate(words = [',,', ',,'],separator = \",\") == []\n assert candidate(words = ['hello.world', 'example.test'],separator = \".\") == ['hello', 'world', 'example', 'test']\n assert candidate(words = ['#abc#', '#def#', '#ghi#'],separator = \"#\") == ['abc', 'def', 'ghi']\n assert candidate(words = ['hello.world', 'python.is.awesome'],separator = \".\") == ['hello', 'world', 'python', 'is', 'awesome']\n assert candidate(words = ['###', '@#@', '$#$'],separator = \"#\") == ['@', '@', '$', '$']\n assert candidate(words = ['hello.world', 'python.code'],separator = \".\") == ['hello', 'world', 'python', 'code']\n assert candidate(words = ['@hello@world', '@foo@bar@baz'],separator = \"@\") == ['hello', 'world', 'foo', 'bar', 'baz']\n assert candidate(words = ['$easy$', '$problem$'],separator = \"$\") == ['easy', 'problem']\n assert candidate(words = ['|||'],separator = \"|\") == []\n assert candidate(words = ['a,b,c', 'd,e,f', 'g,h'],separator = \",\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n assert candidate(words = ['abc', 'def', 'ghi'],separator = \",\") == ['abc', 'def', 'ghi']\n assert candidate(words = ['#a#b#c#'],separator = \"#\") == ['a', 'b', 'c']\n assert candidate(words = ['one.two.three', 'four.five', 'six'],separator = \".\") == ['one', 'two', 'three', 'four', 'five', 'six']\n assert candidate(words = ['a.b.c.d.e'],separator = \".\") == ['a', 'b', 'c', 'd', 'e']\n assert candidate(words = ['a.b.c', 'd.e', 'f'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f']\n assert candidate(words = ['same|same|same', 'different|path|here'],separator = \"|\") == ['same', 'same', 'same', 'different', 'path', 'here']\n assert candidate(words = ['special,characters|.,|$#@|example'],separator = \"|\") == ['special,characters', '.,', '$#@', 'example']\n assert candidate(words = ['.,.', '.a.b.', '.c.d.e.'],separator = \".\") == [',', 'a', 'b', 'c', 'd', 'e']\n assert candidate(words = ['hello|world|foo|bar', 'baz|qux|quux', 'corge|grault|garply'],separator = \"|\") == ['hello', 'world', 'foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply']\n assert candidate(words = ['this$that', 'and', 'the$other', 'thing'],separator = \"$\") == ['this', 'that', 'and', 'the', 'other', 'thing']\n assert candidate(words = ['.a.b.c.', '.d.e.', '.f.g.h.'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n assert candidate(words = ['a.b.c.d.e', 'f.g', 'h', 'i..j', 'k..l..m'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm']\n assert candidate(words = ['a.b.c.d', 'e.f.g', 'h.i'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']\n assert candidate(words = ['complex..string', 'string..with..multiple..dots', 'empty..'],separator = \".\") == ['complex', 'string', 'string', 'with', 'multiple', 'dots', 'empty']\n assert candidate(words = ['##word1##', '##word2##word3##', 'word4##word5##'],separator = \"#\") == ['word1', 'word2', 'word3', 'word4', 'word5']\n assert candidate(words = ['1,2,3', '4,,5', ',6,'],separator = \",\") == ['1', '2', '3', '4', '5', '6']\n assert candidate(words = ['start|end', 'middle|middle|middle', 'no|change'],separator = \"|\") == ['start', 'end', 'middle', 'middle', 'middle', 'no', 'change']\n assert candidate(words = ['noSeparatorHere', 'neitherHere', 'orHere'],separator = \"|\") == ['noSeparatorHere', 'neitherHere', 'orHere']\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'],separator = \"|\") == ['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(words = ['|||', '||||', '|||||'],separator = \"|\") == []\n assert candidate(words = ['nested..dots.and||pipes', 'and#hashes', 'mixed##..|||characters'],separator = \".\") == ['nested', 'dots', 'and||pipes', 'and#hashes', 'mixed##', '|||characters']\n assert candidate(words = ['nested|split|.|string|example'],separator = \"|\") == ['nested', 'split', '.', 'string', 'example']\n assert candidate(words = ['|a||b||c|', '|d||e|', 'f|||g'],separator = \"|\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n assert candidate(words = ['a|b|c', 'd.e.f', 'g#h#i'],separator = \"|\") == ['a', 'b', 'c', 'd.e.f', 'g#h#i']\n assert candidate(words = ['abc#def#ghi#jkl', 'mno#pqr', 'stu#vw'],separator = \"#\") == ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vw']\n assert candidate(words = ['a|b|c|d|e', 'f|g|h|i', 'j|k|l|m|n|o'],separator = \"|\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']\n assert candidate(words = ['@start@middle@end', '@multiple@parts@here', '@only@one'],separator = \"@\") == ['start', 'middle', 'end', 'multiple', 'parts', 'here', 'only', 'one']\n assert candidate(words = ['abc...def...ghi', 'jkl...mno', 'pqr...stu...vwx...yz'],separator = \"...\") == ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']\n assert candidate(words = ['one..two...three', 'four....five', 'six......'],separator = \".\") == ['one', 'two', 'three', 'four', 'five', 'six']\n assert candidate(words = ['abc.def.ghi', 'jklmno.pqr.stu', 'vwxyz.123.456'],separator = \".\") == ['abc', 'def', 'ghi', 'jklmno', 'pqr', 'stu', 'vwxyz', '123', '456']\n assert candidate(words = ['a.b.c.d.e.f.g'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n assert candidate(words = ['hello###world', '###foo###bar', 'baz###'],separator = \"###\") == ['hello', 'world', 'foo', 'bar', 'baz']\n assert candidate(words = ['###abc###', 'def###ghi', '###jkl###'],separator = \"#\") == ['abc', 'def', 'ghi', 'jkl']\n assert candidate(words = ['|a||b|c|', '|d|e||f|', 'g|h|i||j'],separator = \"|\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']\n assert candidate(words = ['no|separator', 'only|one|separator', 'two|separators|here'],separator = \"|\") == ['no', 'separator', 'only', 'one', 'separator', 'two', 'separators', 'here']\n assert candidate(words = ['test$test$test', '$test$test', 'test$$test'],separator = \"$\") == ['test', 'test', 'test', 'test', 'test', 'test', 'test']\n assert candidate(words = ['nested|separators|are|here', 'nested|separators|again'],separator = \"|\") == ['nested', 'separators', 'are', 'here', 'nested', 'separators', 'again']\n assert candidate(words = ['noSeparatorHere', 'norHere', 'stillNotHere'],separator = \".\") == ['noSeparatorHere', 'norHere', 'stillNotHere']\n assert candidate(words = ['||||', '...', '####'],separator = \"|\") == ['...', '####']\n assert candidate(words = ['one$two$three', 'four$five', '$six$'],separator = \"$\") == ['one', 'two', 'three', 'four', 'five', 'six']\n assert candidate(words = ['hello|world|python|programming'],separator = \"|\") == ['hello', 'world', 'python', 'programming']\n assert candidate(words = ['abc@def@ghi', 'jkl@@mno@pqr', 'stu@vwx@@yz'],separator = \"@\") == ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']\n assert candidate(words = ['word1@word2', 'word3', 'word4@word5@word6'],separator = \"@\") == ['word1', 'word2', 'word3', 'word4', 'word5', 'word6']\n assert candidate(words = ['example.com', 'user@example.co.uk'],separator = \".\") == ['example', 'com', 'user@example', 'co', 'uk']\n assert candidate(words = ['abc', 'def', 'ghi'],separator = \"z\") == ['abc', 'def', 'ghi']\n assert candidate(words = ['@@@@', '####', '&&&&'],separator = \"@\") == ['####', '&&&&']\n assert candidate(words = ['a.b.c.d.e', 'f.g', 'h'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n assert candidate(words = ['@#$|%|^&*', '!@#$%^&*()', '|{}[]<>:'],separator = \"$\") == ['@#', '|%|^&*', '!@#', '%^&*()', '|{}[]<>:']\n assert candidate(words = ['startmiddleend', 'doubletriplequadruple'],separator = \"#\") == ['startmiddleend', 'doubletriplequadruple']\n assert candidate(words = ['hello###world', 'foo###bar', 'baz###qux'],separator = \"###\") == ['hello', 'world', 'foo', 'bar', 'baz', 'qux']\n assert candidate(words = ['hello.world$,another.world', 'yet.another.world', 'one.more.world'],separator = \"$\") == ['hello.world', ',another.world', 'yet.another.world', 'one.more.world']\n assert candidate(words = ['a,b,c,d,e', 'f,g,h,i,j', 'k,l,m,n,o'],separator = \",\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']\n assert candidate(words = ['||a||b||c||', '|||', 'd|||e'],separator = \"|\") == ['a', 'b', 'c', 'd', 'e']\n assert candidate(words = ['multiple...dots...here', 'and...here', 'and...and...and'],separator = \"...\") == ['multiple', 'dots', 'here', 'and', 'here', 'and', 'and', 'and']\n assert candidate(words = ['multiple$$$dollar$$$signs', 'another$$$test$$$case'],separator = \"$$$\") == ['multiple', 'dollar', 'signs', 'another', 'test', 'case']\n assert candidate(words = ['hello||world', 'foo|bar|baz', 'qux|||quux'],separator = \"|\") == ['hello', 'world', 'foo', 'bar', 'baz', 'qux', 'quux']\n assert candidate(words = ['word1#word2#word3', 'word4#word5', 'word6'],separator = \"#\") == ['word1', 'word2', 'word3', 'word4', 'word5', 'word6']\n assert candidate(words = ['x|y|z|w|v|u|t', 's|r|q', 'p|o|n|m'],separator = \"|\") == ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm']\n assert candidate(words = ['a.b.c.d.e', 'f.g', 'h.i.j'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']\n assert candidate(words = ['|||', '|a|b|c|', 'd|e|f|'],separator = \"|\") == ['a', 'b', 'c', 'd', 'e', 'f']\n assert candidate(words = ['###', '@#@'],separator = \"#\") == ['@', '@']\n assert candidate(words = ['......', '$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.|$.'],separator = \"$\") == ['......', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.|', '.']\n assert candidate(words = ['start.with.dot.', '.end.with.dot', '.both.ends.'],separator = \".\") == ['start', 'with', 'dot', 'end', 'with', 'dot', 'both', 'ends']\n assert candidate(words = ['nested|path|to|file', 'another|path|with|multiple|segments'],separator = \"|\") == ['nested', 'path', 'to', 'file', 'another', 'path', 'with', 'multiple', 'segments']\n assert candidate(words = ['..', '$.$', '#@#@'],separator = \".\") == ['$', '$', '#@#@']\n assert candidate(words = [',,a,,b,,c,,', ',,,', 'd,,,e'],separator = \",\") == ['a', 'b', 'c', 'd', 'e']\n assert candidate(words = ['a.b.c.d.e', 'f.g.h', 'i.j'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']\n assert candidate(words = ['#start#middle#end', '##double##triple###', '###quadruple####'],separator = \"#\") == ['start', 'middle', 'end', 'double', 'triple', 'quadruple']\n assert candidate(words = ['###abc###', '###def###ghi###', '###'],separator = \"#\") == ['abc', 'def', 'ghi']\n assert candidate(words = ['multiple$$$separators', 'here$$$again$$$and$$$again'],separator = \"$\") == ['multiple', 'separators', 'here', 'again', 'and', 'again']\n assert candidate(words = ['noSeparator', 'alsoNoSeparatorHere'],separator = \"$\") == ['noSeparator', 'alsoNoSeparatorHere']\n assert candidate(words = ['abc#def#ghi', 'jkl|mno|pqr', 'stu,vwx,yz'],separator = \"#\") == ['abc', 'def', 'ghi', 'jkl|mno|pqr', 'stu,vwx,yz']\n assert candidate(words = [',,comma,,', 'separated,,values', ',,'],separator = \",\") == ['comma', 'separated', 'values']\n assert candidate(words = ['leading|trailing|', '|trailing|only', 'only|leading|'],separator = \"|\") == ['leading', 'trailing', 'trailing', 'only', 'only', 'leading']\n assert candidate(words = ['no|separators', 'here', 'either'],separator = \"|\") == ['no', 'separators', 'here', 'either']\n assert candidate(words = ['a@b@c@d', 'e@f@g', 'h@i@j@k@l'],separator = \"@\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l']\n assert candidate(words = ['1234567890', '', '0987654321'],separator = \"5\") == ['1234', '67890', '09876', '4321']\n assert candidate(words = ['x|y|z|w|v|u', 't|s|r|q', 'p|o|n|m|l|k|j|i|h|g|f|e|d|c|b|a'],separator = \"|\") == ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a']\n assert candidate(words = ['###', '@@@', '$$$'],separator = \"#\") == ['@@@', '$$$']\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|', '|'],separator = \"|\") == ['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(words = ['|a||b||c|', 'd||e|f||', '|g|h|i|'],separator = \"|\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']\n assert candidate(words = ['nested.delimiters|inside|string', 'another|one|here'],separator = \"|\") == ['nested.delimiters', 'inside', 'string', 'another', 'one', 'here']\n assert candidate(words = ['....', '|||', '@@@'],separator = \".\") == ['|||', '@@@']\n assert candidate(words = ['$first$$second$$third', 'fourth$$$$fifth', 'sixth$$$$'],separator = \"$\") == ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']\n assert candidate(words = ['a.b.c.d.e', 'f.g', 'h'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n assert candidate(words = ['@start', 'end@', '@both@'],separator = \"@\") == ['start', 'end', 'both']\n assert candidate(words = ['###', '#foo#bar#', '###baz##'],separator = \"#\") == ['foo', 'bar', 'baz']\n assert candidate(words = ['repeated..dots', 'triple|||pipes', 'quadruple@@@@at'],separator = \".\") == ['repeated', 'dots', 'triple|||pipes', 'quadruple@@@@at']\n assert candidate(words = ['a@b@c@d', 'e@f', 'g@h@i@j@k'],separator = \"@\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']\n assert candidate(words = ['multiple.separators.in.one.string', 'another|string|with|separators'],separator = \".\") == ['multiple', 'separators', 'in', 'one', 'string', 'another|string|with|separators']\n assert candidate(words = ['complex@punctuation@marks', '@leading@', '@trailing@', '@@multiple@@@'],separator = \"@\") == ['complex', 'punctuation', 'marks', 'leading', 'trailing', 'multiple']\n assert candidate(words = ['a.b.c.d', 'e.f', 'g.h.i.j.k'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']\n assert candidate(words = ['end.with.dot.', '.start.with.dot', '.middle.dot.'],separator = \".\") == ['end', 'with', 'dot', 'start', 'with', 'dot', 'middle', 'dot']\n assert candidate(words = ['x##y##z', '##', 'w####v'],separator = \"#\") == ['x', 'y', 'z', 'w', 'v']\n assert candidate(words = ['|||abc|||', 'def|||ghi|||', '|||jkl|||mno|||'],separator = \"|\") == ['abc', 'def', 'ghi', 'jkl', 'mno']\n assert candidate(words = ['word', 'anotherword', 'yetanotherword'],separator = \"x\") == ['word', 'anotherword', 'yetanotherword']\n assert candidate(words = ['........', '...', '.'],separator = \".\") == []\n assert candidate(words = ['#example#test#case', '##', 'no#separator'],separator = \"#\") == ['example', 'test', 'case', 'no', 'separator']\n assert candidate(words = ['........'],separator = \".\") == []\n assert candidate(words = ['apple,banana,cherry', 'date,elderberry', 'fig,grape'],separator = \",\") == ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape']\n assert candidate(words = ['..', '...', '....'],separator = \".\") == []\n assert candidate(words = ['|||||||'],separator = \"|\") == []\n assert candidate(words = ['abc.def.ghi', 'jkl..mno', 'pqr'],separator = \".\") == ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr']\n assert candidate(words = ['nested#(separators)#inside#strings', '#multiple##hashes##here', '#no#trailing#hash'],separator = \"#\") == ['nested', '(separators)', 'inside', 'strings', 'multiple', 'hashes', 'here', 'no', 'trailing', 'hash']\n assert candidate(words = ['multiple...dots', 'here||||are', 'pipes', 'and###hashes'],separator = \".\") == ['multiple', 'dots', 'here||||are', 'pipes', 'and###hashes']\n assert candidate(words = ['a|b||c|||d||||e'],separator = \"|\") == ['a', 'b', 'c', 'd', 'e']\n assert candidate(words = [',,apple,,,banana,,,', 'cherry,,,', 'date,'],separator = \",\") == ['apple', 'banana', 'cherry', 'date']\n assert candidate(words = ['@start@', 'middle@', '@end'],separator = \"@\") == ['start', 'middle', 'end']\n assert candidate(words = ['#a#b#c#d', '#e##f#', 'g#h#i#'],separator = \"#\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']\n assert candidate(words = ['a.b.c.d.e', 'f.g.h', 'i.j.k.l'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l']\n assert candidate(words = ['a.b.c.d.e', 'f.g.h', 'i.j.k.l.m'],separator = \".\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm']\n assert candidate(words = ['special$characters$@#|$|@$#|', '@|#$|$#@|', '|@#$#@$|'],separator = \"|\") == ['special$characters$@#', '$', '@$#', '@', '#$', '$#@', '@#$#@$']\n assert candidate(words = ['foo$bar$baz', 'qux$quux', 'corge$grault$garply'],separator = \"$\") == ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply']\n"}, "metadata": {"canonical_parameter_names": ["words", "separator"], "leetcode_dataset_entry_point": "Solution().splitWordsBySeparator", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List splitWordsBySeparator(List words, char separator) {", "container": "Solution", "callable": "splitWordsBySeparator", "parameters": [{"name": "words", "type": "List"}, {"name": "separator", "type": "char"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2789, "task_id": "largest-element-in-an-array-after-merge-operations", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums consisting of positive integers.\nYou can do the following operation on the array any number of times:\n\nChoose an integer i such that 0 <= i < nums.length - 1 and nums[i] <= nums[i + 1]. Replace the element nums[i + 1] with nums[i] + nums[i + 1] and delete the element nums[i] from the array.\n\nReturn the value of the largest element that you can possibly obtain in the final array.\n \nExample 1:\n\nInput: nums = [2,3,7,9,3]\nOutput: 21\nExplanation: We can apply the following operations on the array:\n- Choose i = 0. The resulting array will be nums = [5,7,9,3].\n- Choose i = 1. The resulting array will be nums = [5,16,3].\n- Choose i = 0. The resulting array will be nums = [21,3].\nThe largest element in the final array is 21. It can be shown that we cannot obtain a larger element.\n\nExample 2:\n\nInput: nums = [5,3,3]\nOutput: 11\nExplanation: We can do the following operations on the array:\n- Choose i = 1. The resulting array will be nums = [5,6].\n- Choose i = 0. The resulting array will be nums = [11].\nThere is only one element in the final array, which is 11.\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 = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 30\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 1111111\n assert candidate(nums = [10, 5, 2, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [2, 3, 7, 9, 3]) == 21\n assert candidate(nums = [10, 5, 2]) == 10\n assert candidate(nums = [5, 3, 3]) == 11\n assert candidate(nums = [1, 10, 1, 10, 1]) == 22\n assert candidate(nums = [1, 1000000, 1]) == 1000001\n assert candidate(nums = [5]) == 5\n assert candidate(nums = [1000000]) == 1000000\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [10, 9, 8, 7, 6]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 256\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 20]) == 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, 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]) == 2500\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 1000000\n assert candidate(nums = [1000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 10000000\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1000\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\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\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == 511\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 100\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 75\n assert candidate(nums = [2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2]) == 20\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\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]) == 99\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4]) == 58\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 1, 1, 1]) == 200\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2046\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 60\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 111\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 65\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 206\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 45\n assert candidate(nums = [2, 2, 2, 2, 1, 1, 1, 1, 1, 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]) == 55\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\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, 10, 100, 1000, 10000, 100000, 1000000]) == 1111111\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == 11111\n assert candidate(nums = [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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 165\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 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, 5, 5]) == 188\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 275\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, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 100\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 30\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 90\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 639\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 10000000\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, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 100\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 21\n assert candidate(nums = [5, 5, 5, 5, 10, 10, 10, 10, 15, 15]) == 90\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600]) == 3300\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 42\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, 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]) == 175\n assert candidate(nums = [10, 5, 5, 10, 10, 5, 5, 10]) == 60\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]) == 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]) == 465\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999]) == 9999990\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64, 128, 128, 128, 256, 256, 256, 512, 512, 512, 1024, 1024, 1024]) == 6141\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 4000000\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == 70\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 40\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == 62\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000]) == 5000000\n assert candidate(nums = [1, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 100000\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 56\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4]) == 22\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 45\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]) == 220\n assert candidate(nums = [10, 20, 15, 25, 30, 20, 10, 5, 1, 2]) == 100\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 1000000, 1000000, 1000000]) == 4111111\n assert candidate(nums = [71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == 71\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, 3, 2, 4, 2, 3, 5, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8, 9]) == 95\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 35\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]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 39\n assert candidate(nums = [10, 5, 5, 10, 20, 5]) == 50\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 100\n assert candidate(nums = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == 75\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, 2, 2]) == 124\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 110\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 55\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]) == 53\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 504\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 265\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 110\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 2100\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 1000000\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == 111111\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 1000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\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]) == 220\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 200\n assert candidate(nums = [1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1]) == 5000004\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 39\n assert candidate(nums = [5, 15, 5, 15, 5, 15, 5, 15, 5, 15]) == 100\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 90\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1210\n assert candidate(nums = [1, 3, 3, 2, 2, 4, 4, 1, 1, 5, 5, 1, 1, 6, 6]) == 45\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxArrayValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxArrayValue(int[] nums) {", "container": "Solution", "callable": "maxArrayValue", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2790, "task_id": "maximum-number-of-groups-with-increasing-length", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array usageLimits of length n.\nYour task is to create groups using numbers from 0 to n - 1, ensuring that each number, i, is used no more than usageLimits[i] times in total across all groups. You must also satisfy the following conditions:\n\nEach group must consist of distinct numbers, meaning that no duplicate numbers are allowed within a single group.\nEach group (except the first one) must have a length strictly greater than the previous group.\n\nReturn an integer denoting the maximum number of groups you can create while satisfying these conditions.\n \nExample 1:\n\nInput: usageLimits = [1,2,5]\nOutput: 3\nExplanation: In this example, we can use 0 at most once, 1 at most twice, and 2 at most five times.\nOne way of creating the maximum number of groups while satisfying the conditions is: \nGroup 1 contains the number [2].\nGroup 2 contains the numbers [1,2].\nGroup 3 contains the numbers [0,1,2]. \nIt can be shown that the maximum number of groups is 3. \nSo, the output is 3. \nExample 2:\n\nInput: usageLimits = [2,1,2]\nOutput: 2\nExplanation: In this example, we can use 0 at most twice, 1 at most once, and 2 at most twice.\nOne way of creating the maximum number of groups while satisfying the conditions is:\nGroup 1 contains the number [0].\nGroup 2 contains the numbers [1,2].\nIt can be shown that the maximum number of groups is 2.\nSo, the output is 2. \n\nExample 3:\n\nInput: usageLimits = [1,1]\nOutput: 1\nExplanation: In this example, we can use both 0 and 1 at most once.\nOne way of creating the maximum number of groups while satisfying the conditions is:\nGroup 1 contains the number [0].\nIt can be shown that the maximum number of groups is 1.\nSo, the output is 1. \n\n \nConstraints:\n\n1 <= usageLimits.length <= 105\n1 <= usageLimits[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(usageLimits = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(usageLimits = [1000000000, 1000000000, 1000000000]) == 3\n assert candidate(usageLimits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(usageLimits = [1, 2, 5]) == 3\n assert candidate(usageLimits = [1, 2, 3, 4, 5]) == 5\n assert candidate(usageLimits = [3, 3, 3]) == 3\n assert candidate(usageLimits = [1, 1]) == 1\n assert candidate(usageLimits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(usageLimits = [1]) == 1\n assert candidate(usageLimits = [1, 1000000000, 1, 1000000000, 1]) == 4\n assert candidate(usageLimits = [3, 3, 3, 3]) == 4\n assert candidate(usageLimits = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5\n assert candidate(usageLimits = [2, 1, 2]) == 2\n assert candidate(usageLimits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 5\n assert candidate(usageLimits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 11\n assert candidate(usageLimits = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 19\n assert candidate(usageLimits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(usageLimits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 14\n assert candidate(usageLimits = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(usageLimits = [20, 1, 20, 2, 20, 3, 20, 4, 20, 5, 20, 6, 20, 7, 20, 8, 20, 9, 20, 10]) == 20\n assert candidate(usageLimits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(usageLimits = [1, 3, 6, 10, 15]) == 5\n assert candidate(usageLimits = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 20\n assert candidate(usageLimits = [5, 3, 2, 1]) == 4\n assert candidate(usageLimits = [15, 10, 6, 3, 1]) == 5\n assert candidate(usageLimits = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 10\n assert candidate(usageLimits = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(usageLimits = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(usageLimits = [30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 15\n assert candidate(usageLimits = [10, 10, 10, 10, 10]) == 5\n assert candidate(usageLimits = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(usageLimits = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 10\n assert candidate(usageLimits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(usageLimits = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(usageLimits = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(usageLimits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20]) == 6\n assert candidate(usageLimits = [100, 50, 25, 12, 6, 3, 1]) == 7\n assert candidate(usageLimits = [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]) == 20\n assert candidate(usageLimits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 7\n assert candidate(usageLimits = [5, 4, 3, 2, 1]) == 5\n assert candidate(usageLimits = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 14\n assert candidate(usageLimits = [1000000000, 1, 1000000000, 1, 1000000000, 1]) == 5\n assert candidate(usageLimits = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10\n assert candidate(usageLimits = [1, 2, 2, 3, 3, 3]) == 4\n assert candidate(usageLimits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 16\n assert candidate(usageLimits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(usageLimits = [1000000000, 1000000000, 1000000000, 1000000000]) == 4\n assert candidate(usageLimits = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(usageLimits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 4\n assert candidate(usageLimits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(usageLimits = [5, 2, 4, 1, 3]) == 5\n assert candidate(usageLimits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(usageLimits = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 10\n assert candidate(usageLimits = [5, 4, 3, 2, 1]) == 5\n assert candidate(usageLimits = [100, 50, 25, 10, 5, 1]) == 6\n assert candidate(usageLimits = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 5\n assert candidate(usageLimits = [1, 2, 3, 4, 5]) == 5\n assert candidate(usageLimits = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 10\n assert candidate(usageLimits = [20, 10, 30, 5, 15, 25, 5, 35, 40, 10, 5, 15, 20, 5, 25, 30, 5, 40, 5, 10]) == 20\n assert candidate(usageLimits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 7\n assert candidate(usageLimits = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(usageLimits = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 14\n assert candidate(usageLimits = [10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 10\n assert candidate(usageLimits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 7\n assert candidate(usageLimits = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 11\n assert candidate(usageLimits = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(usageLimits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(usageLimits = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 6\n assert candidate(usageLimits = [10, 10, 10, 10, 10, 10]) == 6\n assert candidate(usageLimits = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n"}, "metadata": {"canonical_parameter_names": ["usageLimits"], "leetcode_dataset_entry_point": "Solution().maxIncreasingGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxIncreasingGroups(List usageLimits) {", "container": "Solution", "callable": "maxIncreasingGroups", "parameters": [{"name": "usageLimits", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2791, "task_id": "count-paths-that-can-form-a-palindrome-in-a-tree", "difficulty": "Hard", "problem_description": "You are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree is represented by a 0-indexed array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1.\nYou are also given a string s of length n, where s[i] is the character assigned to the edge between i and parent[i]. s[0] can be ignored.\nReturn the number of pairs of nodes (u, v) such that u < v and the characters assigned to edges on the path from u to v can be rearranged to form a palindrome.\nA string is a palindrome when it reads the same backwards as forwards.\n \nExample 1:\n\n\nInput: parent = [-1,0,0,1,1,2], s = \"acaabc\"\nOutput: 8\nExplanation: The valid pairs are:\n- All the pairs (0,1), (0,2), (1,3), (1,4) and (2,5) result in one character which is always a palindrome.\n- The pair (2,3) result in the string \"aca\" which is a palindrome.\n- The pair (1,5) result in the string \"cac\" which is a palindrome.\n- The pair (3,5) result in the string \"acac\" which can be rearranged into the palindrome \"acca\".\n\nExample 2:\n\nInput: parent = [-1,0,0,0,0], s = \"aaaaa\"\nOutput: 10\nExplanation: Any pair of nodes (u,v) where u < v is valid.\n\n \nConstraints:\n\nn == parent.length == s.length\n1 <= n <= 105\n0 <= parent[i] <= n - 1 for all i >= 1\nparent[0] == -1\nparent represents a valid tree.\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3],s = \"abacabadaba\") == 15\n assert candidate(parent = [-1, 0, 0, 1, 1, 2],s = \"acaabc\") == 8\n assert candidate(parent = [-1, 0, 0, 0, 1, 2, 3, 4],s = \"aabbccdd\") == 10\n assert candidate(parent = [-1, 0, 0, 0, 0],s = \"aaaaa\") == 10\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5],s = \"abcdefg\") == 6\n assert candidate(parent = [-1, 0, 1, 2, 3],s = \"abcde\") == 4\n assert candidate(parent = [-1, 0, 0, 1, 2, 2, 3, 4],s = \"aabbccdd\") == 10\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],s = \"abcdefghijklmnopqrstuvwxyz\") == 20\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],s = \"aaabbbcccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmttttnnnnooooppppqqqqrrrrssssvvvvwwwwxxxyyyyzzzz\") == 296\n assert candidate(parent = [-1, 0, 1, 0, 2, 3, 1, 3, 1, 4, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 496\n assert candidate(parent = [-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, 33, 34, 35, 36, 37, 38, 39, 40],s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacab\") == 258\n assert candidate(parent = [-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, 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],s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 3851\n assert candidate(parent = [-1, 0, 0, 0, 0, 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, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14],s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacab\") == 684\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],s = \"abcdefghijabcdefghijabcdefghij\") == 29\n assert candidate(parent = [-1, 0, 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, 14],s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 65\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5],s = \"abacabadabacaba\") == 31\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],s = \"abacabadabacabadabacabadabac\") == 62\n assert candidate(parent = [-1, 0, 0, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],s = \"abcdefghijklmnopqrstuvwxyzabcdefghij\") == 20\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8],s = \"abcdefghij\") == 9\n assert candidate(parent = [-1, 0, 0, 0, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 58\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 145\n assert candidate(parent = [-1, 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, 20, 20, 21, 21, 22, 22, 23, 23],s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 52\n assert candidate(parent = [-1, 0, 0, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 28\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29],s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 30\n assert candidate(parent = [-1, 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, 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],s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 266\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 23\n assert candidate(parent = [-1, 0, 0, 0, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 36\n assert candidate(parent = [-1, 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, 20, 20],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 43\n assert candidate(parent = [-1, 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, 20, 20, 21, 21],s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 393\n assert candidate(parent = [-1, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],s = \"abcdefghijklmnopqrstuvwxyz\") == 15\n assert candidate(parent = [-1, 0, 0, 0, 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, 29, 30, 30, 30],s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 2202\n assert candidate(parent = [-1, 0, 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, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 40\n assert candidate(parent = [-1, 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, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 65\n assert candidate(parent = [-1, 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, 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],s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 2628\n assert candidate(parent = [-1, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 30\n assert candidate(parent = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4],s = \"aabbaabbcc\") == 29\n assert candidate(parent = [-1, 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, 20, 20, 21, 21, 22, 22],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 47\n assert candidate(parent = [-1, 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],s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == 41\n assert candidate(parent = [-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, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1001\n assert candidate(parent = [-1, 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, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 126\n assert candidate(parent = [-1, 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, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24],s = \"abcdefghigklmnopqrstuvwxyzabcdefghigklmnopqrstuvwxyzabcdefghigklmnopqrstuvwxyzabcdefghigklmnopqrstuvwxyz\") == 55\n assert candidate(parent = [-1, 0, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],s = \"abacabadabacabadabacab\") == 88\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 20\n assert candidate(parent = [-1, 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],s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 319\n assert candidate(parent = [-1, 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, 20, 20],s = \"abacabadabacabadabacabadabacabadabacabadabacabadaba\") == 358\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],s = \"zyxwvutsrqponmlkjihgfedcbazyxwvu\") == 20\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 0, 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],s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 99\n assert candidate(parent = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 46\n assert candidate(parent = [-1, 0, 0, 1, 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],s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 44\n"}, "metadata": {"canonical_parameter_names": ["parent", "s"], "leetcode_dataset_entry_point": "Solution().countPalindromePaths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countPalindromePaths(List parent, String s) {", "container": "Solution", "callable": "countPalindromePaths", "parameters": [{"name": "parent", "type": "List"}, {"name": "s", "type": "String"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2798, "task_id": "number-of-employees-who-met-the-target", "difficulty": "Easy", "problem_description": "There are n employees in a company, numbered from 0 to n - 1. Each employee i has worked for hours[i] hours in the company.\nThe company requires each employee to work for at least target hours.\nYou are given a 0-indexed array of non-negative integers hours of length n and a non-negative integer target.\nReturn the integer denoting the number of employees who worked at least target hours.\n \nExample 1:\n\nInput: hours = [0,1,2,3,4], target = 2\nOutput: 3\nExplanation: The company wants each employee to work for at least 2 hours.\n- Employee 0 worked for 0 hours and didn't meet the target.\n- Employee 1 worked for 1 hours and didn't meet the target.\n- Employee 2 worked for 2 hours and met the target.\n- Employee 3 worked for 3 hours and met the target.\n- Employee 4 worked for 4 hours and met the target.\nThere are 3 employees who met the target.\n\nExample 2:\n\nInput: hours = [5,1,4,2,2], target = 6\nOutput: 0\nExplanation: The company wants each employee to work for at least 6 hours.\nThere are 0 employees who met the target.\n\n \nConstraints:\n\n1 <= n == hours.length <= 50\n0 <= hours[i], target <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hours = [5, 5, 5, 5, 5],target = 5) == 5\n assert candidate(hours = [3, 4, 5, 6, 7],target = 4) == 4\n assert candidate(hours = [1, 5, 7, 9],target = 8) == 1\n assert candidate(hours = [10, 10, 10],target = 10) == 3\n assert candidate(hours = [0, 1, 2, 3, 4],target = 2) == 3\n assert candidate(hours = [10, 20, 30, 40, 50],target = 25) == 3\n assert candidate(hours = [50, 50, 50, 50, 50],target = 50) == 5\n assert candidate(hours = [1],target = 1) == 1\n assert candidate(hours = [3, 5, 7, 9, 11],target = 10) == 1\n assert candidate(hours = [1, 2, 3, 4, 5],target = 0) == 5\n assert candidate(hours = [100, 200, 300],target = 150) == 2\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5) == 6\n assert candidate(hours = [1, 1, 1, 1, 1],target = 1) == 5\n assert candidate(hours = [3, 3, 3, 3, 3],target = 3) == 5\n assert candidate(hours = [0, 0, 0, 0, 0],target = 1) == 0\n assert candidate(hours = [5, 1, 4, 2, 2],target = 6) == 0\n assert candidate(hours = [100, 200, 300, 400, 500],target = 150) == 4\n assert candidate(hours = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],target = 55000) == 5\n assert candidate(hours = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],target = 25) == 10\n assert candidate(hours = [10000, 20000, 30000, 40000, 50000],target = 30000) == 3\n assert candidate(hours = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 1) == 0\n assert candidate(hours = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],target = 45) == 6\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 150) == 6\n assert candidate(hours = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330],target = 198) == 5\n assert candidate(hours = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 5) == 10\n assert candidate(hours = [55, 55, 55, 55, 55, 55, 55, 55, 55, 55],target = 54) == 10\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 101) == 0\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],target = 25) == 13\n assert candidate(hours = [100000, 50000, 75000, 25000, 0],target = 50000) == 3\n assert candidate(hours = [0, 100000, 50000, 75000, 25000],target = 50000) == 3\n assert candidate(hours = [15, 25, 35, 45, 55],target = 35) == 3\n assert candidate(hours = [100, 200, 300, 400, 500],target = 500) == 1\n assert candidate(hours = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],target = 95) == 5\n assert candidate(hours = [50, 50, 50, 50, 50],target = 50) == 5\n assert candidate(hours = [99995, 99996, 99997, 99998, 99999, 100000],target = 99995) == 6\n assert candidate(hours = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],target = 50) == 11\n assert candidate(hours = [1, 10, 100, 1000, 10000, 100000, 0, 0, 0, 0],target = 100) == 4\n assert candidate(hours = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == 6\n assert candidate(hours = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = 25) == 8\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 0) == 10\n assert candidate(hours = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40],target = 25) == 5\n assert candidate(hours = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250],target = 100) == 7\n assert candidate(hours = [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],target = 9) == 30\n assert candidate(hours = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],target = 5) == 5\n assert candidate(hours = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],target = 100000) == 10\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, 26, 27, 28, 29, 30],target = 15) == 16\n assert candidate(hours = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 2) == 9\n assert candidate(hours = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == 5\n assert candidate(hours = [50, 40, 30, 20, 10, 0],target = 25) == 3\n assert candidate(hours = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 39) == 1\n assert candidate(hours = [10, 20, 30, 40, 50],target = 25) == 3\n assert candidate(hours = [1, 10, 100, 1000, 10000],target = 50) == 3\n assert candidate(hours = [10, 20, 30, 40, 50],target = 100) == 0\n assert candidate(hours = [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],target = 10) == 26\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 10) == 10\n assert candidate(hours = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],target = 10) == 5\n assert candidate(hours = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],target = 60) == 5\n assert candidate(hours = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],target = 25) == 20\n assert candidate(hours = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 20) == 10\n assert candidate(hours = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 1) == 0\n assert candidate(hours = [5, 15, 25, 35, 45],target = 25) == 3\n assert candidate(hours = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],target = 99995) == 5\n assert candidate(hours = [9, 9, 9, 9, 9],target = 9) == 5\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50) == 6\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],target = 30) == 15\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == 1\n assert candidate(hours = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1000) == 1\n assert candidate(hours = [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],target = 8) == 18\n assert candidate(hours = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],target = 5) == 6\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, 50],target = 25) == 14\n assert candidate(hours = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],target = 50000) == 6\n assert candidate(hours = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40],target = 10) == 9\n assert candidate(hours = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60],target = 25) == 8\n assert candidate(hours = [50, 40, 30, 20, 10],target = 25) == 3\n assert candidate(hours = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = 40) == 6\n assert candidate(hours = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250],target = 125) == 6\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, 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],target = 25) == 26\n assert candidate(hours = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 25) == 6\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5) == 6\n assert candidate(hours = [100000, 99999, 99998, 99997, 99996],target = 100000) == 1\n assert candidate(hours = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 500) == 6\n assert candidate(hours = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],target = 9) == 1\n assert candidate(hours = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],target = 5) == 6\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 99) == 1\n assert candidate(hours = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 3) == 6\n assert candidate(hours = [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],target = 2) == 16\n assert candidate(hours = [100000, 99999, 100000, 100000, 99999],target = 100000) == 3\n assert candidate(hours = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],target = 3) == 10\n assert candidate(hours = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1) == 10\n assert candidate(hours = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10) == 1\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 10) == 11\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],target = 20) == 15\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 105) == 0\n assert candidate(hours = [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, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],target = 99) == 52\n assert candidate(hours = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5) == 39\n assert candidate(hours = [0, 0, 0, 0, 0],target = 1) == 0\n assert candidate(hours = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 11) == 5\n assert candidate(hours = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],target = 50000) == 30\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, 1, 1, 1, 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 = 0) == 57\n assert candidate(hours = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 1) == 0\n assert candidate(hours = [12, 34, 56, 78, 90],target = 50) == 3\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 55) == 5\n assert candidate(hours = [30, 25, 20, 15, 10],target = 20) == 3\n"}, "metadata": {"canonical_parameter_names": ["hours", "target"], "leetcode_dataset_entry_point": "Solution().numberOfEmployeesWhoMetTarget", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfEmployeesWhoMetTarget(int[] hours, int target) {", "container": "Solution", "callable": "numberOfEmployeesWhoMetTarget", "parameters": [{"name": "hours", "type": "int[]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2799, "task_id": "count-complete-subarrays-in-an-array", "difficulty": "Medium", "problem_description": "You are given an array nums consisting of positive integers.\nWe call a subarray of an array complete if the following condition is satisfied:\n\nThe number of distinct elements in the subarray is equal to the number of distinct elements in the whole array.\n\nReturn the number of complete subarrays.\nA subarray is a contiguous non-empty part of an array.\n \nExample 1:\n\nInput: nums = [1,3,1,2,2]\nOutput: 4\nExplanation: The complete subarrays are the following: [1,3,1,2], [1,3,1,2,2], [3,1,2] and [3,1,2,2].\n\nExample 2:\n\nInput: nums = [5,5,5,5]\nOutput: 10\nExplanation: The array consists only of the integer 5, so any subarray is complete. The number of subarrays that we can choose is 10.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 2000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 28\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 4\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996]) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3]) == 10\n assert candidate(nums = [7, 7, 7, 1, 7, 7, 7]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 15\n assert candidate(nums = [1, 2, 1, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 1, 2, 1, 2]) == 15\n assert candidate(nums = [10, 20, 30, 40, 50]) == 1\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5]) == 6\n assert candidate(nums = [2000, 1, 2000, 2, 2000, 3]) == 2\n assert candidate(nums = [1, 3, 1, 2, 2]) == 4\n assert candidate(nums = [5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 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]) == 1\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]) == 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]) == 190\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]) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1]) == 144\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]) == 84\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 1, 2, 3, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9]) == 25\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]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 21\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 5, 4, 3, 2, 1]) == 26\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 210\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 55\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, 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]) == 2211\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]) == 231\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, 3, 1, 3, 5, 7, 5, 1, 3, 2, 4, 1, 5, 3, 7, 2, 5, 1, 3, 5, 7, 9, 1, 2, 3, 4, 5]) == 85\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]) == 136\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 115\n assert candidate(nums = [7, 7, 1, 3, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(nums = [1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3]) == 162\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]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(nums = [1000, 1000, 999, 999, 998, 998, 997, 997, 996, 996, 995, 995, 994, 994]) == 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]) == 171\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\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]) == 4\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 66\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 2000, 1999, 1998, 1997, 1996]) == 21\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 210\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]) == 190\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 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, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 351\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]) == 496\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 91\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 = [7, 3, 7, 3, 1, 3, 7, 1, 7, 3, 7, 3, 1]) == 58\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, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 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]) == 25\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]) == 2\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]) == 253\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2, 3, 4, 5]) == 43\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 4\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]) == 1\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 66\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 91\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 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]) == 210\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9]) == 91\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 133\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 91\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 66\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == 66\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 66\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981]) == 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]) == 231\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 10]) == 7\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 66\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10]) == 24\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]) == 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, 11, 12, 13, 14, 15]) == 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]) == 66\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]) == 325\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 6\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 231\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]) == 25\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 190\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 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]) == 136\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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 231\n assert candidate(nums = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 171\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]) == 231\n assert candidate(nums = [10, 20, 10, 30, 20, 10, 40, 50, 30, 20]) == 15\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 120\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countCompleteSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countCompleteSubarrays(int[] nums) {", "container": "Solution", "callable": "countCompleteSubarrays", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2800, "task_id": "shortest-string-that-contains-three-strings", "difficulty": "Medium", "problem_description": "Given three strings a, b, and c, your task is to find a string that has the minimum length and contains all three strings as substrings.\nIf there are multiple such strings, return the lexicographically smallest one.\nReturn a string denoting the answer to the problem.\nNotes\n\nA string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\nA substring is a contiguous sequence of characters within a string.\n\n \nExample 1:\n\nInput: a = \"abc\", b = \"bca\", c = \"aaa\"\nOutput: \"aaabca\"\nExplanation: We show that \"aaabca\" contains all the given strings: a = ans[2...4], b = ans[3..5], c = ans[0..2]. It can be shown that the length of the resulting string would be at least 6 and \"aaabca\" is the lexicographically smallest one.\nExample 2:\n\nInput: a = \"ab\", b = \"ba\", c = \"aba\"\nOutput: \"aba\"\nExplanation: We show that the string \"aba\" contains all the given strings: a = ans[0..1], b = ans[1..2], c = ans[0..2]. Since the length of c is 3, the length of the resulting string would be at least 3. It can be shown that \"aba\" is the lexicographically smallest one.\n\n \nConstraints:\n\n1 <= a.length, b.length, c.length <= 100\na, b, c consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = \"aaaa\",b = \"bbbb\",c = \"cccc\") == \"aaaabbbbcccc\"\n assert candidate(a = \"aaa\",b = \"aa\",c = \"a\") == \"aaa\"\n assert candidate(a = \"ab\",b = \"ba\",c = \"aba\") == \"aba\"\n assert candidate(a = \"hello\",b = \"world\",c = \"hold\") == \"helloholdworld\"\n assert candidate(a = \"a\",b = \"b\",c = \"c\") == \"abc\"\n assert candidate(a = \"abcabc\",b = \"bcabc\",c = \"cabc\") == \"abcabc\"\n assert candidate(a = \"same\",b = \"same\",c = \"same\") == \"same\"\n assert candidate(a = \"a\",b = \"ab\",c = \"abc\") == \"abc\"\n assert candidate(a = \"xyz\",b = \"yzx\",c = \"zxy\") == \"xyzxy\"\n assert candidate(a = \"aaa\",b = \"bbb\",c = \"ccc\") == \"aaabbbccc\"\n assert candidate(a = \"abcde\",b = \"cdefg\",c = \"efghi\") == \"abcdefghi\"\n assert candidate(a = \"xyz\",b = \"zyx\",c = \"yzx\") == \"zyxyzx\"\n assert candidate(a = \"abc\",b = \"bca\",c = \"aaa\") == \"aaabca\"\n assert candidate(a = \"zzz\",b = \"zz\",c = \"z\") == \"zzz\"\n assert candidate(a = \"abcd\",b = \"bcd\",c = \"cde\") == \"abcde\"\n assert candidate(a = \"dog\",b = \"god\",c = \"dog\") == \"dogod\"\n assert candidate(a = \"start\",b = \"middle\",c = \"end\") == \"middlendstart\"\n assert candidate(a = \"abc\",b = \"abc\",c = \"abc\") == \"abc\"\n assert candidate(a = \"abc\",b = \"def\",c = \"ghi\") == \"abcdefghi\"\n assert candidate(a = \"short\",b = \"longerstring\",c = \"tiny\") == \"longerstringshortiny\"\n assert candidate(a = \"one\",b = \"two\",c = \"three\") == \"threetwone\"\n assert candidate(a = \"alphabet\",b = \"bet\",c = \"phabet\") == \"alphabet\"\n assert candidate(a = \"abacabad\",b = \"acabadab\",c = \"adabacab\") == \"adabacabadab\"\n assert candidate(a = \"unique\",b = \"queue\",c = \"ueuniq\") == \"ueuniqueue\"\n assert candidate(a = \"short\",b = \"longer\",c = \"longest\") == \"longerlongestshort\"\n assert candidate(a = \"abcabcabc\",b = \"bcabcabca\",c = \"cabcabcab\") == \"abcabcabcab\"\n assert candidate(a = \"abcd\",b = \"bcd\",c = \"cd\") == \"abcd\"\n assert candidate(a = \"abcxyz\",b = \"xyzabc\",c = \"bcxyza\") == \"abcxyzabc\"\n assert candidate(a = \"intersection\",b = \"section\",c = \"inter\") == \"intersection\"\n assert candidate(a = \"abcdefg\",b = \"efghijk\",c = \"ghijklm\") == \"abcdefghijklm\"\n assert candidate(a = \"abc\",b = \"bcd\",c = \"cde\") == \"abcde\"\n assert candidate(a = \"abcd\",b = \"bcde\",c = \"cdef\") == \"abcdef\"\n assert candidate(a = \"supercalifragilisticexpialidocious\",b = \"califragilistic\",c = \"fragilisticexpialidocious\") == \"supercalifragilisticexpialidocious\"\n assert candidate(a = \"abacaba\",b = \"acababc\",c = \"bacab\") == \"abacababc\"\n assert candidate(a = \"hello\",b = \"world\",c = \"helloworld\") == \"helloworld\"\n assert candidate(a = \"abcd\",b = \"dcba\",c = \"bacd\") == \"abcdcbacd\"\n assert candidate(a = \"mnop\",b = \"nopq\",c = \"opqr\") == \"mnopqr\"\n assert candidate(a = \"sequence\",b = \"sequenceabc\",c = \"absequence\") == \"absequenceabc\"\n assert candidate(a = \"prefix\",b = \"suffix\",c = \"fix\") == \"prefixsuffix\"\n assert candidate(a = \"aaa\",b = \"aab\",c = \"aba\") == \"aaaba\"\n assert candidate(a = \"aabbcc\",b = \"bbccdd\",c = \"ccddeeff\") == \"aabbccddeeff\"\n assert candidate(a = \"xyzz\",b = \"zzxy\",c = \"xyxy\") == \"xyxyzzxy\"\n assert candidate(a = \"abcde\",b = \"edcba\",c = \"cabde\") == \"cabdedcbabcde\"\n assert candidate(a = \"abcdef\",b = \"defghi\",c = \"ghijkl\") == \"abcdefghijkl\"\n assert candidate(a = \"abcdefg\",b = \"efghijk\",c = \"ghijkl\") == \"abcdefghijkl\"\n assert candidate(a = \"pqrs\",b = \"rstu\",c = \"stuv\") == \"pqrstuv\"\n assert candidate(a = \"abcdxyz\",b = \"xyzabc\",c = \"bcde\") == \"abcdxyzabcde\"\n assert candidate(a = \"abcdabcd\",b = \"bcdbcd\",c = \"dcbcdabc\") == \"dcbcdabcdabcdbcd\"\n assert candidate(a = \"algorithm\",b = \"rhythm\",c = \"thmology\") == \"algorithmologyrhythm\"\n assert candidate(a = \"banana\",b = \"nab\",c = \"ana\") == \"bananab\"\n assert candidate(a = \"intersect\",b = \"section\",c = \"inter\") == \"intersection\"\n assert candidate(a = \"apple\",b = \"peach\",c = \"cherry\") == \"applepeacherry\"\n assert candidate(a = \"abcabc\",b = \"bcabca\",c = \"cababc\") == \"cababcabca\"\n assert candidate(a = \"hello\",b = \"lohe\",c = \"hello\") == \"hellohe\"\n assert candidate(a = \"xyzabc\",b = \"bcdef\",c = \"defg\") == \"xyzabcdefg\"\n assert candidate(a = \"overlap\",b = \"lapover\",c = \"over\") == \"lapoverlap\"\n assert candidate(a = \"longstring\",b = \"stringlong\",c = \"nstringl\") == \"nstringlongstring\"\n assert candidate(a = \"abcdef\",b = \"defabc\",c = \"efabcd\") == \"defabcdef\"\n assert candidate(a = \"xy\",b = \"yx\",c = \"xyz\") == \"yxyz\"\n assert candidate(a = \"abc\",b = \"cab\",c = \"bac\") == \"bacabc\"\n assert candidate(a = \"apple\",b = \"plea\",c = \"eat\") == \"appleat\"\n assert candidate(a = \"abcabcabc\",b = \"bcabcbc\",c = \"cabcbcb\") == \"abcabcabcbcb\"\n assert candidate(a = \"pqr\",b = \"qrp\",c = \"rpq\") == \"pqrpq\"\n assert candidate(a = \"hello\",b = \"world\",c = \"hello\") == \"helloworld\"\n assert candidate(a = \"abcdefg\",b = \"efgabcd\",c = \"fgabcde\") == \"efgabcdefg\"\n assert candidate(a = \"aaabbb\",b = \"bbbaaa\",c = \"aaabbb\") == \"aaabbbaaa\"\n assert candidate(a = \"xyz\",b = \"zyx\",c = \"xyx\") == \"xyxyzyx\"\n assert candidate(a = \"abcdefgh\",b = \"efghijkl\",c = \"ghijklmn\") == \"abcdefghijklmn\"\n assert candidate(a = \"aaabbb\",b = \"bbbaaa\",c = \"aabbaa\") == \"aaabbbaaabbaa\"\n assert candidate(a = \"abcdabcd\",b = \"cdabcdabcd\",c = \"bcdabcdabcd\") == \"bcdabcdabcd\"\n assert candidate(a = \"xyz\",b = \"wxyz\",c = \"vwxyz\") == \"vwxyz\"\n assert candidate(a = \"programming\",b = \"coding\",c = \"ingenuity\") == \"codingenuityprogramming\"\n assert candidate(a = \"zebra\",b = \"bra\",c = \"ebra\") == \"zebra\"\n assert candidate(a = \"zzz\",b = \"zzzz\",c = \"zzzzz\") == \"zzzzz\"\n assert candidate(a = \"longstring\",b = \"stringlong\",c = \"ngstringlo\") == \"longstringlong\"\n assert candidate(a = \"antidisestablishmentarianism\",b = \"disestablishmentarianism\",c = \"establishmentarianism\") == \"antidisestablishmentarianism\"\n assert candidate(a = \"xyzabc\",b = \"bcdef\",c = \"defgh\") == \"xyzabcdefgh\"\n assert candidate(a = \"banana\",b = \"ananas\",c = \"nana\") == \"bananas\"\n assert candidate(a = \"abcde\",b = \"edcba\",c = \"bcde\") == \"abcdedcba\"\n assert candidate(a = \"aaaaaa\",b = \"aaaaaab\",c = \"baaaaaa\") == \"baaaaaab\"\n assert candidate(a = \"aabbcc\",b = \"bbccaa\",c = \"ccaabb\") == \"aabbccaabb\"\n assert candidate(a = \"zzzz\",b = \"zzzz\",c = \"zzzz\") == \"zzzz\"\n assert candidate(a = \"unique\",b = \"queue\",c = \"uniq\") == \"uniqueue\"\n assert candidate(a = \"banana\",b = \"nab\",c = \"ananab\") == \"bananab\"\n assert candidate(a = \"longword\",b = \"wordlong\",c = \"long\") == \"longwordlong\"\n assert candidate(a = \"aaaa\",b = \"aaab\",c = \"aabb\") == \"aaaabb\"\n assert candidate(a = \"banana\",b = \"nabana\",c = \"anaban\") == \"anabanana\"\n assert candidate(a = \"banana\",b = \"anana\",c = \"nana\") == \"banana\"\n assert candidate(a = \"hello\",b = \"lohe\",c = \"world\") == \"helloheworld\"\n assert candidate(a = \"pneumonoultramicroscopicsilicovolcanoconiosis\",b = \"microscopicsilicovolcanoconiosis\",c = \"silicovolcanoconiosis\") == \"pneumonoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(a = \"xylophone\",b = \"lophon\",c = \"phone\") == \"xylophone\"\n assert candidate(a = \"abac\",b = \"bacd\",c = \"acde\") == \"abacde\"\n assert candidate(a = \"mississippi\",b = \"issi\",c = \"sip\") == \"mississippi\"\n assert candidate(a = \"abcdefg\",b = \"defgabc\",c = \"fgabcde\") == \"defgabcdefg\"\n assert candidate(a = \"abc\",b = \"cbad\",c = \"dabc\") == \"cbadabc\"\n assert candidate(a = \"aab\",b = \"abb\",c = \"bba\") == \"aabba\"\n assert candidate(a = \"aaaab\",b = \"bbbaa\",c = \"aabba\") == \"bbbaaaabba\"\n assert candidate(a = \"abcd\",b = \"cdab\",c = \"abcd\") == \"abcdab\"\n assert candidate(a = \"abcdefg\",b = \"ghijklm\",c = \"jklmnop\") == \"abcdefghijklmnop\"\n assert candidate(a = \"banana\",b = \"nab\",c = \"nan\") == \"bananab\"\n assert candidate(a = \"abcdabcd\",b = \"bcdbcdb\",c = \"cdcdcdc\") == \"abcdabcdbcdbcdcdcdc\"\n assert candidate(a = \"mnopqr\",b = \"pqrs\",c = \"rstuv\") == \"mnopqrstuv\"\n assert candidate(a = \"overlap\",b = \"lapover\",c = \"verlapo\") == \"lapoverlapo\"\n assert candidate(a = \"abcd\",b = \"cdab\",c = \"bcda\") == \"abcdab\"\n assert candidate(a = \"abacaba\",b = \"cabacab\",c = \"bacabac\") == \"cabacabac\"\n assert candidate(a = \"overlap\",b = \"laplap\",c = \"lapping\") == \"overlaplapping\"\n assert candidate(a = \"hello\",b = \"world\",c = \"helowrld\") == \"hellohelowrldworld\"\n assert candidate(a = \"abcdefghij\",b = \"ghijklmnop\",c = \"mnopqrstuv\") == \"abcdefghijklmnopqrstuv\"\n assert candidate(a = \"aaaab\",b = \"bbbbb\",c = \"ccccd\") == \"aaaabbbbbccccd\"\n assert candidate(a = \"hello\",b = \"world\",c = \"owor\") == \"helloworld\"\n assert candidate(a = \"ab\",b = \"bc\",c = \"ca\") == \"abca\"\n"}, "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().minimumString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String minimumString(String a, String b, String c) {", "container": "Solution", "callable": "minimumString", "parameters": [{"name": "a", "type": "String"}, {"name": "b", "type": "String"}, {"name": "c", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2801, "task_id": "count-stepping-numbers-in-range", "difficulty": "Hard", "problem_description": "Given two positive integers low and high represented as strings, find the count of stepping numbers in the inclusive range [low, high].\nA stepping number is an integer such that all of its adjacent digits have an absolute difference of exactly 1.\nReturn an integer denoting the count of stepping numbers in the inclusive range [low, high]. \nSince the answer may be very large, return it modulo 109 + 7.\nNote: A stepping number should not have a leading zero.\n \nExample 1:\n\nInput: low = \"1\", high = \"11\"\nOutput: 10\nExplanation: The stepping numbers in the range [1,11] are 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10. There are a total of 10 stepping numbers in the range. Hence, the output is 10.\nExample 2:\n\nInput: low = \"90\", high = \"101\"\nOutput: 2\nExplanation: The stepping numbers in the range [90,101] are 98 and 101. There are a total of 2 stepping numbers in the range. Hence, the output is 2. \n \nConstraints:\n\n1 <= int(low) <= int(high) < 10100\n1 <= low.length, high.length <= 100\nlow and high consist of only digits.\nlow and high don't have any leading zeros.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(low = \"123\",high = \"456\") == 13\n assert candidate(low = \"5555555555\",high = \"6666666666\") == 436\n assert candidate(low = \"1111111111\",high = \"2222222222\") == 307\n assert candidate(low = \"1000000000\",high = \"1000000001\") == 0\n assert candidate(low = \"10\",high = \"100\") == 17\n assert candidate(low = \"9999999999\",high = \"9999999999\") == 0\n assert candidate(low = \"1\",high = \"9876543210\") == 6111\n assert candidate(low = \"1\",high = \"11\") == 10\n assert candidate(low = \"9876543210\",high = \"9876543210\") == 1\n assert candidate(low = \"90\",high = \"101\") == 2\n assert candidate(low = \"10000000000000000000\",high = \"10000000000000000010\") == 0\n assert candidate(low = \"12345678901234567890\",high = \"98765432109876543210\") == 1768804\n assert candidate(low = \"12345678901234567890\",high = \"12345678901234567891\") == 0\n assert candidate(low = \"999999999999999999\",high = \"1000000000000000000\") == 0\n assert candidate(low = \"321098765432109876543210987\",high = \"432109876543210987654321098\") == 25767582\n assert candidate(low = \"8888888888\",high = \"8888888899\") == 0\n assert candidate(low = \"9999999999999999999\",high = \"10000000000000000000\") == 0\n assert candidate(low = \"3333333333\",high = \"4444444444\") == 436\n assert candidate(low = \"989898989898989898\",high = \"999999999999999999\") == 1\n assert candidate(low = \"9\",high = \"9\") == 1\n assert candidate(low = \"1234567890\",high = \"2345678901\") == 333\n assert candidate(low = \"1\",high = \"2147483647\") == 3627\n assert candidate(low = \"1010101010\",high = \"2020202020\") == 251\n assert candidate(low = \"8888888888\",high = \"9999999999\") == 196\n assert candidate(low = \"1\",high = \"12345678901234567890\") == 2358711\n assert candidate(low = \"54321098765432109876543210\",high = \"65432109876543210987654321\") == 14851321\n assert candidate(low = \"5\",high = \"5555555555\") == 4904\n assert candidate(low = \"987654321\",high = \"9876543211\") == 2931\n assert candidate(low = \"54321098765432109876\",high = \"65432109876543210987\") == 297140\n assert candidate(low = \"5000000000\",high = \"5000000010\") == 0\n assert candidate(low = \"500\",high = \"600\") == 4\n assert candidate(low = \"5\",high = \"5\") == 1\n assert candidate(low = \"12345678912345678912\",high = \"23456789123456789123\") == 226942\n assert candidate(low = \"8888888888\",high = \"8989898989\") == 70\n assert candidate(low = \"9876543210\",high = \"9876543219\") == 2\n assert candidate(low = \"888888888\",high = \"999999999\") == 105\n assert candidate(low = \"1000000000\",high = \"9999999999\") == 2986\n assert candidate(low = \"8989898989\",high = \"9898989898\") == 127\n assert candidate(low = \"1212121212\",high = \"2121212121\") == 202\n assert candidate(low = \"987654321\",high = \"987654322\") == 1\n assert candidate(low = \"10000000000000000000\",high = \"10000000000000000001\") == 0\n assert candidate(low = \"54321\",high = \"65432\") == 17\n assert candidate(low = \"8999999999999999999\",high = \"9000000000000000001\") == 0\n assert candidate(low = \"1010101010\",high = \"1121212121\") == 70\n assert candidate(low = \"1010101010\",high = \"9090909090\") == 2860\n assert candidate(low = \"9999999999\",high = \"10000000000\") == 0\n assert candidate(low = \"9999999990\",high = \"9999999999\") == 0\n assert candidate(low = \"9876543210987654321\",high = \"9876543210987654322\") == 0\n assert candidate(low = \"1\",high = \"9999999999\") == 6236\n assert candidate(low = \"98765432109876543210\",high = \"98765432109876543211\") == 0\n assert candidate(low = \"1234567890\",high = \"1234567899\") == 1\n assert candidate(low = \"123\",high = \"45678901234567890123\") == 3157659\n assert candidate(low = \"7777777777\",high = \"8888888888\") == 307\n assert candidate(low = \"12121212121212121212\",high = \"13131313131313131313\") == 102885\n assert candidate(low = \"321\",high = \"654\") == 13\n assert candidate(low = \"9876543210123456789\",high = \"9876543210123456790\") == 1\n assert candidate(low = \"1010101010\",high = \"1111111111\") == 70\n assert candidate(low = \"98765432101234567890\",high = \"98765432101234567899\") == 1\n assert candidate(low = \"4444444444\",high = \"5555555555\") == 456\n assert candidate(low = \"200\",high = \"210\") == 1\n assert candidate(low = \"1\",high = \"1234567890\") == 3500\n assert candidate(low = \"987654321\",high = \"9876543210\") == 2931\n assert candidate(low = \"9876543210\",high = \"10123456789\") == 252\n assert candidate(low = \"100000000000000000000000000000000000000000000000000\",high = \"99999999999999999999999999999999999999999999999999\") == 0\n assert candidate(low = \"99999999999999999999\",high = \"100000000000000000000\") == 0\n assert candidate(low = \"1111111111111111111\",high = \"1212121212121212121\") == 8551\n assert candidate(low = \"1111111111\",high = \"1111111111\") == 0\n assert candidate(low = \"8989898989\",high = \"9090909090\") == 1\n assert candidate(low = \"98765432101234567890\",high = \"98765432101234567891\") == 0\n assert candidate(low = \"5432109876\",high = \"5432109877\") == 0\n assert candidate(low = \"50505050505050505050\",high = \"60606060606060606060\") == 298777\n assert candidate(low = \"11111111111111111111\",high = \"22222222222222222222\") == 204289\n assert candidate(low = \"98765432101234567890\",high = \"98765432109876543210\") == 1\n assert candidate(low = \"10000000000\",high = \"20000000000\") == 460\n assert candidate(low = \"123\",high = \"135\") == 1\n assert candidate(low = \"1000000000\",high = \"2000000000\") == 251\n assert candidate(low = \"123456789\",high = \"987654321\") == 1362\n assert candidate(low = \"98765432109876543210987654321\",high = \"98765432109876543210987654322\") == 0\n assert candidate(low = \"98765\",high = \"98766\") == 1\n assert candidate(low = \"123456789\",high = \"1234567891\") == 1681\n assert candidate(low = \"987654321\",high = \"9876543219\") == 2932\n assert candidate(low = \"987654321\",high = \"987654329\") == 2\n assert candidate(low = \"543210\",high = \"6543210\") == 380\n assert candidate(low = \"1234567890\",high = \"1234567891\") == 0\n assert candidate(low = \"123\",high = \"321\") == 6\n assert candidate(low = \"1010101010101010101\",high = \"1111111111111111111\") == 22950\n assert candidate(low = \"8999999999\",high = \"9000000000\") == 0\n assert candidate(low = \"555555555\",high = \"666666666\") == 228\n assert candidate(low = \"10101010101010101010\",high = \"21212121212121212121\") == 195908\n assert candidate(low = \"1\",high = \"10000000000000000000\") == 2194764\n assert candidate(low = \"12345\",high = \"123456789012345\") == 90485\n assert candidate(low = \"2222222222\",high = \"3333333333\") == 389\n assert candidate(low = \"1\",high = \"99999999999999999999999999999999999999999999999999\") == 254219541\n assert candidate(low = \"123454321\",high = \"123456789\") == 16\n assert candidate(low = \"1010101010\",high = \"1010101011\") == 1\n assert candidate(low = \"112233445566778899\",high = \"122334455667788990\") == 12190\n assert candidate(low = \"100000000000000000000000000000000000000000000000000\",high = \"200000000000000000000000000000000000000000000000000\") == 251590529\n assert candidate(low = \"1111111111\",high = \"9999999999\") == 2916\n assert candidate(low = \"10101010101010101010\",high = \"20202020202020202020\") == 164407\n assert candidate(low = \"123\",high = \"133\") == 1\n assert candidate(low = \"10\",high = \"1111111111\") == 3311\n"}, "metadata": {"canonical_parameter_names": ["low", "high"], "leetcode_dataset_entry_point": "Solution().countSteppingNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countSteppingNumbers(String low, String high) {", "container": "Solution", "callable": "countSteppingNumbers", "parameters": [{"name": "low", "type": "String"}, {"name": "high", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2806, "task_id": "account-balance-after-rounded-purchase", "difficulty": "Easy", "problem_description": "Initially, you have a bank account balance of 100 dollars.\nYou are given an integer purchaseAmount representing the amount you will spend on a purchase in dollars, in other words, its price.\nWhen making the purchase, first the purchaseAmount is rounded to the nearest multiple of 10. Let us call this value roundedAmount. Then, roundedAmount dollars are removed from your bank account.\nReturn an integer denoting your final bank account balance after this purchase.\nNotes:\n\n0 is considered to be a multiple of 10 in this problem.\nWhen rounding, 5 is rounded upward (5 is rounded to 10, 15 is rounded to 20, 25 to 30, and so on).\n\n \nExample 1:\n\nInput: purchaseAmount = 9\nOutput: 90\nExplanation:\nThe nearest multiple of 10 to 9 is 10. So your account balance becomes 100 - 10 = 90.\n\nExample 2:\n\nInput: purchaseAmount = 15\nOutput: 80\nExplanation:\nThe nearest multiple of 10 to 15 is 20. So your account balance becomes 100 - 20 = 80.\n\nExample 3:\n\nInput: purchaseAmount = 10\nOutput: 90\nExplanation:\n10 is a multiple of 10 itself. So your account balance becomes 100 - 10 = 90.\n\n \nConstraints:\n\n0 <= purchaseAmount <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(purchaseAmount = 100) == 0\n assert candidate(purchaseAmount = 85) == 10\n assert candidate(purchaseAmount = 15) == 80\n assert candidate(purchaseAmount = 10) == 90\n assert candidate(purchaseAmount = 45) == 50\n assert candidate(purchaseAmount = 51) == 50\n assert candidate(purchaseAmount = 34) == 70\n assert candidate(purchaseAmount = 0) == 100\n assert candidate(purchaseAmount = 60) == 40\n assert candidate(purchaseAmount = 25) == 70\n assert candidate(purchaseAmount = 9) == 90\n assert candidate(purchaseAmount = 75) == 20\n assert candidate(purchaseAmount = 50) == 50\n assert candidate(purchaseAmount = 55) == 40\n assert candidate(purchaseAmount = 99) == 0\n assert candidate(purchaseAmount = 31) == 70\n assert candidate(purchaseAmount = 27) == 70\n assert candidate(purchaseAmount = 22) == 80\n assert candidate(purchaseAmount = 35) == 60\n assert candidate(purchaseAmount = 1) == 100\n assert candidate(purchaseAmount = 7) == 90\n assert candidate(purchaseAmount = 49) == 50\n assert candidate(purchaseAmount = 28) == 70\n assert candidate(purchaseAmount = 11) == 90\n assert candidate(purchaseAmount = 26) == 70\n assert candidate(purchaseAmount = 65) == 30\n assert candidate(purchaseAmount = 90) == 10\n assert candidate(purchaseAmount = 69) == 30\n assert candidate(purchaseAmount = 84) == 20\n assert candidate(purchaseAmount = 91) == 10\n assert candidate(purchaseAmount = 29) == 70\n assert candidate(purchaseAmount = 67) == 30\n assert candidate(purchaseAmount = 23) == 80\n assert candidate(purchaseAmount = 59) == 40\n assert candidate(purchaseAmount = 63) == 40\n assert candidate(purchaseAmount = 4) == 100\n assert candidate(purchaseAmount = 38) == 60\n assert candidate(purchaseAmount = 6) == 90\n assert candidate(purchaseAmount = 5) == 90\n assert candidate(purchaseAmount = 79) == 20\n assert candidate(purchaseAmount = 74) == 30\n assert candidate(purchaseAmount = 47) == 50\n assert candidate(purchaseAmount = 77) == 20\n assert candidate(purchaseAmount = 39) == 60\n assert candidate(purchaseAmount = 2) == 100\n assert candidate(purchaseAmount = 8) == 90\n assert candidate(purchaseAmount = 95) == 0\n assert candidate(purchaseAmount = 14) == 90\n assert candidate(purchaseAmount = 94) == 10\n assert candidate(purchaseAmount = 30) == 70\n assert candidate(purchaseAmount = 89) == 10\n assert candidate(purchaseAmount = 3) == 100\n assert candidate(purchaseAmount = 19) == 80\n assert candidate(purchaseAmount = 82) == 20\n"}, "metadata": {"canonical_parameter_names": ["purchaseAmount"], "leetcode_dataset_entry_point": "Solution().accountBalanceAfterPurchase", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int accountBalanceAfterPurchase(int purchaseAmount) {", "container": "Solution", "callable": "accountBalanceAfterPurchase", "parameters": [{"name": "purchaseAmount", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2807, "task_id": "insert-greatest-common-divisors-in-linked-list", "difficulty": "Medium", "problem_description": "Given the head of a linked list head, in which each node contains an integer value.\nBetween every pair of adjacent nodes, insert a new node with a value equal to the greatest common divisor of them.\nReturn the linked list after insertion.\nThe greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.\n \nExample 1:\n\n\nInput: head = [18,6,10,3]\nOutput: [18,6,6,2,10,1,3]\nExplanation: The 1st diagram denotes the initial linked list and the 2nd diagram denotes the linked list after inserting the new nodes (nodes in blue are the inserted nodes).\n- We insert the greatest common divisor of 18 and 6 = 6 between the 1st and the 2nd nodes.\n- We insert the greatest common divisor of 6 and 10 = 2 between the 2nd and the 3rd nodes.\n- We insert the greatest common divisor of 10 and 3 = 1 between the 3rd and the 4th nodes.\nThere are no more adjacent nodes, so we return the linked list.\n\nExample 2:\n\n\nInput: head = [7]\nOutput: [7]\nExplanation: The 1st diagram denotes the initial linked list and the 2nd diagram denotes the linked list after inserting the new nodes.\nThere are no pairs of adjacent nodes, so we return the initial linked list.\n\n \nConstraints:\n\nThe number of nodes in the list is in the range [1, 5000].\n1 <= Node.val <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(head = list_node([7, 14, 28, 56])), list_node([7, 7, 14, 14, 28, 28, 56]))\n assert is_same_list(candidate(head = list_node([33, 51, 68])), list_node([33, 3, 51, 17, 68]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5])), list_node([1, 1, 2, 1, 3, 1, 4, 1, 5]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50])), list_node([10, 10, 20, 10, 30, 10, 40, 10, 50]))\n assert is_same_list(candidate(head = list_node([1000, 1000])), list_node([1000, 1000, 1000]))\n assert is_same_list(candidate(head = list_node([3, 9, 27, 81])), list_node([3, 3, 9, 9, 27, 27, 81]))\n assert is_same_list(candidate(head = list_node([48, 18, 30])), list_node([48, 6, 18, 6, 30]))\n assert is_same_list(candidate(head = list_node([100, 200, 300])), list_node([100, 100, 200, 100, 300]))\n assert is_same_list(candidate(head = list_node([100, 50, 25, 10])), list_node([100, 50, 50, 25, 25, 5, 10]))\n assert is_same_list(candidate(head = list_node([3, 3, 3, 3, 3])), list_node([3, 3, 3, 3, 3, 3, 3, 3, 3]))\n assert is_same_list(candidate(head = list_node([7])), list_node([7]))\n assert is_same_list(candidate(head = list_node([12, 15, 20])), list_node([12, 3, 15, 5, 20]))\n assert is_same_list(candidate(head = list_node([42, 56, 14])), list_node([42, 14, 56, 14, 14]))\n assert is_same_list(candidate(head = list_node([7, 7, 7, 7])), list_node([7, 7, 7, 7, 7, 7, 7]))\n assert is_same_list(candidate(head = list_node([18, 6, 10, 3])), list_node([18, 6, 6, 2, 10, 1, 3]))\n assert is_same_list(candidate(head = list_node([8, 12, 16, 20])), list_node([8, 4, 12, 4, 16, 4, 20]))\n assert is_same_list(candidate(head = list_node([99, 81, 27])), list_node([99, 9, 81, 27, 27]))\n assert is_same_list(candidate(head = list_node([5, 15, 25, 35])), list_node([5, 5, 15, 5, 25, 5, 35]))\n assert is_same_list(candidate(head = list_node([5, 10, 15, 20, 25])), list_node([5, 5, 10, 5, 15, 5, 20, 5, 25]))\n assert is_same_list(candidate(head = list_node([12, 15, 21])), list_node([12, 3, 15, 3, 21]))\n assert is_same_list(candidate(head = list_node([1000, 500, 250, 125])), list_node([1000, 500, 500, 250, 250, 125, 125]))\n assert is_same_list(candidate(head = list_node([3, 5, 8, 12])), list_node([3, 1, 5, 1, 8, 4, 12]))\n assert is_same_list(candidate(head = list_node([1000, 1000, 1000])), list_node([1000, 1000, 1000, 1000, 1000]))\n assert is_same_list(candidate(head = list_node([98, 49, 24, 12, 6, 3])), list_node([98, 49, 49, 1, 24, 12, 12, 6, 6, 3, 3]))\n assert is_same_list(candidate(head = list_node([13, 17, 19, 23, 29])), list_node([13, 1, 17, 1, 19, 1, 23, 1, 29]))\n assert is_same_list(candidate(head = list_node([11, 22, 33, 44, 55, 66, 77, 88, 99])), list_node([11, 11, 22, 11, 33, 11, 44, 11, 55, 11, 66, 11, 77, 11, 88, 11, 99]))\n assert is_same_list(candidate(head = list_node([2023, 2021, 2019, 2017, 2015])), list_node([2023, 1, 2021, 1, 2019, 1, 2017, 1, 2015]))\n assert is_same_list(candidate(head = list_node([21, 14, 49, 35, 70, 56])), list_node([21, 7, 14, 7, 49, 7, 35, 35, 70, 14, 56]))\n assert is_same_list(candidate(head = list_node([77, 49, 35, 91, 63])), list_node([77, 7, 49, 7, 35, 7, 91, 7, 63]))\n assert is_same_list(candidate(head = list_node([60, 45, 30, 15])), list_node([60, 15, 45, 15, 30, 15, 15]))\n assert is_same_list(candidate(head = list_node([60, 30, 15, 5, 1])), list_node([60, 30, 30, 15, 15, 5, 5, 1, 1]))\n assert is_same_list(candidate(head = list_node([1000, 500, 250, 125, 62, 31, 15, 7, 3, 1])), list_node([1000, 500, 500, 250, 250, 125, 125, 1, 62, 31, 31, 1, 15, 1, 7, 1, 3, 1, 1]))\n assert is_same_list(candidate(head = list_node([112, 128, 144, 160, 176])), list_node([112, 16, 128, 16, 144, 16, 160, 16, 176]))\n assert is_same_list(candidate(head = list_node([77, 14, 28, 49])), list_node([77, 7, 14, 14, 28, 7, 49]))\n assert is_same_list(candidate(head = list_node([21, 35, 105, 175])), list_node([21, 7, 35, 35, 105, 35, 175]))\n assert is_same_list(candidate(head = list_node([8, 12, 18, 24])), list_node([8, 4, 12, 6, 18, 6, 24]))\n assert is_same_list(candidate(head = list_node([8, 12, 16, 20, 24, 28])), list_node([8, 4, 12, 4, 16, 4, 20, 4, 24, 4, 28]))\n assert is_same_list(candidate(head = list_node([11, 22, 33, 44, 55, 66, 77])), list_node([11, 11, 22, 11, 33, 11, 44, 11, 55, 11, 66, 11, 77]))\n assert is_same_list(candidate(head = list_node([21, 14, 7, 49, 35, 28])), list_node([21, 7, 14, 7, 7, 7, 49, 7, 35, 7, 28]))\n assert is_same_list(candidate(head = list_node([1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1])), list_node([1024, 512, 512, 256, 256, 128, 128, 64, 64, 32, 32, 16, 16, 8, 8, 4, 4, 2, 2, 1, 1]))\n assert is_same_list(candidate(head = list_node([54, 27, 9, 3, 1, 3, 9, 27, 54])), list_node([54, 27, 27, 9, 9, 3, 3, 1, 1, 1, 3, 3, 9, 9, 27, 27, 54]))\n assert is_same_list(candidate(head = list_node([11, 22, 33, 44, 55, 66, 77, 88, 99, 110])), list_node([11, 11, 22, 11, 33, 11, 44, 11, 55, 11, 66, 11, 77, 11, 88, 11, 99, 11, 110]))\n assert is_same_list(candidate(head = list_node([150, 120, 90, 60, 30, 15, 5])), list_node([150, 30, 120, 30, 90, 30, 60, 30, 30, 15, 15, 5, 5]))\n assert is_same_list(candidate(head = list_node([111, 222, 333, 444, 555, 666, 777, 888, 999])), list_node([111, 111, 222, 111, 333, 111, 444, 111, 555, 111, 666, 111, 777, 111, 888, 111, 999]))\n assert is_same_list(candidate(head = list_node([1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1])), list_node([1024, 512, 512, 256, 256, 128, 128, 64, 64, 32, 32, 16, 16, 8, 8, 4, 4, 2, 2, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]))\n assert is_same_list(candidate(head = list_node([30, 15, 5, 25])), list_node([30, 15, 15, 5, 5, 5, 25]))\n assert is_same_list(candidate(head = list_node([72, 48, 60, 36, 90])), list_node([72, 24, 48, 12, 60, 12, 36, 18, 90]))\n assert is_same_list(candidate(head = list_node([101, 103, 107, 109])), list_node([101, 1, 103, 1, 107, 1, 109]))\n assert is_same_list(candidate(head = list_node([55, 110, 220, 440, 880, 1760, 3520])), list_node([55, 55, 110, 110, 220, 220, 440, 440, 880, 880, 1760, 1760, 3520]))\n assert is_same_list(candidate(head = list_node([81, 27, 9, 3, 1])), list_node([81, 27, 27, 9, 9, 3, 3, 1, 1]))\n assert is_same_list(candidate(head = list_node([120, 80, 40, 20, 10])), list_node([120, 40, 80, 40, 40, 20, 20, 10, 10]))\n assert is_same_list(candidate(head = list_node([48, 64, 80, 96, 112, 128])), list_node([48, 16, 64, 16, 80, 16, 96, 16, 112, 16, 128]))\n assert is_same_list(candidate(head = list_node([100, 25, 45, 15, 30])), list_node([100, 25, 25, 5, 45, 15, 15, 15, 30]))\n assert is_same_list(candidate(head = list_node([1000, 500, 250, 125, 62, 31, 1])), list_node([1000, 500, 500, 250, 250, 125, 125, 1, 62, 31, 31, 1, 1]))\n assert is_same_list(candidate(head = list_node([8, 12, 18, 24, 30])), list_node([8, 4, 12, 6, 18, 6, 24, 6, 30]))\n assert is_same_list(candidate(head = list_node([44, 66, 88, 110, 132])), list_node([44, 22, 66, 22, 88, 22, 110, 22, 132]))\n assert is_same_list(candidate(head = list_node([225, 150, 100, 50])), list_node([225, 75, 150, 50, 100, 50, 50]))\n assert is_same_list(candidate(head = list_node([19, 38, 76, 152])), list_node([19, 19, 38, 38, 76, 76, 152]))\n assert is_same_list(candidate(head = list_node([1000, 500, 250, 125, 62, 31, 15, 7, 3, 1])), list_node([1000, 500, 500, 250, 250, 125, 125, 1, 62, 31, 31, 1, 15, 1, 7, 1, 3, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 4, 8, 16, 32])), list_node([1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32]))\n assert is_same_list(candidate(head = list_node([24, 36, 48, 60, 72, 84])), list_node([24, 12, 36, 12, 48, 12, 60, 12, 72, 12, 84]))\n assert is_same_list(candidate(head = list_node([77, 14, 49, 7, 21, 35])), list_node([77, 7, 14, 7, 49, 7, 7, 7, 21, 7, 35]))\n assert is_same_list(candidate(head = list_node([99, 33, 66, 11, 22])), list_node([99, 33, 33, 33, 66, 11, 11, 11, 22]))\n assert is_same_list(candidate(head = list_node([15, 30, 45, 60, 75, 90])), list_node([15, 15, 30, 15, 45, 15, 60, 15, 75, 15, 90]))\n assert is_same_list(candidate(head = list_node([23, 46, 69, 92, 115, 138])), list_node([23, 23, 46, 23, 69, 23, 92, 23, 115, 23, 138]))\n assert is_same_list(candidate(head = list_node([72, 48, 24, 12, 6])), list_node([72, 24, 48, 24, 24, 12, 12, 6, 6]))\n assert is_same_list(candidate(head = list_node([56, 98, 154, 224])), list_node([56, 14, 98, 14, 154, 14, 224]))\n assert is_same_list(candidate(head = list_node([100, 25, 50, 20, 40])), list_node([100, 25, 25, 25, 50, 10, 20, 20, 40]))\n assert is_same_list(candidate(head = list_node([2000, 1000, 500, 250, 125, 62, 31])), list_node([2000, 1000, 1000, 500, 500, 250, 250, 125, 125, 1, 62, 31, 31]))\n assert is_same_list(candidate(head = list_node([6, 12, 18, 24, 30, 36, 42, 48, 54])), list_node([6, 6, 12, 6, 18, 6, 24, 6, 30, 6, 36, 6, 42, 6, 48, 6, 54]))\n assert is_same_list(candidate(head = list_node([144, 72, 36, 18, 9, 3, 1])), list_node([144, 72, 72, 36, 36, 18, 18, 9, 9, 3, 3, 1, 1]))\n assert is_same_list(candidate(head = list_node([84, 42, 21, 105])), list_node([84, 42, 42, 21, 21, 21, 105]))\n assert is_same_list(candidate(head = list_node([315, 360, 405, 450])), list_node([315, 45, 360, 45, 405, 45, 450]))\n assert is_same_list(candidate(head = list_node([999, 1000, 998, 997, 996, 995])), list_node([999, 1, 1000, 2, 998, 1, 997, 1, 996, 1, 995]))\n assert is_same_list(candidate(head = list_node([84, 105, 140, 175])), list_node([84, 21, 105, 35, 140, 35, 175]))\n assert is_same_list(candidate(head = list_node([100, 50, 25, 5])), list_node([100, 50, 50, 25, 25, 5, 5]))\n assert is_same_list(candidate(head = list_node([13, 26, 39, 52, 65])), list_node([13, 13, 26, 13, 39, 13, 52, 13, 65]))\n assert is_same_list(candidate(head = list_node([100, 25, 10, 50])), list_node([100, 25, 25, 5, 10, 10, 50]))\n assert is_same_list(candidate(head = list_node([101, 103, 107, 109, 113])), list_node([101, 1, 103, 1, 107, 1, 109, 1, 113]))\n assert is_same_list(candidate(head = list_node([54, 24, 36, 18, 90, 60])), list_node([54, 6, 24, 12, 36, 18, 18, 18, 90, 30, 60]))\n assert is_same_list(candidate(head = list_node([144, 120, 96, 72])), list_node([144, 24, 120, 24, 96, 24, 72]))\n assert is_same_list(candidate(head = list_node([45, 90, 135, 180, 225, 270])), list_node([45, 45, 90, 45, 135, 45, 180, 45, 225, 45, 270]))\n assert is_same_list(candidate(head = list_node([210, 105, 35, 7, 1])), list_node([210, 105, 105, 35, 35, 7, 7, 1, 1]))\n assert is_same_list(candidate(head = list_node([100, 25, 10, 5])), list_node([100, 25, 25, 5, 10, 5, 5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]))\n assert is_same_list(candidate(head = list_node([100, 25, 50, 75, 125])), list_node([100, 25, 25, 25, 50, 25, 75, 25, 125]))\n assert is_same_list(candidate(head = list_node([500, 250, 125, 25])), list_node([500, 250, 250, 125, 125, 25, 25]))\n assert is_same_list(candidate(head = list_node([100, 25, 50, 125, 200])), list_node([100, 25, 25, 25, 50, 25, 125, 25, 200]))\n assert is_same_list(candidate(head = list_node([100, 25, 50, 125, 200])), list_node([100, 25, 25, 25, 50, 25, 125, 25, 200]))\n assert is_same_list(candidate(head = list_node([144, 108, 72, 36, 18])), list_node([144, 36, 108, 36, 72, 36, 36, 18, 18]))\n assert is_same_list(candidate(head = list_node([17, 19, 23, 29, 31, 37, 41, 43, 47])), list_node([17, 1, 19, 1, 23, 1, 29, 1, 31, 1, 37, 1, 41, 1, 43, 1, 47]))\n assert is_same_list(candidate(head = list_node([120, 180, 300, 420])), list_node([120, 60, 180, 60, 300, 60, 420]))\n assert is_same_list(candidate(head = list_node([210, 231, 252, 273, 294])), list_node([210, 21, 231, 21, 252, 21, 273, 21, 294]))\n assert is_same_list(candidate(head = list_node([128, 64, 32, 16, 8, 4, 2, 1])), list_node([128, 64, 64, 32, 32, 16, 16, 8, 8, 4, 4, 2, 2, 1, 1]))\n assert is_same_list(candidate(head = list_node([13, 26, 39, 52, 65, 78])), list_node([13, 13, 26, 13, 39, 13, 52, 13, 65, 13, 78]))\n assert is_same_list(candidate(head = list_node([44, 55, 66, 77, 88, 99, 110])), list_node([44, 11, 55, 11, 66, 11, 77, 11, 88, 11, 99, 11, 110]))\n assert is_same_list(candidate(head = list_node([13, 13, 13, 13, 13])), list_node([13, 13, 13, 13, 13, 13, 13, 13, 13]))\n assert is_same_list(candidate(head = list_node([99, 33, 11, 55, 22])), list_node([99, 33, 33, 11, 11, 11, 55, 11, 22]))\n assert is_same_list(candidate(head = list_node([17, 34, 51, 68])), list_node([17, 17, 34, 17, 51, 17, 68]))\n assert is_same_list(candidate(head = list_node([17, 19, 23, 29, 31, 37, 41, 43])), list_node([17, 1, 19, 1, 23, 1, 29, 1, 31, 1, 37, 1, 41, 1, 43]))\n assert is_same_list(candidate(head = list_node([9, 27, 81, 243, 729])), list_node([9, 9, 27, 27, 81, 81, 243, 243, 729]))\n assert is_same_list(candidate(head = list_node([72, 48, 64, 32, 16])), list_node([72, 24, 48, 16, 64, 32, 32, 16, 16]))\n assert is_same_list(candidate(head = list_node([17, 34, 51, 68, 85])), list_node([17, 17, 34, 17, 51, 17, 68, 17, 85]))\n assert is_same_list(candidate(head = list_node([84, 56, 42, 28, 14])), list_node([84, 28, 56, 14, 42, 14, 28, 14, 14]))\n assert is_same_list(candidate(head = list_node([101, 202, 303, 404, 505])), list_node([101, 101, 202, 101, 303, 101, 404, 101, 505]))\n assert is_same_list(candidate(head = list_node([13, 26, 39, 52])), list_node([13, 13, 26, 13, 39, 13, 52]))\n assert is_same_list(candidate(head = list_node([99, 98, 97, 96, 95, 94, 93, 92, 91, 90])), list_node([99, 1, 98, 1, 97, 1, 96, 1, 95, 1, 94, 1, 93, 1, 92, 1, 91, 1, 90]))\n assert is_same_list(candidate(head = list_node([101, 103, 107, 109, 113])), list_node([101, 1, 103, 1, 107, 1, 109, 1, 113]))\n assert is_same_list(candidate(head = list_node([1000, 500, 250, 125, 62, 31])), list_node([1000, 500, 500, 250, 250, 125, 125, 1, 62, 31, 31]))\n assert is_same_list(candidate(head = list_node([144, 72, 36, 18, 9])), list_node([144, 72, 72, 36, 36, 18, 18, 9, 9]))\n assert is_same_list(candidate(head = list_node([99, 33, 11, 3])), list_node([99, 33, 33, 11, 11, 1, 3]))\n assert is_same_list(candidate(head = list_node([101, 103, 107, 109, 113, 127, 131, 137, 139])), list_node([101, 1, 103, 1, 107, 1, 109, 1, 113, 1, 127, 1, 131, 1, 137, 1, 139]))\n assert is_same_list(candidate(head = list_node([81, 27, 54, 108, 162])), list_node([81, 27, 27, 27, 54, 54, 108, 54, 162]))\n assert is_same_list(candidate(head = list_node([123, 246, 369, 492, 615])), list_node([123, 123, 246, 123, 369, 123, 492, 123, 615]))\n assert is_same_list(candidate(head = list_node([99, 77, 55, 33, 11])), list_node([99, 11, 77, 11, 55, 11, 33, 11, 11]))\n assert is_same_list(candidate(head = list_node([300, 150, 75, 375, 1875])), list_node([300, 150, 150, 75, 75, 75, 375, 375, 1875]))\n assert is_same_list(candidate(head = list_node([441, 147, 49, 7])), list_node([441, 147, 147, 49, 49, 7, 7]))\n assert is_same_list(candidate(head = list_node([81, 27, 9, 3, 1])), list_node([81, 27, 27, 9, 9, 3, 3, 1, 1]))\n assert is_same_list(candidate(head = list_node([21, 28, 35, 42, 49, 56])), list_node([21, 7, 28, 7, 35, 7, 42, 7, 49, 7, 56]))\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().insertGreatestCommonDivisors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {", "container": "Solution", "callable": "ListNode", "parameters": [], "return_type": "class ListNode {\n * int val;\n * ListNode next;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2808, "task_id": "minimum-seconds-to-equalize-a-circular-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums containing n integers.\nAt each second, you perform the following operation on the array:\n\nFor every index i in the range [0, n - 1], replace nums[i] with either nums[i], nums[(i - 1 + n) % n], or nums[(i + 1) % n].\n\nNote that all the elements get replaced simultaneously.\nReturn the minimum number of seconds needed to make all elements in the array nums equal.\n \nExample 1:\n\nInput: nums = [1,2,1,2]\nOutput: 1\nExplanation: We can equalize the array in 1 second in the following way:\n- At 1st second, replace values at each index with [nums[3],nums[1],nums[3],nums[3]]. After replacement, nums = [2,2,2,2].\nIt can be proven that 1 second is the minimum amount of seconds needed for equalizing the array.\n\nExample 2:\n\nInput: nums = [2,1,3,3,2]\nOutput: 2\nExplanation: We can equalize the array in 2 seconds in the following way:\n- At 1st second, replace values at each index with [nums[0],nums[2],nums[2],nums[2],nums[3]]. After replacement, nums = [2,3,3,3,3].\n- At 2nd second, replace values at each index with [nums[1],nums[1],nums[2],nums[3],nums[4]]. After replacement, nums = [3,3,3,3,3].\nIt can be proven that 2 seconds is the minimum amount of seconds needed for equalizing the array.\n\nExample 3:\n\nInput: nums = [5,5,5,5]\nOutput: 0\nExplanation: We don't need to perform any operations as all elements in the initial array are the same.\n\n \nConstraints:\n\n1 <= n == nums.length <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 10, 20, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 1]) == 2\n assert candidate(nums = [10, 10, 1, 10, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 2\n assert candidate(nums = [5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [1, 1, 2, 2, 1, 1]) == 1\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 1]) == 1\n assert candidate(nums = [10, 1, 10, 1, 10]) == 1\n assert candidate(nums = [10, 10, 10, 20, 20, 10, 10, 10]) == 1\n assert candidate(nums = [3, 3, 3, 4, 4, 4, 3]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [1, 2, 1, 2]) == 1\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 2, 2]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == 3\n assert candidate(nums = [2, 1, 3, 3, 2]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == 9\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 1, 1, 2, 2]) == 8\n assert candidate(nums = [3, 2, 1, 4, 3, 2, 1, 5, 3, 2, 1, 6, 3, 2, 1, 7, 3, 2, 1, 8]) == 2\n assert candidate(nums = [5, 6, 5, 7, 5, 8, 5, 9, 5, 10]) == 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]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1]) == 2\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\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 2\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, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1]) == 3\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 3, 3, 3, 3, 3]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 1, 1]) == 8\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2]) == 1\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]) == 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, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 1\n assert candidate(nums = [100, 99, 100, 98, 100, 97, 100, 96, 100, 95, 100, 94, 100, 93, 100]) == 1\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1]) == 2\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10, 7, 7]) == 3\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 1, 1, 1]) == 8\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4]) == 3\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\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 1, 2, 2, 1, 4, 4, 4, 4, 1, 2, 2, 1]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 5\n assert candidate(nums = [8, 9, 8, 10, 8, 11, 8, 12, 8, 13, 8, 14, 8, 15, 8, 16, 8, 17, 8, 18]) == 1\n assert candidate(nums = [6, 6, 6, 6, 5, 5, 5, 5, 6, 6, 6, 6, 5, 5, 5, 5, 6, 6, 6, 6]) == 2\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, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 2\n assert candidate(nums = [9, 1, 9, 2, 9, 3, 9, 4, 9, 5, 9, 6, 9, 7, 9, 8]) == 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\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 1, 1]) == 5\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]) == 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]) == 9\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 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]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 4\n assert candidate(nums = [6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6]) == 1\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]) == 3\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7]) == 1\n assert candidate(nums = [7, 7, 1, 7, 7, 7, 7, 1, 7]) == 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]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 1, 1, 2]) == 8\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5]) == 1\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1]) == 2\n assert candidate(nums = [8, 8, 8, 7, 8, 8, 8, 7, 8, 8, 8, 7, 8, 8, 8]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 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]) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300]) == 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]) == 0\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000]) == 1\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5]) == 1\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 0, 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, 21, 22, 23, 24, 25]) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 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]) == 5\n assert candidate(nums = [7, 5, 3, 5, 7, 5, 3, 5]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30]) == 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]) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 3\n assert candidate(nums = [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]) == 2\n assert candidate(nums = [1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 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, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\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\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 5\n assert candidate(nums = [5, 1, 4, 1, 5, 1, 4, 5, 4, 5]) == 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]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 4\n assert candidate(nums = [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]) == 4\n assert candidate(nums = [1000000000, 999999999, 1000000000, 999999999, 1000000000]) == 1\n assert candidate(nums = [10, 20, 10, 30, 20, 10, 30, 20, 10]) == 1\n assert candidate(nums = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5]) == 1\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 10, 10]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 5\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 8\n assert candidate(nums = [5, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5]) == 7\n assert candidate(nums = [7, 2, 2, 7, 3, 7, 3, 3]) == 1\n assert candidate(nums = [7, 1, 5, 3, 6, 1, 5, 3, 6, 1, 5, 3, 6]) == 2\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9]) == 1\n assert candidate(nums = [9, 9, 1, 9, 9, 1, 9, 9, 1, 9, 9]) == 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]) == 2\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumSeconds", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumSeconds(List nums) {", "container": "Solution", "callable": "minimumSeconds", "parameters": [{"name": "nums", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2809, "task_id": "minimum-time-to-make-array-sum-at-most-x", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2 of equal length. Every second, for all indices 0 <= i < nums1.length, value of nums1[i] is incremented by nums2[i]. After this is done, you can do the following operation:\n\nChoose an index 0 <= i < nums1.length and make nums1[i] = 0.\n\nYou are also given an integer x.\nReturn the minimum time in which you can make the sum of all elements of nums1 to be less than or equal to x, or -1 if this is not possible.\n \nExample 1:\n\nInput: nums1 = [1,2,3], nums2 = [1,2,3], x = 4\nOutput: 3\nExplanation: \nFor the 1st second, we apply the operation on i = 0. Therefore nums1 = [0,2+2,3+3] = [0,4,6]. \nFor the 2nd second, we apply the operation on i = 1. Therefore nums1 = [0+1,0,6+3] = [1,0,9]. \nFor the 3rd second, we apply the operation on i = 2. Therefore nums1 = [1+1,0+2,0] = [2,2,0]. \nNow sum of nums1 = 4. It can be shown that these operations are optimal, so we return 3.\n\n\nExample 2:\n\nInput: nums1 = [1,2,3], nums2 = [3,3,3], x = 4\nOutput: -1\nExplanation: It can be shown that the sum of nums1 will always be greater than x, no matter which operations are performed.\n\n \nConstraints:\n\n1 <= nums1.length <= 103\n1 <= nums1[i] <= 103\n0 <= nums2[i] <= 103\nnums1.length == nums2.length\n0 <= x <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [1, 2, 3],nums2 = [1, 2, 3],x = 4) == 3\n assert candidate(nums1 = [5, 3, 8],nums2 = [2, 1, 4],x = 15) == 1\n assert candidate(nums1 = [5, 5, 5],nums2 = [1, 1, 1],x = 15) == 0\n assert candidate(nums1 = [10, 10, 10],nums2 = [0, 0, 0],x = 30) == 0\n assert candidate(nums1 = [1, 1, 1],nums2 = [0, 0, 0],x = 0) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],x = 25) == 0\n assert candidate(nums1 = [100, 200, 300],nums2 = [10, 20, 30],x = 1000) == 0\n assert candidate(nums1 = [3, 3, 3],nums2 = [1, 2, 3],x = 10) == 0\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 3, 3],x = 4) == -1\n assert candidate(nums1 = [10, 20, 30],nums2 = [0, 0, 0],x = 15) == 2\n assert candidate(nums1 = [100, 200],nums2 = [50, 100],x = 1000) == 0\n assert candidate(nums1 = [10, 20, 30],nums2 = [0, 0, 0],x = 10) == 2\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],x = 10) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2],x = 10) == 0\n assert candidate(nums1 = [2, 4, 6],nums2 = [1, 1, 1],x = 12) == 0\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [1, 2, 3, 4],x = 100) == 0\n assert candidate(nums1 = [5, 3, 1],nums2 = [2, 1, 3],x = 10) == 0\n assert candidate(nums1 = [7, 5, 3],nums2 = [2, 4, 6],x = 20) == 0\n assert candidate(nums1 = [1, 2],nums2 = [3, 4],x = 5) == 0\n assert candidate(nums1 = [3, 2, 1],nums2 = [1, 1, 1],x = 5) == 1\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5],x = 25) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],x = 4) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],x = 150) == 0\n assert candidate(nums1 = [1, 1, 1],nums2 = [1, 1, 1],x = 1) == -1\n assert candidate(nums1 = [3, 3, 3],nums2 = [1, 1, 1],x = 5) == 3\n assert candidate(nums1 = [999, 998, 997, 996, 995],nums2 = [1, 2, 3, 4, 5],x = 4500) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [5, 5, 5, 5, 5],x = 5) == 0\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [0, 0, 0, 0],x = 1000) == 0\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],x = 5) == -1\n assert candidate(nums1 = [10, 20, 30],nums2 = [1, 2, 3],x = 50) == 1\n assert candidate(nums1 = [10, 20, 30],nums2 = [0, 0, 0],x = 15) == 2\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 5000) == 1\n assert candidate(nums1 = [10, 20, 30],nums2 = [1, 2, 3],x = 60) == 0\n assert candidate(nums1 = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 50) == 10\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],x = 4) == 0\n assert candidate(nums1 = [1, 10, 100, 1000],nums2 = [1000, 100, 10, 1],x = 2000) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [9, 7, 5, 3, 1],x = 20) == -1\n assert candidate(nums1 = [50, 100, 150, 200],nums2 = [1, 2, 3, 4],x = 300) == 2\n assert candidate(nums1 = [1000, 1000, 1000],nums2 = [1, 1, 1],x = 2500) == 1\n assert candidate(nums1 = [10, 10, 10, 10, 10],nums2 = [5, 5, 5, 5, 5],x = 25) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 550) == 0\n assert candidate(nums1 = [10, 10, 10, 10],nums2 = [1, 2, 3, 4],x = 30) == 2\n assert candidate(nums1 = [5, 10, 15, 20],nums2 = [1, 1, 1, 1],x = 15) == 3\n assert candidate(nums1 = [5, 15, 25, 35, 45],nums2 = [1, 1, 1, 1, 1],x = 50) == 3\n assert candidate(nums1 = [999, 998, 997, 996, 995],nums2 = [1, 2, 3, 4, 5],x = 5000) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [10, 20, 30, 40, 50],x = 100) == 0\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],x = 100) == 0\n assert candidate(nums1 = [100, 200, 300],nums2 = [10, 20, 30],x = 1500) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],x = 5) == 0\n assert candidate(nums1 = [500, 500, 500],nums2 = [1, 1, 1],x = 1000) == 2\n assert candidate(nums1 = [1000, 1000, 1000, 1000, 1000],nums2 = [1000, 1000, 1000, 1000, 1000],x = 5000) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 1, 1, 1, 1],x = 5) == -1\n assert candidate(nums1 = [3, 6, 9],nums2 = [2, 4, 6],x = 20) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [9, 8, 7, 6, 5],x = 10) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 100) == -1\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],x = 0) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 55) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 50) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],x = 200) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [5, 4, 3, 2, 1],x = 5) == 0\n assert candidate(nums1 = [1000, 500, 250, 125, 62, 31],nums2 = [62, 31, 15, 7, 3, 1],x = 2000) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [1, 2, 3, 4, 5],x = 100) == 0\n assert candidate(nums1 = [100, 200, 300],nums2 = [10, 20, 30],x = 1000) == 0\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],x = 10) == 0\n assert candidate(nums1 = [5, 10, 15, 20],nums2 = [2, 4, 6, 8],x = 50) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [0, 0, 0, 0, 0],x = 15) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 5000) == 0\n assert candidate(nums1 = [100, 100, 100],nums2 = [50, 50, 50],x = 300) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],x = 550) == 0\n assert candidate(nums1 = [100, 200, 300],nums2 = [0, 0, 0],x = 150) == 2\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [0, 0, 0, 0, 0],x = 50) == 3\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [5, 4, 3, 2, 1],x = 50) == 3\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [1, 2, 3, 4],x = 500) == 2\n assert candidate(nums1 = [9, 9, 9, 9],nums2 = [1, 2, 3, 4],x = 50) == 0\n assert candidate(nums1 = [1000, 1000, 1000],nums2 = [1000, 1000, 1000],x = 3000) == 0\n assert candidate(nums1 = [100, 150, 200, 250, 300],nums2 = [5, 10, 15, 20, 25],x = 2000) == 0\n assert candidate(nums1 = [999, 999, 999],nums2 = [1000, 1000, 1000],x = 2997) == 0\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],x = 55) == 0\n assert candidate(nums1 = [9, 8, 7, 6, 5],nums2 = [0, 1, 2, 3, 4],x = 30) == 3\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],x = 50) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5],x = 15) == 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],x = 600) == 0\n assert candidate(nums1 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 5500) == 0\n assert candidate(nums1 = [50, 50, 50, 50],nums2 = [0, 0, 0, 0],x = 150) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],x = 20) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 4, 3, 2, 1],x = 100) == 2\n assert candidate(nums1 = [10, 20, 30],nums2 = [5, 0, 0],x = 30) == 2\n assert candidate(nums1 = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 10000) == 0\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [1, 2, 3, 4],x = 100) == 0\n assert candidate(nums1 = [10, 10, 10, 10, 10],nums2 = [0, 0, 0, 0, 0],x = 10) == 4\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3, 4, 5],x = 1500) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 4, 3, 2, 1],x = 150) == 0\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9],x = 50) == 0\n assert candidate(nums1 = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 5000) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [0, 0, 0, 0, 0],x = 150) == 0\n assert candidate(nums1 = [500, 500, 500, 500, 500],nums2 = [0, 1, 2, 3, 4],x = 2000) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],x = 50) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [0, 0, 0, 0, 1000],x = 1500) == 0\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [1, 2, 3, 4, 5],x = 150) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 5, 5, 5, 5],x = 200) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 100) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 55) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [100, 100, 100, 100, 100],x = 500) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [1, 1, 1, 1, 1],x = 50) == 2\n assert candidate(nums1 = [100, 200, 300],nums2 = [5, 10, 15],x = 600) == 0\n assert candidate(nums1 = [999, 999, 999],nums2 = [1, 1, 1],x = 2995) == 1\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],x = 500) == 1\n assert candidate(nums1 = [100, 200, 300],nums2 = [5, 10, 15],x = 500) == 1\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9],x = 45) == 0\n assert candidate(nums1 = [7, 14, 21, 28],nums2 = [1, 1, 1, 1],x = 50) == 1\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 1, 1, 1, 1],x = 1500) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "x"], "leetcode_dataset_entry_point": "Solution().minimumTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumTime(List nums1, List nums2, int x) {", "container": "Solution", "callable": "minimumTime", "parameters": [{"name": "nums1", "type": "List"}, {"name": "nums2", "type": "List"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2810, "task_id": "faulty-keyboard", "difficulty": "Easy", "problem_description": "Your laptop keyboard is faulty, and whenever you type a character 'i' on it, it reverses the string that you have written. Typing other characters works as expected.\nYou are given a 0-indexed string s, and you type each character of s using your faulty keyboard.\nReturn the final string that will be present on your laptop screen.\n \nExample 1:\n\nInput: s = \"string\"\nOutput: \"rtsng\"\nExplanation: \nAfter typing first character, the text on the screen is \"s\".\nAfter the second character, the text is \"st\". \nAfter the third character, the text is \"str\".\nSince the fourth character is an 'i', the text gets reversed and becomes \"rts\".\nAfter the fifth character, the text is \"rtsn\". \nAfter the sixth character, the text is \"rtsng\". \nTherefore, we return \"rtsng\".\n\nExample 2:\n\nInput: s = \"poiinter\"\nOutput: \"ponter\"\nExplanation: \nAfter the first character, the text on the screen is \"p\".\nAfter the second character, the text is \"po\". \nSince the third character you type is an 'i', the text gets reversed and becomes \"op\". \nSince the fourth character you type is an 'i', the text gets reversed and becomes \"po\".\nAfter the fifth character, the text is \"pon\".\nAfter the sixth character, the text is \"pont\". \nAfter the seventh character, the text is \"ponte\". \nAfter the eighth character, the text is \"ponter\". \nTherefore, we return \"ponter\".\n \nConstraints:\n\n1 <= s.length <= 100\ns consists of lowercase English letters.\ns[0] != 'i'\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"string\") == \"rtsng\"\n assert candidate(s = \"aibcdie\") == \"dcbae\"\n assert candidate(s = \"noicanoati\") == \"taonacno\"\n assert candidate(s = \"abcide\") == \"cbade\"\n assert candidate(s = \"poiinter\") == \"ponter\"\n assert candidate(s = \"abcidifgh\") == \"dabcfgh\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"iabc\") == \"abc\"\n assert candidate(s = \"abcdefghi\") == \"hgfedcba\"\n assert candidate(s = \"lowihello\") == \"wolhello\"\n assert candidate(s = \"abci\") == \"cba\"\n assert candidate(s = \"aibiciici\") == \"ccab\"\n assert candidate(s = \"iiii\") == \"\"\n assert candidate(s = \"abcidiefgh\") == \"dabcefgh\"\n assert candidate(s = \"icba\") == \"cba\"\n assert candidate(s = \"ii\") == \"\"\n assert candidate(s = \"exampleistring\") == \"rtsexampleng\"\n assert candidate(s = \"abc\") == \"abc\"\n assert candidate(s = \"abcdefgh\") == \"abcdefgh\"\n assert candidate(s = \"aibici\") == \"cab\"\n assert candidate(s = \"abcidefghi\") == \"hgfedabc\"\n assert candidate(s = \"noiidea\") == \"nodea\"\n assert candidate(s = \"iaibic\") == \"bac\"\n assert candidate(s = \"abcdefghij\") == \"hgfedcbaj\"\n assert candidate(s = \"abcdei\") == \"edcba\"\n assert candidate(s = \"thisisateststringwithmanyireversals\") == \"ynamhtrtstsetashtsngwreversals\"\n assert candidate(s = \"abcdefghiihgfedcbaabcdeffedcba\") == \"abcdefghhgfedcbaabcdeffedcba\"\n assert candidate(s = \"complexityiincreasesiiwithiiireversals\") == \"htxelpmoctyncreaseswreversals\"\n assert candidate(s = \"floccinaucinihilipilification\") == \"tacllnccolfnauchpfon\"\n assert candidate(s = \"startwithiinthemiddle\") == \"mehtnhtstartwddle\"\n assert candidate(s = \"softwaredevelopmentiitheory\") == \"softwaredevelopmenttheory\"\n assert candidate(s = \"iinnoouuttffyycckkhhhgggeee\") == \"nnoouuttffyycckkhhhgggeee\"\n assert candidate(s = \"palindromelevel\") == \"lapndromelevel\"\n assert candidate(s = \"endwithiiiiiiiiiiiiiiiiii\") == \"wdneth\"\n assert candidate(s = \"nestedireversalsiiii\") == \"detsenreversals\"\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydogi\") == \"godyzalehtrevospmujxofnworbkcaqu\"\n assert candidate(s = \"abracadabra\") == \"abracadabra\"\n assert candidate(s = \"pythonprogramming\") == \"mmargorpnohtypng\"\n assert candidate(s = \"programmingiisfun\") == \"mmargorpngsfun\"\n assert candidate(s = \"iiiiiii\") == \"\"\n assert candidate(s = \"xylophoneix\") == \"enohpolyxx\"\n assert candidate(s = \"iiireversalsnestedinsideiiiii\") == \"eddetsenslasreverns\"\n assert candidate(s = \"longstringwithseveralireversalsandmorecharacters\") == \"lareveshtrtsgnolngwreversalsandmorecharacters\"\n assert candidate(s = \"trickytongueiishere\") == \"rtckytongueshere\"\n assert candidate(s = \"randomcharacterswithiabcdefghijklmnopqrstuvwxyz\") == \"hgfedcbawsretcarahcmodnarthjklmnopqrstuvwxyz\"\n assert candidate(s = \"longstringwithnointerference\") == \"onhtrtsgnolngwnterference\"\n assert candidate(s = \"singleireversal\") == \"elgnsreversal\"\n assert candidate(s = \"datastructuresiiialgorithms\") == \"rogladatastructuresthms\"\n assert candidate(s = \"thisisaverylongstringthatneedstobechecked\") == \"rtsgnolyrevashtsngthatneedstobechecked\"\n assert candidate(s = \"algorithmisawesome\") == \"mhtalgorsawesome\"\n assert candidate(s = \"interview\") == \"vretnew\"\n assert candidate(s = \"almostdone\") == \"almostdone\"\n assert candidate(s = \"imississippi\") == \"ppssmss\"\n assert candidate(s = \"racecariispeedoomeokarttercecar\") == \"racecarspeedoomeokarttercecar\"\n assert candidate(s = \"reverseiiiandthencontinue\") == \"tnocnehtdnareversenue\"\n assert candidate(s = \"abcdefghijiiiiiiiiiiiiiijklmnopqrstuvwxyz\") == \"hgfedcbajjklmnopqrstuvwxyz\"\n assert candidate(s = \"algorithmiiengineering\") == \"reenroglathmengng\"\n assert candidate(s = \"xylophoneiikeyboard\") == \"xylophonekeyboard\"\n assert candidate(s = \"almostmiintrandomiisequence\") == \"almostmntrandomsequence\"\n assert candidate(s = \"aaaaaaaaaaibbbbbbbbbaaaaaaaaaa\") == \"aaaaaaaaaabbbbbbbbbaaaaaaaaaa\"\n assert candidate(s = \"algorithm\") == \"roglathm\"\n assert candidate(s = \"simpletestcase\") == \"smpletestcase\"\n assert candidate(s = \"aaaaabbbbccccdddd\") == \"aaaaabbbbccccdddd\"\n assert candidate(s = \"redder\") == \"redder\"\n assert candidate(s = \"reverseeveryithirdcharacter\") == \"htreverseeveryrdcharacter\"\n assert candidate(s = \"intermittent\") == \"mretnttent\"\n assert candidate(s = \"supercalifragilisticexpialidocious\") == \"codpxecllacrepusfragstalous\"\n assert candidate(s = \"abcdefghiijklmnopqrstuvwxyz\") == \"abcdefghjklmnopqrstuvwxyz\"\n assert candidate(s = \"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == \"\"\n assert candidate(s = \"nestedreversalsiiinesting\") == \"tsennestedreversalsng\"\n assert candidate(s = \"iiiiiiiiiii\") == \"\"\n assert candidate(s = \"onetwothreefourfiveisixseveneightnine\") == \"nthgsfruofeerhtowtenovexsevenene\"\n assert candidate(s = \"withmultipleis\") == \"elpwthmults\"\n assert candidate(s = \"nestedintegers\") == \"detsenntegers\"\n assert candidate(s = \"reversal\") == \"reversal\"\n assert candidate(s = \"reversingireversibility\") == \"lsreversreverngbty\"\n assert candidate(s = \"abcdefghiiiiiiiiiijklmnopqrstuvwxyz\") == \"abcdefghjklmnopqrstuvwxyz\"\n assert candidate(s = \"iiiiiiiii\") == \"\"\n assert candidate(s = \"sequenceofireversalsii\") == \"foecneuqesreversals\"\n assert candidate(s = \"abcdefghijiklmnopqrstuvwxyziiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijklmnopqrstuvwxyz\") == \"jabcdefghklmnopqrstuvwxyzjklmnopqrstuvwxyz\"\n assert candidate(s = \"thisstringhasiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiinside\") == \"snsahgnhtsstrde\"\n assert candidate(s = \"abcdefghijiklmnopqrstuvwxyz\") == \"jabcdefghklmnopqrstuvwxyz\"\n assert candidate(s = \"twofour\") == \"twofour\"\n assert candidate(s = \"aiaiaiaiaiaiaiai\") == \"aaaaaaaa\"\n assert candidate(s = \"reverseeveryiinthisstring\") == \"rtssreverseeverynthng\"\n assert candidate(s = \"complexityincreaseswithmoreireversals\") == \"eromhtytcomplexncreaseswreversals\"\n assert candidate(s = \"thisisnotsoeasyasitis\") == \"tsthsnotsoeasyass\"\n assert candidate(s = \"nnnnmmmmlllkkkjjjiiihgfedcbaiiijjkkllmmnn\") == \"abcdefghnnnnmmmmlllkkkjjjjjkkllmmnn\"\n assert candidate(s = \"faultykeyboardstests\") == \"faultykeyboardstests\"\n assert candidate(s = \"onlyonei\") == \"enoylno\"\n assert candidate(s = \"specialcharactersarefun\") == \"cepsalcharactersarefun\"\n assert candidate(s = \"intermittentireversalsiiii\") == \"tnettntermreversals\"\n assert candidate(s = \"mississippiii\") == \"ppssmss\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == \"hhhgggfffeeedddcccbbbaaajjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\"\n assert candidate(s = \"icancodeinpython\") == \"edocnacnpython\"\n assert candidate(s = \"thisisaverylongstringthatwilltestthealgorithm\") == \"roglaehttsetllrtsgnolyrevashtsngthatwthm\"\n assert candidate(s = \"singleiiiiiiiiiii\") == \"elgns\"\n assert candidate(s = \"aibohphobia\") == \"bohphobaa\"\n assert candidate(s = \"aaaaaaaaiiiiiii\") == \"aaaaaaaa\"\n assert candidate(s = \"debuggingiiibugs\") == \"gndebuggbugs\"\n assert candidate(s = \"complexstringwithmultipleiiiiinversions\") == \"srevntlumhtrtsxelpmocngwpleons\"\n assert candidate(s = \"level\") == \"level\"\n assert candidate(s = \"thisisaverylongstringwithmultipleireversals\") == \"elpwgnsthsaverylongstrthmultreversals\"\n assert candidate(s = \"interviewi\") == \"wenterv\"\n assert candidate(s = \"backtothebeginning\") == \"nnbacktothebegng\"\n assert candidate(s = \"mixedwithiandothercharacters\") == \"htmxedwandothercharacters\"\n assert candidate(s = \"aibohphobiai\") == \"aabohphob\"\n assert candidate(s = \"complexityiiis\") == \"ytcomplexs\"\n assert candidate(s = \"almostdoneii\") == \"almostdone\"\n assert candidate(s = \"mississippiiiiii\") == \"ssmsspp\"\n assert candidate(s = \"aaaaabbbbccccddddiiii\") == \"aaaaabbbbccccdddd\"\n assert candidate(s = \"abcdefghiihgfedcbaiiijjkkllmmnn\") == \"abcdefghhgfedcbajjkkllmmnn\"\n assert candidate(s = \"ireversalatthestart\") == \"reversalatthestart\"\n assert candidate(s = \"abcdefghiabcdefghi\") == \"hgfedcbaabcdefgh\"\n assert candidate(s = \"initialization\") == \"taztnalon\"\n assert candidate(s = \"bananaananab\") == \"bananaananab\"\n assert candidate(s = \"congratulations\") == \"talutargnocons\"\n assert candidate(s = \"nointerruptshere\") == \"onnterruptshere\"\n assert candidate(s = \"endwithiiiiireversal\") == \"htendwreversal\"\n assert candidate(s = \"abcdefghijkilmnopqrstuvwtuvrqpomnlijkihgfedcba\") == \"kjkjabcdefghlmnopqrstuvwtuvrqpomnlhgfedcba\"\n assert candidate(s = \"complexstringwithiiiiiiiiiii\") == \"htrtsxelpmocngw\"\n assert candidate(s = \"mammaiamamma\") == \"ammamamamma\"\n assert candidate(s = \"introductiontoalgorithm\") == \"roglaotnontroductthm\"\n assert candidate(s = \"reversethisplease\") == \"htesreversplease\"\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydogii\") == \"uqackbrownfoxjumpsoverthelazydog\"\n assert candidate(s = \"multipleiiireversalsinbetween\") == \"slasrevertlumplenbetween\"\n assert candidate(s = \"multipeiiiiiinsersions\") == \"sresnepmultons\"\n assert candidate(s = \"performanceiiioptimization\") == \"taztpoperformancemon\"\n assert candidate(s = \"endingwithi\") == \"htdnengw\"\n assert candidate(s = \"iinbetweeni\") == \"neewtebn\"\n assert candidate(s = \"noireversals\") == \"onreversals\"\n assert candidate(s = \"reversalsarefun\") == \"reversalsarefun\"\n assert candidate(s = \"sequenceiiwithiiiiiiiiiinterspersediiiis\") == \"wecneuqesthntersperseds\"\n assert candidate(s = \"mixandmatchi\") == \"hctamdnaxm\"\n assert candidate(s = \"programmingii\") == \"mmargorpng\"\n assert candidate(s = \"multipleiiiiireversals\") == \"elpmultreversals\"\n assert candidate(s = \"thisisaverylongstringwithoutianyireversals\") == \"ynawgnsthsaverylongstrthoutreversals\"\n assert candidate(s = \"xyzzzyxzyzyzyzzyxzyzyzyz\") == \"xyzzzyxzyzyzyzzyxzyzyzyz\"\n assert candidate(s = \"verylongstringwithrandomcharactersandiiiiiiiiiintersions\") == \"sretndnasretcarahcmodnarhtrtsgnolyrevngwons\"\n assert candidate(s = \"thisisaverylongstringwithmanyireversals\") == \"ynamhtrtsgnolyrevashtsngwreversals\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhjjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"abcdefghiiihgfedcbaiiijjkkllmmnniiihgfedcba\") == \"nnmmllkkjjhgfedcbahgfedcbahgfedcba\"\n assert candidate(s = \"interviewinterview\") == \"vretnvretnewew\"\n assert candidate(s = \"oneletter\") == \"oneletter\"\n assert candidate(s = \"nestedinversionexampleiiii\") == \"srevnnestedonexample\"\n assert candidate(s = \"deified\") == \"fdeed\"\n assert candidate(s = \"abcdefghiijiklmnopqrstuvwxyz\") == \"jhgfedcbaklmnopqrstuvwxyz\"\n assert candidate(s = \"iiiiiiiiiiiibbbbbbbbbbcccccccccceeeeeeeeee\") == \"bbbbbbbbbbcccccccccceeeeeeeeee\"\n assert candidate(s = \"thisisaverylongstringwithsomeireversalsintheend\") == \"slasreverwgnsthsaverylongstrthsomentheend\"\n assert candidate(s = \"programmingchallengesarefun\") == \"mmargorpngchallengesarefun\"\n assert candidate(s = \"nolemonnomelon\") == \"nolemonnomelon\"\n assert candidate(s = \"nestediinici\") == \"cnestedn\"\n assert candidate(s = \"continuousintegration\") == \"targetntnocnuouson\"\n assert candidate(s = \"iiiiiiii\") == \"\"\n assert candidate(s = \"intermixedcharacters\") == \"mretnxedcharacters\"\n assert candidate(s = \"racecar\") == \"racecar\"\n assert candidate(s = \"abracaicabracai\") == \"acarbacabraca\"\n assert candidate(s = \"quickbrownfoxjumpsovertheilazydog\") == \"ehtrevospmujxofnworbkcqulazydog\"\n assert candidate(s = \"iiiiiiiiii\") == \"\"\n assert candidate(s = \"abcdefghiihgfedcba\") == \"abcdefghhgfedcba\"\n assert candidate(s = \"abcdefghiihgfedcbaabcdefghiihgfedcba\") == \"abcdefghhgfedcbaabcdefghhgfedcba\"\n assert candidate(s = \"nestedinversionswithinstrings\") == \"rtsnwsnodetsennversthngs\"\n assert candidate(s = \"thisisatestoftheinputstring\") == \"rtstupnsthsatestoftheng\"\n assert candidate(s = \"intermittentinversionsareconfusing\") == \"sufnocerasnotnettntermnversng\"\n assert candidate(s = \"intermittentireversalsiiiiiintermittent\") == \"mretnslasrevermretnttentttent\"\n assert candidate(s = \"mississippi\") == \"ppssmss\"\n assert candidate(s = \"incomprehensibility\") == \"lsneherpmocnbty\"\n assert candidate(s = \"iiiii\") == \"\"\n assert candidate(s = \"shortiiilong\") == \"trohslong\"\n assert candidate(s = \"reversemeifoundyou\") == \"emesreverfoundyou\"\n assert candidate(s = \"reversethisstring\") == \"rtssreversethng\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().finalString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String finalString(String s) {", "container": "Solution", "callable": "finalString", "parameters": [{"name": "s", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2811, "task_id": "check-if-it-is-possible-to-split-array", "difficulty": "Medium", "problem_description": "You are given an array nums of length n and an integer m. You need to determine if it is possible to split the array into n arrays of size 1 by performing a series of steps.\nAn array is called good if:\n\nThe length of the array is one, or\nThe sum of the elements of the array is greater than or equal to m.\n\nIn each step, you can select an existing array (which may be the result of previous steps) with a length of at least two and split it into two arrays, if both resulting arrays are good.\nReturn true if you can split the given array into n arrays, otherwise return false.\n \nExample 1:\n\nInput: nums = [2, 2, 1], m = 4\nOutput: true\nExplanation:\n\nSplit [2, 2, 1] to [2, 2] and [1]. The array [1] has a length of one, and the array [2, 2] has the sum of its elements equal to 4 >= m, so both are good arrays.\nSplit [2, 2] to [2] and [2]. both arrays have the length of one, so both are good arrays.\n\n\nExample 2:\n\nInput: nums = [2, 1, 3], m = 5\nOutput: false\nExplanation:\nThe first move has to be either of the following:\n\nSplit [2, 1, 3] to [2, 1] and [3]. The array [2, 1] has neither length of one nor sum of elements greater than or equal to m.\nSplit [2, 1, 3] to [2] and [1, 3]. The array [1, 3] has neither length of one nor sum of elements greater than or equal to m.\n\nSo as both moves are invalid (they do not divide the array into two good arrays), we are unable to split nums into n arrays of size 1.\n\nExample 3:\n\nInput: nums = [2, 3, 3, 2, 3], m = 6\nOutput: true\nExplanation:\n\nSplit [2, 3, 3, 2, 3] to [2] and [3, 3, 2, 3].\nSplit [3, 3, 2, 3] to [3, 3, 2] and [3].\nSplit [3, 3, 2] to [3, 3] and [2].\nSplit [3, 3] to [3] and [3].\n\n\n \nConstraints:\n\n1 <= n == nums.length <= 100\n1 <= nums[i] <= 100\n1 <= m <= 200\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40],m = 50) == True\n assert candidate(nums = [2, 3, 3, 2, 3],m = 6) == True\n assert candidate(nums = [50, 50],m = 100) == True\n assert candidate(nums = [1, 2, 3, 4, 5],m = 9) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1],m = 2) == True\n assert candidate(nums = [2, 1, 3],m = 5) == False\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],m = 20) == True\n assert candidate(nums = [1, 2, 3, 4, 5],m = 10) == False\n assert candidate(nums = [1, 1, 1, 1],m = 2) == True\n assert candidate(nums = [100, 100],m = 150) == True\n assert candidate(nums = [10, 20, 30, 40, 50],m = 60) == True\n assert candidate(nums = [1, 100, 1, 1, 1],m = 101) == True\n assert candidate(nums = [2, 2, 1],m = 4) == True\n assert candidate(nums = [50, 50, 50, 50],m = 100) == True\n assert candidate(nums = [100, 100, 100],m = 200) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 15) == True\n assert candidate(nums = [100],m = 100) == True\n assert candidate(nums = [5, 5, 5, 5, 5],m = 10) == True\n assert candidate(nums = [50, 50, 50],m = 100) == True\n assert candidate(nums = [1, 1, 1, 1, 1],m = 2) == True\n assert candidate(nums = [5, 5, 5, 5, 5],m = 15) == False\n assert candidate(nums = [10, 20, 30],m = 15) == 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],m = 10) == True\n assert candidate(nums = [10, 20, 30, 40],m = 35) == True\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 102) == False\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],m = 210) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],m = 10) == 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],m = 35) == True\n assert candidate(nums = [90, 10, 10, 10, 10, 10, 10, 10, 10, 10],m = 20) == 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],m = 2) == True\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765],m = 1000) == True\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 101) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],m = 25) == True\n assert candidate(nums = [33, 33, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33],m = 66) == True\n assert candidate(nums = [50, 40, 30, 20, 10, 15, 25, 35, 45, 55],m = 75) == 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],m = 10) == True\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],m = 30) == True\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, 2],m = 3) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 25) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 5) == False\n assert candidate(nums = [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],m = 5) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2) == True\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],m = 99) == True\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],m = 101) == True\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],m = 180) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 180) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == True\n assert candidate(nums = [99, 1, 99, 1, 99, 1, 99, 1, 99],m = 198) == False\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],m = 10) == True\n assert candidate(nums = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50],m = 60) == 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],m = 30) == True\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],m = 190) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 100) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 300) == 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],m = 30) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 9) == 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],m = 100) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2) == 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, 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],m = 99) == 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],m = 50) == True\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],m = 6) == 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],m = 55) == True\n assert candidate(nums = [99, 1, 99, 1, 99, 1, 99, 1, 99, 1],m = 198) == 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, 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],m = 3) == 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],m = 20) == True\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],m = 200) == True\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100],m = 140) == True\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5],m = 60) == True\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],m = 5) == True\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],m = 30) == True\n assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],m = 100) == True\n assert candidate(nums = [99, 1, 99, 1, 99, 1, 99, 1, 99, 1],m = 100) == True\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 101) == True\n assert candidate(nums = [99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99],m = 100) == 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, 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],m = 3) == True\n assert candidate(nums = [50, 50, 1, 50, 50, 1, 50, 50, 1, 50, 50, 1, 50, 50, 1, 50, 50, 1, 50, 50],m = 99) == True\n assert candidate(nums = [10, 20, 10, 20, 10],m = 20) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 4) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 18) == 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],m = 10) == True\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30],m = 60) == True\n assert candidate(nums = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711],m = 3000) == True\n assert candidate(nums = [50, 25, 25, 50, 25, 25, 50],m = 75) == True\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],m = 100) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2) == 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],m = 25) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2) == True\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],m = 10) == True\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],m = 199) == 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],m = 10) == True\n assert candidate(nums = [99, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 99],m = 199) == False\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 39) == True\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],m = 5) == True\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],m = 50) == True\n assert candidate(nums = [20, 10, 10, 30, 20, 10, 10, 40, 30, 10],m = 35) == True\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],m = 99) == True\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],m = 100) == 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],m = 20) == True\n assert candidate(nums = [100, 1, 1, 1, 100],m = 101) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2) == True\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],m = 199) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 150) == True\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],m = 30) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 20) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 200) == 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, 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],m = 150) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 190) == 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],m = 9) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 15) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],m = 30) == True\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],m = 190) == 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],m = 115) == True\n"}, "metadata": {"canonical_parameter_names": ["nums", "m"], "leetcode_dataset_entry_point": "Solution().canSplitArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean canSplitArray(List nums, int m) {", "container": "Solution", "callable": "canSplitArray", "parameters": [{"name": "nums", "type": "List"}, {"name": "m", "type": "int"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2812, "task_id": "find-the-safest-path-in-a-grid", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D matrix grid of size n x n, where (r, c) represents:\n\nA cell containing a thief if grid[r][c] = 1\nAn empty cell if grid[r][c] = 0\n\nYou are initially positioned at cell (0, 0). In one move, you can move to any adjacent cell in the grid, including cells containing thieves.\nThe safeness factor of a path on the grid is defined as the minimum manhattan distance from any cell in the path to any thief in the grid.\nReturn the maximum safeness factor of all paths leading to cell (n - 1, n - 1).\nAn adjacent cell of cell (r, c), is one of the cells (r, c + 1), (r, c - 1), (r + 1, c) and (r - 1, c) if it exists.\nThe Manhattan distance between two cells (a, b) and (x, y) is equal to |a - x| + |b - y|, where |val| denotes the absolute value of val.\n \nExample 1:\n\n\nInput: grid = [[1,0,0],[0,0,0],[0,0,1]]\nOutput: 0\nExplanation: All paths from (0, 0) to (n - 1, n - 1) go through the thieves in cells (0, 0) and (n - 1, n - 1).\n\nExample 2:\n\n\nInput: grid = [[0,0,1],[0,0,0],[0,0,0]]\nOutput: 2\nExplanation: The path depicted in the picture above has a safeness factor of 2 since:\n- The closest cell of the path to the thief at cell (0, 2) is cell (0, 0). The distance between them is | 0 - 0 | + | 0 - 2 | = 2.\nIt can be shown that there are no other paths with a higher safeness factor.\n\nExample 3:\n\n\nInput: grid = [[0,0,0,1],[0,0,0,0],[0,0,0,0],[1,0,0,0]]\nOutput: 2\nExplanation: The path depicted in the picture above has a safeness factor of 2 since:\n- The closest cell of the path to the thief at cell (0, 3) is cell (1, 2). The distance between them is | 0 - 1 | + | 3 - 2 | = 2.\n- The closest cell of the path to the thief at cell (3, 0) is cell (3, 2). The distance between them is | 3 - 3 | + | 0 - 2 | = 2.\nIt can be shown that there are no other paths with a higher safeness factor.\n\n \nConstraints:\n\n1 <= grid.length == n <= 400\ngrid[i].length == n\ngrid[i][j] is either 0 or 1.\nThere is at least one thief in the grid.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 0, 1], [0, 0, 0], [0, 0, 0]]) == 2\n assert candidate(grid = [[1, 0, 0], [0, 0, 0], [0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1], [0, 0, 0], [1, 0, 1]]) == 0\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, 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, 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]]) == 2\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]]) == 0\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], [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\n assert candidate(grid = [[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], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 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, 1, 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, 1]]) == 0\n assert candidate(grid = [[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, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 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(grid = [[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, 1], [0, 0, 0, 1, 0, 0]]) == 1\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, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 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, 1]]) == 0\n assert candidate(grid = [[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, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 1, 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, 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, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[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, 1]]) == 0\n assert candidate(grid = [[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], [1, 0, 0, 0, 0, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 0, 1, 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, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[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], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[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, 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, 1]]) == 0\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, 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, 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]]) == 4\n assert candidate(grid = [[0, 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, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 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, 0]]) == 1\n assert candidate(grid = [[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, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 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, 1, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 1, 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\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, 0, 0, 0, 1, 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, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 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\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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\n assert candidate(grid = [[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]]) == 15\n assert candidate(grid = [[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, 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, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 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\n assert candidate(grid = [[0, 0, 0, 0, 0, 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], [1, 0, 0, 0, 0, 0]]) == 2\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, 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, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 2\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, 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, 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, 0, 0, 0, 0, 0]]) == 3\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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [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]]) == 6\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], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 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, 1]]) == 0\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, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 0\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, 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, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 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, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 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], [1, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[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], [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, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 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, 0, 0, 0, 0, 0, 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, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[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, 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, 1]]) == 0\n assert candidate(grid = [[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, 1]]) == 0\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, 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, 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, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[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, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\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, 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, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[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], [1, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[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], [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, 1, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[0, 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, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\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, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[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, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 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, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 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\n assert candidate(grid = [[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, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0]]) == 1\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], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 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, 0, 0, 1, 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]]) == 1\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, 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], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [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, 1, 1, 0, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\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, 0, 0], [0, 0, 0, 1, 0, 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], [1, 0, 0, 0, 0, 0, 0, 0]]) == 2\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maximumSafenessFactor", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumSafenessFactor(List> grid) {", "container": "Solution", "callable": "maximumSafenessFactor", "parameters": [{"name": "grid", "type": "List>"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2813, "task_id": "maximum-elegance-of-a-k-length-subsequence", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array items of length n and an integer k.\nitems[i] = [profiti, categoryi], where profiti and categoryi denote the profit and category of the ith item respectively.\nLet's define the elegance of a subsequence of items as total_profit + distinct_categories2, where total_profit is the sum of all profits in the subsequence, and distinct_categories is the number of distinct categories from all the categories in the selected subsequence.\nYour task is to find the maximum elegance from all subsequences of size k in items.\nReturn an integer denoting the maximum elegance of a subsequence of items with size exactly k.\nNote: A subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order.\n \nExample 1:\n\nInput: items = [[3,2],[5,1],[10,1]], k = 2\nOutput: 17\nExplanation: In this example, we have to select a subsequence of size 2.\nWe can select items[0] = [3,2] and items[2] = [10,1].\nThe total profit in this subsequence is 3 + 10 = 13, and the subsequence contains 2 distinct categories [2,1].\nHence, the elegance is 13 + 22 = 17, and we can show that it is the maximum achievable elegance. \n\nExample 2:\n\nInput: items = [[3,1],[3,1],[2,2],[5,3]], k = 3\nOutput: 19\nExplanation: In this example, we have to select a subsequence of size 3. \nWe can select items[0] = [3,1], items[2] = [2,2], and items[3] = [5,3]. \nThe total profit in this subsequence is 3 + 2 + 5 = 10, and the subsequence contains 3 distinct categories [1,2,3]. \nHence, the elegance is 10 + 32 = 19, and we can show that it is the maximum achievable elegance.\nExample 3:\n\nInput: items = [[1,1],[2,1],[3,1]], k = 3\nOutput: 7\nExplanation: In this example, we have to select a subsequence of size 3. \nWe should select all the items. \nThe total profit will be 1 + 2 + 3 = 6, and the subsequence contains 1 distinct category [1]. \nHence, the maximum elegance is 6 + 12 = 7. \n \nConstraints:\n\n1 <= items.length == n <= 105\nitems[i].length == 2\nitems[i][0] == profiti\nitems[i][1] == categoryi\n1 <= profiti <= 109\n1 <= categoryi <= n \n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(items = [[10, 1], [9, 1], [8, 1], [7, 1], [6, 1]],k = 2) == 20\n assert candidate(items = [[9, 1], [7, 2], [5, 3], [3, 4], [1, 5]],k = 4) == 40\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],k = 3) == 129\n assert candidate(items = [[5, 1], [6, 2], [7, 3], [8, 4]],k = 4) == 42\n assert candidate(items = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996]],k = 4) == 30\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],k = 5) == 175\n assert candidate(items = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],k = 5) == 1525\n assert candidate(items = [[5, 1], [7, 2], [3, 2], [8, 3], [6, 3]],k = 3) == 29\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 3) == 12\n assert candidate(items = [[5, 1], [5, 1], [5, 1], [5, 2], [5, 2], [5, 3]],k = 4) == 29\n assert candidate(items = [[1000000000, 1], [1000000000, 2], [1000000000, 3], [1000000000, 4], [1000000000, 5]],k = 5) == 5000000025\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],k = 3) == 33\n assert candidate(items = [[3, 2], [5, 1], [10, 1]],k = 2) == 17\n assert candidate(items = [[1, 1], [2, 1], [3, 1]],k = 3) == 7\n assert candidate(items = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],k = 4) == 1416\n assert candidate(items = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],k = 3) == 21\n assert candidate(items = [[10, 5], [10, 5], [10, 5], [10, 5], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9]],k = 5) == 75\n assert candidate(items = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],k = 2) == 10\n assert candidate(items = [[1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000]],k = 3) == 13\n assert candidate(items = [[3, 1], [3, 1], [2, 2], [5, 3]],k = 3) == 19\n assert candidate(items = [[5, 5], [5, 5], [5, 5], [5, 5]],k = 2) == 11\n assert candidate(items = [[1, 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]],k = 3) == 12\n assert candidate(items = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]],k = 5) == 4025\n assert candidate(items = [[100, 1], [90, 1], [80, 2], [70, 2], [60, 3], [50, 3], [40, 3], [30, 4], [20, 4], [10, 4]],k = 3) == 274\n assert candidate(items = [[100, 1], [90, 1], [80, 1], [70, 1], [60, 1], [50, 2], [40, 2], [30, 2], [20, 2], [10, 2]],k = 5) == 401\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 5) == 65\n assert candidate(items = [[100, 10], [90, 9], [80, 8], [70, 7], [60, 6], [50, 5], [40, 4], [30, 3], [20, 2], [10, 1], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],k = 8) == 584\n assert candidate(items = [[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]],k = 5) == 30\n assert candidate(items = [[1000000000, 1], [2000000000, 2], [3000000000, 3], [4000000000, 4], [5000000000, 5], [6000000000, 6], [7000000000, 7], [8000000000, 8], [9000000000, 9], [10000000000, 10]],k = 5) == 40000000025\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [10, 1], [20, 2], [30, 3], [40, 4]],k = 10) == 661\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],k = 10) == 650\n assert candidate(items = [[9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 2], [3, 2], [2, 2], [1, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3], [10, 4]],k = 10) == 94\n assert candidate(items = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 15) == 160\n assert candidate(items = [[5, 3], [10, 2], [15, 1], [20, 3], [25, 2], [30, 1], [35, 4]],k = 4) == 126\n assert candidate(items = [[1000000000, 1], [1000000000, 2], [1000000000, 1], [1000000000, 2], [1000000000, 1], [1000000000, 2], [1000000000, 1], [1000000000, 2], [1000000000, 1], [1000000000, 2]],k = 5) == 5000000004\n assert candidate(items = [[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]],k = 7) == 98\n assert candidate(items = [[100, 1], [200, 2], [300, 1], [400, 2], [500, 3], [600, 3], [700, 4], [800, 4], [900, 5]],k = 6) == 3916\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],k = 15) == 1074\n assert candidate(items = [[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, 1]],k = 10) == 155\n assert candidate(items = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],k = 5) == 65\n assert candidate(items = [[1000000000, 1], [900000000, 1], [800000000, 2], [700000000, 2], [600000000, 3], [500000000, 3], [400000000, 3], [300000000, 4], [200000000, 4], [100000000, 4]],k = 3) == 2700000004\n assert candidate(items = [[10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2]],k = 5) == 43\n assert candidate(items = [[5, 1], [5, 1], [5, 1], [5, 1], [5, 1], [5, 2], [5, 2], [5, 2], [5, 2], [5, 2], [5, 3], [5, 3], [5, 3], [5, 3], [5, 3]],k = 10) == 59\n assert candidate(items = [[50, 1], [40, 1], [30, 1], [20, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [50, 3], [40, 3], [30, 3], [20, 3], [10, 3]],k = 5) == 214\n assert candidate(items = [[10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [10, 2], [10, 3], [10, 3], [10, 3], [10, 4]],k = 4) == 56\n assert candidate(items = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 1], [3, 2], [2, 3], [1, 4], [9, 5]],k = 7) == 73\n assert candidate(items = [[1000000000, 1], [1000000000, 2], [1000000000, 3], [1000000000, 4], [1000000000, 5], [1000000000, 6], [1000000000, 7], [1000000000, 8], [1000000000, 9], [1000000000, 10]],k = 5) == 5000000025\n assert candidate(items = [[50, 1], [40, 2], [30, 3], [20, 4], [10, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],k = 5) == 175\n assert candidate(items = [[5, 1], [7, 2], [9, 3], [10, 2], [12, 1], [15, 4], [18, 5], [20, 1]],k = 5) == 97\n assert candidate(items = [[5, 1], [5, 1], [5, 1], [5, 1], [5, 1], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [15, 3], [15, 3], [15, 3], [15, 3], [15, 3]],k = 5) == 76\n assert candidate(items = [[5, 1], [10, 1], [15, 1], [20, 1], [25, 1], [30, 1], [35, 1], [40, 1], [45, 1], [50, 1], [5, 2], [10, 2], [15, 2], [20, 2], [25, 2], [30, 2], [35, 2], [40, 2], [45, 2], [50, 2]],k = 10) == 404\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],k = 10) == 155\n assert candidate(items = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],k = 15) == 594\n assert candidate(items = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 1], [700, 2], [800, 3], [900, 4], [1000, 5]],k = 7) == 4925\n assert candidate(items = [[100, 1], [90, 1], [80, 1], [70, 1], [60, 1], [50, 2], [40, 2], [30, 2], [20, 2], [10, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3]],k = 6) == 454\n assert candidate(items = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 10], [65, 20], [75, 30], [85, 40], [95, 50]],k = 6) == 445\n assert candidate(items = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],k = 3) == 39\n assert candidate(items = [[100, 1], [90, 2], [80, 3], [70, 4], [60, 5], [50, 6], [40, 7], [30, 8], [20, 9], [10, 10]],k = 7) == 539\n assert candidate(items = [[1, 1], [2, 1], [3, 1], [4, 2], [5, 2], [6, 2], [7, 3], [8, 3], [9, 3], [10, 4], [11, 4], [12, 4], [13, 5], [14, 5], [15, 5]],k = 7) == 97\n assert candidate(items = [[1, 1], [2, 1], [3, 1], [4, 2], [5, 2], [6, 2], [7, 3], [8, 3], [9, 3], [10, 4], [11, 4], [12, 4], [13, 5], [14, 5], [15, 5], [16, 6], [17, 6], [18, 6], [19, 7], [20, 7], [21, 7]],k = 10) == 189\n assert candidate(items = [[10, 1], [20, 1], [30, 1], [40, 2], [50, 2], [60, 2], [70, 3], [80, 3], [90, 3], [100, 4]],k = 7) == 499\n assert candidate(items = [[1, 1], [2, 1], [3, 1], [4, 2], [5, 2], [6, 2], [7, 3], [8, 3], [9, 3], [10, 4]],k = 4) == 44\n assert candidate(items = [[5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [10, 2], [9, 2], [8, 2], [7, 2], [6, 2]],k = 5) == 43\n assert candidate(items = [[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4], [5, 5], [5, 5]],k = 6) == 45\n assert candidate(items = [[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]],k = 15) == 345\n assert candidate(items = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10], [10, 1], [9, 2], [8, 3], [7, 4], [6, 5]],k = 8) == 116\n assert candidate(items = [[500, 1], [400, 1], [300, 1], [200, 1], [100, 1], [500, 2], [400, 2], [300, 2], [200, 2], [100, 2], [500, 3], [400, 3], [300, 3], [200, 3], [100, 3]],k = 8) == 3309\n assert candidate(items = [[1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3]],k = 3) == 15\n assert candidate(items = [[10, 1], [20, 1], [30, 2], [40, 2], [50, 3], [60, 3], [70, 4], [80, 4], [90, 5], [100, 5], [110, 6], [120, 6], [130, 7], [140, 7], [150, 8], [160, 8], [170, 9], [180, 9], [190, 10], [200, 10]],k = 15) == 2014\n assert candidate(items = [[100, 1], [90, 1], [80, 1], [70, 1], [60, 1], [50, 2], [40, 2], [30, 2], [20, 2], [10, 2]],k = 4) == 341\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 5) == 30\n assert candidate(items = [[5, 1], [5, 1], [5, 1], [5, 1], [5, 1], [5, 2], [5, 2], [5, 2], [5, 2], [5, 2]],k = 3) == 19\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == 110\n assert candidate(items = [[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]],k = 15) == 295\n assert candidate(items = [[3, 1], [5, 2], [7, 3], [9, 4], [11, 5], [13, 1], [15, 2], [17, 3], [19, 4], [21, 5]],k = 5) == 110\n assert candidate(items = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [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) == 11\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],k = 5) == 425\n assert candidate(items = [[100, 1], [90, 2], [80, 3], [70, 4], [60, 5], [50, 6], [40, 7], [30, 8], [20, 9], [10, 10]],k = 3) == 279\n assert candidate(items = [[100, 1], [90, 1], [80, 1], [70, 1], [60, 1], [50, 1], [40, 1], [30, 1], [20, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],k = 15) == 594\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 1], [50, 2], [60, 3], [70, 4], [80, 5], [90, 4], [100, 5], [110, 6], [120, 7], [130, 8], [140, 9], [150, 10]],k = 8) == 969\n assert candidate(items = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],k = 3) == 7\n assert candidate(items = [[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]],k = 10) == 155\n assert candidate(items = [[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]],k = 10) == 120\n assert candidate(items = [[1000000000, 1], [999999999, 2], [888888888, 3], [777777777, 4], [666666666, 5], [555555555, 6], [444444444, 7], [333333333, 8], [222222222, 9], [111111111, 10]],k = 5) == 4333333355\n assert candidate(items = [[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]],k = 10) == 205\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],k = 10) == 674\n assert candidate(items = [[10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],k = 8) == 58\n assert candidate(items = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],k = 6) == 49\n assert candidate(items = [[90, 1], [80, 2], [70, 3], [60, 4], [50, 5], [40, 6], [30, 7], [20, 8], [10, 9]],k = 5) == 375\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 1], [70, 2], [80, 3], [90, 4], [100, 5], [110, 6], [120, 7], [130, 8], [140, 9], [150, 10], [160, 11], [170, 12], [180, 13], [190, 14], [200, 15]],k = 10) == 1650\n assert candidate(items = [[1000000000, 100000], [900000000, 100000], [800000000, 100000], [700000000, 100000], [600000000, 100000]],k = 3) == 2700000001\n assert candidate(items = [[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]],k = 10) == 106\n assert candidate(items = [[10, 1], [9, 1], [8, 2], [7, 2], [6, 3], [5, 3], [4, 3], [3, 4], [2, 4], [1, 4], [100, 5], [99, 5], [98, 5], [97, 5], [96, 5]],k = 10) == 551\n assert candidate(items = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],k = 5) == 50\n assert candidate(items = [[5, 1], [5, 1], [5, 2], [5, 2], [5, 3], [5, 3], [5, 4], [5, 4], [5, 5], [5, 5]],k = 5) == 50\n assert candidate(items = [[1000000000, 1], [1000000000, 2], [1000000000, 3], [1000000000, 4], [1000000000, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 7) == 5000000051\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],k = 7) == 539\n assert candidate(items = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],k = 5) == 2109\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 1], [120, 2], [130, 3], [140, 4], [150, 5]],k = 12) == 1240\n assert candidate(items = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],k = 3) == 24\n assert candidate(items = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 2], [70, 2], [80, 2], [90, 2], [100, 2], [110, 3], [120, 3], [130, 3], [140, 3], [150, 3]],k = 10) == 1054\n assert candidate(items = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [10, 6], [9, 7], [8, 8], [7, 9], [6, 10], [5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],k = 5) == 65\n assert candidate(items = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],k = 4) == 36\n assert candidate(items = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],k = 10) == 155\n assert candidate(items = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 2], [70, 2], [80, 2], [90, 2], [100, 2]],k = 5) == 401\n assert candidate(items = [[1000000000, 1], [500000000, 1], [250000000, 1], [125000000, 1], [62500000, 1], [31250000, 2], [15625000, 2], [7812500, 2], [3906250, 2], [1953125, 2]],k = 4) == 1875000001\n assert candidate(items = [[1000000000, 1], [900000000, 2], [800000000, 3], [700000000, 4], [600000000, 5], [500000000, 6], [400000000, 7], [300000000, 8], [200000000, 9], [100000000, 10]],k = 5) == 4000000025\n assert candidate(items = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [9, 9], [10, 9]],k = 10) == 84\n assert candidate(items = [[5, 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]],k = 7) == 84\n assert candidate(items = [[100, 1], [99, 2], [98, 3], [97, 4], [96, 5], [95, 1], [94, 2], [93, 3], [92, 4], [91, 5]],k = 3) == 306\n assert candidate(items = [[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]],k = 5) == 105\n assert candidate(items = [[10, 1], [20, 1], [30, 2], [40, 2], [50, 3], [60, 3], [70, 4], [80, 4], [90, 5], [100, 5], [110, 6], [120, 6], [130, 7], [140, 7], [150, 8], [160, 8]],k = 8) == 1016\n"}, "metadata": {"canonical_parameter_names": ["items", "k"], "leetcode_dataset_entry_point": "Solution().findMaximumElegance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long findMaximumElegance(int[][] items, int k) {", "container": "Solution", "callable": "findMaximumElegance", "parameters": [{"name": "items", "type": "int[][]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2815, "task_id": "max-pair-sum-in-an-array", "difficulty": "Easy", "problem_description": "You are given an integer array nums. You have to find the maximum sum of a pair of numbers from nums such that the largest digit in both numbers is equal.\nFor example, 2373 is made up of three distinct digits: 2, 3, and 7, where 7 is the largest among them.\nReturn the maximum sum or -1 if no such pair exists.\n \nExample 1:\n\nInput: nums = [112,131,411]\nOutput: -1\nExplanation:\nEach numbers largest digit in order is [2,3,4].\n\nExample 2:\n\nInput: nums = [2536,1613,3366,162]\nOutput: 5902\nExplanation:\nAll the numbers have 6 as their largest digit, so the answer is 2536 + 3366 = 5902.\n\nExample 3:\n\nInput: nums = [51,71,17,24,42]\nOutput: 88\nExplanation:\nEach number's largest digit in order is [5,7,7,4,4].\nSo we have only two possible pairs, 71 + 17 = 88 and 24 + 42 = 66.\n\n \nConstraints:\n\n2 <= nums.length <= 100\n1 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [123, 321, 213, 132]) == 534\n assert candidate(nums = [100, 200, 300, 400]) == -1\n assert candidate(nums = [55, 44, 33, 22, 11]) == -1\n assert candidate(nums = [99, 88, 77, 66, 55]) == -1\n assert candidate(nums = [111, 222, 333, 444, 555]) == -1\n assert candidate(nums = [12, 21, 13, 31, 23, 32]) == 63\n assert candidate(nums = [111, 222, 333, 444]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [9000, 900, 90, 9]) == 9900\n assert candidate(nums = [11, 22, 33, 44]) == -1\n assert candidate(nums = [2536, 1613, 3366, 162]) == 5902\n assert candidate(nums = [123, 321, 213, 132]) == 534\n assert candidate(nums = [10, 20, 30, 40, 50]) == -1\n assert candidate(nums = [51, 71, 17, 24, 42]) == 88\n assert candidate(nums = [9, 99, 999, 9999]) == 10998\n assert candidate(nums = [1234, 4321, 2341, 3412, 1423, 2134]) == 7733\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == -1\n assert candidate(nums = [999, 888, 777, 666, 555]) == -1\n assert candidate(nums = [1000, 1001, 1010, 1100]) == 2110\n assert candidate(nums = [112, 131, 411]) == -1\n assert candidate(nums = [999, 888, 777, 666]) == -1\n assert candidate(nums = [1234, 4321, 2341, 1432]) == 6662\n assert candidate(nums = [12, 21, 13, 31, 14, 41, 23, 32, 24, 42, 34, 43]) == 85\n assert candidate(nums = [123, 321, 213, 132, 231, 312]) == 633\n assert candidate(nums = [123, 321, 213]) == 534\n assert candidate(nums = [999, 888, 777, 666]) == -1\n assert candidate(nums = [12345, 54321, 15234, 51423]) == 105744\n assert candidate(nums = [9990, 9909, 9099, 9991, 1999, 9919, 9199, 9992, 2999, 9929, 9299]) == 19983\n assert candidate(nums = [1001, 1010, 1100, 1000, 10, 1]) == 2110\n assert candidate(nums = [9876, 8769, 7698, 6987, 9875, 8759, 7598, 5987, 9874, 8749]) == 19751\n assert candidate(nums = [98765, 87654, 76543, 65432, 54321, 12345, 23456, 34567, 45678, 56789]) == 155554\n assert candidate(nums = [5689, 8956, 6958, 9586, 5869, 9658, 6598, 5698, 8965, 9865]) == 19523\n assert candidate(nums = [12345, 12354, 12435, 12453, 12534, 12543, 21345, 21354, 21435]) == 42789\n assert candidate(nums = [98765, 98764, 98755, 98665, 97765, 96865, 95965, 94765, 93865, 92965]) == 197529\n assert candidate(nums = [1999, 1888, 1777, 1666, 1555, 1444, 1333, 1222, 1111, 9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222]) == 11998\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 12, 21, 32, 23, 34, 43]) == 1791\n assert candidate(nums = [98765, 87654, 76543, 65432, 54321, 43210, 32109, 21098, 10987]) == 130874\n assert candidate(nums = [56789, 98765, 98756, 98675, 98567, 97685, 97658, 97586, 97568, 56789]) == 197521\n assert candidate(nums = [10001, 10010, 10100, 11000, 20002, 20020, 20200, 22000]) == 42200\n assert candidate(nums = [12345, 23456, 34567, 45678, 56789, 67890, 12345, 23456, 34567, 45678, 56789, 67890]) == 135780\n assert candidate(nums = [12345, 54321, 15324, 51234]) == 105555\n assert candidate(nums = [101, 110, 111, 202, 220, 222, 303, 330, 333]) == 663\n assert candidate(nums = [111, 112, 121, 211, 222, 221, 212, 122, 333, 332, 323, 233, 444, 443, 434, 344]) == 887\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 101]) == 212\n assert candidate(nums = [5005, 5500, 5050, 5000, 9999, 9998, 9989, 9899, 9988, 9889, 8999, 8989, 8899]) == 19997\n assert candidate(nums = [12345, 54321, 23415, 34125, 32145, 98765, 87659, 76598, 65987]) == 186424\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 1100000\n assert candidate(nums = [12345, 23456, 34567, 45678, 56789, 67890]) == 124679\n assert candidate(nums = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1010, 1001, 1011, 1101, 1110, 9898, 8989]) == 19897\n assert candidate(nums = [1110, 1101, 1011, 2220, 2202, 2022, 3330, 3303, 3033]) == 6633\n assert candidate(nums = [12345, 54321, 23451, 34512, 45123]) == 99444\n assert candidate(nums = [12345, 67890, 98765, 54321, 23456, 89012, 45678, 78901, 34567]) == 187777\n assert candidate(nums = [10101, 11010, 10110, 10011, 22222, 22221, 22212, 22122, 21222, 12222]) == 44443\n assert candidate(nums = [11223, 33445, 55667, 77889, 99111]) == 177000\n assert candidate(nums = [1234, 4321, 2341, 3412, 4123, 1423, 2143, 3214]) == 8444\n assert candidate(nums = [123456, 654321, 234561, 123654, 543216, 345621, 123465, 564321, 654231, 432165]) == 1308552\n assert candidate(nums = [123, 456, 789, 321, 654, 987, 213, 543, 879]) == 1866\n assert candidate(nums = [1234, 4321, 2341, 3412, 1432]) == 7733\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234]) == 1791357\n assert candidate(nums = [98765, 98765, 88765, 88765, 78765, 78765, 68765, 68765, 58765, 58765]) == 197530\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 234, 345, 456]) == 1791\n assert candidate(nums = [112233, 332211, 113322, 221133, 321123, 231132, 132211, 312211, 223311, 112211]) == 653334\n assert candidate(nums = [12345, 54321, 23451, 34512, 45123, 51234, 67890, 98765, 87654, 76543]) == 166655\n assert candidate(nums = [10000, 9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111]) == 11111\n assert candidate(nums = [123, 1234, 12345, 123456, 1234567, 12345678, 123456789]) == -1\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]) == 1099999998\n assert candidate(nums = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111]) == -1\n assert candidate(nums = [1234, 4321, 2134, 3412, 1111, 9876, 6789]) == 16665\n assert candidate(nums = [123456, 654321, 234561, 124563, 654321, 123456, 111111, 222222, 333333, 444444]) == 1308642\n assert candidate(nums = [1234, 4321, 2134, 3412, 2341]) == 7733\n assert candidate(nums = [1099, 9910, 2088, 8820, 3077, 7730, 4066, 6640, 5055, 5505]) == 11009\n assert candidate(nums = [245, 452, 524, 199, 919, 991]) == 1910\n assert candidate(nums = [98765, 98756, 98675, 98567, 97685, 97658, 97586, 97568]) == 197521\n assert candidate(nums = [89012, 89102, 89021, 89120, 89013]) == 178222\n assert candidate(nums = [12345, 67890, 23456, 78906, 12354, 67980, 13452, 89706, 14352, 98706]) == 188412\n assert candidate(nums = [123, 123, 123, 456, 456, 456, 789, 789, 789]) == 1578\n assert candidate(nums = [1010, 1001, 1100, 1110, 1011, 1111, 2222, 2212, 2122, 2221]) == 4443\n assert candidate(nums = [123456789, 1234567890, 12345678901, 123456789012, 1234567890123]) == 1358024679135\n assert candidate(nums = [11223, 22334, 33445, 44556, 55667, 66778, 77889, 88990, 99001, 10012]) == 187991\n assert candidate(nums = [999, 990, 909, 900, 888, 880, 808, 800, 777, 770, 707, 700]) == 1989\n assert candidate(nums = [1234567, 7654321, 2345671, 1236547, 5432176, 3456217, 1234657, 7654231, 6542371, 4321765]) == 15308552\n assert candidate(nums = [1234, 4321, 3412, 2143, 4444]) == 8765\n assert candidate(nums = [12345, 54321, 13425, 52431, 21354, 45312, 31245, 51234, 23451, 41235]) == 106752\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1111]) == 1222\n assert candidate(nums = [123, 321, 213, 456, 654, 564]) == 1218\n assert candidate(nums = [100100, 200200, 300300, 400400, 500500, 600600, 700700, 800800, 900900]) == -1\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == -1\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == -1\n assert candidate(nums = [1299, 2288, 3377, 4466, 5555, 6644, 7733, 8822, 9911]) == 11210\n assert candidate(nums = [56789, 12345, 67890, 23456, 34567]) == 124679\n assert candidate(nums = [1111, 1222, 1333, 2111, 2222, 2333, 3111, 3222, 3333]) == 6555\n assert candidate(nums = [56789, 98765, 56788, 87654, 56787, 76543, 56786, 65432, 56785]) == 155554\n assert candidate(nums = [9876, 8765, 7654, 6543, 5432, 4321, 3210, 2109, 1098, 987]) == 11985\n assert candidate(nums = [9876, 8765, 7654, 6543, 5432, 4321, 3210, 2109, 1098]) == 11985\n assert candidate(nums = [11111, 12222, 21111, 12121, 12321, 12341, 12345, 123456, 99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222]) == 190122\n assert candidate(nums = [12345, 54321, 13245, 52431, 12435, 53421, 12354, 54231]) == 108552\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 32\n assert candidate(nums = [11223, 32112, 21331, 31221, 12332, 32123, 23113, 13221, 22311]) == 64235\n assert candidate(nums = [1234, 4321, 2341, 3124, 1324, 2413, 4132, 3412, 5678, 8765, 7658, 6587, 8657, 5867, 7568]) == 17422\n assert candidate(nums = [1001, 1010, 1100, 10001, 10010, 10100, 11000, 100001, 100010, 100100]) == 200110\n assert candidate(nums = [1234, 4321, 2134, 3412, 5678, 8765]) == 14443\n assert candidate(nums = [5678, 8765, 6543, 3456, 7890]) == 14443\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == -1\n assert candidate(nums = [12345, 23451, 34512, 45123, 51234, 67890, 78906, 89067, 90678, 67809]) == 179745\n assert candidate(nums = [5555, 5556, 5565, 5655, 6555, 5566, 6655, 6565, 5665, 6665]) == 13320\n assert candidate(nums = [1010, 2020, 3030, 4040, 5050, 6060, 7070, 8080, 9090]) == -1\n assert candidate(nums = [1000, 1001, 1010, 1100, 1110, 1101, 1011, 9000, 9001, 9010]) == 18011\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1111, 2222, 3333, 4444]) == 4888\n assert candidate(nums = [11111, 22222, 33333, 44444, 55555]) == -1\n assert candidate(nums = [12, 21, 34, 43, 56, 65, 78, 87, 90, 90, 100, 101, 110, 111]) == 221\n assert candidate(nums = [55555, 44444, 33333, 22222, 11111, 55554, 44443, 33332, 22221]) == 111109\n assert candidate(nums = [987654321, 123456789, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567]) == 1888888888\n assert candidate(nums = [88888, 87777, 77777, 86666, 66666, 85555, 55555, 84444, 44444]) == 176665\n assert candidate(nums = [11111, 11112, 11121, 11211, 12111, 11113, 11131, 11311, 13111]) == 24422\n assert candidate(nums = [1234, 4321, 2341, 3412, 4123, 2134, 1423, 3214, 4231]) == 8552\n assert candidate(nums = [1234, 4321, 2341, 3412, 3214]) == 7733\n assert candidate(nums = [2332, 3223, 2233, 3322, 3232, 2323, 3332, 3233, 3333, 2223]) == 6665\n assert candidate(nums = [5999, 5888, 5777, 5666, 5555, 5444, 5333, 5222, 5111]) == 10999\n assert candidate(nums = [1112, 2111, 1211, 1121, 1111, 2221, 2212, 2122, 1222, 2222]) == 4443\n assert candidate(nums = [5555, 5554, 5545, 5455, 4555]) == 11109\n assert candidate(nums = [123456, 654321, 234516, 345162, 321654, 987654, 876549, 765498, 654987]) == 1864203\n assert candidate(nums = [98765, 87659, 76598, 65987, 59876]) == 186424\n assert candidate(nums = [199, 288, 377, 466, 555, 554, 467, 378, 289, 190, 290, 380, 470, 560]) == 1109\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 9999\n assert candidate(nums = [11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == -1\n assert candidate(nums = [9999, 9998, 9989, 9899, 9988, 9889, 8999, 8989, 8899, 8889]) == 19997\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxSum(int[] nums) {", "container": "Solution", "callable": "maxSum", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2816, "task_id": "double-a-number-represented-as-a-linked-list", "difficulty": "Medium", "problem_description": "You are given the head of a non-empty linked list representing a non-negative integer without leading zeroes.\nReturn the head of the linked list after doubling it.\n \nExample 1:\n\n\nInput: head = [1,8,9]\nOutput: [3,7,8]\nExplanation: The figure above corresponds to the given linked list which represents the number 189. Hence, the returned linked list represents the number 189 * 2 = 378.\n\nExample 2:\n\n\nInput: head = [9,9,9]\nOutput: [1,9,9,8]\nExplanation: The figure above corresponds to the given linked list which represents the number 999. Hence, the returned linked list reprersents the number 999 * 2 = 1998. \n\n \nConstraints:\n\nThe number of nodes in the list is in the range [1, 104]\n0 <= Node.val <= 9\nThe input is generated such that the list represents a number that does not have leading zeros, except the number 0 itself.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(head = list_node([5, 6, 7, 8, 9])), list_node([1, 1, 3, 5, 7, 8]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9])), list_node([2, 4, 6, 9, 1, 3, 5, 7, 8]))\n assert is_same_list(candidate(head = list_node([0])), list_node([0]))\n assert is_same_list(candidate(head = list_node([9, 9, 9])), list_node([1, 9, 9, 8]))\n assert is_same_list(candidate(head = list_node([1, 8, 9])), list_node([3, 7, 8]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5])), list_node([2, 4, 6, 9, 0]))\n assert is_same_list(candidate(head = list_node([5, 0, 0])), list_node([1, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([1, 0, 0, 0])), list_node([2, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([6, 7, 8, 9, 0])), list_node([1, 3, 5, 7, 8, 0]))\n assert is_same_list(candidate(head = list_node([6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6])), list_node([1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1])), list_node([1, 0, 8, 6, 4, 2]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_list(candidate(head = list_node([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7])), list_node([1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_list(candidate(head = list_node([6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6])), list_node([1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]))\n assert is_same_list(candidate(head = list_node([4, 4, 4, 4, 4, 4, 4, 4, 4, 4])), list_node([8, 8, 8, 8, 8, 8, 8, 8, 8, 8]))\n assert is_same_list(candidate(head = list_node([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3])), list_node([6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]))\n assert is_same_list(candidate(head = list_node([3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6])), list_node([7, 3, 8, 7, 3, 8, 7, 3, 8, 7, 3, 8, 7, 3, 8, 7, 3, 8, 7, 2]))\n assert is_same_list(candidate(head = list_node([8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8])), list_node([1, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_list(candidate(head = list_node([4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4])), list_node([8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]))\n assert is_same_list(candidate(head = list_node([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])), list_node([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 is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_list(candidate(head = list_node([5, 0, 5, 0, 5, 0, 5, 0, 5, 0])), list_node([1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0])), list_node([4, 9, 3, 6, 0, 4, 9, 3, 6, 0, 4, 9, 3, 6, 0]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]))\n assert is_same_list(candidate(head = list_node([9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9])), list_node([1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8]))\n assert is_same_list(candidate(head = list_node([1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])), list_node([2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]))\n assert is_same_list(candidate(head = list_node([7, 8, 9, 0, 1, 2, 3, 4, 5, 6])), list_node([1, 5, 7, 8, 0, 2, 4, 6, 9, 1, 2]))\n assert is_same_list(candidate(head = list_node([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])), list_node([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]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 0, 1, 3, 5, 7, 9])), list_node([4, 9, 3, 6, 0, 2, 7, 1, 5, 8]))\n assert is_same_list(candidate(head = list_node([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3])), list_node([6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]))\n assert is_same_list(candidate(head = list_node([1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0])), list_node([2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]))\n assert is_same_list(candidate(head = list_node([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])), list_node([1, 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, 6]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_list(candidate(head = list_node([1, 0, 1, 0, 1, 0, 1, 0, 1, 0])), list_node([2, 0, 2, 0, 2, 0, 2, 0, 2, 0]))\n assert is_same_list(candidate(head = list_node([7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9])), list_node([1, 5, 7, 9, 3, 5, 7, 9, 3, 5, 7, 8]))\n assert is_same_list(candidate(head = list_node([6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6])), list_node([1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]))\n assert is_same_list(candidate(head = list_node([9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9])), list_node([1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8]))\n assert is_same_list(candidate(head = list_node([4, 3, 2, 1])), list_node([8, 6, 4, 2]))\n assert is_same_list(candidate(head = list_node([8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8])), list_node([1, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6]))\n assert is_same_list(candidate(head = list_node([4, 3, 2, 1, 0])), list_node([8, 6, 4, 2, 0]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]))\n assert is_same_list(candidate(head = list_node([9, 9, 9, 9, 9, 9, 9, 9, 9, 9])), list_node([1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8]))\n assert is_same_list(candidate(head = list_node([4, 5, 6, 7, 8, 9, 0, 1, 2, 3])), list_node([9, 1, 3, 5, 7, 8, 0, 2, 4, 6]))\n assert is_same_list(candidate(head = list_node([5, 0, 0, 0, 0, 0, 0, 0, 0, 0])), list_node([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3])), list_node([6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]))\n assert is_same_list(candidate(head = list_node([7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([1, 5, 3, 0, 8, 6, 4, 2, 1, 9, 7, 5, 3, 0, 8, 6, 4, 2]))\n assert is_same_list(candidate(head = list_node([5, 0, 5, 0, 5])), list_node([1, 0, 1, 0, 1, 0]))\n assert is_same_list(candidate(head = list_node([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])), list_node([1, 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, 8]))\n assert is_same_list(candidate(head = list_node([8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([1, 7, 5, 3, 0, 8, 6, 4, 2, 1, 9, 7, 5, 3, 0, 8, 6, 4, 2]))\n assert is_same_list(candidate(head = list_node([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])), list_node([1, 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, 6]))\n assert is_same_list(candidate(head = list_node([9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1])), list_node([1, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 2]))\n assert is_same_list(candidate(head = list_node([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])), list_node([1, 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, 2]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([1, 9, 7, 5, 3, 0, 8, 6, 4, 2]))\n assert is_same_list(candidate(head = list_node([4, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9])), list_node([9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0])), list_node([4, 9, 3, 6, 0, 4, 9, 3, 6, 0, 4, 9, 3, 6, 0, 4, 9, 3, 6, 0, 4, 9, 3, 6, 0, 4, 9, 3, 6, 0]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9])), list_node([2, 7, 1, 5, 8, 2, 7, 1, 5, 8, 2, 7, 1, 5, 8, 2, 7, 1, 5, 8]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])), list_node([2, 4, 6, 9, 1, 3, 5, 7, 8, 0]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 0, 2, 4, 6, 8, 0])), list_node([4, 9, 3, 6, 0, 4, 9, 3, 6, 0]))\n assert is_same_list(candidate(head = list_node([4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([8, 6, 4, 3, 9, 7, 5, 3, 0, 8, 6, 4, 2]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])), list_node([1, 9, 7, 5, 3, 0, 8, 6, 4, 2, 0]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]))\n assert is_same_list(candidate(head = list_node([4, 9, 9, 9, 9, 9, 9, 9, 9, 9])), list_node([9, 9, 9, 9, 9, 9, 9, 9, 9, 8]))\n assert is_same_list(candidate(head = list_node([5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0])), list_node([1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]))\n assert is_same_list(candidate(head = list_node([2, 5, 8, 2, 5, 8, 2, 5, 8, 2, 5, 8, 2, 5, 8, 2, 5, 8, 2, 5])), list_node([5, 1, 6, 5, 1, 6, 5, 1, 6, 5, 1, 6, 5, 1, 6, 5, 1, 6, 5, 0]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_list(candidate(head = list_node([2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2])), list_node([4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4]))\n assert is_same_list(candidate(head = list_node([9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9])), list_node([1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8]))\n assert is_same_list(candidate(head = list_node([3, 6, 9, 2, 5, 8, 1, 4, 7, 0, 3, 6, 9, 2, 5, 8, 1, 4, 7, 0, 3, 6, 9, 2, 5, 8, 1, 4, 7, 0])), list_node([7, 3, 8, 5, 1, 6, 2, 9, 4, 0, 7, 3, 8, 5, 1, 6, 2, 9, 4, 0, 7, 3, 8, 5, 1, 6, 2, 9, 4, 0]))\n assert is_same_list(candidate(head = list_node([3, 7, 2, 8, 9, 4, 6, 2, 3, 1])), list_node([7, 4, 5, 7, 8, 9, 2, 4, 6, 2]))\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().doubleIt", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {", "container": "Solution", "callable": "ListNode", "parameters": [], "return_type": "class ListNode {\n * int val;\n * ListNode next;\n *", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2817, "task_id": "minimum-absolute-difference-between-elements-with-constraint", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and an integer x.\nFind the minimum absolute difference between two elements in the array that are at least x indices apart.\nIn other words, find two indices i and j such that abs(i - j) >= x and abs(nums[i] - nums[j]) is minimized.\nReturn an integer denoting the minimum absolute difference between two elements that are at least x indices apart.\n \nExample 1:\n\nInput: nums = [4,3,2,4], x = 2\nOutput: 0\nExplanation: We can select nums[0] = 4 and nums[3] = 4. \nThey are at least 2 indices apart, and their absolute difference is the minimum, 0. \nIt can be shown that 0 is the optimal answer.\n\nExample 2:\n\nInput: nums = [5,3,2,10,15], x = 1\nOutput: 1\nExplanation: We can select nums[1] = 3 and nums[2] = 2.\nThey are at least 1 index apart, and their absolute difference is the minimum, 1.\nIt can be shown that 1 is the optimal answer.\n\nExample 3:\n\nInput: nums = [1,2,3,4], x = 3\nOutput: 3\nExplanation: We can select nums[0] = 1 and nums[3] = 4.\nThey are at least 3 indices apart, and their absolute difference is the minimum, 3.\nIt can be shown that 3 is the optimal answer.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n0 <= x < nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],x = 2) == 0\n assert candidate(nums = [10, 5, 3, 9, 2],x = 2) == 1\n assert candidate(nums = [1, 1, 1, 1, 1],x = 0) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7],x = 3) == 0\n assert candidate(nums = [1, 2, 3, 4],x = 3) == 3\n assert candidate(nums = [4, 3, 2, 4],x = 2) == 0\n assert candidate(nums = [1000000000, 1, 1000000000, 1],x = 1) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],x = 4) == 0\n assert candidate(nums = [1, 5, 3, 19, 18, 22],x = 3) == 13\n assert candidate(nums = [10, 5, 3, 6, 8, 1, 2],x = 2) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],x = 2) == 20\n assert candidate(nums = [5, 3, 2, 10, 15],x = 1) == 1\n assert candidate(nums = [10, 5, 3, 6, 8, 2, 9],x = 4) == 1\n assert candidate(nums = [10, 5, 3, 100, 20, 15],x = 2) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],x = 4) == 2\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996],x = 2) == 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],x = 12) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],x = 7) == 3\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],x = 2) == 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, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 25) == 0\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998],x = 2) == 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],x = 7) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 0) == 0\n assert candidate(nums = [3, 8, 15, 17, 9, 5, 12, 3],x = 3) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 3) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 8) == 80\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 3) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],x = 4) == 8\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],x = 5) == 0\n assert candidate(nums = [7, 3, 2, 8, 6, 5, 4, 9, 1, 10],x = 3) == 1\n assert candidate(nums = [5, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],x = 3) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 2) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 6) == 6\n assert candidate(nums = [5, 3, 3, 5, 5, 3, 3, 5, 5, 3, 3, 5],x = 2) == 0\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200],x = 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],x = 9) == 9\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10],x = 4) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 6) == 600\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 3) == 3\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],x = 4) == 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],x = 10) == 10\n assert candidate(nums = [9, 1, 5, 7, 3, 8, 2, 6, 4, 10],x = 4) == 1\n assert candidate(nums = [5, 1, 4, 2, 3],x = 2) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],x = 4) == 4\n assert candidate(nums = [10, 20, 15, 30, 25, 40, 35, 50, 45],x = 3) == 5\n assert candidate(nums = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500],x = 5) == 500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 5) == 50\n assert candidate(nums = [2, 5, 1, 8, 3, 7, 4, 6],x = 2) == 1\n assert candidate(nums = [1, 3, 6, 8, 9, 10, 12, 15, 18, 20],x = 6) == 11\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],x = 4) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 3) == 30\n assert candidate(nums = [1, 5, 9, 14, 20, 25, 30],x = 2) == 8\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],x = 3) == 29\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 10) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 5) == 5\n assert candidate(nums = [9, 5, 12, 6, 18, 3],x = 2) == 1\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],x = 5) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],x = 6) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],x = 5) == 2\n assert candidate(nums = [23, 1, 21, 3, 19, 5, 17, 7, 15, 9, 13, 11, 14, 12, 16, 10, 18, 8, 20, 6, 22, 4, 24, 2, 25],x = 7) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0],x = 5) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 9) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 6) == 600\n assert candidate(nums = [5, 8, 12, 15, 18, 21, 24, 27, 30, 33],x = 4) == 12\n assert candidate(nums = [3, 8, 15, 1, 6],x = 3) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],x = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 4) == 4\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000],x = 3) == 109375000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],x = 2) == 2\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],x = 4) == 0\n assert candidate(nums = [7, 1, 14, 11],x = 2) == 4\n assert candidate(nums = [1, 3, 6, 8, 12, 15, 18, 20],x = 3) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 5) == 5\n assert candidate(nums = [1000000000, 999999999, 1, 2, 3, 4, 5, 6, 7, 8, 9],x = 5) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 2) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 9) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],x = 3) == 3\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10],x = 2) == 0\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1],x = 2) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 4) == 0\n assert candidate(nums = [2, 1, 2, 3, 1, 3, 4, 1, 4, 2, 4, 3, 5, 1, 5, 2, 5, 3, 5, 4],x = 4) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 4) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 5) == 5\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],x = 5) == 50\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5],x = 2) == 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],x = 2) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],x = 8) == 40\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],x = 2) == 0\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],x = 4) == 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],x = 15) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 2) == 200\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],x = 4) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 2) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 1) == 2\n assert candidate(nums = [100, 50, 10, 5, 1, 500, 1000, 200, 300, 400],x = 3) == 49\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],x = 5) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 4) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 5) == 50\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 5) == 0\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],x = 1) == 1\n assert candidate(nums = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 3) == 1\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],x = 2) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],x = 4) == 8\n assert candidate(nums = [5, 3, 2, 4, 1, 6, 7, 8, 9, 10],x = 7) == 3\n assert candidate(nums = [4, 1, 7, 10, 3, 8, 2, 9, 5, 6],x = 2) == 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],x = 10) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 4) == 4\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],x = 2) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],x = 3) == 0\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],x = 8) == 0\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],x = 3) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 7) == 7\n assert candidate(nums = [7, 1, 3, 4, 1, 7],x = 3) == 0\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1],x = 2) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],x = 5) == 0\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1],x = 3) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],x = 2) == 20\n assert candidate(nums = [8, 1, 5, 10, 18, 15, 22, 4, 7, 2],x = 5) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],x = 9) == 0\n assert candidate(nums = [1, 1000000000, 1, 1000000000],x = 2) == 0\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000],x = 1) == 0\n assert candidate(nums = [3, 5, 6, 7, 8, 8],x = 1) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],x = 3) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],x = 6) == 6\n assert candidate(nums = [1],x = 0) == 0\n assert candidate(nums = [6, 2, 1, 100, 1000, 3, 4],x = 4) == 1\n assert candidate(nums = [100, 100, 100, 100],x = 0) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 3) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 5) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 5) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11],x = 5) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],x = 5) == inf\n assert candidate(nums = [1, 1, 1, 1, 1, 1],x = 2) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 4) == 0\n assert candidate(nums = [1, 5, 9, 14, 20],x = 2) == 8\n assert candidate(nums = [10, 20, 30, 40, 50],x = 0) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],x = 5) == 5\n assert candidate(nums = [7, 1, 4, 5, 9, 2, 6, 3],x = 2) == 1\n assert candidate(nums = [7, 1, 4, 5, 6, 2],x = 3) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 2) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],x = 4) == 40\n assert candidate(nums = [10, 5, 1, 7, 10, 3],x = 2) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50],x = 3) == 30\n assert candidate(nums = [1, 3, 6, 8, 9, 15],x = 0) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],x = 4) == 0\n assert candidate(nums = [10, 5, 3, 8, 12, 7, 6, 9, 1, 2],x = 4) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],x = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 9) == 9\n assert candidate(nums = [1, 5, 3, 19, 18, 22, 6, 7],x = 3) == 1\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000],x = 4) == 0\n assert candidate(nums = [5, 8, 3, 9, 7, 6, 2, 4, 1, 10],x = 4) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 2) == 2\n assert candidate(nums = [8, 12, 4, 13, 7],x = 2) == 1\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1],x = 5) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],x = 2) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 0) == 0\n assert candidate(nums = [1, 1, 1, 1, 1],x = 2) == 0\n assert candidate(nums = [1, 100, 1, 100, 1, 100],x = 1) == 0\n assert candidate(nums = [10, 5, 3, 9, 2, 8],x = 2) == 1\n assert candidate(nums = [7, 1, 3, 4, 1, 9],x = 1) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 1) == 2\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],x = 0) == 0\n assert candidate(nums = [7, 1, 3, 4, 1, 9],x = 4) == 2\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1],x = 3) == 0\n assert candidate(nums = [7, 1, 3, 4, 1, 7],x = 2) == 0\n assert candidate(nums = [5, 1, 4, 1, 2],x = 2) == 0\n assert candidate(nums = [1000000000, 1, 1000000000, 1],x = 2) == 0\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997],x = 2) == 1\n assert candidate(nums = [1, 5, 3, 19, 18, 22, 6, 7, 20, 15],x = 4) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 4) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 0) == 0\n assert candidate(nums = [3, 5, 4, 2, 4],x = 1) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],x = 0) == 0\n assert candidate(nums = [7, 1, 3, 8, 6, 2, 5, 4],x = 2) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 1) == 0\n assert candidate(nums = [10, 5, 4, 7, 8, 9],x = 4) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],x = 0) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],x = 3) == 3\n assert candidate(nums = [1, 1000000000, 1, 1000000000],x = 1) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 9) == 0\n assert candidate(nums = [3, 5, 9, 8, 10, 1],x = 2) == 1\n assert candidate(nums = [1, 10, 3, 7, 5, 8, 6, 2, 4, 9],x = 5) == 1\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 1000000000, 999999999, 1],x = 3) == 0\n assert candidate(nums = [10, 5, 3, 9, 2, 8, 6],x = 2) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 8) == 16\n assert candidate(nums = [10, 5, 1, 15, 3, 7, 8],x = 2) == 2\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],x = 5) == 50\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1],x = 3) == 0\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000],x = 2) == 0\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],x = 0) == 0\n assert candidate(nums = [1, 5, 3, 19, 18, 25],x = 3) == 13\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 0) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 5) == 5\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],x = 4) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 0) == 0\n assert candidate(nums = [1, 5, 3, 19, 18, 25],x = 2) == 2\n assert candidate(nums = [10, 5, 3, 8, 12],x = 2) == 2\n assert candidate(nums = [3, 5, 3, 5, 3, 5, 3, 5],x = 3) == 0\n assert candidate(nums = [10, 5, 4, 7, 8, 3, 6, 1],x = 4) == 1\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],x = 9) == 90\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 5) == 0\n assert candidate(nums = [10, 5, 1, 9, 4, 8, 3, 7, 2, 6],x = 4) == 1\n assert candidate(nums = [7, 10, 4, 3, 20, 15],x = 2) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 2) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 3) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],x = 0) == 0\n assert candidate(nums = [1, 2, 3, 100, 101, 102],x = 2) == 2\n assert candidate(nums = [1, 5, 9, 13, 17],x = 4) == 16\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 4) == 40\n assert candidate(nums = [10, 5, 1, 100, 1000],x = 2) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 3) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300],x = 3) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "x"], "leetcode_dataset_entry_point": "Solution().minAbsoluteDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minAbsoluteDifference(List nums, int x) {", "container": "Solution", "callable": "minAbsoluteDifference", "parameters": [{"name": "nums", "type": "List"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2824, "task_id": "count-pairs-whose-sum-is-less-than-target", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums of length n and an integer target, return the number of pairs (i, j) where 0 <= i < j < n and nums[i] + nums[j] < target.\n \nExample 1:\n\nInput: nums = [-1,1,2,3,1], target = 2\nOutput: 3\nExplanation: There are 3 pairs of indices that satisfy the conditions in the statement:\n- (0, 1) since 0 < 1 and nums[0] + nums[1] = 0 < target\n- (0, 2) since 0 < 2 and nums[0] + nums[2] = 1 < target \n- (0, 4) since 0 < 4 and nums[0] + nums[4] = 0 < target\nNote that (0, 3) is not counted since nums[0] + nums[3] is not strictly less than the target.\n\nExample 2:\n\nInput: nums = [-6,2,5,-2,-7,-1,3], target = -2\nOutput: 10\nExplanation: There are 10 pairs of indices that satisfy the conditions in the statement:\n- (0, 1) since 0 < 1 and nums[0] + nums[1] = -4 < target\n- (0, 3) since 0 < 3 and nums[0] + nums[3] = -8 < target\n- (0, 4) since 0 < 4 and nums[0] + nums[4] = -13 < target\n- (0, 5) since 0 < 5 and nums[0] + nums[5] = -7 < target\n- (0, 6) since 0 < 6 and nums[0] + nums[6] = -3 < target\n- (1, 4) since 1 < 4 and nums[1] + nums[4] = -5 < target\n- (3, 4) since 3 < 4 and nums[3] + nums[4] = -9 < target\n- (3, 5) since 3 < 5 and nums[3] + nums[5] = -3 < target\n- (4, 5) since 4 < 5 and nums[4] + nums[5] = -8 < target\n- (4, 6) since 4 < 6 and nums[4] + nums[6] = -4 < target\n\n \nConstraints:\n\n1 <= nums.length == n <= 50\n-50 <= nums[i], target <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],target = 15) == 10\n assert candidate(nums = [-10, -20, -30, -40, -50],target = -80) == 1\n assert candidate(nums = [1, 3, 5, 7, 9],target = 10) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],target = 3) == 10\n assert candidate(nums = [0, 0, 0, 0, 0],target = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],target = 10) == 10\n assert candidate(nums = [-1, -2, -3, -4, -5],target = -3) == 9\n assert candidate(nums = [-5, -4, -3, -2, -1],target = -5) == 6\n assert candidate(nums = [-6, 2, 5, -2, -7, -1, 3],target = -2) == 10\n assert candidate(nums = [0, 0, 0, 0, 0],target = 1) == 10\n assert candidate(nums = [0, 0, 0, 0],target = 1) == 6\n assert candidate(nums = [10, 20, 30, 40, 50],target = 100) == 10\n assert candidate(nums = [-1, 1, 2, 3, 1],target = 2) == 3\n assert candidate(nums = [-5, -4, -3, -2, -1],target = -8) == 1\n assert candidate(nums = [50, -50, 25, -25],target = 0) == 2\n assert candidate(nums = [-5, -10, 3, 8, 0, -2],target = 1) == 9\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],target = -15) == 6\n assert candidate(nums = [25, -25, 0, 15, -15, 10, -10, 5, -5, 20, -20],target = 0) == 25\n assert candidate(nums = [25, 15, 5, -5, -15, -25, 35, 45, 55, -45],target = 0) == 13\n assert candidate(nums = [-15, -25, -35, -45, -55],target = -70) == 4\n assert candidate(nums = [-5, -4, -3, -2, -1],target = -2) == 10\n assert candidate(nums = [-1, -1, -2, -3, -4, -5, -6, -7, -8, -9],target = -3) == 42\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50],target = 25) == 32\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3],target = 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],target = 0) == 90\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25, -30, -35, -40, -45],target = 5) == 90\n assert candidate(nums = [0, 0, 0, 0, 0],target = 0) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],target = 50) == 64\n assert candidate(nums = [-30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30],target = -10) == 25\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],target = 1) == 1128\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 = 30) == 160\n assert candidate(nums = [-49, -47, -45, -43, -41, -39, -37, -35, -33, -31, -29, -27, -25, -23, -21, -19, -17, -15, -13, -11],target = -50) == 134\n assert candidate(nums = [45, 46, 47, 48, 49, 50, -45, -46, -47, -48, -49, -50],target = 0) == 30\n assert candidate(nums = [5, 2, 7, 1, 8, 4, 3, 6],target = 10) == 16\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35],target = 0) == 6\n assert candidate(nums = [5, 15, 25, 35, 45, 50, 45, 35, 25, 15, 5, 0, -5, -15, -25, -35, -45, -50, -45, -35, -25, -15, -5, 0, 5, 15, 25, 35, 45, 50, 45, 35, 25, 15, 5, 0, -5, -15, -25, -35, -45, -50, -45, -35, -25, -15, -5],target = 10) == 604\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 1) == 45\n assert candidate(nums = [50, -50, 40, -40, 30, -30, 20, -20, 10, -10],target = 1) == 25\n assert candidate(nums = [-1, 0, 1, 2, -2, -3, 3],target = 1) == 12\n assert candidate(nums = [5, -5, 15, -15, 25, -25],target = 0) == 6\n assert candidate(nums = [-10, 0, 10, -20, 20, -30, 30, -40, 40, -50, 50],target = 10) == 30\n assert candidate(nums = [-45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45],target = -5) == 72\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],target = 10) == 775\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3],target = 0) == 9\n assert candidate(nums = [-4, -3, -2, -1, 0, 1, 2, 3, 4],target = 1) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17],target = 15) == 8\n assert candidate(nums = [30, 20, 10, 0, -10, -20, -30],target = 10) == 12\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, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],target = 50) == 625\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],target = 8) == 25\n assert candidate(nums = [-2, -3, -4, -5, -6, 1, 2, 3, 4, 5],target = -5) == 9\n assert candidate(nums = [48, 49, 50, -48, -49, -50],target = 0) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 15) == 12\n assert candidate(nums = [-40, -30, -20, -10, 0, 10, 20, 30, 40, 50],target = 10) == 20\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],target = -5) == 41\n assert candidate(nums = [25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25],target = 10) == 35\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],target = 50) == 576\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 180) == 43\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],target = 1) == 20\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],target = 200) == 44\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0],target = 1) == 21\n assert candidate(nums = [25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25, 30, 35, 40, 45, 50, -30, -35, -40, -45, -50],target = 15) == 129\n assert candidate(nums = [-1, 0, 1, 0, -1, 1, 0],target = 1) == 14\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],target = 0) == 20\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40],target = 90) == 25\n assert candidate(nums = [100, -50, 25, -25, 0, 50, -100],target = 0) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 25) == 29\n assert candidate(nums = [-40, -30, -20, -10, 0, 10, 20, 30, 40],target = -15) == 12\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],target = 0) == 25\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],target = 30) == 27\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],target = -15) == 6\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5],target = 2) == 35\n assert candidate(nums = [30, 20, 10, 0, -10, -20, -30, -40, -50, -60],target = -5) == 33\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30],target = 90) == 170\n assert candidate(nums = [30, 20, 10, 0, -10, -20, -30, -40, -50],target = -25) == 16\n assert candidate(nums = [23, 24, 25, 26, 27, 28, 29, 30],target = 50) == 4\n assert candidate(nums = [-50, 0, 50, -40, 40],target = 10) == 6\n assert candidate(nums = [15, 25, 35, 45, 55],target = 100) == 9\n assert candidate(nums = [1, -1, 2, -2, 3, -3],target = 0) == 6\n assert candidate(nums = [-25, -25, -25, -25, -25],target = -50) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 11) == 20\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, 0],target = -10) == 1245\n assert candidate(nums = [-40, -30, -20, -10, 0, 10, 20, 30],target = -5) == 16\n assert candidate(nums = [0, 0, 0, 0, 0],target = 1) == 10\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 0],target = -5) == 25\n assert candidate(nums = [10, -10, 20, -20, 30, -30],target = 0) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 36\n assert candidate(nums = [-5, 0, 5, 10, 15, 20, 25, 30, 35, 40],target = 20) == 9\n assert candidate(nums = [-49, -48, -47, -46, -45, -44, -43, -42, -41, -40],target = -80) == 45\n assert candidate(nums = [45, -45, 44, -44, 43, -43, 42],target = 0) == 9\n assert candidate(nums = [-10, 0, 10, 20, 30, 40, 50],target = 0) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],target = 0) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == 75\n assert candidate(nums = [5, 4, 3, 2, 1],target = 6) == 4\n assert candidate(nums = [5, 4, 3, 2, 1],target = 7) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1],target = 0) == 10\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5],target = 4) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 20) == 20\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5],target = 3) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 0\n assert candidate(nums = [49, -49, 48, -48, 47, -47, 46, -46, 45, -45],target = 0) == 20\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70],target = -100) == 4\n assert candidate(nums = [-5, -5, -5, -5, -5, 5, 5, 5, 5, 5],target = 0) == 10\n assert candidate(nums = [-10, -20, -30, 10, 20, 30, 0],target = -15) == 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 = 21) == 90\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 190) == 44\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 36\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],target = -11) == 20\n assert candidate(nums = [5, 8, -3, 6, 2, 7, 4, 1, -5, -10],target = 5) == 24\n assert candidate(nums = [50, 49, 48, 47, 46],target = 99) == 9\n assert candidate(nums = [23, 17, 42, 8, 3, 19, 5, 28],target = 30) == 11\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3],target = 1) == 12\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15],target = 45) == 46\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countPairs(List nums, int target) {", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "nums", "type": "List"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2825, "task_id": "make-string-a-subsequence-using-cyclic-increments", "difficulty": "Medium", "problem_description": "You are given two 0-indexed strings str1 and str2.\nIn an operation, you select a set of indices in str1, and for each index i in the set, increment str1[i] to the next character cyclically. That is 'a' becomes 'b', 'b' becomes 'c', and so on, and 'z' becomes 'a'.\nReturn true if it is possible to make str2 a subsequence of str1 by performing the operation at most once, and false otherwise.\nNote: A subsequence of a string is a new string that is formed from the original string by deleting some (possibly none) of the characters without disturbing the relative positions of the remaining characters.\n \nExample 1:\n\nInput: str1 = \"abc\", str2 = \"ad\"\nOutput: true\nExplanation: Select index 2 in str1.\nIncrement str1[2] to become 'd'. \nHence, str1 becomes \"abd\" and str2 is now a subsequence. Therefore, true is returned.\nExample 2:\n\nInput: str1 = \"zc\", str2 = \"ad\"\nOutput: true\nExplanation: Select indices 0 and 1 in str1. \nIncrement str1[0] to become 'a'. \nIncrement str1[1] to become 'd'. \nHence, str1 becomes \"ad\" and str2 is now a subsequence. Therefore, true is returned.\nExample 3:\n\nInput: str1 = \"ab\", str2 = \"d\"\nOutput: false\nExplanation: In this example, it can be shown that it is impossible to make str2 a subsequence of str1 using the operation at most once. \nTherefore, false is returned.\n \nConstraints:\n\n1 <= str1.length <= 105\n1 <= str2.length <= 105\nstr1 and str2 consist of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(str1 = \"aaa\",str2 = \"a\") == True\n assert candidate(str1 = \"hello\",str2 = \"heo\") == True\n assert candidate(str1 = \"abcd\",str2 = \"bd\") == True\n assert candidate(str1 = \"zyxwvutsrqponmlkjihgfedcba\",str2 = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(str1 = \"abacaba\",str2 = \"aaa\") == True\n assert candidate(str1 = \"xyz\",str2 = \"yza\") == True\n assert candidate(str1 = \"abc\",str2 = \"abc\") == True\n assert candidate(str1 = \"ab\",str2 = \"d\") == False\n assert candidate(str1 = \"az\",str2 = \"ba\") == True\n assert candidate(str1 = \"abcde\",str2 = \"aec\") == False\n assert candidate(str1 = \"azazaz\",str2 = \"zzz\") == True\n assert candidate(str1 = \"abcde\",str2 = \"ae\") == True\n assert candidate(str1 = \"aabbccddeeff\",str2 = \"abcdef\") == True\n assert candidate(str1 = \"abcde\",str2 = \"ace\") == True\n assert candidate(str1 = \"a\",str2 = \"b\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(str1 = \"aabbcc\",str2 = \"abc\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"z\") == True\n assert candidate(str1 = \"aaa\",str2 = \"b\") == True\n assert candidate(str1 = \"abc\",str2 = \"acb\") == False\n assert candidate(str1 = \"zc\",str2 = \"ad\") == True\n assert candidate(str1 = \"abcxyz\",str2 = \"adz\") == True\n assert candidate(str1 = \"abc\",str2 = \"ad\") == True\n assert candidate(str1 = \"abcd\",str2 = \"dddd\") == False\n assert candidate(str1 = \"a\",str2 = \"a\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"za\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"gh\") == True\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"mnopqr\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = ('adaceg',)) == False\n assert candidate(str1 = \"acegikmoqsuwy\",str2 = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(str1 = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",str2 = \"abcabcabc\") == True\n assert candidate(str1 = \"a\",str2 = \"z\") == False\n assert candidate(str1 = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",str2 = \"acegikmoqsuwy\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",str2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyza\",str2 = \"abcdefghijklmnopqrstuvwxyza\") == True\n assert candidate(str1 = \"b\",str2 = \"a\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"op\") == True\n assert candidate(str1 = \"aaabbbcccdddeeefffggghhhiiiijjjjkkkkllllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\",str2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(str1 = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",str2 = ('xyzxyzxyz',)) == False\n assert candidate(str1 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",str2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",str2 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"wx\") == True\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"acegikmoqsuwy\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"qr\") == True\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzaaa\",str2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(str1 = \"abczyxwvutsrqponmlkjihgfedcba\",str2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"monp\") == False\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"mno\") == True\n assert candidate(str1 = \"zyxwvutsrqponmlkjihgfedcba\",str2 = \"a\") == True\n assert candidate(str1 = \"abcabcabcabcabcabc\",str2 = ('accaaa',)) == False\n assert candidate(str1 = \"abz\",str2 = \"abc\") == False\n assert candidate(str1 = \"abacabadabacaba\",str2 = \"abcd\") == True\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"nopqrstuvwxyz\") == True\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"zxcvbnmlkjhgfedcba\") == False\n assert candidate(str1 = \"abcdabcdabcdabcdabcdabcdabcd\",str2 = \"dddddddddd\") == True\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"nopqrstuvwy\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",str2 = \"zzz\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",str2 = \"zz\") == True\n assert candidate(str1 = \"zyxwvutsrqponmlkjihgfedcba\",str2 = \"mnopqrst\") == False\n assert candidate(str1 = \"aaaaabbbbbaaaaabbbbbaaaaabbbbb\",str2 = ('aaaaaabbbbb',)) == False\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = ('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',)) == False\n assert candidate(str1 = \"zyxwvutsrqponmlkjihgfedcba\",str2 = ('abcdefghijklmnopqrstuvwxyz',)) == False\n assert candidate(str1 = \"abcdeffedcbaz\",str2 = \"zzzz\") == False\n assert candidate(str1 = \"ababababababababababababababab\",str2 = \"bababa\") == True\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"mn\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"abcdefghijklmnopqrstuvwxyza\") == False\n assert candidate(str1 = \"abcdabcdabcd\",str2 = \"abdc\") == True\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"mnopqrstu\") == True\n assert candidate(str1 = \"aaabbbccc\",str2 = \"abc\") == True\n assert candidate(str1 = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\",str2 = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == True\n assert candidate(str1 = \"bdfhjlnprtvxz\",str2 = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(str1 = \"abcdeffedcba\",str2 = \"abcdef\") == True\n assert candidate(str1 = \"abcabcabcabcabcabcabcabc\",str2 = \"acbacbacbacbacbacbacbacbac\") == False\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"mnopqrs\") == True\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"zzz\") == True\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"aaaaaa\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"ef\") == True\n assert candidate(str1 = \"abcdeffedcba\",str2 = \"ace\") == True\n assert candidate(str1 = \"abcabcabcabcabcabcabcabcabcabc\",str2 = \"aaa\") == True\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == False\n assert candidate(str1 = \"z\",str2 = \"a\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(str1 = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"ad\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzaabcdefghijklmnopqrstuvwxyz\",str2 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(str1 = \"zyxwvutsrqponmlkjihgfedcba\",str2 = \"zaa\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"bd\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzaabcdefghijklmnopqrstuvwxyz\",str2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",str2 = \"zabc\") == True\n assert candidate(str1 = \"aaaabbbbccccddddaaaabbbbccccdddd\",str2 = \"abcdabcd\") == True\n assert candidate(str1 = \"abcxyz\",str2 = \"abcxyz\") == True\n assert candidate(str1 = \"abcde\",str2 = \"edcba\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"mn\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"zzz\") == False\n assert candidate(str1 = \"mnopqrsmnopqrsmnopqrs\",str2 = \"mnopqrspqrsmn\") == True\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"mnopqrstv\") == True\n assert candidate(str1 = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\",str2 = \"zyxzyxzyx\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"zzzzzzzzzz\") == False\n assert candidate(str1 = \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\",str2 = ('abcdabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc',)) == False\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"mnopqrst\") == True\n assert candidate(str1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",str2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",str2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(str1 = \"aaaabbbbcccc\",str2 = \"abac\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"uv\") == True\n assert candidate(str1 = \"xyzz\",str2 = \"az\") == True\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"mnop\") == True\n assert candidate(str1 = \"mnopqrstuvwxyzabcdefghijk\",str2 = \"mnopqrstuvwxyz\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",str2 = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzz\",str2 = \"aaaaaaaaaa\") == True\n assert candidate(str1 = \"zyxwvutsrqponmlkjihgfedcba\",str2 = \"az\") == True\n assert candidate(str1 = \"abz\",str2 = \"acz\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",str2 = ('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',)) == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"kl\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyza\",str2 = ('abcdefghijklmnopqrstuvwxz',)) == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyza\",str2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"m\") == True\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"ij\") == True\n assert candidate(str1 = \"abcdexyz\",str2 = \"acz\") == True\n assert candidate(str1 = \"zzz\",str2 = \"aaa\") == True\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"mnopqrstvw\") == True\n assert candidate(str1 = \"abcxyz\",str2 = \"zzz\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"ac\") == True\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = ('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',)) == False\n assert candidate(str1 = \"zaaaaaaaaabcdezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"ad\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyza\",str2 = ('abcdefghijklmnopqrstuvwxyzz',)) == False\n assert candidate(str1 = \"aaaaazzzzzaaaaazzzzzaaaaazzzzz\",str2 = ('zzzzzaaaaazzzzz',)) == False\n assert candidate(str1 = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",str2 = \"adadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadad\") == False\n assert candidate(str1 = \"bxyz\",str2 = \"abcd\") == False\n assert candidate(str1 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",str2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(str1 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",str2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"bdfhjlnprtvxz\") == True\n assert candidate(str1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",str2 = \"abcdefghijklmnopqrstuvwxyza\") == True\n assert candidate(str1 = \"yzabcd\",str2 = \"ad\") == True\n assert candidate(str1 = \"abcabcabcabcabcabcabcabc\",str2 = \"aaabbbccc\") == True\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"\") == True\n assert candidate(str1 = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\",str2 = \"abcdefghi\") == True\n assert candidate(str1 = \"aaaabbbbcccc\",str2 = \"abc\") == True\n assert candidate(str1 = \"abacabadabacaba\",str2 = \"abc\") == True\n assert candidate(str1 = \"aaaabbbbcccc\",str2 = ('abcb',)) == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"zabcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(str1 = \"zyzzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyz\",str2 = ('zyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyz',)) == False\n assert candidate(str1 = \"mnopqrstuvwxyza\",str2 = \"mnopq\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyza\",str2 = \"xyz\") == True\n assert candidate(str1 = \"abcdabcdabcdabcdabcdabcdabcdabcd\",str2 = ('abcdabcdabcd',)) == False\n assert candidate(str1 = \"zyxwvutsrqponmlkjihgfedcba\",str2 = \"azbycxdwevfugthsisrjrqponmlkjihgfedcba\") == False\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"yz\") == True\n assert candidate(str1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",str2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"st\") == True\n"}, "metadata": {"canonical_parameter_names": ["str1", "str2"], "leetcode_dataset_entry_point": "Solution().canMakeSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean canMakeSubsequence(String str1, String str2) {", "container": "Solution", "callable": "canMakeSubsequence", "parameters": [{"name": "str1", "type": "String"}, {"name": "str2", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2826, "task_id": "sorting-three-groups", "difficulty": "Medium", "problem_description": "You are given an integer array nums. Each element in nums is 1, 2 or 3. In each operation, you can remove an element from nums. Return the minimum number of operations to make nums non-decreasing.\n \nExample 1:\n\nInput: nums = [2,1,3,2,1]\nOutput: 3\nExplanation:\nOne of the optimal solutions is to remove nums[0], nums[2] and nums[3].\n\nExample 2:\n\nInput: nums = [1,3,2,1,3,3]\nOutput: 2\nExplanation:\nOne of the optimal solutions is to remove nums[1] and nums[2].\n\nExample 3:\n\nInput: nums = [2,2,2,2,3,3]\nOutput: 0\nExplanation:\nnums is already non-decreasing.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 3\n\n \nFollow-up: Can you come up with an algorithm that runs in O(n) time complexity?", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 3, 2, 2, 1]) == 3\n assert candidate(nums = [3, 3, 3, 2, 2, 2, 1, 1, 1]) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3]) == 2\n assert candidate(nums = [1, 1, 1]) == 0\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1]) == 4\n assert candidate(nums = [1, 2, 2, 1, 3]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 0\n assert candidate(nums = [1, 2, 3, 3, 3, 2, 1]) == 2\n assert candidate(nums = [1, 1, 1, 2, 2, 3]) == 0\n assert candidate(nums = [1, 3, 2, 1, 3, 3]) == 2\n assert candidate(nums = [1, 2, 2, 2, 2, 3, 3, 3]) == 0\n assert candidate(nums = [2, 1, 3, 2, 1]) == 3\n assert candidate(nums = [3, 2, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == 4\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2]) == 3\n assert candidate(nums = [2, 2, 2, 2, 3, 3]) == 0\n assert candidate(nums = [3, 1, 2, 3, 1, 2]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [3, 3, 2, 2, 1]) == 3\n assert candidate(nums = [2, 2, 1, 1, 3, 3]) == 2\n assert candidate(nums = [3, 2, 1]) == 2\n assert candidate(nums = [3, 2, 1, 2, 1]) == 3\n assert candidate(nums = [3, 3, 3]) == 0\n assert candidate(nums = [1, 2, 3, 3, 3, 2, 2, 1, 1, 1]) == 5\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [1, 2, 3, 3, 3]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3]) == 0\n assert candidate(nums = [2, 3, 1, 2, 3, 1, 2, 3]) == 4\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1]) == 4\n assert candidate(nums = [3, 3, 2, 2, 2, 1, 1, 1, 3, 3, 3, 2, 2, 1, 1]) == 9\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1]) == 2\n assert candidate(nums = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 2, 2, 1, 1]) == 4\n assert candidate(nums = [3, 3, 3, 2, 2, 2, 1, 1, 1, 3, 3, 3, 2, 2, 2, 1, 1, 1, 3, 3, 3]) == 12\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]) == 12\n assert candidate(nums = [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1]) == 5\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 7\n assert candidate(nums = [2, 2, 3, 1, 1, 2, 3, 3, 2, 1]) == 5\n assert candidate(nums = [3, 2, 1, 2, 3, 1, 2, 3]) == 4\n assert candidate(nums = [1, 3, 2, 2, 3, 1, 3, 2, 1, 3, 2]) == 5\n assert candidate(nums = [2, 3, 2, 1, 2, 3, 2, 1, 2]) == 4\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3]) == 4\n assert candidate(nums = [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, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 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]) == 0\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [3, 3, 2, 1, 1, 1, 2, 3]) == 3\n assert candidate(nums = [2, 1, 1, 2, 2, 3, 3, 3, 1, 1, 2, 2, 3]) == 5\n assert candidate(nums = [3, 3, 3, 1, 1, 1, 2, 2, 2]) == 3\n assert candidate(nums = [3, 3, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1]) == 8\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == 13\n assert candidate(nums = [3, 3, 2, 2, 2, 1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3]) == 0\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3]) == 3\n assert candidate(nums = [1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3]) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2]) == 8\n assert candidate(nums = [1, 3, 1, 2, 3, 1, 2, 3, 1]) == 4\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 6\n assert candidate(nums = [3, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3]) == 1\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 10\n assert candidate(nums = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 7\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 7\n assert candidate(nums = [3, 1, 2, 2, 1, 3, 3, 2, 1, 1, 3, 3, 2, 2, 1, 1]) == 9\n assert candidate(nums = [3, 2, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 10\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]) == 20\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 8\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [1, 1, 2, 2, 2, 1, 1, 3, 3, 3, 1, 1]) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 4\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 = [2, 1, 1, 3, 2, 3, 1, 2, 3]) == 4\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 0\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 12\n assert candidate(nums = [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [3, 2, 1, 2, 1, 3, 1]) == 4\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 8\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]) == 0\n assert candidate(nums = [3, 1, 3, 2, 3, 1, 2, 1, 3]) == 5\n assert candidate(nums = [2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1]) == 21\n assert candidate(nums = [1, 3, 3, 3, 2, 2, 1, 1]) == 4\n assert candidate(nums = [3, 3, 3, 1, 2, 2, 1, 1]) == 5\n assert candidate(nums = [2, 3, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == 11\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 11\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 5\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, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == 21\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2]) == 4\n assert candidate(nums = [3, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 6\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3]) == 4\n assert candidate(nums = [2, 2, 1, 1, 3, 3, 2, 2, 3, 3]) == 4\n assert candidate(nums = [1, 3, 3, 1, 2, 2, 1, 3, 3, 2]) == 4\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 5\n assert candidate(nums = [2, 2, 3, 1, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1]) == 9\n assert candidate(nums = [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]) == 19\n assert candidate(nums = [2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1]) == 7\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == 12\n assert candidate(nums = [1, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1, 2, 3]) == 5\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1, 1]) == 5\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 6\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 12\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == 7\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 6\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 3, 3, 3, 2, 2, 2]) == 6\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2]) == 4\n assert candidate(nums = [2, 1, 2, 1, 3, 2, 1, 2, 3, 3]) == 4\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 = [1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [2, 2, 3, 1, 2, 3, 1, 2]) == 4\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]) == 13\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 4\n assert candidate(nums = [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 = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 8\n assert candidate(nums = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 10\n assert candidate(nums = [3, 2, 2, 1, 1, 1, 2, 3, 3, 3]) == 3\n assert candidate(nums = [3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3]) == 8\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 5\n assert candidate(nums = [1, 1, 1, 3, 3, 3, 2, 2, 2, 1, 1, 1, 3, 3, 3]) == 6\n assert candidate(nums = [1, 3, 3, 3, 2, 2, 1, 1, 3]) == 4\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 6\n assert candidate(nums = [2, 3, 1, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 9\n assert candidate(nums = [2, 3, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 6\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 6\n assert candidate(nums = [2, 3, 1, 3, 2, 1, 2, 3, 1]) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumOperations(List nums) {", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "nums", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2827, "task_id": "number-of-beautiful-integers-in-the-range", "difficulty": "Hard", "problem_description": "You are given positive integers low, high, and k.\nA number is beautiful if it meets both of the following conditions:\n\nThe count of even digits in the number is equal to the count of odd digits.\nThe number is divisible by k.\n\nReturn the number of beautiful integers in the range [low, high].\n \nExample 1:\n\nInput: low = 10, high = 20, k = 3\nOutput: 2\nExplanation: There are 2 beautiful integers in the given range: [12,18]. \n- 12 is beautiful because it contains 1 odd digit and 1 even digit, and is divisible by k = 3.\n- 18 is beautiful because it contains 1 odd digit and 1 even digit, and is divisible by k = 3.\nAdditionally we can see that:\n- 16 is not beautiful because it is not divisible by k = 3.\n- 15 is not beautiful because it does not contain equal counts even and odd digits.\nIt can be shown that there are only 2 beautiful integers in the given range.\n\nExample 2:\n\nInput: low = 1, high = 10, k = 1\nOutput: 1\nExplanation: There is 1 beautiful integer in the given range: [10].\n- 10 is beautiful because it contains 1 odd digit and 1 even digit, and is divisible by k = 1.\nIt can be shown that there is only 1 beautiful integer in the given range.\n\nExample 3:\n\nInput: low = 5, high = 5, k = 2\nOutput: 0\nExplanation: There are 0 beautiful integers in the given range.\n- 5 is not beautiful because it is not divisible by k = 2 and it does not contain equal even and odd digits.\n\n \nConstraints:\n\n0 < low <= high <= 109\n0 < k <= 20\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(low = 100,high = 200,k = 4) == 0\n assert candidate(low = 100,high = 200,k = 5) == 0\n assert candidate(low = 10,high = 20,k = 3) == 2\n assert candidate(low = 1,high = 10,k = 1) == 1\n assert candidate(low = 100,high = 200,k = 7) == 0\n assert candidate(low = 123,high = 456,k = 7) == 0\n assert candidate(low = 1000,high = 10000,k = 7) == 483\n assert candidate(low = 123,high = 456,k = 5) == 0\n assert candidate(low = 5,high = 5,k = 2) == 0\n assert candidate(low = 1000,high = 10000,k = 11) == 460\n assert candidate(low = 999999,high = 999999,k = 1) == 0\n assert candidate(low = 123456,high = 654321,k = 15) == 11026\n assert candidate(low = 1000,high = 9999,k = 11) == 460\n assert candidate(low = 100000,high = 999999,k = 19) == 14801\n assert candidate(low = 9876543,high = 12345678,k = 16) == 44999\n assert candidate(low = 111111,high = 222222,k = 12) == 3183\n assert candidate(low = 99999,high = 100001,k = 1) == 0\n assert candidate(low = 1000000,high = 8000000,k = 7) == 0\n assert candidate(low = 100000,high = 500000,k = 19) == 6575\n assert candidate(low = 1234567,high = 7654321,k = 18) == 0\n assert candidate(low = 345678,high = 876543,k = 20) == 6510\n assert candidate(low = 5000,high = 15000,k = 13) == 147\n assert candidate(low = 100000,high = 1000000,k = 17) == 16544\n assert candidate(low = 1234,high = 5678,k = 9) == 251\n assert candidate(low = 10000000,high = 20000000,k = 9) == 306040\n assert candidate(low = 5000,high = 50000,k = 3) == 627\n assert candidate(low = 250000,high = 350000,k = 5) == 6500\n assert candidate(low = 1000000,high = 10000000,k = 19) == 0\n assert candidate(low = 50000000,high = 60000000,k = 20) == 156250\n assert candidate(low = 99999,high = 100000,k = 13) == 0\n assert candidate(low = 111111111,high = 222222222,k = 7) == 0\n assert candidate(low = 1000000,high = 2000000,k = 19) == 0\n assert candidate(low = 777777,high = 888888,k = 18) == 1644\n assert candidate(low = 1000,high = 10000,k = 12) == 276\n assert candidate(low = 987654321,high = 987654321,k = 11) == 0\n assert candidate(low = 1234,high = 5678,k = 17) == 101\n assert candidate(low = 100000000,high = 999999999,k = 3) == 0\n assert candidate(low = 123456,high = 789012,k = 17) == 12253\n assert candidate(low = 1111111,high = 2222222,k = 14) == 0\n assert candidate(low = 10000,high = 99999,k = 17) == 0\n assert candidate(low = 123456789,high = 987654321,k = 9) == 0\n assert candidate(low = 1000,high = 10000,k = 13) == 263\n assert candidate(low = 12345,high = 67890,k = 17) == 0\n assert candidate(low = 500000000,high = 600000000,k = 13) == 0\n assert candidate(low = 50000,high = 60000,k = 15) == 0\n assert candidate(low = 100000000,high = 999999999,k = 17) == 0\n assert candidate(low = 500,high = 2000,k = 17) == 21\n assert candidate(low = 11111,high = 22222,k = 14) == 0\n assert candidate(low = 123456,high = 789012,k = 15) == 13887\n assert candidate(low = 2000,high = 3000,k = 20) == 0\n assert candidate(low = 3333333,high = 4444444,k = 16) == 0\n assert candidate(low = 987654321,high = 987654321,k = 19) == 0\n assert candidate(low = 10000,high = 100000,k = 13) == 0\n assert candidate(low = 123456,high = 654321,k = 3) == 55100\n assert candidate(low = 555555,high = 666666,k = 16) == 1899\n assert candidate(low = 500000,high = 600000,k = 20) == 1875\n assert candidate(low = 111111,high = 222222,k = 13) == 2615\n assert candidate(low = 123456,high = 654321,k = 17) == 9719\n assert candidate(low = 234567,high = 765432,k = 25) == 6663\n assert candidate(low = 99990,high = 100000,k = 2) == 0\n assert candidate(low = 12345678,high = 87654321,k = 16) == 1236425\n assert candidate(low = 987654,high = 9876543,k = 3) == 1120\n assert candidate(low = 1000,high = 9999,k = 12) == 276\n assert candidate(low = 123456789,high = 987654321,k = 5) == 0\n assert candidate(low = 100000,high = 1000000,k = 19) == 14801\n assert candidate(low = 123456,high = 654321,k = 19) == 8693\n assert candidate(low = 500000,high = 550000,k = 20) == 875\n assert candidate(low = 1234567,high = 8765432,k = 5) == 0\n assert candidate(low = 10000000,high = 20000000,k = 5) == 546875\n assert candidate(low = 11111111,high = 22222222,k = 7) == 426428\n assert candidate(low = 55555555,high = 88888888,k = 9) == 1034831\n assert candidate(low = 100,high = 1000,k = 3) == 0\n assert candidate(low = 999,high = 1000000,k = 13) == 21897\n assert candidate(low = 100000,high = 999999,k = 3) == 93760\n assert candidate(low = 100,high = 1000,k = 9) == 0\n assert candidate(low = 100,high = 999,k = 9) == 0\n assert candidate(low = 123456789,high = 987654321,k = 18) == 0\n assert candidate(low = 200000,high = 300000,k = 5) == 6250\n assert candidate(low = 100,high = 1000,k = 5) == 0\n assert candidate(low = 111111,high = 222222,k = 19) == 1785\n assert candidate(low = 500000,high = 600000,k = 19) == 1643\n assert candidate(low = 10000000,high = 20000000,k = 18) == 174880\n assert candidate(low = 100000,high = 999999,k = 17) == 16544\n assert candidate(low = 111111,high = 222222,k = 21) == 1614\n assert candidate(low = 1000000,high = 10000000,k = 2) == 0\n assert candidate(low = 333333,high = 444444,k = 14) == 2525\n assert candidate(low = 1111111,high = 8888888,k = 20) == 0\n assert candidate(low = 10000,high = 100000,k = 11) == 0\n assert candidate(low = 100,high = 1000,k = 11) == 0\n assert candidate(low = 1234,high = 8765,k = 11) == 386\n assert candidate(low = 750000,high = 850000,k = 7) == 4287\n assert candidate(low = 1000000,high = 10000000,k = 15) == 0\n assert candidate(low = 111111,high = 222222,k = 18) == 2196\n assert candidate(low = 234567,high = 765432,k = 18) == 10488\n assert candidate(low = 11111,high = 99999,k = 13) == 0\n assert candidate(low = 333333333,high = 666666666,k = 7) == 0\n assert candidate(low = 1,high = 1000000000,k = 20) == 1105750\n assert candidate(low = 1000000,high = 2000000,k = 15) == 0\n assert candidate(low = 10000,high = 99999,k = 13) == 0\n"}, "metadata": {"canonical_parameter_names": ["low", "high", "k"], "leetcode_dataset_entry_point": "Solution().numberOfBeautifulIntegers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfBeautifulIntegers(int low, int high, int k) {", "container": "Solution", "callable": "numberOfBeautifulIntegers", "parameters": [{"name": "low", "type": "int"}, {"name": "high", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2828, "task_id": "check-if-a-string-is-an-acronym-of-words", "difficulty": "Easy", "problem_description": "Given an array of strings words and a string s, determine if s is an acronym of words.\nThe string s is considered an acronym of words if it can be formed by concatenating the first character of each string in words in order. For example, \"ab\" can be formed from [\"apple\", \"banana\"], but it can't be formed from [\"bear\", \"aardvark\"].\nReturn true if s is an acronym of words, and false otherwise. \n \nExample 1:\n\nInput: words = [\"alice\",\"bob\",\"charlie\"], s = \"abc\"\nOutput: true\nExplanation: The first character in the words \"alice\", \"bob\", and \"charlie\" are 'a', 'b', and 'c', respectively. Hence, s = \"abc\" is the acronym. \n\nExample 2:\n\nInput: words = [\"an\",\"apple\"], s = \"a\"\nOutput: false\nExplanation: The first character in the words \"an\" and \"apple\" are 'a' and 'a', respectively. \nThe acronym formed by concatenating these characters is \"aa\". \nHence, s = \"a\" is not the acronym.\n\nExample 3:\n\nInput: words = [\"never\",\"gonna\",\"give\",\"up\",\"on\",\"you\"], s = \"ngguoy\"\nOutput: true\nExplanation: By concatenating the first character of the words in the array, we get the string \"ngguoy\". \nHence, s = \"ngguoy\" is the acronym.\n\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 10\n1 <= s.length <= 100\nwords[i] and s consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['different', 'words', 'here'],s = \"dwh\") == True\n assert candidate(words = ['dog', 'cat'],s = \"dc\") == True\n assert candidate(words = ['single'],s = \"s\") == True\n assert candidate(words = ['make', 'america', 'great', 'again'],s = \"mag\") == False\n assert candidate(words = ['quick', 'brown', 'fox'],s = \"qbf\") == True\n assert candidate(words = ['one', 'two', 'three', 'four'],s = \"otfh\") == False\n assert candidate(words = ['python', 'programming', 'is', 'fun'],s = \"ppif\") == True\n assert candidate(words = ['an', 'apple'],s = \"a\") == False\n assert candidate(words = ['python', 'is', 'fun'],s = \"pif\") == True\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],s = \"abcde\") == True\n assert candidate(words = ['a'],s = \"a\") == True\n assert candidate(words = ['hello', 'world'],s = \"hw\") == True\n assert candidate(words = ['never', 'gonna', 'give', 'up', 'on', 'you'],s = \"ngguoy\") == True\n assert candidate(words = ['ab', 'cd'],s = \"ac\") == True\n assert candidate(words = ['one'],s = \"o\") == True\n assert candidate(words = ['abc', 'def', 'ghi'],s = \"adg\") == True\n assert candidate(words = ['longer', 'words', 'example'],s = \"lwe\") == True\n assert candidate(words = ['python', 'programming'],s = \"pp\") == True\n assert candidate(words = ['the', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'],s = \"tqbfjotld\") == True\n assert candidate(words = ['alice', 'bob', 'charlie'],s = \"abc\") == True\n assert candidate(words = ['one', 'two', 'three'],s = \"ot\") == False\n assert candidate(words = ['unique', 'words', 'here'],s = \"uwh\") == True\n assert candidate(words = ['same', 'same', 'same'],s = \"sss\") == True\n assert candidate(words = ['hello', 'every', 'one'],s = \"heo\") == True\n assert candidate(words = ['cloud', 'computing', 'services'],s = \"ccs\") == True\n assert candidate(words = ['very', 'long', 'words', 'in', 'the', 'list'],s = \"vlwitl\") == True\n assert candidate(words = ['internet', 'of', 'things'],s = \"iot\") == True\n assert candidate(words = ['many', 'letters', 'make', 'the', 'longest', 'acronym'],s = \"mlmtla\") == True\n assert candidate(words = ['binary', 'search', 'tree'],s = \"bst\") == True\n assert candidate(words = ['repeated', 'characters', 'characters', 'in', 'words'],s = \"rcciw\") == True\n assert candidate(words = ['magnificent', 'opulent', 'rich', 'elegant', 'grand'],s = \"moreg\") == True\n assert candidate(words = ['transcendent', 'effervescent', 'mellifluous'],s = \"tem\") == True\n assert candidate(words = ['aardvark', 'bear', 'cat', 'dog', 'elephant', 'frog'],s = \"abcdef\") == True\n assert candidate(words = ['quick', 'brown', 'fox', 'jumps', 'over', 'lazy', 'dogs'],s = \"qbfjold\") == True\n assert candidate(words = ['ambidextrous', 'bilingual', 'chirpy', 'dextrous', 'eloquent'],s = \"abcde\") == True\n assert candidate(words = ['quintessential', 'programming', 'language'],s = \"qpl\") == True\n assert candidate(words = ['cryptic', 'enigma', 'mystery'],s = \"cem\") == True\n assert candidate(words = ['gargantuan', 'colossal', 'tremendous'],s = \"gct\") == True\n assert candidate(words = ['phoenix', 'reborn', 'immortal'],s = \"pri\") == True\n assert candidate(words = ['abracadabra', 'is', 'amazing'],s = \"aia\") == True\n assert candidate(words = ['algorithm', 'data', 'structures'],s = \"ads\") == True\n assert candidate(words = ['almost', 'correct', 'acronym'],s = \"aca\") == True\n assert candidate(words = ['various', 'lengths', 'words', 'here'],s = \"vlwh\") == True\n assert candidate(words = ['creating', 'additional', 'sample', 'data', 'for', 'testing'],s = \"cadft\") == False\n assert candidate(words = ['this', 'is', 'just', 'another', 'test', 'case'],s = \"tijatc\") == True\n assert candidate(words = ['hong', 'kong', 'international', 'airport'],s = \"hkia\") == True\n assert candidate(words = ['xylophone', 'yak', 'zebra'],s = \"xyz\") == True\n assert candidate(words = ['vivacious', 'energetic', 'enthusiastic'],s = \"vee\") == True\n assert candidate(words = ['algorithm', 'data', 'structure'],s = \"ads\") == True\n assert candidate(words = ['hello', 'world', 'this', 'is', 'a', 'test'],s = \"hwtiat\") == True\n assert candidate(words = ['various', 'strings', 'concatenate', 'properly', 'form', 'acronyms'],s = \"vspcfa\") == False\n assert candidate(words = ['panoramic', 'vista', 'landscape'],s = \"pvl\") == True\n assert candidate(words = ['united', 'states', 'of', 'america'],s = \"usoa\") == True\n assert candidate(words = ['neurotransmitter', 'serotonin', 'dopamine'],s = \"nsd\") == True\n assert candidate(words = ['unique', 'letters', 'every', 'word'],s = \"ulew\") == True\n assert candidate(words = ['sunshine', 'in', 'the', 'morning'],s = \"sitem\") == False\n assert candidate(words = ['mount', 'rainier', 'national', 'park'],s = \"mrnp\") == True\n assert candidate(words = ['washington', 'd', 'c'],s = \"wdc\") == True\n assert candidate(words = ['artificial', 'intelligence'],s = \"ai\") == True\n assert candidate(words = ['central', 'park', 'zoo'],s = \"cpz\") == True\n assert candidate(words = ['zephyr', 'whisper', 'gale'],s = \"zwg\") == True\n assert candidate(words = ['development', 'environment', 'setup'],s = \"des\") == True\n assert candidate(words = ['randomized', 'quick', 'sort'],s = \"rqs\") == True\n assert candidate(words = ['programming', 'questions', 'are', 'fun'],s = \"pqaf\") == True\n assert candidate(words = ['multiple', 'words', 'with', 'different', 'lengths', 'here'],s = \"mwdlh\") == False\n assert candidate(words = ['natural', 'language', 'processing'],s = \"nlp\") == True\n assert candidate(words = ['philosophy', 'physics', 'psychology', 'programming', 'python'],s = \"ppppp\") == True\n assert candidate(words = ['exquisite', 'ornate', 'lavish'],s = \"eol\") == True\n assert candidate(words = ['beautiful', 'day', 'at', 'the', 'beach'],s = \"bdatb\") == True\n assert candidate(words = ['make', 'sure', 'every', 'character', 'is', 'captured'],s = \"mseic\") == False\n assert candidate(words = ['machine', 'learning', 'models', 'are', 'awesome'],s = \"mlmaa\") == True\n assert candidate(words = ['supercalifragilisticexpialidocious', 'antidisestablishmentarianism', 'pneumonoultramicroscopicsilicovolcanoconiosis'],s = \"saap\") == False\n assert candidate(words = ['almost', 'correct', 'but', 'one', 'letter', 'off'],s = \"accblo\") == False\n assert candidate(words = ['complex', 'example', 'with', 'repeated', 'characters'],s = \"cewrcc\") == False\n assert candidate(words = ['this', 'is', 'a', 'much', 'longer', 'acronym', 'test', 'case'],s = \"tiamalte\") == False\n assert candidate(words = ['golden', 'state', 'expressway'],s = \"gsex\") == False\n assert candidate(words = ['diamond', 'opal', 'emerald'],s = \"doe\") == True\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'],s = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['multiple', 'characters', 'in', 'each', 'word'],s = \"mciew\") == True\n assert candidate(words = ['magnificent', 'butterfly', 'effect'],s = \"mbe\") == True\n assert candidate(words = ['xylophone', 'yankee', 'zebra'],s = \"xyz\") == True\n assert candidate(words = ['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'],s = \"xyzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['small', 'words', 'lead', 'to', 'big', 'results'],s = \"swlttbr\") == False\n assert candidate(words = ['random', 'words', 'for', 'testing', 'purposes'],s = \"rwftp\") == True\n assert candidate(words = ['repeated', 'words', 'words', 'repeated'],s = \"rwwr\") == True\n assert candidate(words = ['onomatopoeia', 'pneumonoultramicroscopicsilicovolcanoconiosis', 'supercalifragilisticexpialidocious'],s = \"opu\") == False\n assert candidate(words = ['extremely', 'long', 'string', 'to', 'test'],s = \"elstt\") == True\n assert candidate(words = ['question', 'writing', 'exclusive', 'nice', 'documents'],s = \"qwend\") == True\n assert candidate(words = ['generate', 'multiple', 'complex', 'examples', 'to', 'ensure'],s = \"gmceet\") == False\n assert candidate(words = ['this', 'problem', 'seems', 'fairly', 'interesting'],s = \"tpsfii\") == False\n assert candidate(words = ['mismatch', 'example'],s = \"mme\") == False\n assert candidate(words = ['quick', 'brown', 'fox', 'jumps', 'over', 'lazy', 'dog'],s = \"qbfjold\") == True\n assert candidate(words = ['random', 'characters', 'generate', 'test', 'inputs'],s = \"rcgti\") == True\n assert candidate(words = ['complex', 'programming', 'challenge'],s = \"cpc\") == True\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same'],s = \"ssssssssss\") == True\n assert candidate(words = ['let', 'us', 'test', 'some', 'edge', 'cases', 'here'],s = \"lustsech\") == False\n assert candidate(words = ['algorithms', 'data', 'structures', 'and', 'interviews'],s = \"adssai\") == False\n assert candidate(words = ['generate', 'additional', 'inputs', 'automatically'],s = \"gaia\") == True\n assert candidate(words = ['golden', 'gate', 'bridge'],s = \"ggb\") == True\n assert candidate(words = ['quicksilver', 'zephyr', 'deluxe'],s = \"qzd\") == True\n assert candidate(words = ['cryptic', 'enigmatic', 'mysterious', 'obscure'],s = \"ceom\") == False\n assert candidate(words = ['augmented', 'reality', 'technology'],s = \"art\") == True\n assert candidate(words = ['generative', 'adversarial', 'networks'],s = \"gan\") == True\n assert candidate(words = ['repeated', 'repeated', 'repeated', 'repeated'],s = \"rrrr\") == True\n assert candidate(words = ['tiny', 'words'],s = \"tw\") == True\n assert candidate(words = ['revelation', 'salvation', 'transformation', 'unification', 'verification', 'wisdom', 'xenial', 'youthful', 'zealous'],s = \"rstuvwxyz\") == True\n assert candidate(words = ['quicksilver', 'falcon', 'spiderman'],s = \"qfs\") == True\n assert candidate(words = ['xylophone', 'yellow', 'zoo'],s = \"xyz\") == True\n assert candidate(words = ['algorithms', 'data', 'structures'],s = \"ads\") == True\n assert candidate(words = ['find', 'the', 'hidden', 'pattern'],s = \"fthp\") == True\n assert candidate(words = ['machine', 'learning', 'algorithms'],s = \"mla\") == True\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],s = \"adgjmpsvy\") == True\n assert candidate(words = ['programming', 'languages', 'are', 'awesome'],s = \"plaaw\") == False\n assert candidate(words = ['very', 'long', 'wordstocheck', 'the', 'acronym', 'functionality'],s = \"vlwtcaf\") == False\n assert candidate(words = ['this', 'is', 'a', 'test', 'case', 'with', 'multiple', 'words'],s = \"tiatcmw\") == False\n assert candidate(words = ['quicksilver', 'silver', 'mercury'],s = \"qsm\") == True\n assert candidate(words = ['deep', 'neural', 'networks'],s = \"dnn\") == True\n assert candidate(words = ['programming', 'language', 'comprehension', 'practice'],s = \"plcp\") == True\n assert candidate(words = ['keep', 'coding', 'every', 'day'],s = \"kced\") == True\n assert candidate(words = ['a', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'],s = \"aqbfojtld\") == False\n assert candidate(words = ['mississippi', 'river', 'flows', 'southward'],s = \"mrfs\") == True\n assert candidate(words = ['longwordnumberone', 'longwordnumbertwo', 'longwordnumberthree'],s = \"lmolwntlm\") == False\n assert candidate(words = ['fantastic', 'terrific', 'excellent'],s = \"fte\") == True\n assert candidate(words = ['quick', 'brown', 'fox', 'jumps', 'over', 'lazy', 'dog'],s = \"qbfojld\") == False\n assert candidate(words = ['quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'],s = \"qbfjotld\") == True\n assert candidate(words = ['virtual', 'reality', 'experience'],s = \"vre\") == True\n assert candidate(words = ['every', 'good', 'boy', 'does', 'fine'],s = \"egbdf\") == True\n assert candidate(words = ['ubiquitous', 'omnipresent', 'everywhere'],s = \"uoe\") == True\n assert candidate(words = ['new', 'york', 'city'],s = \"nyc\") == True\n"}, "metadata": {"canonical_parameter_names": ["words", "s"], "leetcode_dataset_entry_point": "Solution().isAcronym", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isAcronym(List words, String s) {", "container": "Solution", "callable": "isAcronym", "parameters": [{"name": "words", "type": "List"}, {"name": "s", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2829, "task_id": "determine-the-minimum-sum-of-a-k-avoiding-array", "difficulty": "Medium", "problem_description": "You are given two integers, n and k.\nAn array of distinct positive integers is called a k-avoiding array if there does not exist any pair of distinct elements that sum to k.\nReturn the minimum possible sum of a k-avoiding array of length n.\n \nExample 1:\n\nInput: n = 5, k = 4\nOutput: 18\nExplanation: Consider the k-avoiding array [1,2,4,5,6], which has a sum of 18.\nIt can be proven that there is no k-avoiding array with a sum less than 18.\n\nExample 2:\n\nInput: n = 2, k = 6\nOutput: 3\nExplanation: We can construct the array [1,2], which has a sum of 3.\nIt can be proven that there is no k-avoiding array with a sum less than 3.\n\n \nConstraints:\n\n1 <= n, k <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,k = 8) == 10\n assert candidate(n = 3,k = 5) == 8\n assert candidate(n = 10,k = 15) == 76\n assert candidate(n = 4,k = 7) == 13\n assert candidate(n = 7,k = 10) == 36\n assert candidate(n = 2,k = 6) == 3\n assert candidate(n = 10,k = 10) == 75\n assert candidate(n = 5,k = 4) == 18\n assert candidate(n = 15,k = 8) == 153\n assert candidate(n = 10,k = 18) == 63\n assert candidate(n = 8,k = 16) == 36\n assert candidate(n = 35,k = 35) == 936\n assert candidate(n = 20,k = 30) == 280\n assert candidate(n = 15,k = 25) == 156\n assert candidate(n = 15,k = 3) == 134\n assert candidate(n = 30,k = 31) == 690\n assert candidate(n = 50,k = 1) == 1275\n assert candidate(n = 9,k = 11) == 65\n assert candidate(n = 30,k = 15) == 626\n assert candidate(n = 45,k = 30) == 1455\n assert candidate(n = 10,k = 9) == 79\n assert candidate(n = 12,k = 8) == 102\n assert candidate(n = 45,k = 40) == 1510\n assert candidate(n = 6,k = 11) == 26\n assert candidate(n = 40,k = 20) == 1090\n assert candidate(n = 12,k = 13) == 114\n assert candidate(n = 25,k = 16) == 444\n assert candidate(n = 5,k = 20) == 15\n assert candidate(n = 28,k = 18) == 558\n assert candidate(n = 25,k = 20) == 460\n assert candidate(n = 45,k = 11) == 1235\n assert candidate(n = 48,k = 49) == 1752\n assert candidate(n = 15,k = 12) == 165\n assert candidate(n = 49,k = 25) == 1669\n assert candidate(n = 15,k = 30) == 120\n assert candidate(n = 9,k = 12) == 60\n assert candidate(n = 9,k = 14) == 57\n assert candidate(n = 30,k = 25) == 681\n assert candidate(n = 10,k = 5) == 71\n assert candidate(n = 18,k = 18) == 243\n assert candidate(n = 17,k = 22) == 213\n assert candidate(n = 5,k = 10) == 15\n assert candidate(n = 49,k = 30) == 1701\n assert candidate(n = 18,k = 7) == 216\n assert candidate(n = 8,k = 9) == 52\n assert candidate(n = 30,k = 10) == 565\n assert candidate(n = 20,k = 12) == 280\n assert candidate(n = 30,k = 35) == 686\n assert candidate(n = 25,k = 30) == 465\n assert candidate(n = 35,k = 25) == 906\n assert candidate(n = 40,k = 45) == 1216\n assert candidate(n = 8,k = 12) == 46\n assert candidate(n = 15,k = 5) == 146\n assert candidate(n = 20,k = 15) == 301\n assert candidate(n = 50,k = 51) == 1900\n assert candidate(n = 20,k = 8) == 258\n assert candidate(n = 35,k = 20) == 855\n assert candidate(n = 30,k = 40) == 655\n assert candidate(n = 50,k = 50) == 1875\n assert candidate(n = 22,k = 27) == 370\n assert candidate(n = 45,k = 45) == 1541\n assert candidate(n = 28,k = 28) == 588\n assert candidate(n = 15,k = 20) == 165\n assert candidate(n = 45,k = 47) == 1541\n assert candidate(n = 14,k = 18) == 145\n assert candidate(n = 12,k = 18) == 102\n assert candidate(n = 8,k = 8) == 48\n assert candidate(n = 40,k = 35) == 1211\n assert candidate(n = 40,k = 30) == 1170\n assert candidate(n = 6,k = 35) == 21\n assert candidate(n = 14,k = 9) == 145\n assert candidate(n = 20,k = 25) == 306\n assert candidate(n = 40,k = 10) == 960\n assert candidate(n = 25,k = 50) == 325\n assert candidate(n = 50,k = 40) == 1845\n assert candidate(n = 45,k = 20) == 1350\n assert candidate(n = 25,k = 100) == 325\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().minimumSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumSum(int n, int k) {", "container": "Solution", "callable": "minimumSum", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2830, "task_id": "maximize-the-profit-as-the-salesman", "difficulty": "Medium", "problem_description": "You are given an integer n representing the number of houses on a number line, numbered from 0 to n - 1.\nAdditionally, you are given a 2D integer array offers where offers[i] = [starti, endi, goldi], indicating that ith buyer wants to buy all the houses from starti to endi for goldi amount of gold.\nAs a salesman, your goal is to maximize your earnings by strategically selecting and selling houses to buyers.\nReturn the maximum amount of gold you can earn.\nNote that different buyers can't buy the same house, and some houses may remain unsold.\n \nExample 1:\n\nInput: n = 5, offers = [[0,0,1],[0,2,2],[1,3,2]]\nOutput: 3\nExplanation: There are 5 houses numbered from 0 to 4 and there are 3 purchase offers.\nWe sell houses in the range [0,0] to 1st buyer for 1 gold and houses in the range [1,3] to 3rd buyer for 2 golds.\nIt can be proven that 3 is the maximum amount of gold we can achieve.\n\nExample 2:\n\nInput: n = 5, offers = [[0,0,1],[0,2,10],[1,3,2]]\nOutput: 10\nExplanation: There are 5 houses numbered from 0 to 4 and there are 3 purchase offers.\nWe sell houses in the range [0,2] to 2nd buyer for 10 golds.\nIt can be proven that 10 is the maximum amount of gold we can achieve.\n\n \nConstraints:\n\n1 <= n <= 105\n1 <= offers.length <= 105\noffers[i].length == 3\n0 <= starti <= endi <= n - 1\n1 <= goldi <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,offers = [[0, 4, 10], [1, 5, 15], [3, 7, 20], [8, 9, 5]]) == 25\n assert candidate(n = 10,offers = [[0, 4, 10], [1, 5, 11], [2, 6, 12]]) == 12\n assert candidate(n = 10,offers = [[0, 1, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [8, 9, 5]]) == 15\n assert candidate(n = 5,offers = [[0, 0, 1], [0, 2, 2], [1, 3, 2]]) == 3\n assert candidate(n = 8,offers = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400]]) == 600\n assert candidate(n = 3,offers = [[0, 0, 5], [1, 1, 5], [2, 2, 5]]) == 15\n assert candidate(n = 10,offers = [[0, 4, 5], [1, 5, 6], [2, 6, 7], [3, 7, 8]]) == 8\n assert candidate(n = 10,offers = [[0, 9, 100], [1, 8, 90], [2, 7, 80], [3, 6, 70], [4, 5, 60]]) == 100\n assert candidate(n = 10,offers = [[0, 4, 10], [1, 5, 11], [2, 6, 12], [3, 7, 13], [4, 8, 14]]) == 14\n assert candidate(n = 5,offers = [[0, 0, 1], [0, 2, 10], [1, 3, 2]]) == 10\n assert candidate(n = 7,offers = [[0, 6, 15], [1, 5, 20], [2, 4, 25], [3, 3, 30]]) == 30\n assert candidate(n = 3,offers = [[0, 0, 10], [1, 1, 10], [2, 2, 10]]) == 30\n assert candidate(n = 7,offers = [[0, 2, 3], [1, 3, 5], [2, 4, 7], [3, 5, 9], [4, 6, 11]]) == 16\n assert candidate(n = 10,offers = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]]) == 9\n assert candidate(n = 7,offers = [[0, 6, 100], [1, 3, 50], [2, 4, 60], [4, 5, 30]]) == 100\n assert candidate(n = 100000,offers = [[0, 99999, 1000], [50000, 99999, 500], [0, 49999, 500]]) == 1000\n assert candidate(n = 3,offers = [[0, 0, 5], [1, 1, 6], [2, 2, 7]]) == 18\n assert candidate(n = 100,offers = [[0, 99, 1000], [50, 99, 500], [0, 49, 500]]) == 1000\n assert candidate(n = 10,offers = [[0, 0, 5], [0, 9, 90], [1, 1, 5], [1, 8, 85], [2, 2, 5], [2, 7, 80], [3, 3, 5], [3, 6, 75], [4, 4, 5], [4, 5, 70], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5]]) == 110\n assert candidate(n = 50,offers = [[0, 9, 100], [10, 19, 200], [20, 29, 300], [30, 39, 400], [40, 49, 500]]) == 1500\n assert candidate(n = 15,offers = [[0, 4, 12], [1, 5, 15], [2, 6, 18], [3, 7, 20], [4, 8, 25]]) == 25\n assert candidate(n = 15,offers = [[0, 4, 10], [1, 5, 15], [2, 6, 12], [3, 7, 18], [4, 8, 14], [5, 9, 20], [6, 10, 22], [7, 11, 25], [8, 12, 30], [9, 13, 35], [10, 14, 40]]) == 70\n assert candidate(n = 100,offers = [[0, 10, 50], [20, 30, 60], [40, 50, 70], [60, 70, 80], [80, 90, 90]]) == 350\n assert candidate(n = 20,offers = [[0, 4, 50], [5, 9, 70], [10, 14, 90], [15, 19, 110]]) == 320\n assert candidate(n = 100,offers = [[0, 24, 50], [25, 49, 100], [50, 74, 150], [75, 99, 200]]) == 500\n assert candidate(n = 15,offers = [[0, 2, 5], [3, 5, 6], [6, 8, 7], [9, 11, 8], [12, 14, 9]]) == 35\n assert candidate(n = 10,offers = [[0, 2, 5], [1, 4, 10], [3, 5, 8], [4, 6, 7], [6, 8, 9]]) == 22\n assert candidate(n = 15,offers = [[0, 0, 10], [1, 1, 10], [2, 2, 10], [3, 3, 10], [4, 4, 10], [5, 5, 10], [6, 6, 10], [7, 7, 10], [8, 8, 10], [9, 9, 10], [10, 10, 10], [11, 11, 10], [12, 12, 10], [13, 13, 10], [14, 14, 10]]) == 150\n assert candidate(n = 50,offers = [[0, 49, 1000], [0, 24, 500], [25, 49, 500], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 15, 10], [15, 16, 10], [16, 17, 10], [17, 18, 10], [18, 19, 10], [19, 20, 10], [20, 21, 10], [21, 22, 10], [22, 23, 10], [23, 24, 10], [24, 25, 10], [25, 26, 10], [26, 27, 10], [27, 28, 10], [28, 29, 10], [29, 30, 10], [30, 31, 10], [31, 32, 10], [32, 33, 10], [33, 34, 10], [34, 35, 10], [35, 36, 10], [36, 37, 10], [37, 38, 10], [38, 39, 10], [39, 40, 10], [40, 41, 10], [41, 42, 10], [42, 43, 10], [43, 44, 10], [44, 45, 10], [45, 46, 10], [46, 47, 10], [47, 48, 10], [48, 49, 10]]) == 1000\n assert candidate(n = 10,offers = [[0, 4, 10], [3, 5, 15], [5, 7, 20], [6, 9, 25], [8, 9, 5]]) == 40\n assert candidate(n = 100,offers = [[0, 20, 100], [21, 40, 150], [41, 60, 120], [61, 80, 130], [81, 100, 140]]) == 640\n assert candidate(n = 20,offers = [[0, 4, 20], [5, 9, 30], [10, 14, 40], [15, 19, 50], [0, 9, 70], [10, 19, 80], [0, 14, 90], [5, 19, 100], [0, 19, 110]]) == 160\n assert candidate(n = 20,offers = [[0, 5, 100], [2, 7, 150], [5, 10, 200], [8, 13, 250], [12, 17, 300], [16, 20, 350]]) == 750\n assert candidate(n = 20,offers = [[0, 1, 1], [0, 19, 190], [1, 2, 2], [1, 18, 180], [2, 3, 3], [2, 17, 170], [3, 4, 4], [3, 16, 160], [4, 5, 5], [4, 15, 150], [5, 6, 6], [5, 14, 140], [6, 7, 7], [6, 13, 130], [7, 8, 8], [7, 12, 120], [8, 9, 9], [8, 11, 110], [9, 10, 10], [9, 10, 100]]) == 190\n assert candidate(n = 50,offers = [[0, 4, 10], [5, 9, 15], [10, 14, 20], [15, 19, 25], [20, 24, 30], [25, 29, 35], [30, 34, 40], [35, 39, 45], [40, 44, 50], [45, 49, 55]]) == 325\n assert candidate(n = 50,offers = [[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], [0, 10, 350], [10, 20, 400], [20, 30, 450], [30, 40, 500], [40, 50, 550]]) == 1350\n assert candidate(n = 15,offers = [[0, 2, 100], [1, 4, 120], [2, 5, 130], [3, 6, 140], [4, 7, 150], [5, 8, 160], [6, 9, 170], [7, 10, 180], [8, 11, 190], [9, 12, 200], [10, 13, 210], [11, 14, 220], [12, 14, 230]]) == 670\n assert candidate(n = 100,offers = [[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], [29, 30, 30], [30, 31, 31], [31, 32, 32], [32, 33, 33], [33, 34, 34], [34, 35, 35], [35, 36, 36], [36, 37, 37], [37, 38, 38], [38, 39, 39], [39, 40, 40], [40, 41, 41], [41, 42, 42], [42, 43, 43], [43, 44, 44], [44, 45, 45], [45, 46, 46], [46, 47, 47], [47, 48, 48], [48, 49, 49], [49, 50, 50], [50, 51, 51], [51, 52, 52], [52, 53, 53], [53, 54, 54], [54, 55, 55], [55, 56, 56], [56, 57, 57], [57, 58, 58], [58, 59, 59], [59, 60, 60], [60, 61, 61], [61, 62, 62], [62, 63, 63], [63, 64, 64], [64, 65, 65], [65, 66, 66], [66, 67, 67], [67, 68, 68], [68, 69, 69], [69, 70, 70], [70, 71, 71], [71, 72, 72], [72, 73, 73], [73, 74, 74], [74, 75, 75], [75, 76, 76], [76, 77, 77], [77, 78, 78], [78, 79, 79], [79, 80, 80], [80, 81, 81], [81, 82, 82], [82, 83, 83], [83, 84, 84], [84, 85, 85], [85, 86, 86], [86, 87, 87], [87, 88, 88], [88, 89, 89], [89, 90, 90], [90, 91, 91], [91, 92, 92], [92, 93, 93], [93, 94, 94], [94, 95, 95], [95, 96, 96], [96, 97, 97], [97, 98, 98], [98, 99, 99]]) == 2500\n assert candidate(n = 20,offers = [[0, 3, 7], [1, 4, 8], [2, 5, 9], [3, 6, 10], [4, 7, 11], [5, 8, 12], [6, 9, 13], [7, 10, 14]]) == 24\n assert candidate(n = 20,offers = [[0, 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]]) == 210\n assert candidate(n = 8,offers = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [5, 6, 100], [6, 7, 100]]) == 400\n assert candidate(n = 100,offers = [[0, 10, 50], [11, 20, 60], [21, 30, 70], [31, 40, 80], [41, 50, 90], [51, 60, 100], [61, 70, 110], [71, 80, 120], [81, 90, 130], [91, 100, 140]]) == 950\n assert candidate(n = 20,offers = [[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], [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], [19, 20, 5]]) == 50\n assert candidate(n = 10,offers = [[0, 2, 5], [2, 4, 7], [4, 6, 9], [6, 8, 11], [8, 10, 13]]) == 27\n assert candidate(n = 50,offers = [[0, 4, 100], [10, 14, 150], [20, 24, 200], [30, 34, 250], [40, 44, 300], [1, 5, 90], [11, 15, 140], [21, 25, 190], [31, 35, 240], [41, 45, 290]]) == 1000\n assert candidate(n = 50,offers = [[0, 24, 100], [25, 49, 150], [0, 49, 200], [24, 25, 50], [12, 37, 120]]) == 250\n assert candidate(n = 50,offers = [[0, 1, 1], [2, 3, 1], [4, 5, 1], [6, 7, 1], [8, 9, 1], [10, 11, 1], [12, 13, 1], [14, 15, 1], [16, 17, 1], [18, 19, 1], [20, 21, 1], [22, 23, 1], [24, 25, 1], [26, 27, 1], [28, 29, 1], [30, 31, 1], [32, 33, 1], [34, 35, 1], [36, 37, 1], [38, 39, 1], [40, 41, 1], [42, 43, 1], [44, 45, 1], [46, 47, 1], [48, 49, 1]]) == 25\n assert candidate(n = 25,offers = [[0, 3, 30], [4, 7, 40], [8, 11, 50], [12, 15, 60], [16, 19, 70], [20, 23, 80], [24, 24, 10]]) == 340\n assert candidate(n = 100,offers = [[0, 9, 50], [10, 19, 100], [20, 29, 150], [30, 39, 200], [40, 49, 250], [50, 59, 300], [60, 69, 350], [70, 79, 400], [80, 89, 450], [90, 99, 500]]) == 2750\n assert candidate(n = 10,offers = [[0, 0, 1], [0, 9, 10], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]]) == 25\n assert candidate(n = 20,offers = [[0, 4, 10], [5, 9, 15], [10, 14, 20], [15, 19, 25]]) == 70\n assert candidate(n = 20,offers = [[0, 3, 50], [2, 5, 30], [4, 7, 60], [6, 9, 40], [8, 11, 70], [10, 13, 50], [12, 15, 60], [14, 17, 80], [16, 19, 70]]) == 310\n assert candidate(n = 20,offers = [[0, 5, 100], [1, 4, 80], [2, 3, 60], [3, 6, 70], [4, 7, 90], [5, 8, 120], [6, 9, 110], [7, 10, 130], [8, 11, 150], [9, 12, 140], [10, 13, 170], [11, 14, 160], [12, 15, 190], [13, 16, 180], [14, 17, 210], [15, 18, 200], [16, 19, 230], [17, 19, 220]]) == 740\n assert candidate(n = 20,offers = [[0, 1, 10], [2, 3, 20], [1, 2, 30], [0, 3, 40], [4, 5, 50], [6, 7, 60], [8, 9, 70], [10, 11, 80], [12, 13, 90], [14, 15, 100], [16, 17, 110], [18, 19, 120]]) == 720\n assert candidate(n = 20,offers = [[0, 5, 10], [1, 6, 15], [2, 7, 20], [3, 8, 25], [4, 9, 30], [5, 10, 35], [6, 11, 40], [7, 12, 45], [8, 13, 50], [9, 14, 55], [10, 15, 60], [11, 16, 65], [12, 17, 70], [13, 18, 75], [14, 19, 80]]) == 150\n assert candidate(n = 20,offers = [[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]]) == 110\n assert candidate(n = 75,offers = [[0, 4, 50], [4, 8, 60], [8, 12, 70], [12, 16, 80], [16, 20, 90], [20, 24, 100], [24, 28, 110], [28, 32, 120], [32, 36, 130], [36, 40, 140], [40, 44, 150], [44, 48, 160], [48, 52, 170], [52, 56, 180], [56, 60, 190], [60, 64, 200], [64, 68, 210], [68, 72, 220], [72, 76, 230]]) == 1400\n assert candidate(n = 15,offers = [[0, 2, 10], [3, 5, 15], [6, 8, 20], [9, 11, 25], [12, 14, 30]]) == 100\n assert candidate(n = 15,offers = [[0, 0, 100], [1, 1, 100], [2, 2, 100], [3, 3, 100], [4, 4, 100], [5, 5, 100], [6, 6, 100], [7, 7, 100], [8, 8, 100], [9, 9, 100], [10, 10, 100], [11, 11, 100], [12, 12, 100], [13, 13, 100], [14, 14, 100]]) == 1500\n assert candidate(n = 50,offers = [[0, 24, 1000], [25, 49, 1000], [0, 49, 1500], [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, 29], [30, 30, 30], [31, 31, 31], [32, 32, 32], [33, 33, 33], [34, 34, 34], [35, 35, 35], [36, 36, 36], [37, 37, 37], [38, 38, 38], [39, 39, 39], [40, 40, 40], [41, 41, 41], [42, 42, 42], [43, 43, 43], [44, 44, 44], [45, 45, 45], [46, 46, 46], [47, 47, 47], [48, 48, 48], [49, 49, 49]]) == 2000\n assert candidate(n = 50,offers = [[0, 1, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [8, 9, 5], [10, 11, 6], [12, 13, 7], [14, 15, 8], [16, 17, 9], [18, 19, 10], [20, 21, 11], [22, 23, 12], [24, 25, 13], [26, 27, 14], [28, 29, 15], [30, 31, 16], [32, 33, 17], [34, 35, 18], [36, 37, 19], [38, 39, 20], [40, 41, 21], [42, 43, 22], [44, 45, 23], [46, 47, 24], [48, 49, 25]]) == 325\n assert candidate(n = 75,offers = [[0, 24, 300], [25, 49, 400], [50, 74, 500], [0, 49, 700], [25, 74, 600], [0, 74, 800], [0, 24, 200], [25, 49, 300], [50, 74, 400]]) == 1200\n assert candidate(n = 30,offers = [[0, 5, 10], [5, 10, 20], [10, 15, 30], [15, 20, 40], [20, 25, 50], [25, 30, 60]]) == 120\n assert candidate(n = 100,offers = [[0, 10, 100], [10, 20, 200], [20, 30, 150], [30, 40, 175], [40, 50, 250], [50, 60, 225], [60, 70, 300], [70, 80, 275], [80, 90, 350], [90, 100, 325]]) == 1200\n assert candidate(n = 75,offers = [[0, 10, 50], [11, 20, 55], [21, 30, 60], [31, 40, 65], [41, 50, 70], [51, 60, 75], [61, 70, 80], [71, 74, 85], [0, 74, 200], [1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 11], [11, 12, 12], [13, 14, 13], [15, 16, 14], [17, 18, 15], [19, 20, 16], [21, 22, 17], [23, 24, 18], [25, 26, 19], [27, 28, 20], [29, 30, 21], [31, 32, 22], [33, 34, 23], [35, 36, 24], [37, 38, 25], [39, 40, 26], [41, 42, 27], [43, 44, 28], [45, 46, 29], [47, 48, 30], [49, 50, 31], [51, 52, 32], [53, 54, 33], [55, 56, 34], [57, 58, 35], [59, 60, 36], [61, 62, 37], [63, 64, 38], [65, 66, 39], [67, 68, 40], [69, 70, 41], [71, 72, 42], [73, 74, 43]]) == 930\n assert candidate(n = 15,offers = [[0, 2, 10], [2, 4, 15], [3, 5, 10], [5, 7, 20], [7, 9, 10], [8, 10, 15], [10, 12, 20], [12, 14, 10]]) == 60\n assert candidate(n = 50,offers = [[0, 10, 500], [1, 9, 450], [2, 8, 400], [3, 7, 350], [4, 6, 300], [5, 5, 250], [6, 15, 550], [7, 14, 500], [8, 13, 450], [9, 12, 400], [10, 11, 350], [11, 20, 600], [12, 19, 550], [13, 18, 500], [14, 17, 450], [15, 16, 400], [16, 25, 650], [17, 24, 600], [18, 23, 550], [19, 22, 500], [20, 21, 450], [21, 30, 700], [22, 29, 650], [23, 28, 600], [24, 27, 550], [25, 26, 500], [26, 35, 750], [27, 34, 700], [28, 33, 650], [29, 32, 600], [30, 31, 550], [31, 40, 800], [32, 39, 750], [33, 38, 700], [34, 37, 650], [35, 36, 600]]) == 3750\n assert candidate(n = 25,offers = [[0, 1, 10], [0, 2, 15], [1, 3, 20], [1, 4, 25], [2, 5, 30], [2, 6, 35], [3, 7, 40], [3, 8, 45], [4, 9, 50], [4, 10, 55], [5, 11, 60], [5, 12, 65], [6, 13, 70], [6, 14, 75], [7, 15, 80], [7, 16, 85], [8, 17, 90], [8, 18, 95], [9, 19, 100], [9, 20, 105], [10, 21, 110], [10, 22, 115], [11, 23, 120], [11, 24, 125], [12, 24, 130]]) == 215\n assert candidate(n = 80,offers = [[0, 19, 200], [20, 39, 300], [40, 59, 400], [60, 79, 500]]) == 1400\n assert candidate(n = 15,offers = [[0, 4, 20], [1, 3, 15], [2, 6, 30], [3, 5, 25], [4, 8, 40], [5, 9, 35], [6, 10, 50], [7, 11, 45], [8, 12, 60], [9, 13, 55], [10, 14, 70], [11, 14, 65]]) == 140\n assert candidate(n = 120,offers = [[0, 29, 300], [30, 59, 400], [60, 89, 500], [90, 119, 600]]) == 1800\n assert candidate(n = 100,offers = [[0, 9, 100], [10, 19, 200], [20, 29, 300], [30, 39, 400], [40, 49, 500]]) == 1500\n assert candidate(n = 50,offers = [[0, 10, 100], [10, 20, 150], [20, 30, 200], [30, 40, 250], [40, 50, 300]]) == 600\n assert candidate(n = 100,offers = [[0, 24, 50], [25, 49, 60], [50, 74, 70], [75, 99, 80], [0, 49, 150], [25, 74, 160], [50, 99, 170], [0, 74, 250], [25, 99, 260], [0, 99, 350]]) == 350\n assert candidate(n = 15,offers = [[0, 2, 5], [1, 4, 7], [2, 6, 8], [3, 7, 9], [4, 8, 10], [5, 9, 11], [6, 10, 12], [7, 11, 13], [8, 12, 14], [9, 13, 15]]) == 30\n assert candidate(n = 10,offers = [[0, 2, 3], [0, 5, 10], [0, 8, 12], [0, 9, 15], [1, 3, 4], [1, 4, 8], [1, 5, 10], [1, 6, 12], [1, 7, 14], [1, 8, 16], [1, 9, 18], [2, 4, 6], [2, 5, 9], [2, 6, 12], [2, 7, 15], [2, 8, 18], [2, 9, 21], [3, 5, 8], [3, 6, 11], [3, 7, 14], [3, 8, 17], [3, 9, 20], [4, 6, 10], [4, 7, 13], [4, 8, 16], [4, 9, 19], [5, 7, 12], [5, 8, 15], [5, 9, 18], [6, 8, 14], [6, 9, 17], [7, 9, 16]]) == 30\n assert candidate(n = 10,offers = [[0, 4, 15], [1, 3, 10], [2, 5, 8], [3, 6, 12], [5, 9, 20]]) == 35\n assert candidate(n = 80,offers = [[0, 9, 100], [10, 19, 120], [20, 29, 110], [30, 39, 130], [40, 49, 140], [50, 59, 150], [60, 69, 160], [70, 79, 170]]) == 1080\n assert candidate(n = 7,offers = [[0, 0, 5], [0, 6, 10], [1, 1, 6], [2, 2, 7], [3, 3, 8], [4, 4, 9], [5, 5, 10], [6, 6, 11]]) == 56\n assert candidate(n = 100,offers = [[0, 49, 500], [50, 99, 1000]]) == 1500\n assert candidate(n = 50,offers = [[0, 4, 50], [5, 9, 60], [10, 14, 40], [15, 19, 70], [20, 24, 65], [25, 29, 55], [30, 34, 80], [35, 39, 75], [40, 44, 90], [45, 49, 85]]) == 670\n assert candidate(n = 100,offers = [[0, 50, 1000], [51, 99, 1500], [0, 99, 500], [1, 98, 600], [2, 97, 700], [3, 96, 800], [4, 95, 900], [5, 94, 1000], [6, 93, 1100], [7, 92, 1200], [8, 91, 1300], [9, 90, 1400]]) == 2500\n assert candidate(n = 50,offers = [[0, 9, 100], [10, 19, 150], [20, 29, 200], [30, 39, 250], [40, 49, 300]]) == 1000\n assert candidate(n = 75,offers = [[0, 24, 300], [25, 49, 400], [50, 74, 500]]) == 1200\n assert candidate(n = 50,offers = [[0, 24, 1000], [10, 34, 2000], [20, 44, 3000], [30, 49, 4000], [0, 49, 100], [1, 48, 150], [2, 47, 200], [3, 46, 250], [4, 45, 300], [5, 44, 350], [6, 43, 400], [7, 42, 450], [8, 41, 500], [9, 40, 550], [10, 39, 600]]) == 5000\n assert candidate(n = 12,offers = [[0, 11, 50], [1, 10, 45], [2, 9, 40], [3, 8, 35], [4, 7, 30], [5, 6, 25]]) == 50\n assert candidate(n = 100000,offers = [[0, 10000, 5000], [10001, 20000, 5500], [20001, 30000, 6000], [30001, 40000, 6500], [40001, 50000, 7000]]) == 30000\n assert candidate(n = 15,offers = [[0, 4, 20], [3, 7, 30], [6, 9, 40], [8, 12, 50], [11, 14, 60]]) == 120\n assert candidate(n = 25,offers = [[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], [11, 12, 120], [12, 13, 130], [13, 14, 140], [14, 15, 150], [15, 16, 160], [16, 17, 170], [17, 18, 180], [18, 19, 190], [19, 20, 200], [20, 21, 210], [21, 22, 220], [22, 23, 230], [23, 24, 240], [24, 24, 250]]) == 1690\n assert candidate(n = 100,offers = [[0, 20, 100], [25, 45, 150], [50, 70, 200], [75, 99, 250]]) == 700\n"}, "metadata": {"canonical_parameter_names": ["n", "offers"], "leetcode_dataset_entry_point": "Solution().maximizeTheProfit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximizeTheProfit(int n, List> offers) {", "container": "Solution", "callable": "maximizeTheProfit", "parameters": [{"name": "n", "type": "int"}, {"name": "offers", "type": "List>"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2831, "task_id": "find-the-longest-equal-subarray", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and an integer k.\nA subarray is called equal if all of its elements are equal. Note that the empty subarray is an equal subarray.\nReturn the length of the longest possible equal subarray after deleting at most k elements from nums.\nA subarray is a contiguous, possibly empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,3,2,3,1,3], k = 3\nOutput: 3\nExplanation: It's optimal to delete the elements at index 2 and index 4.\nAfter deleting them, nums becomes equal to [1, 3, 3, 3].\nThe longest equal subarray starts at i = 1 and ends at j = 3 with length equal to 3.\nIt can be proven that no longer equal subarrays can be created.\n\nExample 2:\n\nInput: nums = [1,1,2,2,1,1], k = 2\nOutput: 4\nExplanation: It's optimal to delete the elements at index 2 and index 3.\nAfter deleting them, nums becomes equal to [1, 1, 1, 1].\nThe array itself is an equal subarray, so the answer is 4.\nIt can be proven that no longer equal subarrays can be created.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= nums.length\n0 <= k <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 1, 10, 10],k = 1) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3],k = 3) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],k = 4) == 3\n assert candidate(nums = [1, 2, 2, 1, 2, 2],k = 2) == 4\n assert candidate(nums = [10, 1, 2, 2, 1, 3, 3, 3, 3, 4],k = 4) == 4\n assert candidate(nums = [1, 2, 2, 1, 2, 1, 1, 1],k = 2) == 4\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 2) == 4\n assert candidate(nums = [5, 5, 5, 1, 5, 5],k = 1) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],k = 4) == 1\n assert candidate(nums = [1, 2],k = 1) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == 1\n assert candidate(nums = [4, 4, 4, 1, 1],k = 2) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [1, 2, 2, 1, 2, 1, 1, 1, 1, 2, 2],k = 3) == 6\n assert candidate(nums = [1],k = 0) == 1\n assert candidate(nums = [10, 10, 1, 10, 10, 1, 10],k = 3) == 5\n assert candidate(nums = [1, 3, 2, 3, 1, 3],k = 3) == 3\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],k = 2) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],k = 2) == 5\n assert candidate(nums = [1, 2, 2, 1, 2, 1, 2],k = 2) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1],k = 3) == 5\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == 10\n assert candidate(nums = [1, 1, 2, 2, 1, 1],k = 2) == 4\n assert candidate(nums = [10, 10, 10, 1, 10, 10, 10],k = 3) == 6\n assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 5\n assert candidate(nums = [7, 7, 7, 1, 7, 7, 7, 7],k = 4) == 7\n assert candidate(nums = [1, 1, 1, 1, 1],k = 0) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],k = 0) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],k = 3) == 3\n assert candidate(nums = [10, 10, 1, 10, 10, 1, 1, 1],k = 3) == 4\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 2, 2, 1, 1, 1, 1],k = 4) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 15) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6],k = 5) == 6\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],k = 20) == 7\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 7) == 5\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 8) == 4\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1],k = 8) == 5\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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 25) == 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, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 5) == 29\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 11\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],k = 10) == 30\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, 6, 6, 6],k = 15) == 10\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 30, 30, 10, 10, 10, 10],k = 6) == 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, 8, 8, 8, 9, 9, 9],k = 15) == 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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 30) == 4\n assert candidate(nums = [1, 2, 3, 3, 3, 4, 5, 5, 5, 5],k = 2) == 4\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9],k = 6) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1],k = 10) == 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, 5, 5],k = 10) == 45\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],k = 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, 1, 1, 1, 1, 1, 1],k = 15) == 6\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) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 4) == 5\n assert candidate(nums = [5, 5, 4, 4, 5, 5, 5, 3, 5, 5, 5, 2, 5, 5, 5, 5, 5, 5],k = 7) == 14\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],k = 10) == 7\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 7, 7, 7, 7, 8, 8, 8, 8, 7, 7, 7, 7],k = 8) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 9) == 11\n assert candidate(nums = [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(nums = [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],k = 20) == 3\n assert candidate(nums = [10, 20, 20, 10, 10, 20, 30, 30, 30, 20, 20, 10, 10, 10, 10, 20, 20, 20, 30, 30, 30, 30, 30, 10, 10, 10, 10, 10],k = 10) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 15) == 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 = 15) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1],k = 5) == 6\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],k = 20) == 4\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2],k = 7) == 4\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2],k = 6) == 6\n assert candidate(nums = [1, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1],k = 12) == 15\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 20) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1],k = 12) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 44\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 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, 5],k = 15) == 10\n assert candidate(nums = [10, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 10) == 10\n assert candidate(nums = [5, 5, 5, 5, 1, 1, 5, 5, 5, 5, 1, 1, 5, 5, 5, 5],k = 6) == 12\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 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],k = 0) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 8) == 2\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3],k = 8) == 8\n assert candidate(nums = [1, 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],k = 10) == 4\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) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 13\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, 1, 1, 2, 2, 3, 3],k = 20) == 4\n assert candidate(nums = [10, 20, 20, 10, 10, 20, 10, 10, 10, 10],k = 3) == 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],k = 8) == 9\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) == 2\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],k = 10) == 6\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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 15) == 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, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 18) == 3\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, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 15) == 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 = 5) == 2\n assert candidate(nums = [1, 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],k = 25) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 15) == 4\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10],k = 10) == 6\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, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 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, 10, 10, 10],k = 15) == 3\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 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, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 15) == 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],k = 6) == 8\n assert candidate(nums = [5, 5, 4, 4, 4, 5, 5, 5, 5, 5],k = 4) == 7\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 7) == 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],k = 10) == 1\n assert candidate(nums = [1, 1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 1, 1],k = 4) == 5\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],k = 15) == 16\n assert candidate(nums = [1, 1, 1, 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 = 10) == 3\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 3) == 4\n assert candidate(nums = [1, 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2],k = 5) == 11\n assert candidate(nums = [5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5],k = 5) == 10\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 5) == 3\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 = 5) == 6\n assert candidate(nums = [1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4],k = 5) == 5\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],k = 5) == 5\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 = 20) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 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],k = 12) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4],k = 8) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().longestEqualSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int longestEqualSubarray(List nums, int k) {", "container": "Solution", "callable": "longestEqualSubarray", "parameters": [{"name": "nums", "type": "List"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2833, "task_id": "furthest-point-from-origin", "difficulty": "Easy", "problem_description": "You are given a string moves of length n consisting only of characters 'L', 'R', and '_'. The string represents your movement on a number line starting from the origin 0.\nIn the ith move, you can choose one of the following directions:\n\nmove to the left if moves[i] = 'L' or moves[i] = '_'\nmove to the right if moves[i] = 'R' or moves[i] = '_'\n\nReturn the distance from the origin of the furthest point you can get to after n moves.\n \nExample 1:\n\nInput: moves = \"L_RL__R\"\nOutput: 3\nExplanation: The furthest point we can reach from the origin 0 is point -3 through the following sequence of moves \"LLRLLLR\".\n\nExample 2:\n\nInput: moves = \"_R__LL_\"\nOutput: 5\nExplanation: The furthest point we can reach from the origin 0 is point -5 through the following sequence of moves \"LRLLLLL\".\n\nExample 3:\n\nInput: moves = \"_______\"\nOutput: 7\nExplanation: The furthest point we can reach from the origin 0 is point 7 through the following sequence of moves \"RRRRRRR\".\n\n \nConstraints:\n\n1 <= moves.length == n <= 50\nmoves consists only of characters 'L', 'R' and '_'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(moves = \"________R\") == 9\n assert candidate(moves = \"L_RL__R\") == 3\n assert candidate(moves = \"L_____R\") == 5\n assert candidate(moves = \"R_L_R_L\") == 3\n assert candidate(moves = \"L________\") == 9\n assert candidate(moves = \"R________\") == 9\n assert candidate(moves = \"LLRRLLR\") == 1\n assert candidate(moves = \"LLRRRRR\") == 3\n assert candidate(moves = \"LRLRLRL\") == 1\n assert candidate(moves = \"_L_R_L_\") == 5\n assert candidate(moves = \"LLLLLLL\") == 7\n assert candidate(moves = \"________L\") == 9\n assert candidate(moves = \"__R____\") == 7\n assert candidate(moves = \"R_R_R_R\") == 7\n assert candidate(moves = \"____L__\") == 7\n assert candidate(moves = \"R_____L\") == 5\n assert candidate(moves = \"RLRLRLR\") == 1\n assert candidate(moves = \"_R__LL_\") == 5\n assert candidate(moves = \"_______\") == 7\n assert candidate(moves = \"RRRRRRR\") == 7\n assert candidate(moves = \"_________\") == 9\n assert candidate(moves = \"RRLLLLL\") == 3\n assert candidate(moves = \"R_______L_______R_______L_______R_______L_______R_______L_______R_______L_______R_______L_______R_______L_______R_______\") == 106\n assert candidate(moves = \"_________________R_________________\") == 35\n assert candidate(moves = \"R__R__R__R__R__R__R__R__R\") == 25\n assert candidate(moves = \"LLLLLLLLLLL\") == 11\n assert candidate(moves = \"RR____LLRRRR\") == 8\n assert candidate(moves = \"RL_RLR_R_\") == 5\n assert candidate(moves = \"RLRLRLRLR\") == 1\n assert candidate(moves = \"LLLLLLLLLLLLLLLLLLLLLLLL\") == 24\n assert candidate(moves = \"R_L_R_L_R_L_R_L_R_L_R_L\") == 11\n assert candidate(moves = \"LR_LRLRL_\") == 3\n assert candidate(moves = \"________L________R________\") == 24\n assert candidate(moves = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 40\n assert candidate(moves = \"RRRR_LLLL_\") == 2\n assert candidate(moves = \"LLLLLLLLLLLLLLRRRRRRRRRRRRRRRRRRRR\") == 6\n assert candidate(moves = \"R________R\") == 10\n assert candidate(moves = \"_LRLRLRLRLRLRLRLRLR_\") == 2\n assert candidate(moves = \"RRRRRRRRRRRRRRLLLLLLLLLLLLLLLLLLLL\") == 6\n assert candidate(moves = \"L_L_L_L_L\") == 9\n assert candidate(moves = \"___________\") == 11\n assert candidate(moves = \"L_____L_____L_____L_____L_\") == 26\n assert candidate(moves = \"RRRRLLLLLLLLLLLLLLLL\") == 12\n assert candidate(moves = \"_LRR_LRR_LRR_LRR_LRR_LRR_\") == 13\n assert candidate(moves = \"RRRR_LLLLL\") == 2\n assert candidate(moves = \"R__L__R__L__R__L__R__L__R__L__R__L__\") == 24\n assert candidate(moves = \"_LLRRLLRR__L\") == 4\n assert candidate(moves = \"_L__R_L__R_L\") == 8\n assert candidate(moves = \"________________R__________L______________\") == 40\n assert candidate(moves = \"LLLLRRRRR\") == 1\n assert candidate(moves = \"L_R__R_L__R\") == 7\n assert candidate(moves = \"R_RR_R_RRRR\") == 11\n assert candidate(moves = \"_L_L_L_L_L_\") == 11\n assert candidate(moves = \"LR_LR_LR_LR_LR_LR_LR_LR_\") == 8\n assert candidate(moves = \"_____________\") == 13\n assert candidate(moves = \"LR_RLR_RLR_RLR_RLR_RLR_RLR\") == 12\n assert candidate(moves = \"LR_LRLRLRLRLRLRLRLRLRLRLRL\") == 2\n assert candidate(moves = \"RL_RL_RL_RL_RL_RL_RL_RL_RL_RL\") == 9\n assert candidate(moves = \"_________________L_________________\") == 35\n assert candidate(moves = \"LRRLRRLLRRLLRR\") == 2\n assert candidate(moves = \"________________________\") == 24\n assert candidate(moves = \"____R____L____\") == 12\n assert candidate(moves = \"R____R____R____R____R_____\") == 26\n assert candidate(moves = \"LRLRLRLRLR\") == 0\n assert candidate(moves = \"L__R__L__R__L__R__L__R__\") == 16\n assert candidate(moves = \"____L___R____\") == 11\n assert candidate(moves = \"_L__R__L__R_\") == 8\n assert candidate(moves = \"LLRR__LLRR__LLRR\") == 4\n assert candidate(moves = \"_L_R_L_R_L_R\") == 6\n assert candidate(moves = \"LR_LR_LR_LR_LR_LR_LR\") == 6\n assert candidate(moves = \"________R_________\") == 18\n assert candidate(moves = \"R______L_\") == 7\n assert candidate(moves = \"_________L_________\") == 19\n assert candidate(moves = \"L_____R_____L_____R\") == 15\n assert candidate(moves = \"_L_L_L_L_L_L_L_L_L_L_L_L_\") == 25\n assert candidate(moves = \"RRRRRRRRRRRRRRRRRRRRRRRR\") == 24\n assert candidate(moves = \"L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R\") == 17\n assert candidate(moves = \"RL_RLR_RLR_RLR_RLR_RLR_R\") == 12\n assert candidate(moves = \"____L_____\") == 10\n assert candidate(moves = \"LLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLL\") == 4\n assert candidate(moves = \"LLLLLLRRRRRR\") == 0\n assert candidate(moves = \"_L______R\") == 7\n assert candidate(moves = \"LLLL____R\") == 7\n assert candidate(moves = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 40\n assert candidate(moves = \"LL_R__R_L__L___\") == 11\n assert candidate(moves = \"L_____L_____L_____\") == 18\n assert candidate(moves = \"LLLLLLLLRRRRRRRRRRLLLLRRRRRRRR\") == 6\n assert candidate(moves = \"_________________________\") == 25\n assert candidate(moves = \"R_R_R_R_R_R_R\") == 13\n assert candidate(moves = \"RL_RL_RL_RL\") == 3\n assert candidate(moves = \"_R_L_R_L_R_\") == 7\n assert candidate(moves = \"_L__R__L__R__L__R__L__R__L__R_\") == 20\n assert candidate(moves = \"___________________________\") == 27\n assert candidate(moves = \"R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R\") == 23\n assert candidate(moves = \"__L__R__L__\") == 9\n assert candidate(moves = \"LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL\") == 1\n assert candidate(moves = \"R______L_____\") == 11\n assert candidate(moves = \"L_R__R_L__R_L_R_L__R_L_R_\") == 15\n assert candidate(moves = \"_LL_R_L_R_L_\") == 8\n assert candidate(moves = \"RRRRRRRRRRR\") == 11\n assert candidate(moves = \"RLLLLRRRRRRR\") == 4\n assert candidate(moves = \"L___R___L___R___L___R___\") == 18\n assert candidate(moves = \"____LR____LR____LR____LR__\") == 18\n assert candidate(moves = \"____R____R____L\") == 13\n assert candidate(moves = \"_____________L____________R_____________\") == 38\n assert candidate(moves = \"LRRLRLRLRLRLRLRLRLRL\") == 0\n assert candidate(moves = \"L_R_L_R_L_R\") == 5\n assert candidate(moves = \"L___R___L___R___L___R___L\") == 19\n assert candidate(moves = \"________________L________________________R____________\") == 52\n assert candidate(moves = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 42\n assert candidate(moves = \"________________\") == 16\n assert candidate(moves = \"L_L_L_L_L_L_L_L_L_L_L_L\") == 23\n assert candidate(moves = \"LRRLRRLLRRRL\") == 2\n assert candidate(moves = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 44\n assert candidate(moves = \"RR___L__L___R_R\") == 11\n assert candidate(moves = \"RRRRRRRR____\") == 12\n assert candidate(moves = \"R_______L\") == 7\n assert candidate(moves = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 44\n assert candidate(moves = \"LR_RLR_LRLRLRLRLRL\") == 2\n assert candidate(moves = \"____R_______\") == 12\n assert candidate(moves = \"R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L\") == 17\n assert candidate(moves = \"__LLRR__L__\") == 7\n assert candidate(moves = \"L__L__L__L__L__L__L__L__L\") == 25\n assert candidate(moves = \"L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R_L_R\") == 23\n assert candidate(moves = \"L_____R_____L\") == 11\n assert candidate(moves = \"RR_RRRRRLLLL_LLLLLLLLL\") == 8\n assert candidate(moves = \"_L_L_L_L_L_L_L\") == 14\n assert candidate(moves = \"LRLRLRLRLRLR\") == 0\n assert candidate(moves = \"_LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL_\") == 3\n assert candidate(moves = \"R___L___R___L___R___L___R\") == 19\n assert candidate(moves = \"LLLLLLLLLLLLLLLLRRRRRRRRRR\") == 6\n assert candidate(moves = \"RRRRLLLLLLLLRRRRLLLLLLLLRRRRLLLLLLLL\") == 12\n assert candidate(moves = \"L_______R\") == 7\n assert candidate(moves = \"LLLLLLLL____\") == 12\n assert candidate(moves = \"R_______________________L\") == 23\n assert candidate(moves = \"LRRLRRLRL\") == 1\n assert candidate(moves = \"L_R_L_R_L_R_L_R_\") == 8\n assert candidate(moves = \"R_R_R_R_R\") == 9\n assert candidate(moves = \"_R_L__R_L__R\") == 8\n assert candidate(moves = \"RRRRRLLLLLL\") == 1\n assert candidate(moves = \"R__L__R__L__R__L__R__L__\") == 16\n assert candidate(moves = \"RRRRRRLLLLLLRRRRRRLLLLLL___\") == 3\n assert candidate(moves = \"L_L_L_L_L_L_L_L_L\") == 17\n assert candidate(moves = \"_L__R__L__R__L\") == 10\n assert candidate(moves = \"RRRR____L\") == 7\n assert candidate(moves = \"____L_R____R\") == 10\n assert candidate(moves = \"_LRRRR______L___\") == 12\n assert candidate(moves = \"_L___R__L_\") == 8\n assert candidate(moves = \"R_L_R_L_R_L\") == 5\n assert candidate(moves = \"LRRLRLRLRL\") == 0\n assert candidate(moves = \"LLLLLLLRRRR\") == 3\n"}, "metadata": {"canonical_parameter_names": ["moves"], "leetcode_dataset_entry_point": "Solution().furthestDistanceFromOrigin", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int furthestDistanceFromOrigin(String moves) {", "container": "Solution", "callable": "furthestDistanceFromOrigin", "parameters": [{"name": "moves", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2834, "task_id": "find-the-minimum-possible-sum-of-a-beautiful-array", "difficulty": "Medium", "problem_description": "You are given positive integers n and target.\nAn array nums is beautiful if it meets the following conditions:\n\nnums.length == n.\nnums consists of pairwise distinct positive integers.\nThere doesn't exist two distinct indices, i and j, in the range [0, n - 1], such that nums[i] + nums[j] == target.\n\nReturn the minimum possible sum that a beautiful array could have modulo 109 + 7.\n \nExample 1:\n\nInput: n = 2, target = 3\nOutput: 4\nExplanation: We can see that nums = [1,3] is beautiful.\n- The array nums has length n = 2.\n- The array nums consists of pairwise distinct positive integers.\n- There doesn't exist two distinct indices, i and j, with nums[i] + nums[j] == 3.\nIt can be proven that 4 is the minimum possible sum that a beautiful array could have.\n\nExample 2:\n\nInput: n = 3, target = 3\nOutput: 8\nExplanation: We can see that nums = [1,3,4] is beautiful.\n- The array nums has length n = 3.\n- The array nums consists of pairwise distinct positive integers.\n- There doesn't exist two distinct indices, i and j, with nums[i] + nums[j] == 3.\nIt can be proven that 8 is the minimum possible sum that a beautiful array could have.\n\nExample 3:\n\nInput: n = 1, target = 1\nOutput: 1\nExplanation: We can see, that nums = [1] is beautiful.\n\n \nConstraints:\n\n1 <= n <= 109\n1 <= target <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,target = 3) == 4\n assert candidate(n = 100,target = 100) == 7500\n assert candidate(n = 5,target = 8) == 18\n assert candidate(n = 1,target = 1) == 1\n assert candidate(n = 1000000000,target = 1000000000) == 750000042\n assert candidate(n = 3,target = 3) == 8\n assert candidate(n = 10,target = 15) == 76\n assert candidate(n = 10,target = 5) == 71\n assert candidate(n = 5,target = 10) == 15\n assert candidate(n = 100,target = 10) == 5430\n assert candidate(n = 50,target = 100) == 1275\n assert candidate(n = 100,target = 1) == 5050\n assert candidate(n = 10000,target = 10001) == 75005000\n assert candidate(n = 10000,target = 20000) == 50005000\n assert candidate(n = 5,target = 2) == 15\n assert candidate(n = 200,target = 250) == 29400\n assert candidate(n = 500,target = 250) == 171750\n assert candidate(n = 500,target = 10) == 127230\n assert candidate(n = 100000000,target = 10000000) == 916675007\n assert candidate(n = 10000000,target = 5000000) == 997018757\n assert candidate(n = 200000000,target = 150000000) == 769375007\n assert candidate(n = 80,target = 40) == 4380\n assert candidate(n = 1000000000,target = 1) == 21\n assert candidate(n = 1000,target = 500) == 687250\n assert candidate(n = 3000,target = 1500) == 6186750\n assert candidate(n = 3,target = 7) == 6\n assert candidate(n = 10000,target = 5000) == 68747500\n assert candidate(n = 1000,target = 1001) == 750500\n assert candidate(n = 100,target = 50) == 6850\n assert candidate(n = 500000000,target = 750000000) == 921875014\n assert candidate(n = 10000,target = 7500) == 73436250\n assert candidate(n = 100,target = 101) == 7550\n assert candidate(n = 75,target = 50) == 4050\n assert candidate(n = 1000,target = 1000) == 750000\n assert candidate(n = 20,target = 15) == 301\n assert candidate(n = 999999999,target = 1000000000) == 250000050\n assert candidate(n = 100000000,target = 100000000) == 947500007\n assert candidate(n = 500000000,target = 500000000) == 687500014\n assert candidate(n = 300,target = 301) == 67650\n assert candidate(n = 500000,target = 100000) == 499798971\n assert candidate(n = 30,target = 25) == 681\n assert candidate(n = 1000,target = 2000) == 500500\n assert candidate(n = 75,target = 100) == 4075\n assert candidate(n = 999999999,target = 999999999) == 750000049\n assert candidate(n = 1000000,target = 500000) == 499745191\n assert candidate(n = 200,target = 300) == 27550\n assert candidate(n = 5000000,target = 1000000) == 997896757\n assert candidate(n = 2,target = 5) == 3\n assert candidate(n = 300,target = 150) == 61800\n assert candidate(n = 50,target = 10) == 1455\n assert candidate(n = 25000000,target = 75000000) == 10312500\n assert candidate(n = 100000,target = 50000) == 874974958\n assert candidate(n = 999999999,target = 2) == 28\n assert candidate(n = 75,target = 150) == 2850\n assert candidate(n = 200,target = 150) == 29350\n assert candidate(n = 200000000,target = 800000000) == 960000007\n assert candidate(n = 500,target = 500) == 187500\n assert candidate(n = 50000,target = 25000) == 718737493\n assert candidate(n = 50,target = 20) == 1635\n assert candidate(n = 1000,target = 100) == 547050\n assert candidate(n = 750,target = 150) == 331575\n assert candidate(n = 25000000,target = 50000000) == 10312500\n assert candidate(n = 50,target = 25) == 1731\n assert candidate(n = 75000000,target = 25000000) == 949843757\n assert candidate(n = 150,target = 300) == 11325\n assert candidate(n = 500,target = 100) == 147300\n assert candidate(n = 250000000,target = 500000000) == 906250007\n assert candidate(n = 1000,target = 505) == 688996\n assert candidate(n = 1000000,target = 1000000) == 999994757\n assert candidate(n = 75,target = 75) == 4256\n assert candidate(n = 5000,target = 2000) == 16498500\n assert candidate(n = 100000000,target = 150000000) == 976875007\n assert candidate(n = 99999999,target = 100000000) == 797500008\n assert candidate(n = 5000,target = 5001) == 18752500\n assert candidate(n = 999999999,target = 500000000) == 687500050\n assert candidate(n = 90,target = 90) == 6075\n assert candidate(n = 100000,target = 100001) == 500049951\n assert candidate(n = 1,target = 1000000000) == 1\n assert candidate(n = 10,target = 11) == 80\n assert candidate(n = 50000000,target = 25000000) == 975468757\n assert candidate(n = 25,target = 15) == 451\n assert candidate(n = 150,target = 75) == 15506\n assert candidate(n = 10000,target = 10000) == 75000000\n assert candidate(n = 100000000,target = 1) == 15000000\n assert candidate(n = 500000000,target = 1000000000) == 375000007\n assert candidate(n = 500,target = 300) == 177400\n assert candidate(n = 150,target = 200) == 16275\n assert candidate(n = 1,target = 2) == 1\n assert candidate(n = 200,target = 200) == 30000\n assert candidate(n = 50,target = 30) == 1765\n assert candidate(n = 50000,target = 10000) == 474979993\n"}, "metadata": {"canonical_parameter_names": ["n", "target"], "leetcode_dataset_entry_point": "Solution().minimumPossibleSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumPossibleSum(int n, int target) {", "container": "Solution", "callable": "minimumPossibleSum", "parameters": [{"name": "n", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2835, "task_id": "minimum-operations-to-form-subsequence-with-target-sum", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array nums consisting of non-negative powers of 2, and an integer target.\nIn one operation, you must apply the following changes to the array:\n\nChoose any element of the array nums[i] such that nums[i] > 1.\nRemove nums[i] from the array.\nAdd two occurrences of nums[i] / 2 to the end of nums.\n\nReturn the minimum number of operations you need to perform so that nums contains a subsequence whose elements sum to target. If it is impossible to obtain such a subsequence, return -1.\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,8], target = 7\nOutput: 1\nExplanation: In the first operation, we choose element nums[2]. The array becomes equal to nums = [1,2,4,4].\nAt this stage, nums contains the subsequence [1,2,4] which sums up to 7.\nIt can be shown that there is no shorter sequence of operations that results in a subsequnce that sums up to 7.\n\nExample 2:\n\nInput: nums = [1,32,1,2], target = 12\nOutput: 2\nExplanation: In the first operation, we choose element nums[1]. The array becomes equal to nums = [1,1,2,16,16].\nIn the second operation, we choose element nums[3]. The array becomes equal to nums = [1,1,2,16,8,8]\nAt this stage, nums contains the subsequence [1,1,2,8] which sums up to 12.\nIt can be shown that there is no shorter sequence of operations that results in a subsequence that sums up to 12.\nExample 3:\n\nInput: nums = [1,32,1], target = 35\nOutput: -1\nExplanation: It can be shown that no sequence of operations results in a subsequence that sums up to 35.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 230\nnums consists only of non-negative powers of two.\n1 <= target < 231\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 4, 8, 16],target = 31) == -1\n assert candidate(nums = [32, 16, 8, 4, 2, 1],target = 63) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],target = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 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],target = 15) == 0\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1],target = 255) == 0\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],target = 2147483647) == 0\n assert candidate(nums = [1, 32, 1, 2],target = 12) == 2\n assert candidate(nums = [64],target = 32) == 1\n assert candidate(nums = [1024],target = 512) == 1\n assert candidate(nums = [1, 2, 8],target = 7) == 1\n assert candidate(nums = [1],target = 1) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],target = 1048575) == 0\n assert candidate(nums = [2, 4, 8, 16],target = 30) == 0\n assert candidate(nums = [1, 32, 1],target = 35) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64],target = 63) == 6\n assert candidate(nums = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1023) == 0\n assert candidate(nums = [1024],target = 1) == 10\n assert candidate(nums = [1073741824],target = 1073741824) == 0\n assert candidate(nums = [2, 2, 2, 2],target = 8) == 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],target = 16) == 0\n assert candidate(nums = [16, 8, 4, 2, 1],target = 31) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 2047) == 0\n assert candidate(nums = [1, 1, 1, 1],target = 1) == 0\n assert candidate(nums = [1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144],target = 524287) == -1\n assert candidate(nums = [512, 512, 256, 256, 128, 128, 64, 64, 32, 32, 16, 16, 8, 8, 4, 4, 2, 2, 1, 1],target = 1023) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1535) == 0\n assert candidate(nums = [2, 16, 32, 64, 128, 256, 512],target = 1015) == -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],target = 20) == 0\n assert candidate(nums = [1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],target = 65535) == 0\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],target = 100) == 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],target = 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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) == -1\n assert candidate(nums = [1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024],target = 4095) == 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, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824],target = 2147483647) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],target = 65535) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 1025) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 511) == 0\n assert candidate(nums = [256, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 512) == 0\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128],target = 1023) == -1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2],target = 1000) == 0\n assert candidate(nums = [16, 8, 4, 2, 1, 1, 1],target = 31) == 0\n assert candidate(nums = [256, 128, 64, 32, 16, 8, 4, 2, 1],target = 448) == 0\n assert candidate(nums = [1, 4, 16, 64, 256, 1024, 4096, 16384],target = 12345) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 4095) == -1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1536) == 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],target = 15) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 32767) == 0\n assert candidate(nums = [16, 16, 16, 16, 8, 8, 8, 8, 4, 4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1],target = 63) == 0\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],target = 4095) == -1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 1024) == -1\n assert candidate(nums = [1, 4, 16, 64, 256, 1024, 4096],target = 2047) == 11\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],target = 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],target = 10) == 0\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],target = 2147483647) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 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],target = 30) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 1023) == 10\n assert candidate(nums = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 2047) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64],target = 127) == -1\n assert candidate(nums = [32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 32767) == -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],target = 1073741823) == 0\n assert candidate(nums = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 2047) == 0\n assert candidate(nums = [1024, 512, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 1, 1, 1],target = 2047) == 0\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16],target = 31) == 0\n assert candidate(nums = [8, 4, 2, 1, 1, 1, 1, 1],target = 13) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 2047) == -1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64, 128, 128, 128, 256, 256, 256, 512, 512, 512, 1024, 1024, 1024],target = 2047) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1023) == -1\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 32767) == 0\n assert candidate(nums = [512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824],target = 2147483647) == -1\n assert candidate(nums = [512, 512, 512, 512],target = 1024) == 0\n assert candidate(nums = [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, 1],target = 2147483647) == 0\n assert candidate(nums = [1, 4, 16, 64, 256],target = 255) == 7\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256],target = 255) == 8\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1024) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 32767) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 1023) == 10\n assert candidate(nums = [1, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144],target = 524287) == -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, 2048, 2048, 4096, 4096, 8192, 8192, 16384, 16384, 32768, 32768, 65536, 65536, 131072, 131072, 262144, 262144, 524288, 524288, 1048576, 1048576, 2097152, 2097152, 4194304, 4194304, 8388608, 8388608, 16777216, 16777216, 33554432, 33554432, 67108864, 67108864, 134217728, 134217728, 268435456, 268435456, 536870912, 536870912, 1073741824, 1073741824],target = 1073741823) == 0\n assert candidate(nums = [1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 2047) == 0\n assert candidate(nums = [1, 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],target = 2147483647) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],target = 4095) == 0\n assert candidate(nums = [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, 1],target = 1) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 2047) == 0\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 2047) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192],target = 15000) == 0\n assert candidate(nums = [2, 4, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512],target = 1023) == 2\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],target = 2047) == 0\n assert candidate(nums = [512, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1023) == 0\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, 1024, 1024, 1024, 1024, 2048, 2048, 2048, 2048, 4096, 4096, 4096, 4096, 8192, 8192, 8192, 8192, 16384, 16384, 16384, 16384, 32768, 32768, 32768, 32768, 65536, 65536, 65536, 65536, 131072, 131072, 131072, 131072, 262144, 262144, 262144, 262144, 524288, 524288, 524288, 524288, 1048576, 1048576, 1048576, 1048576, 2097152, 2097152, 2097152, 2097152, 4194304, 4194304, 4194304, 4194304, 8388608, 8388608, 8388608, 8388608, 16777216, 16777216, 16777216, 16777216, 33554432, 33554432, 33554432, 33554432, 67108864, 67108864, 67108864, 67108864, 134217728, 134217728, 134217728, 134217728, 268435456, 268435456, 268435456, 268435456, 536870912, 536870912, 536870912, 536870912, 1073741824, 1073741824, 1073741824, 1073741824],target = 2147483647) == 0\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],target = 1024) == 0\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, 2048, 2048, 4096, 4096, 8192, 8192, 16384, 16384, 32768, 32768, 65536, 65536, 131072, 131072, 262144, 262144, 524288, 524288, 1048576, 1048576, 2097152, 2097152, 4194304, 4194304, 8388608, 8388608, 16777216, 16777216, 33554432, 33554432, 67108864, 67108864, 134217728, 134217728, 268435456, 268435456, 536870912, 536870912, 1073741824, 1073741824],target = 2147483647) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 8) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 2047) == 0\n assert candidate(nums = [32, 32, 16, 16, 8, 8, 4, 4, 2, 2, 1, 1],target = 48) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],target = 8191) == 0\n assert candidate(nums = [4, 16, 64, 256],target = 317) == 6\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 2047) == -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],target = 2097151) == 21\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],target = 4095) == -1\n assert candidate(nums = [262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1048575) == -1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1023) == 0\n assert candidate(nums = [1, 1, 1, 1, 16],target = 15) == 2\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],target = 1048575) == 0\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],target = 4294967295) == -1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],target = 8191) == -1\n assert candidate(nums = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1023) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 1023) == 0\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],target = 0) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 1023) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192],target = 8191) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 31) == -1\n assert candidate(nums = [512, 512, 512, 512, 512, 512, 512, 512, 512, 512],target = 2048) == 0\n assert candidate(nums = [4, 8, 16, 32, 64],target = 100) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minOperations(List nums, int target) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "List"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2836, "task_id": "maximize-value-of-function-in-a-ball-passing-game", "difficulty": "Hard", "problem_description": "You are given an integer array receiver of length n and an integer k. n players are playing a ball-passing game.\nYou choose the starting player, i. The game proceeds as follows: player i passes the ball to player receiver[i], who then passes it to receiver[receiver[i]], and so on, for k passes in total. The game's score is the sum of the indices of the players who touched the ball, including repetitions, i.e. i + receiver[i] + receiver[receiver[i]] + ... + receiver(k)[i].\nReturn the maximum possible score.\nNotes:\n\nreceiver may contain duplicates.\nreceiver[i] may be equal to i.\n\n \nExample 1:\n\nInput: receiver = [2,0,1], k = 4\nOutput: 6\nExplanation:\nStarting with player i = 2 the initial score is 2:\n\n\n\nPass\nSender Index\nReceiver Index\nScore\n\n\n1\n2\n1\n3\n\n\n2\n1\n0\n3\n\n\n3\n0\n2\n5\n\n\n4\n2\n1\n6\n\n\n\n\nExample 2:\n\nInput: receiver = [1,1,1,2,3], k = 3\nOutput: 10\nExplanation:\nStarting with player i = 4 the initial score is 4:\n\n\n\nPass\nSender Index\nReceiver Index\nScore\n\n\n1\n4\n3\n7\n\n\n2\n3\n2\n9\n\n\n3\n2\n1\n10\n\n\n\n\n \nConstraints:\n\n1 <= receiver.length == n <= 105\n0 <= receiver[i] <= n - 1\n1 <= k <= 1010\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(receiver = [4, 3, 2, 1, 0],k = 10) == 24\n assert candidate(receiver = [4, 3, 2, 1, 0],k = 5) == 12\n assert candidate(receiver = [3, 3, 3, 3],k = 10) == 33\n assert candidate(receiver = [0, 2, 1, 0],k = 5) == 9\n assert candidate(receiver = [1, 1, 1, 2, 3],k = 3) == 10\n assert candidate(receiver = [0, 2, 1, 3],k = 2) == 9\n assert candidate(receiver = [2, 0, 1],k = 4) == 6\n assert candidate(receiver = [1, 2, 3, 4, 0],k = 2) == 9\n assert candidate(receiver = [3, 2, 1, 0],k = 5) == 9\n assert candidate(receiver = [1, 2, 3, 4, 0],k = 10) == 24\n assert candidate(receiver = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1000000000) == 9\n assert candidate(receiver = [1, 2, 0, 3, 4, 5],k = 15) == 80\n assert candidate(receiver = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 5000000000) == 2500000009\n assert candidate(receiver = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4],k = 1000000000) == 11500000019\n assert candidate(receiver = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 100000) == 1900019\n assert candidate(receiver = [0, 0, 0, 0, 0],k = 1000000000) == 4\n assert candidate(receiver = [2, 0, 1, 3, 4, 5, 3, 2],k = 100) == 505\n assert candidate(receiver = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6],k = 875000000) == 6562500009\n assert candidate(receiver = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0],k = 1000000) == 9500019\n assert candidate(receiver = [1, 0, 3, 2, 5, 4],k = 999999999) == 4500000000\n assert candidate(receiver = [2, 3, 4, 5, 0, 1],k = 123456789) == 370370372\n assert candidate(receiver = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0],k = 1000000000) == 9500000019\n assert candidate(receiver = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10000000000) == 9\n assert candidate(receiver = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == 54\n assert candidate(receiver = [0, 1, 0, 1, 0, 1],k = 5000000000) == 5000000005\n assert candidate(receiver = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8],k = 200) == 1709\n assert candidate(receiver = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 20) == 99\n assert candidate(receiver = [0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5],k = 1000) == 5011\n assert candidate(receiver = [3, 0, 1, 2, 7, 8, 9, 10, 5, 6, 11, 4],k = 500) == 4011\n assert candidate(receiver = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 0],k = 8765432109) == 43827160558\n assert candidate(receiver = [5, 6, 0, 1, 3, 2, 4],k = 100) == 356\n assert candidate(receiver = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 1000000) == 9500019\n assert candidate(receiver = [4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4],k = 100000) == 200016\n assert candidate(receiver = [1, 0, 2, 4, 3, 5, 6, 7, 8, 9],k = 50) == 459\n assert candidate(receiver = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 15, 10],k = 1000000000) == 12500000015\n assert candidate(receiver = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 1000000000) == 3000000009\n assert candidate(receiver = [2, 3, 4, 5, 6, 0, 1, 7, 8, 9],k = 20) == 189\n assert candidate(receiver = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2],k = 1000000) == 1000020\n assert candidate(receiver = [0, 0, 0, 0, 0, 0],k = 999999999) == 5\n assert candidate(receiver = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],k = 10000000000) == 80000000008\n assert candidate(receiver = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 1000) == 4509\n assert candidate(receiver = [4, 3, 2, 1, 0, 4, 3, 2, 1, 0],k = 10000000000) == 20000000009\n assert candidate(receiver = [2, 3, 4, 5, 6, 7, 8, 9, 0, 1],k = 10000000) == 50000009\n assert candidate(receiver = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == 27\n assert candidate(receiver = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1000000000) == 500000009\n assert candidate(receiver = [2, 3, 4, 5, 6, 1, 0],k = 10000000000) == 30000000006\n assert candidate(receiver = [5, 4, 3, 2, 1, 0, 6, 7, 8, 9],k = 10000000000) == 90000000009\n assert candidate(receiver = [3, 1, 2, 0, 5, 4, 7, 6, 9, 8],k = 1000) == 8509\n assert candidate(receiver = [2, 3, 4, 5, 6, 7, 8, 9, 0, 1],k = 1500000000) == 7500000009\n assert candidate(receiver = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8],k = 50) == 434\n assert candidate(receiver = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18],k = 100000000) == 1850000019\n assert candidate(receiver = [5, 3, 0, 1, 4, 2],k = 500000000) == 2000000004\n assert candidate(receiver = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 999999999) == 4000000005\n assert candidate(receiver = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],k = 100000) == 800008\n assert candidate(receiver = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 50) == 260\n assert candidate(receiver = [3, 2, 1, 0, 7, 6, 5, 4],k = 10000000000) == 55000000007\n assert candidate(receiver = [0, 0, 1, 2, 3, 4],k = 1000000000) == 15\n assert candidate(receiver = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],k = 1250000000) == 10000000008\n assert candidate(receiver = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9],k = 625000000) == 5625000009\n assert candidate(receiver = [3, 0, 1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18],k = 1000000000) == 18500000019\n assert candidate(receiver = [5, 3, 0, 2, 1, 4],k = 10000000000) == 25000000005\n assert candidate(receiver = [4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 14, 13, 12, 11, 10, 19, 18, 17, 16, 15],k = 900000000) == 15300000019\n assert candidate(receiver = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 500000000) == 9\n assert candidate(receiver = [2, 4, 6, 8, 10, 12, 14, 16, 18, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 9999999999) == 190000000000\n assert candidate(receiver = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18],k = 1000) == 13022\n assert candidate(receiver = [2, 3, 4, 5, 6, 7, 8, 9, 0, 1],k = 25) == 134\n assert candidate(receiver = [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],k = 10000000000) == 490000000049\n assert candidate(receiver = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 10000000000) == 45000000009\n assert candidate(receiver = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 500000000) == 9500000019\n assert candidate(receiver = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 1000000000) == 19000000019\n assert candidate(receiver = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 1000000000) == 9500000019\n assert candidate(receiver = [7, 6, 5, 4, 3, 2, 1, 0, 8, 9, 10, 11, 12, 13, 14, 15],k = 9876543210) == 148148148165\n assert candidate(receiver = [5, 4, 3, 2, 1, 0],k = 15) == 40\n assert candidate(receiver = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 500000000) == 2250000009\n assert candidate(receiver = [0, 0, 0, 0, 0],k = 100000) == 4\n assert candidate(receiver = [5, 6, 0, 1, 4, 3, 2],k = 15) == 64\n assert candidate(receiver = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5000) == 25009\n assert candidate(receiver = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 1000000000) == 5000000010\n assert candidate(receiver = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 11, 10, 15, 14, 13, 12],k = 100000000) == 1350000015\n assert candidate(receiver = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 50) == 34\n assert candidate(receiver = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 109\n assert candidate(receiver = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4],k = 750000000) == 4875000009\n assert candidate(receiver = [5, 4, 3, 2, 1, 0],k = 500000000) == 1250000005\n assert candidate(receiver = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0],k = 5000000000) == 10000000008\n assert candidate(receiver = [2, 0, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 0],k = 1000000000) == 17500000018\n assert candidate(receiver = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5000000000) == 5000000019\n assert candidate(receiver = [2, 0, 3, 1, 6, 4, 5, 7, 8, 9],k = 100000000000) == 900000000009\n assert candidate(receiver = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 9999999999) == 45000000000\n assert candidate(receiver = [5, 4, 3, 2, 1, 0],k = 100) == 255\n assert candidate(receiver = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1000000000) == 9000000009\n assert candidate(receiver = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],k = 50) == 408\n assert candidate(receiver = [2, 1, 0, 3, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],k = 100000000) == 1450000015\n assert candidate(receiver = [5, 4, 3, 2, 1, 0],k = 10000000000) == 25000000005\n assert candidate(receiver = [0, 3, 6, 9, 2, 5, 8, 1, 4, 7],k = 50) == 259\n assert candidate(receiver = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10],k = 999999999) == 14500000000\n assert candidate(receiver = [6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 100000) == 1500015\n assert candidate(receiver = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 1000) == 3009\n assert candidate(receiver = [5, 4, 3, 2, 1, 0],k = 1000000000) == 2500000005\n assert candidate(receiver = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 1000000000) == 4500000009\n assert candidate(receiver = [0, 2, 3, 4, 5, 6, 7, 8, 9, 1],k = 100) == 512\n assert candidate(receiver = [3, 0, 1, 2, 5, 4],k = 100) == 455\n assert candidate(receiver = [3, 2, 1, 0, 7, 6, 5, 4, 9, 8],k = 50) == 434\n assert candidate(receiver = [1, 2, 0, 4, 5, 3, 6, 7, 8, 9],k = 50) == 459\n assert candidate(receiver = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10000000000) == 10000000019\n assert candidate(receiver = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 1000000000) == 1000000009\n assert candidate(receiver = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 999999999) == 500000008\n assert candidate(receiver = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4],k = 9999999999) == 25000000010\n assert candidate(receiver = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 1000000000) == 18500000019\n assert candidate(receiver = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8],k = 100000) == 850009\n"}, "metadata": {"canonical_parameter_names": ["receiver", "k"], "leetcode_dataset_entry_point": "Solution().getMaxFunctionValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long getMaxFunctionValue(List receiver, long k) {", "container": "Solution", "callable": "getMaxFunctionValue", "parameters": [{"name": "receiver", "type": "List"}, {"name": "k", "type": "long"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2839, "task_id": "check-if-strings-can-be-made-equal-with-operations-i", "difficulty": "Easy", "problem_description": "You are given two strings s1 and s2, both of length 4, consisting of lowercase English letters.\nYou can apply the following operation on any of the two strings any number of times:\n\nChoose any two indices i and j such that j - i = 2, then swap the two characters at those indices in the string.\n\nReturn true if you can make the strings s1 and s2 equal, and false otherwise.\n \nExample 1:\n\nInput: s1 = \"abcd\", s2 = \"cdab\"\nOutput: true\nExplanation: We can do the following operations on s1:\n- Choose the indices i = 0, j = 2. The resulting string is s1 = \"cbad\".\n- Choose the indices i = 1, j = 3. The resulting string is s1 = \"cdab\" = s2.\n\nExample 2:\n\nInput: s1 = \"abcd\", s2 = \"dacb\"\nOutput: false\nExplanation: It is not possible to make the two strings equal.\n\n \nConstraints:\n\ns1.length == s2.length == 4\ns1 and s2 consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"abcd\",s2 = \"cdab\") == True\n assert candidate(s1 = \"acbd\",s2 = \"bdac\") == True\n assert candidate(s1 = \"abab\",s2 = \"abcd\") == False\n assert candidate(s1 = \"abdc\",s2 = \"cdab\") == False\n assert candidate(s1 = \"abcd\",s2 = \"dacb\") == False\n assert candidate(s1 = \"abab\",s2 = \"baba\") == False\n assert candidate(s1 = \"abcd\",s2 = \"abcd\") == True\n assert candidate(s1 = \"aabb\",s2 = \"bbaa\") == True\n assert candidate(s1 = \"abcd\",s2 = \"dcba\") == False\n assert candidate(s1 = \"zzzz\",s2 = \"zzzz\") == True\n assert candidate(s1 = \"zabc\",s2 = \"cbaz\") == False\n assert candidate(s1 = \"efef\",s2 = \"fefo\") == False\n assert candidate(s1 = \"abcd\",s2 = \"dcab\") == False\n assert candidate(s1 = \"abcd\",s2 = \"dbca\") == False\n assert candidate(s1 = \"qrst\",s2 = \"tqsr\") == False\n assert candidate(s1 = \"mnop\",s2 = \"ponq\") == False\n assert candidate(s1 = \"ijkl\",s2 = \"lkji\") == False\n assert candidate(s1 = \"abcd\",s2 = \"cabd\") == False\n assert candidate(s1 = \"wxxy\",s2 = \"yxwx\") == False\n assert candidate(s1 = \"abcd\",s2 = \"abdc\") == False\n assert candidate(s1 = \"qrst\",s2 = \"tsqr\") == False\n assert candidate(s1 = \"abba\",s2 = \"baab\") == True\n assert candidate(s1 = \"abcd\",s2 = \"cadb\") == False\n assert candidate(s1 = \"abcd\",s2 = \"cdac\") == False\n assert candidate(s1 = \"wxyz\",s2 = \"yxwz\") == True\n assert candidate(s1 = \"abac\",s2 = \"cabd\") == False\n assert candidate(s1 = \"mnop\",s2 = \"npom\") == False\n assert candidate(s1 = \"ijkl\",s2 = \"lkij\") == False\n assert candidate(s1 = \"efgh\",s2 = \"fegh\") == False\n assert candidate(s1 = \"pqrs\",s2 = \"rqps\") == True\n assert candidate(s1 = \"uvwx\",s2 = \"xwvu\") == False\n assert candidate(s1 = \"wxyz\",s2 = \"xywz\") == False\n assert candidate(s1 = \"xyxy\",s2 = \"yxyx\") == False\n assert candidate(s1 = \"efgh\",s2 = \"hgfq\") == False\n assert candidate(s1 = \"abcd\",s2 = \"dbac\") == False\n assert candidate(s1 = \"aabb\",s2 = \"abab\") == False\n assert candidate(s1 = \"mnop\",s2 = \"ponm\") == False\n assert candidate(s1 = \"abcd\",s2 = \"bdca\") == False\n assert candidate(s1 = \"qrst\",s2 = \"tsrf\") == False\n assert candidate(s1 = \"qrst\",s2 = \"tsrq\") == False\n assert candidate(s1 = \"abcd\",s2 = \"badc\") == False\n assert candidate(s1 = \"qrst\",s2 = \"tqrs\") == False\n assert candidate(s1 = \"abcd\",s2 = \"adcb\") == True\n assert candidate(s1 = \"mnop\",s2 = \"pmno\") == False\n assert candidate(s1 = \"abba\",s2 = \"baba\") == False\n assert candidate(s1 = \"abcd\",s2 = \"bacd\") == False\n assert candidate(s1 = \"abca\",s2 = \"acba\") == False\n assert candidate(s1 = \"abcd\",s2 = \"bdac\") == False\n assert candidate(s1 = \"mnop\",s2 = \"onmp\") == True\n assert candidate(s1 = \"lwxy\",s2 = \"xylw\") == True\n assert candidate(s1 = \"zzza\",s2 = \"zzaa\") == False\n assert candidate(s1 = \"abcd\",s2 = \"acdb\") == False\n assert candidate(s1 = \"zzzz\",s2 = \"zzaz\") == False\n assert candidate(s1 = \"aabb\",s2 = \"abba\") == True\n assert candidate(s1 = \"abcd\",s2 = \"acbd\") == False\n assert candidate(s1 = \"wxyz\",s2 = \"xyzw\") == False\n assert candidate(s1 = \"xxyz\",s2 = \"zyxz\") == False\n assert candidate(s1 = \"abcd\",s2 = \"dabc\") == False\n assert candidate(s1 = \"pqrs\",s2 = \"rspq\") == True\n assert candidate(s1 = \"zyxw\",s2 = \"xwyz\") == False\n assert candidate(s1 = \"abcd\",s2 = \"abca\") == False\n assert candidate(s1 = \"abca\",s2 = \"cabd\") == False\n assert candidate(s1 = \"mnop\",s2 = \"nopm\") == False\n"}, "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().canBeEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean canBeEqual(String s1, String s2) {", "container": "Solution", "callable": "canBeEqual", "parameters": [{"name": "s1", "type": "String"}, {"name": "s2", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2840, "task_id": "check-if-strings-can-be-made-equal-with-operations-ii", "difficulty": "Medium", "problem_description": "You are given two strings s1 and s2, both of length n, consisting of lowercase English letters.\nYou can apply the following operation on any of the two strings any number of times:\n\nChoose any two indices i and j such that i < j and the difference j - i is even, then swap the two characters at those indices in the string.\n\nReturn true if you can make the strings s1 and s2 equal, and false otherwise.\n \nExample 1:\n\nInput: s1 = \"abcdba\", s2 = \"cabdab\"\nOutput: true\nExplanation: We can apply the following operations on s1:\n- Choose the indices i = 0, j = 2. The resulting string is s1 = \"cbadba\".\n- Choose the indices i = 2, j = 4. The resulting string is s1 = \"cbbdaa\".\n- Choose the indices i = 1, j = 5. The resulting string is s1 = \"cabdab\" = s2.\n\nExample 2:\n\nInput: s1 = \"abe\", s2 = \"bea\"\nOutput: false\nExplanation: It is not possible to make the two strings equal.\n\n \nConstraints:\n\nn == s1.length == s2.length\n1 <= n <= 105\ns1 and s2 consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"aabbcc\",s2 = \"bbaacc\") == True\n assert candidate(s1 = \"abcdabcd\",s2 = \"dcbadcba\") == False\n assert candidate(s1 = \"abcdba\",s2 = \"cabdab\") == True\n assert candidate(s1 = \"a\",s2 = \"a\") == True\n assert candidate(s1 = \"hello\",s2 = \"olelh\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"acbbca\") == True\n assert candidate(s1 = \"abcd\",s2 = \"cdab\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\") == False\n assert candidate(s1 = \"xyz\",s2 = \"zyx\") == True\n assert candidate(s1 = \"ab\",s2 = \"ba\") == False\n assert candidate(s1 = \"abe\",s2 = \"bea\") == False\n assert candidate(s1 = \"abcd\",s2 = \"dcba\") == False\n assert candidate(s1 = \"aabbccddeeff\",s2 = \"ffeeddccbbaa\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"ssimmppiiss\") == False\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzzyyxwwvvuuttrrssqqppoonnmmllkkjjiihhggffeeeeddccbbaa\") == False\n assert candidate(s1 = \"palindrome\",s2 = \"paldinrome\") == False\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(s1 = \"racecar\",s2 = \"acecarr\") == False\n assert candidate(s1 = \"aaabbbccc\",s2 = \"bbbaaacc\") == False\n assert candidate(s1 = \"oddindexedswap\",s2 = \"doidndexswpoa\") == False\n assert candidate(s1 = \"abcdefghijabcdefghijabcdefghij\",s2 = \"abcdefghijabcdefghijabcdefghjk\") == False\n assert candidate(s1 = \"level\",s2 = \"level\") == True\n assert candidate(s1 = \"deified\",s2 = \"deified\") == True\n assert candidate(s1 = \"evenlydistributedstring\",s2 = \"elvnyeedisutrdstrign\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbbaa\") == True\n assert candidate(s1 = \"pqrstuv\",s2 = \"upqrsvt\") == False\n assert candidate(s1 = \"rotor\",s2 = \"rotar\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"gfedcba\") == True\n assert candidate(s1 = \"racecar\",s2 = \"carrace\") == False\n assert candidate(s1 = \"abababab\",s2 = \"babababa\") == False\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(s1 = \"zxcvbnm\",s2 = \"mnbvcxz\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzyyxwwvvuuttssrrqppoonnllkkjjiihhggeeffdccbbbaa\") == False\n assert candidate(s1 = \"abcdefgh\",s2 = \"gfehdcba\") == False\n assert candidate(s1 = \"abcdefghijabcdefghijabcdefghij\",s2 = \"bacdfegihjbacdfegihjbacdfegihj\") == False\n assert candidate(s1 = \"aaaabbbbccccddddeeeeffffgggghhhh\",s2 = \"hhhhggggffffeeeeddddbbbbccccaaaa\") == True\n assert candidate(s1 = \"hellohello\",s2 = \"ehlolhloel\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"abaabacabadabaaba\") == False\n assert candidate(s1 = \"abcdabcdabcdabcd\",s2 = \"bacdbacdbacdbacd\") == False\n assert candidate(s1 = \"banana\",s2 = \"ananab\") == False\n assert candidate(s1 = \"abcabcabcabcabcabcabcabcabcabc\",s2 = \"bababababababababababababababababa\") == False\n assert candidate(s1 = \"zzzzzzzzzz\",s2 = \"zzzzzzzzzz\") == True\n assert candidate(s1 = \"abacabadabacabad\",s2 = \"babaacabadabacab\") == False\n assert candidate(s1 = \"abcdabcdabcdabcd\",s2 = \"ddddccccbbbbaaaa\") == False\n assert candidate(s1 = \"aabbccddeeff\",s2 = \"abbaccddffee\") == True\n assert candidate(s1 = \"xyzxyzxyzxyz\",s2 = \"zyxzyxzyxzyx\") == True\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyzz\",s2 = \"zzabcdefghijklmnopqrstuvwxy\") == True\n assert candidate(s1 = \"thisisaverylongstring\",s2 = \"tihisrasevylnsgtrnogi\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"ppissimissi\") == True\n assert candidate(s1 = \"aaaaaabbbbbb\",s2 = \"bbbbbaaaaaa\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"aabacabadabacab\") == False\n assert candidate(s1 = \"abcdefghijkmnopqrstuvwxyz\",s2 = \"bacdfeghijkmnopqrstvwxyz\") == False\n assert candidate(s1 = \"abacabadabacabad\",s2 = \"babaacabdacaba\") == False\n assert candidate(s1 = \"abcdef\",s2 = \"fdecba\") == False\n assert candidate(s1 = \"abcdefghijk\",s2 = \"jihgfedcbaa\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"imississipp\") == False\n assert candidate(s1 = \"qwertqwert\",s2 = \"wqerqewtqw\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"ssissimippi\") == True\n assert candidate(s1 = \"almostsame\",s2 = \"lmostsae\") == False\n assert candidate(s1 = \"abcdefgabcdefg\",s2 = \"gfedcbagfedcba\") == True\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwx\",s2 = \"bacdfeghijklmnopqrstuvxw\") == False\n assert candidate(s1 = \"abcdefghijkll\",s2 = \"llijkgfhecdba\") == False\n assert candidate(s1 = \"abcabcabc\",s2 = \"bcabcbaca\") == False\n assert candidate(s1 = \"zaybzcyd\",s2 = \"dzbyazcy\") == False\n assert candidate(s1 = \"abcdefghef\",s2 = \"gdefhabcef\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"bbccaa\") == True\n assert candidate(s1 = \"abcabcabc\",s2 = \"cbacbacba\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"bbbbccccddddeeeeffffgggghhhhiiijjjkkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == False\n assert candidate(s1 = \"abcdefghijklmnop\",s2 = \"ponmlkjihgfedcba\") == False\n assert candidate(s1 = \"programming\",s2 = \"pgmrnomggin\") == False\n assert candidate(s1 = \"repaper\",s2 = \"repaper\") == True\n assert candidate(s1 = \"abcdefgihjklmnopqrstuvwxyz\",s2 = \"bacdfegihjklmnopqrstuvwxzy\") == False\n assert candidate(s1 = \"abcdeffedcba\",s2 = \"fedcbaffedcba\") == False\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",s2 = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeeeddccbbbaa\") == False\n assert candidate(s1 = \"sameorder\",s2 = \"sameorder\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"bbaaccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(s1 = \"abcdabcd\",s2 = \"dcbaabcd\") == False\n assert candidate(s1 = \"abcdefghij\",s2 = \"jihgfedcba\") == False\n assert candidate(s1 = \"pqrstuvw\",s2 = \"wvutsrqp\") == False\n assert candidate(s1 = \"zyxwvutsrqponmlkjihgfedcba\",s2 = \"yxwvuztsrqponmlkjihgfedcba\") == False\n assert candidate(s1 = \"abcdefghij\",s2 = \"aecgbdfhij\") == False\n assert candidate(s1 = \"acdbegfh\",s2 = \"bfegacdh\") == False\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(s1 = \"abadecafagbahbbhacdg\",s2 = \"bdacegafabchbahbadcg\") == False\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghij\") == True\n assert candidate(s1 = \"aabbaabb\",s2 = \"bbaabbaa\") == True\n assert candidate(s1 = \"xyzzyxzyxzyx\",s2 = \"zyxzyxzyxzyx\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzzzyyyxxxwwvvuuttssrrqqppoonnllkkjjiihhggeeffddeebbcaaa\") == False\n assert candidate(s1 = \"abcabcabcabc\",s2 = \"cbacbacbacba\") == True\n assert candidate(s1 = \"racecar\",s2 = \"racecar\") == True\n assert candidate(s1 = \"abacabadabacabad\",s2 = \"badcbadcbadcba\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"abacabaabacabada\") == False\n assert candidate(s1 = \"aabbccddeeff\",s2 = \"fbeeccddbaaa\") == False\n assert candidate(s1 = \"noon\",s2 = \"noon\") == True\n assert candidate(s1 = \"aaabbbcccddd\",s2 = \"dddcccbbbaaa\") == False\n assert candidate(s1 = \"zxyxzyzyx\",s2 = \"yxzyxzyxq\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"ppimississi\") == False\n assert candidate(s1 = \"abcdefghij\",s2 = \"gbihfedcja\") == False\n assert candidate(s1 = \"aabbccddeeffgghhiijj\",s2 = \"jjiihhggffeeeddccbaa\") == False\n assert candidate(s1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(s1 = \"aabbaabbaabb\",s2 = \"bbaabbaabbba\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"afedcba\") == False\n assert candidate(s1 = \"abacabad\",s2 = \"dcadcbab\") == False\n assert candidate(s1 = \"aabbccdd\",s2 = \"ddccbbaa\") == True\n assert candidate(s1 = \"ababababababababababababab\",s2 = \"bababababababababababababa\") == False\n assert candidate(s1 = \"noonnoon\",s2 = \"nnoonnou\") == False\n assert candidate(s1 = \"ababab\",s2 = \"bababa\") == False\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"abbaccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(s1 = \"abcdefgihjklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(s1 = \"abcdefghij\",s2 = \"jeihgfedcb\") == False\n assert candidate(s1 = \"abcdefghijk\",s2 = \"jihgfedcbak\") == False\n assert candidate(s1 = \"qwertypoiuytrewq\",s2 = \"qwertyuiytrewpoi\") == False\n assert candidate(s1 = \"rotor\",s2 = \"rotor\") == True\n assert candidate(s1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",s2 = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == True\n assert candidate(s1 = \"noonoon\",s2 = \"nooouon\") == False\n assert candidate(s1 = \"detartrated\",s2 = \"detartrated\") == True\n assert candidate(s1 = \"abcdabcdabcd\",s2 = \"dcbaabcdabcd\") == False\n assert candidate(s1 = \"aabbaabbaabbaabb\",s2 = \"bbaabbaabbaabbaa\") == True\n assert candidate(s1 = \"mnopqrstuvwxyzabcdefghijkl\",s2 = \"onmpqrstuvwxyzabcdefghijkl\") == True\n assert candidate(s1 = \"abcdabcd\",s2 = \"cdabcdab\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzyyxxwwvvuuttrrqqppoonnllkkjjiihhggeeffddeeaabbcc\") == False\n assert candidate(s1 = \"xyxzyzyx\",s2 = \"yxzyxzyz\") == False\n assert candidate(s1 = \"pqrstuvwx\",s2 = \"vutsrqpwx\") == True\n assert candidate(s1 = \"abacabadabacabaa\",s2 = \"abaabacabadabaab\") == False\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zabcdefghijklmnopqrstuvwxy\") == False\n assert candidate(s1 = \"aabbccddeeff\",s2 = \"bbccddeeffaa\") == True\n"}, "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().checkStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean checkStrings(String s1, String s2) {", "container": "Solution", "callable": "checkStrings", "parameters": [{"name": "s1", "type": "String"}, {"name": "s2", "type": "String"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2841, "task_id": "maximum-sum-of-almost-unique-subarray", "difficulty": "Medium", "problem_description": "You are given an integer array nums and two positive integers m and k.\nReturn the maximum sum out of all almost unique subarrays of length k of nums. If no such subarray exists, return 0.\nA subarray of nums is almost unique if it contains at least m distinct elements.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [2,6,7,3,1,7], m = 3, k = 4\nOutput: 18\nExplanation: There are 3 almost unique subarrays of size k = 4. These subarrays are [2, 6, 7, 3], [6, 7, 3, 1], and [7, 3, 1, 7]. Among these subarrays, the one with the maximum sum is [2, 6, 7, 3] which has a sum of 18.\n\nExample 2:\n\nInput: nums = [5,9,9,2,4,5,4], m = 1, k = 3\nOutput: 23\nExplanation: There are 5 almost unique subarrays of size k. These subarrays are [5, 9, 9], [9, 9, 2], [9, 2, 4], [2, 4, 5], and [4, 5, 4]. Among these subarrays, the one with the maximum sum is [5, 9, 9] which has a sum of 23.\n\nExample 3:\n\nInput: nums = [1,2,1,2,1,2,1], m = 3, k = 3\nOutput: 0\nExplanation: There are no subarrays of size k = 3 that contain at least m = 3 distinct elements in the given array [1,2,1,2,1,2,1]. Therefore, no almost unique subarrays exist, and the maximum sum is 0.\n\n \nConstraints:\n\n1 <= nums.length <= 2 * 104\n1 <= m <= k <= nums.length\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 2,k = 3) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],m = 4,k = 5) == 35\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],m = 5,k = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],m = 2,k = 3) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],m = 3,k = 4) == 16\n assert candidate(nums = [5, 9, 9, 2, 4, 5, 4],m = 1,k = 3) == 23\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1],m = 3,k = 3) == 0\n assert candidate(nums = [2, 6, 7, 3, 1, 7],m = 3,k = 4) == 18\n assert candidate(nums = [1, 1, 1, 1, 1],m = 2,k = 3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],m = 2,k = 5) == 35\n assert candidate(nums = [10, 10, 10, 10, 10],m = 1,k = 2) == 20\n assert candidate(nums = [10, 20, 30, 40, 50],m = 3,k = 5) == 150\n assert candidate(nums = [5, 5, 5, 5, 5],m = 1,k = 2) == 10\n assert candidate(nums = [10, 10, 10, 10, 10],m = 2,k = 3) == 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, 8, 8, 8, 9, 9, 9],m = 5,k = 9) == 0\n assert candidate(nums = [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],m = 4,k = 10) == 54\n assert candidate(nums = [12, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],m = 5,k = 12) == 562\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],m = 3,k = 7) == 49\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],m = 4,k = 7) == 18\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],m = 3,k = 7) == 26\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],m = 2,k = 25) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],m = 3,k = 3) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],m = 4,k = 5) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],m = 4,k = 4) == 0\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 5,k = 7) == 119\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],m = 3,k = 7) == 4900\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],m = 5,k = 7) == 119\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],m = 5,k = 9) == 189\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],m = 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],m = 1,k = 20) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 5,k = 5) == 400\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 5,k = 7) == 84\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,k = 6) == 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 15,k = 15) == 345\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2],m = 6,k = 10) == 54\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 6) == 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],m = 5,k = 7) == 119\n assert candidate(nums = [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],m = 2,k = 5) == 14\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],m = 1,k = 10) == 80\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],m = 5,k = 7) == 42\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],m = 4,k = 5) == 18\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6],m = 2,k = 4) == 22\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],m = 4,k = 6) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 5,k = 6) == 39\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 4,k = 4) == 30\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],m = 3,k = 5) == 27\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],m = 3,k = 4) == 30\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],m = 1,k = 3) == 3000000000\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],m = 5,k = 10) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],m = 3,k = 5) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 10) == 55\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118],m = 10,k = 15) == 1665\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8],m = 4,k = 5) == 34\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9],m = 4,k = 6) == 0\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],m = 4,k = 7) == 161\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10,k = 10) == 55\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],m = 5,k = 10) == 60\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],m = 5,k = 10) == 0\n assert candidate(nums = [5, 8, 2, 8, 3, 6, 1, 9, 7, 4, 10],m = 4,k = 5) == 31\n assert candidate(nums = [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, 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],m = 7,k = 9) == 45\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 8,k = 12) == 740\n assert candidate(nums = [7, 7, 1, 7, 7, 7, 1, 7, 7, 7, 1, 7, 7, 7, 1, 7, 7, 7, 1, 7],m = 2,k = 8) == 44\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 6) == 9\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, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],m = 5,k = 10) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 6,k = 8) == 52\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],m = 5,k = 5) == 75\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],m = 3,k = 5) == 10\n assert candidate(nums = [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],m = 6,k = 9) == 99\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],m = 5,k = 8) == 64\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],m = 3,k = 4) == 16\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10],m = 4,k = 7) == 55\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],m = 3,k = 5) == 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 1,k = 10) == 50\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 7,k = 8) == 920\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000, 10000000000],m = 5,k = 6) == 45000000000\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 2,k = 10) == 0\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],m = 5,k = 10) == 30\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1],m = 3,k = 4) == 0\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8],m = 5,k = 6) == 33\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],m = 4,k = 8) == 108\n assert candidate(nums = [29, 18, 27, 29, 18, 27, 29, 18, 27, 29, 18, 27, 29, 18, 27, 29, 18, 27, 29, 18],m = 3,k = 7) == 177\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],m = 2,k = 5) == 0\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],m = 5,k = 5) == 4333333330\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 5) == 40\n assert candidate(nums = [2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4],m = 2,k = 3) == 9\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],m = 7,k = 9) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8],m = 3,k = 6) == 39\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],m = 3,k = 6) == 135\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],m = 4,k = 6) == 81\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 6,k = 8) == 52\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 5,k = 9) == 45\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555],m = 4,k = 5) == 4333333330\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],m = 2,k = 20) == 0\n assert candidate(nums = [2, 3, 3, 2, 3, 2, 2, 3, 2, 3, 2, 3],m = 2,k = 4) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 6) == 45\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],m = 4,k = 5) == 28\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],m = 3,k = 5) == 4000\n assert candidate(nums = [5, 8, 6, 9, 2, 1, 5, 7, 4, 3],m = 3,k = 5) == 30\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],m = 4,k = 7) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],m = 2,k = 3) == 2700\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 5,k = 5) == 900\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4,k = 5) == 40\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],m = 4,k = 15) == 95\n assert candidate(nums = [9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6],m = 3,k = 6) == 0\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9],m = 4,k = 6) == 0\n assert candidate(nums = [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],m = 4,k = 8) == 44\n assert candidate(nums = [5, 5, 5, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],m = 3,k = 5) == 20\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 5,k = 10) == 155\n"}, "metadata": {"canonical_parameter_names": ["nums", "m", "k"], "leetcode_dataset_entry_point": "Solution().maxSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxSum(List nums, int m, int k) {", "container": "Solution", "callable": "maxSum", "parameters": [{"name": "nums", "type": "List"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2842, "task_id": "count-k-subsequences-of-a-string-with-maximum-beauty", "difficulty": "Hard", "problem_description": "You are given a string s and an integer k.\nA k-subsequence is a subsequence of s, having length k, and all its characters are unique, i.e., every character occurs once.\nLet f(c) denote the number of times the character c occurs in s.\nThe beauty of a k-subsequence is the sum of f(c) for every character c in the k-subsequence.\nFor example, consider s = \"abbbdd\" and k = 2:\n\nf('a') = 1, f('b') = 3, f('d') = 2\nSome k-subsequences of s are:\n\t\n\"abbbdd\" -> \"ab\" having a beauty of f('a') + f('b') = 4\n\"abbbdd\" -> \"ad\" having a beauty of f('a') + f('d') = 3\n\"abbbdd\" -> \"bd\" having a beauty of f('b') + f('d') = 5\n\n\n\nReturn an integer denoting the number of k-subsequences whose beauty is the maximum among all k-subsequences. Since the answer may be too large, return it modulo 109 + 7.\nA subsequence of a string is a new string formed from the original string by deleting some (possibly none) of the characters without disturbing the relative positions of the remaining characters.\nNotes\n\nf(c) is the number of times a character c occurs in s, not a k-subsequence.\nTwo k-subsequences are considered different if one is formed by an index that is not present in the other. So, two k-subsequences may form the same string.\n\n \nExample 1:\n\nInput: s = \"bcca\", k = 2\nOutput: 4\nExplanation: From s we have f('a') = 1, f('b') = 1, and f('c') = 2.\nThe k-subsequences of s are: \nbcca having a beauty of f('b') + f('c') = 3 \nbcca having a beauty of f('b') + f('c') = 3 \nbcca having a beauty of f('b') + f('a') = 2 \nbcca having a beauty of f('c') + f('a') = 3\nbcca having a beauty of f('c') + f('a') = 3 \nThere are 4 k-subsequences that have the maximum beauty, 3. \nHence, the answer is 4. \n\nExample 2:\n\nInput: s = \"abbcd\", k = 4\nOutput: 2\nExplanation: From s we have f('a') = 1, f('b') = 2, f('c') = 1, and f('d') = 1. \nThe k-subsequences of s are: \nabbcd having a beauty of f('a') + f('b') + f('c') + f('d') = 5\nabbcd having a beauty of f('a') + f('b') + f('c') + f('d') = 5 \nThere are 2 k-subsequences that have the maximum beauty, 5. \nHence, the answer is 2. \n\n \nConstraints:\n\n1 <= s.length <= 2 * 105\n1 <= k <= s.length\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 26) == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 2) == 0\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().countKSubsequencesWithMaxBeauty", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countKSubsequencesWithMaxBeauty(String s, int k) {", "container": "Solution", "callable": "countKSubsequencesWithMaxBeauty", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2843, "task_id": "count-symmetric-integers", "difficulty": "Easy", "problem_description": "You are given two positive integers low and high.\nAn integer x consisting of 2 * n digits is symmetric if the sum of the first n digits of x is equal to the sum of the last n digits of x. Numbers with an odd number of digits are never symmetric.\nReturn the number of symmetric integers in the range [low, high].\n \nExample 1:\n\nInput: low = 1, high = 100\nOutput: 9\nExplanation: There are 9 symmetric integers between 1 and 100: 11, 22, 33, 44, 55, 66, 77, 88, and 99.\n\nExample 2:\n\nInput: low = 1200, high = 1230\nOutput: 4\nExplanation: There are 4 symmetric integers between 1200 and 1230: 1203, 1212, 1221, and 1230.\n\n \nConstraints:\n\n1 <= low <= high <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(low = 10,high = 20) == 1\n assert candidate(low = 1,high = 9999) == 624\n assert candidate(low = 500,high = 1500) == 20\n assert candidate(low = 1000,high = 1000) == 0\n assert candidate(low = 500,high = 550) == 0\n assert candidate(low = 1,high = 100) == 9\n assert candidate(low = 1,high = 10000) == 624\n assert candidate(low = 1000,high = 10000) == 615\n assert candidate(low = 1200,high = 1230) == 4\n assert candidate(low = 10,high = 1000) == 9\n assert candidate(low = 9999,high = 10000) == 1\n assert candidate(low = 2500,high = 2600) == 8\n assert candidate(low = 1000,high = 9999) == 615\n assert candidate(low = 2500,high = 3500) == 74\n assert candidate(low = 7777,high = 8888) == 70\n assert candidate(low = 7000,high = 7100) == 8\n assert candidate(low = 1001,high = 9990) == 614\n assert candidate(low = 1234,high = 4321) == 216\n assert candidate(low = 1,high = 10) == 0\n assert candidate(low = 2000,high = 2999) == 69\n assert candidate(low = 5000,high = 5500) == 40\n assert candidate(low = 1234,high = 5678) == 326\n assert candidate(low = 7500,high = 7600) == 7\n assert candidate(low = 8000,high = 8500) == 43\n assert candidate(low = 3000,high = 3100) == 4\n assert candidate(low = 3000,high = 3999) == 73\n assert candidate(low = 999,high = 9999) == 615\n assert candidate(low = 5000,high = 5050) == 6\n assert candidate(low = 1000,high = 2000) == 63\n assert candidate(low = 1111,high = 2222) == 70\n assert candidate(low = 10001,high = 20001) == 0\n assert candidate(low = 8000,high = 8100) == 9\n assert candidate(low = 5000,high = 6000) == 75\n assert candidate(low = 2000,high = 3000) == 69\n assert candidate(low = 1000,high = 1010) == 2\n assert candidate(low = 9000,high = 9999) == 55\n assert candidate(low = 3000,high = 3300) == 15\n assert candidate(low = 6000,high = 6100) == 7\n assert candidate(low = 8888,high = 8888) == 1\n assert candidate(low = 9876,high = 9885) == 0\n assert candidate(low = 999,high = 1001) == 1\n assert candidate(low = 1111,high = 9999) == 612\n assert candidate(low = 12345,high = 67890) == 0\n assert candidate(low = 9000,high = 9100) == 10\n assert candidate(low = 9900,high = 10100) == 1\n assert candidate(low = 1000,high = 1100) == 2\n assert candidate(low = 8888,high = 9999) == 59\n assert candidate(low = 1001,high = 1020) == 2\n assert candidate(low = 100100,high = 100200) == 1\n assert candidate(low = 3000,high = 7000) == 296\n assert candidate(low = 1234,high = 8765) == 542\n assert candidate(low = 999,high = 10001) == 615\n assert candidate(low = 9876,high = 9876) == 0\n assert candidate(low = 100,high = 10000) == 615\n assert candidate(low = 1100,high = 1400) == 12\n assert candidate(low = 1001,high = 1010) == 2\n assert candidate(low = 5000,high = 5100) == 6\n assert candidate(low = 7800,high = 7900) == 4\n assert candidate(low = 4999,high = 5001) == 0\n assert candidate(low = 1001,high = 9999) == 615\n assert candidate(low = 1001,high = 1099) == 2\n assert candidate(low = 8000,high = 8999) == 63\n assert candidate(low = 5000,high = 9999) == 335\n assert candidate(low = 9000,high = 10000) == 55\n assert candidate(low = 5000,high = 9000) == 280\n assert candidate(low = 5678,high = 8765) == 216\n assert candidate(low = 2000,high = 8000) == 434\n assert candidate(low = 10000,high = 10000) == 0\n assert candidate(low = 10010,high = 10020) == 0\n assert candidate(low = 5000,high = 50000) == 335\n assert candidate(low = 9900,high = 10000) == 1\n assert candidate(low = 4500,high = 4600) == 10\n"}, "metadata": {"canonical_parameter_names": ["low", "high"], "leetcode_dataset_entry_point": "Solution().countSymmetricIntegers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countSymmetricIntegers(int low, int high) {", "container": "Solution", "callable": "countSymmetricIntegers", "parameters": [{"name": "low", "type": "int"}, {"name": "high", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2844, "task_id": "minimum-operations-to-make-a-special-number", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string num representing a non-negative integer.\nIn one operation, you can pick any digit of num and delete it. Note that if you delete all the digits of num, num becomes 0.\nReturn the minimum number of operations required to make num special.\nAn integer x is considered special if it is divisible by 25.\n \nExample 1:\n\nInput: num = \"2245047\"\nOutput: 2\nExplanation: Delete digits num[5] and num[6]. The resulting number is \"22450\" which is special since it is divisible by 25.\nIt can be shown that 2 is the minimum number of operations required to get a special number.\nExample 2:\n\nInput: num = \"2908305\"\nOutput: 3\nExplanation: Delete digits num[3], num[4], and num[6]. The resulting number is \"2900\" which is special since it is divisible by 25.\nIt can be shown that 3 is the minimum number of operations required to get a special number.\nExample 3:\n\nInput: num = \"10\"\nOutput: 1\nExplanation: Delete digit num[0]. The resulting number is \"0\" which is special since it is divisible by 25.\nIt can be shown that 1 is the minimum number of operations required to get a special number.\n\n\n \nConstraints:\n\n1 <= num.length <= 100\nnum only consists of digits '0' through '9'.\nnum does not contain any leading zeros.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"10\") == 1\n assert candidate(num = \"00000\") == 0\n assert candidate(num = \"75\") == 0\n assert candidate(num = \"52\") == 2\n assert candidate(num = \"500000\") == 0\n assert candidate(num = \"5252525252\") == 1\n assert candidate(num = \"1111111111\") == 10\n assert candidate(num = \"000\") == 0\n assert candidate(num = \"333\") == 3\n assert candidate(num = \"2468024680\") == 4\n assert candidate(num = \"99999\") == 5\n assert candidate(num = \"98765432109876543210\") == 4\n assert candidate(num = \"0246802468\") == 8\n assert candidate(num = \"55555\") == 5\n assert candidate(num = \"875\") == 0\n assert candidate(num = \"2245047\") == 2\n assert candidate(num = \"9876543210\") == 4\n assert candidate(num = \"0\") == 0\n assert candidate(num = \"2908305\") == 3\n assert candidate(num = \"2500\") == 0\n assert candidate(num = \"99999999999999999999\") == 20\n assert candidate(num = \"2050\") == 0\n assert candidate(num = \"55\") == 2\n assert candidate(num = \"375\") == 0\n assert candidate(num = \"999999999\") == 9\n assert candidate(num = \"625\") == 0\n assert candidate(num = \"123056789\") == 6\n assert candidate(num = \"11223344556677889900\") == 0\n assert candidate(num = \"100\") == 0\n assert candidate(num = \"5555555555\") == 10\n assert candidate(num = \"300\") == 0\n assert candidate(num = \"24680\") == 4\n assert candidate(num = \"00\") == 0\n assert candidate(num = \"1234567890\") == 4\n assert candidate(num = \"125\") == 0\n assert candidate(num = \"13579\") == 5\n assert candidate(num = \"50\") == 0\n assert candidate(num = \"1357913579\") == 5\n assert candidate(num = \"9999999999\") == 10\n assert candidate(num = \"25\") == 0\n assert candidate(num = \"57\") == 2\n assert candidate(num = \"2000\") == 0\n assert candidate(num = \"200\") == 0\n assert candidate(num = \"999999999999999999999999999999999999999999999999999\") == 51\n assert candidate(num = \"135792468050\") == 0\n assert candidate(num = \"246824682468\") == 12\n assert candidate(num = \"789012345678901234567890\") == 4\n assert candidate(num = \"500500500500500\") == 0\n assert candidate(num = \"33333333333333333333\") == 20\n assert candidate(num = \"11223344556677889900112233445566778899\") == 13\n assert candidate(num = \"7525105025007525105025007525105025007525105025\") == 0\n assert candidate(num = \"5050505050505050\") == 0\n assert candidate(num = \"246802468024680246802468024680246802468024680\") == 4\n assert candidate(num = \"9999000099990000\") == 0\n assert candidate(num = \"50050050050050050050\") == 0\n assert candidate(num = \"25000000000000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"387625387625387625387625387625\") == 0\n assert candidate(num = \"97531975319753197531\") == 2\n assert candidate(num = \"257001025\") == 0\n assert candidate(num = \"0000000000\") == 0\n assert candidate(num = \"9999999990\") == 9\n assert candidate(num = \"50505050505050505050\") == 0\n assert candidate(num = \"135791357913579135791357913579135791357913579\") == 5\n assert candidate(num = \"99887766554433221100\") == 0\n assert candidate(num = \"499999999999999999999999999999999999999999999999999\") == 51\n assert candidate(num = \"111111111100\") == 0\n assert candidate(num = \"500500500500500500500500500500500500500500500500500\") == 0\n assert candidate(num = \"19387654321098765432101234567890\") == 4\n assert candidate(num = \"1234567890123456789012345678901234567890\") == 4\n assert candidate(num = \"959595959595959595959595959595959595959595959595959\") == 51\n assert candidate(num = \"579135791357913579135791357910\") == 3\n assert candidate(num = \"135791357913579135791357913579135791357913579135791\") == 6\n assert candidate(num = \"50000000000000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"975319753197531975\") == 0\n assert candidate(num = \"2525252525252525252525252525252525252525\") == 0\n assert candidate(num = \"345678901234567890\") == 4\n assert candidate(num = \"3333333333333333333333333333333333333333333335\") == 46\n assert candidate(num = \"98765432109876543210987654321098765432109876543210\") == 4\n assert candidate(num = \"9876543210987654321098765432109876543210987654321098\") == 6\n assert candidate(num = \"2575257525752575257525752575257525752575\") == 0\n assert candidate(num = \"8888888888888888888888888888888888888888888888\") == 46\n assert candidate(num = \"0000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"12345678905\") == 3\n assert candidate(num = \"5432109876543210\") == 4\n assert candidate(num = \"4321098765432109876543210987654321098765\") == 1\n assert candidate(num = \"8765432109876543210987654321098765432109\") == 5\n assert candidate(num = \"3333333333333333333333333333333333333333333330\") == 45\n assert candidate(num = \"77777777777777777777777777777777777777777777777777\") == 50\n assert candidate(num = \"52505250525052505250525052505250\") == 0\n assert candidate(num = \"55555555555555555555\") == 20\n assert candidate(num = \"864208642086420864208642086420864208642086420864208\") == 5\n assert candidate(num = \"2468135792468135792468\") == 11\n assert candidate(num = \"2525252525252525252525252525252525252525252525252525\") == 0\n assert candidate(num = \"20000000000000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"999999999999999999999999999999999999999999999999990\") == 50\n assert candidate(num = \"8765432109876543210\") == 4\n assert candidate(num = \"0000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"5050505050505050505050505050505050505050505050\") == 0\n assert candidate(num = \"8246824682468246\") == 16\n assert candidate(num = \"36925814703692581470\") == 4\n assert candidate(num = \"10101010101010101010101010101010101010101010101010101010\") == 1\n assert candidate(num = \"753153753153753153\") == 4\n assert candidate(num = \"1001001001001001001001001001001\") == 1\n assert candidate(num = \"246802468024680246802468024680246802468024680246802\") == 5\n assert candidate(num = \"000000000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"30000000000000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"2525252525252525252525252525252525252525252525\") == 0\n assert candidate(num = \"4876543210987654321098765432109876543210\") == 4\n assert candidate(num = \"9999990\") == 6\n assert candidate(num = \"25002500250025002500250025002500250025002500\") == 0\n assert candidate(num = \"204861012141618202224262830323436384042444648\") == 17\n assert candidate(num = \"000111000222000333000444000555000666000777000\") == 0\n assert candidate(num = \"000000000000000000000000000000\") == 0\n assert candidate(num = \"11111111111111111111111111111111111111111111\") == 44\n assert candidate(num = \"805\") == 2\n assert candidate(num = \"50000000000000000000\") == 0\n assert candidate(num = \"19283746555555555555\") == 13\n assert candidate(num = \"5555555555555555555555555555555555555555\") == 40\n assert candidate(num = \"12345678909876543210123456789098765432101234567890\") == 4\n assert candidate(num = \"13579135791357913579\") == 5\n assert candidate(num = \"2222222222222222222222222222222222222222\") == 40\n assert candidate(num = \"25000000250000000025000000000000000025\") == 0\n assert candidate(num = \"2222222222222222222222222222222222222222222222\") == 46\n assert candidate(num = \"252525252525252525252525252525\") == 0\n assert candidate(num = \"5050505050505050505050505050505050505050\") == 0\n assert candidate(num = \"111111111111111111110\") == 20\n assert candidate(num = \"987654321098765432109876543210\") == 4\n assert candidate(num = \"222222222222222222222\") == 21\n assert candidate(num = \"12345678909876543210\") == 4\n assert candidate(num = \"012345678901234567890123456789012345678901234567890\") == 4\n assert candidate(num = \"222222222250\") == 0\n assert candidate(num = \"9999099990999909999099990999909999099990\") == 4\n assert candidate(num = \"5000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"9876543210987654321098765432109876543210\") == 4\n assert candidate(num = \"5734094321098765432100\") == 0\n assert candidate(num = \"101010101010101010101010101010101010101010\") == 1\n assert candidate(num = \"98765432101234567890\") == 4\n assert candidate(num = \"987654321098765432101234567890\") == 4\n assert candidate(num = \"02502502502502502502\") == 1\n assert candidate(num = \"19293949596979899909192939495969798999091929394\") == 17\n assert candidate(num = \"0101010101010101010101010101010101010101010101010101010101010\") == 1\n assert candidate(num = \"0123456789012345678901234567890123456789\") == 6\n assert candidate(num = \"555555555525\") == 0\n assert candidate(num = \"404040404040404040404040404040404040404040404040400\") == 0\n assert candidate(num = \"5555555555555525\") == 0\n assert candidate(num = \"25252525252525252525252525252525252525252525\") == 0\n assert candidate(num = \"86420864208642086420\") == 4\n assert candidate(num = \"25252525252525252525\") == 0\n assert candidate(num = \"555555555555555555555555555555555555555555555555555\") == 51\n assert candidate(num = \"01234567890123456789\") == 6\n assert candidate(num = \"55555555555555555555555555555555555555555555555550\") == 0\n assert candidate(num = \"24680246802468024680\") == 4\n assert candidate(num = \"50505050505050505050505050505050505050505050505050\") == 0\n assert candidate(num = \"1234567890123456789012345678901234567890123456\") == 3\n assert candidate(num = \"82468024680246802468\") == 8\n assert candidate(num = \"123456789012345678901234567890\") == 4\n assert candidate(num = \"222222222222222222222222222222222222222222222222225\") == 0\n assert candidate(num = \"33333353333333333335\") == 20\n assert candidate(num = \"62626262626262626262\") == 20\n assert candidate(num = \"123450\") == 0\n assert candidate(num = \"12345678901234567890123456789012345678901234567890\") == 4\n assert candidate(num = \"025025025025\") == 0\n assert candidate(num = \"112233445566778899\") == 13\n assert candidate(num = \"9438765432109876543210123456789050\") == 0\n assert candidate(num = \"12345678900\") == 0\n assert candidate(num = \"18642086420864208640\") == 3\n assert candidate(num = \"52357845968275982450\") == 0\n assert candidate(num = \"777777777777777777777777777777777777777777777777770\") == 50\n assert candidate(num = \"00000000000000000000\") == 0\n assert candidate(num = \"25252525252525\") == 0\n assert candidate(num = \"975310\") == 2\n assert candidate(num = \"10101010101010101010\") == 1\n assert candidate(num = \"333333333333333333333333333333333333333333333333335\") == 51\n assert candidate(num = \"11111111111111111111\") == 20\n assert candidate(num = \"1234567890123456789012345678901234567890123456789012\") == 6\n assert candidate(num = \"55555555555525\") == 0\n assert candidate(num = \"94387126540054321689745261098743652109876543210\") == 4\n assert candidate(num = \"12345678901234567890\") == 4\n assert candidate(num = \"555555555500\") == 0\n assert candidate(num = \"52525252525252525252\") == 1\n assert candidate(num = \"952595259525952595259525952595\") == 2\n assert candidate(num = \"09876543210987654321\") == 5\n assert candidate(num = \"77777777777777777777\") == 20\n assert candidate(num = \"10000000000000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"1000000\") == 0\n assert candidate(num = \"0000000000000000\") == 0\n assert candidate(num = \"22450478900\") == 0\n assert candidate(num = \"22222222222222222222\") == 20\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumOperations(String num) {", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "num", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2845, "task_id": "count-of-interesting-subarrays", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums, an integer modulo, and an integer k.\nYour task is to find the count of subarrays that are interesting.\nA subarray nums[l..r] is interesting if the following condition holds:\n\nLet cnt be the number of indices i in the range [l, r] such that nums[i] % modulo == k. Then, cnt % modulo == k.\n\nReturn an integer denoting the count of interesting subarrays. \nNote: A subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [3,2,4], modulo = 2, k = 1\nOutput: 3\nExplanation: In this example the interesting subarrays are: \nThe subarray nums[0..0] which is [3]. \n- There is only one index, i = 0, in the range [0, 0] that satisfies nums[i] % modulo == k. \n- Hence, cnt = 1 and cnt % modulo == k. \nThe subarray nums[0..1] which is [3,2].\n- There is only one index, i = 0, in the range [0, 1] that satisfies nums[i] % modulo == k. \n- Hence, cnt = 1 and cnt % modulo == k.\nThe subarray nums[0..2] which is [3,2,4]. \n- There is only one index, i = 0, in the range [0, 2] that satisfies nums[i] % modulo == k. \n- Hence, cnt = 1 and cnt % modulo == k. \nIt can be shown that there are no other interesting subarrays. So, the answer is 3.\nExample 2:\n\nInput: nums = [3,1,9,6], modulo = 3, k = 0\nOutput: 2\nExplanation: In this example the interesting subarrays are: \nThe subarray nums[0..3] which is [3,1,9,6]. \n- There are three indices, i = 0, 2, 3, in the range [0, 3] that satisfy nums[i] % modulo == k. \n- Hence, cnt = 3 and cnt % modulo == k. \nThe subarray nums[1..1] which is [1]. \n- There is no index, i, in the range [1, 1] that satisfies nums[i] % modulo == k. \n- Hence, cnt = 0 and cnt % modulo == k. \nIt can be shown that there are no other interesting subarrays. So, the answer is 2.\n \nConstraints:\n\n1 <= nums.length <= 105 \n1 <= nums[i] <= 109\n1 <= modulo <= 109\n0 <= k < modulo\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 2, 4],modulo = 2,k = 1) == 3\n assert candidate(nums = [8, 12, 16, 20, 24],modulo = 4,k = 0) == 2\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7],modulo = 7,k = 0) == 1\n assert candidate(nums = [3, 1, 9, 6],modulo = 3,k = 0) == 2\n assert candidate(nums = [5, 5, 5, 5],modulo = 5,k = 0) == 0\n assert candidate(nums = [1, 3, 5, 7, 9],modulo = 2,k = 1) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7],modulo = 7,k = 3) == 0\n assert candidate(nums = [11, 22, 33, 44, 55],modulo = 11,k = 0) == 0\n assert candidate(nums = [7, 7, 7, 7, 7],modulo = 7,k = 0) == 0\n assert candidate(nums = [2, 4, 6, 8, 10],modulo = 2,k = 0) == 6\n assert candidate(nums = [1, 1, 1, 1, 1],modulo = 2,k = 1) == 9\n assert candidate(nums = [7, 14, 21, 28, 35],modulo = 7,k = 0) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],modulo = 5,k = 0) == 1\n assert candidate(nums = [5, 5, 5, 5, 5],modulo = 5,k = 0) == 1\n assert candidate(nums = [13, 19, 3, 5, 17],modulo = 5,k = 2) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],modulo = 10,k = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],modulo = 2,k = 1) == 9\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195],modulo = 13,k = 0) == 3\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],modulo = 8,k = 4) == 0\n assert candidate(nums = [21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164, 175, 186],modulo = 7,k = 3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],modulo = 5,k = 2) == 30\n assert candidate(nums = [3, 8, 15, 12, 6, 18, 21],modulo = 3,k = 0) == 7\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39],modulo = 3,k = 0) == 26\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400],modulo = 9,k = 1) == 53\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],modulo = 3,k = 0) == 35\n assert candidate(nums = [13, 19, 23, 29, 31, 37, 41, 43, 47, 53],modulo = 11,k = 1) == 24\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],modulo = 2,k = 1) == 30\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],modulo = 3,k = 1) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],modulo = 11,k = 2) == 0\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],modulo = 13,k = 0) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],modulo = 9,k = 0) == 2\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],modulo = 11,k = 0) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],modulo = 10,k = 5) == 12\n assert candidate(nums = [13, 19, 23, 29, 31, 37, 41, 43, 47, 53],modulo = 7,k = 3) == 0\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420],modulo = 42,k = 0) == 0\n assert candidate(nums = [99, 198, 297, 396, 495, 594, 693, 792, 891, 990],modulo = 99,k = 33) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],modulo = 3,k = 0) == 63\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],modulo = 11,k = 5) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6],modulo = 6,k = 4) == 0\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30],modulo = 7,k = 2) == 3\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266, 285],modulo = 19,k = 0) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],modulo = 2,k = 1) == 30\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],modulo = 11,k = 3) == 0\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],modulo = 4,k = 3) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],modulo = 4,k = 3) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],modulo = 3,k = 0) == 15\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],modulo = 5,k = 0) == 7\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888],modulo = 9,k = 0) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],modulo = 4,k = 2) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],modulo = 4,k = 2) == 0\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],modulo = 8,k = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],modulo = 3,k = 1) == 25\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],modulo = 5,k = 4) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],modulo = 3,k = 1) == 25\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],modulo = 21,k = 10) == 0\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44],modulo = 3,k = 2) == 40\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555],modulo = 9,k = 5) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143],modulo = 11,k = 0) == 3\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1012],modulo = 13,k = 4) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],modulo = 3,k = 2) == 70\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80],modulo = 4,k = 0) == 45\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],modulo = 10,k = 0) == 1\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],modulo = 101,k = 0) == 0\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],modulo = 15,k = 5) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],modulo = 7,k = 3) == 0\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],modulo = 21,k = 10) == 0\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],modulo = 12,k = 3) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],modulo = 2,k = 1) == 64\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],modulo = 5,k = 0) == 7\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],modulo = 101,k = 50) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121],modulo = 11,k = 3) == 0\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],modulo = 1000000007,k = 1) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],modulo = 250,k = 200) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],modulo = 2,k = 1) == 30\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],modulo = 5,k = 2) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],modulo = 3,k = 1) == 24\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],modulo = 9,k = 2) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],modulo = 4,k = 2) == 12\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],modulo = 11,k = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],modulo = 5,k = 2) == 0\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255],modulo = 17,k = 0) == 0\n assert candidate(nums = [11, 13, 15, 17, 19, 21, 23, 25, 27, 29],modulo = 7,k = 3) == 0\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],modulo = 13,k = 2) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],modulo = 9,k = 1) == 18\n assert candidate(nums = [12, 23, 34, 45, 56, 67, 78, 89, 910, 1011],modulo = 13,k = 2) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],modulo = 10,k = 3) == 4\n assert candidate(nums = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],modulo = 5,k = 3) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],modulo = 10,k = 0) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],modulo = 13,k = 2) == 0\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169],modulo = 13,k = 2) == 0\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021],modulo = 7,k = 4) == 4\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],modulo = 101,k = 50) == 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],modulo = 7,k = 3) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],modulo = 3,k = 2) == 15\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],modulo = 11,k = 0) == 0\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1010],modulo = 11,k = 10) == 0\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420],modulo = 42,k = 21) == 0\n assert candidate(nums = [14, 28, 42, 56, 70, 84, 98, 112, 126, 140],modulo = 14,k = 7) == 0\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],modulo = 12,k = 6) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],modulo = 10,k = 5) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],modulo = 15,k = 5) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115],modulo = 5,k = 0) == 11\n assert candidate(nums = [2, 5, 10, 13, 18, 21, 26, 31, 34, 39],modulo = 7,k = 0) == 25\n assert candidate(nums = [100, 200, 300, 400, 500],modulo = 5,k = 1) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],modulo = 100,k = 50) == 0\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],modulo = 4,k = 0) == 10\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],modulo = 7,k = 0) == 6\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60],modulo = 5,k = 0) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],modulo = 10,k = 5) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],modulo = 11,k = 1) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "modulo", "k"], "leetcode_dataset_entry_point": "Solution().countInterestingSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countInterestingSubarrays(List nums, int modulo, int k) {", "container": "Solution", "callable": "countInterestingSubarrays", "parameters": [{"name": "nums", "type": "List"}, {"name": "modulo", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2846, "task_id": "minimum-edge-weight-equilibrium-queries-in-a-tree", "difficulty": "Hard", "problem_description": "There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ui, vi, wi] indicates that there is an edge between nodes ui and vi with weight wi in the tree.\nYou are also given a 2D integer array queries of length m, where queries[i] = [ai, bi]. For each query, find the minimum number of operations required to make the weight of every edge on the path from ai to bi equal. In one operation, you can choose any edge of the tree and change its weight to any value.\nNote that:\n\nQueries are independent of each other, meaning that the tree returns to its initial state on each new query.\nThe path from ai to bi is a sequence of distinct nodes starting with node ai and ending with node bi such that every two adjacent nodes in the sequence share an edge in the tree.\n\nReturn an array answer of length m where answer[i] is the answer to the ith query.\n \nExample 1:\n\n\nInput: n = 7, edges = [[0,1,1],[1,2,1],[2,3,1],[3,4,2],[4,5,2],[5,6,2]], queries = [[0,3],[3,6],[2,6],[0,6]]\nOutput: [0,0,1,3]\nExplanation: In the first query, all the edges in the path from 0 to 3 have a weight of 1. Hence, the answer is 0.\nIn the second query, all the edges in the path from 3 to 6 have a weight of 2. Hence, the answer is 0.\nIn the third query, we change the weight of edge [2,3] to 2. After this operation, all the edges in the path from 2 to 6 have a weight of 2. Hence, the answer is 1.\nIn the fourth query, we change the weights of edges [0,1], [1,2] and [2,3] to 2. After these operations, all the edges in the path from 0 to 6 have a weight of 2. Hence, the answer is 3.\nFor each queries[i], it can be shown that answer[i] is the minimum number of operations needed to equalize all the edge weights in the path from ai to bi.\n\nExample 2:\n\n\nInput: n = 8, edges = [[1,2,6],[1,3,4],[2,4,6],[2,5,3],[3,6,6],[3,0,8],[7,0,2]], queries = [[4,6],[0,4],[6,5],[7,4]]\nOutput: [1,2,2,3]\nExplanation: In the first query, we change the weight of edge [1,3] to 6. After this operation, all the edges in the path from 4 to 6 have a weight of 6. Hence, the answer is 1.\nIn the second query, we change the weight of edges [0,3] and [3,1] to 6. After these operations, all the edges in the path from 0 to 4 have a weight of 6. Hence, the answer is 2.\nIn the third query, we change the weight of edges [1,3] and [5,2] to 6. After these operations, all the edges in the path from 6 to 5 have a weight of 6. Hence, the answer is 2.\nIn the fourth query, we change the weights of edges [0,7], [0,3] and [1,3] to 6. After these operations, all the edges in the path from 7 to 4 have a weight of 6. Hence, the answer is 3.\nFor each queries[i], it can be shown that answer[i] is the minimum number of operations needed to equalize all the edge weights in the path from ai to bi.\n\n \nConstraints:\n\n1 <= n <= 104\nedges.length == n - 1\nedges[i].length == 3\n0 <= ui, vi < n\n1 <= wi <= 26\nThe input is generated such that edges represents a valid tree.\n1 <= queries.length == m <= 2 * 104\nqueries[i].length == 2\n0 <= ai, bi < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 2], [4, 5, 2], [5, 6, 2]],queries = [[0, 3], [3, 6], [2, 6], [0, 6]]) == [0, 0, 1, 3]\n assert candidate(n = 8,edges = [[1, 2, 6], [1, 3, 4], [2, 4, 6], [2, 5, 3], [3, 6, 6], [3, 0, 8], [7, 0, 2]],queries = [[4, 6], [0, 4], [6, 5], [7, 4]]) == [1, 2, 2, 3]\n assert candidate(n = 20,edges = [[0, 1, 5], [1, 2, 4], [2, 3, 6], [3, 4, 5], [4, 5, 4], [5, 6, 6], [6, 7, 5], [7, 8, 4], [8, 9, 6], [0, 10, 3], [10, 11, 2], [11, 12, 3], [12, 13, 4], [13, 14, 3], [14, 15, 2], [15, 16, 3], [16, 17, 4], [17, 18, 3], [18, 19, 2]],queries = [[0, 4], [7, 14], [2, 13], [8, 15], [1, 16], [9, 18]]) == [2, 9, 4, 10, 4, 13]\n assert candidate(n = 30,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 3], [7, 8, 3], [8, 9, 3], [9, 10, 4], [10, 11, 4], [11, 12, 4], [12, 13, 5], [13, 14, 5], [14, 15, 5], [15, 16, 6], [16, 17, 6], [17, 18, 6], [18, 19, 7], [19, 20, 7], [20, 21, 7], [21, 22, 8], [22, 23, 8], [23, 24, 8], [24, 25, 9], [25, 26, 9], [26, 27, 9], [27, 28, 10], [28, 29, 10]],queries = [[0, 29], [1, 28], [2, 27], [3, 26], [4, 25], [5, 24], [6, 23], [7, 22], [8, 21], [9, 20], [10, 19], [11, 18], [12, 17], [13, 16], [14, 15]]) == [26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 0]\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]],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 8]]) == [13, 11, 9, 7, 5, 3, 1, 0]\n assert candidate(n = 15,edges = [[0, 1, 5], [0, 2, 3], [0, 3, 2], [1, 4, 1], [1, 5, 1], [2, 6, 4], [2, 7, 4], [3, 8, 3], [3, 9, 6], [4, 10, 2], [5, 11, 5], [6, 12, 3], [7, 13, 4], [8, 14, 6]],queries = [[10, 12], [5, 14], [1, 13], [0, 11], [8, 11]]) == [4, 4, 2, 1, 3]\n assert candidate(n = 9,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]],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4]]) == [7, 5, 3, 1, 0]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 6, 3], [6, 7, 4], [7, 8, 4], [8, 9, 5], [9, 10, 5], [10, 11, 6]],queries = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 4], [8, 3], [9, 2], [10, 1]]) == [3, 3, 3, 3, 3, 3, 3, 1, 3, 5, 7]\n assert candidate(n = 25,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]],queries = [[0, 24], [1, 23], [2, 22], [3, 21]]) == [23, 21, 19, 17]\n assert candidate(n = 20,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], [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]],queries = [[0, 19], [0, 10], [5, 15], [10, 15], [0, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 3], [1, 4, 7], [2, 5, 10], [2, 6, 5], [3, 7, 2], [4, 8, 8], [5, 9, 15]],queries = [[0, 7], [1, 8], [3, 6], [4, 9], [7, 9]]) == [2, 1, 2, 3, 4]\n assert candidate(n = 15,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 6, 3], [6, 7, 4], [7, 8, 4], [8, 9, 5], [9, 10, 5], [10, 11, 6], [11, 12, 6], [12, 13, 7], [13, 14, 7]],queries = [[0, 7], [3, 11], [5, 13], [2, 14]]) == [5, 6, 6, 10]\n assert candidate(n = 12,edges = [[0, 1, 5], [0, 2, 3], [0, 3, 4], [1, 4, 5], [1, 5, 3], [2, 6, 4], [2, 7, 5], [3, 8, 3], [3, 9, 4], [4, 10, 2], [5, 11, 2]],queries = [[0, 10], [4, 8], [1, 6], [2, 9], [3, 11], [5, 7]]) == [1, 2, 2, 1, 3, 2]\n assert candidate(n = 18,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 10], [3, 4, 20], [4, 5, 10], [5, 6, 20], [6, 7, 10], [7, 8, 20], [8, 9, 10], [9, 10, 20], [10, 11, 10], [11, 12, 20], [12, 13, 10], [13, 14, 20], [14, 15, 10], [15, 16, 20], [16, 17, 10]],queries = [[0, 17], [1, 16], [2, 15], [3, 14], [4, 13], [5, 12], [6, 11], [7, 10], [8, 9]]) == [8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(n = 50,edges = [[0, 1, 20], [1, 2, 19], [2, 3, 18], [3, 4, 17], [4, 5, 16], [5, 6, 15], [6, 7, 14], [7, 8, 13], [8, 9, 12], [9, 10, 11], [10, 11, 10], [11, 12, 9], [12, 13, 8], [13, 14, 7], [14, 15, 6], [15, 16, 5], [16, 17, 4], [17, 18, 3], [18, 19, 2], [19, 20, 1], [20, 21, 20], [21, 22, 19], [22, 23, 18], [23, 24, 17], [24, 25, 16], [25, 26, 15], [26, 27, 14], [27, 28, 13], [28, 29, 12], [29, 30, 11], [30, 31, 10], [31, 32, 9], [32, 33, 8], [33, 34, 7], [34, 35, 6], [35, 36, 5], [36, 37, 4], [37, 38, 3], [38, 39, 2], [39, 40, 1], [40, 41, 20], [41, 42, 19], [42, 43, 18], [43, 44, 17], [44, 45, 16], [45, 46, 15], [46, 47, 14], [47, 48, 13], [48, 49, 12]],queries = [[0, 49], [0, 25], [10, 35], [25, 49], [10, 25]]) == [46, 23, 23, 22, 14]\n assert candidate(n = 15,edges = [[0, 1, 3], [1, 2, 2], [2, 3, 3], [0, 4, 1], [4, 5, 1], [5, 6, 3], [6, 7, 2], [7, 8, 3], [0, 9, 2], [9, 10, 2], [10, 11, 3], [11, 12, 2], [12, 13, 1], [13, 14, 1]],queries = [[0, 3], [5, 7], [2, 12], [8, 14], [1, 13], [6, 10]]) == [1, 1, 2, 7, 3, 3]\n assert candidate(n = 20,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]],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 20,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 6, 3], [6, 7, 4], [7, 8, 4], [8, 9, 5], [9, 10, 5], [10, 11, 6], [11, 12, 6], [12, 13, 7], [13, 14, 7], [14, 15, 8], [15, 16, 8], [16, 17, 9], [17, 18, 9], [18, 19, 10]],queries = [[0, 19], [1, 18], [2, 17], [3, 16]]) == [17, 15, 13, 11]\n assert candidate(n = 15,edges = [[0, 1, 2], [1, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 2], [3, 6, 3], [4, 7, 3], [4, 8, 4], [5, 9, 5], [5, 10, 2], [6, 11, 2], [6, 12, 3], [7, 13, 3], [8, 14, 4]],queries = [[0, 14], [1, 13], [2, 12], [4, 11]]) == [2, 2, 1, 3]\n assert candidate(n = 10,edges = [[0, 1, 3], [0, 2, 5], [1, 3, 2], [1, 4, 2], [2, 5, 4], [2, 6, 4], [3, 7, 6], [4, 8, 1], [5, 9, 3]],queries = [[0, 7], [1, 9], [3, 5], [2, 8], [6, 9]]) == [2, 2, 3, 3, 1]\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], [4, 8, 9], [5, 9, 10], [6, 10, 11], [7, 11, 12], [8, 12, 13], [9, 13, 14], [10, 14, 15]],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [3, 4, 4, 1, 4, 0, 4, 0]\n assert candidate(n = 25,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]],queries = [[0, 24], [1, 23], [2, 22], [3, 21], [4, 20], [5, 19], [6, 18], [7, 17], [8, 16], [9, 15]]) == [23, 21, 19, 17, 15, 13, 11, 9, 7, 5]\n assert candidate(n = 100,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 3], [7, 8, 3], [8, 9, 3], [9, 10, 4], [10, 11, 4], [11, 12, 4], [12, 13, 5], [13, 14, 5], [14, 15, 5], [15, 16, 6], [16, 17, 6], [17, 18, 6], [18, 19, 7], [19, 20, 7], [20, 21, 7], [21, 22, 8], [22, 23, 8], [23, 24, 8], [24, 25, 9], [25, 26, 9], [26, 27, 9], [27, 28, 10], [28, 29, 10], [29, 30, 10], [30, 31, 11], [31, 32, 11], [32, 33, 11], [33, 34, 12], [34, 35, 12], [35, 36, 12], [36, 37, 13], [37, 38, 13], [38, 39, 13], [39, 40, 14], [40, 41, 14], [41, 42, 14], [42, 43, 15], [43, 44, 15], [44, 45, 15], [45, 46, 16], [46, 47, 16], [47, 48, 16], [48, 49, 17], [49, 50, 17], [50, 51, 17], [51, 52, 18], [52, 53, 18], [53, 54, 18], [54, 55, 19], [55, 56, 19], [56, 57, 19], [57, 58, 20], [58, 59, 20], [59, 60, 20], [60, 61, 21], [61, 62, 21], [62, 63, 21], [63, 64, 22], [64, 65, 22], [65, 66, 22], [66, 67, 23], [67, 68, 23], [68, 69, 23], [69, 70, 24], [70, 71, 24], [71, 72, 24], [72, 73, 25], [73, 74, 25], [74, 75, 25], [75, 76, 26], [76, 77, 26], [77, 78, 26], [78, 79, 1], [79, 80, 1], [80, 81, 2], [81, 82, 2], [82, 83, 3], [83, 84, 3], [84, 85, 4], [85, 86, 4], [86, 87, 5], [87, 88, 5], [88, 89, 6], [89, 90, 6], [90, 91, 7], [91, 92, 7], [92, 93, 8], [93, 94, 8], [94, 95, 9], [95, 96, 9], [96, 97, 10], [97, 98, 10], [98, 99, 10]],queries = [[0, 99], [1, 98], [2, 97], [3, 96], [4, 95], [5, 94], [6, 93], [7, 92], [8, 91], [9, 90], [10, 89], [11, 88], [12, 87], [13, 86], [14, 85], [15, 84], [16, 83], [17, 82], [18, 81], [19, 80], [20, 79], [21, 78], [22, 77], [23, 76], [24, 75], [25, 74], [26, 73], [27, 72], [28, 71], [29, 70], [30, 69], [31, 68], [32, 67], [33, 66], [34, 65], [35, 64], [36, 63], [37, 62], [38, 61], [39, 60], [40, 59], [41, 58], [42, 57], [43, 56], [44, 55], [45, 54], [46, 53], [47, 52], [48, 51], [49, 50]]) == [93, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 71, 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]\n assert candidate(n = 10,edges = [[0, 1, 3], [0, 2, 3], [1, 3, 5], [1, 4, 5], [2, 5, 7], [2, 6, 7], [3, 7, 9], [3, 8, 9], [4, 9, 11]],queries = [[0, 9], [1, 8], [2, 7], [4, 6]]) == [2, 1, 2, 2]\n assert candidate(n = 40,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 3], [7, 8, 3], [8, 9, 3], [9, 10, 4], [10, 11, 4], [11, 12, 4], [12, 13, 5], [13, 14, 5], [14, 15, 5], [15, 16, 6], [16, 17, 6], [17, 18, 6], [18, 19, 7], [19, 20, 7], [20, 21, 7], [21, 22, 8], [22, 23, 8], [23, 24, 8], [24, 25, 9], [25, 26, 9], [26, 27, 9], [27, 28, 10], [28, 29, 10], [29, 30, 10], [30, 31, 11], [31, 32, 11], [32, 33, 11], [33, 34, 12], [34, 35, 12], [35, 36, 12], [36, 37, 13], [37, 38, 13], [38, 39, 13]],queries = [[0, 39], [1, 38], [2, 37], [3, 36], [4, 35], [5, 34], [6, 33], [7, 32], [8, 31], [9, 30], [10, 29], [11, 28], [12, 27], [13, 26], [14, 25], [15, 24], [16, 23], [17, 22], [18, 21], [19, 20]]) == [36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0]\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], [3, 8, 8], [4, 9, 9], [5, 10, 10], [6, 11, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [7, 11], [8, 10]]) == [2, 3, 3, 0, 2, 1, 5, 5]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "queries"], "leetcode_dataset_entry_point": "Solution().minOperationsQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] minOperationsQueries(int n, int[][] edges, int[][] queries) {", "container": "Solution", "callable": "minOperationsQueries", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}, {"name": "queries", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2848, "task_id": "points-that-intersect-with-cars", "difficulty": "Easy", "problem_description": "You are given a 0-indexed 2D integer array nums representing the coordinates of the cars parking on a number line. For any index i, nums[i] = [starti, endi] where starti is the starting point of the ith car and endi is the ending point of the ith car.\nReturn the number of integer points on the line that are covered with any part of a car.\n \nExample 1:\n\nInput: nums = [[3,6],[1,5],[4,7]]\nOutput: 7\nExplanation: All the points from 1 to 7 intersect at least one car, therefore the answer would be 7.\n\nExample 2:\n\nInput: nums = [[1,3],[5,8]]\nOutput: 7\nExplanation: Points intersecting at least one car are 1, 2, 3, 5, 6, 7, 8. There are a total of 7 points, therefore the answer would be 7.\n\n \nConstraints:\n\n1 <= nums.length <= 100\nnums[i].length == 2\n1 <= starti <= endi <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [[1, 100]]) == 100\n assert candidate(nums = [[1, 3], [5, 8]]) == 7\n assert candidate(nums = [[1, 1], [2, 2], [3, 3]]) == 3\n assert candidate(nums = [[10, 15], [20, 25]]) == 12\n assert candidate(nums = [[1, 100], [50, 60], [60, 90]]) == 100\n assert candidate(nums = [[5, 10], [10, 15]]) == 11\n assert candidate(nums = [[10, 15], [12, 20], [8, 14]]) == 13\n assert candidate(nums = [[1, 100], [50, 60], [60, 80]]) == 100\n assert candidate(nums = [[10, 15], [12, 20], [18, 25]]) == 16\n assert candidate(nums = [[3, 6], [1, 5], [4, 7]]) == 7\n assert candidate(nums = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [19, 21], [22, 24], [25, 27], [28, 30]]) == 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]]) == 20\n assert candidate(nums = [[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]]) == 91\n assert candidate(nums = [[1, 20], [5, 25], [10, 30], [15, 35], [20, 40]]) == 40\n assert candidate(nums = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20]]) == 15\n assert candidate(nums = [[1, 5], [2, 4], [3, 3], [4, 4], [5, 5]]) == 5\n assert candidate(nums = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30], [31, 35], [36, 40]]) == 40\n assert candidate(nums = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90]]) == 54\n assert candidate(nums = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 9\n assert candidate(nums = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(nums = [[1, 50], [51, 100], [1, 100]]) == 100\n assert candidate(nums = [[5, 10], [8, 12], [15, 20], [18, 25], [22, 30]]) == 24\n assert candidate(nums = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50]]) == 30\n assert candidate(nums = [[3, 6], [1, 5], [4, 7], [8, 10], [11, 13]]) == 13\n assert candidate(nums = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]]) == 21\n assert candidate(nums = [[30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [10, 20], [20, 30]]) == 91\n assert candidate(nums = [[1, 50], [51, 100], [25, 75], [76, 99], [1, 100]]) == 100\n assert candidate(nums = [[2, 10], [5, 15], [8, 20], [18, 30]]) == 29\n assert candidate(nums = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50]]) == 41\n assert candidate(nums = [[30, 40], [35, 45], [40, 50], [45, 55]]) == 26\n assert candidate(nums = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == 100\n assert candidate(nums = [[10, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]]) == 91\n assert candidate(nums = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 10\n assert candidate(nums = [[1, 10], [5, 20], [15, 30], [25, 40]]) == 40\n assert candidate(nums = [[5, 8], [8, 11], [11, 14], [14, 17], [17, 20], [20, 23], [23, 26], [26, 29], [29, 32]]) == 28\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], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70]]) == 61\n assert candidate(nums = [[5, 10], [10, 15], [15, 20]]) == 16\n assert candidate(nums = [[1, 50], [20, 60], [55, 80], [70, 100]]) == 100\n assert candidate(nums = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17]]) == 17\n assert candidate(nums = [[1, 10], [11, 20], [21, 30]]) == 30\n assert candidate(nums = [[10, 30], [20, 40], [30, 50], [40, 60], [50, 70], [60, 80], [70, 90], [80, 100]]) == 91\n assert candidate(nums = [[5, 10], [15, 20], [25, 30], [5, 15], [10, 25]]) == 26\n assert candidate(nums = [[1, 5], [5, 9], [9, 13], [13, 17], [17, 21], [21, 25]]) == 25\n assert candidate(nums = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]]) == 12\n assert candidate(nums = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15]]) == 15\n assert candidate(nums = [[1, 50], [51, 100], [1, 100], [25, 75], [50, 60]]) == 100\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\n assert candidate(nums = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]]) == 60\n assert candidate(nums = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 10\n assert candidate(nums = [[1, 100], [2, 99], [3, 98]]) == 100\n assert candidate(nums = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 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]]) == 10\n assert candidate(nums = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 10\n assert candidate(nums = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40]]) == 31\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]]) == 22\n assert candidate(nums = [[3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19]]) == 9\n assert candidate(nums = [[2, 4], [4, 6], [6, 8], [8, 10]]) == 9\n assert candidate(nums = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == 51\n assert candidate(nums = [[1, 50], [5, 45], [10, 40], [15, 35], [20, 30]]) == 50\n assert candidate(nums = [[1, 100], [2, 99], [3, 98], [4, 97]]) == 100\n assert candidate(nums = [[3, 7], [7, 11], [11, 15], [15, 19], [19, 23], [23, 27], [27, 31], [31, 35]]) == 33\n assert candidate(nums = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5\n assert candidate(nums = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [19, 21]]) == 21\n assert candidate(nums = [[1, 100], [50, 100], [1, 50]]) == 100\n assert candidate(nums = [[1, 100], [1, 100], [1, 100], [1, 100], [1, 100], [1, 100], [1, 100], [1, 100], [1, 100], [1, 100]]) == 100\n assert candidate(nums = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22]]) == 17\n assert candidate(nums = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50]]) == 50\n assert candidate(nums = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 14\n assert candidate(nums = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11]]) == 11\n assert candidate(nums = [[5, 10], [12, 15], [16, 20], [22, 25]]) == 19\n assert candidate(nums = [[1, 10], [5, 15], [10, 20], [15, 25]]) == 25\n assert candidate(nums = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]]) == 100\n assert candidate(nums = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 10\n assert candidate(nums = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 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 = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50], [45, 55], [50, 60]]) == 51\n assert candidate(nums = [[3, 9], [6, 12], [10, 14], [13, 19]]) == 17\n assert candidate(nums = [[5, 15], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65], [65, 75], [75, 85], [85, 95], [95, 100]]) == 96\n assert candidate(nums = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35]]) == 31\n assert candidate(nums = [[1, 10], [2, 8], [3, 7], [4, 6], [5, 5]]) == 10\n assert candidate(nums = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]]) == 14\n assert candidate(nums = [[30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]]) == 61\n assert candidate(nums = [[2, 3], [5, 8], [10, 15], [20, 22], [25, 27], [30, 35], [38, 40], [45, 50]]) == 33\n assert candidate(nums = [[5, 10], [11, 15], [16, 20], [21, 25]]) == 21\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numberOfPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfPoints(List> nums) {", "container": "Solution", "callable": "numberOfPoints", "parameters": [{"name": "nums", "type": "List>"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2849, "task_id": "determine-if-a-cell-is-reachable-at-a-given-time", "difficulty": "Medium", "problem_description": "You are given four integers sx, sy, fx, fy, and a non-negative integer t.\nIn an infinite 2D grid, you start at the cell (sx, sy). Each second, you must move to any of its adjacent cells.\nReturn true if you can reach cell (fx, fy) after exactly t seconds, or false otherwise.\nA cell's adjacent cells are the 8 cells around it that share at least one corner with it. You can visit the same cell several times.\n \nExample 1:\n\n\nInput: sx = 2, sy = 4, fx = 7, fy = 7, t = 6\nOutput: true\nExplanation: Starting at cell (2, 4), we can reach cell (7, 7) in exactly 6 seconds by going through the cells depicted in the picture above. \n\nExample 2:\n\n\nInput: sx = 3, sy = 1, fx = 7, fy = 3, t = 3\nOutput: false\nExplanation: Starting at cell (3, 1), it takes at least 4 seconds to reach cell (7, 3) by going through the cells depicted in the picture above. Hence, we cannot reach cell (7, 3) at the third second.\n\n \nConstraints:\n\n1 <= sx, sy, fx, fy <= 109\n0 <= t <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sx = 1,sy = 1,fx = 2,fy = 2,t = 1) == True\n assert candidate(sx = 2,sy = 4,fx = 7,fy = 7,t = 6) == True\n assert candidate(sx = 1,sy = 1,fx = 10,fy = 10,t = 14) == True\n assert candidate(sx = 1000000000,sy = 1000000000,fx = 1000000000,fy = 1000000000,t = 0) == True\n assert candidate(sx = 1,sy = 1,fx = 2,fy = 1,t = 1) == True\n assert candidate(sx = 1,sy = 1,fx = 10,fy = 10,t = 15) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 2,t = 1000000000) == True\n assert candidate(sx = 3,sy = 1,fx = 7,fy = 3,t = 3) == False\n assert candidate(sx = 1,sy = 1,fx = 1000000000,fy = 1000000000,t = 1999999998) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 1,t = 1) == False\n assert candidate(sx = 5,sy = 5,fx = 5,fy = 5,t = 10) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 1,t = 0) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 2,t = 1) == True\n assert candidate(sx = 1,sy = 1,fx = 1000000000,fy = 1000000000,t = 2000000000) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 1,t = 3) == True\n assert candidate(sx = 10,sy = 10,fx = 5,fy = 5,t = 10) == True\n assert candidate(sx = 1,sy = 1,fx = 3,fy = 3,t = 2) == True\n assert candidate(sx = 1,sy = 1,fx = 2,fy = 2,t = 2) == True\n assert candidate(sx = 10,sy = 10,fx = 15,fy = 15,t = 10) == True\n assert candidate(sx = 10,sy = 10,fx = 20,fy = 20,t = 21) == True\n assert candidate(sx = 0,sy = 0,fx = 500000000,fy = 500000000,t = 999999999) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 2,t = 0) == False\n assert candidate(sx = 5,sy = 5,fx = 5,fy = 5,t = 3) == True\n assert candidate(sx = 10,sy = 10,fx = 10,fy = 10,t = 10) == True\n assert candidate(sx = 5,sy = 5,fx = 5,fy = 6,t = 2) == True\n assert candidate(sx = 1000000000,sy = 1,fx = 1000000000,fy = 1,t = 0) == True\n assert candidate(sx = 1,sy = 1,fx = 4,fy = 4,t = 6) == True\n assert candidate(sx = 10,sy = 10,fx = 15,fy = 15,t = 5) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 1,t = 1000000000) == True\n assert candidate(sx = 1000,sy = 1000,fx = 999,fy = 999,t = 2) == True\n assert candidate(sx = 5,sy = 5,fx = 1,fy = 1,t = 4) == True\n assert candidate(sx = 500000000,sy = 500000000,fx = 1,fy = 1,t = 999999998) == True\n assert candidate(sx = 999999999,sy = 999999999,fx = 1,fy = 1,t = 1999999998) == True\n assert candidate(sx = 10,sy = 10,fx = 15,fy = 15,t = 11) == True\n assert candidate(sx = 10,sy = 10,fx = 5,fy = 15,t = 10) == True\n assert candidate(sx = 1,sy = 1,fx = 10,fy = 10,t = 19) == True\n assert candidate(sx = 5,sy = 5,fx = 5,fy = 5,t = 1) == False\n assert candidate(sx = 0,sy = 0,fx = 0,fy = 0,t = 0) == True\n assert candidate(sx = 1,sy = 1,fx = 2,fy = 2,t = 4) == True\n assert candidate(sx = 10,sy = 10,fx = 10,fy = 10,t = 0) == True\n assert candidate(sx = 500,sy = 500,fx = 500,fy = 500,t = 0) == True\n assert candidate(sx = 1,sy = 1,fx = 5,fy = 5,t = 7) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 10,t = 10) == True\n assert candidate(sx = 10,sy = 10,fx = 9,fy = 9,t = 2) == True\n assert candidate(sx = 10,sy = 10,fx = 15,fy = 15,t = 7) == True\n assert candidate(sx = 1,sy = 1,fx = 3,fy = 3,t = 4) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 10,t = 9) == True\n assert candidate(sx = 5,sy = 5,fx = 10,fy = 10,t = 15) == True\n assert candidate(sx = 500000000,sy = 500000000,fx = 500000000,fy = 500000000,t = 1000000000) == True\n assert candidate(sx = 1,sy = 1,fx = 5,fy = 5,t = 8) == True\n assert candidate(sx = 10,sy = 10,fx = 15,fy = 15,t = 9) == True\n assert candidate(sx = 100,sy = 100,fx = 105,fy = 105,t = 10) == True\n assert candidate(sx = 1,sy = 1,fx = 2,fy = 3,t = 2) == True\n assert candidate(sx = 1,sy = 1,fx = 10,fy = 1,t = 9) == True\n assert candidate(sx = 1,sy = 1,fx = 2,fy = 2,t = 3) == True\n assert candidate(sx = 1000,sy = 1000,fx = 998,fy = 998,t = 4) == True\n assert candidate(sx = 10,sy = 10,fx = 15,fy = 15,t = 6) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 1,t = 2) == True\n assert candidate(sx = 1,sy = 1,fx = 3,fy = 3,t = 3) == True\n assert candidate(sx = 500000000,sy = 500000000,fx = 600000000,fy = 600000000,t = 100000000) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 3,t = 2) == True\n assert candidate(sx = 10,sy = 10,fx = 15,fy = 15,t = 8) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 2,t = 2) == True\n assert candidate(sx = 5,sy = 5,fx = 15,fy = 15,t = 18) == True\n assert candidate(sx = 0,sy = 0,fx = 1,fy = 1,t = 1) == True\n assert candidate(sx = 1,sy = 1,fx = 3,fy = 3,t = 6) == True\n assert candidate(sx = 1,sy = 1,fx = 3,fy = 1,t = 3) == True\n assert candidate(sx = 1,sy = 1,fx = 1000000000,fy = 1000000000,t = 1000000000) == True\n assert candidate(sx = 1,sy = 1,fx = 1,fy = 3,t = 3) == True\n assert candidate(sx = 0,sy = 0,fx = 3,fy = 4,t = 5) == True\n assert candidate(sx = 999999999,sy = 999999999,fx = 1000000000,fy = 1000000000,t = 1) == True\n assert candidate(sx = 1,sy = 1,fx = 10,fy = 10,t = 18) == True\n assert candidate(sx = 10,sy = 10,fx = 10,fy = 15,t = 7) == True\n assert candidate(sx = 500,sy = 500,fx = 500,fy = 500,t = 5) == True\n assert candidate(sx = 100,sy = 100,fx = 105,fy = 95,t = 10) == True\n assert candidate(sx = 1000000000,sy = 1000000000,fx = 1000000000,fy = 1000000000,t = 1000000000) == True\n assert candidate(sx = 1000000000,sy = 1000000000,fx = 1,fy = 1,t = 1999999998) == True\n assert candidate(sx = 1,sy = 1,fx = 1000000000,fy = 1000000000,t = 1999999999) == True\n assert candidate(sx = 1,sy = 1,fx = 2,fy = 3,t = 3) == True\n assert candidate(sx = 10,sy = 10,fx = 5,fy = 5,t = 9) == True\n assert candidate(sx = 3,sy = 3,fx = 1,fy = 1,t = 4) == True\n assert candidate(sx = 5,sy = 5,fx = 5,fy = 5,t = 0) == True\n assert candidate(sx = 1,sy = 1,fx = 10,fy = 1,t = 10) == True\n assert candidate(sx = 1,sy = 1,fx = 3,fy = 3,t = 5) == True\n assert candidate(sx = 1000000000,sy = 1,fx = 1,fy = 1000000000,t = 1999999998) == True\n assert candidate(sx = 1,sy = 1,fx = 10,fy = 10,t = 17) == True\n assert candidate(sx = 1,sy = 1,fx = 4,fy = 4,t = 5) == True\n assert candidate(sx = 1,sy = 1,fx = 100,fy = 100,t = 198) == True\n assert candidate(sx = 1,sy = 2,fx = 3,fy = 4,t = 4) == True\n"}, "metadata": {"canonical_parameter_names": ["sx", "sy", "fx", "fy", "t"], "leetcode_dataset_entry_point": "Solution().isReachableAtTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean isReachableAtTime(int sx, int sy, int fx, int fy, int t) {", "container": "Solution", "callable": "isReachableAtTime", "parameters": [{"name": "sx", "type": "int"}, {"name": "sy", "type": "int"}, {"name": "fx", "type": "int"}, {"name": "fy", "type": "int"}, {"name": "t", "type": "int"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2850, "task_id": "minimum-moves-to-spread-stones-over-grid", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D integer matrix grid of size 3 * 3, representing the number of stones in each cell. The grid contains exactly 9 stones, and there can be multiple stones in a single cell.\nIn one move, you can move a single stone from its current cell to any other cell if the two cells share a side.\nReturn the minimum number of moves required to place one stone in each cell.\n \nExample 1:\n\n\nInput: grid = [[1,1,0],[1,1,1],[1,2,1]]\nOutput: 3\nExplanation: One possible sequence of moves to place one stone in each cell is: \n1- Move one stone from cell (2,1) to cell (2,2).\n2- Move one stone from cell (2,2) to cell (1,2).\n3- Move one stone from cell (1,2) to cell (0,2).\nIn total, it takes 3 moves to place one stone in each cell of the grid.\nIt can be shown that 3 is the minimum number of moves required to place one stone in each cell.\n\nExample 2:\n\n\nInput: grid = [[1,3,0],[1,0,0],[1,0,3]]\nOutput: 4\nExplanation: One possible sequence of moves to place one stone in each cell is:\n1- Move one stone from cell (0,1) to cell (0,2).\n2- Move one stone from cell (0,1) to cell (1,1).\n3- Move one stone from cell (2,2) to cell (1,2).\n4- Move one stone from cell (2,2) to cell (2,1).\nIn total, it takes 4 moves to place one stone in each cell of the grid.\nIt can be shown that 4 is the minimum number of moves required to place one stone in each cell.\n\n \nConstraints:\n\ngrid.length == grid[i].length == 3\n0 <= grid[i][j] <= 9\nSum of grid is equal to 9.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[2, 2, 1], [1, 1, 1], [1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 9], [0, 0, 0], [0, 0, 0]]) == 18\n assert candidate(grid = [[2, 2, 1], [1, 1, 1], [1, 1, 2]]) == 0\n assert candidate(grid = [[1, 3, 0], [1, 0, 0], [1, 0, 3]]) == 4\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 0\n assert candidate(grid = [[1, 2, 1], [2, 1, 2], [1, 2, 1]]) == 0\n assert candidate(grid = [[1, 1, 1], [1, 2, 2], [2, 2, 1]]) == 0\n assert candidate(grid = [[1, 2, 2], [2, 1, 1], [2, 1, 1]]) == 0\n assert candidate(grid = [[3, 0, 0], [0, 3, 0], [0, 0, 3]]) == 8\n assert candidate(grid = [[1, 1, 0], [1, 1, 1], [1, 2, 1]]) == 3\n assert candidate(grid = [[0, 0, 0], [0, 9, 0], [0, 0, 0]]) == 12\n assert candidate(grid = [[1, 1, 1], [1, 2, 1], [1, 1, 1]]) == 0\n assert candidate(grid = [[3, 1, 1], [0, 0, 0], [1, 1, 3]]) == 4\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 9]]) == 18\n assert candidate(grid = [[1, 0, 0], [0, 0, 0], [0, 0, 8]]) == 14\n assert candidate(grid = [[2, 2, 0], [1, 0, 2], [0, 1, 1]]) == 4\n assert candidate(grid = [[0, 1, 0], [1, 0, 0], [0, 0, 7]]) == 12\n assert candidate(grid = [[0, 1, 2], [3, 0, 0], [0, 0, 3]]) == 6\n assert candidate(grid = [[0, 0, 0], [0, 0, 2], [0, 0, 7]]) == 16\n assert candidate(grid = [[0, 1, 2], [2, 0, 1], [1, 2, 0]]) == 4\n assert candidate(grid = [[2, 1, 0], [1, 1, 1], [0, 1, 2]]) == 4\n assert candidate(grid = [[2, 0, 1], [1, 0, 3], [0, 3, 0]]) == 4\n assert candidate(grid = [[4, 0, 1], [0, 0, 0], [1, 0, 3]]) == 6\n assert candidate(grid = [[1, 0, 2], [2, 0, 0], [0, 1, 3]]) == 5\n assert candidate(grid = [[2, 1, 0], [1, 2, 1], [0, 1, 2]]) == 4\n assert candidate(grid = [[0, 2, 0], [3, 0, 0], [0, 1, 3]]) == 6\n assert candidate(grid = [[3, 0, 0], [0, 0, 3], [0, 3, 0]]) == 6\n assert candidate(grid = [[0, 0, 1], [1, 7, 0], [0, 0, 1]]) == 7\n assert candidate(grid = [[2, 2, 2], [1, 1, 1], [0, 0, 0]]) == 6\n assert candidate(grid = [[1, 1, 0], [0, 0, 0], [0, 0, 7]]) == 11\n assert candidate(grid = [[1, 2, 0], [0, 1, 2], [2, 0, 1]]) == 4\n assert candidate(grid = [[0, 2, 0], [1, 0, 3], [0, 4, 0]]) == 5\n assert candidate(grid = [[0, 0, 0], [1, 1, 1], [2, 2, 2]]) == 6\n assert candidate(grid = [[0, 0, 0], [0, 8, 1], [0, 0, 0]]) == 11\n assert candidate(grid = [[0, 1, 0], [0, 7, 0], [0, 1, 0]]) == 10\n assert candidate(grid = [[1, 2, 0], [2, 0, 1], [0, 3, 0]]) == 4\n assert candidate(grid = [[1, 2, 2], [2, 1, 1], [1, 1, 1]]) == 0\n assert candidate(grid = [[2, 2, 0], [1, 1, 0], [0, 0, 3]]) == 5\n assert candidate(grid = [[2, 2, 1], [1, 0, 1], [1, 1, 2]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minimumMoves", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumMoves(int[][] grid) {", "container": "Solution", "callable": "minimumMoves", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2851, "task_id": "string-transformation", "difficulty": "Hard", "problem_description": "You are given two strings s and t of equal length n. You can perform the following operation on the string s:\n\nRemove a suffix of s of length l where 0 < l < n and append it at the start of s.\n\tFor example, let s = 'abcd' then in one operation you can remove the suffix 'cd' and append it in front of s making s = 'cdab'.\n\nYou are also given an integer k. Return the number of ways in which s can be transformed into t in exactly k operations.\nSince the answer can be large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: s = \"abcd\", t = \"cdab\", k = 2\nOutput: 2\nExplanation: \nFirst way:\nIn first operation, choose suffix from index = 3, so resulting s = \"dabc\".\nIn second operation, choose suffix from index = 3, so resulting s = \"cdab\".\n\nSecond way:\nIn first operation, choose suffix from index = 1, so resulting s = \"bcda\".\nIn second operation, choose suffix from index = 1, so resulting s = \"cdab\".\n\nExample 2:\n\nInput: s = \"ababab\", t = \"ababab\", k = 1\nOutput: 2\nExplanation: \nFirst way:\nChoose suffix from index = 2, so resulting s = \"ababab\".\n\nSecond way:\nChoose suffix from index = 4, so resulting s = \"ababab\".\n\n \nConstraints:\n\n2 <= s.length <= 5 * 105\n1 <= k <= 1015\ns.length == t.length\ns and t consist of only lowercase English alphabets.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",t = \"cdab\",k = 2) == 2\n assert candidate(s = \"abcdef\",t = \"defabc\",k = 3) == 21\n assert candidate(s = \"xyzabc\",t = \"abcxyz\",k = 5) == 521\n assert candidate(s = \"abcde\",t = \"eabcd\",k = 10) == 209715\n assert candidate(s = \"xyzxyz\",t = \"zxyzxy\",k = 5) == 1042\n assert candidate(s = \"aaaaaa\",t = \"aaaaaa\",k = 1000000000000000) == 410143883\n assert candidate(s = \"abcabcabc\",t = \"cababcabc\",k = 4) == 0\n assert candidate(s = \"abcdefg\",t = \"efgabcd\",k = 3) == 31\n assert candidate(s = \"zzzz\",t = \"zzzz\",k = 1000000000000000) == 468606845\n assert candidate(s = \"ababab\",t = \"ababab\",k = 1) == 2\n assert candidate(s = \"xyzxyz\",t = \"xyzxyz\",k = 5) == 1041\n assert candidate(s = \"aaaaaa\",t = \"aaaaaa\",k = 5) == 3125\n assert candidate(s = \"aabbcc\",t = \"ccbaab\",k = 4) == 0\n assert candidate(s = \"longstringlongstringlongstringlongstring\",t = \"stringlongstringlongstringlongstrin\",k = 100000000000000000100) == 0\n assert candidate(s = \"abababababababababab\",t = \"babababababababababa\",k = 3) == 3430\n assert candidate(s = \"abcdefghijabcdefghij\",t = \"defghijabcdefghija\",k = 100000000000000) == 0\n assert candidate(s = \"abacabadabacaba\",t = \"dabacabaabacaba\",k = 8) == 98385937\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzabcdefghijklmnopqrstuvwxyzabcd\",k = 100000000000000000) == 0\n assert candidate(s = \"abcdabcdabcdabcd\",t = \"dabcdabcdabcdabc\",k = 10) == 162596648\n assert candidate(s = \"repeatedpatternrepeatedpattern\",t = \"atedpatternrepeatedpatternrepe\",k = 99999999999999) == 849771837\n assert candidate(s = \"abcabcabcabcabcabc\",t = \"cabcabcabcabcabcab\",k = 500000000000000) == 685999657\n assert candidate(s = \"mississippi\",t = \"ississippim\",k = 10000000000000) == 499109493\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",t = \"cabcabcabcabcabcabcabcab\",k = 123456789123456789123) == 60155055\n assert candidate(s = \"cryptography\",t = \"graphycrypto\",k = 500000000000000000) == 547734217\n assert candidate(s = \"aaaaabbbbb\",t = \"bbbbbbaaaa\",k = 15) == 0\n assert candidate(s = \"abcdefghij\",t = \"ghijklmnop\",k = 1) == 0\n assert candidate(s = \"abcdefabcdef\",t = \"defabcdefabc\",k = 123456789123456789) == 93349771\n assert candidate(s = \"mississippi\",t = \"ississippimis\",k = 6) == 0\n assert candidate(s = \"aabbccddeeffgghhiijj\",t = \"ddeeffgghhiijjaabbcc\",k = 5) == 123805\n assert candidate(s = \"repeatedpatternrepeatedpattern\",t = \"patternrepeatedpatternrepe\",k = 7) == 0\n assert candidate(s = \"aaaaaaaaaaaaaaaa\",t = \"aaaaaaaaaaaaaaaa\",k = 999999999999999) == 644220373\n assert candidate(s = \"abababababababab\",t = \"babababababababa\",k = 987654321) == 765551830\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"mnopqrstuvwxyzabcdefghijkl\",k = 123456789) == 292665766\n assert candidate(s = \"rotationrotationrotation\",t = \"ionrotationrotationrotati\",k = 111111111111111111111) == 0\n assert candidate(s = \"aaaaaaaaaaab\",t = \"baaaaaaaaaaa\",k = 1000000000000000) == 229977291\n assert candidate(s = \"abababababababab\",t = \"babababababababa\",k = 1000000000000000) == 831652769\n assert candidate(s = \"abcdefgabcdefg\",t = \"defgabcdefgabc\",k = 8) == 116532960\n assert candidate(s = \"xyzabcxyzabcxyz\",t = \"abcxyzabcxyzabc\",k = 7) == 0\n assert candidate(s = \"abababababababab\",t = \"babababababababa\",k = 9) == 221679555\n assert candidate(s = \"aaaaabbbbbaaaaabbbbb\",t = \"bbbbbaaaaabbbbbaaaaa\",k = 1000000000000000) == 390681001\n assert candidate(s = \"abracadabraabracadabra\",t = \"racadabraabracadabraab\",k = 600000000000000) == 240096750\n assert candidate(s = \"mississippi\",t = \"issippimiss\",k = 700000000000000) == 393112130\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"ccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaabb\",k = 123456789) == 882829284\n assert candidate(s = \"hellohellohellohellohello\",t = \"ohellohellohellohellohel\",k = 987654321987654321) == 0\n assert candidate(s = \"mississippi\",t = \"pimississi\",k = 999999999999999999) == 0\n assert candidate(s = \"abcdabcdabcdabcd\",t = \"cdabcdabcdabcdab\",k = 666666666666666666) == 518849396\n assert candidate(s = \"aabbccddeeffgghhiijj\",t = \"ccddeeffgghhiijjaaabbb\",k = 1000000) == 0\n assert candidate(s = \"xyzzyzyzyzyzyzyz\",t = \"zyzyzyzyzyzyzyzxyz\",k = 1000000000000000) == 228956597\n assert candidate(s = \"abcdefghabcdefgh\",t = \"ghabcdefghabcdefgh\",k = 1000000000) == 900560950\n assert candidate(s = \"abcdefabcdef\",t = \"defabcdefabc\",k = 1000000000000000) == 459954582\n assert candidate(s = \"racecar\",t = \"caracer\",k = 1000000000000) == 0\n assert candidate(s = \"abcabcabcabcabcabc\",t = \"cabcabcabcabcabcab\",k = 200000000000000) == 265479843\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",t = \"efghijabcdefghijabcdefghijabcd\",k = 1000000000000000) == 154245892\n assert candidate(s = \"abcdefgabcdefg\",t = \"efgabcdefgabcd\",k = 1000000000000000) == 38019381\n assert candidate(s = \"aaaaabbbbbcccccddddd\",t = \"bbbbbcccccdddddaaaaa\",k = 1000000000000000) == 695340504\n assert candidate(s = \"uniquestringunique\",t = \"euniquestringuniqu\",k = 987654321) == 817134159\n assert candidate(s = \"abcdefgh\",t = \"efghabcd\",k = 1000000000000000) == 653970076\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",t = \"cabcabcabcabcabcabcabcabcabcab\",k = 400000000000000) == 403487855\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzabcdefgabcdefgaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyy\",k = 123456789123456) == 224296084\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzxyyxwvvuttssrrqqppoonnmmllkkjjiihhggeeffddccbbaa\",k = 1000000000) == 0\n assert candidate(s = \"zzyzxzyzxzyz\",t = \"zyzxzyzxzyzz\",k = 12) == 535696233\n assert candidate(s = \"racecar\",t = \"caracer\",k = 3) == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",t = \"zzzzzzzzzzzzzzzzzzzz\",k = 500000000000000) == 415651994\n assert candidate(s = \"abcdefghij\",t = \"efghijabcd\",k = 1000000000000000) == 164370742\n assert candidate(s = \"aaaaabbbbbaaaaabbb\",t = \"bbbbbaaaaabbbbbbaaaa\",k = 1000000000000000) == 0\n assert candidate(s = \"uniquestringwithnounduplicates\",t = \"uniquestringwithnounduplica\",k = 2) == 0\n assert candidate(s = \"aabbccddeeff\",t = \"ccddeeffaabb\",k = 3) == 111\n assert candidate(s = \"repeatedrepeated\",t = \"atedrepeatedrepe\",k = 200000000000000000) == 212764291\n assert candidate(s = \"aaaabbbbccccdddd\",t = \"bbbbccccddddaaaa\",k = 987654321) == 845693984\n assert candidate(s = \"aaaaabbbbb\",t = \"bbbbbbaaaa\",k = 10) == 0\n assert candidate(s = \"thisisaverylongstring\",t = \"stringthisisaverylon\",k = 100) == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",t = \"cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab\",k = 500000000000000000) == 816699960\n assert candidate(s = \"abcdabcdabcdabcd\",t = \"ddddabcdabcdabcdabcd\",k = 2000000) == 395130602\n assert candidate(s = \"abababababababababab\",t = \"babababababababababa\",k = 999999999999999999) == 238518966\n assert candidate(s = \"abacabadabacaba\",t = \"cabacabadabacab\",k = 5) == 0\n assert candidate(s = \"cyclecyclecyclecycle\",t = \"yclecyclecyclecycl\",k = 1000000000000000) == 0\n assert candidate(s = \"abcabcabcabcabcabc\",t = \"cabcabcabcabcabcab\",k = 20) == 958338650\n assert candidate(s = \"abcdabcdabcdabcd\",t = \"dabcdabcdabcdabc\",k = 300000000000000) == 967363299\n assert candidate(s = \"aabbccddeeff\",t = \"ffddeeffaabbcc\",k = 1000000000000000) == 0\n assert candidate(s = \"abcdabcdabcdabcdabcd\",t = \"dabcdabcdabcdabcdabc\",k = 999999999999999) == 446142240\n assert candidate(s = \"abcabcabcabcabcabc\",t = \"cabcabcabcabcabcab\",k = 6) == 8045856\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"nopqrstuvwxyzabcdefghijklm\",k = 1000000000000000) == 907107378\n assert candidate(s = \"repeatthisrepeatthis\",t = \"thisrepeatthisrepeat\",k = 654321987654321987) == 726267327\n assert candidate(s = \"zzzzzzzzzzzzzzzz\",t = \"zzzzzzzzzzzzzzzz\",k = 1000000000000000) == 663305532\n assert candidate(s = \"abacabadabacaba\",t = \"dabacabacabacadaba\",k = 123456789) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzabcdefghijklmnopqrstuvwxyzabcd\",k = 222222222222222222222) == 0\n assert candidate(s = \"thisthisthisthisthisthisthis\",t = \"histhisthisthisthisthisthist\",k = 10000000000000) == 937749612\n assert candidate(s = \"abcdabcdabcdabcd\",t = \"ddddabcdabcdabcdabc\",k = 10) == 40649162\n assert candidate(s = \"hellohellohellohello\",t = \"lohellohellohellohel\",k = 7) == 178774348\n"}, "metadata": {"canonical_parameter_names": ["s", "t", "k"], "leetcode_dataset_entry_point": "Solution().numberOfWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfWays(String s, String t, long k) {", "container": "Solution", "callable": "numberOfWays", "parameters": [{"name": "s", "type": "String"}, {"name": "t", "type": "String"}, {"name": "k", "type": "long"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2855, "task_id": "minimum-right-shifts-to-sort-the-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array nums of length n containing distinct positive integers. Return the minimum number of right shifts required to sort nums and -1 if this is not possible.\nA right shift is defined as shifting the element at index i to index (i + 1) % n, for all indices.\n \nExample 1:\n\nInput: nums = [3,4,5,1,2]\nOutput: 2\nExplanation: \nAfter the first right shift, nums = [2,3,4,5,1].\nAfter the second right shift, nums = [1,2,3,4,5].\nNow nums is sorted; therefore the answer is 2.\n\nExample 2:\n\nInput: nums = [1,3,5]\nOutput: 0\nExplanation: nums is already sorted therefore, the answer is 0.\nExample 3:\n\nInput: nums = [2,1,4]\nOutput: -1\nExplanation: It's impossible to sort the array using right shifts.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\nnums contains distinct integers.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [4, 5, 6, 1, 2, 3]) == 3\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [50, 10, 20, 30, 40]) == 4\n assert candidate(nums = [1, 3, 5]) == 0\n assert candidate(nums = [2, 1, 4]) == -1\n assert candidate(nums = [4, 5, 1, 2, 3]) == 3\n assert candidate(nums = [2, 3, 4, 5, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [5, 1, 2, 3, 4]) == 4\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 99]) == 9\n assert candidate(nums = [3, 1, 2]) == 2\n assert candidate(nums = [2, 3, 1]) == 1\n assert candidate(nums = [3, 4, 5, 1, 2]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [3, 1, 2, 4, 5]) == -1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 1\n assert candidate(nums = [1, 3, 2, 4, 5]) == -1\n assert candidate(nums = [5, 4, 2, 1, 3]) == -1\n assert candidate(nums = [3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 1]) == -1\n assert candidate(nums = [3, 5, 4, 1, 2]) == -1\n assert candidate(nums = [15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 14\n assert candidate(nums = [6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [4, 2, 5, 1, 3]) == -1\n assert candidate(nums = [2, 3, 4, 5, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11\n assert candidate(nums = [7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8]) == 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, 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(nums = [5, 1, 2, 3, 4]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12]) == -1\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [1, 2, 3, 5, 4]) == 1\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == -1\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(nums = [15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(nums = [5, 1, 2, 3, 4, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == 3\n assert candidate(nums = [3, 1, 4, 2]) == -1\n assert candidate(nums = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(nums = [7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(nums = [5, 4, 3, 2, 1]) == -1\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, 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, 1, 2]) == 2\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 4\n assert candidate(nums = [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(nums = [10, 11, 12, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(nums = [2, 5, 1, 3, 4]) == -1\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 1, 2]) == 2\n assert candidate(nums = [1, 2, 4, 5, 3]) == 1\n assert candidate(nums = [3, 5, 4, 1, 2]) == -1\n assert candidate(nums = [9, 10, 11, 1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(nums = [5, 1, 3, 4, 2]) == -1\n assert candidate(nums = [3, 1, 2, 5, 4]) == -1\n assert candidate(nums = [60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 1, 2, 3, 4]) == 4\n assert candidate(nums = [1, 2, 3, 5, 4]) == 1\n assert candidate(nums = [2, 3, 4, 1, 5]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [4, 3, 1, 2, 5]) == -1\n assert candidate(nums = [1, 3, 2]) == 1\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 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]) == 29\n assert candidate(nums = [8, 9, 10, 11, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(nums = [5, 2, 3, 4, 1]) == -1\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4]) == 4\n assert candidate(nums = [20, 30, 40, 50, 60, 70, 80, 90, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == -1\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 1, 2, 3]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == -1\n assert candidate(nums = [2, 3, 4, 5, 1, 6]) == -1\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == 2\n assert candidate(nums = [15, 25, 35, 45, 55, 10, 20, 30, 40]) == -1\n assert candidate(nums = [9, 10, 11, 12, 13, 1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [4, 1, 2, 5, 3]) == -1\n assert candidate(nums = [4, 5, 1, 2, 3]) == 3\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 1, 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]) == 0\n assert candidate(nums = [3, 1, 2, 4, 6, 5]) == -1\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12]) == -1\n assert candidate(nums = [100, 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, 14, 2, 13, 3, 12, 4, 11, 5, 10, 6, 9, 7, 8]) == -1\n assert candidate(nums = [98, 99, 100, 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]) == 97\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [100, 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]) == 99\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4]) == 4\n assert candidate(nums = [100, 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, 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]) == -1\n assert candidate(nums = [8, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(nums = [11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 4, 3]) == 1\n assert candidate(nums = [2, 3, 4, 5, 1, 6, 7]) == -1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4]) == 4\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3]) == 3\n assert candidate(nums = [3, 2, 1]) == -1\n assert candidate(nums = [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 1]) == 1\n assert candidate(nums = [10, 11, 12, 13, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [2, 4, 1, 5, 3]) == -1\n assert candidate(nums = [100, 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]) == 99\n assert candidate(nums = [2, 3, 1, 5, 4]) == -1\n assert candidate(nums = [5, 3, 4, 1, 2]) == -1\n assert candidate(nums = [99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 18\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(nums = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(nums = [99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20]) == 18\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 12]) == -1\n assert candidate(nums = [1, 3, 2, 5, 4]) == -1\n assert candidate(nums = [2, 3, 5, 4, 1]) == -1\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 1, 2, 3, 4]) == 4\n assert candidate(nums = [6, 7, 8, 9, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 14\n assert candidate(nums = [1, 3, 2]) == 1\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, 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]) == -1\n assert candidate(nums = [2, 1, 3, 4, 5]) == -1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 4\n assert candidate(nums = [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(nums = [20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 19\n assert candidate(nums = [3, 4, 1, 2, 5]) == -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, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 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]) == 49\n assert candidate(nums = [11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [2, 3, 1, 4, 5]) == -1\n assert candidate(nums = [99, 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, 90, 91, 92, 93, 94, 95, 96, 97, 98]) == 97\n assert candidate(nums = [8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7]) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumRightShifts", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumRightShifts(List nums) {", "container": "Solution", "callable": "minimumRightShifts", "parameters": [{"name": "nums", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2856, "task_id": "minimum-array-length-after-pair-removals", "difficulty": "Medium", "problem_description": "Given an integer array num sorted in non-decreasing order.\nYou can perform the following operation any number of times:\n\nChoose two indices, i and j, where nums[i] < nums[j].\nThen, remove the elements at indices i and j from nums. The remaining elements retain their original order, and the array is re-indexed.\n\nReturn the minimum length of nums after applying the operation zero or more times.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 0\nExplanation:\n\n\nExample 2:\n\nInput: nums = [1,1,2,2,3,3]\nOutput: 0\nExplanation:\n\n\nExample 3:\n\nInput: nums = [1000000000,1000000000]\nOutput: 2\nExplanation:\nSince both numbers are equal, they cannot be removed.\n\nExample 4:\n\nInput: nums = [2,3,4,4,4]\nOutput: 1\nExplanation:\n\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\nnums is sorted in non-decreasing order.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 9\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 0\n assert candidate(nums = [1, 2, 3, 4]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 3]) == 0\n assert candidate(nums = [1000000000, 1000000000]) == 2\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3]) == 1\n assert candidate(nums = [2, 3, 4, 4, 4]) == 1\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2]) == 4\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 3]) == 1\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 5]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 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]) == 1\n assert candidate(nums = [1, 2, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 1\n assert candidate(nums = [1, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6]) == 0\n assert candidate(nums = [1, 1, 1, 1, 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]) == 1\n assert candidate(nums = [1, 2, 3, 4, 4, 5, 6, 7, 8, 8, 8, 9, 10, 11, 12, 12, 13, 14, 15, 16, 16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 21, 22, 23, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 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]) == 20\n assert candidate(nums = [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]) == 0\n assert candidate(nums = [1, 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]) == 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, 6, 6, 6, 7, 8, 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, 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]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [1, 1, 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, 8, 8, 8, 8, 8, 8, 8, 8]) == 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, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 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]) == 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]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [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, 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]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 10]) == 1\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 14\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 = [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]) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(nums = [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, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(nums = [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, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == 1\n assert candidate(nums = [1, 2, 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]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6]) == 1\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 1\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, 7]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == 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, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4]) == 1\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, 7, 7, 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]) == 1\n assert candidate(nums = [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, 5, 5]) == 1\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [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, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 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, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 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]) == 42\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 8, 8, 9, 9]) == 1\n assert candidate(nums = [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]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 10\n assert candidate(nums = [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, 10]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 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]) == 0\n assert candidate(nums = [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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6]) == 1\n assert candidate(nums = [1, 1, 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [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, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4]) == 1\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]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 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]) == 0\n assert candidate(nums = [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, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(nums = [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, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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, 22, 23, 24, 25]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 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]) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 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]) == 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]) == 38\n assert candidate(nums = [1, 2, 2, 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]) == 1\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, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 1\n assert candidate(nums = [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, 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]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [1, 2, 3, 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, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\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, 6, 6, 6, 6, 6, 6]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8]) == 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]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(nums = [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, 4, 4, 4, 4, 4]) == 1\n assert candidate(nums = [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]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4]) == 1\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, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 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, 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]) == 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, 8, 8, 8]) == 0\n assert candidate(nums = [1, 2, 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]) == 34\n assert candidate(nums = [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]) == 0\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 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, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 23\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minLengthAfterRemovals", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minLengthAfterRemovals(List nums) {", "container": "Solution", "callable": "minLengthAfterRemovals", "parameters": [{"name": "nums", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2857, "task_id": "count-pairs-of-points-with-distance-k", "difficulty": "Medium", "problem_description": "You are given a 2D integer array coordinates and an integer k, where coordinates[i] = [xi, yi] are the coordinates of the ith point in a 2D plane.\nWe define the distance between two points (x1, y1) and (x2, y2) as (x1 XOR x2) + (y1 XOR y2) where XOR is the bitwise XOR operation.\nReturn the number of pairs (i, j) such that i < j and the distance between points i and j is equal to k.\n \nExample 1:\n\nInput: coordinates = [[1,2],[4,2],[1,3],[5,2]], k = 5\nOutput: 2\nExplanation: We can choose the following pairs:\n- (0,1): Because we have (1 XOR 4) + (2 XOR 2) = 5.\n- (2,3): Because we have (1 XOR 5) + (3 XOR 2) = 5.\n\nExample 2:\n\nInput: coordinates = [[1,3],[1,3],[1,3],[1,3],[1,3]], k = 0\nOutput: 10\nExplanation: Any two chosen pairs will have a distance of 0. There are 10 ways to choose two pairs.\n\n \nConstraints:\n\n2 <= coordinates.length <= 50000\n0 <= xi, yi <= 106\n0 <= k <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3]],k = 2) == 2\n assert candidate(coordinates = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3]],k = 0) == 10\n assert candidate(coordinates = [[1, 2], [4, 2], [1, 3], [5, 2]],k = 5) == 2\n assert candidate(coordinates = [[0, 0], [0, 1], [1, 0], [1, 1]],k = 1) == 4\n assert candidate(coordinates = [[1000000, 1000000], [0, 0], [500000, 500000]],k = 1000000) == 1\n assert candidate(coordinates = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110]],k = 20) == 3\n assert candidate(coordinates = [[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]],k = 15) == 0\n assert candidate(coordinates = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],k = 0) == 45\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 15) == 0\n assert candidate(coordinates = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],k = 10) == 0\n assert candidate(coordinates = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],k = 25) == 0\n assert candidate(coordinates = [[123456, 654321], [111111, 999999], [222222, 888888], [333333, 777777], [444444, 666666]],k = 555555) == 0\n assert candidate(coordinates = [[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]],k = 15) == 0\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 31) == 0\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 9) == 0\n assert candidate(coordinates = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],k = 0) == 36\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],k = 2) == 5\n assert candidate(coordinates = [[123, 456], [654, 321], [789, 987], [111, 222], [333, 444], [555, 666]],k = 555) == 0\n assert candidate(coordinates = [[100000, 50000], [200000, 50000], [300000, 50000], [400000, 50000], [500000, 50000]],k = 100000) == 0\n assert candidate(coordinates = [[1000000, 1000000], [999999, 999999], [1000001, 1000001], [999998, 999998], [1000002, 1000002]],k = 2) == 2\n assert candidate(coordinates = [[0, 0], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],k = 15) == 1\n assert candidate(coordinates = [[2, 3], [5, 7], [8, 10], [3, 6], [1, 2]],k = 8) == 0\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],k = 0) == 0\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],k = 1) == 9\n assert candidate(coordinates = [[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]],k = 0) == 10\n assert candidate(coordinates = [[100000, 100000], [99999, 99999], [99998, 99998], [100001, 100001]],k = 1) == 0\n assert candidate(coordinates = [[1000000, 0], [0, 1000000], [500000, 500000], [0, 0], [1000000, 1000000]],k = 1000000) == 5\n assert candidate(coordinates = [[1, 2], [4, 2], [1, 3], [5, 2], [2, 1], [5, 1], [3, 5], [2, 4], [4, 4], [5, 5]],k = 5) == 5\n assert candidate(coordinates = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],k = 30) == 0\n assert candidate(coordinates = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6]],k = 3) == 0\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],k = 9) == 0\n assert candidate(coordinates = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]],k = 2) == 0\n assert candidate(coordinates = [[1, 0], [0, 1], [1, 1], [0, 0], [2, 2], [3, 3], [4, 4]],k = 2) == 3\n assert candidate(coordinates = [[50000, 50000], [50001, 50001], [50002, 50002], [50003, 50003], [50004, 50004], [50005, 50005], [50006, 50006], [50007, 50007], [50008, 50008], [50009, 50009]],k = 1) == 0\n assert candidate(coordinates = [[10, 20], [20, 10], [30, 40], [40, 30], [50, 60], [60, 50], [70, 80], [80, 70], [90, 100], [100, 90]],k = 20) == 0\n assert candidate(coordinates = [[2, 5], [3, 7], [10, 8], [5, 5], [1, 1], [6, 9]],k = 6) == 0\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 15) == 0\n assert candidate(coordinates = [[100000, 100000], [200000, 200000], [300000, 300000], [400000, 400000], [500000, 500000], [600000, 600000], [700000, 700000], [800000, 800000], [900000, 900000], [1000000, 1000000]],k = 999999) == 0\n assert candidate(coordinates = [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]],k = 0) == 45\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],k = 2) == 5\n assert candidate(coordinates = [[1, 0], [0, 1], [1, 1], [0, 0], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],k = 2) == 5\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 3) == 0\n assert candidate(coordinates = [[1, 2], [4, 2], [1, 3], [5, 2], [2, 3], [3, 4], [5, 5], [6, 6], [7, 7], [8, 8]],k = 5) == 2\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 0) == 0\n assert candidate(coordinates = [[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], [16, 15]],k = 3) == 0\n assert candidate(coordinates = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]],k = 3) == 0\n assert candidate(coordinates = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 15) == 3\n assert candidate(coordinates = [[12345, 67890], [98765, 43210], [11111, 22222], [33333, 44444], [55555, 66666]],k = 88888) == 0\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 5) == 0\n assert candidate(coordinates = [[12345, 67890], [98765, 43210], [13579, 24680], [24680, 13579], [98765, 12345], [43210, 67890], [86420, 13579], [67890, 24680], [43210, 98765], [24680, 12345]],k = 86420) == 0\n assert candidate(coordinates = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],k = 100) == 0\n assert candidate(coordinates = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],k = 0) == 45\n assert candidate(coordinates = [[1, 100000], [100000, 1], [2, 99999], [99999, 2], [3, 99998], [99998, 3], [4, 99997], [99997, 4], [5, 99996], [99996, 5]],k = 99999) == 0\n assert candidate(coordinates = [[1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2]],k = 0) == 20\n assert candidate(coordinates = [[1000000, 1000000], [999999, 999999], [500000, 500000], [0, 0]],k = 1023) == 0\n assert candidate(coordinates = [[1000000, 0], [0, 1000000], [1000000, 1000000], [0, 0]],k = 1000000) == 4\n assert candidate(coordinates = [[10, 1], [1, 10], [10, 10], [1, 1], [0, 0], [2, 2], [3, 3], [4, 4]],k = 9) == 0\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 10) == 0\n assert candidate(coordinates = [[2, 3], [3, 2], [4, 1], [1, 4], [5, 0], [0, 5], [6, 7], [7, 6], [8, 9], [9, 8]],k = 7) == 0\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],k = 18) == 2\n assert candidate(coordinates = [[100000, 0], [0, 100000], [100000, 100000], [0, 0], [50000, 50000], [60000, 60000], [70000, 70000], [80000, 80000], [90000, 90000], [100000, 100000]],k = 100000) == 7\n assert candidate(coordinates = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 1) == 4\n assert candidate(coordinates = [[123456, 654321], [987654, 123456], [246810, 135792], [369111, 246810], [479123, 369111]],k = 1000000) == 0\n assert candidate(coordinates = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],k = 50) == 0\n assert candidate(coordinates = [[1000000, 1000000], [0, 0], [500000, 500000], [250000, 250000]],k = 1000000) == 1\n assert candidate(coordinates = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600]],k = 100) == 0\n assert candidate(coordinates = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80]],k = 10) == 0\n assert candidate(coordinates = [[500000, 500000], [500001, 500001], [500002, 500002], [500003, 500003], [500004, 500004]],k = 1) == 0\n assert candidate(coordinates = [[1000000, 0], [0, 1000000], [500000, 500000], [250000, 750000], [750000, 250000]],k = 1000000) == 0\n assert candidate(coordinates = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],k = 1) == 0\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]],k = 0) == 0\n assert candidate(coordinates = [[1000000, 0], [0, 1000000], [500000, 500000], [1000000, 1000000]],k = 1000000) == 2\n assert candidate(coordinates = [[123, 456], [789, 101], [234, 567], [890, 123], [345, 678], [901, 234]],k = 567) == 0\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],k = 1) == 0\n assert candidate(coordinates = [[123, 456], [654, 321], [123, 456], [654, 321], [987, 654], [321, 987]],k = 537) == 0\n assert candidate(coordinates = [[100000, 100000], [0, 0], [100000, 0], [0, 100000], [50000, 50000]],k = 100000) == 5\n assert candidate(coordinates = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]],k = 10) == 2\n assert candidate(coordinates = [[255, 255], [254, 254], [253, 253], [252, 252], [251, 251], [250, 250]],k = 3) == 0\n assert candidate(coordinates = [[10, 20], [15, 25], [20, 10], [25, 15]],k = 15) == 0\n assert candidate(coordinates = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 1) == 0\n assert candidate(coordinates = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8]],k = 3) == 0\n assert candidate(coordinates = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],k = 0) == 45\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 2) == 4\n assert candidate(coordinates = [[999999, 0], [0, 999999], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],k = 999999) == 16\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 3) == 0\n assert candidate(coordinates = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],k = 1) == 0\n assert candidate(coordinates = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [100, 200], [200, 300], [300, 400], [400, 500], [500, 600]],k = 150) == 0\n assert candidate(coordinates = [[1, 2], [4, 6], [7, 8], [10, 12], [13, 14], [16, 18], [19, 20], [22, 24], [25, 26], [28, 30]],k = 3) == 0\n assert candidate(coordinates = [[1000000, 1000000], [500000, 500000], [250000, 250000], [125000, 125000], [62500, 62500]],k = 999999) == 0\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 0) == 0\n assert candidate(coordinates = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],k = 0) == 45\n"}, "metadata": {"canonical_parameter_names": ["coordinates", "k"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countPairs(List> coordinates, int k) {", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "coordinates", "type": "List>"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2858, "task_id": "minimum-edge-reversals-so-every-node-is-reachable", "difficulty": "Hard", "problem_description": "There is a simple directed graph with n nodes labeled from 0 to n - 1. The graph would form a tree if its edges were bi-directional.\nYou are given an integer n and a 2D integer array edges, where edges[i] = [ui, vi] represents a directed edge going from node ui to node vi.\nAn edge reversal changes the direction of an edge, i.e., a directed edge going from node ui to node vi becomes a directed edge going from node vi to node ui.\nFor every node i in the range [0, n - 1], your task is to independently calculate the minimum number of edge reversals required so it is possible to reach any other node starting from node i through a sequence of directed edges.\nReturn an integer array answer, where answer[i] is the minimum number of edge reversals required so it is possible to reach any other node starting from node i through a sequence of directed edges.\n \nExample 1:\n\n\nInput: n = 4, edges = [[2,0],[2,1],[1,3]]\nOutput: [1,1,0,2]\nExplanation: The image above shows the graph formed by the edges.\nFor node 0: after reversing the edge [2,0], it is possible to reach any other node starting from node 0.\nSo, answer[0] = 1.\nFor node 1: after reversing the edge [2,1], it is possible to reach any other node starting from node 1.\nSo, answer[1] = 1.\nFor node 2: it is already possible to reach any other node starting from node 2.\nSo, answer[2] = 0.\nFor node 3: after reversing the edges [1,3] and [2,1], it is possible to reach any other node starting from node 3.\nSo, answer[3] = 2.\n\nExample 2:\n\n\nInput: n = 3, edges = [[1,2],[2,0]]\nOutput: [2,0,1]\nExplanation: The image above shows the graph formed by the edges.\nFor node 0: after reversing the edges [2,0] and [1,2], it is possible to reach any other node starting from node 0.\nSo, answer[0] = 2.\nFor node 1: it is already possible to reach any other node starting from node 1.\nSo, answer[1] = 0.\nFor node 2: after reversing the edge [1, 2], it is possible to reach any other node starting from node 2.\nSo, answer[2] = 1.\n\n \nConstraints:\n\n2 <= n <= 105\nedges.length == n - 1\nedges[i].length == 2\n0 <= ui == edges[i][0] < n\n0 <= vi == edges[i][1] < n\nui != vi\nThe input is generated such that if the edges were bi-directional, the graph would be a tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 4,edges = [[2, 0], [2, 1], [1, 3]]) == [1, 1, 0, 2]\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [0, 1, 2, 3, 4]\n assert candidate(n = 5,edges = [[0, 1], [2, 0], [3, 2], [4, 2]]) == [3, 4, 2, 1, 1]\n assert candidate(n = 5,edges = [[0, 1], [2, 0], [3, 2], [4, 3]]) == [3, 4, 2, 1, 0]\n assert candidate(n = 3,edges = [[1, 2], [2, 0]]) == [2, 0, 1]\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [3, 8], [8, 9], [9, 10], [10, 11]]) == [0, 1, 2, 3, 1, 2, 3, 4, 4, 5, 6, 7]\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [6, 8], [8, 9], [9, 10]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5]\n assert candidate(n = 13,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]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 16,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]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(n = 15,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]]) == [0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7]]) == [0, 1, 1, 2, 2, 2, 2, 3]\n assert candidate(n = 15,edges = [[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]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 14,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]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(n = 20,edges = [[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]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 13,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]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [0, 1, 1, 2, 2, 2, 2]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3]\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 15,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]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(n = 7,edges = [[0, 1], [1, 3], [2, 1], [4, 1], [5, 2], [6, 2]]) == [4, 5, 4, 6, 4, 3, 3]\n assert candidate(n = 11,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 15,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]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 3]\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [5, 8], [8, 9], [9, 10]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5]\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7]]) == [0, 1, 2, 3, 1, 2, 3, 4]\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [6, 8]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3]\n assert candidate(n = 16,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]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 3]\n assert candidate(n = 20,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]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 20,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]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]\n assert candidate(n = 7,edges = [[0, 1], [1, 3], [3, 2], [2, 4], [4, 5], [5, 6]]) == [0, 1, 3, 2, 4, 5, 6]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]]) == [0, 1, 1, 2, 2, 2]\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [6, 8], [8, 9], [9, 10], [10, 11]]) == [0, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 6]\n assert candidate(n = 6,edges = [[0, 1], [1, 3], [3, 4], [4, 5], [2, 3]]) == [1, 2, 2, 3, 4, 5]\n assert candidate(n = 14,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]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().minEdgeReversals", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] minEdgeReversals(int n, int[][] edges) {", "container": "Solution", "callable": "minEdgeReversals", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2859, "task_id": "sum-of-values-at-indices-with-k-set-bits", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums and an integer k.\nReturn an integer that denotes the sum of elements in nums whose corresponding indices have exactly k set bits in their binary representation.\nThe set bits in an integer are the 1's present when it is written in binary.\n\nFor example, the binary representation of 21 is 10101, which has 3 set bits.\n\n \nExample 1:\n\nInput: nums = [5,10,1,5,2], k = 1\nOutput: 13\nExplanation: The binary representation of the indices are: \n0 = 0002\n1 = 0012\n2 = 0102\n3 = 0112\n4 = 1002 \nIndices 1, 2, and 4 have k = 1 set bits in their binary representation.\nHence, the answer is nums[1] + nums[2] + nums[4] = 13.\nExample 2:\n\nInput: nums = [4,3,2,1], k = 2\nOutput: 1\nExplanation: The binary representation of the indices are:\n0 = 002\n1 = 012\n2 = 102\n3 = 112\nOnly index 3 has k = 2 set bits in its binary representation.\nHence, the answer is nums[3] = 1.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 105\n0 <= k <= 10\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],k = 0) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 0\n assert candidate(nums = [32, 16, 8, 4, 2, 1],k = 3) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],k = 3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 8\n assert candidate(nums = [31, 14, 7, 3, 1],k = 0) == 31\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],k = 2) == 17\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 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],k = 4) == 1\n assert candidate(nums = [4, 3, 2, 1],k = 2) == 1\n assert candidate(nums = [5, 10, 1, 5, 2],k = 1) == 13\n assert candidate(nums = [987654, 321098, 654321, 123456, 789012, 456789, 890123, 567890],k = 3) == 567890\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1],k = 3) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],k = 4) == 160\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 1) == 556\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],k = 4) == 390\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 5) == 0\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128],k = 3) == 392\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 = 0) == 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 = 1) == 65814\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 5) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 2) == 255\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 3) == 2\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],k = 2) == 120\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],k = 4) == 80\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 = 2) == 880\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 = 2) == 10\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 5) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 45\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999],k = 4) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 0) == 9\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310, 341, 372, 403, 434, 465],k = 2) == 1581\n assert candidate(nums = [15, 23, 45, 67, 89, 101, 113, 125, 137, 149],k = 3) == 125\n assert candidate(nums = [12, 34, 56, 78, 90, 102, 114, 126, 138, 150, 162, 174],k = 3) == 300\n assert candidate(nums = [3, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41],k = 3) == 29\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, 217, 224, 231, 238, 245, 252, 259, 266, 273, 280, 287, 294, 301, 308, 315, 322, 329, 336, 343, 350, 357, 364, 371, 378, 385, 392, 399, 406, 413, 420, 427, 434, 441, 448, 455, 462, 469, 476, 483, 490, 497, 504, 511],k = 6) == 448\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600],k = 2) == 5100\n assert candidate(nums = [1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012, 10123, 11234, 12345, 13456, 14567, 15678, 16789, 17890, 18901, 19012, 20123, 21234, 22345, 23456, 24567, 25678, 26789, 27890, 28901, 29012, 30123, 31234, 32345, 33456],k = 5) == 32345\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 5) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == 80\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 6) == 0\n assert candidate(nums = [12345, 67890, 54321, 98765, 43210, 87654, 32109, 76543, 21098, 65432],k = 2) == 283960\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],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, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],k = 3) == 196\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1) == 1900\n assert candidate(nums = [31415, 9265, 3589, 7932, 3846, 2643, 3832, 795, 0, 288, 4197, 1693, 9937, 5105, 8209, 7494, 4592, 3078, 1640, 6286, 2089, 9862, 8034, 8253, 4211, 7067, 9, 35010],k = 4) == 50757\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],k = 2) == 255\n assert candidate(nums = [65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 6) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 800\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 4) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 2700\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 2) == 357\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 24\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 2) == 3\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120],k = 4) == 0\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981],k = 5) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270, 279, 288, 297, 306, 315, 324, 333, 342, 351, 360, 369, 378, 387, 396, 405, 414, 423, 432, 441, 450, 459, 468, 477, 486, 495, 504, 513, 522, 531, 540, 549, 558, 567, 576, 585, 594, 603, 612, 621, 630],k = 7) == 0\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 6) == 0\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111],k = 1) == 2331\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1],k = 6) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1) == 1900\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 2) == 96\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],k = 3) == 53500\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 4) == 31\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 5) == 0\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9, 1],k = 1) == 16\n assert candidate(nums = [12345, 23456, 34567, 45678, 56789, 67890, 78901, 89012, 90123, 12345],k = 3) == 89012\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 100000\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],k = 0) == 1\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 3) == 1152\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],k = 10) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 3) == 8\n assert candidate(nums = [98765, 43210, 11111, 88888, 55555, 22222, 77777, 33333, 66666, 44444, 7777, 5555, 2222, 8888, 9999],k = 3) == 57775\n assert candidate(nums = [4294967295, 2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607],k = 4) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],k = 5) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().sumIndicesWithKSetBits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int sumIndicesWithKSetBits(List nums, int k) {", "container": "Solution", "callable": "sumIndicesWithKSetBits", "parameters": [{"name": "nums", "type": "List"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2860, "task_id": "happy-students", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of length n where n is the total number of students in the class. The class teacher tries to select a group of students so that all the students remain happy.\nThe ith student will become happy if one of these two conditions is met:\n\nThe student is selected and the total number of selected students is strictly greater than nums[i].\nThe student is not selected and the total number of selected students is strictly less than nums[i].\n\nReturn the number of ways to select a group of students so that everyone remains happy.\n \nExample 1:\n\nInput: nums = [1,1]\nOutput: 2\nExplanation: \nThe two possible ways are:\nThe class teacher selects no student.\nThe class teacher selects both students to form the group. \nIf the class teacher selects just one student to form a group then the both students will not be happy. Therefore, there are only two possible ways.\n\nExample 2:\n\nInput: nums = [6,0,3,3,6,7,2,7]\nOutput: 3\nExplanation: \nThe three possible ways are:\nThe class teacher selects the student with index = 1 to form the group.\nThe class teacher selects the students with index = 1, 2, 3, 6 to form the group.\nThe class teacher selects all the students to form the group.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] < nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4]) == 2\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [10, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 1\n assert candidate(nums = [4, 4, 4, 4, 3, 3, 3, 3, 2, 2]) == 2\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(nums = [5, 1, 4, 2, 3]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4]) == 1\n assert candidate(nums = [3, 2, 1, 0]) == 1\n assert candidate(nums = [0]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 1\n assert candidate(nums = [3, 2, 1]) == 1\n assert candidate(nums = [6, 0, 3, 3, 6, 7, 2, 7]) == 3\n assert candidate(nums = [1, 1]) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 1\n assert candidate(nums = [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 1\n assert candidate(nums = [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]) == 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]) == 2\n assert candidate(nums = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [0, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == 1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(nums = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 1\n assert candidate(nums = [1, 0, 2, 3, 0, 2, 1, 3, 2, 1, 0, 3, 2, 1, 0]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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]) == 2\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 1\n assert candidate(nums = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0]) == 2\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 1\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 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]) == 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 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]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 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]) == 2\n assert candidate(nums = [2, 2, 2, 1, 1, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == 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\n assert candidate(nums = [3, 3, 2, 2, 1, 1, 0, 0, 0, 0]) == 1\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]) == 1\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [2, 0, 3, 1, 4, 5, 6, 7, 8, 9]) == 1\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 = [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, 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 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 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]) == 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 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5, 10, 6, 10, 7, 10, 8, 10, 9, 10, 10]) == 2\n assert candidate(nums = [4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 2\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 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\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [5, 3, 8, 2, 7, 4, 1, 6, 9, 0]) == 1\n assert candidate(nums = [0, 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, 11, 12, 13, 14, 15]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [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, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 11, 10, 13, 12, 15, 14]) == 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, 3, 1, 8, 5, 4, 9, 6, 2, 0, 10, 11, 12, 13, 14]) == 1\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, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 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]) == 2\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 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, 85, 90, 95, 0]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 0]) == 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 = [30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(nums = [0, 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 = [0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [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]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 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]) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 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, 7]) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countWays(List nums) {", "container": "Solution", "callable": "countWays", "parameters": [{"name": "nums", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2861, "task_id": "maximum-number-of-alloys", "difficulty": "Medium", "problem_description": "You are the owner of a company that creates alloys using various types of metals. There are n different types of metals available, and you have access to k machines that can be used to create alloys. Each machine requires a specific amount of each metal type to create an alloy.\nFor the ith machine to create an alloy, it needs composition[i][j] units of metal of type j. Initially, you have stock[i] units of metal type i, and purchasing one unit of metal type i costs cost[i] coins.\nGiven integers n, k, budget, a 1-indexed 2D array composition, and 1-indexed arrays stock and cost, your goal is to maximize the number of alloys the company can create while staying within the budget of budget coins.\nAll alloys must be created with the same machine.\nReturn the maximum number of alloys that the company can create.\n \nExample 1:\n\nInput: n = 3, k = 2, budget = 15, composition = [[1,1,1],[1,1,10]], stock = [0,0,0], cost = [1,2,3]\nOutput: 2\nExplanation: It is optimal to use the 1st machine to create alloys.\nTo create 2 alloys we need to buy the:\n- 2 units of metal of the 1st type.\n- 2 units of metal of the 2nd type.\n- 2 units of metal of the 3rd type.\nIn total, we need 2 * 1 + 2 * 2 + 2 * 3 = 12 coins, which is smaller than or equal to budget = 15.\nNotice that we have 0 units of metal of each type and we have to buy all the required units of metal.\nIt can be proven that we can create at most 2 alloys.\n\nExample 2:\n\nInput: n = 3, k = 2, budget = 15, composition = [[1,1,1],[1,1,10]], stock = [0,0,100], cost = [1,2,3]\nOutput: 5\nExplanation: It is optimal to use the 2nd machine to create alloys.\nTo create 5 alloys we need to buy:\n- 5 units of metal of the 1st type.\n- 5 units of metal of the 2nd type.\n- 0 units of metal of the 3rd type.\nIn total, we need 5 * 1 + 5 * 2 + 0 * 3 = 15 coins, which is smaller than or equal to budget = 15.\nIt can be proven that we can create at most 5 alloys.\n\nExample 3:\n\nInput: n = 2, k = 3, budget = 10, composition = [[2,1],[1,2],[1,1]], stock = [1,1], cost = [5,5]\nOutput: 2\nExplanation: It is optimal to use the 3rd machine to create alloys.\nTo create 2 alloys we need to buy the:\n- 1 unit of metal of the 1st type.\n- 1 unit of metal of the 2nd type.\nIn total, we need 1 * 5 + 1 * 5 = 10 coins, which is smaller than or equal to budget = 10.\nIt can be proven that we can create at most 2 alloys.\n\n \nConstraints:\n\n1 <= n, k <= 100\n0 <= budget <= 108\ncomposition.length == k\ncomposition[i].length == n\n1 <= composition[i][j] <= 100\nstock.length == cost.length == n\n0 <= stock[i] <= 108\n1 <= cost[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,k = 2,budget = 15,composition = [[1, 1, 1], [1, 1, 10]],stock = [0, 0, 0],cost = [1, 2, 3]) == 2\n assert candidate(n = 1,k = 1,budget = 100,composition = [[5]],stock = [0],cost = [20]) == 1\n assert candidate(n = 2,k = 2,budget = 20,composition = [[1, 2], [2, 1]],stock = [10, 10],cost = [1, 1]) == 13\n assert candidate(n = 3,k = 2,budget = 15,composition = [[1, 1, 1], [1, 1, 10]],stock = [0, 0, 100],cost = [1, 2, 3]) == 5\n assert candidate(n = 2,k = 3,budget = 10,composition = [[2, 1], [1, 2], [1, 1]],stock = [1, 1],cost = [5, 5]) == 2\n assert candidate(n = 6,k = 4,budget = 200,composition = [[1, 1, 1, 1, 1, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [1, 3, 5, 7, 9, 11]],stock = [5, 10, 15, 20, 25, 30],cost = [1, 2, 3, 4, 5, 6]) == 31\n assert candidate(n = 2,k = 4,budget = 200,composition = [[1, 1], [2, 2], [3, 3], [4, 4]],stock = [10, 10],cost = [1, 2]) == 76\n assert candidate(n = 5,k = 3,budget = 250,composition = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3]],stock = [0, 0, 0, 0, 0],cost = [1, 1, 1, 1, 1]) == 50\n assert candidate(n = 6,k = 4,budget = 300,composition = [[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4]],stock = [0, 0, 0, 0, 0, 0],cost = [1, 2, 3, 4, 5, 6]) == 14\n assert candidate(n = 4,k = 3,budget = 100,composition = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 2, 2, 2]],stock = [5, 5, 5, 5],cost = [1, 1, 1, 1]) == 15\n assert candidate(n = 5,k = 5,budget = 1000,composition = [[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]],stock = [100, 100, 100, 100, 100],cost = [1, 1, 1, 1, 1]) == 1100\n assert candidate(n = 2,k = 3,budget = 150,composition = [[1, 1], [2, 1], [1, 2]],stock = [50, 50],cost = [10, 20]) == 55\n assert candidate(n = 4,k = 3,budget = 500,composition = [[1, 1, 1, 1], [2, 2, 2, 2], [1, 2, 3, 4]],stock = [10, 10, 10, 10],cost = [10, 20, 30, 40]) == 15\n assert candidate(n = 6,k = 2,budget = 300,composition = [[1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10]],stock = [5, 5, 5, 5, 5, 5],cost = [1, 1, 1, 1, 1, 1]) == 55\n assert candidate(n = 3,k = 5,budget = 500,composition = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],stock = [0, 0, 0],cost = [1, 2, 3]) == 83\n assert candidate(n = 4,k = 4,budget = 350,composition = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],stock = [50, 50, 50, 50],cost = [1, 2, 3, 4]) == 85\n assert candidate(n = 3,k = 3,budget = 200,composition = [[1, 1, 1], [10, 1, 1], [1, 10, 1]],stock = [100, 100, 100],cost = [1, 10, 100]) == 101\n assert candidate(n = 4,k = 4,budget = 200,composition = [[1, 1, 1, 1], [1, 0, 0, 1], [0, 1, 0, 1], [0, 0, 1, 1]],stock = [20, 20, 20, 20],cost = [1, 2, 3, 4]) == 60\n assert candidate(n = 3,k = 2,budget = 50,composition = [[1, 2, 3], [3, 2, 1]],stock = [10, 20, 30],cost = [1, 2, 3]) == 14\n assert candidate(n = 3,k = 3,budget = 1000,composition = [[10, 20, 30], [20, 30, 40], [30, 40, 50]],stock = [0, 0, 0],cost = [1, 2, 3]) == 7\n assert candidate(n = 4,k = 3,budget = 50,composition = [[2, 1, 3, 1], [1, 2, 1, 2], [3, 3, 3, 3]],stock = [10, 5, 0, 0],cost = [5, 3, 2, 4]) == 5\n assert candidate(n = 2,k = 3,budget = 250,composition = [[10, 1], [1, 10], [5, 5]],stock = [100, 100],cost = [1, 1]) == 45\n assert candidate(n = 5,k = 3,budget = 500,composition = [[2, 3, 1, 4, 5], [1, 1, 1, 1, 1], [5, 5, 5, 5, 5]],stock = [10, 20, 30, 40, 50],cost = [1, 2, 3, 4, 5]) == 70\n assert candidate(n = 3,k = 1,budget = 50,composition = [[10, 10, 10]],stock = [5, 5, 5],cost = [1, 1, 1]) == 2\n assert candidate(n = 4,k = 4,budget = 300,composition = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],stock = [50, 50, 50, 50],cost = [1, 2, 3, 4]) == 350\n assert candidate(n = 4,k = 3,budget = 100,composition = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]],stock = [5, 5, 5, 5],cost = [2, 3, 4, 5]) == 4\n assert candidate(n = 5,k = 4,budget = 100,composition = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 1, 1, 1, 1], [10, 10, 10, 10, 10]],stock = [5, 5, 5, 5, 5],cost = [1, 2, 3, 4, 5]) == 11\n assert candidate(n = 4,k = 4,budget = 150,composition = [[1, 1, 1, 1], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]],stock = [50, 0, 0, 0],cost = [1, 10, 10, 10]) == 200\n assert candidate(n = 6,k = 2,budget = 300,composition = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]],stock = [0, 0, 0, 0, 0, 0],cost = [1, 2, 3, 4, 5, 6]) == 5\n assert candidate(n = 3,k = 2,budget = 300,composition = [[1, 1, 1], [2, 2, 2]],stock = [0, 0, 0],cost = [100, 50, 25]) == 1\n assert candidate(n = 4,k = 4,budget = 800,composition = [[1, 1, 1, 1], [2, 1, 1, 1], [1, 2, 1, 1], [1, 1, 2, 1]],stock = [10, 20, 30, 40],cost = [5, 10, 15, 20]) == 46\n assert candidate(n = 7,k = 3,budget = 1500,composition = [[1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [3, 3, 3, 3, 3, 3, 3]],stock = [50, 60, 70, 80, 90, 100, 110],cost = [1, 2, 3, 4, 5, 6, 7]) == 47\n assert candidate(n = 5,k = 5,budget = 1000,composition = [[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]],stock = [500, 500, 500, 500, 500],cost = [1, 1, 1, 1, 1]) == 700\n assert candidate(n = 4,k = 4,budget = 200,composition = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],stock = [0, 0, 0, 0],cost = [5, 5, 5, 5]) == 10\n assert candidate(n = 3,k = 4,budget = 300,composition = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2]],stock = [20, 30, 40],cost = [5, 10, 15]) == 20\n assert candidate(n = 4,k = 3,budget = 200,composition = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]],stock = [0, 0, 0, 100],cost = [10, 20, 30, 40]) == 20\n assert candidate(n = 2,k = 3,budget = 10000,composition = [[100, 1], [1, 100], [50, 50]],stock = [5000, 5000],cost = [1, 1]) == 200\n assert candidate(n = 6,k = 2,budget = 3000,composition = [[1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10]],stock = [5, 10, 15, 20, 25, 30],cost = [1, 2, 3, 4, 5, 6]) == 164\n assert candidate(n = 4,k = 3,budget = 100,composition = [[2, 3, 1, 4], [1, 1, 1, 1], [5, 5, 5, 5]],stock = [10, 10, 10, 10],cost = [1, 2, 3, 4]) == 20\n assert candidate(n = 4,k = 2,budget = 1000,composition = [[1, 1, 1, 1], [99, 99, 99, 99]],stock = [100, 100, 100, 100],cost = [1, 1, 1, 1]) == 350\n assert candidate(n = 10,k = 2,budget = 5000,composition = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]],stock = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 90\n assert candidate(n = 7,k = 3,budget = 2500,composition = [[1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [2, 3, 2, 3, 2, 3, 2]],stock = [50, 50, 50, 50, 50, 50, 50],cost = [1, 1, 1, 1, 1, 1, 1]) == 167\n assert candidate(n = 7,k = 3,budget = 1000,composition = [[1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13]],stock = [100, 200, 300, 400, 500, 600, 700],cost = [1, 2, 3, 4, 5, 6, 7]) == 107\n assert candidate(n = 5,k = 3,budget = 500,composition = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 2, 2, 2, 2]],stock = [10, 20, 30, 40, 50],cost = [5, 4, 3, 2, 1]) == 28\n assert candidate(n = 3,k = 5,budget = 200,composition = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],stock = [10, 10, 10],cost = [10, 20, 30]) == 13\n assert candidate(n = 5,k = 2,budget = 250,composition = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]],stock = [0, 0, 0, 0, 0],cost = [1, 2, 3, 4, 5]) == 7\n assert candidate(n = 2,k = 3,budget = 50,composition = [[1, 1], [2, 2], [3, 3]],stock = [20, 20],cost = [1, 2]) == 36\n assert candidate(n = 6,k = 5,budget = 1000,composition = [[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]],stock = [0, 0, 0, 0, 0, 0],cost = [1, 2, 3, 4, 5, 6]) == 47\n assert candidate(n = 2,k = 4,budget = 500,composition = [[1, 1], [1, 2], [2, 1], [2, 2]],stock = [100, 100],cost = [1, 1]) == 350\n assert candidate(n = 3,k = 3,budget = 200,composition = [[1, 1, 1], [1, 0, 1], [0, 1, 1]],stock = [10, 10, 10],cost = [1, 1, 1]) == 110\n assert candidate(n = 3,k = 3,budget = 200,composition = [[1, 1, 1], [10, 10, 10], [5, 5, 5]],stock = [100, 100, 100],cost = [1, 2, 3]) == 133\n assert candidate(n = 4,k = 5,budget = 500,composition = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],stock = [50, 50, 50, 50],cost = [10, 20, 30, 40]) == 55\n assert candidate(n = 6,k = 6,budget = 300,composition = [[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]],stock = [0, 0, 0, 0, 0, 0],cost = [1, 2, 3, 4, 5, 6]) == 14\n assert candidate(n = 4,k = 2,budget = 200,composition = [[1, 2, 3, 4], [4, 3, 2, 1]],stock = [0, 0, 0, 0],cost = [10, 20, 30, 40]) == 1\n assert candidate(n = 5,k = 3,budget = 1000,composition = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 2, 1, 2]],stock = [10, 20, 30, 40, 50],cost = [1, 2, 3, 4, 5]) == 55\n assert candidate(n = 5,k = 5,budget = 2000,composition = [[1, 1, 1, 1, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [10, 10, 10, 10, 10], [2, 3, 4, 5, 6]],stock = [0, 0, 0, 0, 0],cost = [1, 2, 3, 4, 5]) == 133\n assert candidate(n = 3,k = 2,budget = 50,composition = [[1, 1, 1], [1, 2, 3]],stock = [10, 10, 10],cost = [1, 1, 1]) == 26\n assert candidate(n = 5,k = 2,budget = 800,composition = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10]],stock = [100, 100, 100, 100, 100],cost = [1, 2, 3, 4, 5]) == 6\n assert candidate(n = 3,k = 3,budget = 100,composition = [[1, 2, 3], [3, 2, 1], [2, 3, 1]],stock = [10, 10, 10],cost = [10, 10, 10]) == 6\n assert candidate(n = 5,k = 5,budget = 100,composition = [[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]],stock = [10, 10, 10, 10, 10],cost = [10, 10, 10, 10, 10]) == 20\n assert candidate(n = 3,k = 5,budget = 300,composition = [[1, 1, 1], [2, 1, 1], [1, 2, 1], [1, 1, 2], [3, 3, 3]],stock = [0, 0, 0],cost = [10, 20, 30]) == 5\n assert candidate(n = 3,k = 3,budget = 450,composition = [[3, 3, 3], [4, 4, 4], [5, 5, 5]],stock = [0, 0, 0],cost = [5, 10, 15]) == 5\n assert candidate(n = 6,k = 2,budget = 200,composition = [[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0]],stock = [10, 20, 30, 40, 50, 60],cost = [1, 2, 3, 4, 5, 6]) == 81\n assert candidate(n = 6,k = 3,budget = 300,composition = [[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3]],stock = [10, 10, 10, 10, 10, 10],cost = [1, 2, 3, 4, 5, 6]) == 24\n assert candidate(n = 5,k = 3,budget = 1000,composition = [[2, 3, 1, 1, 2], [1, 2, 3, 4, 5], [3, 2, 1, 2, 1]],stock = [10, 20, 30, 40, 50],cost = [1, 2, 3, 4, 5]) == 67\n assert candidate(n = 2,k = 5,budget = 50,composition = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 3]],stock = [5, 5],cost = [10, 20]) == 6\n assert candidate(n = 3,k = 3,budget = 1000,composition = [[2, 2, 2], [3, 3, 3], [1, 1, 1]],stock = [100, 200, 300],cost = [1, 1, 1]) == 533\n assert candidate(n = 5,k = 4,budget = 500,composition = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [10, 10, 10, 10, 10], [1, 1, 1, 1, 1]],stock = [50, 50, 50, 50, 50],cost = [5, 5, 5, 5, 5]) == 70\n assert candidate(n = 3,k = 3,budget = 50,composition = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],stock = [15, 15, 15],cost = [1, 1, 1]) == 31\n assert candidate(n = 2,k = 5,budget = 300,composition = [[1, 1], [2, 1], [1, 2], [3, 1], [1, 3]],stock = [100, 100],cost = [50, 100]) == 102\n assert candidate(n = 6,k = 6,budget = 600,composition = [[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]],stock = [0, 0, 0, 0, 0, 0],cost = [1, 2, 3, 4, 5, 6]) == 28\n assert candidate(n = 3,k = 5,budget = 200,composition = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 1, 2]],stock = [10, 20, 30],cost = [1, 2, 3]) == 34\n assert candidate(n = 3,k = 2,budget = 500,composition = [[10, 20, 30], [30, 20, 10]],stock = [50, 50, 50],cost = [5, 10, 15]) == 3\n assert candidate(n = 4,k = 4,budget = 100,composition = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],stock = [25, 25, 25, 25],cost = [1, 1, 1, 1]) == 125\n assert candidate(n = 7,k = 3,budget = 1000,composition = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3]],stock = [100, 100, 100, 100, 100, 100, 100],cost = [1, 2, 3, 4, 5, 6, 7]) == 135\n assert candidate(n = 4,k = 4,budget = 1000,composition = [[10, 20, 30, 40], [20, 30, 40, 50], [30, 40, 50, 60], [40, 50, 60, 70]],stock = [0, 0, 0, 0],cost = [5, 4, 3, 2]) == 3\n assert candidate(n = 5,k = 1,budget = 200,composition = [[10, 20, 30, 40, 50]],stock = [5, 10, 15, 20, 25],cost = [1, 2, 3, 4, 5]) == 0\n assert candidate(n = 5,k = 2,budget = 50,composition = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2]],stock = [5, 5, 5, 5, 5],cost = [1, 1, 1, 1, 1]) == 15\n assert candidate(n = 5,k = 2,budget = 1000,composition = [[10, 10, 10, 10, 10], [1, 1, 1, 1, 1]],stock = [100, 100, 100, 100, 100],cost = [1, 2, 3, 4, 5]) == 166\n assert candidate(n = 4,k = 3,budget = 500,composition = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1]],stock = [100, 100, 100, 100],cost = [1, 2, 3, 4]) == 68\n assert candidate(n = 5,k = 4,budget = 100,composition = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 1, 5, 4], [3, 3, 3, 3, 3]],stock = [10, 10, 10, 10, 10],cost = [1, 2, 3, 4, 5]) == 6\n assert candidate(n = 4,k = 4,budget = 500,composition = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],stock = [100, 100, 100, 100],cost = [1, 2, 3, 4]) == 150\n assert candidate(n = 8,k = 2,budget = 3000,composition = [[1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10]],stock = [100, 100, 100, 100, 100, 100, 100, 100],cost = [1, 2, 3, 4, 5, 6, 7, 8]) == 183\n assert candidate(n = 10,k = 10,budget = 100000,composition = [[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]],stock = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2818\n assert candidate(n = 2,k = 5,budget = 50,composition = [[1, 1], [2, 1], [1, 2], [3, 1], [1, 3]],stock = [0, 0],cost = [5, 10]) == 3\n assert candidate(n = 3,k = 3,budget = 150,composition = [[1, 2, 3], [3, 2, 1], [2, 3, 1]],stock = [10, 20, 30],cost = [10, 20, 30]) == 11\n assert candidate(n = 5,k = 5,budget = 200,composition = [[1, 1, 1, 1, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1]],stock = [10, 10, 10, 10, 10],cost = [1, 2, 3, 4, 5]) == 23\n assert candidate(n = 3,k = 5,budget = 200,composition = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],stock = [50, 50, 50],cost = [10, 20, 30]) == 53\n assert candidate(n = 3,k = 5,budget = 500,composition = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],stock = [10, 10, 10],cost = [1, 1, 1]) == 176\n assert candidate(n = 4,k = 5,budget = 1200,composition = [[1, 1, 1, 1], [2, 1, 1, 2], [1, 2, 2, 1], [2, 2, 1, 1], [1, 1, 2, 2]],stock = [50, 50, 50, 50],cost = [10, 20, 30, 40]) == 62\n assert candidate(n = 4,k = 4,budget = 1000,composition = [[10, 20, 30, 40], [5, 15, 25, 35], [1, 1, 1, 1], [100, 50, 25, 10]],stock = [0, 0, 0, 0],cost = [1, 2, 3, 4]) == 100\n"}, "metadata": {"canonical_parameter_names": ["n", "k", "budget", "composition", "stock", "cost"], "leetcode_dataset_entry_point": "Solution().maxNumberOfAlloys", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxNumberOfAlloys(int n, int k, int budget, List> composition, List stock, List cost) {", "container": "Solution", "callable": "maxNumberOfAlloys", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}, {"name": "budget", "type": "int"}, {"name": "composition", "type": "List>"}, {"name": "stock", "type": "List"}, {"name": "cost", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2862, "task_id": "maximum-element-sum-of-a-complete-subset-of-indices", "difficulty": "Hard", "problem_description": "You are given a 1-indexed array nums. Your task is to select a complete subset from nums where every pair of selected indices multiplied is a perfect square,. i. e. if you select ai and aj, i * j must be a perfect square.\nReturn the sum of the complete subset with the maximum sum.\n \nExample 1:\n\nInput: nums = [8,7,3,5,7,2,4,9]\nOutput: 16\nExplanation:\nWe select elements at indices 2 and 8 and 2 * 8 is a perfect square.\n\nExample 2:\n\nInput: nums = [8,10,3,8,1,13,7,9,4]\nOutput: 20\nExplanation:\nWe select elements at indices 1, 4, and 9. 1 * 4, 1 * 9, 4 * 9 are perfect squares.\n\n \nConstraints:\n\n1 <= n == nums.length <= 104\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [8, 10, 3, 8, 1, 13, 7, 9, 4]) == 20\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 30\n assert candidate(nums = [8, 7, 3, 5, 7, 2, 4, 9]) == 16\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(nums = [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]) == 14\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 3000\n assert candidate(nums = [9, 64, 36, 49, 1, 64, 25, 81, 16, 4, 2, 9, 3, 1, 81, 9, 49, 1, 4, 36, 16, 4, 1, 9, 64, 25, 1, 1, 81, 9, 49, 1, 4, 36, 16, 4, 1, 9, 64, 25, 1, 1, 81, 9]) == 151\n assert candidate(nums = [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]) == 469\n assert candidate(nums = [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, 2116, 2209, 2304, 2401, 2500]) == 3562\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, 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]) == 760\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]) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(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]) == 55\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 18, 19, 21, 22, 23, 26, 27, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 46, 47, 49]) == 85\n assert candidate(nums = [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, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025]) == 4963\n assert candidate(nums = [16, 8, 4, 2, 1, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216]) == 16810258\n assert candidate(nums = [123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456]) == 864192\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 2999999989\n assert candidate(nums = [36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625]) == 754\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 56\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]) == 5500\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]) == 560\n assert candidate(nums = [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]) == 205\n assert candidate(nums = [10, 15, 21, 30, 35, 42, 56, 63, 70, 84, 91, 105, 112, 126, 133, 140, 154, 165, 182, 196, 210, 224, 231, 252, 266, 280, 308, 315, 322, 336, 364, 385, 392, 420, 441, 462, 490, 504, 532, 539, 550, 588, 616, 630, 646, 665, 672, 728, 735, 756, 770, 812, 840, 858, 882, 924, 931, 980, 990]) == 1713\n assert candidate(nums = [9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484]) == 533\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 30000\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 3000000000\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]) == 550\n assert candidate(nums = [16, 8, 4, 2, 1, 16, 8, 4, 2, 1, 16, 8, 4, 2, 1, 16, 8, 4, 2, 1, 16, 8, 4, 2, 1]) == 37\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]) == 55\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]) == 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]) == 6\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 425\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]) == 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, 73, 79, 83, 89, 97]) == 182\n assert candidate(nums = [9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 516\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 30\n assert candidate(nums = [31, 28, 30, 29, 33, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 139\n assert candidate(nums = [9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3]) == 24\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, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211]) == 360\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]) == 2275\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 30\n assert candidate(nums = [8, 7, 3, 5, 7, 2, 4, 9, 8, 7, 3, 5, 7, 2, 4, 9, 8, 7, 3, 5, 7, 2, 4, 9, 8, 7, 3, 5, 7, 2, 4, 9, 8, 7, 3, 5, 7, 2, 4, 9, 8, 7, 3, 5, 7, 2, 4, 9, 8, 7, 3, 5, 7, 2, 4, 9, 8, 7, 3, 5, 7, 2, 4, 9]) == 60\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 300\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]) == 12\n assert candidate(nums = [98, 81, 64, 49, 36, 25, 16, 9, 4, 1, 0, 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]) == 997\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 2999999989\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, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == 455\n assert candidate(nums = [49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676]) == 858\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, 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, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 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, 200]) == 770\n assert candidate(nums = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991, 99999990, 99999989, 99999988, 99999987, 99999986, 99999985, 99999984, 99999983, 99999982, 99999981]) == 399999974\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 150\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]) == 8\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 3000\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]) == 560\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]) == 91\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 30\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]) == 182\n assert candidate(nums = [9, 4, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441]) == 477\n assert candidate(nums = [25, 16, 9, 4, 1, 64, 49, 36, 25, 16, 9, 4, 1, 144, 121, 100, 81, 64, 49, 36, 25, 16, 9, 4, 1, 361, 324, 289, 256, 225, 196, 169, 144, 121, 100, 81, 64, 49, 36, 25, 16, 9, 4, 1, 841, 810, 784, 756, 729, 676, 625, 576, 529, 484, 441, 400, 361, 324, 289, 256, 225, 196, 169, 144, 121, 100, 81, 64, 49, 36, 25, 16, 9, 4, 1]) == 1109\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumSum(List nums) {", "container": "Solution", "callable": "maximumSum", "parameters": [{"name": "nums", "type": "List"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2864, "task_id": "maximum-odd-binary-number", "difficulty": "Easy", "problem_description": "You are given a binary string s that contains at least one '1'.\nYou have to rearrange the bits in such a way that the resulting binary number is the maximum odd binary number that can be created from this combination.\nReturn a string representing the maximum odd binary number that can be created from the given combination.\nNote that the resulting string can have leading zeros.\n \nExample 1:\n\nInput: s = \"010\"\nOutput: \"001\"\nExplanation: Because there is just one '1', it must be in the last position. So the answer is \"001\".\n\nExample 2:\n\nInput: s = \"0101\"\nOutput: \"1001\"\nExplanation: One of the '1's must be in the last position. The maximum number that can be made with the remaining digits is \"100\". So the answer is \"1001\".\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consists only of '0' and '1'.\ns contains at least one '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == \"1111\"\n assert candidate(s = \"101010101\") == \"111100001\"\n assert candidate(s = \"110011\") == \"111001\"\n assert candidate(s = \"111\") == \"111\"\n assert candidate(s = \"1110\") == \"1101\"\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000000000000001\") == \"0000000000000000000000000000000000000000000000000000000000000001\"\n assert candidate(s = \"111000\") == \"110001\"\n assert candidate(s = \"1001001\") == \"1100001\"\n assert candidate(s = \"001010\") == \"100001\"\n assert candidate(s = \"1100\") == \"1001\"\n assert candidate(s = \"100001\") == \"100001\"\n assert candidate(s = \"010\") == \"001\"\n assert candidate(s = \"001001001\") == \"110000001\"\n assert candidate(s = \"0101\") == \"1001\"\n assert candidate(s = \"000001\") == \"000001\"\n assert candidate(s = \"10001\") == \"10001\"\n assert candidate(s = \"1100001\") == \"1100001\"\n assert candidate(s = \"11111\") == \"11111\"\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101\") == \"1111111111111111111111111111111000000000000000000000000000000001\"\n assert candidate(s = \"101010\") == \"110001\"\n assert candidate(s = \"00001\") == \"00001\"\n assert candidate(s = \"1000\") == \"0001\"\n assert candidate(s = \"11100\") == \"11001\"\n assert candidate(s = \"0101010101\") == \"1111000001\"\n assert candidate(s = \"0001\") == \"0001\"\n assert candidate(s = \"11001001\") == \"11100001\"\n assert candidate(s = \"101010101010101010\") == \"111111110000000001\"\n assert candidate(s = \"01010101010101010101010101010101\") == \"11111111111111100000000000000001\"\n assert candidate(s = \"101010101010101\") == \"111111100000001\"\n assert candidate(s = \"00100100101010\") == \"11110000000001\"\n assert candidate(s = \"00000000000000000000001\") == \"00000000000000000000001\"\n assert candidate(s = \"1111000011110000\") == \"1111111000000001\"\n assert candidate(s = \"10000000000000000000000000000000000000000000000000000000000000001\") == \"10000000000000000000000000000000000000000000000000000000000000001\"\n assert candidate(s = \"1000001\") == \"1000001\"\n assert candidate(s = \"1001001001001001001001\") == \"1111111000000000000001\"\n assert candidate(s = \"00000000001\") == \"00000000001\"\n assert candidate(s = \"010011001100\") == \"111100000001\"\n assert candidate(s = \"100011100111\") == \"111111000001\"\n assert candidate(s = \"0000100010001\") == \"1100000000001\"\n assert candidate(s = \"1111000010\") == \"1111000001\"\n assert candidate(s = \"00000000000000000000000000000001\") == \"00000000000000000000000000000001\"\n assert candidate(s = \"00010010101\") == \"11100000001\"\n assert candidate(s = \"11110000\") == \"11100001\"\n assert candidate(s = \"1111111111110\") == \"1111111111101\"\n assert candidate(s = \"11010101010101010101\") == \"11111111110000000001\"\n assert candidate(s = \"00000001\") == \"00000001\"\n assert candidate(s = \"1111111111\") == \"1111111111\"\n assert candidate(s = \"010101010101\") == \"111110000001\"\n assert candidate(s = \"1010101010101010101\") == \"1111111110000000001\"\n assert candidate(s = \"000000000001\") == \"000000000001\"\n assert candidate(s = \"11111111111111110000\") == \"11111111111111100001\"\n assert candidate(s = \"11111111111111111111\") == \"11111111111111111111\"\n assert candidate(s = \"0010101010\") == \"1110000001\"\n assert candidate(s = \"11111111111111111111111111111111\") == \"11111111111111111111111111111111\"\n assert candidate(s = \"00000000000000000001\") == \"00000000000000000001\"\n assert candidate(s = \"1111111111111111\") == \"1111111111111111\"\n assert candidate(s = \"0000111111\") == \"1111100001\"\n assert candidate(s = \"111000011\") == \"111100001\"\n assert candidate(s = \"01010101010101010101\") == \"11111111100000000001\"\n assert candidate(s = \"1001101\") == \"1110001\"\n assert candidate(s = \"1100000000000000000000000000000001\") == \"1100000000000000000000000000000001\"\n assert candidate(s = \"111110000000\") == \"111100000001\"\n assert candidate(s = \"11111000000\") == \"11110000001\"\n assert candidate(s = \"10000000000\") == \"00000000001\"\n assert candidate(s = \"110100110\") == \"111100001\"\n assert candidate(s = \"1010101010\") == \"1111000001\"\n assert candidate(s = \"010101010101010101\") == \"111111110000000001\"\n assert candidate(s = \"1000000000000000000001\") == \"1000000000000000000001\"\n assert candidate(s = \"11111110000000000000000000000000\") == \"11111100000000000000000000000001\"\n assert candidate(s = \"1101001\") == \"1110001\"\n assert candidate(s = \"11001100\") == \"11100001\"\n assert candidate(s = \"1010101010101010\") == \"1111111000000001\"\n assert candidate(s = \"110000000000001\") == \"110000000000001\"\n assert candidate(s = \"1111111111111111111111\") == \"1111111111111111111111\"\n assert candidate(s = \"111000011000\") == \"111100000001\"\n assert candidate(s = \"0101010101010101010101\") == \"1111111111000000000001\"\n assert candidate(s = \"100010001\") == \"110000001\"\n assert candidate(s = \"10011001100110011001100110011001\") == \"11111111111111100000000000000001\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maximumOddBinaryNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String maximumOddBinaryNumber(String s) {", "container": "Solution", "callable": "maximumOddBinaryNumber", "parameters": [{"name": "s", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2865, "task_id": "beautiful-towers-i", "difficulty": "Medium", "problem_description": "You are given an array heights of n integers representing the number of bricks in n consecutive towers. Your task is to remove some bricks to form a mountain-shaped tower arrangement. In this arrangement, the tower heights are non-decreasing, reaching a maximum peak value with one or multiple consecutive towers and then non-increasing.\nReturn the maximum possible sum of heights of a mountain-shaped tower arrangement.\n \nExample 1:\n\nInput: heights = [5,3,4,1,1]\nOutput: 13\nExplanation:\nWe remove some bricks to make heights = [5,3,3,1,1], the peak is at index 0.\n\nExample 2:\n\nInput: heights = [6,5,3,9,2,7]\nOutput: 22\nExplanation:\nWe remove some bricks to make heights = [3,3,3,9,2,2], the peak is at index 3.\n\nExample 3:\n\nInput: heights = [3,2,5,5,2,3]\nOutput: 18\nExplanation:\nWe remove some bricks to make heights = [2,2,5,5,2,2], the peak is at index 2 or 3.\n\n \nConstraints:\n\n1 <= n == heights.length <= 103\n1 <= heights[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [1, 3, 5, 7, 9, 7, 5, 3, 1]) == 41\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(heights = [7, 4, 7, 4, 7]) == 23\n assert candidate(heights = [3, 2, 5, 5, 2, 3]) == 18\n assert candidate(heights = [1, 2, 3, 4, 5]) == 15\n assert candidate(heights = [1, 2, 3, 2, 1]) == 9\n assert candidate(heights = [7, 4, 4, 4, 10, 6]) == 32\n assert candidate(heights = [1, 2, 1, 2, 1]) == 6\n assert candidate(heights = [9, 4, 8, 7, 5, 3, 2, 6, 1]) == 36\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(heights = [10, 9, 2, 5, 3, 7, 20]) == 39\n assert candidate(heights = [8, 6, 5, 7, 9]) == 31\n assert candidate(heights = [1, 3, 3, 3, 3, 3, 3, 2, 1]) == 22\n assert candidate(heights = [1, 3, 2, 3, 1]) == 9\n assert candidate(heights = [10, 20, 10, 20, 10]) == 60\n assert candidate(heights = [1, 1, 1, 1, 1]) == 5\n assert candidate(heights = [5, 3, 4, 1, 1]) == 13\n assert candidate(heights = [10, 20, 10]) == 40\n assert candidate(heights = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 13\n assert candidate(heights = [6, 5, 3, 9, 2, 7]) == 22\n assert candidate(heights = [5, 4, 3, 2, 1]) == 15\n assert candidate(heights = [5, 5, 5, 5, 5, 5]) == 30\n assert candidate(heights = [10, 9, 8, 7, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 109\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 36\n assert candidate(heights = [5, 1, 5, 10, 15, 10, 5, 1, 5]) == 49\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 10, 10, 5, 4, 3, 2, 1]) == 60\n assert candidate(heights = [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]) == 108\n assert candidate(heights = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 104\n assert candidate(heights = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 83\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(heights = [1, 2, 3, 4, 3, 2, 3, 4, 3, 2, 1]) == 24\n assert candidate(heights = [1, 5, 1, 7, 1, 9, 1, 11, 1, 13, 1, 15, 1]) == 27\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == 70\n assert candidate(heights = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 215\n assert candidate(heights = [1, 1, 1, 1, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1]) == 59\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(heights = [3, 3, 3, 3, 3, 6, 3, 3, 3, 3, 3]) == 36\n assert candidate(heights = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 56\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 55\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 761\n assert candidate(heights = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 330\n assert candidate(heights = [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, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 58\n assert candidate(heights = [1, 1, 1, 10, 1, 1, 1, 10, 1, 1, 1]) == 20\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 1, 2, 3, 4, 5]) == 30\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 46\n assert candidate(heights = [3, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 93\n assert candidate(heights = [1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1]) == 20\n assert candidate(heights = [1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 1000000018\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == 70\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 65\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 605\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 40\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 550\n assert candidate(heights = [9, 9, 9, 10, 9, 9, 9, 10, 9, 9, 9, 10, 9, 9, 9]) == 136\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9000000020\n assert candidate(heights = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 29\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 46\n assert candidate(heights = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 75\n assert candidate(heights = [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, 2, 3, 4, 5]) == 112\n assert candidate(heights = [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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 120\n assert candidate(heights = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 17\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 112\n assert candidate(heights = [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, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 374\n assert candidate(heights = [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]) == 26\n assert candidate(heights = [10, 20, 30, 25, 35, 40, 30, 20, 10]) == 215\n assert candidate(heights = [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]) == 400\n assert candidate(heights = [7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, 7, 7]) == 37\n assert candidate(heights = [5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5]) == 150\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(heights = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5]) == 207\n assert candidate(heights = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 100\n assert candidate(heights = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 42\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 55\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 1, 2, 3, 4, 3, 2, 1]) == 26\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 64\n assert candidate(heights = [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(heights = [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]) == 82\n assert candidate(heights = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 129\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10]) == 66\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 650\n assert candidate(heights = [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]) == 110\n assert candidate(heights = [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]) == 43\n assert candidate(heights = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 201\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1000\n assert candidate(heights = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(heights = [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]) == 109\n assert candidate(heights = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 125\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 64\n assert candidate(heights = [1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 49\n assert candidate(heights = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 24\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\n assert candidate(heights = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 33\n assert candidate(heights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 210\n assert candidate(heights = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 10999999945\n assert candidate(heights = [10, 20, 30, 40, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45]) == 385\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(heights = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 4999999990\n assert candidate(heights = [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]) == 45\n assert candidate(heights = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 100\n assert candidate(heights = [10, 20, 15, 10, 15, 20, 10, 5, 10, 15, 20, 25]) == 110\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10]) == 75\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 210\n assert candidate(heights = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 109\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 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(heights = [1, 2, 3, 4, 5, 100, 5, 4, 3, 2, 1, 2, 3, 4, 5, 100, 5, 4, 3, 2, 1]) == 140\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 560\n assert candidate(heights = [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]) == 33\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10]) == 460\n assert candidate(heights = [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]) == 87\n assert candidate(heights = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(heights = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1010\n assert candidate(heights = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 45\n assert candidate(heights = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 60\n assert candidate(heights = [100, 10, 1, 100, 10, 1, 100, 10, 1, 100, 10, 1, 100, 10, 1, 100]) == 124\n assert candidate(heights = [5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5]) == 45\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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]) == 57\n assert candidate(heights = [5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 71\n assert candidate(heights = [1, 1, 1, 1, 10, 1, 1, 1, 1]) == 18\n assert candidate(heights = [2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 31\n assert candidate(heights = [1, 3, 2, 3, 4, 5, 3, 2, 1]) == 23\n assert candidate(heights = [6, 5, 4, 3, 2, 1]) == 21\n assert candidate(heights = [1, 5, 3, 7, 5, 3, 1]) == 23\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 550\n assert candidate(heights = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 6000000000\n assert candidate(heights = [10, 10, 10, 10, 10]) == 50\n assert candidate(heights = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 20\n assert candidate(heights = [1000000000, 1000000000, 1000000000]) == 3000000000\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(heights = [1, 3, 2, 4, 3, 5, 4, 6, 5]) == 30\n assert candidate(heights = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 9999999955\n assert candidate(heights = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(heights = [9, 4, 8, 7, 5, 6, 3, 2, 1]) == 39\n assert candidate(heights = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 19\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 11\n assert candidate(heights = [10, 20, 30, 40, 50, 40, 30, 20, 10]) == 250\n assert candidate(heights = [9, 8, 7, 8, 9]) == 38\n assert candidate(heights = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 109\n assert candidate(heights = [1, 3, 2, 5, 4, 6, 5, 7, 6]) == 36\n assert candidate(heights = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 99\n assert candidate(heights = [5, 6, 7, 8, 9, 8, 7, 6, 5]) == 61\n assert candidate(heights = [9, 4, 2, 1, 3, 5, 7, 6, 8, 10]) == 42\n assert candidate(heights = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 19\n assert candidate(heights = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 30\n assert candidate(heights = [1, 2, 3, 2, 3, 4, 3, 4, 5]) == 25\n assert candidate(heights = [1, 3, 2, 1, 2, 1, 3, 1]) == 11\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(heights = [1, 2, 3, 4, 5, 1, 1, 1, 1, 1]) == 20\n assert candidate(heights = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 13\n assert candidate(heights = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(heights = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 19\n assert candidate(heights = [1, 3, 2, 1, 2, 3, 1, 2, 3, 1]) == 13\n assert candidate(heights = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(heights = [1, 3, 2, 3, 1]) == 9\n assert candidate(heights = [1, 2, 1, 2, 1, 2]) == 7\n assert candidate(heights = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 13\n assert candidate(heights = [1, 2, 1]) == 4\n assert candidate(heights = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5000000000\n assert candidate(heights = [1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 23\n assert candidate(heights = [1000000000, 1, 1000000000, 1, 1000000000]) == 1000000004\n assert candidate(heights = [2, 1, 2]) == 4\n assert candidate(heights = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 36\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10]) == 62\n assert candidate(heights = [10, 20, 10, 30, 10, 40, 10]) == 100\n assert candidate(heights = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5000000000\n assert candidate(heights = [1, 2, 3, 4, 3, 2, 1]) == 16\n assert candidate(heights = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(heights = [1, 1, 1, 1, 1, 5, 4, 3, 2, 1]) == 20\n assert candidate(heights = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 25\n assert candidate(heights = [1, 3, 2, 1, 2, 3, 2, 1]) == 12\n assert candidate(heights = [9, 4, 4, 7, 2]) == 23\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11]) == 52\n assert candidate(heights = [1, 3, 2, 1]) == 7\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(heights = [1, 3, 5, 4, 7, 5, 6, 4, 3, 8, 9, 1]) == 43\n assert candidate(heights = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10000000000\n assert candidate(heights = [1, 5, 3, 5, 1]) == 13\n assert candidate(heights = [1000000000, 1000000000, 1000000000, 1000000000]) == 4000000000\n assert candidate(heights = [1000000000, 1000000000, 1000000000]) == 3000000000\n assert candidate(heights = [9, 7, 5, 3, 1, 3, 5, 7, 9]) == 29\n assert candidate(heights = [5, 4, 4, 4, 5]) == 21\n assert candidate(heights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 110\n"}, "metadata": {"canonical_parameter_names": ["heights"], "leetcode_dataset_entry_point": "Solution().maximumSumOfHeights", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumSumOfHeights(int[] heights) {", "container": "Solution", "callable": "maximumSumOfHeights", "parameters": [{"name": "heights", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2866, "task_id": "beautiful-towers-ii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array maxHeights of n integers.\nYou are tasked with building n towers in the coordinate line. The ith tower is built at coordinate i and has a height of heights[i].\nA configuration of towers is beautiful if the following conditions hold:\n\n1 <= heights[i] <= maxHeights[i]\nheights is a mountain array.\n\nArray heights is a mountain if there exists an index i such that:\n\nFor all 0 < j <= i, heights[j - 1] <= heights[j]\nFor all i <= k < n - 1, heights[k + 1] <= heights[k]\n\nReturn the maximum possible sum of heights of a beautiful configuration of towers.\n \nExample 1:\n\nInput: maxHeights = [5,3,4,1,1]\nOutput: 13\nExplanation: One beautiful configuration with a maximum sum is heights = [5,3,3,1,1]. This configuration is beautiful since:\n- 1 <= heights[i] <= maxHeights[i] \n- heights is a mountain of peak i = 0.\nIt can be shown that there exists no other beautiful configuration with a sum of heights greater than 13.\nExample 2:\n\nInput: maxHeights = [6,5,3,9,2,7]\nOutput: 22\nExplanation: One beautiful configuration with a maximum sum is heights = [3,3,3,9,2,2]. This configuration is beautiful since:\n- 1 <= heights[i] <= maxHeights[i]\n- heights is a mountain of peak i = 3.\nIt can be shown that there exists no other beautiful configuration with a sum of heights greater than 22.\nExample 3:\n\nInput: maxHeights = [3,2,5,5,2,3]\nOutput: 18\nExplanation: One beautiful configuration with a maximum sum is heights = [2,2,5,5,2,2]. This configuration is beautiful since:\n- 1 <= heights[i] <= maxHeights[i]\n- heights is a mountain of peak i = 2. \nNote that, for this configuration, i = 3 can also be considered a peak.\nIt can be shown that there exists no other beautiful configuration with a sum of heights greater than 18.\n\n \nConstraints:\n\n1 <= n == maxHeights.length <= 105\n1 <= maxHeights[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(maxHeights = [1, 2, 3, 4, 5]) == 15\n assert candidate(maxHeights = [5, 4, 3, 2, 1]) == 15\n assert candidate(maxHeights = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5000000000\n assert candidate(maxHeights = [1, 3, 2, 4, 3, 5, 4, 6, 5]) == 30\n assert candidate(maxHeights = [10, 10, 10, 10, 10]) == 50\n assert candidate(maxHeights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(maxHeights = [1, 3, 2, 3, 1]) == 9\n assert candidate(maxHeights = [1, 3, 2, 1, 2, 3, 1, 2, 1]) == 12\n assert candidate(maxHeights = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5000000000\n assert candidate(maxHeights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(maxHeights = [3, 2, 5, 5, 2, 3]) == 18\n assert candidate(maxHeights = [7, 8, 9, 10, 9, 8, 7]) == 58\n assert candidate(maxHeights = [5, 3, 4, 1, 1]) == 13\n assert candidate(maxHeights = [4, 4, 4, 4, 4, 4, 4]) == 28\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 25\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 25\n assert candidate(maxHeights = [1, 1, 1, 1, 1]) == 5\n assert candidate(maxHeights = [6, 5, 3, 9, 2, 7]) == 22\n assert candidate(maxHeights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10]) == 66\n assert candidate(maxHeights = [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]) == 114\n assert candidate(maxHeights = [5, 5, 5, 5, 9, 5, 5, 5, 5]) == 49\n assert candidate(maxHeights = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 70\n assert candidate(maxHeights = [1, 10, 2, 8, 3, 7, 4, 6, 5]) == 30\n assert candidate(maxHeights = [3, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 6, 6]) == 54\n assert candidate(maxHeights = [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]) == 120\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 20\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 34\n assert candidate(maxHeights = [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]) == 40\n assert candidate(maxHeights = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 36\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3]) == 44\n assert candidate(maxHeights = [5, 6, 7, 8, 9, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4]) == 114\n assert candidate(maxHeights = [1, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 26\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3]) == 46\n assert candidate(maxHeights = [2, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10]) == 111\n assert candidate(maxHeights = [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]) == 118\n assert candidate(maxHeights = [1, 3, 2, 5, 4, 6, 5, 7, 6, 8]) == 43\n assert candidate(maxHeights = [3, 3, 3, 3, 3, 5, 5, 5, 5, 5]) == 40\n assert candidate(maxHeights = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 500\n assert candidate(maxHeights = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 44\n assert candidate(maxHeights = [7, 7, 7, 7, 1, 7, 7, 7, 7, 7]) == 40\n assert candidate(maxHeights = [5, 4, 4, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7]) == 85\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 120\n assert candidate(maxHeights = [5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 1, 1, 1, 1]) == 39\n assert candidate(maxHeights = [1, 5, 3, 7, 5, 9, 7, 11, 9, 13, 11, 9, 7, 5, 3, 1]) == 98\n assert candidate(maxHeights = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 60\n assert candidate(maxHeights = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 10, 15, 20, 25, 30, 25, 20, 15, 10]) == 300\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(maxHeights = [3, 3, 3, 3, 5, 5, 5, 5, 3, 3, 3, 3, 5, 5, 5, 5, 3, 3, 3, 3]) == 68\n assert candidate(maxHeights = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 25\n assert candidate(maxHeights = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 45\n assert candidate(maxHeights = [2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 2, 2]) == 73\n assert candidate(maxHeights = [1, 1, 1, 1, 10, 1, 1, 1, 1, 1]) == 19\n assert candidate(maxHeights = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 120\n assert candidate(maxHeights = [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]) == 26\n assert candidate(maxHeights = [10, 20, 30, 40, 50, 40, 30, 20, 10]) == 250\n assert candidate(maxHeights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 7, 4, 8, 3, 9, 2, 10, 1]) == 65\n assert candidate(maxHeights = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 9, 7, 5]) == 69\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 3, 2, 1]) == 41\n assert candidate(maxHeights = [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]) == 110\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3]) == 35\n assert candidate(maxHeights = [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]) == 42\n assert candidate(maxHeights = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(maxHeights = [5, 5, 5, 5, 6, 5, 5, 5, 5]) == 46\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 29\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(maxHeights = [5, 5, 5, 5, 5, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 51\n assert candidate(maxHeights = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 19\n assert candidate(maxHeights = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10]) == 110\n assert candidate(maxHeights = [1, 1, 1, 10, 1, 1, 10, 1, 1, 10, 1, 1, 1]) == 22\n assert candidate(maxHeights = [1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1]) == 29\n assert candidate(maxHeights = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10]) == 360\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1]) == 104\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1]) == 70\n assert candidate(maxHeights = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7]) == 68\n assert candidate(maxHeights = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 19\n assert candidate(maxHeights = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(maxHeights = [5, 5, 5, 5, 1, 5, 5, 5, 5]) == 25\n assert candidate(maxHeights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1000\n assert candidate(maxHeights = [5, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5]) == 90\n assert candidate(maxHeights = [3, 1, 3, 1, 3, 1, 3]) == 9\n assert candidate(maxHeights = [1, 5, 3, 8, 7, 2, 6, 4, 9, 0]) == 30\n assert candidate(maxHeights = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 85\n assert candidate(maxHeights = [3, 3, 3, 3, 10, 3, 3, 3, 3, 10, 3, 3, 3, 3]) == 49\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1]) == 65\n assert candidate(maxHeights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 650\n assert candidate(maxHeights = [1, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 20\n assert candidate(maxHeights = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 20\n assert candidate(maxHeights = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 150\n assert candidate(maxHeights = [1, 3, 2, 3, 4, 3, 2, 3, 1]) == 20\n assert candidate(maxHeights = [1, 3, 5, 7, 9, 11, 13, 15, 13, 11, 9, 7, 5, 3, 1]) == 113\n assert candidate(maxHeights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 65\n assert candidate(maxHeights = [2, 2, 3, 4, 5, 6, 5, 5, 5, 5, 6, 7, 8, 9, 10]) == 81\n assert candidate(maxHeights = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 101\n assert candidate(maxHeights = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7]) == 111\n assert candidate(maxHeights = [1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 103\n assert candidate(maxHeights = [9, 9, 9, 9, 9, 1, 1, 1, 1, 1]) == 50\n assert candidate(maxHeights = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(maxHeights = [100, 90, 80, 70, 60, 50, 60, 70, 80, 90, 100]) == 700\n assert candidate(maxHeights = [9, 7, 5, 3, 1, 1, 3, 5, 7, 9]) == 30\n assert candidate(maxHeights = [1, 3, 5, 7, 9, 7, 5, 3, 1]) == 41\n assert candidate(maxHeights = [1, 3, 5, 7, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 50\n assert candidate(maxHeights = [1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 1]) == 27\n assert candidate(maxHeights = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 53\n assert candidate(maxHeights = [100, 50, 50, 100, 50, 50, 100, 50, 50, 100]) == 550\n assert candidate(maxHeights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 64\n assert candidate(maxHeights = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 19\n assert candidate(maxHeights = [1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 1000000008\n assert candidate(maxHeights = [1, 2, 2, 3, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 3, 2, 2, 1]) == 28\n"}, "metadata": {"canonical_parameter_names": ["maxHeights"], "leetcode_dataset_entry_point": "Solution().maximumSumOfHeights", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumSumOfHeights(List maxHeights) {", "container": "Solution", "callable": "maximumSumOfHeights", "parameters": [{"name": "maxHeights", "type": "List"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2867, "task_id": "count-valid-paths-in-a-tree", "difficulty": "Hard", "problem_description": "There is an undirected tree with n nodes labeled from 1 to n. You are given the integer n and 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.\nReturn the number of valid paths in the tree.\nA path (a, b) is valid if there exists exactly one prime number among the node labels in the path from a to b.\nNote that:\n\nThe path (a, b) is a sequence of distinct nodes starting with node a and ending with node b such that every two adjacent nodes in the sequence share an edge in the tree.\nPath (a, b) and path (b, a) are considered the same and counted only once.\n\n \nExample 1:\n\n\nInput: n = 5, edges = [[1,2],[1,3],[2,4],[2,5]]\nOutput: 4\nExplanation: The pairs with exactly one prime number on the path between them are: \n- (1, 2) since the path from 1 to 2 contains prime number 2. \n- (1, 3) since the path from 1 to 3 contains prime number 3.\n- (1, 4) since the path from 1 to 4 contains prime number 2.\n- (2, 4) since the path from 2 to 4 contains prime number 2.\nIt can be shown that there are only 4 valid paths.\n\nExample 2:\n\n\nInput: n = 6, edges = [[1,2],[1,3],[2,4],[3,5],[3,6]]\nOutput: 6\nExplanation: The pairs with exactly one prime number on the path between them are: \n- (1, 2) since the path from 1 to 2 contains prime number 2.\n- (1, 3) since the path from 1 to 3 contains prime number 3.\n- (1, 4) since the path from 1 to 4 contains prime number 2.\n- (1, 6) since the path from 1 to 6 contains prime number 3.\n- (2, 4) since the path from 2 to 4 contains prime number 2.\n- (3, 6) since the path from 3 to 6 contains prime number 3.\nIt can be shown that there are only 6 valid paths.\n\n \nConstraints:\n\n1 <= n <= 105\nedges.length == n - 1\nedges[i].length == 2\n1 <= ui, vi <= n\nThe input is generated such that edges represent a valid tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8]]) == 8\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [3, 6]]) == 6\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == 18\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7]]) == 7\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9], [9, 10]]) == 12\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [4, 7]]) == 9\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == 6\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10]]) == 11\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 6], [4, 7]]) == 9\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [5, 10]]) == 11\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [2, 4], [2, 5]]) == 4\n assert candidate(n = 3,edges = [[1, 2], [2, 3]]) == 1\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12]]) == 13\n assert candidate(n = 20,edges = [[1, 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], [10, 20]]) == 47\n assert candidate(n = 25,edges = [[1, 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]]) == 63\n assert candidate(n = 50,edges = [[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]]) == 149\n assert candidate(n = 75,edges = [[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], [26, 51], [26, 52], [27, 53], [27, 54], [28, 55], [28, 56], [29, 57], [29, 58], [30, 59], [30, 60], [31, 61], [31, 62], [32, 63], [32, 64], [33, 65], [33, 66], [34, 67], [34, 68], [35, 69], [35, 70], [36, 71], [36, 72], [37, 73], [37, 74], [38, 75]]) == 348\n assert candidate(n = 50,edges = [[1, 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], [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]]) == 202\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15]]) == 34\n assert candidate(n = 15,edges = [[1, 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]]) == 27\n assert candidate(n = 100,edges = [[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], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [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], [51, 52], [52, 53], [53, 54], [54, 55], [55, 56], [56, 57], [57, 58], [58, 59], [59, 60], [61, 62], [62, 63], [63, 64], [64, 65], [65, 66], [66, 67], [67, 68], [68, 69], [69, 70], [71, 72], [72, 73], [73, 74], [74, 75], [75, 76], [76, 77], [77, 78], [78, 79], [79, 80], [81, 82], [82, 83], [83, 84], [84, 85], [85, 86], [86, 87], [87, 88], [88, 89], [89, 90], [91, 92], [92, 93], [93, 94], [94, 95], [95, 96], [96, 97], [97, 98], [98, 99], [99, 100]]) == 333\n assert candidate(n = 15,edges = [[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]]) == 18\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12]]) == 13\n assert candidate(n = 20,edges = [[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]]) == 33\n assert candidate(n = 40,edges = [[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]]) == 120\n assert candidate(n = 25,edges = [[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]]) == 41\n assert candidate(n = 100,edges = [[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], [30, 60], [30, 61], [31, 62], [31, 63], [32, 64], [32, 65], [33, 66], [33, 67], [34, 68], [34, 69], [35, 70], [35, 71], [36, 72], [36, 73], [37, 74], [37, 75], [38, 76], [38, 77], [39, 78], [39, 79], [40, 80], [40, 81], [41, 82], [41, 83], [42, 84], [42, 85], [43, 86], [43, 87], [44, 88], [44, 89], [45, 90], [45, 91], [46, 92], [46, 93], [47, 94], [47, 95], [48, 96], [48, 97], [49, 98], [49, 99], [50, 100]]) == 499\n assert candidate(n = 150,edges = [[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], [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]]) == 578\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 13], [7, 14], [8, 15]]) == 16\n assert candidate(n = 100,edges = [[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], [26, 51], [26, 52], [27, 53], [27, 54], [28, 55], [28, 56], [29, 57], [29, 58], [30, 59], [30, 60], [31, 61], [31, 62], [32, 63], [32, 64], [33, 65], [33, 66], [34, 67], [34, 68], [35, 69], [35, 70], [36, 71], [36, 72], [37, 73], [37, 74], [38, 75], [38, 76], [39, 77], [39, 78], [40, 79], [40, 80], [41, 81], [41, 82], [42, 83], [42, 84], [43, 85], [43, 86], [44, 87], [44, 88], [45, 89], [45, 90], [46, 91], [46, 92], [47, 93], [47, 94], [48, 95], [48, 96], [49, 97], [49, 98], [50, 99], [50, 100]]) == 517\n assert candidate(n = 30,edges = [[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]]) == 59\n assert candidate(n = 18,edges = [[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]]) == 27\n assert candidate(n = 50,edges = [[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], [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]]) == 138\n assert candidate(n = 100,edges = [[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], [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]]) == 368\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().countPaths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countPaths(int n, int[][] edges) {", "container": "Solution", "callable": "countPaths", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2869, "task_id": "minimum-operations-to-collect-elements", "difficulty": "Easy", "problem_description": "You are given an array nums of positive integers and an integer k.\nIn one operation, you can remove the last element of the array and add it to your collection.\nReturn the minimum number of operations needed to collect elements 1, 2, ..., k.\n \nExample 1:\n\nInput: nums = [3,1,5,4,2], k = 2\nOutput: 4\nExplanation: After 4 operations, we collect elements 2, 4, 5, and 1, in this order. Our collection contains elements 1 and 2. Hence, the answer is 4.\n\nExample 2:\n\nInput: nums = [3,1,5,4,2], k = 5\nOutput: 5\nExplanation: After 5 operations, we collect elements 2, 4, 5, 1, and 3, in this order. Our collection contains elements 1 through 5. Hence, the answer is 5.\n\nExample 3:\n\nInput: nums = [3,2,5,3,1], k = 3\nOutput: 4\nExplanation: After 4 operations, we collect elements 1, 3, 5, and 2, in this order. Our collection contains elements 1 through 3. Hence, the answer is 4.\n\n \nConstraints:\n\n1 <= nums.length <= 50\n1 <= nums[i] <= nums.length\n1 <= k <= nums.length\nThe input is generated such that you can collect elements 1, 2, ..., k.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 1, 2, 1, 2],k = 2) == 2\n assert candidate(nums = [2, 3, 1, 4, 5],k = 4) == 5\n assert candidate(nums = [3, 1, 5, 4, 2],k = 5) == 5\n assert candidate(nums = [4, 3, 2, 1, 5],k = 5) == 5\n assert candidate(nums = [2, 4, 6, 8, 10],k = 3) == None\n assert candidate(nums = [1, 2, 2, 3, 3],k = 3) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(nums = [5, 4, 3, 2, 1],k = 5) == 5\n assert candidate(nums = [1, 3, 2, 5, 4],k = 4) == 5\n assert candidate(nums = [2, 2, 2, 1, 3],k = 3) == 3\n assert candidate(nums = [5, 1, 2, 3, 4],k = 1) == 4\n assert candidate(nums = [3, 1, 5, 4, 2],k = 2) == 4\n assert candidate(nums = [1, 3, 5, 7, 9],k = 1) == 5\n assert candidate(nums = [1, 3, 5, 7, 9],k = 4) == None\n assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [2, 4, 3, 1, 5],k = 4) == 5\n assert candidate(nums = [2, 4, 1, 3, 5],k = 2) == 5\n assert candidate(nums = [2, 4, 1, 3, 5],k = 4) == 5\n assert candidate(nums = [5, 3, 1, 4, 2],k = 2) == 3\n assert candidate(nums = [3, 2, 5, 3, 1],k = 3) == 4\n assert candidate(nums = [5, 4, 3, 2, 1],k = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],k = 5) == 10\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 2, 3, 4, 5, 6],k = 6) == 6\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1],k = 7) == 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, 1],k = 1) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 8\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 = 10) == 10\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],k = 50) == 50\n assert candidate(nums = [5, 3, 2, 1, 4, 6, 7],k = 7) == 7\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],k = 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],k = 25) == 25\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],k = 7) == 7\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) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1],k = 5) == 5\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1],k = 3) == 3\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1],k = 3) == 10\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 20\n assert candidate(nums = [5, 3, 2, 1, 4, 6, 7, 8, 9, 10],k = 10) == 10\n assert candidate(nums = [4, 5, 3, 2, 1, 6, 7],k = 5) == 7\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 5) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(nums = [3, 6, 5, 2, 8, 7, 4, 1, 9, 10],k = 5) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 3) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1],k = 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, 1],k = 1) == 1\n assert candidate(nums = [2, 1, 1, 3, 1, 2, 1, 2, 3],k = 3) == 3\n assert candidate(nums = [2, 1, 5, 4, 3, 6, 8, 7, 10, 9, 12, 11],k = 6) == 12\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13],k = 13) == 13\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 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],k = 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 50) == 50\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],k = 20) == 20\n assert candidate(nums = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 15\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 7],k = 5) == 7\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 15\n assert candidate(nums = [6, 3, 1, 5, 4, 2, 7, 8, 9, 10],k = 10) == 10\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 = 20) == 20\n assert candidate(nums = [7, 1, 6, 2, 5, 3, 4, 8, 9, 10],k = 10) == 10\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3],k = 3) == 3\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],k = 5) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 10) == 10\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 1, 2, 3],k = 3) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 9\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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 1) == None\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == None\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 15\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],k = 25) == 25\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],k = 1) == None\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 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, 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 = 45) == 50\n assert candidate(nums = [7, 3, 5, 1, 2, 6, 4],k = 7) == 7\n assert candidate(nums = [5, 1, 4, 3, 2, 5, 1, 4, 3, 2, 5, 1, 4, 3, 2, 5, 1, 4, 3, 2],k = 5) == 5\n assert candidate(nums = [4, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2],k = 4) == 4\n assert candidate(nums = [3, 2, 1, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],k = 15) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(nums = [5, 3, 1, 2, 4, 6],k = 4) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == 9\n assert candidate(nums = [5, 1, 3, 4, 2, 5, 4, 3, 2, 1],k = 5) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 15\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 = 10) == 10\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(nums = [5, 3, 6, 1, 2, 8, 4, 7, 9, 10],k = 10) == 10\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 10\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10],k = 10) == 10\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 = 6) == 21\n assert candidate(nums = [5, 3, 1, 4, 2, 3, 1, 4, 2, 5],k = 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],k = 1) == None\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 5\n assert candidate(nums = [4, 3, 2, 1, 4, 3, 2, 1],k = 4) == 4\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 10) == 10\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 = 15) == 15\n assert candidate(nums = [3, 5, 1, 2, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 15\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 18\n assert candidate(nums = [3, 6, 5, 3, 7, 8, 9, 1, 2, 4, 5, 6, 7, 8, 9],k = 9) == 12\n assert candidate(nums = [4, 4, 4, 4, 4, 1, 2, 3, 4, 5],k = 5) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minOperations(List nums, int k) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "List"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2870, "task_id": "minimum-number-of-operations-to-make-array-empty", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums consisting of positive integers.\nThere are two types of operations that you can apply on the array any number of times:\n\nChoose two elements with equal values and delete them from the array.\nChoose three elements with equal values and delete them from the array.\n\nReturn the minimum number of operations required to make the array empty, or -1 if it is not possible.\n \nExample 1:\n\nInput: nums = [2,3,3,2,2,4,2,3,4]\nOutput: 4\nExplanation: We can apply the following operations to make the array empty:\n- Apply the first operation on the elements at indices 0 and 3. The resulting array is nums = [3,3,2,4,2,3,4].\n- Apply the first operation on the elements at indices 2 and 4. The resulting array is nums = [3,3,4,3,4].\n- Apply the second operation on the elements at indices 0, 1, and 3. The resulting array is nums = [4,4].\n- Apply the first operation on the elements at indices 0 and 1. The resulting array is nums = [].\nIt can be shown that we cannot make the array empty in less than 4 operations.\n\nExample 2:\n\nInput: nums = [2,1,2,2,3,3]\nOutput: -1\nExplanation: It is impossible to empty the array.\n\n \nConstraints:\n\n2 <= nums.length <= 105\n1 <= nums[i] <= 106\n\n \nNote: This question is the same as 2244: Minimum Rounds to Complete All Tasks.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 5\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 6\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 4\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3]) == 4\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 4\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 3]) == -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]) == 10\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(nums = [1000000, 1000000, 1000000]) == 1\n assert candidate(nums = [2, 1, 2, 2, 3, 3]) == -1\n assert candidate(nums = [2, 3, 3, 2, 2, 4, 2, 3, 4]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -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]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2]) == 3\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 5\n assert candidate(nums = [1000000, 1000000, 1000000]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 6\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 7\n assert candidate(nums = [10, 10, 10, 20, 20, 20, 20, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 12\n assert candidate(nums = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50, 60, 60, 60, 70, 70, 70]) == 7\n assert candidate(nums = [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]) == 9\n assert candidate(nums = [36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37]) == 14\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 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, 8, 8, 8, 8, 8, 8]) == 15\n assert candidate(nums = [48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49]) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 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, 6, 6, 6, 6, 6, 6, 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]) == 23\n assert candidate(nums = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36]) == 19\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 8\n assert candidate(nums = [6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 11\n assert candidate(nums = [43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45]) == 24\n assert candidate(nums = [26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 9\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, 9]) == -1\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30]) == 8\n assert candidate(nums = [1, 1, 1, 1, 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, 3, 3]) == 12\n assert candidate(nums = [10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40]) == 16\n assert candidate(nums = [10, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 12\n assert candidate(nums = [40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41]) == 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, 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 = [38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39]) == 15\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]) == -1\n assert candidate(nums = [24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 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]) == -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, 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]) == 18\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 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, 5, 5, 5, 5, 5, 5]) == 16\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\n assert candidate(nums = [18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 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]) == 19\n assert candidate(nums = [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20]) == 21\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 10\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]) == 15\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]) == 14\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]) == 12\n assert candidate(nums = [11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15]) == 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, 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]) == 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, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == 16\n assert candidate(nums = [1, 2, 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]) == -1\n assert candidate(nums = [26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 19\n assert candidate(nums = [24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27]) == 19\n assert candidate(nums = [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]) == 12\n assert candidate(nums = [11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]) == 18\n assert candidate(nums = [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]) == 18\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]) == 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]) == -1\n assert candidate(nums = [44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45]) == 19\n assert candidate(nums = [20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23]) == 9\n assert candidate(nums = [100, 100, 100, 100, 101, 101, 101, 102, 102, 102, 102, 102, 103, 103, 103, 103, 103, 103, 103, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104]) == 12\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]) == 18\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, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43]) == 18\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, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 26\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, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 14\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == -1\n assert candidate(nums = [10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13]) == 8\n assert candidate(nums = [33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35]) == 13\n assert candidate(nums = [37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39]) == 17\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]) == 15\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]) == 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, 5]) == 7\n assert candidate(nums = [16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]) == 9\n assert candidate(nums = [28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 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, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 22\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 10\n assert candidate(nums = [21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 18\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 20\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]) == 19\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 4]) == 18\n assert candidate(nums = [1, 1, 2, 2, 2, 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, 4, 4]) == 13\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 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, 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, 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]) == 12\n assert candidate(nums = [1, 1, 2, 2, 2, 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, 5, 5, 5, 5]) == 13\n assert candidate(nums = [8, 8, 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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 22\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, 10, 10]) == -1\n assert candidate(nums = [11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 20\n assert candidate(nums = [40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 19\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]) == 12\n assert candidate(nums = [1, 1, 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]) == 15\n assert candidate(nums = [46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47]) == 20\n assert candidate(nums = [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, 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, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 27\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4]) == 9\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minOperations(int[] nums) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2871, "task_id": "split-array-into-maximum-number-of-subarrays", "difficulty": "Medium", "problem_description": "You are given an array nums consisting of non-negative integers.\nWe define the score of subarray nums[l..r] such that l <= r as nums[l] AND nums[l + 1] AND ... AND nums[r] where AND is the bitwise AND operation.\nConsider splitting the array into one or more subarrays such that the following conditions are satisfied:\n\nEach element of the array belongs to exactly one subarray.\nThe sum of scores of the subarrays is the minimum possible.\n\nReturn the maximum number of subarrays in a split that satisfies the conditions above.\nA subarray is a contiguous part of an array.\n \nExample 1:\n\nInput: nums = [1,0,2,0,1,2]\nOutput: 3\nExplanation: We can split the array into the following subarrays:\n- [1,0]. The score of this subarray is 1 AND 0 = 0.\n- [2,0]. The score of this subarray is 2 AND 0 = 0.\n- [1,2]. The score of this subarray is 1 AND 2 = 0.\nThe sum of scores is 0 + 0 + 0 = 0, which is the minimum possible score that we can obtain.\nIt can be shown that we cannot split the array into more than 3 subarrays with a total score of 0. So we return 3.\n\nExample 2:\n\nInput: nums = [5,7,1,3]\nOutput: 1\nExplanation: We can split the array into one subarray: [5,7,1,3] with a score of 1, which is the minimum possible score that we can obtain.\nIt can be shown that we cannot split the array into more than 1 subarray with a total score of 1. So we return 1.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [8, 12, 10, 14, 6, 7]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047]) == 1\n assert candidate(nums = [8, 8, 8, 8, 8]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9]) == 1\n assert candidate(nums = [15, 9, 8, 7, 14]) == 1\n assert candidate(nums = [8, 6, 7, 12, 0, 1]) == 2\n assert candidate(nums = [5, 7, 1, 3]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 4\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [8, 12, 10, 6, 14, 1, 9, 5, 3, 11, 7, 13, 2, 4]) == 3\n assert candidate(nums = [8, 12, 4, 6]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 5\n assert candidate(nums = [1, 0, 2, 0, 1, 2]) == 3\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 2\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]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 5\n assert candidate(nums = [8, 12, 10, 14, 6, 14, 10, 12, 8, 14, 10, 12, 8, 6, 14, 10, 12, 8]) == 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 = [255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256]) == 5\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 7\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 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]) == 10\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == 1\n assert candidate(nums = [8, 4, 2, 1, 8, 4, 2, 1, 8, 4, 2, 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]) == 10\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 255, 127, 63, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 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]) == 1\n assert candidate(nums = [1, 2, 3, 0, 4, 5, 0, 6, 7, 8, 0]) == 5\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511]) == 1\n assert candidate(nums = [15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]) == 1\n assert candidate(nums = [31, 15, 7, 3, 1, 31, 15, 7, 3, 1, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 1\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]) == 10\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, 0]) == 1\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986]) == 1\n assert candidate(nums = [15, 7, 15, 7, 15, 7, 15, 7, 15, 7, 15, 7, 15, 7, 15, 7, 15, 7, 15, 7]) == 1\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255]) == 1\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 3\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 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]) == 1\n assert candidate(nums = [1, 15, 3, 15, 3, 15, 3, 15, 3, 15]) == 1\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == 1\n assert candidate(nums = [16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240]) == 3\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 = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336]) == 3\n assert candidate(nums = [1, 0, 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, 0, 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, 0]) == 6\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 5\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 4\n assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008]) == 1\n assert candidate(nums = [3, 1, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 1\n assert candidate(nums = [31, 31, 31, 31, 31, 0, 31, 31, 31, 31, 31, 0, 31, 31, 31, 31, 31]) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 7\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 8\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 2\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095]) == 1\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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 1\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 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]) == 10\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023]) == 1\n assert candidate(nums = [16, 16, 16, 16, 16, 16, 16, 16, 16, 16]) == 1\n assert candidate(nums = [8, 4, 2, 1, 16, 8, 4, 2, 32, 16, 8, 4, 64, 32, 16, 8, 128, 64, 32, 16, 256, 128, 64, 32, 512, 256, 128, 64]) == 14\n assert candidate(nums = [16, 8, 4, 2, 1, 16, 8, 4, 2, 1, 16, 8, 4, 2, 1, 16, 8, 4, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [16, 8, 4, 2, 1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 7\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0]) == 5\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 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]) == 10\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(nums = [1, 0, 3, 2, 1, 0, 3, 2, 1, 0]) == 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]) == 4\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 4\n assert candidate(nums = [31, 62, 124, 248, 496, 992, 1984, 3968, 7936, 15872]) == 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, 0]) == 16\n assert candidate(nums = [15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == 1\n assert candidate(nums = [8, 4, 2, 1, 8, 4, 2, 1, 8, 4]) == 5\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 8\n assert candidate(nums = [31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095]) == 1\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, 0]) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]) == 1\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79]) == 1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255]) == 1\n assert candidate(nums = [2, 1, 5, 6, 0, 3, 8, 0, 9, 7, 0, 11, 4, 0, 13, 12, 0, 15, 14, 0, 16, 17, 0, 18, 19, 0, 20, 21]) == 11\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 9\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15]) == 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, 51, 53, 55, 57, 59, 61, 63, 0, 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, 0]) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxSubarrays(int[] nums) {", "container": "Solution", "callable": "maxSubarrays", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2872, "task_id": "maximum-number-of-k-divisible-components", "difficulty": "Hard", "problem_description": "There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and 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 values of length n, where values[i] is the value associated with the ith node, and an integer k.\nA valid split of the tree is obtained by removing any set of edges, possibly empty, from the tree such that the resulting components all have values that are divisible by k, where the value of a connected component is the sum of the values of its nodes.\nReturn the maximum number of components in any valid split.\n \nExample 1:\n\n\nInput: n = 5, edges = [[0,2],[1,2],[1,3],[2,4]], values = [1,8,1,4,4], k = 6\nOutput: 2\nExplanation: We remove the edge connecting node 1 with 2. The resulting split is valid because:\n- The value of the component containing nodes 1 and 3 is values[1] + values[3] = 12.\n- The value of the component containing nodes 0, 2, and 4 is values[0] + values[2] + values[4] = 6.\nIt can be shown that no other valid split has more than 2 connected components.\nExample 2:\n\n\nInput: n = 7, edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]], values = [3,0,6,1,5,2,1], k = 3\nOutput: 3\nExplanation: We remove the edge connecting node 0 with 2, and the edge connecting node 0 with 1. The resulting split is valid because:\n- The value of the component containing node 0 is values[0] = 3.\n- The value of the component containing nodes 2, 5, and 6 is values[2] + values[5] + values[6] = 9.\n- The value of the component containing nodes 1, 3, and 4 is values[1] + values[3] + values[4] = 6.\nIt can be shown that no other valid split has more than 3 connected components.\n\n \nConstraints:\n\n1 <= n <= 3 * 104\nedges.length == n - 1\nedges[i].length == 2\n0 <= ai, bi < n\nvalues.length == n\n0 <= values[i] <= 109\n1 <= k <= 109\nSum of values is divisible by k.\nThe input is generated such that edges represents a valid tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [2, 3], [2, 4], [2, 5]],values = [2, 10, 5, 1, 1, 1],k = 5) == 2\n assert candidate(n = 5,edges = [[0, 2], [1, 2], [1, 3], [2, 4]],values = [1, 8, 1, 4, 4],k = 6) == 2\n assert candidate(n = 3,edges = [[0, 1], [0, 2]],values = [1, 1, 1],k = 2) == 0\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [1, 3]],values = [4, 6, 5, 9],k = 3) == 2\n assert candidate(n = 3,edges = [[0, 1], [1, 2]],values = [3, 9, 12],k = 3) == 3\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [1, 3]],values = [5, 5, 5, 5],k = 5) == 4\n assert candidate(n = 4,edges = [[0, 1], [2, 3], [1, 2]],values = [4, 4, 4, 4],k = 4) == 4\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],values = [3, 0, 6, 1, 5, 2, 1],k = 3) == 3\n assert candidate(n = 3,edges = [[0, 1], [0, 2]],values = [3, 0, 6],k = 3) == 3\n assert candidate(n = 3,edges = [[0, 1], [0, 2]],values = [1, 2, 3],k = 1) == 3\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5]],values = [12, 6, 6, 6, 6, 6],k = 12) == 0\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [0, 3], [3, 4], [3, 5]],values = [15, 15, 15, 15, 15, 15],k = 15) == 6\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [1, 3]],values = [4, 4, 4, 4],k = 4) == 4\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],values = [6, 6, 6, 6, 6, 6],k = 6) == 6\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],values = [6, 3, 9, 1, 12, 15, 3, 9, 6, 6],k = 3) == 7\n assert candidate(n = 25,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], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24]],values = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225],k = 9) == 25\n assert candidate(n = 20,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]],values = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 2) == 20\n assert candidate(n = 20,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]],values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 20\n assert candidate(n = 25,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], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24]],values = [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) == 25\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],values = [6, 12, 18, 3, 3, 6, 9, 3, 6, 6],k = 3) == 10\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],values = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],k = 3) == 12\n assert candidate(n = 50,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], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24], [9, 25], [10, 26], [10, 27], [11, 28], [11, 29], [12, 30], [12, 31], [12, 32], [13, 33], [13, 34], [14, 35], [14, 36], [15, 37], [15, 38], [16, 39], [16, 40], [17, 41], [17, 42], [18, 43], [18, 44], [19, 45], [19, 46], [20, 47], [20, 48], [21, 49]],values = [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],k = 11) == 50\n assert candidate(n = 25,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]],values = [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) == 25\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7], [3, 8], [3, 9]],values = [10, 15, 20, 25, 30, 5, 3, 4, 2, 1],k = 5) == 4\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]],values = [10, 20, 30, 40, 50, 60, 70, 80],k = 10) == 8\n assert candidate(n = 15,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]],values = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 3) == 15\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 2) == 7\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],values = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 10\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 4\n assert candidate(n = 25,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]],values = [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],k = 3) == 25\n assert candidate(n = 20,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]],values = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120],k = 6) == 20\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1) == 9\n assert candidate(n = 15,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]],values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 15\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],values = [7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7) == 9\n assert candidate(n = 20,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]],values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 20\n assert candidate(n = 30,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], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [11, 27], [11, 28], [12, 29]],values = [1, 1, 1, 1, 1, 1, 1, 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) == 30\n assert candidate(n = 20,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], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19]],values = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 2) == 20\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11]],values = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 9) == 12\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],values = [12, 15, 3, 6, 9, 18, 21, 12, 15, 9],k = 3) == 10\n assert candidate(n = 20,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]],values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 20\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11]],values = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 3) == 12\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],values = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],k = 7) == 12\n assert candidate(n = 20,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]],values = [5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 5],k = 5) == 20\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]],values = [7, 14, 21, 28, 35, 42, 49, 56],k = 7) == 8\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],values = [11, 22, 33, 11, 22, 33, 11, 22, 33, 11, 11],k = 11) == 11\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]],values = [1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 2\n assert candidate(n = 20,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]],values = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 20\n assert candidate(n = 15,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]],values = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90],k = 6) == 15\n assert candidate(n = 25,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], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24]],values = [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 = 5) == 25\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],values = [25, 50, 75, 100, 125, 150, 175, 200, 225],k = 25) == 9\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 3) == 4\n assert candidate(n = 18,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], [8, 16], [9, 17]],values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 18\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11]],values = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96],k = 8) == 12\n assert candidate(n = 30,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]],values = [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],k = 20) == 30\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14]],values = [6, 3, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 3) == 15\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],values = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 7) == 10\n assert candidate(n = 20,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]],values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 20\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],values = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 10\n assert candidate(n = 30,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], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24], [9, 25], [10, 26], [10, 27], [11, 28], [11, 29]],values = [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],k = 7) == 30\n assert candidate(n = 20,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]],values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 20\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 1\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7]],values = [8, 8, 8, 8, 8, 8, 8, 8],k = 8) == 8\n assert candidate(n = 20,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]],values = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 4) == 12\n assert candidate(n = 16,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]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 3) == 5\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],values = [6, 12, 18, 24, 30, 36, 42, 48, 54],k = 18) == 4\n assert candidate(n = 15,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]],values = [3, 0, 6, 1, 5, 2, 1, 4, 3, 2, 1, 0, 5, 4, 3],k = 3) == 4\n assert candidate(n = 15,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]],values = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90],k = 6) == 15\n assert candidate(n = 15,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]],values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 5) == 15\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]],values = [2, 4, 6, 8, 10, 12, 14, 16],k = 4) == 5\n assert candidate(n = 15,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]],values = [15, 30, 45, 10, 10, 30, 45, 10, 10, 30, 10, 10, 30, 10, 10],k = 15) == 4\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 3) == 5\n assert candidate(n = 15,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]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 4\n assert candidate(n = 18,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]],values = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108],k = 6) == 18\n assert candidate(n = 25,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]],values = [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 = 5) == 11\n assert candidate(n = 35,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], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [11, 27], [11, 28], [12, 29], [12, 30], [13, 31], [13, 32], [14, 33], [14, 34]],values = [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],k = 3) == 35\n assert candidate(n = 14,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], [6, 13]],values = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168],k = 12) == 14\n assert candidate(n = 16,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]],values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 16\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 10) == 7\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "values", "k"], "leetcode_dataset_entry_point": "Solution().maxKDivisibleComponents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxKDivisibleComponents(int n, int[][] edges, int[] values, int k) {", "container": "Solution", "callable": "maxKDivisibleComponents", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}, {"name": "values", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2873, "task_id": "maximum-value-of-an-ordered-triplet-i", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums.\nReturn the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.\nThe value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].\n \nExample 1:\n\nInput: nums = [12,6,1,2,7]\nOutput: 77\nExplanation: The value of the triplet (0, 2, 4) is (nums[0] - nums[2]) * nums[4] = 77.\nIt can be shown that there are no ordered triplets of indices with a value greater than 77. \n\nExample 2:\n\nInput: nums = [1,10,3,4,19]\nOutput: 133\nExplanation: The value of the triplet (1, 2, 4) is (nums[1] - nums[2]) * nums[4] = 133.\nIt can be shown that there are no ordered triplets of indices with a value greater than 133.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: 0\nExplanation: The only ordered triplet of indices (0, 1, 2) has a negative value of (nums[0] - nums[1]) * nums[2] = -3. Hence, the answer would be 0.\n\n \nConstraints:\n\n3 <= nums.length <= 100\n1 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 2, 1, 5, 4, 6]) == 12\n assert candidate(nums = [10, 20, 3, 40, 5, 60, 7, 80, 9, 10]) == 4240\n assert candidate(nums = [12, 6, 1, 2, 7]) == 77\n assert candidate(nums = [8, 6, 4, 2, 10, 9, 7, 5, 3, 1]) == 60\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 42\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 10, 3, 4, 19]) == 133\n assert candidate(nums = [10, 9, 8, 7, 6]) == 18\n assert candidate(nums = [100, 90, 80, 70, 60]) == 1800\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 0\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == 9702\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500]) == 0\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [10, 5, 15, 20, 25]) == 125\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 80\n assert candidate(nums = [3, 2, 1, 4, 5, 6]) == 12\n assert candidate(nums = [5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [3, 2, 1, 5, 4]) == 10\n assert candidate(nums = [100, 50, 200, 300, 400]) == 20000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 0\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500]) == 125000000000\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [100, 100, 100]) == 0\n assert candidate(nums = [5, 15, 10, 25, 20, 35, 30, 45, 40, 55, 50]) == 275\n assert candidate(nums = [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995, 5]) == 999996000004\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 125000000000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 0\n assert candidate(nums = [1000000, 1, 1000000, 1, 1000000]) == 999999000000\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 = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 9702\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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6]) == 81\n assert candidate(nums = [500, 400, 300, 200, 100, 101, 102, 103, 104, 105]) == 42000\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 63\n assert candidate(nums = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50]) == 250\n assert candidate(nums = [1000000, 500000, 1, 2, 3, 4, 5, 6, 7, 8]) == 7999992\n assert candidate(nums = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 200000000000\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996]) == 999997000002\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 140\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60]) == 9000\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1]) == 500\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 0\n assert candidate(nums = [1000000, 1, 1000000, 1, 1000000, 1, 1000000]) == 999999000000\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [100, 10, 200, 20, 300, 30, 400, 40, 500, 50]) == 180000\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 6\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60]) == 600\n assert candidate(nums = [1000000, 1000000, 1, 2, 3, 1000000, 4, 5, 6, 1000000]) == 999999000000\n assert candidate(nums = [10, 5, 15, 20, 12, 25, 30, 5, 35, 40]) == 1000\n assert candidate(nums = [5, 25, 15, 45, 35, 65, 55, 75, 60, 85]) == 1275\n assert candidate(nums = [1, 2, 3, 10, 1, 2, 3, 10, 1, 2, 3, 10]) == 90\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [10, 100, 20, 200, 30, 300, 40, 400, 50, 500]) == 175000\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26]) == 0\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 80\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 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]) == 0\n assert candidate(nums = [1, 2, 3, 1000000, 1000000, 1000000, 1, 2, 3, 1]) == 2999997\n assert candidate(nums = [100, 50, 25, 10, 5, 2, 1]) == 1250\n assert candidate(nums = [10, 20, 30, 15, 25, 35, 40, 5, 45, 50, 55, 60]) == 2100\n assert candidate(nums = [1, 100, 2, 200, 3, 300, 4, 400, 5, 500]) == 197500\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]) == 0\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 7999928\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 9702\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 0\n assert candidate(nums = [10, 20, 10, 30, 15, 40, 25, 50, 35, 60, 45, 70, 55, 80, 65, 90, 75, 100, 85, 95]) == 1500\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1980\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 6\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 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]) == 0\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 5, 15, 25, 35]) == 1925\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10]) == 80\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 90\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 100000, 10000, 1000]) == 9000000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 200000\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 81\n assert candidate(nums = [1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1]) == 50000000000\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 1]) == 2000\n assert candidate(nums = [1000, 2000, 1500, 3000, 2500, 4000, 3500, 5000, 4500]) == 2500000\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 42\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == 997002\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]) == 0\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 4, 7, 5]) == 14\n assert candidate(nums = [100, 200, 150, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 50000\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 = [1000, 500, 1500, 2000, 2500, 3000, 3500]) == 1750000\n assert candidate(nums = [100, 99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6, 93, 7, 92, 8, 91, 9, 90]) == 9702\n assert candidate(nums = [20, 18, 25, 15, 30, 10, 35, 5, 40, 0, 45, 2, 50, 1, 55, 3, 60, 4, 65, 6]) == 3640\n assert candidate(nums = [5, 3, 8, 6, 2, 9, 1, 7, 4, 10]) == 80\n assert candidate(nums = [100, 101, 99, 102, 98, 103, 97, 104, 96, 105]) == 840\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 9900\n assert candidate(nums = [5, 100, 50, 200, 150, 300, 250, 400, 350]) == 20000\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 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]) == 0\n assert candidate(nums = [10, 5, 20, 15, 25, 30, 35, 40, 45, 50]) == 250\n assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == 198000\n assert candidate(nums = [1, 999999, 2, 999998, 3, 999997, 4, 999996, 5, 999995]) == 999995000006\n assert candidate(nums = [10, 100, 10, 100, 10, 100, 10, 100, 10, 100, 10, 100, 10, 100, 10, 100, 10, 100, 10, 100]) == 9000\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 90\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11]) == 11\n assert candidate(nums = [5, 10, 3, 15, 20, 2, 25, 1, 30]) == 720\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50]) == 2250\n assert candidate(nums = [1, 200000, 2, 199999, 3, 199998, 4, 199997, 5, 199996, 6, 199995, 7, 199994, 8, 199993, 9, 199992, 10, 199991]) == 39999400002\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 0\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, 9, 3, 2, 3, 8, 4, 6]) == 81\n assert candidate(nums = [1000, 500, 750, 250, 300, 600, 400, 800, 900, 100]) == 675000\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 0, -1, -2]) == 1250\n assert candidate(nums = [5, 25, 10, 20, 15, 30, 2, 28, 29, 3]) == 812\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 0\n assert candidate(nums = [5, 3, 1, 8, 6, 4, 7, 9, 2, 10]) == 70\n assert candidate(nums = [50, 10, 100, 20, 150, 30, 200, 40, 250, 50]) == 40000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10]) == 20\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumTripletValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumTripletValue(int[] nums) {", "container": "Solution", "callable": "maximumTripletValue", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2874, "task_id": "maximum-value-of-an-ordered-triplet-ii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums.\nReturn the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.\nThe value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].\n \nExample 1:\n\nInput: nums = [12,6,1,2,7]\nOutput: 77\nExplanation: The value of the triplet (0, 2, 4) is (nums[0] - nums[2]) * nums[4] = 77.\nIt can be shown that there are no ordered triplets of indices with a value greater than 77. \n\nExample 2:\n\nInput: nums = [1,10,3,4,19]\nOutput: 133\nExplanation: The value of the triplet (1, 2, 4) is (nums[1] - nums[2]) * nums[4] = 133.\nIt can be shown that there are no ordered triplets of indices with a value greater than 133.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: 0\nExplanation: The only ordered triplet of indices (0, 1, 2) has a negative value of (nums[0] - nums[1]) * nums[2] = -3. Hence, the answer would be 0.\n\n \nConstraints:\n\n3 <= nums.length <= 105\n1 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [12, 6, 1, 2, 7]) == 77\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 2000\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250]) == 125000000000\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 42\n assert candidate(nums = [10, 9, 8, 7, 6, 5]) == 20\n assert candidate(nums = [5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6]) == 7\n assert candidate(nums = [1, 10, 3, 4, 19]) == 133\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == 0\n assert candidate(nums = [100, 90, 80, 70, 60]) == 1800\n assert candidate(nums = [50, 40, 30, 20, 10]) == 400\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10]) == 11\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1000000, 1, 1000000, 1, 1000000]) == 999999000000\n assert candidate(nums = [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995, 5]) == 999996000004\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 0\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 = [1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000]) == 999999000000\n assert candidate(nums = [100, 90, 101, 91, 102, 92, 103, 93, 104, 94]) == 1040\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 1]) == 7999920\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2000\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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9]) == 81\n assert candidate(nums = [9, 1, 8, 1, 7, 1, 6, 1, 5, 1, 4, 1, 3, 1, 2, 1, 1, 1, 1, 1]) == 64\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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6]) == 81\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 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15]) == 135\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996]) == 999997000002\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 5, 10, 20, 40, 80, 160, 320, 640]) == 63360\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 100]) == 0\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]) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 0\n assert candidate(nums = [10, 20, 30, 15, 25, 35, 5, 40, 45, 50, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 3000\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == 6\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6, 99, 7, 8, 98, 9, 10, 97, 11]) == 9504\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 999999\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20, 21, 22, 23, 24, 25]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 20\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2000\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 1]) == 7999928\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1000000]) == 9000000\n assert candidate(nums = [500000, 1, 499999, 2, 499998, 3, 499997, 4, 499996, 5, 499995, 6, 499994, 7, 499993, 8, 499992, 9, 499991, 10]) == 249999000001\n assert candidate(nums = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13]) == 30\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10]) == 0\n assert candidate(nums = [10, 20, 30, 25, 40, 50, 15, 60, 70, 80]) == 2800\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15]) == 135\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 1800\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10]) == 8100\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 45, 40, 35, 30, 25, 20, 15, 10]) == 500\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 80\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]) == 0\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9999990\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 7999928\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 990\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 10\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60, 55]) == 300\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]) == 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, 1000000]) == 0\n assert candidate(nums = [1, 100, 2, 101, 3, 102, 4, 103, 5, 104, 6, 105, 7, 106, 8, 107, 9, 108, 10, 109]) == 10682\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 800\n assert candidate(nums = [5, 3, 6, 7, 2, 8, 1, 4, 9, 10, 11, 12]) == 84\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1]) == 999999000000\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(nums = [2, 1, 5, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 40\n assert candidate(nums = [1, 10, 1, 20, 1, 30, 1, 40, 1, 50, 1, 60, 1, 70, 1, 80, 1, 90, 1, 100]) == 8900\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997]) == 999997000002\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 140\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91, 1000000]) == 98000000\n assert candidate(nums = [1000000, 1, 999999, 2, 999998, 3, 999997]) == 999998000001\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]) == 90\n assert candidate(nums = [5, 3, 1, 6, 4, 2, 7, 9, 8, 10, 11, 12, 13, 14, 15]) == 60\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 160\n assert candidate(nums = [1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1]) == 50000000000\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 42\n assert candidate(nums = [5, 15, 25, 10, 35, 20, 45, 30, 55, 40]) == 825\n assert candidate(nums = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20]) == 600\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000000]) == 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]) == 0\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 15, 50, 60, 45, 70]) == 1750\n assert candidate(nums = [1000000, 1, 999999, 2, 999998, 3, 999997, 4, 999996, 5]) == 999998000001\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11]) == 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, 1000000]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15]) == 60\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 90\n assert candidate(nums = [1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10, 110]) == 9900\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 0\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 90\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11]) == 99\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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7]) == 81\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 4, 3, 2, 1]) == 380\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, 10]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5]) == 6\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5]) == 2000\n assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 361\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(nums = [500000, 400000, 300000, 200000, 100000, 99999, 89999, 79999, 69999, 59999, 49999, 39999, 29999, 19999, 9999]) == 40000000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1000000]) == 999000000\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1]) == 125000000000\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 = [100000, 1, 100001, 2, 100002, 3, 100003, 4, 100004, 5, 100005, 6, 100006, 7, 100007, 8, 100008, 9, 100009, 10]) == 10000799991\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 2000\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == 80\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(nums = [1000000, 900000, 1000000, 800000, 700000, 900000, 600000, 500000, 400000, 300000, 200000, 100000]) == 270000000000\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumTripletValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumTripletValue(int[] nums) {", "container": "Solution", "callable": "maximumTripletValue", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2875, "task_id": "minimum-size-subarray-in-infinite-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums and an integer target.\nA 0-indexed array infinite_nums is generated by infinitely appending the elements of nums to itself.\nReturn the length of the shortest subarray of the array infinite_nums with a sum equal to target. If there is no such subarray return -1.\n \nExample 1:\n\nInput: nums = [1,2,3], target = 5\nOutput: 2\nExplanation: In this example infinite_nums = [1,2,3,1,2,3,1,2,...].\nThe subarray in the range [1,2], has the sum equal to target = 5 and length = 2.\nIt can be proven that 2 is the shortest length of a subarray with sum equal to target = 5.\n\nExample 2:\n\nInput: nums = [1,1,1,2,3], target = 4\nOutput: 2\nExplanation: In this example infinite_nums = [1,1,1,2,3,1,1,1,2,3,1,1,...].\nThe subarray in the range [4,5], has the sum equal to target = 4 and length = 2.\nIt can be proven that 2 is the shortest length of a subarray with sum equal to target = 4.\n\nExample 3:\n\nInput: nums = [2,4,6,8], target = 3\nOutput: -1\nExplanation: In this example infinite_nums = [2,4,6,8,2,4,6,8,...].\nIt can be proven that there is no subarray with sum equal to target = 3.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 105\n1 <= target <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],target = 150) == 5\n assert candidate(nums = [7, 7, 7, 7, 7],target = 28) == 4\n assert candidate(nums = [5, 5, 5, 5, 5],target = 15) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],target = 9) == 2\n assert candidate(nums = [3, 3, 3, 3, 3],target = 9) == 3\n assert candidate(nums = [1, 2, 3],target = 6) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],target = 1) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7],target = 42) == 6\n assert candidate(nums = [5, 5, 5, 5],target = 15) == 3\n assert candidate(nums = [2, 4, 6, 8],target = 3) == -1\n assert candidate(nums = [1, 1, 1, 2, 3],target = 4) == 2\n assert candidate(nums = [1],target = 1) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],target = 15) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],target = 30) == 10\n assert candidate(nums = [1, 3, 5, 7],target = 15) == 3\n assert candidate(nums = [1, 2, 3],target = 5) == 2\n assert candidate(nums = [5, 5, 5, 5],target = 20) == 4\n assert candidate(nums = [100000],target = 100000) == 1\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3],target = 21) == 10\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19],target = 100) == 11\n assert candidate(nums = [7, 14, 28, 56, 112],target = 224) == 6\n assert candidate(nums = [10, 20, 30, 40, 50],target = 300) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 100) == 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],target = 90) == 12\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],target = 90) == 10\n assert candidate(nums = [7, 11, 15, 19],target = 100) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 55) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 110) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],target = 100) == 3\n assert candidate(nums = [5, 5, 5, 5, 5],target = 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],target = 100) == 100\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3],target = 27) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 100) == 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],target = 20) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 550) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 45) == 9\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],target = 315) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 10\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17],target = 100) == -1\n assert candidate(nums = [7, 8, 9],target = 40) == 5\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55],target = 10000) == 697\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 450) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 1000) == 181\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],target = 39) == 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],target = 10) == 10\n assert candidate(nums = [5, 10, 15, 20, 25, 30],target = 100) == 5\n assert candidate(nums = [1, 10, 100, 1000, 10000],target = 11111) == 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],target = 50) == 50\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 50) == 10\n assert candidate(nums = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67],target = 300) == 6\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 119) == 17\n assert candidate(nums = [1, 2, 4, 8, 16, 32],target = 127) == 13\n assert candidate(nums = [5, 5, 5, 5, 5],target = 75) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = 50) == 50\n assert candidate(nums = [9, 7, 5, 3, 1],target = 20) == 4\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 27) == 9\n assert candidate(nums = [123456, 654321, 123456, 654321],target = 4508736) == -1\n assert candidate(nums = [2, 3, 6, 7, 9],target = 19) == -1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],target = 90) == 4\n assert candidate(nums = [3, 3, 3],target = 27) == 9\n assert candidate(nums = [5, 5, 5, 5, 5],target = 125) == 25\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1023) == 10\n assert candidate(nums = [5, 7, 9, 11, 13],target = 100) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 120) == 15\n assert candidate(nums = [7, 14, 21, 28, 35],target = 98) == 4\n assert candidate(nums = [100000, 100000, 100000],target = 300000) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 225) == 45\n assert candidate(nums = [100000],target = 500000) == 5\n assert candidate(nums = [10, 5, 15, 20, 25],target = 150) == 10\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78],target = 500) == -1\n assert candidate(nums = [100000],target = 1000000000) == 10000\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 90) == 30\n assert candidate(nums = [5, 2, 7, 3, 9],target = 31) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 30) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 45) == 14\n assert candidate(nums = [10, 20, 30],target = 100) == 5\n assert candidate(nums = [10, 20, 30, 40, 50],target = 120) == 3\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17],target = 101) == 11\n assert candidate(nums = [123456, 654321, 135792, 246801, 357912, 468012, 579123],target = 10000000) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 27) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 30) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6],target = 15) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 120) == 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],target = 210) == 20\n assert candidate(nums = [1, 10, 100, 1000, 10000],target = 11111) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 100000) == 1816\n assert candidate(nums = [7, 8, 9],target = 60) == -1\n assert candidate(nums = [17, 19, 23, 29, 31],target = 150) == 6\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],target = 1000) == -1\n assert candidate(nums = [5, 2, 3, 1, 1, 1, 1, 1, 1, 1],target = 18) == 11\n assert candidate(nums = [100, 200, 300],target = 1000) == 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],target = 40) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 2500) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 120) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 55) == 10\n assert candidate(nums = [7, 1, 5, 3],target = 31) == 7\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],target = 180) == 20\n assert candidate(nums = [9, 7, 5, 3, 1],target = 30) == 6\n assert candidate(nums = [5, 2, 7],target = 22) == -1\n assert candidate(nums = [100, 200, 300, 400, 500],target = 2500) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 550) == 10\n assert candidate(nums = [7, 14, 21, 28, 35],target = 105) == 5\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16],target = 100) == 12\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],target = 1500000) == 5\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 90) == 30\n assert candidate(nums = [100000, 100000, 100000, 100000],target = 400000) == 4\n assert candidate(nums = [10, 20, 30, 40, 50],target = 120) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 25) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],target = 9000) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 275) == 50\n assert candidate(nums = [1],target = 100000) == 100000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 55) == 10\n assert candidate(nums = [1, 2, 3],target = 30) == 15\n assert candidate(nums = [123, 456, 789],target = 1518) == -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],target = 210) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 1000) == 181\n assert candidate(nums = [1],target = 1000000) == 1000000\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().minSizeSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minSizeSubarray(int[] nums, int target) {", "container": "Solution", "callable": "minSizeSubarray", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2876, "task_id": "count-visited-nodes-in-a-directed-graph", "difficulty": "Hard", "problem_description": "There is a directed graph consisting of n nodes numbered from 0 to n - 1 and n directed edges.\nYou are given a 0-indexed array edges where edges[i] indicates that there is an edge from node i to node edges[i].\nConsider the following process on the graph:\n\nYou start from a node x and keep visiting other nodes through edges until you reach a node that you have already visited before on this same process.\n\nReturn an array answer where answer[i] is the number of different nodes that you will visit if you perform the process starting from node i.\n \nExample 1:\n\n\nInput: edges = [1,2,0,0]\nOutput: [3,3,3,4]\nExplanation: We perform the process starting from each node in the following way:\n- Starting from node 0, we visit the nodes 0 -> 1 -> 2 -> 0. The number of different nodes we visit is 3.\n- Starting from node 1, we visit the nodes 1 -> 2 -> 0 -> 1. The number of different nodes we visit is 3.\n- Starting from node 2, we visit the nodes 2 -> 0 -> 1 -> 2. The number of different nodes we visit is 3.\n- Starting from node 3, we visit the nodes 3 -> 0 -> 1 -> 2 -> 0. The number of different nodes we visit is 4.\n\nExample 2:\n\n\nInput: edges = [1,2,3,4,0]\nOutput: [5,5,5,5,5]\nExplanation: Starting from any node we can visit every node in the graph in the process.\n\n \nConstraints:\n\nn == edges.length\n2 <= n <= 105\n0 <= edges[i] <= n - 1\nedges[i] != i\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [3, 5, 5, 3, 4, 3]) == [2, 3, 3, 1, 1, 2]\n assert candidate(edges = [1, 0]) == [2, 2]\n assert candidate(edges = [1, 1, 1, 1, 1, 1]) == [2, 1, 2, 2, 2, 2]\n assert candidate(edges = [3, 3, 4, 2, 3]) == [4, 4, 3, 3, 3]\n assert candidate(edges = [1, 2, 0, 0]) == [3, 3, 3, 4]\n assert candidate(edges = [5, 4, 0, 3, 1, 3]) == [3, 2, 4, 1, 2, 2]\n assert candidate(edges = [2, 0, 1, 4, 5, 3, 1]) == [3, 3, 3, 3, 3, 3, 4]\n assert candidate(edges = [1, 3, 0, 5, 4, 3]) == [4, 3, 5, 2, 1, 2]\n assert candidate(edges = [2, 0, 1, 4, 3]) == [3, 3, 3, 2, 2]\n assert candidate(edges = [2, 2, 3, 1]) == [4, 3, 3, 3]\n assert candidate(edges = [2, 0, 1, 4, 5, 3, 2, 0]) == [3, 3, 3, 3, 3, 3, 4, 4]\n assert candidate(edges = [1, 2, 3, 4, 0]) == [5, 5, 5, 5, 5]\n assert candidate(edges = [5, 4, 0, 2, 0, 4, 1]) == [3, 4, 4, 5, 3, 3, 5]\n assert candidate(edges = [1, 0, 0, 4, 1]) == [2, 2, 3, 4, 3]\n assert candidate(edges = [1, 0, 0, 0, 0]) == [2, 2, 3, 3, 3]\n assert candidate(edges = [5, 4, 5, 4, 3, 6, 2]) == [4, 3, 3, 2, 2, 3, 3]\n assert candidate(edges = [2, 0, 1, 4, 5, 3]) == [3, 3, 3, 3, 3, 3]\n assert candidate(edges = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(edges = [2, 0, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 19]) == [3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(edges = [1, 2, 0, 1, 3, 4, 2, 5, 6, 7, 8, 9, 10]) == [3, 3, 3, 4, 5, 6, 4, 7, 5, 8, 6, 9, 7]\n assert candidate(edges = [1, 2, 3, 4, 5, 0, 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, 0]) == [6, 6, 6, 6, 6, 6, 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]\n assert candidate(edges = [1, 3, 0, 5, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [4, 3, 5, 3, 1, 3, 6, 4, 2, 4, 7, 5, 3, 5, 8, 6, 4, 6, 9, 7]\n assert candidate(edges = [3, 0, 4, 1, 2, 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]) == [3, 3, 2, 3, 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, 1, 1, 1, 1]\n assert candidate(edges = [1, 2, 3, 0, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [4, 4, 4, 4, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [2, 1, 3, 0, 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, 0]) == [3, 1, 3, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4]\n assert candidate(edges = [3, 8, 10, 5, 3, 4, 7, 9, 6, 2, 1, 5, 8, 11, 6, 0, 12, 13, 14, 2, 9]) == [4, 7, 7, 3, 3, 3, 7, 7, 7, 7, 7, 4, 8, 5, 8, 5, 9, 6, 9, 8, 8]\n assert candidate(edges = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 15]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 5, 5, 5, 5]\n assert candidate(edges = [5, 6, 2, 0, 1, 4, 3]) == [6, 6, 1, 6, 6, 6, 6]\n assert candidate(edges = [4, 3, 0, 5, 3, 5]) == [4, 3, 5, 2, 3, 1]\n assert candidate(edges = [2, 3, 4, 5, 6, 7, 8, 9, 0, 1]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(edges = [7, 1, 1, 3, 7, 6, 5, 0]) == [2, 1, 2, 1, 3, 2, 2, 2]\n assert candidate(edges = [1, 3, 2, 1, 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, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45, 44, 47, 46, 49, 48, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 63, 62, 65, 64, 67, 66, 69, 68, 71, 70, 73, 72, 75, 74, 77, 76, 79, 78, 81, 80, 83, 82, 85, 84, 87, 86, 89, 88, 91, 90, 93, 92, 95, 94, 97, 96, 99, 98]) == [3, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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(edges = [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, 0]) == [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]\n assert candidate(edges = [3, 4, 0, 1, 2, 0, 3, 5, 6, 7]) == [5, 5, 5, 5, 5, 6, 6, 7, 7, 8]\n assert candidate(edges = [4, 3, 0, 5, 3, 1, 4]) == [5, 3, 6, 3, 4, 3, 5]\n assert candidate(edges = [1, 0, 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, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45, 44, 47, 46, 49, 48, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 63, 62, 65, 64, 67, 66, 69, 68, 71, 70, 73, 72, 75, 74, 77, 76, 79, 78, 81, 80, 83, 82, 85, 84, 87, 86, 89, 88, 91, 90, 93, 92, 95, 94, 97, 96, 99, 98, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]\n assert candidate(edges = [5, 6, 0, 5, 1, 3, 4, 2, 7]) == [3, 3, 4, 2, 3, 2, 3, 5, 6]\n assert candidate(edges = [7, 0, 1, 2, 3, 4, 5, 6]) == [8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(edges = [5, 4, 3, 2, 1, 0]) == [2, 2, 2, 2, 2, 2]\n assert candidate(edges = [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, 0]) == [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]\n assert candidate(edges = [1, 3, 2, 0, 5, 6, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [3, 3, 1, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [2, 1, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(edges = [2, 3, 1, 0, 2]) == [4, 4, 4, 4, 5]\n assert candidate(edges = [4, 1, 2, 0, 5, 3]) == [4, 1, 1, 4, 4, 4]\n assert candidate(edges = [3, 0, 1, 4, 2, 5, 6, 7, 8, 9, 5]) == [5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 2]\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 0]) == [9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(edges = [3, 1, 0, 5, 4, 3]) == [3, 1, 4, 2, 1, 2]\n assert candidate(edges = [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, 0]) == [3, 2, 1, 1, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4]\n assert candidate(edges = [8, 5, 5, 5, 5, 0, 5, 5, 2]) == [4, 5, 4, 5, 5, 4, 5, 5, 4]\n assert candidate(edges = [3, 3, 3, 3]) == [2, 2, 2, 1]\n assert candidate(edges = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4]) == [6, 6, 6, 6, 6, 6, 7, 7, 7, 7]\n assert candidate(edges = [1, 2, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 3, 4]) == [3, 3, 3, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]\n assert candidate(edges = [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, 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, 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, 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, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == [11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(edges = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2]\n assert candidate(edges = [1, 2, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == [3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4]\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]\n assert candidate(edges = [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, 0, 1, 2]) == [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(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(edges = [1, 2, 0, 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]) == [3, 3, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(edges = [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, 1, 2, 1, 2, 1, 2, 1]) == [2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(edges = [3, 3, 3, 1]) == [3, 2, 3, 2]\n assert candidate(edges = [3, 1, 0, 2, 4, 5, 3]) == [3, 1, 3, 3, 1, 1, 4]\n assert candidate(edges = [5, 1, 4, 4, 5, 6, 6, 6, 6, 7]) == [3, 1, 4, 4, 3, 2, 1, 2, 2, 3]\n assert candidate(edges = [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]) == [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]\n assert candidate(edges = [6, 7, 8, 9, 10, 11, 12, 0, 1, 2, 3, 4, 5]) == [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\n assert candidate(edges = [2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1]) == [11, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13]\n assert candidate(edges = [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, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 0]) == [3, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4]\n assert candidate(edges = [5, 0, 1, 6, 5, 2, 3, 4, 8, 9, 7]) == [4, 4, 4, 2, 5, 4, 2, 6, 1, 1, 7]\n assert candidate(edges = [3, 0, 0, 0]) == [2, 3, 3, 2]\n assert candidate(edges = [1, 2, 3, 4, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 5]) == [5, 5, 5, 5, 5, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(edges = [1, 3, 0, 5, 0, 6, 0, 6, 6, 8, 8]) == [5, 5, 6, 5, 6, 5, 5, 6, 6, 7, 7]\n assert candidate(edges = [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, 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]\n assert candidate(edges = [6, 5, 5, 3, 4, 0, 0, 7, 5, 7]) == [2, 4, 4, 1, 1, 3, 2, 1, 4, 2]\n assert candidate(edges = [5, 5, 5, 5, 5, 5]) == [2, 2, 2, 2, 2, 1]\n assert candidate(edges = [5, 6, 7, 8, 9, 4, 5, 6, 7, 8]) == [7, 7, 7, 7, 6, 6, 6, 6, 6, 6]\n assert candidate(edges = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == [2, 1, 1, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3]\n assert candidate(edges = [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, 50]) == [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, 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]\n assert candidate(edges = [2, 3, 1, 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, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 0]) == [120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120]\n assert candidate(edges = [99, 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, 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, 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, 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, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 101]\n assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 6, 6, 6, 6]\n assert candidate(edges = [2, 3, 1, 4, 6, 5, 7, 0]) == [7, 7, 7, 7, 7, 1, 7, 7]\n assert candidate(edges = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 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, 5, 5, 5, 5]\n assert candidate(edges = [3, 0, 0, 2, 1, 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0]) == [3, 4, 3, 3, 5, 1, 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, 4]\n assert candidate(edges = [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, 0]) == [40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40]\n assert candidate(edges = [6, 3, 0, 2, 1, 4, 5, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10]) == [7, 7, 7, 7, 7, 7, 7, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]\n assert candidate(edges = [2, 1, 5, 3, 4, 7, 6, 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, 0]) == [46, 1, 46, 1, 1, 46, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46]\n assert candidate(edges = [2, 1, 3, 4, 5, 6, 7, 8, 9, 0]) == [9, 1, 9, 9, 9, 9, 9, 9, 9, 9]\n"}, "metadata": {"canonical_parameter_names": ["edges"], "leetcode_dataset_entry_point": "Solution().countVisitedNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] countVisitedNodes(List edges) {", "container": "Solution", "callable": "countVisitedNodes", "parameters": [{"name": "edges", "type": "List"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2894, "task_id": "divisible-and-non-divisible-sums-difference", "difficulty": "Easy", "problem_description": "You are given positive integers n and m.\nDefine two integers as follows:\n\nnum1: The sum of all integers in the range [1, n] (both inclusive) that are not divisible by m.\nnum2: The sum of all integers in the range [1, n] (both inclusive) that are divisible by m.\n\nReturn the integer num1 - num2.\n \nExample 1:\n\nInput: n = 10, m = 3\nOutput: 19\nExplanation: In the given example:\n- Integers in the range [1, 10] that are not divisible by 3 are [1,2,4,5,7,8,10], num1 is the sum of those integers = 37.\n- Integers in the range [1, 10] that are divisible by 3 are [3,6,9], num2 is the sum of those integers = 18.\nWe return 37 - 18 = 19 as the answer.\n\nExample 2:\n\nInput: n = 5, m = 6\nOutput: 15\nExplanation: In the given example:\n- Integers in the range [1, 5] that are not divisible by 6 are [1,2,3,4,5], num1 is the sum of those integers = 15.\n- Integers in the range [1, 5] that are divisible by 6 are [], num2 is the sum of those integers = 0.\nWe return 15 - 0 = 15 as the answer.\n\nExample 3:\n\nInput: n = 5, m = 1\nOutput: -15\nExplanation: In the given example:\n- Integers in the range [1, 5] that are not divisible by 1 are [], num1 is the sum of those integers = 0.\n- Integers in the range [1, 5] that are divisible by 1 are [1,2,3,4,5], num2 is the sum of those integers = 15.\nWe return 0 - 15 = -15 as the answer.\n\n \nConstraints:\n\n1 <= n, m <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1000,m = 1000) == 498500\n assert candidate(n = 5,m = 6) == 15\n assert candidate(n = 5,m = 1) == -15\n assert candidate(n = 20,m = 4) == 90\n assert candidate(n = 100,m = 10) == 3950\n assert candidate(n = 1,m = 1) == -1\n assert candidate(n = 7,m = 2) == 4\n assert candidate(n = 10,m = 3) == 19\n assert candidate(n = 600,m = 50) == 172500\n assert candidate(n = 300,m = 7) == 32508\n assert candidate(n = 120,m = 13) == 6090\n assert candidate(n = 250,m = 7) == 22555\n assert candidate(n = 350,m = 7) == 43575\n assert candidate(n = 800,m = 20) == 287600\n assert candidate(n = 250,m = 11) == 25809\n assert candidate(n = 950,m = 19) == 403275\n assert candidate(n = 600,m = 31) == 168520\n assert candidate(n = 750,m = 25) == 258375\n assert candidate(n = 999,m = 333) == 495504\n assert candidate(n = 600,m = 29) == 168120\n assert candidate(n = 600,m = 9) == 140502\n assert candidate(n = 300,m = 15) == 38850\n assert candidate(n = 1000,m = 999) == 498502\n assert candidate(n = 999,m = 17) == 441326\n assert candidate(n = 800,m = 23) == 293030\n assert candidate(n = 700,m = 29) == 227950\n assert candidate(n = 450,m = 19) == 90987\n assert candidate(n = 600,m = 5) == 107700\n assert candidate(n = 750,m = 19) == 251985\n assert candidate(n = 300,m = 25) == 41250\n assert candidate(n = 600,m = 42) == 171480\n assert candidate(n = 900,m = 29) == 376682\n assert candidate(n = 300,m = 11) == 36834\n assert candidate(n = 999,m = 13) == 423424\n assert candidate(n = 400,m = 37) == 76130\n assert candidate(n = 500,m = 41) == 118854\n assert candidate(n = 550,m = 11) == 123475\n assert candidate(n = 300,m = 4) == 22350\n assert candidate(n = 222,m = 37) == 23199\n assert candidate(n = 800,m = 31) == 300250\n assert candidate(n = 450,m = 18) == 89775\n assert candidate(n = 600,m = 20) == 161700\n assert candidate(n = 750,m = 15) == 243375\n assert candidate(n = 600,m = 19) == 161452\n assert candidate(n = 650,m = 17) == 186381\n assert candidate(n = 750,m = 50) == 269625\n assert candidate(n = 999,m = 11) == 409410\n assert candidate(n = 400,m = 41) == 76510\n assert candidate(n = 250,m = 13) == 26435\n assert candidate(n = 800,m = 33) == 300600\n assert candidate(n = 500,m = 13) == 105984\n assert candidate(n = 950,m = 31) == 422895\n assert candidate(n = 500,m = 250) == 123750\n assert candidate(n = 300,m = 19) == 40590\n assert candidate(n = 500,m = 30) == 117090\n assert candidate(n = 700,m = 11) == 200998\n assert candidate(n = 800,m = 400) == 318000\n assert candidate(n = 900,m = 55) == 390490\n assert candidate(n = 450,m = 2) == -225\n assert candidate(n = 375,m = 16) == 61668\n assert candidate(n = 200,m = 3) == 6834\n assert candidate(n = 333,m = 3) == 18315\n assert candidate(n = 250,m = 17) == 27805\n assert candidate(n = 350,m = 23) == 55905\n assert candidate(n = 300,m = 29) == 41960\n assert candidate(n = 400,m = 16) == 69800\n assert candidate(n = 500,m = 7) == 89466\n assert candidate(n = 333,m = 77) == 54071\n assert candidate(n = 750,m = 5) == 168375\n assert candidate(n = 200,m = 17) == 17856\n assert candidate(n = 450,m = 20) == 91355\n assert candidate(n = 600,m = 11) == 147630\n assert candidate(n = 800,m = 17) == 282048\n assert candidate(n = 500,m = 25) == 114750\n assert candidate(n = 800,m = 300) == 318600\n assert candidate(n = 100,m = 19) == 4480\n assert candidate(n = 450,m = 30) == 94275\n assert candidate(n = 800,m = 16) == 279600\n assert candidate(n = 200,m = 13) == 16980\n assert candidate(n = 750,m = 29) == 262775\n assert candidate(n = 500,m = 5) == 74750\n assert candidate(n = 200,m = 8) == 14900\n assert candidate(n = 750,m = 42) == 268773\n assert candidate(n = 400,m = 11) == 65548\n assert candidate(n = 900,m = 9) == 314550\n assert candidate(n = 450,m = 23) == 92735\n assert candidate(n = 300,m = 150) == 44250\n assert candidate(n = 420,m = 23) == 80544\n assert candidate(n = 999,m = 7) == 357358\n assert candidate(n = 800,m = 11) == 262584\n assert candidate(n = 900,m = 23) == 369570\n assert candidate(n = 800,m = 25) == 294000\n assert candidate(n = 600,m = 12) == 149700\n"}, "metadata": {"canonical_parameter_names": ["n", "m"], "leetcode_dataset_entry_point": "Solution().differenceOfSums", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int differenceOfSums(int n, int m) {", "container": "Solution", "callable": "differenceOfSums", "parameters": [{"name": "n", "type": "int"}, {"name": "m", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2895, "task_id": "minimum-processing-time", "difficulty": "Medium", "problem_description": "You have a certain number of processors, each having 4 cores. The number of tasks to be executed is four times the number of processors. Each task must be assigned to a unique core, and each core can only be used once.\nYou are given an array processorTime representing the time each processor becomes available and an array tasks representing how long each task takes to complete. Return the minimum time needed to complete all tasks.\n \nExample 1:\n\nInput: processorTime = [8,10], tasks = [2,2,3,1,8,7,4,5]\nOutput: 16\nExplanation:\nAssign the tasks at indices 4, 5, 6, 7 to the first processor which becomes available at time = 8, and the tasks at indices 0, 1, 2, 3 to the second processor which becomes available at time = 10. \nThe time taken by the first processor to finish the execution of all tasks is max(8 + 8, 8 + 7, 8 + 4, 8 + 5) = 16.\nThe time taken by the second processor to finish the execution of all tasks is max(10 + 2, 10 + 2, 10 + 3, 10 + 1) = 13.\n\nExample 2:\n\nInput: processorTime = [10,20], tasks = [2,3,1,2,5,8,4,3]\nOutput: 23\nExplanation:\nAssign the tasks at indices 1, 4, 5, 6 to the first processor and the others to the second processor.\nThe time taken by the first processor to finish the execution of all tasks is max(10 + 3, 10 + 5, 10 + 8, 10 + 4) = 18.\nThe time taken by the second processor to finish the execution of all tasks is max(20 + 2, 20 + 1, 20 + 2, 20 + 3) = 23.\n\n \nConstraints:\n\n1 <= n == processorTime.length <= 25000\n1 <= tasks.length <= 105\n0 <= processorTime[i] <= 109\n1 <= tasks[i] <= 109\ntasks.length == 4 * n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(processorTime = [5, 5, 5, 5],tasks = [1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(processorTime = [1, 2, 3, 4],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(processorTime = [1, 3, 5],tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(processorTime = [1000000000, 1000000000],tasks = [1000000000, 1000000000, 1000000000, 1000000000]) == 2000000000\n assert candidate(processorTime = [0, 0, 0, 0],tasks = [1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(processorTime = [1, 2, 3, 4],tasks = [10, 9, 8, 7, 6, 5, 4, 3]) == 13\n assert candidate(processorTime = [5, 5, 5, 5],tasks = [1, 1, 1, 1, 2, 2, 2, 2]) == 7\n assert candidate(processorTime = [0, 0, 0, 0],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(processorTime = [1, 2, 3, 4],tasks = [10, 20, 30, 40, 5, 6, 7, 8]) == 43\n assert candidate(processorTime = [1000000000],tasks = [1, 1, 1, 1]) == 1000000001\n assert candidate(processorTime = [0, 0, 0, 0],tasks = [1000000000, 1000000000, 1000000000, 1000000000, 999999999, 999999999, 999999999, 999999999]) == 1000000000\n assert candidate(processorTime = [1, 5, 9],tasks = [6, 2, 3, 4, 5, 1, 7, 8]) == 17\n assert candidate(processorTime = [10, 20],tasks = [2, 3, 1, 2, 5, 8, 4, 3]) == 23\n assert candidate(processorTime = [0, 0, 0, 0],tasks = [100, 200, 300, 400, 50, 60, 70, 80]) == 400\n assert candidate(processorTime = [8, 10],tasks = [2, 2, 3, 1, 8, 7, 4, 5]) == 16\n assert candidate(processorTime = [0, 0, 0, 0],tasks = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(processorTime = [100, 200, 300, 400, 500],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 540\n assert candidate(processorTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],tasks = [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]) == 62\n assert candidate(processorTime = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],tasks = [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]) == 1000000026\n assert candidate(processorTime = [1, 3, 5, 7, 9, 11, 13, 15],tasks = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 24\n assert candidate(processorTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 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(processorTime = [10, 20, 30, 40, 50],tasks = [90, 80, 70, 60, 50, 40, 30, 20, 10, 5]) == 110\n assert candidate(processorTime = [1000000000, 999999999, 999999998, 999999997],tasks = [1, 2, 3, 4, 5, 6, 7, 8]) == 1000000007\n assert candidate(processorTime = [1, 10, 100, 1000],tasks = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000]) == 1000100\n assert candidate(processorTime = [0, 1, 2, 3, 4, 5, 6, 7],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(processorTime = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],tasks = [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]) == 1032\n assert candidate(processorTime = [1000, 2000, 3000, 4000, 5000],tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1, 100, 200, 300, 400, 500, 600, 700]) == 5700\n assert candidate(processorTime = [1000000, 2000000, 3000000, 4000000],tasks = [1, 2, 3, 4, 5, 6, 7, 8]) == 4000004\n assert candidate(processorTime = [50, 20, 30, 10],tasks = [120, 50, 30, 20, 10, 80, 60, 40]) == 150\n assert candidate(processorTime = [100, 200, 300, 400, 500],tasks = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800]) == 1300\n assert candidate(processorTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],tasks = [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\n assert candidate(processorTime = [1000000, 2000000, 3000000, 4000000],tasks = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 100000, 90000, 80000, 70000, 60000, 50000, 40000]) == 4070000\n assert candidate(processorTime = [100, 200, 300, 400, 500, 600, 700, 800],tasks = [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]) == 804\n assert candidate(processorTime = [10, 20, 30, 40],tasks = [1000000000, 1000000000, 1000000000, 1000000000, 1, 1, 1, 1]) == 1000000030\n assert candidate(processorTime = [1, 100, 200, 300, 400],tasks = [1, 1, 1, 1, 1000000000, 1000000000, 1000000000, 1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000001\n assert candidate(processorTime = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45],tasks = [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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 46\n assert candidate(processorTime = [5, 15, 25, 35],tasks = [100, 90, 80, 70, 60, 50, 40, 30]) == 125\n assert candidate(processorTime = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 8004\n assert candidate(processorTime = [0, 0, 0, 0, 0],tasks = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985, 999999984]) == 999999999\n assert candidate(processorTime = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],tasks = [500000000, 600000000, 700000000, 800000000, 900000000, 1000000000, 1100000000, 1200000000, 1300000000, 1400000000, 1500000000, 1600000000, 1700000000, 1800000000, 1900000000, 2000000000]) == 7000000000\n assert candidate(processorTime = [1, 1, 1, 1, 1, 1, 1, 1],tasks = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000, 10000, 1000, 100, 10, 1, 1]) == 1000001\n assert candidate(processorTime = [100, 200, 300, 400, 500, 600],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240]) == 640\n assert candidate(processorTime = [0, 10, 20, 30, 40, 50],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 54\n assert candidate(processorTime = [10, 20, 30, 40, 50, 60, 70, 80],tasks = [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]) == 84\n assert candidate(processorTime = [1000, 2000, 3000, 4000],tasks = [1, 1, 1, 1, 100, 100, 100, 100, 10000, 10000, 10000, 10000, 100000, 100000, 100000, 100000]) == 101000\n assert candidate(processorTime = [0, 0, 0, 0, 0, 0, 0, 0],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 16\n assert candidate(processorTime = [100, 200, 300, 400, 500, 600, 700, 800],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 801\n assert candidate(processorTime = [5, 15, 25, 35, 45, 55],tasks = [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]) == 65\n assert candidate(processorTime = [0, 1000000000, 500000000, 750000000, 250000000],tasks = [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]) == 1000000016\n assert candidate(processorTime = [1, 10, 100, 1000, 10000],tasks = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984]) == 19999\n assert candidate(processorTime = [1000000000, 2000000000, 3000000000],tasks = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000]) == 3000008000\n assert candidate(processorTime = [1, 1, 1, 1, 1, 1, 1, 1],tasks = [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\n assert candidate(processorTime = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 81\n assert candidate(processorTime = [5, 15, 25, 35, 45],tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1505\n assert candidate(processorTime = [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],tasks = [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, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124]) == 187\n assert candidate(processorTime = [5, 15, 25, 35, 45, 55, 65, 75],tasks = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 155\n assert candidate(processorTime = [0, 0, 0, 0, 0, 0, 0, 0],tasks = [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]) == 10\n assert candidate(processorTime = [5, 5, 5, 5, 5],tasks = [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]) == 37\n assert candidate(processorTime = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],tasks = [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]) == 104\n assert candidate(processorTime = [1000, 2000, 1500, 2500, 3000, 3500, 4000, 4500, 5000, 5500],tasks = [500, 450, 400, 350, 300, 250, 200, 150, 100, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600]) == 6070\n assert candidate(processorTime = [5, 15, 25, 35, 45],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 49\n assert candidate(processorTime = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],tasks = [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]) == 208\n assert candidate(processorTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [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]) == 104\n assert candidate(processorTime = [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],tasks = [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]) == 126\n assert candidate(processorTime = [100, 200, 150, 250, 300, 350, 400, 450],tasks = [90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 540\n assert candidate(processorTime = [0, 0, 0, 0, 0, 0, 0, 0],tasks = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985]) == 1000000000\n assert candidate(processorTime = [10, 10, 10, 10],tasks = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993]) == 1000010\n assert candidate(processorTime = [100, 200, 300, 400],tasks = [15, 25, 35, 45, 55, 65, 75, 85]) == 445\n assert candidate(processorTime = [1, 3, 5, 7, 9, 11, 13, 15],tasks = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984]) == 1000008\n assert candidate(processorTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [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]) == 195\n assert candidate(processorTime = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],tasks = [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]) == 140\n assert candidate(processorTime = [10, 10, 10, 10],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 26\n assert candidate(processorTime = [1, 2, 3, 4, 5, 6, 7, 8],tasks = [8, 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, 9]) == 21\n assert candidate(processorTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],tasks = [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]) == 154\n assert candidate(processorTime = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000],tasks = [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]) == 8400\n assert candidate(processorTime = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],tasks = [90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 5]) == 91000\n assert candidate(processorTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],tasks = [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]) == 51\n assert candidate(processorTime = [50, 25, 0, 75],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 79\n assert candidate(processorTime = [0, 1000000000, 500000000, 750000000, 250000000, 100000000],tasks = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985, 999999984, 999999983, 999999982, 999999981, 999999980, 999999979, 999999978, 999999977, 999999976, 999999975, 999999974, 999999973, 999999972, 999999971, 999999970]) == 1999999979\n assert candidate(processorTime = [1, 2, 3, 4, 5, 6, 7, 8],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 21\n assert candidate(processorTime = [1000000000, 2000000000, 3000000000, 4000000000],tasks = [1000000000, 1000000000, 1000000000, 1000000000, 900000000, 900000000, 900000000, 900000000, 800000000, 800000000, 800000000, 800000000, 700000000, 700000000, 700000000, 700000000]) == 4700000000\n assert candidate(processorTime = [50, 40, 30, 20, 10, 0],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 54\n assert candidate(processorTime = [100, 200, 300, 400, 500],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 660\n assert candidate(processorTime = [100, 200, 300, 400, 500, 600, 700, 800],tasks = [8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200]) == 8500\n assert candidate(processorTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],tasks = [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"}, "metadata": {"canonical_parameter_names": ["processorTime", "tasks"], "leetcode_dataset_entry_point": "Solution().minProcessingTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minProcessingTime(List processorTime, List tasks) {", "container": "Solution", "callable": "minProcessingTime", "parameters": [{"name": "processorTime", "type": "List"}, {"name": "tasks", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2896, "task_id": "apply-operations-to-make-two-strings-equal", "difficulty": "Medium", "problem_description": "You are given two 0-indexed binary strings s1 and s2, both of length n, and a positive integer x.\nYou can perform any of the following operations on the string s1 any number of times:\n\nChoose two indices i and j, and flip both s1[i] and s1[j]. The cost of this operation is x.\nChoose an index i such that i < n - 1 and flip both s1[i] and s1[i + 1]. The cost of this operation is 1.\n\nReturn the minimum cost needed to make the strings s1 and s2 equal, or return -1 if it is impossible.\nNote that flipping a character means changing it from 0 to 1 or vice-versa.\n \nExample 1:\n\nInput: s1 = \"1100011000\", s2 = \"0101001010\", x = 2\nOutput: 4\nExplanation: We can do the following operations:\n- Choose i = 3 and apply the second operation. The resulting string is s1 = \"1101111000\".\n- Choose i = 4 and apply the second operation. The resulting string is s1 = \"1101001000\".\n- Choose i = 0 and j = 8 and apply the first operation. The resulting string is s1 = \"0101001010\" = s2.\nThe total cost is 1 + 1 + 2 = 4. It can be shown that it is the minimum cost possible.\n\nExample 2:\n\nInput: s1 = \"10110\", s2 = \"00011\", x = 4\nOutput: -1\nExplanation: It is not possible to make the two strings equal.\n\n \nConstraints:\n\nn == s1.length == s2.length\n1 <= n, x <= 500\ns1 and s2 consist only of the characters '0' and '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"101010\",s2 = \"010101\",x = 1) == 3\n assert candidate(s1 = \"1111\",s2 = \"1111\",x = 3) == 0\n assert candidate(s1 = \"101010\",s2 = \"010101\",x = 5) == 3\n assert candidate(s1 = \"1111\",s2 = \"1111\",x = 5) == 0\n assert candidate(s1 = \"1111\",s2 = \"1111\",x = 10) == 0\n assert candidate(s1 = \"001100\",s2 = \"110011\",x = 3) == 3\n assert candidate(s1 = \"101010\",s2 = \"010101\",x = 3) == 3\n assert candidate(s1 = \"1100011000\",s2 = \"0101001010\",x = 2) == 4\n assert candidate(s1 = \"0000\",s2 = \"1111\",x = 1) == 2\n assert candidate(s1 = \"0000\",s2 = \"1111\",x = 5) == 2\n assert candidate(s1 = \"10110\",s2 = \"00011\",x = 4) == -1\n assert candidate(s1 = \"110100001111001011010101010101010101010101\",s2 = \"001011110001010100101010101010101010101010\",x = 8) == 22\n assert candidate(s1 = \"01010101010101\",s2 = \"10101010101010\",x = 1) == 7\n assert candidate(s1 = \"00000000000000\",s2 = \"11111111111111\",x = 1) == 7\n assert candidate(s1 = \"1010101010101010101010\",s2 = \"1101101101101101101101\",x = 7) == 12\n assert candidate(s1 = \"000000000000\",s2 = \"111111111111\",x = 10) == 6\n assert candidate(s1 = \"000000000000000000000000000000000000\",s2 = \"111111111111111111111111111111111111\",x = 20) == 18\n assert candidate(s1 = \"110011001100\",s2 = \"001100110011\",x = 7) == 6\n assert candidate(s1 = \"111000111000111\",s2 = \"000111000111000\",x = 15) == -1\n assert candidate(s1 = \"101010101010\",s2 = \"010101010101\",x = 7) == 6\n assert candidate(s1 = \"11001100110011\",s2 = \"00110011001100\",x = 10) == 7\n assert candidate(s1 = \"0000000000000000000000\",s2 = \"1111111111111111111111\",x = 20) == 11\n assert candidate(s1 = \"110011001100\",s2 = \"001100110011\",x = 6) == 6\n assert candidate(s1 = \"1111000011\",s2 = \"0000111100\",x = 4) == 5\n assert candidate(s1 = \"1001001001001001\",s2 = \"0110110110110110\",x = 15) == 8\n assert candidate(s1 = \"111000111000\",s2 = \"000111000111\",x = 6) == 6\n assert candidate(s1 = \"000000000000\",s2 = \"111111111111\",x = 100) == 6\n assert candidate(s1 = \"1111000011110000\",s2 = \"0000111100001111\",x = 3) == 8\n assert candidate(s1 = \"01010101010\",s2 = \"10101010101\",x = 10) == -1\n assert candidate(s1 = \"111000000111\",s2 = \"000111111000\",x = 3) == 6\n assert candidate(s1 = \"101010101010\",s2 = \"010101010101\",x = 4) == 6\n assert candidate(s1 = \"100110011001\",s2 = \"011001100110\",x = 7) == 6\n assert candidate(s1 = \"111100001111\",s2 = \"000011110000\",x = 3) == 6\n assert candidate(s1 = \"10101010101010101010101010101010\",s2 = \"01010101010101010101010101010101\",x = 5) == 16\n assert candidate(s1 = \"1100101010101010\",s2 = \"0110010101010101\",x = 5) == 8\n assert candidate(s1 = \"10010010010010010010010010010010\",s2 = \"01101101101101101101101101101101\",x = 3) == 16\n assert candidate(s1 = \"100010001000\",s2 = \"011101110111\",x = 20) == 6\n assert candidate(s1 = \"111000111000\",s2 = \"000111000111\",x = 8) == 6\n assert candidate(s1 = \"0011001100\",s2 = \"1100110011\",x = 2) == 5\n assert candidate(s1 = \"010101010101010101010101\",s2 = \"101010101010101010101010\",x = 1) == 12\n assert candidate(s1 = \"1010101010101010101010\",s2 = \"0101010101010101010101\",x = 4) == 11\n assert candidate(s1 = \"0110011001\",s2 = \"1001100110\",x = 7) == 5\n assert candidate(s1 = \"101010101010\",s2 = \"101010101010\",x = 7) == 0\n assert candidate(s1 = \"10101010101010\",s2 = \"01010101010101\",x = 5) == 7\n assert candidate(s1 = \"0000000000\",s2 = \"1111111111\",x = 10) == 5\n assert candidate(s1 = \"101010101010\",s2 = \"101010101010\",x = 10) == 0\n assert candidate(s1 = \"111111111111\",s2 = \"000000000000\",x = 1) == 6\n assert candidate(s1 = \"101010101010\",s2 = \"010101010101\",x = 1) == 6\n assert candidate(s1 = \"110101010101\",s2 = \"001010101010\",x = 10) == 6\n assert candidate(s1 = \"101010101010\",s2 = \"110011001100\",x = 8) == 3\n assert candidate(s1 = \"111000001110\",s2 = \"111111111111\",x = 6) == 6\n assert candidate(s1 = \"11110000111100001111\",s2 = \"00001111000011110000\",x = 10) == 10\n assert candidate(s1 = \"1001100110\",s2 = \"1100110011\",x = 2) == -1\n assert candidate(s1 = \"010101010101\",s2 = \"101010101010\",x = 10) == 6\n assert candidate(s1 = \"10101010101010\",s2 = \"01010101010101\",x = 4) == 7\n assert candidate(s1 = \"0000000000000000000000\",s2 = \"0000000000000000000000\",x = 8) == 0\n assert candidate(s1 = \"11110000\",s2 = \"00001111\",x = 3) == 4\n assert candidate(s1 = \"101010101010\",s2 = \"101010101010\",x = 1) == 0\n assert candidate(s1 = \"0000000000\",s2 = \"1111111111\",x = 15) == 5\n assert candidate(s1 = \"1100110011\",s2 = \"0011001100\",x = 10) == 5\n assert candidate(s1 = \"1111000011110000\",s2 = \"0000111100001111\",x = 8) == 8\n assert candidate(s1 = \"111011101110\",s2 = \"000100010001\",x = 4) == 6\n assert candidate(s1 = \"11111111111111\",s2 = \"11111111111111\",x = 100) == 0\n assert candidate(s1 = \"000000000000000000000000000000\",s2 = \"111111111111111111111111111111\",x = 50) == 15\n assert candidate(s1 = \"110110110110\",s2 = \"111001100111\",x = 2) == 4\n assert candidate(s1 = \"111000111\",s2 = \"111111111\",x = 1) == -1\n assert candidate(s1 = \"0101010101\",s2 = \"1100110011\",x = 2) == -1\n assert candidate(s1 = \"0101010101010101010101010101010101010101\",s2 = \"1010101010101010101010101010101010101010\",x = 4) == 20\n assert candidate(s1 = \"01010101010101010101\",s2 = \"10101010101010101010\",x = 3) == 10\n assert candidate(s1 = \"1001100110\",s2 = \"0110011001\",x = 3) == 5\n assert candidate(s1 = \"1111111111\",s2 = \"0000000000\",x = 3) == 5\n assert candidate(s1 = \"1100110011\",s2 = \"0011001100\",x = 5) == 5\n assert candidate(s1 = \"110110110110110110\",s2 = \"001001001001001001\",x = 6) == 9\n assert candidate(s1 = \"1111111111111111111111\",s2 = \"1111111111111111111111\",x = 2) == 0\n assert candidate(s1 = \"111000111000\",s2 = \"000111000111\",x = 3) == 6\n assert candidate(s1 = \"01010101010101\",s2 = \"10101010101010\",x = 8) == 7\n assert candidate(s1 = \"1001001001\",s2 = \"0110110110\",x = 6) == 5\n assert candidate(s1 = \"0101010101\",s2 = \"1010101010\",x = 10) == 5\n assert candidate(s1 = \"1101101101\",s2 = \"1010101010\",x = 5) == 6\n assert candidate(s1 = \"010101010101\",s2 = \"101010101010\",x = 2) == 6\n assert candidate(s1 = \"111000111000\",s2 = \"000111000111\",x = 7) == 6\n assert candidate(s1 = \"1100110011001100\",s2 = \"0011001100110011\",x = 9) == 8\n assert candidate(s1 = \"1101010101\",s2 = \"0110101010\",x = 5) == -1\n assert candidate(s1 = \"110000110000\",s2 = \"001111001111\",x = 4) == 6\n assert candidate(s1 = \"1100110011\",s2 = \"0011001100\",x = 8) == 5\n assert candidate(s1 = \"111111111111\",s2 = \"000000000000\",x = 2) == 6\n assert candidate(s1 = \"100010001000\",s2 = \"011101110111\",x = 4) == 6\n assert candidate(s1 = \"10101010101010\",s2 = \"01010101010101\",x = 8) == 7\n assert candidate(s1 = \"10101010101010\",s2 = \"11001100110011\",x = 6) == -1\n assert candidate(s1 = \"11010101010101010101\",s2 = \"00101010101010101010\",x = 2) == 10\n assert candidate(s1 = \"110011001100110011001100\",s2 = \"001100110011001100110011\",x = 9) == 12\n assert candidate(s1 = \"111000111000\",s2 = \"000111000111\",x = 10) == 6\n assert candidate(s1 = \"10101010101010\",s2 = \"01010101010101\",x = 15) == 7\n assert candidate(s1 = \"1001001001\",s2 = \"1110111011\",x = 5) == 5\n assert candidate(s1 = \"111111000000\",s2 = \"000000111111\",x = 2) == 6\n assert candidate(s1 = \"110011001100110011001100110011001100\",s2 = \"110011001100110011001100110011001100\",x = 15) == 0\n assert candidate(s1 = \"110001100011\",s2 = \"001110011100\",x = 2) == 6\n assert candidate(s1 = \"100100100100\",s2 = \"011001100110\",x = 1) == 3\n assert candidate(s1 = \"110011001100\",s2 = \"001100110011\",x = 5) == 6\n assert candidate(s1 = \"1001010010\",s2 = \"0110101101\",x = 5) == 5\n assert candidate(s1 = \"111111111111\",s2 = \"000000000000\",x = 3) == 6\n assert candidate(s1 = \"111000111000111\",s2 = \"000111000111000\",x = 1) == -1\n assert candidate(s1 = \"110111011101\",s2 = \"001000100010\",x = 6) == 6\n assert candidate(s1 = \"11110000\",s2 = \"00001111\",x = 1) == 4\n assert candidate(s1 = \"011001100110\",s2 = \"100110011001\",x = 9) == 6\n assert candidate(s1 = \"11111111111111111111111111111111\",s2 = \"11111111111111111111111111111111\",x = 7) == 0\n assert candidate(s1 = \"10101010101010101010101010101010\",s2 = \"01010101010101010101010101010101\",x = 10) == 16\n assert candidate(s1 = \"1100101100\",s2 = \"0011010011\",x = 5) == 5\n assert candidate(s1 = \"000000000000\",s2 = \"111111111111\",x = 1) == 6\n assert candidate(s1 = \"100100100100\",s2 = \"100100100100\",x = 7) == 0\n assert candidate(s1 = \"111000111\",s2 = \"111111111\",x = 5) == -1\n assert candidate(s1 = \"1001010101\",s2 = \"0110101010\",x = 5) == 5\n assert candidate(s1 = \"110110110110\",s2 = \"001001001001\",x = 2) == 6\n"}, "metadata": {"canonical_parameter_names": ["s1", "s2", "x"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minOperations(String s1, String s2, int x) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "s1", "type": "String"}, {"name": "s2", "type": "String"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2897, "task_id": "apply-operations-on-array-to-maximize-sum-of-squares", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums and a positive integer k.\nYou can do the following operation on the array any number of times:\n\nChoose any two distinct indices i and j and simultaneously update the values of nums[i] to (nums[i] AND nums[j]) and nums[j] to (nums[i] OR nums[j]). Here, OR denotes the bitwise OR operation, and AND denotes the bitwise AND operation.\n\nYou have to choose k elements from the final array and calculate the sum of their squares.\nReturn the maximum sum of squares you can achieve.\nSince the answer can be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [2,6,5,8], k = 2\nOutput: 261\nExplanation: We can do the following operations on the array:\n- Choose i = 0 and j = 3, then change nums[0] to (2 AND 8) = 0 and nums[3] to (2 OR 8) = 10. The resulting array is nums = [0,6,5,10].\n- Choose i = 2 and j = 3, then change nums[2] to (5 AND 10) = 0 and nums[3] to (5 OR 10) = 15. The resulting array is nums = [0,6,0,15].\nWe can choose the elements 15 and 6 from the final array. The sum of squares is 152 + 62 = 261.\nIt can be shown that this is the maximum value we can get.\n\nExample 2:\n\nInput: nums = [4,5,4,7], k = 3\nOutput: 90\nExplanation: We do not need to apply any operations.\nWe can choose the elements 7, 5, and 4 with a sum of squares: 72 + 52 + 42 = 90.\nIt can be shown that this is the maximum value we can get.\n\n \nConstraints:\n\n1 <= k <= nums.length <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == 99\n assert candidate(nums = [10, 10, 10, 10],k = 4) == 400\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 2) == 98\n assert candidate(nums = [10, 10, 10, 10],k = 2) == 200\n assert candidate(nums = [1, 1, 1, 1],k = 4) == 4\n assert candidate(nums = [3, 3, 3, 3, 3, 3],k = 3) == 27\n assert candidate(nums = [2, 6, 5, 8],k = 2) == 261\n assert candidate(nums = [4, 5, 4, 7],k = 3) == 90\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777],k = 2) == 976625502\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 49\n assert candidate(nums = [1, 1, 1, 1, 1, 1],k = 6) == 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],k = 20) == 20\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999],k = 20) == 1280\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 10) == 73676282\n assert candidate(nums = [123456789, 987654321, 234567890, 876543210, 456789012, 765432109, 654321098, 543210987, 432109876, 321098765],k = 10) == 686045577\n assert candidate(nums = [999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937],k = 5) == 24500\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 3) == 147\n assert candidate(nums = [134217728, 268435456, 536870912, 1073741824, 67108864, 134217728, 268435456, 536870912, 1073741824, 67108864],k = 10) == 214664351\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73],k = 20) == 65732\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 7) == 64660\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1024, 2048, 4096, 8192, 16384],k = 15) == 74023771\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32],k = 6) == 7938\n assert candidate(nums = [123456789, 987654321, 111222333, 333222111, 444555666],k = 4) == 54499332\n assert candidate(nums = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17],k = 16) == 4624\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 = 15) == 509522932\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 11) == 4190209\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31],k = 10) == 9610\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 10) == 4186116\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999],k = 10) == 640\n assert candidate(nums = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17],k = 10) == 2890\n assert candidate(nums = [8, 4, 2, 1, 16, 32, 64, 128, 256, 512],k = 10) == 1046529\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],k = 5) == 847975472\n assert candidate(nums = [31, 15, 7, 3, 1, 128, 64, 32, 16, 8],k = 10) == 66221\n assert candidate(nums = [23456789, 987654321, 34567890, 876543210, 45678901, 765432109],k = 3) == 500137909\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888],k = 10) == 10971971\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 = 10) == 509522932\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31],k = 25) == 24025\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == 242976\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643],k = 3) == 551856212\n assert candidate(nums = [314159, 271828, 161803, 414159, 926535, 897932, 384626, 433832, 795028, 841971],k = 5) == 410299793\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 = 10) == 94637808\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],k = 5) == 320\n assert candidate(nums = [233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233],k = 20) == 1085780\n assert candidate(nums = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005],k = 4) == 43\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 = 15) == 11297913\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000],k = 10) == 790321908\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(nums = [256, 128, 64, 32, 16, 8, 4, 2, 1],k = 9) == 261121\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 = 20) == 509522932\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],k = 10) == 10\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 10) == 351846767\n assert candidate(nums = [65535, 65534, 65533, 65532, 65531, 65530, 65529, 65528, 65527, 65526, 65525, 65524, 65523, 65522, 65521],k = 10) == 944430306\n assert candidate(nums = [2147483647, 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, 1],k = 10) == 701237477\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 = 20) == 20\n assert candidate(nums = [31, 17, 15, 13, 11, 7, 5, 3, 2],k = 5) == 2421\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 = 21) == 42286015\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647],k = 10) == 506187364\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888],k = 5) == 108685633\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) == 10\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644],k = 4) == 632671383\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 7) == 57663\n assert candidate(nums = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000],k = 5) == 757777593\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 = 15) == 420002\n assert candidate(nums = [1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006, 1000007, 1000008, 1000009],k = 5) == 89965549\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384],k = 3) == 7681529\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000],k = 5) == 216111556\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 5) == 53085\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 864204680, 975318642, 789456123, 654321987, 321654987, 456789123],k = 5) == 103639635\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 5) == 245\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 = 30) == 192245\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000],k = 6) == 785975284\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) == 500\n assert candidate(nums = [1023, 2047, 3071, 4095, 5119, 6143, 7167, 8191],k = 8) == 272556040\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642, 2147483641, 2147483640, 2147483639, 2147483638, 2147483637],k = 11) == 133607314\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 8) == 1394008\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483647, 2147483647],k = 2) == 701237477\n assert candidate(nums = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17],k = 5) == 1445\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 5) == 245\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 5) == 3461\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],k = 10) == 6250\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 5) == 1392773\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 5) == 704657727\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536],k = 8) == 179344781\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 11) == 8380418\n assert candidate(nums = [123456789, 987654321, 123456789, 987654321, 123456789, 987654321, 123456789, 987654321, 123456789, 987654321],k = 5) == 925171582\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048],k = 5) == 460740093\n assert candidate(nums = [13, 27, 39, 45, 51, 63, 75, 87, 99, 111, 123, 135, 147, 159, 171],k = 10) == 286506\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79],k = 10) == 80842\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047],k = 5) == 5579013\n assert candidate(nums = [1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024],k = 10) == 10485760\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],k = 30) == 850618742\n assert candidate(nums = [31, 15, 7, 3, 1, 0],k = 4) == 1244\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13],k = 15) == 2535\n assert candidate(nums = [31, 62, 124, 248, 496, 992, 1984, 3968, 7936, 15872],k = 5) == 357400917\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483647],k = 4) == 402474947\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536],k = 7) == 912482192\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxSum(List nums, int k) {", "container": "Solution", "callable": "maxSum", "parameters": [{"name": "nums", "type": "List"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2899, "task_id": "last-visited-integers", "difficulty": "Easy", "problem_description": "Given an integer array nums where nums[i] is either a positive integer or -1. We need to find for each -1 the respective positive integer, which we call the last visited integer.\nTo achieve this goal, let's define two empty arrays: seen and ans.\nStart iterating from the beginning of the array nums.\n\nIf a positive integer is encountered, prepend it to the front of seen.\nIf -1 is encountered, let k be the number of consecutive -1s seen so far (including the current -1),\n\t\nIf k is less than or equal to the length of seen, append the k-th element of seen to ans.\nIf k is strictly greater than the length of seen, append -1 to ans.\n\n\n\nReturn the array ans.\n \nExample 1:\n\nInput: nums = [1,2,-1,-1,-1]\nOutput: [2,1,-1]\nExplanation:\nStart with seen = [] and ans = [].\n\nProcess nums[0]: The first element in nums is 1. We prepend it to the front of seen. Now, seen == [1].\nProcess nums[1]: The next element is 2. We prepend it to the front of seen. Now, seen == [2, 1].\nProcess nums[2]: The next element is -1. This is the first occurrence of -1, so k == 1. We look for the first element in seen. We append 2 to ans. Now, ans == [2].\nProcess nums[3]: Another -1. This is the second consecutive -1, so k == 2. The second element in seen is 1, so we append 1 to ans. Now, ans == [2, 1].\nProcess nums[4]: Another -1, the third in a row, making k = 3. However, seen only has two elements ([2, 1]). Since k is greater than the number of elements in seen, we append -1 to ans. Finally, ans == [2, 1, -1].\n\n\nExample 2:\n\nInput: nums = [1,-1,2,-1,-1]\nOutput: [1,2,1]\nExplanation:\nStart with seen = [] and ans = [].\n\nProcess nums[0]: The first element in nums is 1. We prepend it to the front of seen. Now, seen == [1].\nProcess nums[1]: The next element is -1. This is the first occurrence of -1, so k == 1. We look for the first element in seen, which is 1. Append 1 to ans. Now, ans == [1].\nProcess nums[2]: The next element is 2. Prepend this to the front of seen. Now, seen == [2, 1].\nProcess nums[3]: The next element is -1. This -1 is not consecutive to the first -1 since 2 was in between. Thus, k resets to 1. The first element in seen is 2, so append 2 to ans. Now, ans == [1, 2].\nProcess nums[4]: Another -1. This is consecutive to the previous -1, so k == 2. The second element in seen is 1, append 1 to ans. Finally, ans == [1, 2, 1].\n\n\n \nConstraints:\n\n1 <= nums.length <= 100\nnums[i] == -1 or 1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, -1, 1, 2, -1]) == [-1, -1, 2]\n assert candidate(nums = [1, 2, 3, 4, -1, -1, -1, -1]) == [4, 3, 2, 1]\n assert candidate(nums = [1, -1, -1, -1, 2, -1, -1, 3, -1]) == [1, -1, -1, 2, 1, 3]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10]) == [-1, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 1, 1, -1, -1, -1, -1]) == [1, 1, 1, -1]\n assert candidate(nums = [1, 2, 3, -1, 4, 5, -1, -1, 6, -1, -1, -1]) == [3, 5, 4, 6, 5, 4]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 1, 1]\n assert candidate(nums = [1, -1, -1, -1, 2, -1]) == [1, -1, -1, 2]\n assert candidate(nums = [1, 2, 3, 4, 5]) == []\n assert candidate(nums = [5, 5, 5, -1, -1, -1, -1, -1]) == [5, 5, 5, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [5, 4, 3, 2, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [-1, -1, -1, -1]) == [-1, -1, -1, -1]\n assert candidate(nums = [10, -1, 20, -1, -1, 30, -1, -1, -1]) == [10, 20, 10, 30, 20, 10]\n assert candidate(nums = [5, -1, 5, -1, 5, -1]) == [5, 5, 5]\n assert candidate(nums = [-1, -1, 1, 2, -1, -1]) == [-1, -1, 2, 1]\n assert candidate(nums = [100, -1, -1, -1, -1, -1, -1, -1]) == [100, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, -1, -1, -1, -1, -1, -1, -1]) == [50, 40, 30, 20, 10, -1, -1]\n assert candidate(nums = [-1, -1, 1, 2, 3, -1]) == [-1, -1, 3]\n assert candidate(nums = [50, 25, 75, -1, -1, 100, -1, -1, -1]) == [75, 25, 100, 75, 25]\n assert candidate(nums = [1, 1, 1, -1, -1, -1, -1, -1]) == [1, 1, 1, -1, -1]\n assert candidate(nums = [1, -1, 2, -1, -1]) == [1, 2, 1]\n assert candidate(nums = [10, 20, 30, -1, -1, -1, 40, -1, -1, -1, -1]) == [30, 20, 10, 40, 30, 20, 10]\n assert candidate(nums = [3, -1, 4, -1, 5, -1, -1]) == [3, 4, 5, 4]\n assert candidate(nums = [5, 5, 5, -1, -1, 5, -1, -1, -1, -1]) == [5, 5, 5, 5, 5, 5]\n assert candidate(nums = [-1, 1, 2, -1, -1, -1]) == [-1, 2, 1, -1]\n assert candidate(nums = [3, 4, 5, -1, -1, -1, -1]) == [5, 4, 3, -1]\n assert candidate(nums = [-1, -1, -1]) == [-1, -1, -1]\n assert candidate(nums = [3, 4, 5, -1, -1, 6, -1]) == [5, 4, 6]\n assert candidate(nums = [5, -1, 4, -1, 3, -1, 2, -1, 1, -1]) == [5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, -1, -1, -1]) == [2, 1, -1]\n assert candidate(nums = [100, -1, -1, -1, 50, 60, -1, -1, -1, -1, -1]) == [100, -1, -1, 60, 50, 100, -1, -1]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, 97, -1, 96, -1]) == [100, 99, 98, 97, 96]\n assert candidate(nums = [1, -1, -1, 2, -1, 3, -1, -1]) == [1, -1, 2, 3, 2]\n assert candidate(nums = [1, -1, -1, 2, -1, -1, 3, -1, -1, 4, -1, -1]) == [1, -1, 2, 1, 3, 2, 4, 3]\n assert candidate(nums = [10, 20, 30, -1, -1, -1, -1]) == [30, 20, 10, -1]\n assert candidate(nums = [1, 2, 3, -1, 4, 5, -1, 6, 7, -1, 8, 9, -1, 10, 11, -1, -1, -1, -1]) == [3, 5, 7, 9, 11, 10, 9, 8]\n assert candidate(nums = [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]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(nums = [-1, -1, -1, -1, -1, 1, 2, 3, -1, -1, 4, 5, -1, -1, -1, 6, 7, -1, -1, -1, -1]) == [-1, -1, -1, -1, -1, 3, 2, 5, 4, 3, 7, 6, 5, 4]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1]) == [-1, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [-1, 1, 2, -1, 3, 4, 5, -1, -1, -1, -1, 6, 7, 8, 9, -1, -1, -1, -1, -1]) == [-1, 2, 5, 4, 3, 2, 9, 8, 7, 6, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, -1, -1, -1, 60, 70, 80, -1, -1, -1, 90, 100, -1, -1, -1, 110, 120, -1, -1, -1]) == [50, 40, 30, 80, 70, 60, 100, 90, 80, 120, 110, 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]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, 97, -1, 96, -1, 95, -1]) == [100, 99, 98, 97, 96, 95]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1, 6, 7, 8, 9, -1, -1, -1, -1, -1]) == [5, 4, 3, 2, 9, 8, 7, 6, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, 6, 7, 8, 9, 10, -1, -1, -1, 11, 12, 13, 14, 15, -1, -1, -1, 16, 17, 18, 19, 20, -1, -1, -1]) == [5, 4, 3, 10, 9, 8, 15, 14, 13, 20, 19, 18]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, -1, 97, -1, -1, -1, -1, -1]) == [100, 99, 98, 99, 97, 98, 99, 100, -1]\n assert candidate(nums = [1, 2, 3, -1, -1, -1, 4, 5, 6, -1, -1, -1, 7, 8, 9, -1, -1, -1, 10, 11, 12, -1, -1, -1]) == [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10]\n assert candidate(nums = [1, 2, 3, -1, 4, -1, -1, 5, -1, -1, -1, -1]) == [3, 4, 3, 5, 4, 3, 2]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, -1, -1, -1]) == [-1, 1, 2, 3, 4, 5, 4, 3, 2]\n assert candidate(nums = [10, -1, 20, -1, 30, -1, 40, -1, 50, -1, 60, -1, 70, -1, 80, -1, 90, -1, 100, -1, -1, -1, -1]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70]\n assert candidate(nums = [-1, -1, 1, -1, -1, 2, -1, -1, 3, -1, -1, 4, -1, -1, 5, -1, -1, 6, -1, -1, 7, -1, -1, 8, -1, -1, 9, -1, -1, 10, -1, -1]) == [-1, -1, 1, -1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9]\n assert candidate(nums = [10, -1, 20, -1, 30, -1, 40, -1, 50, -1, 60, -1, 70, -1]) == [10, 20, 30, 40, 50, 60, 70]\n assert candidate(nums = [1, 2, 3, 4, -1, 5, 6, -1, -1, 7, 8, -1, -1, -1, -1, -1]) == [4, 6, 5, 8, 7, 6, 5, 4]\n assert candidate(nums = [1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, 11, -1, 12, -1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums = [1, 2, 3, -1, 4, 5, -1, 6, 7, -1, 8, 9, -1, 10, 11, -1, 12, 13, -1, 14, 15, -1, 16, 17, -1, 18, 19, -1, 20, 21, -1, 22, 23, -1]) == [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]\n assert candidate(nums = [1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 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]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1]) == [1, 2, 3, 4, 5, 6, 7, 8, 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]\n assert candidate(nums = [1, 2, 3, -1, -1, -1, 4, 5, 6, -1, -1, -1, -1, -1]) == [3, 2, 1, 6, 5, 4, 3, 2]\n assert candidate(nums = [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]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1, 6, 7, -1, -1, -1, -1, -1]) == [5, 4, 3, 2, 7, 6, 5, 4, 3]\n assert candidate(nums = [100, 99, 98, 97, 96, -1, -1, 95, -1, -1, 94, -1, -1, 93, -1, -1, -1, -1]) == [96, 97, 95, 96, 94, 95, 93, 94, 95, 96]\n assert candidate(nums = [1, 2, -1, 3, 4, -1, 5, 6, -1, -1, -1, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, 13, 14, -1, -1]) == [2, 4, 6, 5, 4, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, 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, -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1, -1, -1, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1]) == [5, 4, 3, 2, 1, -1, 10, 9, 8, 7, 6, 5, 4]\n assert candidate(nums = [50, -1, 49, -1, 48, -1, 47, -1, 46, -1, 45, -1, 44, -1, 43, -1, 42, -1, 41, -1, 40, -1, 39, -1, 38, -1, 37, -1, 36, -1, 35, -1, 34, -1, 33, -1, 32, -1, 31, -1, 30, -1, 29, -1, 28, -1, 27, -1, 26, -1, 25, -1, 24, -1, 23, -1, 22, -1, 21, -1, 20, -1, 19, -1, 18, -1, 17, -1, 16, -1, 15, -1, 14, -1, 13, -1, 12, -1, 11, -1, 10, -1, 9, -1, 8, -1, 7, -1, 6, -1, 5, -1, 4, -1, 3, -1, 2, -1, 1, -1]) == [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]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, 16, -1, 17, -1, 18, -1, -1, -1, -1, -1]) == [15, 16, 17, 18, 17, 16, 15, 14]\n assert candidate(nums = [10, 20, 30, 40, 50, -1, -1, -1, 60, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1]) == [50, 40, 30, 60, 50, 40, 30, 70, 60, 50, 40, 30]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6]\n assert candidate(nums = [50, -1, 51, -1, 52, -1, 53, -1, 54, -1, 55, -1, 56, -1, 57, -1, 58, -1, 59, -1, 60, -1, 61, -1, 62, -1]) == [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1, -1, 6, 7, 8, -1, -1, -1, -1]) == [5, 4, 3, 2, 1, 8, 7, 6, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6]\n assert candidate(nums = [7, -1, 8, -1, -1, 9, -1, -1, -1, -1, 10, -1]) == [7, 8, 7, 9, 8, 7, -1, 10]\n assert candidate(nums = [1, 2, -1, 3, 4, -1, 5, 6, -1, 7, 8, -1, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [2, 4, 6, 8, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, -1, 2, -1, 3, -1, -1, -1, 4, -1, -1]) == [1, 2, 3, 2, 1, 4, 3]\n assert candidate(nums = [5, -1, 10, -1, 15, -1, 20, -1, 25, -1, 30, -1, -1, -1, -1]) == [5, 10, 15, 20, 25, 30, 25, 20, 15]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1, 6, 7, 8, -1, -1, -1, -1, 9, 10, -1, -1, -1, -1]) == [5, 4, 3, 2, 8, 7, 6, 5, 10, 9, 8, 7]\n assert candidate(nums = [1, 2, 3, -1, 4, 5, -1, -1, -1, -1]) == [3, 5, 4, 3, 2]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, 97, -1, 96, -1, 95, -1, 94, -1, 93, -1, 92, -1, 91, -1]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, 97, -1, 96, -1, 95, -1, 94, -1]) == [100, 99, 98, 97, 96, 95, 94]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, 97, -1, 96, -1, 95, -1, 94, -1, 93, -1, 92, -1, 91, -1, 90, -1]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]\n assert candidate(nums = [1, -1, -1, 2, -1, -1, 3, -1, -1, 4, -1, -1, 5, -1, -1, 6, -1, -1, 7, -1, -1]) == [1, -1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6]\n assert candidate(nums = [9, -1, 8, -1, 7, -1, 6, -1, 5, -1, 4, -1, 3, -1, 2, -1, 1, -1, -1, -1, -1, 10, -1, -1, -1, -1, 11, -1, -1, -1, -1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 10, 1, 2, 3, 11, 10, 1, 2]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10]) == [-1, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, -1, -1, -1, -1, 4, 4, -1, -1, -1, -1, 5, 5, -1, -1, -1, -1]) == [3, 3, 2, 2, 4, 4, 3, 3, 5, 5, 4, 4]\n assert candidate(nums = [1, -1, -1, -1, -1, 2, -1, -1, 3, -1, 4, -1, -1, 5, -1, -1, -1, 6, -1, -1]) == [1, -1, -1, -1, 2, 1, 3, 4, 3, 5, 4, 3, 6, 5]\n assert candidate(nums = [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, 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, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6]\n assert candidate(nums = [100, 99, -1, 98, -1, 97, -1, -1, 96, -1, -1, -1, -1, -1]) == [99, 98, 97, 98, 96, 97, 98, 99, 100]\n assert candidate(nums = [1, 2, -1, 3, 4, -1, 5, 6, -1, 7, 8, -1, 9, 10, -1, 11, 12, -1, 13, 14, -1, 15, 16, -1, 17, 18, -1, 19, 20, -1]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [1, 2, -1, 3, 4, -1, -1, 5, -1, -1, -1, -1]) == [2, 4, 3, 5, 4, 3, 2]\n assert candidate(nums = [-1, -1, -1, -1, 1, -1, -1, -1, 2, -1, -1, 3, -1, -1, 4, -1, -1, -1, 5, -1, -1]) == [-1, -1, -1, -1, 1, -1, -1, 2, 1, 3, 2, 4, 3, 2, 5, 4]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, 97, -1, 96, -1, 95, -1, 94, -1, 93, -1, 92, -1, 91, -1]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]\n assert candidate(nums = [-1, -1, 1, 2, -1, 3, 4, -1, -1, 5, 6, -1, -1, 7, 8, -1, -1, 9, 10, -1, -1]) == [-1, -1, 2, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [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, 5, -1]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 80]) == [60, 50, 40, 30, 20, 10, -1, -1, -1, -1]\n assert candidate(nums = [-1, -1, -1, 1, -1, -1, 2, -1, -1, 3, -1, -1, 4, -1, -1, 5, -1, -1, 6, -1, -1, 7, -1, -1, 8, -1, -1, 9, -1, -1]) == [-1, -1, -1, 1, -1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]\n assert candidate(nums = [-1, -1, -1, 1, -1, -1, 2, -1, -1, 3, -1, -1, 4, -1, -1, 5, -1, -1, 6, -1, -1, 7, -1, -1, 8, -1, -1, 9, -1, -1, 10, -1, -1, -1]) == [-1, -1, -1, 1, -1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 8]\n assert candidate(nums = [1, 2, -1, -1, 3, 4, -1, -1, -1, 5, 6, -1, -1, -1, -1, 7, 8, -1, -1, -1, -1, -1, 9, 10, -1, -1, -1, -1, -1, -1]) == [2, 1, 4, 3, 2, 6, 5, 4, 3, 8, 7, 6, 5, 4, 10, 9, 8, 7, 6, 5]\n assert candidate(nums = [1, 2, 3, -1, -1, 4, 5, 6, -1, -1, -1, 7, 8, 9, -1, -1, -1, -1, 10, 11, 12, -1, -1, -1, -1, -1, 13, 14, 15, -1, -1, -1, -1, -1]) == [3, 2, 6, 5, 4, 9, 8, 7, 6, 12, 11, 10, 9, 8, 15, 14, 13, 12, 11]\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 2, -1, -1, 3, -1, -1, 4, -1, -1, 5, -1, -1, 6, -1, -1, 7, -1, -1, 8, -1, -1, 9, -1, -1, 10, -1, -1, 11, -1, -1, 12, -1, -1, 13, -1, -1, 14, -1, -1, 15, -1, -1, 16, -1, -1, 17, -1, -1, 18, -1, -1, 19, -1, -1, 20, -1, -1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -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, 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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1]) == [-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 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, 6, 7, 8, 9, 10, -1, -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, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6]\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, -1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [50, 49, 48, 47, 46, -1, 45, -1, -1, 44, -1, -1, -1, 43, -1, -1, -1, -1, 42, -1, -1, -1, -1, -1]) == [46, 45, 46, 44, 45, 46, 43, 44, 45, 46, 42, 43, 44, 45, 46]\n assert candidate(nums = [1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [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]) == [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 = [1, 2, 3, -1, -1, 4, -1, -1, -1, 5, -1, -1, -1, -1]) == [3, 2, 4, 3, 2, 5, 4, 3, 2]\n assert candidate(nums = [5, 4, 3, 2, 1, -1, -1, -1, -1, -1, -1, -1, -1]) == [1, 2, 3, 4, 5, -1, -1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1]) == [1, 1, 1, 1]\n assert candidate(nums = [5, -1, -1, -1, -1, -1, -1]) == [5, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [10, -1, 20, -1, 30, -1, -1, -1]) == [10, 20, 30, 20, 10]\n assert candidate(nums = [100, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [100, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, 5, -1, -1, 2, -1, -1, -1]) == [5, 3, 2, 5, 3]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, 97, -1, -1]) == [100, 99, 98, 97, 98]\n assert candidate(nums = [1, 1, 1, 1, -1, -1, -1, -1, -1, -1]) == [1, 1, 1, 1, -1, -1]\n assert candidate(nums = [10, -1, 20, -1, 30, -1, 40, -1, 50]) == [10, 20, 30, 40]\n assert candidate(nums = [1, -1, 2, 3, -1, -1, 4, -1, -1, -1]) == [1, 3, 2, 4, 3, 2]\n assert candidate(nums = [3, -1, -1, -1, 4]) == [3, -1, -1]\n assert candidate(nums = [1, -1, 2, -1, -1]) == [1, 2, 1]\n assert candidate(nums = [5, -1, 5, -1, 5, -1, 5]) == [5, 5, 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]\n assert candidate(nums = [5, 6, 7, -1, -1, 8, -1, -1, -1]) == [7, 6, 8, 7, 6]\n assert candidate(nums = [10, 9, 8, -1, 7, -1, -1, -1]) == [8, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1, -1, -1]) == [5, 4, 3, 2, 1, -1]\n assert candidate(nums = [-1, -1, -1, 1, -1, -1, 2, -1, -1, 3, -1, -1]) == [-1, -1, -1, 1, -1, 2, 1, 3, 2]\n assert candidate(nums = [10, -1, 9, -1, 11, -1, -1]) == [10, 9, 11, 9]\n assert candidate(nums = [1, 2, -1, -1, -1]) == [2, 1, -1]\n assert candidate(nums = [-1]) == [-1]\n assert candidate(nums = [5, -1, 4, -1, 3, -1, 2, -1, 1]) == [5, 4, 3, 2]\n assert candidate(nums = [-1, -1, -1, 1]) == [-1, -1, -1]\n assert candidate(nums = [10, 20, 30, -1, -1, -1, -1, -1, -1, -1]) == [30, 20, 10, -1, -1, -1, -1]\n assert candidate(nums = [5, -1, -1, 3, -1, -1, -1]) == [5, -1, 3, 5, -1]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == [1, 1, 1, 1]\n assert candidate(nums = [1, -1, 2, -1, 3, -1, 4, -1, -1, -1]) == [1, 2, 3, 4, 3, 2]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == [1, 1, 1, 1]\n assert candidate(nums = [-1, -1, -1, 1, 2, 3, -1, -1]) == [-1, -1, -1, 3, 2]\n assert candidate(nums = [5, -1, -1, 15, -1, 25, -1, -1, -1, -1]) == [5, -1, 15, 25, 15, 5, -1]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1, -1, -1]) == [-1, 1, 2, 3, 2, 1]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1]) == [1, 1, 1]\n assert candidate(nums = [5, 10, -1, 15, -1, -1, 20, -1, -1, -1]) == [10, 15, 10, 20, 15, 10]\n assert candidate(nums = [1, -1, -1, -1, 2, -1, -1, -1]) == [1, -1, -1, 2, 1, -1]\n assert candidate(nums = [1]) == []\n assert candidate(nums = [-1, -1, -1, 1, 2]) == [-1, -1, -1]\n assert candidate(nums = [7, -1, 6, 5, -1, -1, 4, -1, -1, 3]) == [7, 5, 6, 4, 5]\n assert candidate(nums = [5, 5, 5, -1, -1, -1, -1]) == [5, 5, 5, -1]\n assert candidate(nums = [-1, -1, 1, -1, 2, -1, 3, -1, -1, -1]) == [-1, -1, 1, 2, 3, 2, 1]\n assert candidate(nums = [-1, -1, 1, -1, 2, -1, -1, 3, -1, -1, -1]) == [-1, -1, 1, 2, 1, 3, 2, 1]\n assert candidate(nums = [-1, -1, 1, -1, 2, -1, -1]) == [-1, -1, 1, 2, 1]\n assert candidate(nums = [1, -1, -1, 2, -1, -1, -1, 3, -1]) == [1, -1, 2, 1, -1, 3]\n assert candidate(nums = [1, 2, 3, -1, -1, -1, -1]) == [3, 2, 1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1]) == [5, 4, 3, 2]\n assert candidate(nums = [50, -1, -1, 50, -1, -1, -1, -1]) == [50, -1, 50, 50, -1, -1]\n assert candidate(nums = [100, -1, 50, -1, -1, 25, -1, -1, -1, -1]) == [100, 50, 100, 25, 50, 100, -1]\n assert candidate(nums = [5, -1, -1, 3, -1, 2, -1, -1, -1]) == [5, -1, 3, 2, 3, 5]\n assert candidate(nums = [1, -1, -1, -1, -1, -1, -1]) == [1, -1, -1, -1, -1, -1]\n assert candidate(nums = [50, -1, -1, 60, -1, -1, -1, -1]) == [50, -1, 60, 50, -1, -1]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1, -1]) == [-1, 1, 2, 3, 2]\n assert candidate(nums = [5, -1, 4, -1, 3, -1, 2, -1, 1, -1]) == [5, 4, 3, 2, 1]\n assert candidate(nums = [-1, -1, 1, 2, 3]) == [-1, -1]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1]) == [-1, 1, 2, 3]\n assert candidate(nums = [1, 1, 1, -1, -1, -1]) == [1, 1, 1]\n assert candidate(nums = [1, -1, -1, 2, -1, -1, 3, -1, -1, 4]) == [1, -1, 2, 1, 3, 2]\n assert candidate(nums = [1, -1, -1, -1, 2, -1, -1, 3, -1, -1, -1, -1]) == [1, -1, -1, 2, 1, 3, 2, 1, -1]\n assert candidate(nums = [-1, -1, -1, 1, -1, 2, -1, -1, 3, -1, -1, -1]) == [-1, -1, -1, 1, 2, 1, 3, 2, 1]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, 97, -1]) == [100, 99, 98, 97]\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, 3, 5, -1, -1, 2, -1]) == [5, 3, 2]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, -1]) == [100, 99, 98, 99]\n assert candidate(nums = [1, 1, 1, -1, -1, -1, 1, -1, -1]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [100, -1, -1, 99, -1, 98, -1, -1, -1, -1]) == [100, -1, 99, 98, 99, 100, -1]\n assert candidate(nums = [100, 99, 98, 97, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [97, 98, 99, 100, -1, -1, -1, -1, -1]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1, 4, -1]) == [-1, 1, 2, 3, 4]\n assert candidate(nums = [1, -1]) == [1]\n assert candidate(nums = [5, 3, -1, 4, -1, -1, -1]) == [3, 4, 3, 5]\n assert candidate(nums = [-1, -1, -1, 1, -1, 2, -1, -1, 3, -1]) == [-1, -1, -1, 1, 2, 1, 3]\n assert candidate(nums = [-1, 5, -1, 6, -1, -1]) == [-1, 5, 6, 5]\n assert candidate(nums = [5, -1, -1, 5, -1, -1, 5, -1]) == [5, -1, 5, 5, 5]\n assert candidate(nums = [1, -1, -1, 2, -1, 3, -1, -1, -1]) == [1, -1, 2, 3, 2, 1]\n assert candidate(nums = [7, -1, -1, 8, -1, 9, -1, -1, -1, 10]) == [7, -1, 8, 9, 8, 7]\n assert candidate(nums = [1, 1, 1, -1, -1, -1, -1]) == [1, 1, 1, -1]\n assert candidate(nums = [3, -1, -1, -1, 4]) == [3, -1, -1]\n assert candidate(nums = [10, 20, 30, -1, -1, -1, -1]) == [30, 20, 10, -1]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, -1, -1]) == [100, 99, 98, 99, 100]\n assert candidate(nums = [50, 25, -1, -1, 75, -1, -1, -1, 100]) == [25, 50, 75, 25, 50]\n assert candidate(nums = [5, -1, 3, -1, 2, -1, -1, -1]) == [5, 3, 2, 3, 5]\n assert candidate(nums = [5, 4, 3, 2, 1, -1, -1, -1, -1, -1]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [5, 6, 7, -1, -1, -1, -1, 8, 9, -1, -1]) == [7, 6, 5, -1, 9, 8]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5]) == [-1, 1, 2, 3, 4]\n assert candidate(nums = [50, 50, 50, 50, -1, -1, -1, -1, -1, -1]) == [50, 50, 50, 50, -1, -1]\n assert candidate(nums = [10, 20, 30, -1, -1, 40, -1, -1, -1, -1]) == [30, 20, 40, 30, 20, 10]\n assert candidate(nums = [5, -1, -1, 10, -1, -1, 20, -1]) == [5, -1, 10, 5, 20]\n assert candidate(nums = [-1, 1, -1, 2, -1, 3, -1, 4]) == [-1, 1, 2, 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]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1]) == [5, 4, 3, 2]\n assert candidate(nums = [5, 3, -1, -1, 4, -1, 2, -1]) == [3, 5, 4, 2]\n assert candidate(nums = [3, -1, -1, 4, -1, 5]) == [3, -1, 4]\n assert candidate(nums = [5, -1, 5, -1, 5, -1, 5, -1, 5]) == [5, 5, 5, 5]\n assert candidate(nums = [1, -1, -1, -1]) == [1, -1, -1]\n assert candidate(nums = [3, 3, 3, -1, -1, -1]) == [3, 3, 3]\n assert candidate(nums = [3, 2, 1, -1, -1, -1, -1]) == [1, 2, 3, -1]\n assert candidate(nums = [5, -1, -1, -1, 3]) == [5, -1, -1]\n assert candidate(nums = [10, -1, 20, -1, 30, -1, 40, -1, 50, -1]) == [10, 20, 30, 40, 50]\n assert candidate(nums = [100, -1, -1, -1, -1, -1, -1]) == [100, -1, -1, -1, -1, -1]\n assert candidate(nums = [-1, -1, -1, -1, -1]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [-1, 1, 2, -1, -1, 3, -1]) == [-1, 2, 1, 3]\n assert candidate(nums = [1, 2, 3, -1, 4, 5, -1, -1, -1, 6]) == [3, 5, 4, 3]\n assert candidate(nums = [10, -1, 20, -1, 30, -1, -1, -1]) == [10, 20, 30, 20, 10]\n assert candidate(nums = [99, -1, 98, -1, 97, -1, 96, -1, 95, -1]) == [99, 98, 97, 96, 95]\n assert candidate(nums = [100, -1, -1, 50, -1, 25, -1, -1, -1, -1]) == [100, -1, 50, 25, 50, 100, -1]\n assert candidate(nums = [-1, -1, 1, -1, 2, -1, 3, -1, 4]) == [-1, -1, 1, 2, 3]\n assert candidate(nums = [-1, -1, -1, 1, 2]) == [-1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1, -1]) == [5, 4, 3, 2, 1]\n assert candidate(nums = [3, -1, -1, -1, 5]) == [3, -1, -1]\n assert candidate(nums = [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, -1, -1, -1, -1]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [10, -1, 11, 12, -1, -1, -1, -1, -1]) == [10, 12, 11, 10, -1, -1]\n assert candidate(nums = [-1, 1, -1, 2, -1, -1, 3, -1]) == [-1, 1, 2, 1, 3]\n assert candidate(nums = [1, 2, 3, -1, -1, -1, -1]) == [3, 2, 1, -1]\n assert candidate(nums = [10, 20, 30, -1, -1, 40, -1, -1, -1, -1]) == [30, 20, 40, 30, 20, 10]\n assert candidate(nums = [3, -1, -1, 4, -1, -1, -1]) == [3, -1, 4, 3, -1]\n assert candidate(nums = [10, 20, 30, -1, -1, -1, 40, -1]) == [30, 20, 10, 40]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1, -1]) == [5, 4, 3, 2, 1]\n assert candidate(nums = [-1, -1, -1, 1, 2, 3]) == [-1, -1, -1]\n assert candidate(nums = [3, -1, 4, 5, -1, -1, -1]) == [3, 5, 4, 3]\n assert candidate(nums = [-1, -1, 1, 2, -1, -1, 3]) == [-1, -1, 2, 1]\n assert candidate(nums = [-1, -1, -1, 1, 2, 3, -1, -1, -1]) == [-1, -1, -1, 3, 2, 1]\n assert candidate(nums = [5, 5, -1, -1, 5, -1, -1, -1]) == [5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -1, -1, -1, -1, -1]) == [5, 4, 3, 2, 1, -1]\n assert candidate(nums = [-1, -1, 1, 2, -1, -1, 3, -1]) == [-1, -1, 2, 1, 3]\n assert candidate(nums = [50, -1, 50, -1, 50, -1, 50]) == [50, 50, 50]\n assert candidate(nums = [50, 40, 30, 20, 10, -1, -1, -1, -1, -1, -1, -1]) == [10, 20, 30, 40, 50, -1, -1]\n assert candidate(nums = [-1, 1, 2, -1, -1, 3, -1, -1, -1]) == [-1, 2, 1, 3, 2, 1]\n assert candidate(nums = [100, -1, 99, -1, 98, -1, -1]) == [100, 99, 98, 99]\n assert candidate(nums = [-1, -1, 1, 2, -1, 3, -1, -1]) == [-1, -1, 2, 3, 2]\n assert candidate(nums = [1, -1, -1, -1, -1]) == [1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, -1, 4, -1, 5, -1, -1, -1]) == [3, 4, 5, 4, 3]\n assert candidate(nums = [1, 3, 5, -1, -1, 7, -1, -1, -1, -1]) == [5, 3, 7, 5, 3, 1]\n assert candidate(nums = [5, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [5, -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]\n assert candidate(nums = [-1, -1, 1, 2, 3, -1, -1]) == [-1, -1, 3, 2]\n assert candidate(nums = [5, 2, 3, -1, 4, -1, -1, -1, 6, -1]) == [3, 4, 3, 2, 6]\n assert candidate(nums = [50, -1, -1, -1, -1, -1]) == [50, -1, -1, -1, -1]\n assert candidate(nums = [-1, -1, 1, 2, -1, -1]) == [-1, -1, 2, 1]\n assert candidate(nums = [100, -1, -1, -1, 99, -1, 98, -1, -1, -1, -1]) == [100, -1, -1, 99, 98, 99, 100, -1]\n assert candidate(nums = [7, -1, 8, -1, 9, -1, 10, -1, 11, -1, 12, -1]) == [7, 8, 9, 10, 11, 12]\n assert candidate(nums = [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, 1, 1]\n assert candidate(nums = [-1, -1, -1, 1, -1, 2, -1, 3, -1, -1]) == [-1, -1, -1, 1, 2, 3, 2]\n assert candidate(nums = [42, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == [42, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, -1, -1, 4, 5, -1, -1, -1]) == [3, 2, 5, 4, 3]\n assert candidate(nums = [10, 9, 8, 7, -1, -1, -1, -1, 6, -1]) == [7, 8, 9, 10, 6]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().lastVisitedIntegers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List lastVisitedIntegers(int[] nums) {", "container": "Solution", "callable": "lastVisitedIntegers", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2900, "task_id": "longest-unequal-adjacent-groups-subsequence-i", "difficulty": "Easy", "problem_description": "You are given a string array words and a binary array groups both of length n, where words[i] is associated with groups[i].\nYour task is to select the longest alternating subsequence from words. A subsequence of words is alternating if for any two consecutive strings in the sequence, their corresponding elements in the binary array groups differ. Essentially, you are to choose strings such that adjacent elements have non-matching corresponding bits in the groups array.\nFormally, you need to find the longest subsequence of an array of indices [0, 1, ..., n - 1] denoted as [i0, i1, ..., ik-1], such that groups[ij] != groups[ij+1] for each 0 <= j < k - 1 and then find the words corresponding to these indices.\nReturn the selected subsequence. If there are multiple answers, return any of them.\nNote: The elements in words are distinct.\n \nExample 1:\n\nInput: words = [\"e\",\"a\",\"b\"], groups = [0,0,1]\nOutput: [\"e\",\"b\"]\nExplanation: A subsequence that can be selected is [\"e\",\"b\"] because groups[0] != groups[2]. Another subsequence that can be selected is [\"a\",\"b\"] because groups[1] != groups[2]. It can be demonstrated that the length of the longest subsequence of indices that satisfies the condition is 2.\n\nExample 2:\n\nInput: words = [\"a\",\"b\",\"c\",\"d\"], groups = [1,0,1,1]\nOutput: [\"a\",\"b\",\"c\"]\nExplanation: A subsequence that can be selected is [\"a\",\"b\",\"c\"] because groups[0] != groups[1] and groups[1] != groups[2]. Another subsequence that can be selected is [\"a\",\"b\",\"d\"] because groups[0] != groups[1] and groups[1] != groups[3]. It can be shown that the length of the longest subsequence of indices that satisfies the condition is 3.\n\n \nConstraints:\n\n1 <= n == words.length == groups.length <= 100\n1 <= words[i].length <= 10\ngroups[i] is either 0 or 1.\nwords consists of distinct strings.\nwords[i] consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['dog', 'cat', 'bird', 'fish'],groups = [0, 1, 1, 0]) == ['dog', 'cat', 'fish']\n assert candidate(words = ['x', 'y', 'z'],groups = [0, 1, 0]) == ['x', 'y', 'z']\n assert candidate(words = ['a', 'b', 'c', 'd'],groups = [1, 0, 1, 1]) == ['a', 'b', 'c']\n assert candidate(words = ['e', 'a', 'b'],groups = [0, 0, 1]) == ['e', 'b']\n assert candidate(words = ['one', 'two', 'three'],groups = [1, 1, 0]) == ['one', 'three']\n assert candidate(words = ['apple', 'banana', 'cherry'],groups = [1, 1, 0]) == ['apple', 'cherry']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],groups = [1, 0, 1, 0, 1]) == ['one', 'two', 'three', 'four', 'five']\n assert candidate(words = ['cat', 'dog', 'fish', 'bird'],groups = [1, 1, 0, 0]) == ['cat', 'fish']\n assert candidate(words = ['hello', 'world', 'python', 'code'],groups = [0, 1, 0, 1]) == ['hello', 'world', 'python', 'code']\n assert candidate(words = ['dog', 'cat', 'bat', 'rat'],groups = [0, 1, 0, 1]) == ['dog', 'cat', 'bat', 'rat']\n assert candidate(words = ['hello', 'world', 'python', 'code'],groups = [1, 0, 1, 0]) == ['hello', 'world', 'python', 'code']\n assert candidate(words = ['hello', 'world', 'abc', 'def'],groups = [0, 1, 0, 1]) == ['hello', 'world', 'abc', 'def']\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],groups = [0, 1, 0, 1]) == ['red', 'blue', 'green', 'yellow']\n assert candidate(words = ['umbrella', 'tornado', 'rainbow', 'ocean', 'mountain', 'lake', 'island', 'forest', 'desert', 'canyon', 'volcano', 'glacier', 'river'],groups = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == ['umbrella', 'tornado', 'ocean', 'lake', 'forest', 'canyon', 'glacier']\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy'],groups = [0, 1, 0, 1, 0]) == ['sun', 'moon', 'star', 'planet', 'galaxy']\n assert candidate(words = ['x', 'y', 'z', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['x', 'y', 'z', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w']\n assert candidate(words = ['ocean', 'sea', 'lake', 'river', 'stream', 'creek', 'pond'],groups = [0, 1, 0, 1, 0, 1, 0]) == ['ocean', 'sea', 'lake', 'river', 'stream', 'creek', 'pond']\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy', 'universe', 'constellation', 'comet', 'asteroid', 'supernova'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['sun', 'moon', 'star', 'planet', 'galaxy', 'universe', 'constellation', 'comet', 'asteroid', 'supernova']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']\n assert candidate(words = ['sun', 'moon', 'star', 'comet', 'planet', 'galaxy', 'universe'],groups = [0, 1, 1, 0, 1, 0, 1]) == ['sun', 'moon', 'comet', 'planet', 'galaxy', 'universe']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta'],groups = [0, 1, 1, 0, 0, 1]) == ['alpha', 'beta', 'delta', 'zeta']\n assert candidate(words = ['quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'],groups = [1, 0, 1, 0, 1, 0, 1, 0]) == ['quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't']\n assert candidate(words = ['flower', 'tree', 'bush', 'shrub', 'vine', 'grass', 'moss'],groups = [0, 1, 0, 1, 0, 1, 0]) == ['flower', 'tree', 'bush', 'shrub', 'vine', 'grass', 'moss']\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'galaxy', 'universe'],groups = [0, 1, 0, 1, 0, 1, 0, 1]) == ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'galaxy', 'universe']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta'],groups = [1, 1, 0, 0, 1, 1, 0, 0]) == ['alpha', 'gamma', 'epsilon', 'eta']\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy', 'universe', 'constellation', 'asteroid'],groups = [0, 1, 0, 1, 0, 1, 0, 1]) == ['sun', 'moon', 'star', 'planet', 'galaxy', 'universe', 'constellation', 'asteroid']\n assert candidate(words = ['orange', 'lemon', 'lime', 'mango', 'papaya', 'guava', 'kiwi'],groups = [1, 0, 0, 1, 1, 0, 1]) == ['orange', 'lemon', 'mango', 'guava', 'kiwi']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']\n assert candidate(words = ['car', 'truck', 'bike', 'motorcycle', 'bicycle', 'scooter', 'skateboard', 'longboard', 'tricycle'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['car', 'truck', 'bike', 'motorcycle', 'bicycle', 'scooter', 'skateboard', 'longboard', 'tricycle']\n assert candidate(words = ['ocean', 'sea', 'lake', 'river', 'creek', 'stream', 'pond'],groups = [1, 0, 1, 0, 1, 0, 1]) == ['ocean', 'sea', 'lake', 'river', 'creek', 'stream', 'pond']\n assert candidate(words = ['zebra', 'yak', 'xylophone', 'wolf', 'vulture', 'toucan', 'snake', 'raven', 'quetzal', 'parrot'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['zebra', 'yak', 'xylophone', 'wolf', 'vulture', 'toucan', 'snake', 'raven', 'quetzal', 'parrot']\n assert candidate(words = ['zebra', 'elephant', 'giraffe', 'hippo', 'rhino', 'lion', 'tiger', 'bear'],groups = [0, 0, 1, 1, 0, 0, 1, 1]) == ['zebra', 'giraffe', 'rhino', 'tiger']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']\n assert candidate(words = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'],groups = [0, 1, 1, 0, 0, 1, 1]) == ['red', 'orange', 'green', 'indigo']\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],groups = [1, 0, 1, 0, 1, 0, 1]) == ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape']\n assert candidate(words = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],groups = [1, 0, 1, 0, 1, 0, 1]) == ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']\n assert candidate(words = ['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'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['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']\n assert candidate(words = ['puppy', 'kitten', 'fish', 'bird', 'dog', 'cat', 'hamster', 'gerbil', 'rabbit'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['puppy', 'kitten', 'fish', 'bird', 'dog', 'cat', 'hamster', 'gerbil', 'rabbit']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda'],groups = [1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1]) == ['alpha', 'beta', 'delta', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda']\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'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['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(words = ['ocean', 'sea', 'lake', 'river', 'pond', 'brook', 'creek', 'stream'],groups = [0, 1, 1, 0, 0, 1, 0, 0]) == ['ocean', 'sea', 'river', 'brook', 'creek']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa']\n assert candidate(words = ['cat', 'dog', 'bird', 'fish', 'ant', 'bee', 'moth', 'fly', 'antelope', 'giraffe'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['cat', 'dog', 'bird', 'fish', 'ant', 'bee', 'moth', 'fly', 'antelope', 'giraffe']\n assert candidate(words = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'],groups = [0, 1, 0, 1, 0, 1, 0]) == ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']\n assert candidate(words = ['car', 'bike', 'truck', 'bus', 'motorcycle', 'scooter', 'bicycle'],groups = [1, 0, 0, 1, 1, 0, 0]) == ['car', 'bike', 'bus', 'scooter']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']\n assert candidate(words = ['orange', 'lemon', 'lime', 'grapefruit', 'kiwi', 'mango', 'papaya', 'guava', 'dragonfruit'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['orange', 'lemon', 'lime', 'grapefruit', 'kiwi', 'mango', 'papaya', 'guava', 'dragonfruit']\n assert candidate(words = ['red', 'green', 'blue', 'yellow', 'purple', 'cyan', 'magenta', 'black', 'white'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['red', 'green', 'blue', 'yellow', 'purple', 'cyan', 'magenta', 'black', 'white']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],groups = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == ['one', 'three', 'five', 'seven', 'nine']\n assert candidate(words = ['cat', 'dog', 'rat', 'bat', 'owl', 'fox', 'wolf', 'bear'],groups = [0, 1, 0, 1, 0, 1, 0, 1]) == ['cat', 'dog', 'rat', 'bat', 'owl', 'fox', 'wolf', 'bear']\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'galaxy', 'universe', 'nebula', 'blackhole'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'galaxy', 'universe', 'nebula', 'blackhole']\n assert candidate(words = ['zebra', 'giraffe', 'elephant', 'lion', 'tiger', 'bear', 'wolf', 'hippo'],groups = [0, 1, 0, 1, 0, 1, 0, 1]) == ['zebra', 'giraffe', 'elephant', 'lion', 'tiger', 'bear', 'wolf', 'hippo']\n assert candidate(words = ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q'],groups = [1, 1, 0, 1, 0, 0, 1, 0, 1, 1]) == ['x', 'z', 'w', 'v', 't', 's', 'r']\n assert candidate(words = ['a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff', 'ggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjjjj'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff', 'ggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjjjj']\n assert candidate(words = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'],groups = [1, 1, 0, 1, 0, 1, 0]) == ['red', 'yellow', 'green', 'blue', 'indigo', 'violet']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta'],groups = [0, 1, 0, 1, 0, 1, 0, 1]) == ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta']\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'galaxy'],groups = [0, 1, 1, 0, 1, 0, 1]) == ['sun', 'moon', 'planet', 'comet', 'asteroid', 'galaxy']\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'purple', 'pink', 'orange', 'black', 'white', 'gray', 'brown'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['red', 'blue', 'green', 'yellow', 'purple', 'pink', 'orange', 'black', 'white', 'gray', 'brown']\n assert candidate(words = ['zebra', 'giraffe', 'elephant', 'lion', 'tiger', 'bear', 'wolf', 'fox'],groups = [0, 1, 0, 1, 0, 1, 0, 1]) == ['zebra', 'giraffe', 'elephant', 'lion', 'tiger', 'bear', 'wolf', 'fox']\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],groups = [0, 1, 0, 1, 0, 1, 0]) == ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape']\n assert candidate(words = ['sunrise', 'sunset', 'dawn', 'dusk', 'midnight', 'noon', 'evening', 'morning'],groups = [1, 0, 1, 0, 1, 0, 1, 0]) == ['sunrise', 'sunset', 'dawn', 'dusk', 'midnight', 'noon', 'evening', 'morning']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen']\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'nebula'],groups = [1, 0, 1, 0, 1, 0, 1]) == ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'nebula']\n assert candidate(words = ['piano', 'guitar', 'violin', 'drums', 'flute', 'trumpet', 'saxophone', 'balalaika'],groups = [0, 1, 0, 1, 0, 1, 0, 1]) == ['piano', 'guitar', 'violin', 'drums', 'flute', 'trumpet', 'saxophone', 'balalaika']\n assert candidate(words = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'],groups = [1, 1, 0, 0, 1, 1, 0]) == ['red', 'yellow', 'blue', 'violet']\n assert candidate(words = ['ocean', 'river', 'lake', 'stream', 'pond', 'fountain', 'basin'],groups = [1, 0, 1, 0, 1, 0, 1]) == ['ocean', 'river', 'lake', 'stream', 'pond', 'fountain', 'basin']\n assert candidate(words = ['zebra', 'giraffe', 'elephant', 'tiger', 'lion', 'bear', 'wolf', 'fox', 'coyote', 'lynx'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['zebra', 'giraffe', 'elephant', 'tiger', 'lion', 'bear', 'wolf', 'fox', 'coyote', 'lynx']\n assert candidate(words = ['zebra', 'lion', 'tiger', 'giraffe', 'elephant', 'rhino', 'hippo', 'monkey'],groups = [0, 1, 1, 0, 0, 1, 1, 0]) == ['zebra', 'lion', 'giraffe', 'rhino', 'monkey']\n assert candidate(words = ['mountain', 'hill', 'peak', 'valley', 'canyon', 'cliff', 'ridge'],groups = [1, 0, 1, 0, 1, 0, 1]) == ['mountain', 'hill', 'peak', 'valley', 'canyon', 'cliff', 'ridge']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],groups = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == ['a', 'b', 'd', 'f', 'h', 'j']\n assert candidate(words = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'ultraviolet'],groups = [1, 0, 1, 0, 1, 0, 1, 0]) == ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'ultraviolet']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda']\n assert candidate(words = ['cat', 'dog', 'fish', 'bird', 'cat', 'dog', 'fish', 'bird', 'cat', 'dog', 'fish', 'bird', 'cat', 'dog', 'fish', 'bird', 'cat', 'dog', 'fish', 'bird'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['cat', 'dog', 'fish', 'bird', 'cat', 'dog', 'fish', 'bird', 'cat', 'dog', 'fish', 'bird', 'cat', 'dog', 'fish', 'bird', 'cat', 'dog', 'fish', 'bird']\n assert candidate(words = ['sushi', 'pizza', 'burger', 'steak', 'salad', 'pasta', 'taco', 'burrito', 'sandwich', 'omelette'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['sushi', 'pizza', 'burger', 'steak', 'salad', 'pasta', 'taco', 'burrito', 'sandwich', 'omelette']\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'is', 'fun'],groups = [0, 1, 1, 0, 0, 1]) == ['hello', 'world', 'programming', 'fun']\n assert candidate(words = ['zebra', 'giraffe', 'elephant', 'lion', 'tiger', 'bear', 'monkey'],groups = [0, 1, 0, 1, 0, 1, 0]) == ['zebra', 'giraffe', 'elephant', 'lion', 'tiger', 'bear', 'monkey']\n assert candidate(words = ['zebra', 'giraffe', 'elephant', 'tiger', 'lion', 'bear', 'panda', 'rhino', 'hippo', 'flamingo'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['zebra', 'giraffe', 'elephant', 'tiger', 'lion', 'bear', 'panda', 'rhino', 'hippo', 'flamingo']\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'is', 'fun', 'and', 'challenging'],groups = [0, 1, 1, 0, 1, 0, 1, 0]) == ['hello', 'world', 'programming', 'is', 'fun', 'and', 'challenging']\n assert candidate(words = ['ant', 'bee', 'cow', 'dog', 'elephant', 'frog', 'goat', 'horse', 'iguana', 'jaguar'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['ant', 'bee', 'cow', 'dog', 'elephant', 'frog', 'goat', 'horse', 'iguana', 'jaguar']\n assert candidate(words = ['zebra', 'elephant', 'tiger', 'lion', 'giraffe', 'rhino'],groups = [1, 0, 1, 0, 1, 0]) == ['zebra', 'elephant', 'tiger', 'lion', 'giraffe', 'rhino']\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'red', 'blue', 'green', 'yellow', 'red', 'blue', 'green', 'yellow', 'red', 'blue', 'green'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['red', 'blue', 'green', 'yellow', 'red', 'blue', 'green', 'yellow', 'red', 'blue', 'green', 'yellow', 'red', 'blue', 'green']\n assert candidate(words = ['orange', 'lemon', 'lime', 'mango', 'kiwi', 'papaya', 'guava', 'melon'],groups = [0, 1, 0, 1, 0, 1, 0, 1]) == ['orange', 'lemon', 'lime', 'mango', 'kiwi', 'papaya', 'guava', 'melon']\n assert candidate(words = ['ocean', 'river', 'lake', 'pond', 'stream', 'creek', 'bay', 'gulf'],groups = [1, 0, 1, 0, 1, 0, 1, 0]) == ['ocean', 'river', 'lake', 'pond', 'stream', 'creek', 'bay', 'gulf']\n assert candidate(words = ['x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']\n assert candidate(words = ['panda', 'koala', 'kangaroo', 'polarbear', 'dolphin', 'seal', 'walrus'],groups = [0, 1, 0, 1, 0, 1, 0]) == ['panda', 'koala', 'kangaroo', 'polarbear', 'dolphin', 'seal', 'walrus']\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'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['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(words = ['ant', 'bee', 'ant', 'bee', 'ant', 'bee', 'ant', 'bee', 'ant', 'bee', 'ant', 'bee'],groups = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['ant', 'bee', 'ant', 'bee', 'ant', 'bee', 'ant', 'bee', 'ant', 'bee', 'ant', 'bee']\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'galaxy'],groups = [1, 0, 1, 0, 1, 0, 1]) == ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'galaxy']\n assert candidate(words = ['aardvark', 'beaver', 'capybara', 'dugong', 'elephant', 'flamingo', 'giraffe', 'hippopotamus', 'iguana'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1]) == ['aardvark', 'beaver', 'capybara', 'dugong', 'elephant', 'flamingo', 'giraffe', 'hippopotamus', 'iguana']\n assert candidate(words = ['car', 'bike', 'plane', 'train', 'boat', 'ship', 'bus'],groups = [1, 0, 1, 0, 1, 0, 1]) == ['car', 'bike', 'plane', 'train', 'boat', 'ship', 'bus']\n assert candidate(words = ['ocean', 'river', 'lake', 'pond', 'waterfall', 'creek', 'stream'],groups = [0, 1, 0, 1, 0, 1, 0]) == ['ocean', 'river', 'lake', 'pond', 'waterfall', 'creek', 'stream']\n assert candidate(words = ['north', 'south', 'east', 'west', 'northeast', 'northwest', 'southeast', 'southwest'],groups = [1, 0, 1, 0, 1, 0, 1, 0]) == ['north', 'south', 'east', 'west', 'northeast', 'northwest', 'southeast', 'southwest']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta'],groups = [0, 1, 0, 1, 0, 1]) == ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigma', 'tau', 'upsilon', 'phi', 'chi', 'psi', 'omega'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigma', 'tau', 'upsilon', 'phi', 'chi', 'psi', 'omega']\n assert candidate(words = ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q'],groups = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q']\n assert candidate(words = ['one', 'two', 'three', 'four'],groups = [0, 1, 1, 0]) == ['one', 'two', 'four']\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],groups = [0, 0, 1, 1]) == ['red', 'green']\n assert candidate(words = ['red', 'green', 'blue'],groups = [1, 1, 0]) == ['red', 'blue']\n assert candidate(words = ['x', 'y', 'z'],groups = [0, 0, 0]) == ['x']\n assert candidate(words = ['dog', 'cat', 'bird', 'fish'],groups = [1, 0, 1, 0]) == ['dog', 'cat', 'bird', 'fish']\n assert candidate(words = ['hello', 'world', 'python'],groups = [0, 1, 0]) == ['hello', 'world', 'python']\n assert candidate(words = ['zebra', 'lion', 'tiger', 'bear'],groups = [1, 0, 1, 0]) == ['zebra', 'lion', 'tiger', 'bear']\n assert candidate(words = ['a', 'b'],groups = [0, 1]) == ['a', 'b']\n assert candidate(words = ['apple', 'banana', 'cherry'],groups = [0, 1, 0]) == ['apple', 'banana', 'cherry']\n assert candidate(words = ['dog', 'cat', 'mouse', 'elephant'],groups = [1, 0, 1, 0]) == ['dog', 'cat', 'mouse', 'elephant']\n assert candidate(words = ['x', 'y', 'z', 'w', 'v'],groups = [0, 1, 0, 1, 0]) == ['x', 'y', 'z', 'w', 'v']\n assert candidate(words = ['hello', 'world'],groups = [0, 0]) == ['hello']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],groups = [0, 1, 0, 1, 0]) == ['a', 'b', 'c', 'd', 'e']\n assert candidate(words = ['apple', 'banana', 'cherry', 'date'],groups = [1, 1, 0, 0]) == ['apple', 'cherry']\n assert candidate(words = ['a', 'b', 'a', 'b', 'a', 'b'],groups = [0, 1, 0, 1, 0, 1]) == ['a', 'b', 'a', 'b', 'a', 'b']\n assert candidate(words = ['one', 'two', 'three', 'four'],groups = [1, 1, 1, 0]) == ['one', 'four']\n assert candidate(words = ['dog', 'cat', 'bird', 'fish'],groups = [1, 1, 0, 0]) == ['dog', 'bird']\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],groups = [0, 1, 0, 1]) == ['sun', 'moon', 'star', 'planet']\n assert candidate(words = ['up', 'down', 'left', 'right'],groups = [1, 0, 1, 0]) == ['up', 'down', 'left', 'right']\n assert candidate(words = ['apple', 'banana', 'cherry'],groups = [0, 1, 0]) == ['apple', 'banana', 'cherry']\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'black'],groups = [0, 0, 1, 1, 0]) == ['red', 'green', 'black']\n assert candidate(words = ['up', 'down', 'left', 'right'],groups = [0, 1, 0, 1]) == ['up', 'down', 'left', 'right']\n assert candidate(words = ['light', 'dark'],groups = [0, 1]) == ['light', 'dark']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],groups = [1, 1, 1, 1, 1]) == ['a']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six'],groups = [1, 0, 1, 0, 1, 0]) == ['one', 'two', 'three', 'four', 'five', 'six']\n assert candidate(words = ['dog', 'cat', 'mouse'],groups = [1, 0, 1]) == ['dog', 'cat', 'mouse']\n assert candidate(words = ['fast', 'slow', 'big', 'small'],groups = [1, 0, 1, 0]) == ['fast', 'slow', 'big', 'small']\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],groups = [1, 0, 1, 0]) == ['red', 'blue', 'green', 'yellow']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta'],groups = [0, 1, 0, 1]) == ['alpha', 'beta', 'gamma', 'delta']\n assert candidate(words = ['red', 'blue', 'green'],groups = [0, 1, 0]) == ['red', 'blue', 'green']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],groups = [1, 1, 0, 0, 1]) == ['one', 'three', 'five']\n assert candidate(words = ['one', 'two', 'three'],groups = [1, 1, 1]) == ['one']\n assert candidate(words = ['cat', 'dog', 'mouse'],groups = [0, 0, 1]) == ['cat', 'mouse']\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry'],groups = [1, 0, 1, 0, 1]) == ['apple', 'banana', 'cherry', 'date', 'elderberry']\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'purple', 'orange'],groups = [1, 0, 1, 0, 1, 0]) == ['red', 'blue', 'green', 'yellow', 'purple', 'orange']\n assert candidate(words = ['x', 'y', 'z'],groups = [0, 0, 0]) == ['x']\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],groups = [0, 1, 1, 0]) == ['sun', 'moon', 'planet']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],groups = [1, 0, 1, 0, 1]) == ['one', 'two', 'three', 'four', 'five']\n assert candidate(words = ['hello', 'world', 'foo', 'bar'],groups = [0, 1, 0, 1]) == ['hello', 'world', 'foo', 'bar']\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],groups = [1, 1, 1, 0]) == ['red', 'yellow']\n assert candidate(words = ['sun', 'moon', 'star'],groups = [0, 1, 0]) == ['sun', 'moon', 'star']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta'],groups = [1, 0, 1, 0]) == ['alpha', 'beta', 'gamma', 'delta']\n assert candidate(words = ['fast', 'slow', 'high', 'low'],groups = [1, 0, 1, 0]) == ['fast', 'slow', 'high', 'low']\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],groups = [1, 1, 1, 1]) == ['sun']\n assert candidate(words = ['cat', 'dog', 'elephant'],groups = [1, 0, 1]) == ['cat', 'dog', 'elephant']\n assert candidate(words = ['apple', 'banana', 'cherry', 'date'],groups = [0, 1, 0, 1]) == ['apple', 'banana', 'cherry', 'date']\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'purple'],groups = [0, 1, 0, 1, 0]) == ['red', 'blue', 'green', 'yellow', 'purple']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],groups = [1, 0, 1, 0, 1]) == ['a', 'b', 'c', 'd', 'e']\n assert candidate(words = ['dog', 'cat', 'fish', 'bird'],groups = [1, 0, 1, 1]) == ['dog', 'cat', 'fish']\n assert candidate(words = ['dog', 'cat', 'bird'],groups = [0, 0, 1]) == ['dog', 'bird']\n assert candidate(words = ['dog', 'cat', 'fish', 'bird'],groups = [1, 0, 1, 0]) == ['dog', 'cat', 'fish', 'bird']\n assert candidate(words = ['up', 'down', 'left', 'right'],groups = [1, 0, 1, 0]) == ['up', 'down', 'left', 'right']\n assert candidate(words = ['cat', 'dog', 'bird', 'fish'],groups = [0, 1, 0, 1]) == ['cat', 'dog', 'bird', 'fish']\n assert candidate(words = ['dog', 'cat', 'bird', 'fish'],groups = [1, 0, 1, 1]) == ['dog', 'cat', 'bird']\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],groups = [1, 1, 0, 0]) == ['red', 'green']\n assert candidate(words = ['hello', 'world'],groups = [0, 1]) == ['hello', 'world']\n assert candidate(words = ['cat', 'dog', 'elephant', 'fox'],groups = [1, 0, 1, 0]) == ['cat', 'dog', 'elephant', 'fox']\n assert candidate(words = ['red', 'blue', 'green'],groups = [0, 0, 0]) == ['red']\n assert candidate(words = ['cat', 'dog', 'bird'],groups = [0, 1, 0]) == ['cat', 'dog', 'bird']\n assert candidate(words = ['x', 'y', 'z', 'w'],groups = [0, 1, 0, 1]) == ['x', 'y', 'z', 'w']\n assert candidate(words = ['cat', 'dog', 'bird', 'fish'],groups = [1, 0, 1, 0]) == ['cat', 'dog', 'bird', 'fish']\n assert candidate(words = ['sun', 'moon', 'star'],groups = [0, 1, 1]) == ['sun', 'moon']\n assert candidate(words = ['red', 'green', 'blue', 'yellow'],groups = [1, 1, 0, 0]) == ['red', 'blue']\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],groups = [1, 0, 1, 1]) == ['sun', 'moon', 'star']\n assert candidate(words = ['hello', 'world', 'python', 'programming'],groups = [0, 1, 0, 1]) == ['hello', 'world', 'python', 'programming']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],groups = [0, 1, 0, 1, 0]) == ['one', 'two', 'three', 'four', 'five']\n assert candidate(words = ['one', 'two', 'three', 'four'],groups = [0, 1, 0, 1]) == ['one', 'two', 'three', 'four']\n assert candidate(words = ['red', 'blue', 'green'],groups = [0, 1, 1]) == ['red', 'blue']\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'black'],groups = [1, 0, 1, 0, 1]) == ['red', 'blue', 'green', 'yellow', 'black']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f'],groups = [1, 0, 1, 0, 1, 0]) == ['a', 'b', 'c', 'd', 'e', 'f']\n assert candidate(words = ['cat', 'dog', 'fish', 'bird', 'lizard'],groups = [0, 1, 0, 1, 0]) == ['cat', 'dog', 'fish', 'bird', 'lizard']\n assert candidate(words = ['x', 'y', 'z', 'w'],groups = [1, 0, 1, 0]) == ['x', 'y', 'z', 'w']\n assert candidate(words = ['x', 'y', 'z'],groups = [1, 0, 1]) == ['x', 'y', 'z']\n assert candidate(words = ['hello', 'world', 'python', 'code'],groups = [1, 0, 1, 0]) == ['hello', 'world', 'python', 'code']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f'],groups = [1, 0, 1, 0, 1, 0]) == ['a', 'b', 'c', 'd', 'e', 'f']\n assert candidate(words = ['apple', 'banana', 'cherry', 'date'],groups = [0, 1, 0, 1]) == ['apple', 'banana', 'cherry', 'date']\n assert candidate(words = ['hello', 'world', 'python', 'code'],groups = [0, 1, 0, 1]) == ['hello', 'world', 'python', 'code']\n assert candidate(words = ['red', 'blue', 'green'],groups = [1, 1, 1]) == ['red']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f'],groups = [0, 1, 0, 1, 0, 1]) == ['a', 'b', 'c', 'd', 'e', 'f']\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],groups = [0, 0, 1, 1]) == ['sun', 'star']\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],groups = [1, 0, 1, 0]) == ['sun', 'moon', 'star', 'planet']\n assert candidate(words = ['dog', 'cat', 'fish', 'bird'],groups = [0, 1, 0, 1]) == ['dog', 'cat', 'fish', 'bird']\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],groups = [0, 1, 0, 1]) == ['red', 'blue', 'green', 'yellow']\n assert candidate(words = ['fast', 'slow', 'quick', 'lazy'],groups = [1, 0, 1, 0]) == ['fast', 'slow', 'quick', 'lazy']\n assert candidate(words = ['red', 'blue', 'green'],groups = [0, 0, 1]) == ['red', 'green']\n assert candidate(words = ['fast', 'slow', 'big', 'small'],groups = [1, 0, 1, 0]) == ['fast', 'slow', 'big', 'small']\n assert candidate(words = ['red', 'blue', 'green'],groups = [1, 0, 1]) == ['red', 'blue', 'green']\n assert candidate(words = ['hello', 'world'],groups = [1, 0]) == ['hello', 'world']\n assert candidate(words = ['hello', 'world', 'python', 'code'],groups = [1, 1, 0, 0]) == ['hello', 'python']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'],groups = [1, 0, 1, 0, 1]) == ['alpha', 'beta', 'gamma', 'delta', 'epsilon']\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],groups = [0, 1, 0, 1]) == ['sun', 'moon', 'star', 'planet']\n assert candidate(words = ['dog', 'cat', 'fish'],groups = [1, 0, 1]) == ['dog', 'cat', 'fish']\n assert candidate(words = ['cat', 'dog', 'fish', 'bird', 'elephant'],groups = [1, 0, 1, 0, 1]) == ['cat', 'dog', 'fish', 'bird', 'elephant']\n assert candidate(words = ['left', 'right', 'up', 'down'],groups = [0, 1, 0, 1]) == ['left', 'right', 'up', 'down']\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta'],groups = [0, 0, 1, 1, 0, 1]) == ['alpha', 'gamma', 'epsilon', 'zeta']\n assert candidate(words = ['sun', 'moon', 'star'],groups = [1, 0, 1]) == ['sun', 'moon', 'star']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six'],groups = [0, 0, 1, 1, 0, 0]) == ['one', 'three', 'five']\n assert candidate(words = ['hello', 'world'],groups = [0, 1]) == ['hello', 'world']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],groups = [0, 0, 1, 1, 0]) == ['one', 'three', 'five']\n assert candidate(words = ['hello', 'world', 'python', 'programming'],groups = [1, 0, 1, 0]) == ['hello', 'world', 'python', 'programming']\n assert candidate(words = ['hello', 'world', 'python', 'code'],groups = [0, 0, 1, 1]) == ['hello', 'python']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g'],groups = [0, 1, 0, 1, 0, 1, 0]) == ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],groups = [0, 1, 0, 1, 0]) == ['one', 'two', 'three', 'four', 'five']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],groups = [1, 1, 0, 0, 1]) == ['one', 'three', 'five']\n assert candidate(words = ['quick', 'brown', 'fox'],groups = [1, 0, 1]) == ['quick', 'brown', 'fox']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],groups = [0, 0, 1, 1, 0]) == ['one', 'three', 'five']\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],groups = [1, 0, 1, 1]) == ['sun', 'moon', 'star']\n assert candidate(words = ['hello', 'world', 'python', 'programming'],groups = [0, 0, 1, 1]) == ['hello', 'python']\n assert candidate(words = ['x', 'y', 'z', 'w', 'v'],groups = [0, 0, 0, 1, 1]) == ['x', 'w']\n"}, "metadata": {"canonical_parameter_names": ["words", "groups"], "leetcode_dataset_entry_point": "Solution().getLongestSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List getLongestSubsequence(String[] words, int[] groups) {", "container": "Solution", "callable": "getLongestSubsequence", "parameters": [{"name": "words", "type": "String[]"}, {"name": "groups", "type": "int[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2901, "task_id": "longest-unequal-adjacent-groups-subsequence-ii", "difficulty": "Medium", "problem_description": "You are given a string array words, and an array groups, both arrays having length n.\nThe hamming distance between two strings of equal length is the number of positions at which the corresponding characters are different.\nYou need to select the longest subsequence from an array of indices [0, 1, ..., n - 1], such that for the subsequence denoted as [i0, i1, ..., ik-1] having length k, the following holds:\n\nFor adjacent indices in the subsequence, their corresponding groups are unequal, i.e., groups[ij] != groups[ij+1], for each j where 0 < j + 1 < k.\nwords[ij] and words[ij+1] are equal in length, and the hamming distance between them is 1, where 0 < j + 1 < k, for all indices in the subsequence.\n\nReturn a string array containing the words corresponding to the indices (in order) in the selected subsequence. If there are multiple answers, return any of them.\nNote: strings in words may be unequal in length.\n \nExample 1:\n\nInput: words = [\"bab\",\"dab\",\"cab\"], groups = [1,2,2]\nOutput: [\"bab\",\"cab\"]\nExplanation: A subsequence that can be selected is [0,2].\n\ngroups[0] != groups[2]\nwords[0].length == words[2].length, and the hamming distance between them is 1.\n\nSo, a valid answer is [words[0],words[2]] = [\"bab\",\"cab\"].\nAnother subsequence that can be selected is [0,1].\n\ngroups[0] != groups[1]\nwords[0].length == words[1].length, and the hamming distance between them is 1.\n\nSo, another valid answer is [words[0],words[1]] = [\"bab\",\"dab\"].\nIt can be shown that the length of the longest subsequence of indices that satisfies the conditions is 2.\n\nExample 2:\n\nInput: words = [\"a\",\"b\",\"c\",\"d\"], groups = [1,2,3,4]\nOutput: [\"a\",\"b\",\"c\",\"d\"]\nExplanation: We can select the subsequence [0,1,2,3].\nIt satisfies both conditions.\nHence, the answer is [words[0],words[1],words[2],words[3]] = [\"a\",\"b\",\"c\",\"d\"].\nIt has the longest length among all subsequences of indices that satisfy the conditions.\nHence, it is the only answer.\n\n \nConstraints:\n\n1 <= n == words.length == groups.length <= 1000\n1 <= words[i].length <= 10\n1 <= groups[i] <= n\nwords consists of distinct strings.\nwords[i] consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'bac', 'bca', 'cab', 'cba', 'acb'],groups = [1, 2, 1, 2, 1, 2]) == ['abc']\n assert candidate(words = ['same', 'sane', 'same'],groups = [1, 2, 1]) == ['same', 'sane', 'same']\n assert candidate(words = ['test', 'tast', 'best', 'rest'],groups = [1, 2, 2, 3]) == ['test', 'best', 'rest']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'hexlo'],groups = [1, 2, 2, 3]) == ['hello', 'hallo']\n assert candidate(words = ['abcd', 'abcf', 'abgf', 'abgh'],groups = [1, 2, 2, 3]) == ['abcd', 'abcf']\n assert candidate(words = ['hello', 'hallo', 'hbllo', 'hillo'],groups = [1, 1, 2, 3]) == ['hello', 'hbllo', 'hillo']\n assert candidate(words = ['bab', 'dab', 'cab'],groups = [1, 2, 2]) == ['bab', 'dab']\n assert candidate(words = ['word', 'worm', 'wore', 'core'],groups = [1, 2, 1, 2]) == ['word', 'worm', 'wore', 'core']\n assert candidate(words = ['same', 'sane', 'tame', 'game'],groups = [1, 2, 2, 3]) == ['same', 'tame', 'game']\n assert candidate(words = ['a', 'b', 'c', 'd'],groups = [1, 2, 3, 4]) == ['a', 'b', 'c', 'd']\n assert candidate(words = ['apple', 'appla', 'appel'],groups = [1, 2, 1]) == ['apple', 'appla']\n assert candidate(words = ['a', 'ab', 'abc', 'abcd'],groups = [1, 2, 3, 4]) == ['a']\n assert candidate(words = ['zzz', 'zzx', 'zzw', 'zzv'],groups = [1, 2, 3, 4]) == ['zzz', 'zzx', 'zzw', 'zzv']\n assert candidate(words = ['test', 'tast', 'tost', 'test'],groups = [1, 2, 1, 2]) == ['test', 'tast', 'tost', 'test']\n assert candidate(words = ['abc', 'bcd', 'cde', 'def'],groups = [1, 2, 3, 4]) == ['abc']\n assert candidate(words = ['one', 'two', 'three', 'four'],groups = [1, 2, 2, 3]) == ['one']\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl'],groups = [1, 1, 2, 2]) == ['abc']\n assert candidate(words = ['word', 'wird', 'word', 'wird'],groups = [1, 2, 1, 2]) == ['word', 'wird', 'word', 'wird']\n assert candidate(words = ['abc', 'abb', 'aba', 'aaa', 'aab'],groups = [1, 2, 3, 4, 5]) == ['abc', 'abb', 'aba', 'aaa', 'aab']\n assert candidate(words = ['aabb', 'abab', 'abba', 'baab'],groups = [1, 2, 1, 2]) == ['aabb']\n assert candidate(words = ['aabb', 'abab', 'babb', 'baab'],groups = [1, 2, 1, 2]) == ['babb', 'baab']\n assert candidate(words = ['cat', 'cot', 'dog', 'dot', 'log'],groups = [1, 2, 1, 2, 3]) == ['cat', 'cot']\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],groups = [1, 2, 1, 2, 1, 2]) == ['abc']\n assert candidate(words = ['xyz', 'xyw', 'xyv', 'xyu'],groups = [1, 2, 3, 4]) == ['xyz', 'xyw', 'xyv', 'xyu']\n assert candidate(words = ['aaaa', 'aaab', 'aabb', 'abbb', 'bbbb'],groups = [1, 2, 3, 4, 5]) == ['aaaa', 'aaab', 'aabb', 'abbb', 'bbbb']\n assert candidate(words = ['abc', 'bac', 'cab', 'bca', 'acb', 'cba'],groups = [1, 2, 3, 1, 2, 3]) == ['abc']\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abcg'],groups = [1, 2, 3, 4]) == ['abcd', 'abce', 'abcf', 'abcg']\n assert candidate(words = ['abc', 'abd', 'acd', 'bcd', 'ace'],groups = [1, 2, 1, 2, 1]) == ['abc', 'abd', 'acd', 'bcd']\n assert candidate(words = ['abcd', 'abcf', 'abdf', 'abef', 'acdf', 'acef', 'bcdf', 'bcef'],groups = [1, 2, 1, 2, 1, 2, 1, 2]) == ['abcd', 'abcf', 'abdf', 'abef']\n assert candidate(words = ['code', 'codd', 'cods', 'coex', 'coey'],groups = [1, 2, 2, 3, 3]) == ['code', 'codd']\n assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'efg'],groups = [1, 2, 3, 4, 5]) == ['abc']\n assert candidate(words = ['apple', 'apples', 'appl', 'app'],groups = [1, 2, 3, 4]) == ['apple']\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']\n assert candidate(words = ['same', 'sane', 'sate', 'site'],groups = [1, 2, 1, 2]) == ['same', 'sane', 'sate', 'site']\n assert candidate(words = ['abcde', 'abfde', 'abcfe', 'abcef'],groups = [1, 2, 3, 4]) == ['abcde', 'abfde']\n assert candidate(words = ['abc', 'abd', 'acd', 'bcd', 'bce', 'bde'],groups = [1, 2, 1, 2, 1, 2]) == ['abc', 'abd', 'acd', 'bcd', 'bce', 'bde']\n assert candidate(words = ['mnop', 'mnoq', 'mnrp', 'mnsp', 'mntp'],groups = [1, 2, 3, 2, 1]) == ['mnop', 'mnrp', 'mnsp', 'mntp']\n assert candidate(words = ['apple', 'apply', 'appla', 'appla'],groups = [1, 2, 1, 3]) == ['apple', 'apply', 'appla']\n assert candidate(words = ['aaaa', 'abaa', 'acaa', 'aada', 'aada', 'aadd'],groups = [1, 2, 3, 1, 2, 3]) == ['aaaa', 'abaa', 'acaa']\n assert candidate(words = ['dog', 'cog', 'dag', 'dog', 'dig'],groups = [1, 2, 1, 2, 1]) == ['dag', 'dog', 'dig']\n assert candidate(words = ['word', 'worm', 'wirm', 'wirm', 'wirn'],groups = [1, 2, 3, 4, 5]) == ['word', 'worm', 'wirm', 'wirn']\n assert candidate(words = ['test', 'tast', 'tost', 'test', 'teat'],groups = [1, 2, 1, 2, 1]) == ['test', 'tast', 'tost', 'test', 'teat']\n assert candidate(words = ['aaaaa', 'aaaba', 'aaaca', 'aaada'],groups = [1, 2, 1, 2]) == ['aaaaa', 'aaaba', 'aaaca', 'aaada']\n assert candidate(words = ['cat', 'bat', 'rat', 'tat'],groups = [1, 2, 1, 2]) == ['cat', 'bat', 'rat', 'tat']\n assert candidate(words = ['abcde', 'abcdf', 'abcgf', 'abchg', 'abchf'],groups = [1, 2, 3, 4, 3]) == ['abcde', 'abcdf', 'abcgf']\n assert candidate(words = ['abcde', 'abcdf', 'abcef', 'abcag'],groups = [1, 2, 1, 2]) == ['abcde', 'abcdf', 'abcef']\n assert candidate(words = ['apple', 'appla', 'appla', 'applb', 'applc'],groups = [1, 2, 2, 3, 3]) == ['apple', 'appla', 'applb']\n assert candidate(words = ['abc', 'acc', 'bcd', 'bce', 'bde'],groups = [1, 2, 1, 2, 1]) == ['bcd', 'bce', 'bde']\n assert candidate(words = ['start', 'starr', 'statr', 'strat', 'strot'],groups = [1, 2, 1, 2, 1]) == ['start', 'starr', 'statr']\n assert candidate(words = ['abcd', 'abcf', 'abdg', 'abef'],groups = [1, 2, 3, 4]) == ['abcd', 'abcf', 'abef']\n assert candidate(words = ['aaaa', 'aaab', 'aaba', 'abaa', 'baaa'],groups = [1, 2, 3, 4, 5]) == ['aaaa', 'aaab']\n assert candidate(words = ['kitten', 'sitten', 'bitten', 'bitter', 'bitter'],groups = [1, 2, 3, 4, 5]) == ['kitten', 'sitten', 'bitten', 'bitter']\n assert candidate(words = ['hello', 'hallo', 'hella', 'hellu'],groups = [1, 2, 1, 2]) == ['hello', 'hallo']\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abcg', 'abch', 'abcx'],groups = [1, 2, 3, 4, 5, 6]) == ['abcd', 'abce', 'abcf', 'abcg', 'abch', 'abcx']\n assert candidate(words = ['hello', 'hxllo', 'hexlo', 'helxo'],groups = [1, 2, 3, 4]) == ['hello', 'hxllo']\n assert candidate(words = ['aabb', 'abab', 'baba', 'bbaa'],groups = [1, 2, 1, 2]) == ['aabb']\n assert candidate(words = ['apple', 'abble', 'abble', 'abble'],groups = [1, 2, 3, 2]) == ['apple']\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abcg', 'abch', 'abci'],groups = [1, 2, 3, 4, 5, 6]) == ['abcd', 'abce', 'abcf', 'abcg', 'abch', 'abci']\n assert candidate(words = ['abc', 'abd', 'abe', 'bcd', 'bce'],groups = [1, 1, 2, 2, 3]) == ['abc', 'abe']\n assert candidate(words = ['abcd', 'abcf', 'abcd', 'abcf'],groups = [1, 2, 1, 2]) == ['abcd', 'abcf', 'abcd', 'abcf']\n assert candidate(words = ['abcd', 'abcf', 'abcd', 'abdf'],groups = [1, 2, 3, 4]) == ['abcd', 'abcf', 'abcd']\n assert candidate(words = ['abcd', 'acbd', 'abzd', 'abxc'],groups = [1, 2, 3, 4]) == ['abcd', 'abzd']\n assert candidate(words = ['same', 'same', 'same', 'same'],groups = [1, 2, 3, 4]) == ['same']\n assert candidate(words = ['abc', 'abd', 'acc', 'bcd'],groups = [1, 2, 1, 3]) == ['abc', 'abd']\n assert candidate(words = ['zebra', 'zeara', 'zeraa', 'zerar'],groups = [1, 2, 1, 2]) == ['zebra', 'zeara']\n assert candidate(words = ['abcd', 'abdc', 'acdb', 'adcb', 'bacd', 'bcad', 'bdac', 'bdca'],groups = [1, 2, 1, 2, 1, 2, 1, 2]) == ['abcd']\n assert candidate(words = ['apple', 'apply', 'spoke', 'slope'],groups = [1, 2, 3, 4]) == ['apple', 'apply']\n assert candidate(words = ['abcd', 'abcf', 'abdc', 'abcf'],groups = [1, 2, 1, 2]) == ['abcd', 'abcf']\n assert candidate(words = ['hello', 'hallo', 'hullo', 'hella', 'hillo'],groups = [1, 2, 1, 2, 1]) == ['hello', 'hallo', 'hullo']\n assert candidate(words = ['hello', 'hallo', 'hella', 'hell'],groups = [1, 2, 1, 2]) == ['hello', 'hallo']\n assert candidate(words = ['test', 'tset', 'sett', 'stet'],groups = [1, 2, 1, 2]) == ['test']\n assert candidate(words = ['word', 'worm', 'wore', 'core', 'cord', 'cred'],groups = [1, 2, 1, 2, 1, 2]) == ['word', 'worm', 'wore', 'core', 'cord']\n assert candidate(words = ['zebra', 'zera', 'zeraa', 'zeara'],groups = [1, 2, 1, 2]) == ['zebra', 'zeara']\n assert candidate(words = ['zebra', 'zebra', 'zebra', 'zebra'],groups = [1, 2, 1, 2]) == ['zebra']\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abca'],groups = [1, 2, 3, 4]) == ['abcd', 'abce', 'abcf', 'abca']\n assert candidate(words = ['dog', 'dig', 'dug', 'dot'],groups = [1, 2, 1, 2]) == ['dog', 'dig', 'dug']\n assert candidate(words = ['abcd', 'abcf', 'abde', 'abdc'],groups = [1, 2, 3, 4]) == ['abcd', 'abcf']\n assert candidate(words = ['hello', 'hallo', 'hella', 'hellu'],groups = [1, 2, 1, 3]) == ['hello', 'hallo']\n assert candidate(words = ['abcd', 'abcf', 'abdg', 'abeg'],groups = [1, 2, 3, 4]) == ['abcd', 'abcf']\n assert candidate(words = ['abc', 'abd', 'acd', 'bcd', 'ace', 'bce', 'abe', 'bde', 'cde', 'abc'],groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == ['abc', 'abd', 'acd', 'bcd', 'bce', 'bde', 'cde']\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],groups = [1, 2, 3, 4, 5]) == ['one']\n assert candidate(words = ['word', 'wird', 'wurd', 'wurd', 'wurk'],groups = [1, 2, 1, 2, 3]) == ['word', 'wird', 'wurd', 'wurk']\n assert candidate(words = ['same', 'sane', 'sane', 'sane', 'same'],groups = [1, 2, 2, 3, 3]) == ['same', 'sane', 'same']\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc'],groups = [1, 2, 1, 2, 1, 2, 1]) == ['abc']\n assert candidate(words = ['abcd', 'abcf', 'abde', 'abce', 'abcd'],groups = [1, 2, 3, 4, 1]) == ['abcd', 'abcf', 'abce', 'abcd']\n assert candidate(words = ['xyza', 'xyzb', 'xyzc', 'xyzd'],groups = [1, 2, 3, 4]) == ['xyza', 'xyzb', 'xyzc', 'xyzd']\n assert candidate(words = ['abc', 'acd', 'bcd', 'bed'],groups = [1, 2, 1, 2]) == ['acd', 'bcd', 'bed']\n assert candidate(words = ['zebra', 'zera', 'zeraa', 'zerab', 'zercb'],groups = [1, 2, 1, 2, 1]) == ['zeraa', 'zerab', 'zercb']\n assert candidate(words = ['code', 'kode', 'coke', 'cide'],groups = [1, 2, 1, 2]) == ['code', 'kode']\n assert candidate(words = ['abc', 'abd', 'bcd', 'bce'],groups = [1, 2, 1, 2]) == ['abc', 'abd']\n assert candidate(words = ['word', 'worm', 'worn', 'word'],groups = [1, 2, 1, 2]) == ['word', 'worm', 'worn', 'word']\n assert candidate(words = ['python', 'phyton', 'phthon', 'pyhton'],groups = [1, 2, 1, 2]) == ['python']\n assert candidate(words = ['hello', 'hallo', 'hillo', 'hella', 'hellb'],groups = [1, 2, 2, 3, 3]) == ['hello', 'hallo']\n assert candidate(words = ['test', 'tast', 'tost', 'test'],groups = [1, 2, 3, 4]) == ['test', 'tast', 'tost', 'test']\n assert candidate(words = ['abc', 'aabb', 'abbb', 'babb', 'bbcc'],groups = [1, 2, 2, 3, 3]) == ['aabb', 'babb']\n assert candidate(words = ['abcd', 'abcf', 'abdf', 'acdf'],groups = [1, 2, 3, 1]) == ['abcd', 'abcf', 'abdf', 'acdf']\n assert candidate(words = ['hello', 'hallo', 'hullo', 'hella'],groups = [1, 2, 3, 4]) == ['hello', 'hallo', 'hullo']\n assert candidate(words = ['aaaa', 'aaab', 'aabb', 'abbb'],groups = [1, 1, 2, 2]) == ['aaab', 'aabb']\n assert candidate(words = ['abcd', 'abdd', 'acdd', 'acdd', 'acde', 'acdf'],groups = [1, 2, 3, 1, 2, 3]) == ['abcd', 'abdd', 'acdd', 'acde', 'acdf']\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno'],groups = [1, 1, 1, 1, 1]) == ['abc']\n assert candidate(words = ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa'],groups = [1, 2, 3, 4, 5, 6]) == ['aabb']\n assert candidate(words = ['hello', 'hallo', 'hillo', 'hollo'],groups = [1, 1, 2, 2]) == ['hello', 'hillo']\n assert candidate(words = ['aabb', 'aacc', 'aadd', 'aabb', 'aacc'],groups = [1, 2, 3, 1, 2]) == ['aabb']\n assert candidate(words = ['abcd', 'abcf', 'acdf', 'bcdf'],groups = [1, 2, 3, 4]) == ['abcd', 'abcf']\n assert candidate(words = ['one', 'two', 'thr', 'fou', 'fiv'],groups = [1, 2, 1, 2, 1]) == ['one']\n assert candidate(words = ['apple', 'appla', 'applb', 'applc', 'appld'],groups = [1, 2, 2, 2, 3]) == ['apple', 'appla', 'appld']\n assert candidate(words = ['graph', 'grapf', 'graph', 'grapt', 'grapt'],groups = [1, 2, 3, 2, 1]) == ['graph', 'grapf', 'graph', 'grapt']\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abcd'],groups = [1, 2, 1, 2]) == ['abcd', 'abce', 'abcf', 'abcd']\n assert candidate(words = ['aaab', 'abab', 'abba', 'baaa'],groups = [1, 2, 3, 4]) == ['aaab', 'abab']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'hexlo', 'hexxo'],groups = [1, 2, 2, 3, 3]) == ['hello', 'hallo']\n assert candidate(words = ['abc', 'bcd', 'bce', 'bde', 'bdf'],groups = [1, 2, 2, 3, 4]) == ['bce', 'bde', 'bdf']\n assert candidate(words = ['abcd', 'abcf', 'abde', 'abce'],groups = [1, 2, 3, 4]) == ['abcd', 'abcf', 'abce']\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abcg', 'abch'],groups = [1, 2, 3, 4, 5]) == ['abcd', 'abce', 'abcf', 'abcg', 'abch']\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abdg', 'abdh'],groups = [1, 2, 3, 4, 5]) == ['abcd', 'abce', 'abcf']\n assert candidate(words = ['abc', 'abd', 'abe', 'ace', 'adf', 'aeg'],groups = [1, 2, 1, 2, 1, 2]) == ['abc', 'abd', 'abe', 'ace']\n assert candidate(words = ['cat', 'bat', 'rat', 'mat'],groups = [1, 2, 1, 2]) == ['cat', 'bat', 'rat', 'mat']\n assert candidate(words = ['apple', 'apble', 'appla', 'applb', 'applc'],groups = [1, 2, 3, 2, 1]) == ['apple', 'appla', 'applb', 'applc']\n assert candidate(words = ['aaaa', 'aaab', 'aaba', 'abaa'],groups = [1, 2, 1, 2]) == ['aaaa', 'aaab']\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abci', 'abcj'],groups = [1, 2, 3, 4, 5]) == ['abcd', 'abce', 'abcf', 'abci', 'abcj']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'hexlo', 'hexxo'],groups = [1, 2, 3, 4, 5]) == ['hello', 'hallo', 'hxllo']\n assert candidate(words = ['cat', 'bat', 'rat', 'cap', 'car'],groups = [1, 2, 3, 4, 5]) == ['cat', 'bat', 'rat']\n assert candidate(words = ['aaaa', 'abaa', 'acaa', 'aada'],groups = [1, 1, 2, 2]) == ['aaaa', 'acaa']\n assert candidate(words = ['apple', 'abble', 'abble', 'abble', 'abble'],groups = [1, 2, 1, 2, 1]) == ['apple']\n assert candidate(words = ['zzzz', 'zzzw', 'zzzx', 'zzzy'],groups = [1, 2, 3, 4]) == ['zzzz', 'zzzw', 'zzzx', 'zzzy']\n assert candidate(words = ['abcd', 'abcc', 'abcb', 'abca'],groups = [1, 2, 1, 2]) == ['abcd', 'abcc', 'abcb', 'abca']\n assert candidate(words = ['aaaa', 'abaa', 'acaa', 'adab', 'adac'],groups = [1, 2, 3, 1, 2]) == ['aaaa', 'abaa', 'acaa']\n assert candidate(words = ['xylo', 'xyxo', 'xyxo', 'xylo', 'xylo'],groups = [1, 2, 3, 2, 1]) == ['xylo', 'xyxo', 'xylo']\n assert candidate(words = ['aaaa', 'aaba', 'abaa', 'abba', 'acaa', 'acba'],groups = [1, 2, 1, 2, 1, 2]) == ['aaaa', 'aaba']\n assert candidate(words = ['zzzz', 'zzzy', 'zzzx', 'zzxw'],groups = [5, 4, 3, 2]) == ['zzzz', 'zzzy', 'zzzx']\n assert candidate(words = ['abcd', 'abdc', 'acdb', 'adcb'],groups = [1, 2, 1, 2]) == ['abcd']\n assert candidate(words = ['aaaa', 'aaab', 'aaba', 'abaa', 'aaaa'],groups = [1, 2, 1, 2, 1]) == ['aaaa', 'aaab', 'aaaa']\n assert candidate(words = ['hello', 'hallo', 'hillo', 'hillo'],groups = [1, 2, 1, 3]) == ['hello', 'hallo', 'hillo']\n assert candidate(words = ['abcde', 'abxde', 'abxde', 'abcye'],groups = [1, 2, 2, 3]) == ['abcde', 'abxde']\n assert candidate(words = ['aaaa', 'abaa', 'acaa', 'aada', 'aada', 'aadd', 'aadd', 'aade'],groups = [1, 2, 1, 2, 3, 3, 4, 4]) == ['aaaa', 'aada', 'aadd', 'aade']\n assert candidate(words = ['apple', 'appla', 'abble', 'abble'],groups = [1, 2, 3, 2]) == ['apple', 'appla']\n assert candidate(words = ['hello', 'hallo', 'hullo', 'hellu'],groups = [1, 2, 1, 2]) == ['hello', 'hallo', 'hullo']\n assert candidate(words = ['test', 'tast', 'tost', 'test', 'tast', 'tost', 'test'],groups = [1, 2, 1, 2, 1, 2, 1]) == ['test', 'tast', 'tost', 'test', 'tast', 'tost', 'test']\n assert candidate(words = ['zzzz', 'zzzy', 'zzzx', 'zzxw'],groups = [1, 2, 1, 2]) == ['zzzz', 'zzzy', 'zzzx']\n assert candidate(words = ['apple', 'apply', 'appla', 'applu'],groups = [1, 2, 3, 4]) == ['apple', 'apply', 'appla', 'applu']\n assert candidate(words = ['word', 'ward', 'wird', 'wrod', 'wore', 'core'],groups = [1, 2, 1, 2, 1, 2]) == ['word', 'ward', 'wird']\n assert candidate(words = ['word', 'worm', 'womb', 'womb'],groups = [1, 2, 1, 3]) == ['word', 'worm']\n assert candidate(words = ['dog', 'dot', 'lot', 'log', 'cog'],groups = [1, 2, 2, 3, 4]) == ['dog', 'log', 'cog']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'hellp'],groups = [1, 2, 3, 4]) == ['hello', 'hallo', 'hxllo']\n assert candidate(words = ['same', 'sane', 'sane', 'same'],groups = [1, 2, 3, 4]) == ['same', 'sane', 'same']\n assert candidate(words = ['abc', 'abd', 'acd', 'bcd'],groups = [1, 2, 1, 2]) == ['abc', 'abd', 'acd', 'bcd']\n assert candidate(words = ['one', 'two', 'three'],groups = [1, 2, 1]) == ['one']\n assert candidate(words = ['abc', 'abd', 'acc', 'bcd'],groups = [1, 1, 2, 2]) == ['abc', 'acc']\n assert candidate(words = ['abc', 'abd', 'abc', 'abe'],groups = [1, 2, 3, 4]) == ['abc', 'abd', 'abc', 'abe']\n assert candidate(words = ['hello', 'hallo', 'hullo', 'hellu'],groups = [1, 1, 2, 2]) == ['hello', 'hullo']\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl'],groups = [1, 1, 1, 1]) == ['abc']\n assert candidate(words = ['aaaa', 'aaab', 'aaba', 'abaa', 'abab', 'abba', 'bbaa', 'bbab', 'bbba', 'bbbb'],groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == ['aaaa']\n assert candidate(words = ['abc', 'abd', 'bcd', 'ace'],groups = [1, 2, 1, 2]) == ['abc', 'abd']\n assert candidate(words = ['loop', 'loap', 'leep', 'leap'],groups = [1, 2, 3, 4]) == ['loop', 'loap', 'leap']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'hexlo'],groups = [1, 2, 1, 2]) == ['hello', 'hallo', 'hxllo']\n assert candidate(words = ['word', 'ward', 'wear', 'ware'],groups = [1, 2, 3, 2]) == ['word', 'ward']\n assert candidate(words = ['aaa', 'aab', 'aac', 'aba', 'abb'],groups = [1, 2, 3, 4, 5]) == ['aaa', 'aab', 'aac']\n assert candidate(words = ['fun', 'sun', 'tun', 'fum'],groups = [1, 2, 3, 4]) == ['fun', 'sun', 'tun']\n assert candidate(words = ['abcd', 'abcf', 'abdc'],groups = [1, 2, 1]) == ['abcd', 'abcf']\n assert candidate(words = ['word', 'woro', 'work'],groups = [3, 3, 4]) == ['word', 'work']\n assert candidate(words = ['test', 'tast', 'tist', 'best'],groups = [1, 2, 3, 1]) == ['test', 'tast', 'tist']\n assert candidate(words = ['cat', 'bat', 'rat', 'car'],groups = [1, 2, 1, 2]) == ['cat', 'bat', 'rat']\n assert candidate(words = ['test', 'text', 'tast', 'tect'],groups = [1, 2, 1, 2]) == ['test', 'text']\n assert candidate(words = ['apple', 'appla', 'applb', 'applc'],groups = [3, 3, 4, 4]) == ['apple', 'applb']\n assert candidate(words = ['zero', 'hero', 'hero', 'hero'],groups = [1, 2, 1, 2]) == ['zero', 'hero']\n assert candidate(words = ['cat', 'bat', 'rat', 'car'],groups = [1, 2, 3, 4]) == ['cat', 'bat', 'rat']\n assert candidate(words = ['abcd', 'abcf', 'abgd'],groups = [1, 2, 1]) == ['abcd', 'abcf']\n assert candidate(words = ['word', 'work', 'worm', 'worn'],groups = [1, 2, 1, 2]) == ['word', 'work', 'worm', 'worn']\n assert candidate(words = ['word', 'wird', 'word', 'wird'],groups = [1, 2, 3, 4]) == ['word', 'wird', 'word', 'wird']\n assert candidate(words = ['zebra', 'zebra', 'zebra'],groups = [1, 2, 1]) == ['zebra']\n assert candidate(words = ['hello', 'hallo', 'hellp', 'hxllo'],groups = [5, 5, 6, 7]) == ['hello', 'hellp']\n assert candidate(words = ['hello', 'hallo', 'hella'],groups = [1, 2, 3]) == ['hello', 'hallo']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'hexlo'],groups = [1, 1, 2, 2]) == ['hello', 'hxllo']\n assert candidate(words = ['hello', 'hallo', 'hxllo'],groups = [1, 1, 2]) == ['hello', 'hxllo']\n assert candidate(words = ['dog', 'dot', 'lot', 'log'],groups = [1, 2, 3, 4]) == ['dog', 'dot', 'lot', 'log']\n assert candidate(words = ['test', 'text', 'tast', 'tuxt'],groups = [1, 1, 2, 2]) == ['test', 'tast']\n assert candidate(words = ['star', 'tart', 'kart', 'tars'],groups = [1, 2, 3, 4]) == ['tart', 'kart']\n assert candidate(words = ['tiny', 'tint', 'tint', 'tank'],groups = [1, 2, 1, 2]) == ['tiny', 'tint']\n assert candidate(words = ['aaa', 'aab', 'aac', 'aba', 'aca', 'baa', 'bab', 'bac', 'caa', 'cab', 'cac'],groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == ['aaa', 'aab', 'aac', 'bac', 'cac']\n assert candidate(words = ['apple', 'appla', 'applu', 'appli'],groups = [1, 2, 1, 2]) == ['apple', 'appla', 'applu', 'appli']\n assert candidate(words = ['java', 'lava', 'slava', 'flava'],groups = [1, 2, 3, 4]) == ['java', 'lava']\n assert candidate(words = ['same', 'sane', 'tame', 'game'],groups = [1, 2, 1, 2]) == ['same', 'sane']\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],groups = [1, 2, 3, 4, 5]) == ['a']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'hellp'],groups = [1, 1, 2, 2]) == ['hello', 'hxllo']\n assert candidate(words = ['word', 'wird', 'word', 'wird'],groups = [1, 2, 2, 3]) == ['word', 'wird']\n assert candidate(words = ['zzz', 'zyz', 'zxy', 'zyx'],groups = [1, 2, 3, 4]) == ['zzz', 'zyz', 'zyx']\n assert candidate(words = ['xyz', 'xyx', 'yzz', 'zzy'],groups = [3, 2, 3, 2]) == ['xyz', 'xyx']\n assert candidate(words = ['test', 'text', 'tset', 'best'],groups = [1, 2, 3, 4]) == ['test', 'text']\n assert candidate(words = ['apple', 'appla', 'applb', 'applc'],groups = [1, 2, 3, 4]) == ['apple', 'appla', 'applb', 'applc']\n assert candidate(words = ['abc', 'def', 'ghi'],groups = [1, 2, 3]) == ['abc']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'pxllo'],groups = [1, 2, 1, 2]) == ['hello', 'hallo', 'hxllo', 'pxllo']\n assert candidate(words = ['code', 'kode', 'kode'],groups = [1, 2, 1]) == ['code', 'kode']\n assert candidate(words = ['hello', 'hallo', 'hullo', 'hellp'],groups = [1, 2, 1, 2]) == ['hello', 'hallo', 'hullo']\n assert candidate(words = ['test', 'tast', 'west', 'lest'],groups = [1, 2, 1, 2]) == ['test', 'tast']\n assert candidate(words = ['cat', 'bat', 'rat', 'car'],groups = [1, 1, 2, 2]) == ['cat', 'rat']\n assert candidate(words = ['abc', 'abd', 'acc', 'bcd'],groups = [1, 2, 1, 2]) == ['abc', 'abd']\n assert candidate(words = ['abc', 'bcd', 'cde', 'dec'],groups = [1, 2, 3, 4]) == ['abc']\n assert candidate(words = ['test', 'tast', 'fest', 'best'],groups = [1, 2, 1, 2]) == ['test', 'tast']\n assert candidate(words = ['aaa', 'aab', 'aba', 'baa', 'bbb'],groups = [1, 2, 3, 2, 1]) == ['aaa', 'aab']\n assert candidate(words = ['hello', 'hallo', 'hellp', 'herlo'],groups = [1, 1, 2, 2]) == ['hello', 'hellp']\n assert candidate(words = ['test', 'tast', 'tist'],groups = [1, 2, 3]) == ['test', 'tast', 'tist']\n assert candidate(words = ['one', 'two', 'three', 'four'],groups = [1, 1, 1, 1]) == ['one']\n assert candidate(words = ['aaaa', 'aaab', 'aaba', 'abaa'],groups = [1, 2, 3, 4]) == ['aaaa', 'aaab']\n assert candidate(words = ['one', 'two', 'three', 'four'],groups = [1, 1, 2, 2]) == ['one']\n assert candidate(words = ['hello', 'hallo', 'hella'],groups = [1, 2, 1]) == ['hello', 'hallo']\n assert candidate(words = ['test', 'tast', 'tist', 'teat'],groups = [1, 2, 1, 2]) == ['test', 'tast', 'tist']\n assert candidate(words = ['test', 'tast', 'tast'],groups = [1, 2, 1]) == ['test', 'tast']\n assert candidate(words = ['abc', 'abd', 'acc'],groups = [1, 2, 1]) == ['abc', 'abd']\n assert candidate(words = ['abc', 'abd', 'acc', 'acd'],groups = [1, 2, 3, 4]) == ['abc', 'abd', 'acd']\n assert candidate(words = ['abc', 'abcd', 'abce'],groups = [1, 2, 3]) == ['abcd', 'abce']\n assert candidate(words = ['apple', 'apble', 'aagle', 'apgle', 'applu'],groups = [1, 2, 1, 2, 1]) == ['apple', 'apble']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'hell'],groups = [1, 2, 1, 2]) == ['hello', 'hallo', 'hxllo']\n assert candidate(words = ['hello', 'hallo', 'hella', 'hellu'],groups = [1, 2, 2, 3]) == ['hello', 'hella', 'hellu']\n assert candidate(words = ['same', 'sane', 'sane', 'same'],groups = [1, 2, 1, 2]) == ['same', 'sane']\n assert candidate(words = ['apple', 'appla', 'applb', 'applc'],groups = [1, 2, 1, 2]) == ['apple', 'appla', 'applb', 'applc']\n assert candidate(words = ['code', 'cide', 'codi', 'coie'],groups = [1, 1, 2, 2]) == ['code', 'codi']\n assert candidate(words = ['hello', 'hallo', 'hxllo'],groups = [1, 2, 1]) == ['hello', 'hallo', 'hxllo']\n assert candidate(words = ['zoom', 'boom', 'boon', 'boom'],groups = [1, 2, 1, 3]) == ['zoom', 'boom', 'boon', 'boom']\n assert candidate(words = ['abcd', 'abcf', 'abef', 'abeg'],groups = [1, 2, 3, 4]) == ['abcd', 'abcf', 'abef', 'abeg']\n assert candidate(words = ['keep', 'peek', 'peel'],groups = [1, 2, 1]) == ['peek', 'peel']\n assert candidate(words = ['word', 'worm', 'worn'],groups = [1, 2, 3]) == ['word', 'worm', 'worn']\n assert candidate(words = ['apple', 'appla', 'applb', 'applc'],groups = [1, 2, 2, 3]) == ['apple', 'appla', 'applc']\n assert candidate(words = ['aaa', 'aab', 'aac', 'aad'],groups = [1, 2, 1, 2]) == ['aaa', 'aab', 'aac', 'aad']\n assert candidate(words = ['abc', 'bcd', 'cde', 'def'],groups = [1, 1, 2, 3]) == ['abc']\n assert candidate(words = ['aaa', 'aab', 'aac'],groups = [1, 2, 3]) == ['aaa', 'aab', 'aac']\n assert candidate(words = ['test', 'tast', 'tist', 'tast'],groups = [1, 2, 3, 1]) == ['test', 'tast', 'tist', 'tast']\n assert candidate(words = ['test', 'tast', 'tekt'],groups = [1, 2, 3]) == ['test', 'tast']\n assert candidate(words = ['abcd', 'abce', 'abcf'],groups = [1, 2, 3]) == ['abcd', 'abce', 'abcf']\n assert candidate(words = ['word', 'wore', 'word', 'worn'],groups = [1, 2, 3, 4]) == ['word', 'wore', 'word', 'worn']\n assert candidate(words = ['one', 'two', 'thr'],groups = [1, 1, 1]) == ['one']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'hellp'],groups = [1, 2, 1, 2]) == ['hello', 'hallo', 'hxllo']\n assert candidate(words = ['code', 'coed', 'cdeo'],groups = [2, 2, 3]) == ['code']\n assert candidate(words = ['loop', 'lopo', 'leep'],groups = [1, 2, 1]) == ['loop']\n assert candidate(words = ['same', 'sane', 'safe'],groups = [1, 1, 2]) == ['same', 'safe']\n assert candidate(words = ['apple', 'apply', 'spoil', 'spied'],groups = [1, 1, 2, 2]) == ['apple']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'pxllo'],groups = [1, 2, 3, 4]) == ['hello', 'hallo', 'hxllo', 'pxllo']\n assert candidate(words = ['test', 'text', 'tast', 'tast'],groups = [1, 2, 1, 3]) == ['test', 'text']\n assert candidate(words = ['abcd', 'abcf', 'abdf', 'abef'],groups = [1, 2, 3, 4]) == ['abcd', 'abcf', 'abdf', 'abef']\n assert candidate(words = ['one', 'two', 'ton', 'oen'],groups = [1, 1, 2, 2]) == ['one']\n assert candidate(words = ['word', 'wird', 'word', 'wond'],groups = [1, 1, 2, 2]) == ['wird', 'word']\n assert candidate(words = ['test', 'tast', 'ttst'],groups = [1, 2, 3]) == ['test', 'tast', 'ttst']\n assert candidate(words = ['aaa', 'aab', 'aac'],groups = [1, 2, 1]) == ['aaa', 'aab', 'aac']\n assert candidate(words = ['dog', 'dot', 'lot', 'log'],groups = [1, 2, 1, 2]) == ['dog', 'dot', 'lot', 'log']\n assert candidate(words = ['test', 'tast', 'teat'],groups = [1, 2, 3]) == ['test', 'tast']\n assert candidate(words = ['same', 'sane', 'same', 'sane'],groups = [1, 2, 1, 2]) == ['same', 'sane', 'same', 'sane']\n assert candidate(words = ['apple', 'bpple', 'cppld'],groups = [1, 2, 1]) == ['apple', 'bpple']\n assert candidate(words = ['xyz', 'xyx', 'xzx', 'xxz'],groups = [1, 1, 1, 1]) == ['xyz']\n assert candidate(words = ['apple', 'appla', 'bpple', 'appea'],groups = [1, 2, 3, 4]) == ['apple', 'appla', 'appea']\n assert candidate(words = ['apple', 'appla', 'applp'],groups = [1, 2, 1]) == ['apple', 'appla', 'applp']\n assert candidate(words = ['abcd', 'abcf', 'abce', 'abdc'],groups = [1, 1, 2, 1]) == ['abcd', 'abce']\n assert candidate(words = ['same', 'sane', 'sale', 'tale'],groups = [1, 2, 3, 4]) == ['same', 'sane', 'sale', 'tale']\n assert candidate(words = ['test', 'tast', 'tost', 'fest'],groups = [1, 2, 3, 4]) == ['test', 'tast', 'tost']\n assert candidate(words = ['cat', 'bat', 'rat', 'hat'],groups = [1, 1, 2, 2]) == ['cat', 'rat']\n assert candidate(words = ['one', 'two', 'three', 'four'],groups = [1, 2, 3, 4]) == ['one']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'pxllo'],groups = [1, 2, 2, 3]) == ['hello', 'hxllo', 'pxllo']\n assert candidate(words = ['same', 'sane', 'sane', 'same'],groups = [1, 2, 2, 3]) == ['same', 'sane', 'same']\n assert candidate(words = ['apple', 'appla', 'applu', 'applp'],groups = [1, 1, 2, 2]) == ['apple', 'applu']\n assert candidate(words = ['same', 'sane', 'safe', 'same'],groups = [1, 2, 3, 1]) == ['same', 'sane', 'safe', 'same']\n assert candidate(words = ['xyz', 'xyw', 'xzz', 'xyx'],groups = [1, 2, 1, 2]) == ['xyz', 'xyw']\n assert candidate(words = ['cat', 'dog', 'bat'],groups = [1, 2, 3]) == ['cat', 'bat']\n assert candidate(words = ['word', 'ward', 'cord', 'card'],groups = [1, 2, 3, 4]) == ['word', 'ward', 'card']\n assert candidate(words = ['same', 'sane', 'sake'],groups = [1, 2, 1]) == ['same', 'sane', 'sake']\n assert candidate(words = ['abc', 'abd', 'acc', 'aba'],groups = [1, 2, 3, 2]) == ['abc', 'abd']\n assert candidate(words = ['apple', 'appla', 'abble', 'abble'],groups = [1, 2, 2, 3]) == ['apple', 'appla']\n assert candidate(words = ['test', 'text', 'tast'],groups = [1, 2, 1]) == ['test', 'text']\n assert candidate(words = ['abcd', 'abcf', 'abdf'],groups = [1, 1, 2]) == ['abcf', 'abdf']\n assert candidate(words = ['word', 'worm', 'wirm', 'wirt'],groups = [1, 2, 1, 3]) == ['word', 'worm', 'wirm', 'wirt']\n assert candidate(words = ['code', 'kode', 'cide', 'coke'],groups = [1, 2, 3, 4]) == ['code', 'kode']\n assert candidate(words = ['word', 'worm', 'worn'],groups = [1, 2, 1]) == ['word', 'worm', 'worn']\n assert candidate(words = ['xyz', 'xyw', 'xzz', 'xyy'],groups = [2, 3, 2, 3]) == ['xyz', 'xyw']\n assert candidate(words = ['xyz', 'xyx', 'xyy', 'xyw'],groups = [1, 2, 3, 4]) == ['xyz', 'xyx', 'xyy', 'xyw']\n assert candidate(words = ['same', 'sane', 'tame', 'game'],groups = [1, 2, 3, 4]) == ['same', 'tame', 'game']\n assert candidate(words = ['tree', 'trex', 'trey', 'gree'],groups = [1, 2, 1, 2]) == ['tree', 'trex', 'trey']\n assert candidate(words = ['abc', 'bcd', 'cde', 'def'],groups = [1, 1, 2, 2]) == ['abc']\n assert candidate(words = ['test', 'tets', 'tast', 'tast'],groups = [1, 2, 2, 3]) == ['test', 'tast']\n assert candidate(words = ['abcd', 'abcf', 'abdg'],groups = [1, 2, 3]) == ['abcd', 'abcf']\n assert candidate(words = ['hello', 'hallo', 'hullo'],groups = [1, 2, 1]) == ['hello', 'hallo', 'hullo']\n assert candidate(words = ['abc', 'bcd', 'cde'],groups = [1, 1, 2]) == ['abc']\n assert candidate(words = ['same', 'sane', 'game', 'tame'],groups = [1, 2, 1, 2]) == ['same', 'sane']\n assert candidate(words = ['test', 'tast', 'teat', 'teet'],groups = [1, 2, 3, 4]) == ['test', 'teat', 'teet']\n assert candidate(words = ['abc', 'abd', 'acc'],groups = [1, 2, 3]) == ['abc', 'abd']\n assert candidate(words = ['code', 'cide', 'kode', 'coda'],groups = [1, 2, 1, 2]) == ['code', 'cide']\n assert candidate(words = ['same', 'sane', 'game'],groups = [1, 1, 2]) == ['same', 'game']\n assert candidate(words = ['hello', 'hallo', 'hxllo', 'hexlo'],groups = [10, 20, 10, 30]) == ['hello', 'hallo', 'hxllo']\n assert candidate(words = ['abc', 'abd', 'acc', 'bcd'],groups = [1, 2, 3, 4]) == ['abc', 'abd']\n assert candidate(words = ['hello', 'hallo', 'hullo', 'hellp'],groups = [1, 2, 1, 3]) == ['hello', 'hallo', 'hullo']\n assert candidate(words = ['play', 'plby', 'plya', 'plax'],groups = [1, 1, 2, 2]) == ['play', 'plax']\n assert candidate(words = ['test', 'tast', 'tost', 'tett'],groups = [1, 2, 1, 2]) == ['test', 'tast', 'tost']\n assert candidate(words = ['same', 'sane', 'sage', 'page'],groups = [1, 1, 2, 2]) == ['same', 'sage']\n assert candidate(words = ['test', 'tast', 'tell', 'tall'],groups = [1, 2, 3, 4]) == ['test', 'tast']\n assert candidate(words = ['same', 'sane', 'sale', 'male'],groups = [1, 2, 3, 4]) == ['same', 'sane', 'sale', 'male']\n assert candidate(words = ['abcd', 'abcf', 'abdf', 'acdf'],groups = [1, 2, 3, 4]) == ['abcd', 'abcf', 'abdf', 'acdf']\n assert candidate(words = ['apple', 'apply', 'spork'],groups = [1, 2, 1]) == ['apple', 'apply']\n assert candidate(words = ['test', 'text', 'tast', 'best'],groups = [1, 2, 1, 3]) == ['test', 'text']\n assert candidate(words = ['hello', 'hallo', 'hxllo'],groups = [1, 2, 3]) == ['hello', 'hallo', 'hxllo']\n assert candidate(words = ['abc', 'abd', 'bcd', 'bce'],groups = [1, 2, 2, 3]) == ['abc', 'abd']\n assert candidate(words = ['one', 'two', 'three'],groups = [1, 2, 3]) == ['one']\n assert candidate(words = ['same', 'sane', 'safe', 'sale'],groups = [1, 2, 1, 2]) == ['same', 'sane', 'safe', 'sale']\n assert candidate(words = ['dog', 'cog', 'rog'],groups = [1, 2, 3]) == ['dog', 'cog', 'rog']\n assert candidate(words = ['five', 'fife', 'five', 'five'],groups = [1, 2, 1, 2]) == ['five', 'fife', 'five']\n assert candidate(words = ['abc', 'bcd', 'cde', 'efg'],groups = [1, 1, 2, 2]) == ['abc']\n assert candidate(words = ['aaa', 'aab', 'aba', 'abb', 'baa', 'bab', 'bba', 'bbb'],groups = [1, 2, 3, 4, 5, 6, 7, 8]) == ['aaa', 'aab', 'abb', 'bbb']\n assert candidate(words = ['zzz', 'zzy', 'zyy', 'yyy'],groups = [1, 2, 1, 2]) == ['zzz', 'zzy', 'zyy', 'yyy']\n assert candidate(words = ['word', 'worm', 'worn', 'word'],groups = [1, 2, 1, 3]) == ['word', 'worm', 'worn', 'word']\n assert candidate(words = ['code', 'mode', 'mroe'],groups = [1, 2, 1]) == ['code', 'mode']\n assert candidate(words = ['word', 'worm', 'worn'],groups = [1, 1, 2]) == ['word', 'worn']\n assert candidate(words = ['apple', 'apply', 'appla'],groups = [1, 1, 2]) == ['apple', 'appla']\n assert candidate(words = ['cat', 'bat', 'rat', 'hat'],groups = [1, 2, 3, 4]) == ['cat', 'bat', 'rat', 'hat']\n assert candidate(words = ['abc', 'bcd', 'cde'],groups = [1, 1, 1]) == ['abc']\n assert candidate(words = ['cat', 'bat', 'rat', 'hat'],groups = [1, 1, 1, 2]) == ['cat', 'hat']\n assert candidate(words = ['word', 'wird', 'wordy'],groups = [1, 2, 3]) == ['word', 'wird']\n"}, "metadata": {"canonical_parameter_names": ["words", "groups"], "leetcode_dataset_entry_point": "Solution().getWordsInLongestSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List getWordsInLongestSubsequence(String[] words, int[] groups) {", "container": "Solution", "callable": "getWordsInLongestSubsequence", "parameters": [{"name": "words", "type": "String[]"}, {"name": "groups", "type": "int[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2902, "task_id": "count-of-sub-multisets-with-bounded-sum", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array nums of non-negative integers, and two integers l and r.\nReturn the count of sub-multisets within nums where the sum of elements in each subset falls within the inclusive range of [l, r].\nSince the answer may be large, return it modulo 109 + 7.\nA sub-multiset is an unordered collection of elements of the array in which a given value x can occur 0, 1, ..., occ[x] times, where occ[x] is the number of occurrences of x in the array.\nNote that:\n\nTwo sub-multisets are the same if sorting both sub-multisets results in identical multisets.\nThe sum of an empty multiset is 0.\n\n \nExample 1:\n\nInput: nums = [1,2,2,3], l = 6, r = 6\nOutput: 1\nExplanation: The only subset of nums that has a sum of 6 is {1, 2, 3}.\n\nExample 2:\n\nInput: nums = [2,1,4,2,7], l = 1, r = 5\nOutput: 7\nExplanation: The subsets of nums that have a sum within the range [1, 5] are {1}, {2}, {4}, {2, 2}, {1, 2}, {1, 4}, and {1, 2, 2}.\n\nExample 3:\n\nInput: nums = [1,2,1,3,5,2], l = 3, r = 5\nOutput: 9\nExplanation: The subsets of nums that have a sum within the range [3, 5] are {3}, {5}, {1, 2}, {1, 3}, {2, 2}, {2, 3}, {1, 1, 2}, {1, 1, 3}, and {1, 2, 2}.\n \nConstraints:\n\n1 <= nums.length <= 2 * 104\n0 <= nums[i] <= 2 * 104\nSum of nums does not exceed 2 * 104.\n0 <= l <= r <= 2 * 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3],l = 6,r = 6) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],l = 15,r = 100) == 23\n assert candidate(nums = [10, 20, 30, 40, 50],l = 15,r = 75) == 14\n assert candidate(nums = [10, 20, 30, 40, 50],l = 15,r = 60) == 11\n assert candidate(nums = [1, 2, 1, 3, 5, 2],l = 3,r = 5) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = 5,r = 5) == 1\n assert candidate(nums = [1, 1, 1, 1, 1],l = 1,r = 5) == 5\n assert candidate(nums = [10000, 10000, 10000],l = 20000,r = 30000) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],l = 5,r = 10) == 18\n assert candidate(nums = [0, 0, 0],l = 0,r = 0) == 4\n assert candidate(nums = [2, 1, 4, 2, 7],l = 1,r = 5) == 7\n assert candidate(nums = [0, 0, 0, 0],l = 0,r = 0) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],l = 20,r = 30) == 104\n assert candidate(nums = [20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000],l = 10000,r = 20000) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = 5,r = 10) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = 10,r = 20) == 219\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],l = 25,r = 75) == 11\n assert candidate(nums = [1, 2, 3, 4, 5],l = 0,r = 15) == 32\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],l = 10,r = 20) == 247\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],l = 10,r = 40) == 11085\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],l = 100,r = 500) == 455555\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = 200,r = 500) == 796\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],l = 20000,r = 40000) == 704\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = 200,r = 400) == 704\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],l = 100,r = 1000) == 19\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5],l = 5,r = 15) == 169\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = 150,r = 300) == 531\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],l = 400,r = 600) == 12610\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],l = 5,r = 25) == 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],l = 50,r = 150) == 982553\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],l = 10,r = 50) == 23142\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = 0,r = 5) == 6\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],l = 5,r = 15) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],l = 20,r = 30) == 3\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],l = 4,r = 9) == 33\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],l = 15,r = 25) == 11\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = 2500,r = 4500) == 597\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],l = 250,r = 500) == 436865\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],l = 5,r = 15) == 119\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],l = 5000,r = 25000) == 426\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],l = 100,r = 400) == 192776\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],l = 20,r = 40) == 3\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],l = 15,r = 30) == 839\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],l = 20,r = 30) == 1254\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = 10,r = 20) == 11\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = 150,r = 400) == 826\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],l = 5,r = 15) == 205\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, 5, 5, 5, 5, 5, 5, 5, 5],l = 10,r = 20) == 316\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],l = 2000,r = 4000) == 2001\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20],l = 20,r = 60) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = 150,r = 450) == 892\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = 15,r = 50) == 918\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],l = 10,r = 30) == 1480\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = 20,r = 50) == 614\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],l = 10,r = 30) == 5\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],l = 20,r = 50) == 269\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],l = 20,r = 100) == 455555\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],l = 30,r = 100) == 3571\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500],l = 2500,r = 5000) == 6\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],l = 150,r = 300) == 4992\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],l = 100,r = 200) == 77629\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],l = 5000,r = 10000) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],l = 5000,r = 10000) == 23274\n assert candidate(nums = [10000],l = 10000,r = 10000) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],l = 20,r = 50) == 269\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = 1500,r = 3500) == 704\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],l = 500,r = 1000) == 501\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],l = 30,r = 100) == 865\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],l = 50,r = 100) == 20215\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],l = 20,r = 50) == 473\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],l = 30,r = 50) == 218\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],l = 50,r = 100) == 9146\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = 5,r = 8) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = 1500,r = 4500) == 892\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],l = 1000,r = 6000) == 50984\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],l = 5,r = 10) == 6\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],l = 10,r = 20) == 64\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22],l = 30,r = 70) == 1093\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = 1000,r = 3000) == 597\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = 100,r = 500) == 984\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = 15,r = 30) == 531\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],l = 70,r = 280) == 892\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],l = 50,r = 100) == 51\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = 15,r = 35) == 704\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],l = 100,r = 200) == 86894\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = 10,r = 30) == 597\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],l = 30,r = 150) == 620\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],l = 10,r = 20) == 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],l = 5,r = 15) == 11\n"}, "metadata": {"canonical_parameter_names": ["nums", "l", "r"], "leetcode_dataset_entry_point": "Solution().countSubMultisets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countSubMultisets(List nums, int l, int r) {", "container": "Solution", "callable": "countSubMultisets", "parameters": [{"name": "nums", "type": "List"}, {"name": "l", "type": "int"}, {"name": "r", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2903, "task_id": "find-indices-with-index-and-value-difference-i", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference.\nYour task is to find two indices i and j, both in the range [0, n - 1], that satisfy the following conditions:\n\nabs(i - j) >= indexDifference, and\nabs(nums[i] - nums[j]) >= valueDifference\n\nReturn an integer array answer, where answer = [i, j] if there are two such indices, and answer = [-1, -1] otherwise. If there are multiple choices for the two indices, return any of them.\nNote: i and j may be equal.\n \nExample 1:\n\nInput: nums = [5,1,4,1], indexDifference = 2, valueDifference = 4\nOutput: [0,3]\nExplanation: In this example, i = 0 and j = 3 can be selected.\nabs(0 - 3) >= 2 and abs(nums[0] - nums[3]) >= 4.\nHence, a valid answer is [0,3].\n[3,0] is also a valid answer.\n\nExample 2:\n\nInput: nums = [2,1], indexDifference = 0, valueDifference = 0\nOutput: [0,0]\nExplanation: In this example, i = 0 and j = 0 can be selected.\nabs(0 - 0) >= 0 and abs(nums[0] - nums[0]) >= 0.\nHence, a valid answer is [0,0].\nOther valid answers are [0,1], [1,0], and [1,1].\n\nExample 3:\n\nInput: nums = [1,2,3], indexDifference = 2, valueDifference = 4\nOutput: [-1,-1]\nExplanation: In this example, it can be shown that it is impossible to find two indices that satisfy both conditions.\nHence, [-1,-1] is returned.\n \nConstraints:\n\n1 <= n == nums.length <= 100\n0 <= nums[i] <= 50\n0 <= indexDifference <= 100\n0 <= valueDifference <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9],indexDifference = 2,valueDifference = 6) == [0, 3]\n assert candidate(nums = [0, 0, 0, 0, 0],indexDifference = 0,valueDifference = 0) == [0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50],indexDifference = 1,valueDifference = 25) == [0, 3]\n assert candidate(nums = [0, 0, 0, 0],indexDifference = 3,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [0, 0, 0, 0],indexDifference = 1,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [10, 5, 15, 20, 25],indexDifference = 2,valueDifference = 10) == [1, 3]\n assert candidate(nums = [4, 2, 3, 1, 5],indexDifference = 1,valueDifference = 2) == [0, 1]\n assert candidate(nums = [1, 3, 5, 7, 9],indexDifference = 3,valueDifference = 4) == [0, 3]\n assert candidate(nums = [45, 46, 47, 48, 49, 50],indexDifference = 2,valueDifference = 5) == [0, 5]\n assert candidate(nums = [4, 2, 3, 4, 5],indexDifference = 1,valueDifference = 2) == [0, 1]\n assert candidate(nums = [50, 40, 30, 20, 10],indexDifference = 2,valueDifference = 15) == [0, 2]\n assert candidate(nums = [1, 2, 3],indexDifference = 2,valueDifference = 4) == [-1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],indexDifference = 5,valueDifference = 5) == [0, 5]\n assert candidate(nums = [2, 1],indexDifference = 0,valueDifference = 0) == [0, 0]\n assert candidate(nums = [50, 40, 30, 20, 10],indexDifference = 2,valueDifference = 30) == [0, 3]\n assert candidate(nums = [3, 5, 7, 9, 11],indexDifference = 1,valueDifference = 2) == [0, 1]\n assert candidate(nums = [5, 5, 5, 5, 5],indexDifference = 1,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [3, 3, 3, 3, 3],indexDifference = 0,valueDifference = 0) == [0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50],indexDifference = 3,valueDifference = 15) == [0, 3]\n assert candidate(nums = [10, 20, 30, 40, 50],indexDifference = 3,valueDifference = 20) == [0, 3]\n assert candidate(nums = [10, 20, 30, 40, 50],indexDifference = 2,valueDifference = 25) == [0, 3]\n assert candidate(nums = [50, 40, 30, 20, 10],indexDifference = 2,valueDifference = 25) == [0, 3]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],indexDifference = 3,valueDifference = 6) == [0, 3]\n assert candidate(nums = [5, 1, 4, 1],indexDifference = 2,valueDifference = 4) == [0, 3]\n assert candidate(nums = [9, 7, 5, 3, 1],indexDifference = 2,valueDifference = 6) == [0, 3]\n assert candidate(nums = [8, 8, 8, 8, 8, 8],indexDifference = 0,valueDifference = 0) == [0, 0]\n assert candidate(nums = [9, 7, 5, 3, 1],indexDifference = 3,valueDifference = 4) == [0, 3]\n assert candidate(nums = [4, 2, 3, 4, 1],indexDifference = 1,valueDifference = 2) == [0, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 5,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],indexDifference = 15,valueDifference = 50) == [0, 15]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 4,valueDifference = 45) == [0, 5]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],indexDifference = 3,valueDifference = 5) == [0, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],indexDifference = 7,valueDifference = 40) == [0, 7]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],indexDifference = 3,valueDifference = 6) == [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],indexDifference = 10,valueDifference = 10) == [0, 10]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],indexDifference = 1,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],indexDifference = 5,valueDifference = 15) == [0, 5]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10],indexDifference = 2,valueDifference = 4) == [2, 4]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],indexDifference = 4,valueDifference = 30) == [0, 4]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11],indexDifference = 5,valueDifference = 10) == [0, 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],indexDifference = 2,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],indexDifference = 5,valueDifference = 5) == [0, 5]\n assert candidate(nums = [10, 10, 10, 10, 20, 20, 20, 20, 30, 30, 30, 30, 40, 40],indexDifference = 2,valueDifference = 10) == [0, 4]\n assert candidate(nums = [100, 50, 100, 50, 100, 50, 100, 50, 100],indexDifference = 2,valueDifference = 40) == [0, 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],indexDifference = 5,valueDifference = 10) == [0, 10]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],indexDifference = 5,valueDifference = 10) == [-1, -1]\n assert candidate(nums = [9, 7, 5, 3, 1, 3, 5, 7, 9, 11],indexDifference = 6,valueDifference = 6) == [3, 9]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],indexDifference = 2,valueDifference = 35) == [0, 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],indexDifference = 10,valueDifference = 5) == [0, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],indexDifference = 2,valueDifference = 2) == [0, 2]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],indexDifference = 2,valueDifference = 30) == [0, 3]\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10, 0],indexDifference = 5,valueDifference = 55) == [0, 6]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],indexDifference = 0,valueDifference = 0) == [0, 0]\n assert candidate(nums = [0, 10, 20, 30, 40, 50, 40, 30, 20, 10, 0],indexDifference = 3,valueDifference = 20) == [0, 3]\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25, -30, -35, -40, -45],indexDifference = 4,valueDifference = 20) == [0, 4]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],indexDifference = 1,valueDifference = 8) == [0, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 7,valueDifference = 40) == [0, 7]\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, 0],indexDifference = 12,valueDifference = 10) == [0, 12]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 4,valueDifference = 50) == [0, 5]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],indexDifference = 5,valueDifference = 20) == [0, 5]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],indexDifference = 5,valueDifference = 45) == [0, 5]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],indexDifference = 6,valueDifference = 40) == [0, 6]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 9,valueDifference = 1) == [0, 9]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],indexDifference = 3,valueDifference = 25) == [0, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],indexDifference = 6,valueDifference = 7) == [0, 7]\n assert candidate(nums = [50, 25, 0, 25, 50, 75, 100, 125, 150],indexDifference = 3,valueDifference = 50) == [2, 5]\n assert candidate(nums = [0, 50, 0, 50, 0, 50, 0, 50, 0, 50],indexDifference = 1,valueDifference = 50) == [0, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],indexDifference = 6,valueDifference = 50) == [0, 6]\n assert candidate(nums = [50, 25, 0, 25, 50, 25, 0, 25, 50, 25, 0],indexDifference = 5,valueDifference = 30) == [0, 6]\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],indexDifference = 3,valueDifference = 27) == [0, 3]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 4,valueDifference = 45) == [0, 5]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],indexDifference = 3,valueDifference = 60) == [0, 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],indexDifference = 1,valueDifference = 0) == [0, 1]\n assert candidate(nums = [30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100],indexDifference = 2,valueDifference = 25) == [0, 3]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],indexDifference = 6,valueDifference = 300) == [0, 6]\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],indexDifference = 4,valueDifference = 25) == [0, 4]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],indexDifference = 2,valueDifference = 8) == [0, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],indexDifference = 8,valueDifference = 7) == [0, 8]\n assert candidate(nums = [42, 23, 34, 12, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56],indexDifference = 8,valueDifference = 30) == [1, 9]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],indexDifference = 1,valueDifference = 1) == [0, 2]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],indexDifference = 6,valueDifference = 4) == [0, 6]\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],indexDifference = 15,valueDifference = 30) == [0, 15]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],indexDifference = 8,valueDifference = 15) == [0, 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, 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],indexDifference = 15,valueDifference = 15) == [0, 15]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],indexDifference = 8,valueDifference = 30) == [0, 8]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 1,valueDifference = 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],indexDifference = 10,valueDifference = 15) == [0, 15]\n assert candidate(nums = [30, 20, 10, 0, 10, 20, 30, 40, 50, 60],indexDifference = 3,valueDifference = 20) == [0, 3]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49],indexDifference = 7,valueDifference = 20) == [0, 7]\n assert candidate(nums = [8, 6, 4, 2, 0, 2, 4, 6, 8, 10],indexDifference = 4,valueDifference = 6) == [0, 4]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],indexDifference = 4,valueDifference = 20) == [0, 4]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10],indexDifference = 3,valueDifference = 9) == [0, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],indexDifference = 8,valueDifference = 3) == [0, 8]\n assert candidate(nums = [30, 20, 10, 0, 10, 20, 30, 40, 50, 60],indexDifference = 5,valueDifference = 25) == [2, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 2,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],indexDifference = 7,valueDifference = 16) == [0, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],indexDifference = 9,valueDifference = 9) == [0, 9]\n assert candidate(nums = [45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50],indexDifference = 3,valueDifference = 15) == [0, 3]\n assert candidate(nums = [50, 25, 0, 25, 50, 75, 100, 125, 150, 175],indexDifference = 6,valueDifference = 75) == [1, 7]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],indexDifference = 6,valueDifference = 10) == [-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, 21, 22, 23, 24, 25],indexDifference = 15,valueDifference = 15) == [0, 15]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],indexDifference = 4,valueDifference = 8) == [0, 4]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50],indexDifference = 3,valueDifference = 20) == [0, 3]\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5],indexDifference = 4,valueDifference = 25) == [0, 4]\n assert candidate(nums = [42, 24, 35, 16, 27, 38, 49, 10, 21, 32],indexDifference = 5,valueDifference = 15) == [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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],indexDifference = 10,valueDifference = 10) == [0, 10]\n assert candidate(nums = [45, 35, 25, 15, 5, 0, 5, 15, 25, 35, 45],indexDifference = 6,valueDifference = 20) == [0, 6]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40],indexDifference = 3,valueDifference = 25) == [0, 3]\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5],indexDifference = 3,valueDifference = 2) == [0, 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],indexDifference = 10,valueDifference = 10) == [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],indexDifference = 7,valueDifference = 10) == [0, 10]\n assert candidate(nums = [42, 24, 12, 36, 21, 6, 48, 30, 18, 9, 54, 33, 15, 27, 63, 45, 22, 11, 44, 39],indexDifference = 7,valueDifference = 30) == [0, 9]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],indexDifference = 9,valueDifference = 45) == [0, 9]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],indexDifference = 2,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 2,valueDifference = 0) == [0, 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],indexDifference = 8,valueDifference = 10) == [0, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 8,valueDifference = 30) == [0, 8]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],indexDifference = 10,valueDifference = 5) == [0, 10]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],indexDifference = 5,valueDifference = 999999999) == [0, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],indexDifference = 5,valueDifference = 10) == [0, 5]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],indexDifference = 5,valueDifference = 200) == [0, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 9,valueDifference = 80) == [0, 9]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],indexDifference = 7,valueDifference = 50) == [0, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 30,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [42, 23, 34, 56, 78, 89, 90, 87, 65, 43, 21, 2],indexDifference = 6,valueDifference = 45) == [0, 6]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 4,valueDifference = 30) == [0, 4]\n assert candidate(nums = [30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 7,valueDifference = 25) == [1, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],indexDifference = 2,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50],indexDifference = 5,valueDifference = 30) == [0, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 2,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],indexDifference = 3,valueDifference = 3) == [0, 3]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],indexDifference = 6,valueDifference = 50) == [0, 6]\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],indexDifference = 5,valueDifference = 5) == [0, 5]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],indexDifference = 7,valueDifference = 90) == [0, 7]\n assert candidate(nums = [45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33],indexDifference = 6,valueDifference = 5) == [0, 6]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6],indexDifference = 3,valueDifference = 5) == [0, 5]\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4],indexDifference = 3,valueDifference = 1) == [0, 3]\n"}, "metadata": {"canonical_parameter_names": ["nums", "indexDifference", "valueDifference"], "leetcode_dataset_entry_point": "Solution().findIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] findIndices(int[] nums, int indexDifference, int valueDifference) {", "container": "Solution", "callable": "findIndices", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "indexDifference", "type": "int"}, {"name": "valueDifference", "type": "int"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2904, "task_id": "shortest-and-lexicographically-smallest-beautiful-string", "difficulty": "Medium", "problem_description": "You are given a binary string s and a positive integer k.\nA substring of s is beautiful if the number of 1's in it is exactly k.\nLet len be the length of the shortest beautiful substring.\nReturn the lexicographically smallest beautiful substring of string s with length equal to len. If s doesn't contain a beautiful substring, return an empty string.\nA string a is lexicographically larger than a string b (of the same length) if in the first position where a and b differ, a has a character strictly larger than the corresponding character in b.\n\nFor example, \"abcd\" is lexicographically larger than \"abcc\" because the first position they differ is at the fourth character, and d is greater than c.\n\n \nExample 1:\n\nInput: s = \"100011001\", k = 3\nOutput: \"11001\"\nExplanation: There are 7 beautiful substrings in this example:\n1. The substring \"100011001\".\n2. The substring \"100011001\".\n3. The substring \"100011001\".\n4. The substring \"100011001\".\n5. The substring \"100011001\".\n6. The substring \"100011001\".\n7. The substring \"100011001\".\nThe length of the shortest beautiful substring is 5.\nThe lexicographically smallest beautiful substring with length 5 is the substring \"11001\".\n\nExample 2:\n\nInput: s = \"1011\", k = 2\nOutput: \"11\"\nExplanation: There are 3 beautiful substrings in this example:\n1. The substring \"1011\".\n2. The substring \"1011\".\n3. The substring \"1011\".\nThe length of the shortest beautiful substring is 2.\nThe lexicographically smallest beautiful substring with length 2 is the substring \"11\".\n\nExample 3:\n\nInput: s = \"000\", k = 1\nOutput: \"\"\nExplanation: There are no beautiful substrings in this example.\n\n \nConstraints:\n\n1 <= s.length <= 100\n1 <= k <= s.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1100110011001100110011001100\",k = 6) == \"1100110011\"\n assert candidate(s = \"100011001\",k = 3) == \"11001\"\n assert candidate(s = \"1010101010\",k = 5) == \"101010101\"\n assert candidate(s = \"1111111111\",k = 5) == \"11111\"\n assert candidate(s = \"100100100\",k = 3) == \"1001001\"\n assert candidate(s = \"000\",k = 1) == \"\"\n assert candidate(s = \"111010101\",k = 2) == \"11\"\n assert candidate(s = \"0000000000\",k = 1) == \"\"\n assert candidate(s = \"111000\",k = 2) == \"11\"\n assert candidate(s = \"1001001001\",k = 4) == \"1001001001\"\n assert candidate(s = \"1111\",k = 2) == \"11\"\n assert candidate(s = \"0101010101010101010101010101\",k = 5) == \"101010101\"\n assert candidate(s = \"11001100110011001100\",k = 5) == \"100110011\"\n assert candidate(s = \"010101\",k = 3) == \"10101\"\n assert candidate(s = \"1010101\",k = 4) == \"1010101\"\n assert candidate(s = \"1011\",k = 2) == \"11\"\n assert candidate(s = \"10101010101010101010\",k = 10) == \"1010101010101010101\"\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\",k = 12) == \"10101010101010101010101\"\n assert candidate(s = \"101010101010101010101010101010101010101010101010\",k = 10) == \"1010101010101010101\"\n assert candidate(s = \"000000000000000000000000000000\",k = 1) == \"\"\n assert candidate(s = \"110110110110110110110110110110\",k = 5) == \"1011011\"\n assert candidate(s = \"00000000000000000000000000000000\",k = 5) == \"\"\n assert candidate(s = \"1001001001001001001001001001001\",k = 5) == \"1001001001001\"\n assert candidate(s = \"1010101010101010101010101010101010101010\",k = 10) == \"1010101010101010101\"\n assert candidate(s = \"00000000000000000000000000000000\",k = 1) == \"\"\n assert candidate(s = \"1111000011110000111100001111000011110000111100001111000011110000\",k = 8) == \"111100001111\"\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111111111111111\",k = 15) == \"111111111111111\"\n assert candidate(s = \"01001001001001001001001001001001001001001001001001001001001001001001\",k = 8) == \"1001001001001001001001\"\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101\",k = 12) == \"10101010101010101010101\"\n assert candidate(s = \"111000111000111000\",k = 3) == \"111\"\n assert candidate(s = \"1100011000110001100011000110001100011000\",k = 6) == \"110001100011\"\n assert candidate(s = \"101010101010101010101010101010101010101010101010\",k = 9) == \"10101010101010101\"\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111\",k = 50) == \"11111111111111111111111111111111111111111111111111\"\n assert candidate(s = \"010101010101010101010101010101010101010101010101\",k = 5) == \"101010101\"\n assert candidate(s = \"10101010101010101010101010101010\",k = 10) == \"1010101010101010101\"\n assert candidate(s = \"111111111111111111111111111111\",k = 10) == \"1111111111\"\n assert candidate(s = \"111000111000111000111000111000111000111000111000\",k = 9) == \"111000111000111\"\n assert candidate(s = \"010101010101010101010101010101010101010101010101\",k = 8) == \"101010101010101\"\n assert candidate(s = \"01010101010101010101010101010101010101010101\",k = 10) == \"1010101010101010101\"\n assert candidate(s = \"1001100110011001100110011001100110011001100110011001100110011001100110011001\",k = 6) == \"1100110011\"\n assert candidate(s = \"0101010101010101010101010101\",k = 3) == \"10101\"\n assert candidate(s = \"111000111000111000111000111000111000111\",k = 6) == \"111000111\"\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\",k = 10) == \"1010101010101010101\"\n assert candidate(s = \"111000111000111000111000111000111000111000\",k = 11) == \"11000111000111000111\"\n assert candidate(s = \"1101001101001101001101001101\",k = 4) == \"1001101\"\n assert candidate(s = \"111011101110111011101110\",k = 7) == \"101110111\"\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\",k = 3) == \"\"\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000000000000000000000000000\",k = 1) == \"\"\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100\",k = 15) == \"10011001100110011001100110011\"\n assert candidate(s = \"00000000000000000000\",k = 1) == \"\"\n assert candidate(s = \"000000000000000000000000000000000000000000000001\",k = 1) == \"1\"\n assert candidate(s = \"0001000100010001000100010001000100010001000100010001\",k = 3) == \"100010001\"\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\",k = 7) == \"1010101010101\"\n assert candidate(s = \"000000000000000000000000000000000000000000000000\",k = 3) == \"\"\n assert candidate(s = \"1110011100011100111000011100000111000000\",k = 6) == \"11100111\"\n assert candidate(s = \"1110000001110000011100000111000001110000011100000111\",k = 6) == \"11100000111\"\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100\",k = 11) == \"100110011001100110011\"\n assert candidate(s = \"0000000000000000000000000000000000000000\",k = 1) == \"\"\n assert candidate(s = \"110011001100110011001100110011001100\",k = 6) == \"1100110011\"\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010\",k = 13) == \"1010101010101010101010101\"\n assert candidate(s = \"111000111000111000111000111000111000111000\",k = 6) == \"111000111\"\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",k = 15) == \"10101010101010101010101010101\"\n assert candidate(s = \"0101010101010101010101010101010101010101\",k = 15) == \"10101010101010101010101010101\"\n assert candidate(s = \"10001000100010001000100010001000100010001000\",k = 5) == \"10001000100010001\"\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101\",k = 15) == \"10101010101010101010101010101\"\n assert candidate(s = \"110001100011000110001100011000110001100011000\",k = 5) == \"10001100011\"\n assert candidate(s = \"11000110001100011000110001100011000\",k = 6) == \"110001100011\"\n assert candidate(s = \"010101010101010101010101010101010101010101\",k = 10) == \"1010101010101010101\"\n assert candidate(s = \"01010101010101010101010101010101\",k = 5) == \"101010101\"\n assert candidate(s = \"101010101010101010101010101010101010\",k = 10) == \"1010101010101010101\"\n assert candidate(s = \"0101010101010101010101010101010101010101\",k = 5) == \"101010101\"\n assert candidate(s = \"111000111000111000111000111\",k = 6) == \"111000111\"\n assert candidate(s = \"111110000000000000000000000000000000000000000000\",k = 5) == \"11111\"\n assert candidate(s = \"1101101101101101101101101101101101101101\",k = 7) == \"1011011011\"\n assert candidate(s = \"11100111001110011100111001110011100111001110011100\",k = 8) == \"110011100111\"\n assert candidate(s = \"10000001000000100000010000001\",k = 3) == \"100000010000001\"\n assert candidate(s = \"11110000111100001111000011110000\",k = 4) == \"1111\"\n assert candidate(s = \"0010010010010010010010010010010010010010\",k = 2) == \"1001\"\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",k = 20) == \"101010101010101010101010101010101010101\"\n assert candidate(s = \"101010101010101010101010101010101010101010101010\",k = 8) == \"101010101010101\"\n assert candidate(s = \"111110000011111000001111100000111110000011111\",k = 8) == \"1110000011111\"\n assert candidate(s = \"1010101010101010101010101010101010101010\",k = 15) == \"10101010101010101010101010101\"\n assert candidate(s = \"111000111000111000111000\",k = 9) == \"111000111000111\"\n assert candidate(s = \"1000001000001000001000001000001000001000001000001000001000001\",k = 2) == \"1000001\"\n assert candidate(s = \"1000000000000000000000000000000000000001\",k = 1) == \"1\"\n assert candidate(s = \"1110000111000011100001110000\",k = 4) == \"10000111\"\n assert candidate(s = \"10101010101010101010101010101010101010101010\",k = 7) == \"1010101010101\"\n assert candidate(s = \"000100010001000100010001\",k = 2) == \"10001\"\n assert candidate(s = \"1000100010001000100010001\",k = 3) == \"100010001\"\n assert candidate(s = \"1001001001001001001001001001001001001001001001\",k = 5) == \"1001001001001\"\n assert candidate(s = \"0000000000000000000000000000000000000000000000000001\",k = 1) == \"1\"\n assert candidate(s = \"11111000001111100000111110000011111\",k = 5) == \"11111\"\n assert candidate(s = \"0110110110110110110110110110110110110110110110\",k = 4) == \"11011\"\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000\",k = 1) == \"\"\n assert candidate(s = \"11000001110000011100000111000001110000011100000111\",k = 7) == \"10000011100000111\"\n assert candidate(s = \"001001001001001001001001001001001001001\",k = 3) == \"1001001\"\n assert candidate(s = \"11111111111111111111111111111111\",k = 15) == \"111111111111111\"\n assert candidate(s = \"1010101010101010101010101010101010101010101010\",k = 8) == \"101010101010101\"\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000\",k = 1) == \"\"\n assert candidate(s = \"111111111111111111111111111111111111111111111111\",k = 9) == \"111111111\"\n assert candidate(s = \"010101010101010101010101010101010101\",k = 10) == \"1010101010101010101\"\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100\",k = 10) == \"110011001100110011\"\n assert candidate(s = \"100000100000100000100000100000100000100000100000\",k = 3) == \"1000001000001\"\n assert candidate(s = \"100110011001100110011001100110011001100110011001100110011001100110011001\",k = 9) == \"10011001100110011\"\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000111000111000111000111000\",k = 7) == \"1000111000111\"\n assert candidate(s = \"10101010101010101010\",k = 7) == \"1010101010101\"\n assert candidate(s = \"1111000011110000111100001111\",k = 8) == \"111100001111\"\n assert candidate(s = \"1010101010101010101010101010101010101010\",k = 12) == \"10101010101010101010101\"\n assert candidate(s = \"01010101010101010101\",k = 3) == \"10101\"\n assert candidate(s = \"001001001001001001001001001001001001001001001001\",k = 5) == \"1001001001001\"\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001\",k = 12) == \"1001001001001001001001001001001001\"\n assert candidate(s = \"000000000011111111111111111111111111111111111111111111111111111111111111\",k = 20) == \"11111111111111111111\"\n assert candidate(s = \"110110110110110110110110110110110110110\",k = 7) == \"1011011011\"\n assert candidate(s = \"10101010101010101010\",k = 6) == \"10101010101\"\n assert candidate(s = \"01001001001001001001001001001001001001001001001001001001001001001001001001001001\",k = 4) == \"1001001001\"\n assert candidate(s = \"1001001001001001001001001001001001001001\",k = 12) == \"1001001001001001001001001001001001\"\n assert candidate(s = \"00000000000000000000000000000000000000000000\",k = 1) == \"\"\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 9) == \"10101010101010101\"\n assert candidate(s = \"010101010101010101010101010101\",k = 5) == \"101010101\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().shortestBeautifulSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public String shortestBeautifulSubstring(String s, int k) {", "container": "Solution", "callable": "shortestBeautifulSubstring", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2905, "task_id": "find-indices-with-index-and-value-difference-ii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference.\nYour task is to find two indices i and j, both in the range [0, n - 1], that satisfy the following conditions:\n\nabs(i - j) >= indexDifference, and\nabs(nums[i] - nums[j]) >= valueDifference\n\nReturn an integer array answer, where answer = [i, j] if there are two such indices, and answer = [-1, -1] otherwise. If there are multiple choices for the two indices, return any of them.\nNote: i and j may be equal.\n \nExample 1:\n\nInput: nums = [5,1,4,1], indexDifference = 2, valueDifference = 4\nOutput: [0,3]\nExplanation: In this example, i = 0 and j = 3 can be selected.\nabs(0 - 3) >= 2 and abs(nums[0] - nums[3]) >= 4.\nHence, a valid answer is [0,3].\n[3,0] is also a valid answer.\n\nExample 2:\n\nInput: nums = [2,1], indexDifference = 0, valueDifference = 0\nOutput: [0,0]\nExplanation: In this example, i = 0 and j = 0 can be selected.\nabs(0 - 0) >= 0 and abs(nums[0] - nums[0]) >= 0.\nHence, a valid answer is [0,0].\nOther valid answers are [0,1], [1,0], and [1,1].\n\nExample 3:\n\nInput: nums = [1,2,3], indexDifference = 2, valueDifference = 4\nOutput: [-1,-1]\nExplanation: In this example, it can be shown that it is impossible to find two indices that satisfy both conditions.\nHence, [-1,-1] is returned.\n \nConstraints:\n\n1 <= n == nums.length <= 105\n0 <= nums[i] <= 109\n0 <= indexDifference <= 105\n0 <= valueDifference <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 90, 80, 70, 60],indexDifference = 2,valueDifference = 25) == [0, 3]\n assert candidate(nums = [1, 10, 1, 10, 1, 10],indexDifference = 2,valueDifference = 8) == [0, 3]\n assert candidate(nums = [100, 90, 80, 70, 60, 50],indexDifference = 4,valueDifference = 30) == [0, 4]\n assert candidate(nums = [10, 20, 30, 40, 50],indexDifference = 1,valueDifference = 15) == [0, 2]\n assert candidate(nums = [10, 20, 30, 40, 50],indexDifference = 2,valueDifference = 20) == [0, 2]\n assert candidate(nums = [1, 5, 3, 6, 7, 8, 2],indexDifference = 3,valueDifference = 4) == [0, 3]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 3,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9],indexDifference = 4,valueDifference = 8) == [0, 4]\n assert candidate(nums = [4, 5, 6, 7, 8, 9],indexDifference = 3,valueDifference = 3) == [0, 3]\n assert candidate(nums = [1, 5, 3, 6, 7, 8, 9],indexDifference = 3,valueDifference = 4) == [0, 3]\n assert candidate(nums = [4, 1, 3, 2],indexDifference = 1,valueDifference = 2) == [0, 1]\n assert candidate(nums = [1, 3, 5, 7, 9],indexDifference = 3,valueDifference = 4) == [0, 3]\n assert candidate(nums = [1, 1, 1, 1, 1, 1],indexDifference = 1,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [1, 2, 3],indexDifference = 2,valueDifference = 4) == [-1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],indexDifference = 5,valueDifference = 5) == [0, 5]\n assert candidate(nums = [2, 1],indexDifference = 0,valueDifference = 0) == [0, 0]\n assert candidate(nums = [5, 5, 5, 5],indexDifference = 1,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [9, 7, 5, 3, 1],indexDifference = 4,valueDifference = 8) == [0, 4]\n assert candidate(nums = [9, 7, 5, 3, 1],indexDifference = 3,valueDifference = 6) == [0, 3]\n assert candidate(nums = [1, 1, 1, 1, 1],indexDifference = 2,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [5, 1, 4, 1],indexDifference = 2,valueDifference = 4) == [0, 3]\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6],indexDifference = 3,valueDifference = 2) == [0, 3]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],indexDifference = 7,valueDifference = 50) == [0, 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],indexDifference = 10,valueDifference = 10) == [0, 10]\n assert candidate(nums = [500, 400, 300, 200, 100, 0, 100, 200, 300, 400],indexDifference = 5,valueDifference = 200) == [0, 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],indexDifference = 10,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [5, 3, 6, 8, 1, 9, 2, 7, 4, 10],indexDifference = 3,valueDifference = 5) == [1, 5]\n assert candidate(nums = [10, 50, 30, 60, 20, 70, 40, 80, 100, 90],indexDifference = 3,valueDifference = 30) == [0, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],indexDifference = 2,valueDifference = 2) == [0, 2]\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9],indexDifference = 2,valueDifference = 2) == [0, 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, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],indexDifference = 15,valueDifference = 30) == [0, 15]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],indexDifference = 6,valueDifference = 400) == [0, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],indexDifference = 8,valueDifference = 2) == [0, 8]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 0,valueDifference = 0) == [0, 0]\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500],indexDifference = 2,valueDifference = 250) == [0, 5]\n assert candidate(nums = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000],indexDifference = 5,valueDifference = 200000000) == [0, 5]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],indexDifference = 3,valueDifference = 6) == [0, 6]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],indexDifference = 3,valueDifference = 25) == [0, 3]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 6,valueDifference = 40) == [0, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],indexDifference = 6,valueDifference = 7) == [0, 7]\n assert candidate(nums = [1000000000, 0, 1000000000, 0, 1000000000, 0],indexDifference = 2,valueDifference = 1000000000) == [0, 3]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],indexDifference = 4,valueDifference = 8) == [0, 4]\n assert candidate(nums = [5, 8, 12, 15, 3, 1, 9, 11, 6, 2, 7, 10],indexDifference = 3,valueDifference = 8) == [0, 3]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],indexDifference = 4,valueDifference = 300) == [0, 4]\n assert candidate(nums = [5, 1, 9, 3, 7, 11, 2, 8, 6, 10],indexDifference = 3,valueDifference = 8) == [1, 5]\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996],indexDifference = 1,valueDifference = 1000000000) == [-1, -1]\n assert candidate(nums = [1000000000, 0, 500000000, 250000000, 750000000, 1, 999999999, 2, 999999998, 3],indexDifference = 4,valueDifference = 500000000) == [0, 5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],indexDifference = 4,valueDifference = 6) == [0, 4]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],indexDifference = 3,valueDifference = 8) == [0, 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],indexDifference = 9,valueDifference = 8) == [0, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],indexDifference = 3,valueDifference = 10) == [0, 5]\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],indexDifference = 3,valueDifference = 6) == [0, 3]\n assert candidate(nums = [10, 100, 10, 100, 10, 100, 10, 100, 10, 100],indexDifference = 5,valueDifference = 80) == [0, 5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],indexDifference = 6,valueDifference = 8) == [0, 6]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],indexDifference = 4,valueDifference = 20) == [0, 4]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],indexDifference = 6,valueDifference = 70) == [0, 7]\n assert candidate(nums = [100, 50, 150, 100, 50, 150, 100, 50, 150, 100],indexDifference = 5,valueDifference = 50) == [0, 5]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],indexDifference = 6,valueDifference = 5) == [0, 6]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],indexDifference = 4,valueDifference = 5) == [0, 5]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],indexDifference = 4,valueDifference = 30) == [0, 4]\n assert candidate(nums = [1000000000, 500000000, 1500000000, 2000000000, 0],indexDifference = 1,valueDifference = 500000000) == [0, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],indexDifference = 7,valueDifference = 300) == [0, 7]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],indexDifference = 8,valueDifference = 7) == [0, 8]\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 0],indexDifference = 2,valueDifference = 4) == [0, 2]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],indexDifference = 2,valueDifference = 2) == [0, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 1,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 2,valueDifference = 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],indexDifference = 10,valueDifference = 10) == [0, 10]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],indexDifference = 3,valueDifference = 400) == [0, 4]\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],indexDifference = 4,valueDifference = 8) == [0, 5]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],indexDifference = 7,valueDifference = 6) == [0, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],indexDifference = 1,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],indexDifference = 8,valueDifference = 12) == [0, 8]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],indexDifference = 2,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 0,valueDifference = 90) == [0, 9]\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],indexDifference = 5,valueDifference = 45) == [0, 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, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],indexDifference = 12,valueDifference = 20) == [0, 12]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],indexDifference = 4,valueDifference = 4) == [0, 4]\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996],indexDifference = 1,valueDifference = 999999990) == [0, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],indexDifference = 2,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5],indexDifference = 5,valueDifference = 18) == [1, 6]\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3],indexDifference = 2,valueDifference = 1) == [0, 3]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],indexDifference = 10,valueDifference = 50) == [0, 10]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],indexDifference = 5,valueDifference = 10) == [0, 5]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],indexDifference = 5,valueDifference = 1000) == [0, 10]\n assert candidate(nums = [100, 200, 101, 201, 102, 202, 103, 203, 104, 204, 105, 205, 106, 206, 107, 207, 108, 208, 109, 209],indexDifference = 3,valueDifference = 100) == [0, 3]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],indexDifference = 3,valueDifference = 45) == [0, 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],indexDifference = 10,valueDifference = 10) == [0, 10]\n assert candidate(nums = [10, 20, 30, 25, 15, 5, 10, 15, 20, 25],indexDifference = 4,valueDifference = 15) == [1, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 5,valueDifference = 40) == [0, 5]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],indexDifference = 5,valueDifference = 10) == [-1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],indexDifference = 7,valueDifference = 6) == [0, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 8,valueDifference = 30) == [0, 8]\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500],indexDifference = 4,valueDifference = 150) == [0, 4]\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],indexDifference = 10,valueDifference = 25) == [0, 10]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993],indexDifference = 4,valueDifference = 5) == [0, 5]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],indexDifference = 5,valueDifference = 25) == [0, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],indexDifference = 10,valueDifference = 0) == [-1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],indexDifference = 3,valueDifference = 6) == [0, 6]\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9],indexDifference = 2,valueDifference = 3) == [0, 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],indexDifference = 7,valueDifference = 30) == [0, 7]\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],indexDifference = 2,valueDifference = 9) == [0, 3]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],indexDifference = 1,valueDifference = 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],indexDifference = 10,valueDifference = 0) == [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],indexDifference = 7,valueDifference = 7) == [0, 7]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],indexDifference = 2,valueDifference = 5) == [0, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],indexDifference = 7,valueDifference = 5) == [0, 7]\n assert candidate(nums = [8, 6, 4, 2, 0, 1, 3, 5, 7, 9],indexDifference = 2,valueDifference = 4) == [0, 2]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],indexDifference = 7,valueDifference = 200) == [0, 7]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],indexDifference = 5,valueDifference = 10) == [0, 5]\n assert candidate(nums = [3, 1, 2, 4, 6, 5, 9, 8, 7, 10],indexDifference = 5,valueDifference = 5) == [1, 6]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],indexDifference = 5,valueDifference = 300) == [0, 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],indexDifference = 12,valueDifference = 12) == [0, 12]\n assert candidate(nums = [9, 3, 7, 1, 8, 5, 6, 2, 4, 10],indexDifference = 4,valueDifference = 7) == [0, 7]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],indexDifference = 5,valueDifference = 4) == [0, 5]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],indexDifference = 5,valueDifference = 25) == [0, 5]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12],indexDifference = 3,valueDifference = 4) == [0, 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],indexDifference = 5,valueDifference = 1) == [-1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],indexDifference = 6,valueDifference = 6) == [0, 6]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],indexDifference = 4,valueDifference = 5) == [0, 5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],indexDifference = 6,valueDifference = 10) == [0, 6]\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],indexDifference = 5,valueDifference = 27) == [0, 5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],indexDifference = 3,valueDifference = 6) == [0, 3]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],indexDifference = 5,valueDifference = 10) == [0, 5]\n assert candidate(nums = [8, 6, 4, 2, 0, 1, 3, 5, 7, 9],indexDifference = 3,valueDifference = 3) == [0, 3]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],indexDifference = 2,valueDifference = 3) == [0, 3]\n"}, "metadata": {"canonical_parameter_names": ["nums", "indexDifference", "valueDifference"], "leetcode_dataset_entry_point": "Solution().findIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] findIndices(int[] nums, int indexDifference, int valueDifference) {", "container": "Solution", "callable": "findIndices", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "indexDifference", "type": "int"}, {"name": "valueDifference", "type": "int"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2906, "task_id": "construct-product-matrix", "difficulty": "Medium", "problem_description": "Given a 0-indexed 2D integer matrix grid of size n * m, we define a 0-indexed 2D matrix p of size n * m as the product matrix of grid if the following condition is met:\n\nEach element p[i][j] is calculated as the product of all elements in grid except for the element grid[i][j]. This product is then taken modulo 12345.\n\nReturn the product matrix of grid.\n \nExample 1:\n\nInput: grid = [[1,2],[3,4]]\nOutput: [[24,12],[8,6]]\nExplanation: p[0][0] = grid[0][1] * grid[1][0] * grid[1][1] = 2 * 3 * 4 = 24\np[0][1] = grid[0][0] * grid[1][0] * grid[1][1] = 1 * 3 * 4 = 12\np[1][0] = grid[0][0] * grid[0][1] * grid[1][1] = 1 * 2 * 4 = 8\np[1][1] = grid[0][0] * grid[0][1] * grid[1][0] = 1 * 2 * 3 = 6\nSo the answer is [[24,12],[8,6]].\nExample 2:\n\nInput: grid = [[12345],[2],[1]]\nOutput: [[2],[0],[0]]\nExplanation: p[0][0] = grid[0][1] * grid[0][2] = 2 * 1 = 2.\np[0][1] = grid[0][0] * grid[0][2] = 12345 * 1 = 12345. 12345 % 12345 = 0. So p[0][1] = 0.\np[0][2] = grid[0][0] * grid[0][1] = 12345 * 2 = 24690. 24690 % 12345 = 0. So p[0][2] = 0.\nSo the answer is [[2],[0],[0]].\n \nConstraints:\n\n1 <= n == grid.length <= 105\n1 <= m == grid[i].length <= 105\n2 <= n * m <= 105\n1 <= grid[i][j] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(grid = [[7], [11], [13]]) == [[143], [91], [77]]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]]) == [[720, 360, 240], [180, 144, 120]]\n assert candidate(grid = [[12345], [2], [1]]) == [[2], [0], [0]]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1]]) == [[1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(grid = [[5, 10, 15], [20, 25, 30]]) == [[3210, 1605, 9300], [6975, 5580, 4650]]\n assert candidate(grid = [[5, 6, 7], [8, 9, 10]]) == [[5550, 510, 9255], [6555, 4455, 2775]]\n assert candidate(grid = [[1, 2], [3, 4]]) == [[24, 12], [8, 6]]\n assert candidate(grid = [[5, 10], [15, 20]]) == [[3000, 1500], [1000, 750]]\n assert candidate(grid = [[999999999, 888888888], [777777777, 666666666]]) == [[12126, 4383], [1482, 5844]]\n assert candidate(grid = [[1000000000, 999999999], [888888888, 777777777]]) == [[5844, 7785], [7215, 2955]]\n assert candidate(grid = [[5, 3], [2, 4]]) == [[24, 40], [60, 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, 1, 1, 1]]\n assert candidate(grid = [[2, 3], [4, 5], [6, 7]]) == [[2520, 1680], [1260, 1008], [840, 720]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == [[11715, 12030, 12135, 6015, 9750, 12240, 12255, 9180, 8160, 4875]]\n assert candidate(grid = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]\n assert candidate(grid = [[1, 0, 1], [1, 1, 1], [1, 1, 1]]) == [[0, 1, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[1000000007, 1000000008, 1000000009], [1000000010, 1000000011, 1000000012]]) == [[11625, 8835, 7125], [9573, 6285, 11310]]\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]]\n assert candidate(grid = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [[11715], [12030], [12135], [6015], [9750], [12240], [12255], [9180], [8160], [4875]]\n assert candidate(grid = [[1000000000, 1], [1, 1000000000]]) == [[5620, 5890], [5890, 5620]]\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == [[11505, 11925, 7950], [12135, 4770, 3975], [12225, 12240, 6765]]\n assert candidate(grid = [[12345, 12345, 12345], [12345, 12345, 12345], [12345, 12345, 12345]]) == [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[12345, 24690, 37035], [49380, 61725, 74070]]) == [[0, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[12344, 12343, 12342], [12341, 12340, 12339], [12338, 12337, 12336]]) == [[4875, 8610, 9855], [4305, 10851, 11100], [2460, 8325, 3285]]\n assert candidate(grid = [[1000000000, 2000000000, 3000000000], [4000000000, 5000000000, 6000000000]]) == [[6585, 9465, 10425], [10905, 6255, 11385]]\n assert candidate(grid = [[2, 3, 5, 7], [11, 13, 17, 19], [23, 29, 31, 37]]) == [[780, 520, 312, 3750], [9120, 120, 5175, 5280], [3825, 3885, 1245, 3045]]\n assert candidate(grid = [[12345, 67890, 54321], [10101, 20202, 30303], [40404, 50505, 60606]]) == [[10875, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[12345], [24690], [37035], [49380], [61665]]) == [[0], [0], [0], [0], [0]]\n assert candidate(grid = [[12345, 12346, 12347], [12348, 12349, 12350], [12351, 12352, 12353]]) == [[3285, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[2, 3], [5, 7], [11, 13], [17, 19], [23, 29], [31, 37]]) == [[780, 520], [312, 3750], [9120, 120], [5175, 5280], [3825, 3885], [1245, 3045]]\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]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [[10740, 5370, 7695, 2685, 9555, 10020, 6825, 7515, 2565, 10950], [7710, 5010, 3675, 9585, 11415, 9930, 5715, 7455, 1215, 5475]]\n assert candidate(grid = [[1000000, 2000000, 3000000], [4000000, 5000000, 6000000]]) == [[2145, 7245, 4830], [9795, 10305, 2415]]\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]]\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]]) == [[8280, 4140], [2760, 2070], [4125, 1380], [4710, 1035], [9150, 8235], [1875, 690], [5385, 2355], [5490, 6690], [8475, 4575], [2385, 10290], [5685, 7110], [360, 345], [825, 8865], [11280, 7350], [9225, 2745], [1860, 3345], [4740, 10410], [5880, 8460], [8565, 7365], [5910, 5145], [6525, 9015], [10815, 3555], [1830, 180], [6480, 6345], [4200, 6585]]\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]]) == [[8850, 4425, 7065, 8385, 1770, 9705, 6555, 10365, 2355, 885], [10905, 11025, 2580, 9450, 8820, 11355, 6330, 7350, 2415, 6615], [6300, 11625, 1995, 11685, 10230, 1290, 9015, 4725, 3285, 4410]]\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]]) == [[6570, 3285, 2190, 7815, 11190], [1095, 11520, 10080, 4845, 5595], [11820, 6720, 1455, 5760, 7845], [5040, 2565, 8595, 2295, 8970], [3840, 5910, 7800, 3360, 9645]]\n assert candidate(grid = [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60]]) == [[4860, 2430, 1620], [1215, 5910, 810], [5985, 6780, 540], [2955, 9420, 405]]\n assert candidate(grid = [[100000, 200000, 300000], [400000, 500000, 600000], [700000, 800000, 900000]]) == [[765, 6555, 255], [9450, 7560, 6300], [5400, 4725, 4200]]\n assert candidate(grid = [[1000000000, 999999999], [888888888, 777777777]]) == [[5844, 7785], [7215, 2955]]\n assert candidate(grid = [[987654321, 876543210, 765432109], [654321098, 543210987, 432109876]]) == [[480, 7659, 5820], [5835, 3135, 12270]]\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]]) == [[8850, 4425, 7065], [8385, 1770, 9705], [6555, 10365, 2355], [885, 10905, 11025], [2580, 9450, 8820], [11355, 6330, 7350], [2415, 6615, 6300], [11625, 1995, 11685], [10230, 1290, 9015], [4725, 3285, 4410]]\n assert candidate(grid = [[1000, 2000, 3000], [4000, 5000, 6000], [7000, 8000, 9000], [10000, 11000, 12000]]) == [[4305, 8325, 5550], [10335, 3330, 2775], [615, 11340, 10080], [1665, 7125, 7560]]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == [[3255, 7800, 9315], [3900, 3120, 10830], [465, 1950, 3105], [1560, 4785, 5415]]\n assert candidate(grid = [[12345, 24690, 37035], [49380, 61725, 74070], [86415, 98760, 111105]]) == [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[12345, 6789, 11111], [22222, 33333, 44444], [55555, 66666, 77777]]) == [[9615, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[123, 456, 789], [101112, 131415, 161718], [192021, 222324, 252627]]) == [[3705, 8715, 8745], [4335, 3591, 4815], [8760, 10170, 8745]]\n assert candidate(grid = [[50000, 50001, 50002], [50003, 50004, 50005], [50006, 50007, 50008], [50009, 50010, 50011], [50012, 50013, 50014]]) == [[3615, 1005, 9240], [9780, 6045, 5265], [7485, 4185, 7815], [3210, 6105, 8130], [8625, 9645, 225]]\n assert candidate(grid = [[99999, 88888], [77777, 66666], [55555, 44444]]) == [[210, 9495], [270, 315], [5316, 6645]]\n assert candidate(grid = [[1000000000, 999999999, 999999998], [999999997, 999999996, 999999995], [999999994, 999999993, 999999992]]) == [[7200, 11670, 6495], [7050, 6150, 4755], [7410, 9195, 4245]]\n assert candidate(grid = [[1000000000, 1000000000], [1000000000, 1000000000]]) == [[4855, 4855], [4855, 4855]]\n assert candidate(grid = [[2, 3, 5], [7, 11, 13], [17, 19, 23], [29, 31, 37]]) == [[780, 520, 312], [3750, 9120, 120], [5175, 5280, 3825], [3885, 1245, 3045]]\n assert candidate(grid = [[2, 3, 5, 7], [11, 13, 17, 19], [23, 29, 31, 37], [41, 43, 47, 53]]) == [[7830, 9335, 5601, 11055], [7035, 255, 195, 11220], [6585, 540, 7275, 11100], [6705, 12135, 7425, 11010]]\n assert candidate(grid = [[12345, 24690, 37035, 49380, 61725, 74070, 86415, 98760, 111105, 123450], [135795, 148140, 160485, 172830, 185175, 197520, 209865, 222210, 234555, 246900]]) == [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(grid = [[98765, 43210, 24680], [13579, 86420, 97531], [23456, 78901, 65432]]) == [[5845, 11690, 3250], [3275, 5845, 10925], [9070, 11495, 8350]]\n assert candidate(grid = [[12345], [24690], [37035], [49380], [61275]]) == [[0], [0], [0], [0], [0]]\n assert candidate(grid = [[98765, 43210, 11111], [22222, 33333, 55555], [66666, 77777, 88888]]) == [[1740, 3480, 5055], [8700, 9915, 3480], [11130, 9540, 2175]]\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]]) == [[240, 120, 8310, 60, 7455, 4155, 5325, 30, 6885, 9900], [9900, 6885, 30, 5325, 4155, 7455, 60, 8310, 120, 240], [240, 8310, 7455, 5325, 6885, 9000, 8565, 6600, 3645, 6510]]\n assert candidate(grid = [[12345, 6789, 101112], [131415, 161718, 192021]]) == [[6510, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[12345, 6789, 2345], [9876, 5432, 1234]]) == [[0, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[12345, 12345, 12345, 12345, 12345], [12345, 12345, 12345, 12345, 12345]]) == [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n assert candidate(grid = [[12345, 1, 12345], [1, 12345, 1], [12345, 1, 12345]]) == [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [[10095, 11220, 11595, 5610, 11895], [11970, 10260, 2805, 7980, 12120], [2040, 5985, 4575, 5130, 12195]]\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]]) == [[366, 366, 366, 366, 366, 366, 366, 366, 366, 366], [183, 183, 183, 183, 183, 183, 183, 183, 183, 183], [8352, 8352, 8352, 8352, 8352, 8352, 8352, 8352, 8352, 8352]]\n assert candidate(grid = [[123, 456, 789], [101, 202, 303], [404, 505, 606], [707, 808, 909]]) == [[6930, 6255, 9060], [7095, 9720, 6480], [4860, 6357, 3240], [11595, 2430, 2160]]\n assert candidate(grid = [[99999, 99998, 99997], [99996, 99995, 99994], [99993, 99992, 99991]]) == [[5010, 8205, 4080], [2685, 5586, 4290], [9660, 8265, 4140]]\n assert candidate(grid = [[12345], [12345], [12345], [12345]]) == [[0], [0], [0], [0]]\n assert candidate(grid = [[2], [3], [5], [7], [11], [13], [17], [19], [23], [29], [31], [37], [41], [43], [47], [53], [59], [61], [67], [71]]) == [[9915], [2495], [11373], [6360], [2925], [2475], [3345], [10140], [9450], [4515], [11790], [11880], [7710], [3045], [9615], [840], [2010], [4575], [1770], [4800]]\n assert candidate(grid = [[2, 3, 5, 7, 11], [13, 17, 19, 23, 29], [31, 37, 41, 43, 47]]) == [[5505, 3670, 2202, 5100, 5490], [5595, 2100, 11625, 10140, 6765], [7125, 4635, 4785, 6285, 9690]]\n assert candidate(grid = [[999999999, 999999998, 999999997], [999999996, 999999995, 999999994], [999999993, 999999992, 999999991]]) == [[8475, 3495, 7500], [2340, 9156, 7095], [6630, 2940, 7200]]\n assert candidate(grid = [[12345, 12344, 12343], [12342, 12341, 12340]]) == [[12225, 0, 0], [0, 0, 0]]\n assert candidate(grid = [[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]]) == [[1530, 765, 510, 6555, 2775], [255, 10800, 9450, 8400, 7560], [7995, 6300, 6765, 5400, 5040], [4725, 90, 4200, 1380, 3780], [3600, 10170, 1140, 3150, 555]]\n assert candidate(grid = [[1000000000, 999999999], [999999998, 1000000001]]) == [[12147, 70], [11580, 10770]]\n assert candidate(grid = [[12345], [1], [2], [3], [4], [5], [6], [7], [8], [9]]) == [[4875], [0], [0], [0], [0], [0], [0], [0], [0], [0]]\n assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == [[7630, 7630, 7630], [7630, 7630, 7630], [7630, 7630, 7630]]\n assert candidate(grid = [[12345, 12345, 12345, 12345], [12345, 12345, 12345, 12345], [12345, 12345, 12345, 12345]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n assert candidate(grid = [[1000000, 1000001, 1000002], [1000003, 1000004, 1000005], [1000006, 1000007, 1000008]]) == [[1530, 180, 4725], [4005, 10005, 7575], [570, 9720, 4275]]\n assert candidate(grid = [[98765, 43210], [13579, 24680], [111111, 222222]]) == [[900, 1800], [3345, 11895], [750, 375]]\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]]\n assert candidate(grid = [[1000000000, 1000000000, 1000000000], [1000000000, 1000000000, 1000000000]]) == [[4930, 4930, 4930], [4930, 4930, 4930]]\n assert candidate(grid = [[999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]]) == [[4155, 3090, 3240, 4665, 9960, 2670, 11160, 480, 11505, 6360]]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().constructProductMatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] constructProductMatrix(int[][] grid) {", "container": "Solution", "callable": "constructProductMatrix", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2908, "task_id": "minimum-sum-of-mountain-triplets-i", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array nums of integers.\nA triplet of indices (i, j, k) is a mountain if:\n\ni < j < k\nnums[i] < nums[j] and nums[k] < nums[j]\n\nReturn the minimum possible sum of a mountain triplet of nums. If no such triplet exists, return -1.\n \nExample 1:\n\nInput: nums = [8,6,1,5,3]\nOutput: 9\nExplanation: Triplet (2, 3, 4) is a mountain triplet of sum 9 since: \n- 2 < 3 < 4\n- nums[2] < nums[3] and nums[4] < nums[3]\nAnd the sum of this triplet is nums[2] + nums[3] + nums[4] = 9. It can be shown that there are no mountain triplets with a sum of less than 9.\n\nExample 2:\n\nInput: nums = [5,4,8,7,10,2]\nOutput: 13\nExplanation: Triplet (1, 3, 5) is a mountain triplet of sum 13 since: \n- 1 < 3 < 5\n- nums[1] < nums[3] and nums[5] < nums[3]\nAnd the sum of this triplet is nums[1] + nums[3] + nums[5] = 13. It can be shown that there are no mountain triplets with a sum of less than 13.\n\nExample 3:\n\nInput: nums = [6,5,4,3,4,5]\nOutput: -1\nExplanation: It can be shown that there are no mountain triplets in nums.\n\n \nConstraints:\n\n3 <= nums.length <= 50\n1 <= nums[i] <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 8, 7, 10, 2]) == 13\n assert candidate(nums = [1, 5, 3, 6, 4, 7, 2]) == 6\n assert candidate(nums = [10, 20, 15, 30, 25, 40]) == 45\n assert candidate(nums = [3, 3, 3, 3, 3, 3]) == -1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 6\n assert candidate(nums = [4, 3, 2, 1, 5, 6, 7, 8, 9]) == -1\n assert candidate(nums = [1, 3, 1, 3, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [10, 20, 3, 40, 5, 60, 70, 8]) == 33\n assert candidate(nums = [1, 3, 2, 1, 2, 3]) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2]) == 4\n assert candidate(nums = [2, 1, 3, 4, 3, 2, 1]) == 4\n assert candidate(nums = [3, 1, 4, 2, 5]) == 7\n assert candidate(nums = [6, 5, 4, 3, 4, 5]) == -1\n assert candidate(nums = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8]) == 6\n assert candidate(nums = [1, 5, 3, 5, 1]) == 5\n assert candidate(nums = [7, 1, 3, 2, 4, 6, 5]) == 6\n assert candidate(nums = [8, 6, 1, 5, 3]) == 9\n assert candidate(nums = [3, 2, 1, 4, 5, 3, 2, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 8, 7, 6, 5, 4, 3, 2]) == 6\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 40, 35, 45]) == 30\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]) == 4\n assert candidate(nums = [7, 8, 9, 1, 10, 2, 11, 3, 12, 4, 13, 5, 14, 6, 15]) == 13\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 4\n assert candidate(nums = [42, 21, 31, 41, 10, 20, 30, 50, 15, 25, 35, 45, 5, 1, 6, 11, 16, 26, 36, 46]) == 26\n assert candidate(nums = [8, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == 26\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10, 14]) == 8\n assert candidate(nums = [2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 4\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 = [50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == -1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [5, 3, 1, 2, 4, 6, 7, 8, 10, 9]) == 20\n assert candidate(nums = [30, 25, 20, 15, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == -1\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 6\n assert candidate(nums = [2, 1, 3, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 8\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3]) == 4\n assert candidate(nums = [8, 1, 5, 10, 3, 12, 7, 9]) == 9\n assert candidate(nums = [40, 20, 30, 10, 50, 35, 45, 25, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110, 105]) == 60\n assert candidate(nums = [2, 3, 1, 4, 5, 3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [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, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\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\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 45, 50]) == 30\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 50]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 50]) == -1\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5]) == 12\n assert candidate(nums = [47, 45, 43, 41, 39, 40, 42, 44, 46, 48, 50, 49, 47, 45, 43]) == 126\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15]) == 12\n assert candidate(nums = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1]) == 5\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10]) == 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, 1, 1, 1, 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, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 4\n assert candidate(nums = [30, 20, 10, 5, 15, 25, 35, 40, 30, 25, 20, 15, 10, 5, 0]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 4\n assert candidate(nums = [15, 10, 12, 11, 13, 9, 14, 8, 16, 7, 17, 6, 18, 5, 19, 4, 20, 3, 21, 2]) == 23\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\n assert candidate(nums = [50, 1, 50, 2, 50, 3, 50, 4, 50, 5, 50, 6, 50, 7, 50]) == 53\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19]) == 70\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == -1\n assert candidate(nums = [30, 10, 20, 15, 25, 5, 35, 5, 10, 40]) == 30\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, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11]) == 14\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 4\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\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 40, 35]) == 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]) == 4\n assert candidate(nums = [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]) == 6\n assert candidate(nums = [10, 20, 15, 25, 5, 30, 22, 18, 17, 28]) == 30\n assert candidate(nums = [2, 5, 3, 8, 6, 4, 9, 7, 10, 1]) == 6\n assert candidate(nums = [4, 5, 1, 6, 2, 7, 3, 8, 9, 10, 11]) == 9\n assert candidate(nums = [5, 6, 7, 8, 9, 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]) == -1\n assert candidate(nums = [20, 15, 10, 5, 6, 7, 8, 12, 11, 16]) == 28\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == -1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == -1\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == -1\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 4\n assert candidate(nums = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [10, 20, 30, 40, 35, 25, 15, 10, 20, 30, 40, 35, 25, 15]) == 35\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, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [50, 1, 50, 1, 50, 1, 50, 1, 50, 1]) == 52\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 51, 52, 53, 54, 55]) == -1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 6\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 6\n assert candidate(nums = [10, 20, 30, 25, 15, 5, 25, 30, 10]) == 30\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, 9, 8]) == 18\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 13\n assert candidate(nums = [25, 20, 15, 30, 25, 20, 35, 30, 25, 40, 35, 30, 45, 40, 35]) == 60\n assert candidate(nums = [5, 3, 8, 6, 7, 4, 9, 2, 10, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 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]) == -1\n assert candidate(nums = [20, 15, 10, 25, 30, 5, 40, 45, 50]) == 40\n assert candidate(nums = [9, 1, 2, 3, 8, 5, 6, 4, 7]) == 10\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, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == -1\n assert candidate(nums = [10, 20, 5, 15, 25, 10, 30, 5, 40]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 5, 3, 4, 2, 6, 8, 7, 9, 10, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [25, 20, 15, 10, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == -1\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 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, 100, 2, 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, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5]) == 8\n assert candidate(nums = [2, 1, 3, 4, 3, 5, 6, 5, 7, 8, 7, 9, 10]) == 8\n assert candidate(nums = [10, 20, 15, 25, 5, 30, 10]) == 30\n assert candidate(nums = [10, 20, 30, 25, 15, 27, 17, 28, 18, 29, 9, 19, 21, 22, 23]) == 34\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5]) == 8\n assert candidate(nums = [3, 2, 1, 4, 3, 2, 5, 4, 3, 6, 5, 4, 7, 6, 5, 8, 7, 6, 9, 8, 7, 10, 9, 8]) == 6\n assert candidate(nums = [3, 5, 1, 4, 2, 6, 7, 8, 9, 10, 11, 12, 13]) == 7\n assert candidate(nums = [2, 1, 3, 4, 3, 2, 4, 3, 2, 1, 3, 4, 3, 2, 4, 3, 2, 1, 3, 4, 3, 2]) == 4\n assert candidate(nums = [30, 25, 20, 15, 10, 5, 10, 15, 20, 25, 30]) == -1\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [8, 1, 9, 3, 7, 5, 11, 2, 13, 4]) == 6\n assert candidate(nums = [30, 20, 10, 25, 15, 35, 40, 45, 50]) == 50\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumSum(int[] nums) {", "container": "Solution", "callable": "minimumSum", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2909, "task_id": "minimum-sum-of-mountain-triplets-ii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of integers.\nA triplet of indices (i, j, k) is a mountain if:\n\ni < j < k\nnums[i] < nums[j] and nums[k] < nums[j]\n\nReturn the minimum possible sum of a mountain triplet of nums. If no such triplet exists, return -1.\n \nExample 1:\n\nInput: nums = [8,6,1,5,3]\nOutput: 9\nExplanation: Triplet (2, 3, 4) is a mountain triplet of sum 9 since: \n- 2 < 3 < 4\n- nums[2] < nums[3] and nums[4] < nums[3]\nAnd the sum of this triplet is nums[2] + nums[3] + nums[4] = 9. It can be shown that there are no mountain triplets with a sum of less than 9.\n\nExample 2:\n\nInput: nums = [5,4,8,7,10,2]\nOutput: 13\nExplanation: Triplet (1, 3, 5) is a mountain triplet of sum 13 since: \n- 1 < 3 < 5\n- nums[1] < nums[3] and nums[5] < nums[3]\nAnd the sum of this triplet is nums[1] + nums[3] + nums[5] = 13. It can be shown that there are no mountain triplets with a sum of less than 13.\n\nExample 3:\n\nInput: nums = [6,5,4,3,4,5]\nOutput: -1\nExplanation: It can be shown that there are no mountain triplets in nums.\n\n \nConstraints:\n\n3 <= nums.length <= 105\n1 <= nums[i] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 1, 3, 1, 4, 1, 3, 1]) == 5\n assert candidate(nums = [100000000, 1, 100000000, 2, 100000000]) == 100000003\n assert candidate(nums = [5, 4, 8, 7, 10, 2]) == 13\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 3, 1, 4, 1, 5, 1, 6, 1]) == 5\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 6\n assert candidate(nums = [1, 100000000, 2, 99999999, 3, 99999998]) == 100000003\n assert candidate(nums = [1, 3, 1, 3, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [10, 20, 30, 15, 25, 35, 40, 10]) == 35\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [6, 5, 4, 3, 4, 5]) == -1\n assert candidate(nums = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(nums = [1, 5, 3, 7, 6, 8]) == 9\n assert candidate(nums = [8, 6, 1, 5, 3]) == 9\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1]) == 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]) == 4\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 4\n assert candidate(nums = [8, 1, 2, 3, 4, 5, 6, 7, 8]) == -1\n assert candidate(nums = [2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8]) == 6\n assert candidate(nums = [5, 1, 3, 7, 2, 6, 4, 8, 9]) == 6\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 31\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 103\n assert candidate(nums = [15, 10, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == -1\n assert candidate(nums = [5, 10, 15, 10, 5, 20, 25, 20, 15, 10, 5]) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 11, 12, 13, 14, 15]) == -1\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]) == 1\n assert candidate(nums = [8, 6, 1, 5, 3, 7, 2, 4, 9, 10, 11]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [7, 7, 7, 8, 7, 7, 7]) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == -1\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 102\n assert candidate(nums = [5, 1, 4, 2, 7, 3, 6, 8, 0, 9]) == 3\n assert candidate(nums = [3, 5, 1, 8, 4, 7, 6, 9, 2, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 7\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 7\n assert candidate(nums = [5, 1, 4, 3, 7, 6, 8]) == 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]) == -1\n assert candidate(nums = [7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5]) == 20\n assert candidate(nums = [8, 1, 5, 6, 3, 2, 4, 7]) == 6\n assert candidate(nums = [8, 1, 5, 3, 7, 2, 6, 4, 9]) == 6\n assert candidate(nums = [8, 6, 1, 5, 3, 7, 2, 10, 4, 9, 11, 13, 12]) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == -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]) == 4\n assert candidate(nums = [1, 5, 1, 4, 1, 3, 1, 2, 1]) == 4\n assert candidate(nums = [100, 101, 99, 102, 98, 103, 97, 104, 96]) == 297\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 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, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 103\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15]) == 7\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]) == -1\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5]) == 103\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == -1\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]) == 3\n assert candidate(nums = [1, 2, 100, 2, 100, 2, 100, 2, 100, 2, 100, 2, 100, 2, 100, 2, 100, 2, 100]) == 103\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10]) == 22\n assert candidate(nums = [10, 20, 30, 40, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0]) == 25\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 7, 8, 9, 10, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 10, 15, 20, 25, 1, 2, 3, 4, 5]) == 16\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 6\n assert candidate(nums = [100, 200, 150, 250, 100, 300, 50, 400, 250, 500, 200, 450, 300, 550, 600, 525, 475, 650, 700, 625]) == 300\n assert candidate(nums = [5, 1, 3, 7, 2, 6, 4, 8]) == 6\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 13\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8, 7, 6, 5, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [10, 20, 10, 30, 5, 40, 25, 50, 15]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [10, 20, 5, 15, 10, 25, 5]) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12]) == -1\n assert candidate(nums = [1, 5, 3, 7, 2, 6, 4, 8]) == 6\n assert candidate(nums = [7, 1, 3, 5, 9, 6, 8, 2, 4]) == 6\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 100]) == 400\n assert candidate(nums = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -1\n assert candidate(nums = [2, 3, 1, 4, 6, 5, 8, 7, 9, 10, 11, 12]) == 6\n assert candidate(nums = [8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13]) == 12\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == 13\n assert candidate(nums = [10, 20, 15, 25, 10, 30, 5, 40, 25, 50]) == 30\n assert candidate(nums = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [5, 4, 3, 2, 1, 11, 12, 13, 14, 15]) == -1\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [7, 1, 5, 3, 6, 4, 2, 8, 10, 1, 12]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumSum(int[] nums) {", "container": "Solution", "callable": "minimumSum", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2911, "task_id": "minimum-changes-to-make-k-semi-palindromes", "difficulty": "Hard", "problem_description": "Given a string s and an integer k, partition s into k substrings such that the letter changes needed to make each substring a semi-palindrome are minimized.\nReturn the minimum number of letter changes required.\nA semi-palindrome is a special type of string that can be divided into palindromes based on a repeating pattern. To check if a string is a semi-palindrome:​\n\nChoose a positive divisor d of the string's length. d can range from 1 up to, but not including, the string's length. For a string of length 1, it does not have a valid divisor as per this definition, since the only divisor is its length, which is not allowed.\nFor a given divisor d, divide the string into groups where each group contains characters from the string that follow a repeating pattern of length d. Specifically, the first group consists of characters at positions 1, 1 + d, 1 + 2d, and so on; the second group includes characters at positions 2, 2 + d, 2 + 2d, etc.\nThe string is considered a semi-palindrome if each of these groups forms a palindrome.\n\nConsider the string \"abcabc\":\n\nThe length of \"abcabc\" is 6. Valid divisors are 1, 2, and 3.\nFor d = 1: The entire string \"abcabc\" forms one group. Not a palindrome.\nFor d = 2:\n\t\nGroup 1 (positions 1, 3, 5): \"acb\"\nGroup 2 (positions 2, 4, 6): \"bac\"\nNeither group forms a palindrome.\n\n\nFor d = 3:\n\t\nGroup 1 (positions 1, 4): \"aa\"\nGroup 2 (positions 2, 5): \"bb\"\nGroup 3 (positions 3, 6): \"cc\"\nAll groups form palindromes. Therefore, \"abcabc\" is a semi-palindrome.\n\n\n\n \nExample 1: \n\nInput: s = \"abcac\", k = 2 \nOutput: 1 \nExplanation: Divide s into \"ab\" and \"cac\". \"cac\" is already semi-palindrome. Change \"ab\" to \"aa\", it becomes semi-palindrome with d = 1.\n\nExample 2: \n\nInput: s = \"abcdef\", k = 2 \nOutput: 2 \nExplanation: Divide s into substrings \"abc\" and \"def\". Each needs one change to become semi-palindrome.\n\nExample 3: \n\nInput: s = \"aabbaa\", k = 3 \nOutput: 0 \nExplanation: Divide s into substrings \"aa\", \"bb\" and \"aa\". All are already semi-palindromes.\n\n \nConstraints:\n\n2 <= s.length <= 200\n1 <= k <= s.length / 2\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbcc\",k = 3) == 0\n assert candidate(s = \"abccba\",k = 2) == 2\n assert candidate(s = \"aabbccdd\",k = 4) == 0\n assert candidate(s = \"abcabcabc\",k = 4) == 4\n assert candidate(s = \"aaaaaa\",k = 2) == 0\n assert candidate(s = \"abcabcabcabc\",k = 4) == 3\n assert candidate(s = \"abccba\",k = 1) == 0\n assert candidate(s = \"aabbaa\",k = 3) == 0\n assert candidate(s = \"racecar\",k = 1) == 0\n assert candidate(s = \"abcac\",k = 2) == 1\n assert candidate(s = \"zzzzzz\",k = 2) == 0\n assert candidate(s = \"abcdabc\",k = 2) == 2\n assert candidate(s = \"abcdefg\",k = 2) == 3\n assert candidate(s = \"abcdcba\",k = 3) == 2\n assert candidate(s = \"abcdefg\",k = 3) == 3\n assert candidate(s = \"abcabcabc\",k = 3) == 3\n assert candidate(s = \"aaaa\",k = 2) == 0\n assert candidate(s = \"abcdabc\",k = 3) == 3\n assert candidate(s = \"abcabc\",k = 3) == 3\n assert candidate(s = \"abcdef\",k = 2) == 2\n assert candidate(s = \"abccba\",k = 3) == 2\n assert candidate(s = \"ababab\",k = 3) == 3\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiop\",k = 6) == 5\n assert candidate(s = \"aabbccddeeaabbccddeeaabbccdd\",k = 6) == 2\n assert candidate(s = \"abcdefedcbafedcba\",k = 3) == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcd\",k = 5) == 2\n assert candidate(s = \"abcdabcdabcdabcd\",k = 4) == 2\n assert candidate(s = \"xyzxyzxyzxyz\",k = 4) == 3\n assert candidate(s = \"xyzxyzxyzxyzxyz\",k = 3) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",k = 5) == 4\n assert candidate(s = \"abcdeabcdeabcde\",k = 4) == 5\n assert candidate(s = \"level\",k = 1) == 0\n assert candidate(s = \"banana\",k = 2) == 1\n assert candidate(s = \"aabbaabbaabbaabb\",k = 4) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmlloo\",k = 5) == 6\n assert candidate(s = \"abccbaabccbaabccba\",k = 4) == 2\n assert candidate(s = \"abracadabraabracadabra\",k = 4) == 5\n assert candidate(s = \"redder\",k = 2) == 2\n assert candidate(s = \"repaper\",k = 2) == 3\n assert candidate(s = \"abababaabab\",k = 3) == 0\n assert candidate(s = \"abcdefghij\",k = 2) == 4\n assert candidate(s = \"abcdefabcdef\",k = 4) == 4\n assert candidate(s = \"abcdefghiabcdefghiabcdefghi\",k = 4) == 3\n assert candidate(s = \"xyzxyzxyzxyzxyz\",k = 5) == 4\n assert candidate(s = \"aabbaaabbbaa\",k = 3) == 1\n assert candidate(s = \"aaabbbcccdddaaa\",k = 4) == 2\n assert candidate(s = \"abcdefgabcdefg\",k = 4) == 5\n assert candidate(s = \"xyxzyxzyxzyxzyxzyx\",k = 4) == 1\n assert candidate(s = \"xyxyxyxyxyxyxy\",k = 3) == 0\n assert candidate(s = \"aaaaabbbbbcccc\",k = 3) == 0\n assert candidate(s = \"ababababababab\",k = 3) == 0\n assert candidate(s = \"abcdefghabcdefghabcdefgh\",k = 6) == 5\n assert candidate(s = \"mississippi\",k = 2) == 2\n assert candidate(s = \"abccbaabccba\",k = 2) == 0\n assert candidate(s = \"abcdefabcdefabcdef\",k = 6) == 6\n assert candidate(s = \"abcdefggfedcba\",k = 2) == 5\n assert candidate(s = \"noonnoonnoon\",k = 3) == 0\n assert candidate(s = \"aabbccddeeffgghhiijj\",k = 5) == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnoopp\",k = 6) == 8\n assert candidate(s = \"aaabaaabaaabaaab\",k = 5) == 1\n assert candidate(s = \"aabbccddeeff\",k = 3) == 4\n assert candidate(s = \"abcdefgabcdefg\",k = 2) == 5\n assert candidate(s = \"racecar\",k = 3) == 2\n assert candidate(s = \"abababab\",k = 3) == 1\n assert candidate(s = \"ababababababab\",k = 5) == 1\n assert candidate(s = \"abcabcabcabcabcabc\",k = 6) == 5\n assert candidate(s = \"mnopqrnopqr\",k = 3) == 4\n assert candidate(s = \"deified\",k = 1) == 0\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",k = 5) == 4\n assert candidate(s = \"abcabcabcabcabcabcabc\",k = 7) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 7) == 0\n assert candidate(s = \"abcdefghij\",k = 5) == 5\n assert candidate(s = \"noon\",k = 1) == 0\n assert candidate(s = \"aaaaaaaaaa\",k = 5) == 0\n assert candidate(s = \"abcdefghijklnmopqrstuvwxyz\",k = 5) == 9\n assert candidate(s = \"abcdefghij\",k = 3) == 4\n assert candidate(s = \"racecar\",k = 2) == 3\n assert candidate(s = \"rotor\",k = 1) == 0\n assert candidate(s = \"abracadabraabracadabra\",k = 5) == 4\n assert candidate(s = \"xyzyxzyxzyx\",k = 4) == 3\n assert candidate(s = \"aaaaabbbbccccdddd\",k = 4) == 0\n assert candidate(s = \"aaabbbcccdddeeefffggg\",k = 5) == 3\n assert candidate(s = \"aaaabbbbccccdddd\",k = 4) == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",k = 6) == 3\n assert candidate(s = \"ababababab\",k = 3) == 0\n assert candidate(s = \"aabaaabaaabaaa\",k = 4) == 1\n assert candidate(s = \"aabbccddeeffgg\",k = 4) == 4\n assert candidate(s = \"aaaaabbbbcccc\",k = 3) == 0\n assert candidate(s = \"mnopqrsmnopqrsmno\",k = 3) == 6\n assert candidate(s = \"aabbccddeeffgg\",k = 6) == 2\n assert candidate(s = \"zzzaaaabbbccc\",k = 4) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10) == 10\n assert candidate(s = \"abababababababab\",k = 4) == 0\n assert candidate(s = \"mnopqrspqrspqr\",k = 3) == 2\n assert candidate(s = \"abacabadaba\",k = 3) == 1\n assert candidate(s = \"mississippi\",k = 3) == 1\n assert candidate(s = \"abacabadabacaba\",k = 5) == 2\n assert candidate(s = \"abacabadabacaba\",k = 3) == 0\n assert candidate(s = \"zzzzzyzzzzzz\",k = 5) == 0\n assert candidate(s = \"xyxyxyxyxyxy\",k = 6) == 6\n assert candidate(s = \"abcdeedcba\",k = 2) == 4\n assert candidate(s = \"abcdabcdabcdabcdabcd\",k = 4) == 1\n assert candidate(s = \"abcdefedcba\",k = 5) == 4\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaa\",k = 5) == 0\n assert candidate(s = \"zzzzzyzzzzz\",k = 2) == 0\n assert candidate(s = \"abcabcabcabcabc\",k = 5) == 4\n assert candidate(s = \"abcdefabcdef\",k = 2) == 1\n assert candidate(s = \"abcdefabcdefabcdefabcdef\",k = 5) == 3\n assert candidate(s = \"anana\",k = 1) == 0\n assert candidate(s = \"abcdefghijabcdefghij\",k = 5) == 7\n assert candidate(s = \"aaaabbbb\",k = 2) == 0\n assert candidate(s = \"xyzyzyzyz\",k = 4) == 3\n assert candidate(s = \"mnopqrstuvwx\",k = 4) == 4\n assert candidate(s = \"zzzzzzyyyzzzzzyyy\",k = 2) == 0\n assert candidate(s = \"reviled\",k = 2) == 3\n assert candidate(s = \"aaabbbbccccaaa\",k = 3) == 3\n assert candidate(s = \"abacabadabacaba\",k = 4) == 1\n assert candidate(s = \"aabbccddeeff\",k = 4) == 2\n assert candidate(s = \"xyzxyzxyzxyzxyz\",k = 4) == 3\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().minimumChanges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumChanges(String s, int k) {", "container": "Solution", "callable": "minimumChanges", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2913, "task_id": "subarrays-distinct-element-sum-of-squares-i", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums.\nThe distinct count of a subarray of nums is defined as:\n\nLet nums[i..j] be a subarray of nums consisting of all the indices from i to j such that 0 <= i <= j < nums.length. Then the number of distinct values in nums[i..j] is called the distinct count of nums[i..j].\n\nReturn the sum of the squares of distinct counts of all subarrays of nums.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,2,1]\nOutput: 15\nExplanation: Six possible subarrays are:\n[1]: 1 distinct value\n[2]: 1 distinct value\n[1]: 1 distinct value\n[1,2]: 2 distinct values\n[2,1]: 2 distinct values\n[1,2,1]: 2 distinct values\nThe sum of the squares of the distinct counts in all subarrays is equal to 12 + 12 + 12 + 22 + 22 + 22 = 15.\n\nExample 2:\n\nInput: nums = [1,1]\nOutput: 3\nExplanation: Three possible subarrays are:\n[1]: 1 distinct value\n[1]: 1 distinct value\n[1,1]: 1 distinct value\nThe sum of the squares of the distinct counts in all subarrays is equal to 12 + 12 + 12 = 3.\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 = [1, 3, 3, 2, 2, 1]) == 85\n assert candidate(nums = [10, 20, 10, 20, 10]) == 45\n assert candidate(nums = [1, 2, 2, 1]) == 25\n assert candidate(nums = [1, 3, 2, 3, 1]) == 70\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100, 100, 99, 99, 98]) == 49\n assert candidate(nums = [1, 2, 3, 4]) == 50\n assert candidate(nums = [10, 20, 30, 40, 50]) == 105\n assert candidate(nums = [5, 6, 7, 8, 9]) == 105\n assert candidate(nums = [7, 7, 7, 7, 7, 7]) == 21\n assert candidate(nums = [1, 2, 1]) == 15\n assert candidate(nums = [5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 105\n assert candidate(nums = [10, 10, 10]) == 6\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 184\n assert candidate(nums = [4, 4, 4, 4]) == 10\n assert candidate(nums = [4, 5, 6, 7]) == 50\n assert candidate(nums = [1, 2]) == 6\n assert candidate(nums = [2, 3, 2, 3]) == 28\n assert candidate(nums = [1, 2, 3]) == 20\n assert candidate(nums = [1, 1]) == 3\n assert candidate(nums = [5]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 1730\n assert candidate(nums = [3, 4, 3, 2, 3, 1]) == 120\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 4, 4, 4, 4]) == 410\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == 171\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 755\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2]) == 293\n assert candidate(nums = [10, 20, 30, 20, 10, 30, 20, 10]) == 220\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1210\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1716\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]) == 1811\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 825\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 551\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 778\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 210\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 551\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 78\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1]) == 220\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 1210\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 263\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 778\n assert candidate(nums = [1, 2, 3, 2, 1]) == 70\n assert candidate(nums = [3, 1, 2, 3, 4, 5, 3, 2]) == 370\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 50, 10]) == 367\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 278\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 4635\n assert candidate(nums = [1, 3, 3, 1, 2, 2, 3, 1]) == 194\n assert candidate(nums = [50, 50, 51, 51, 52, 52, 53, 53, 54, 54]) == 415\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 451\n assert candidate(nums = [5, 6, 5, 7, 8, 7, 6, 5, 9, 10, 9, 8, 7, 6]) == 1899\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 77\n assert candidate(nums = [10, 20, 30, 20, 10, 30]) == 111\n assert candidate(nums = [10, 20, 30, 20, 10, 30, 20, 10, 30]) == 288\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 415\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 4830\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 120\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 4830\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 415\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 415\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 1210\n assert candidate(nums = [3, 1, 2, 3, 4, 2, 5]) == 240\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 55\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 778\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1210\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10560\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 438\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 5440\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1210\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 1645\n assert candidate(nums = [10, 20, 30, 40, 50]) == 105\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1]) == 861\n assert candidate(nums = [10, 20, 10, 30, 20, 30, 40, 50]) == 298\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 930\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 1645\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 553\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 930\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5415\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 438\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 1285\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 3]) == 367\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 36\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10560\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 1794\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 825\n assert candidate(nums = [9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 3910\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10560\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9]) == 551\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5415\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 962\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]) == 8670850\n assert candidate(nums = [1, 1, 2, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 751\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]) == 6455\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 4, 3, 2, 1]) == 611\n assert candidate(nums = [5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 415\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1210\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 55\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 2, 3]) == 419\n assert candidate(nums = [10, 20, 30, 20, 10, 30]) == 111\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 4635\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 1285\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 2366\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 350\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumCounts", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int sumCounts(List nums) {", "container": "Solution", "callable": "sumCounts", "parameters": [{"name": "nums", "type": "List"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2914, "task_id": "minimum-number-of-changes-to-make-binary-string-beautiful", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary string s having an even length.\nA string is beautiful if it's possible to partition it into one or more substrings such that:\n\nEach substring has an even length.\nEach substring contains only 1's or only 0's.\n\nYou can change any character in s to 0 or 1.\nReturn the minimum number of changes required to make the string s beautiful.\n \nExample 1:\n\nInput: s = \"1001\"\nOutput: 2\nExplanation: We change s[1] to 1 and s[3] to 0 to get string \"1100\".\nIt can be seen that the string \"1100\" is beautiful because we can partition it into \"11|00\".\nIt can be proven that 2 is the minimum number of changes needed to make the string beautiful.\n\nExample 2:\n\nInput: s = \"10\"\nOutput: 1\nExplanation: We change s[1] to 1 to get string \"11\".\nIt can be seen that the string \"11\" is beautiful because we can partition it into \"11\".\nIt can be proven that 1 is the minimum number of changes needed to make the string beautiful.\n\nExample 3:\n\nInput: s = \"0000\"\nOutput: 0\nExplanation: We don't need to make any changes as the string \"0000\" is beautiful already.\n\n \nConstraints:\n\n2 <= s.length <= 105\ns has an even length.\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 0\n assert candidate(s = \"101010\") == 3\n assert candidate(s = \"11001100\") == 0\n assert candidate(s = \"001100\") == 0\n assert candidate(s = \"10\") == 1\n assert candidate(s = \"110011\") == 0\n assert candidate(s = \"00110011\") == 0\n assert candidate(s = \"11110000\") == 0\n assert candidate(s = \"0101\") == 2\n assert candidate(s = \"010101\") == 3\n assert candidate(s = \"1001\") == 2\n assert candidate(s = \"0000\") == 0\n assert candidate(s = \"00001111\") == 0\n assert candidate(s = \"111111111111111111111111\") == 0\n assert candidate(s = \"000000111111000000111111\") == 0\n assert candidate(s = \"110011001100110011001100\") == 0\n assert candidate(s = \"1100110011001100\") == 0\n assert candidate(s = \"010101010101010101010101\") == 12\n assert candidate(s = \"00000000111111110000000011111111\") == 0\n assert candidate(s = \"10101001010101\") == 7\n assert candidate(s = \"10101010101010101010101010\") == 13\n assert candidate(s = \"0000111111000011111100001111\") == 0\n assert candidate(s = \"00001111000011110000\") == 0\n assert candidate(s = \"101010101010101010101010\") == 12\n assert candidate(s = \"1010101010\") == 5\n assert candidate(s = \"0000000000000000\") == 0\n assert candidate(s = \"1010100101010101\") == 8\n assert candidate(s = \"1010101010101010\") == 8\n assert candidate(s = \"011101110111\") == 3\n assert candidate(s = \"110011001100\") == 0\n assert candidate(s = \"111111000000111111000000\") == 0\n assert candidate(s = \"10011001100110011001\") == 10\n assert candidate(s = \"10111000111000111000\") == 4\n assert candidate(s = \"0100100100100100\") == 5\n assert candidate(s = \"01001001001001\") == 5\n assert candidate(s = \"0011001100110011\") == 0\n assert candidate(s = \"00001100001100001100\") == 0\n assert candidate(s = \"000111000111\") == 2\n assert candidate(s = \"110101010101\") == 5\n assert candidate(s = \"111111111111\") == 0\n assert candidate(s = \"0110110110110110\") == 6\n assert candidate(s = \"11110000111100001111\") == 0\n assert candidate(s = \"1010010101010101\") == 8\n assert candidate(s = \"0101011010101010\") == 8\n assert candidate(s = \"101010101010\") == 6\n assert candidate(s = \"11111111111111111111\") == 0\n assert candidate(s = \"000011110000\") == 0\n assert candidate(s = \"1100111100000011\") == 0\n assert candidate(s = \"1111111111111111\") == 0\n assert candidate(s = \"110000110000\") == 0\n assert candidate(s = \"01100110011001\") == 7\n assert candidate(s = \"11111111000000001111111100000000\") == 0\n assert candidate(s = \"11010101\") == 3\n assert candidate(s = \"1111001111001111\") == 0\n assert candidate(s = \"11001100110011000000\") == 0\n assert candidate(s = \"0110100100110001\") == 5\n assert candidate(s = \"1011001100110011\") == 1\n assert candidate(s = \"11010101101010101010\") == 9\n assert candidate(s = \"000000000000\") == 0\n assert candidate(s = \"100000000001\") == 2\n assert candidate(s = \"1001001001001001\") == 6\n assert candidate(s = \"11001100110011001100\") == 0\n assert candidate(s = \"11100011100011100011\") == 3\n assert candidate(s = \"1010101010101010101010101010\") == 14\n assert candidate(s = \"0000110000110000\") == 0\n assert candidate(s = \"0000111111110000\") == 0\n assert candidate(s = \"111000111000\") == 2\n assert candidate(s = \"1111111100000000\") == 0\n assert candidate(s = \"111100001111\") == 0\n assert candidate(s = \"1100101011110000\") == 2\n assert candidate(s = \"1010101001010101\") == 8\n assert candidate(s = \"01100110011001100110\") == 10\n assert candidate(s = \"1000100010001000100010001000\") == 7\n assert candidate(s = \"010101010101\") == 6\n assert candidate(s = \"11010101010101\") == 6\n assert candidate(s = \"0101010101010101\") == 8\n assert candidate(s = \"000000000000000000000000\") == 0\n assert candidate(s = \"00000000\") == 0\n assert candidate(s = \"0101010101010101010101010101\") == 14\n assert candidate(s = \"11110011000011110000111100\") == 0\n assert candidate(s = \"00010001000100010001\") == 5\n assert candidate(s = \"01010101010110101010\") == 10\n assert candidate(s = \"11001011001011\") == 2\n assert candidate(s = \"1111000011111100\") == 0\n assert candidate(s = \"0111011101110111011101110111\") == 7\n assert candidate(s = \"100010001000\") == 3\n assert candidate(s = \"00110011001100110011\") == 0\n assert candidate(s = \"1110001110001110\") == 3\n assert candidate(s = \"00000000000000000000\") == 0\n assert candidate(s = \"1111000011110000\") == 0\n assert candidate(s = \"110000111100110000111100\") == 0\n assert candidate(s = \"0000000011111111\") == 0\n assert candidate(s = \"0101010110101010\") == 8\n assert candidate(s = \"1111000000001111\") == 0\n assert candidate(s = \"1100001100001100\") == 0\n assert candidate(s = \"0110011001100110\") == 8\n assert candidate(s = \"1101001101001101\") == 3\n assert candidate(s = \"100110011001\") == 6\n assert candidate(s = \"1001100110011001\") == 8\n assert candidate(s = \"001001001001\") == 4\n assert candidate(s = \"01010101010101010101\") == 10\n assert candidate(s = \"110000111100\") == 0\n assert candidate(s = \"110110110110\") == 4\n assert candidate(s = \"11111111\") == 0\n assert candidate(s = \"1111000011000011\") == 0\n assert candidate(s = \"01010101\") == 4\n assert candidate(s = \"11111111000000001111\") == 0\n assert candidate(s = \"0101101010101010\") == 8\n assert candidate(s = \"10101010101010101010\") == 10\n assert candidate(s = \"00000000111111110000\") == 0\n assert candidate(s = \"0000001111110000\") == 0\n assert candidate(s = \"1111110000001111\") == 0\n assert candidate(s = \"1101010101\") == 4\n assert candidate(s = \"1011101110111011\") == 4\n assert candidate(s = \"001100110011\") == 0\n assert candidate(s = \"0000111100001111\") == 0\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minChanges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minChanges(String s) {", "container": "Solution", "callable": "minChanges", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2915, "task_id": "length-of-the-longest-subsequence-that-sums-to-target", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of integers nums, and an integer target.\nReturn the length of the longest subsequence of nums that sums up to target. If no such subsequence exists, return -1.\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,5], target = 9\nOutput: 3\nExplanation: There are 3 subsequences with a sum equal to 9: [4,5], [1,3,5], and [2,3,4]. The longest subsequences are [1,3,5], and [2,3,4]. Hence, the answer is 3.\n\nExample 2:\n\nInput: nums = [4,1,3,2,1,5], target = 7\nOutput: 4\nExplanation: There are 5 subsequences with a sum equal to 7: [4,3], [4,1,2], [4,2,1], [1,1,5], and [1,3,2,1]. The longest subsequence is [1,3,2,1]. Hence, the answer is 4.\n\nExample 3:\n\nInput: nums = [1,1,5,4,5], target = 3\nOutput: -1\nExplanation: It can be shown that nums has no subsequence that sums up to 3.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 1000\n1 <= target <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 7, 8, 10],target = 15) == 3\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 8, 9, 10],target = 15) == 4\n assert candidate(nums = [10, 20, 30, 40, 50],target = 50) == 2\n assert candidate(nums = [999, 1],target = 1000) == 2\n assert candidate(nums = [100, 200, 300],target = 100) == 1\n assert candidate(nums = [1, 2, 3],target = 7) == -1\n assert candidate(nums = [4, 1, 3, 2, 1, 5],target = 7) == 4\n assert candidate(nums = [1],target = 1) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],target = 100) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],target = 3) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 25) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],target = 9) == 3\n assert candidate(nums = [10, 20, 30, 40, 50],target = 60) == 3\n assert candidate(nums = [5, 5, 5, 5, 5],target = 15) == 3\n assert candidate(nums = [500, 500, 500, 500],target = 1000) == 2\n assert candidate(nums = [1, 2, 3],target = 6) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],target = 1) == 1\n assert candidate(nums = [1000],target = 1000) == 1\n assert candidate(nums = [1, 1, 5, 4, 5],target = 3) == -1\n assert candidate(nums = [1, 2, 3, 4, 5],target = 15) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],target = 5) == 5\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 25) == -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],target = 15) == 15\n assert candidate(nums = [999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1000) == 2\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],target = 9995) == -1\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],target = 1998) == -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, 42, 44, 46, 48, 50],target = 600) == 24\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 30) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 75) == 7\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],target = 210) == 11\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],target = 700) == 13\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980],target = 990) == 1\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],target = 2970) == -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],target = 500) == 22\n assert candidate(nums = [10, 20, 30, 40, 50],target = 100) == 4\n assert candidate(nums = [333, 334, 333, 334, 333, 334, 333, 334, 333, 334, 333, 334, 333, 334, 333, 334, 333, 334, 333, 334],target = 1000) == 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],target = 1000) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 50) == 9\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 2500) == 6\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],target = 400) == 9\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 100) == 5\n assert candidate(nums = [10, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90],target = 900) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 500) == 9\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],target = 210) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 550) == 10\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 50) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 300) == 7\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 3000) == 7\n assert candidate(nums = [999, 500, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 1000) == 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],target = 100) == 13\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],target = 100) == 5\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448],target = 500) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 900) == 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],target = 5) == 5\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135],target = 675) == 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],target = 10) == 10\n assert candidate(nums = [123, 456, 789, 234, 567, 890, 345, 678, 901, 12, 34, 56, 78, 90],target = 2500) == -1\n assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],target = 1500) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 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],target = 100) == 10\n assert candidate(nums = [100, 200, 300, 400, 500],target = 1500) == 5\n assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],target = 1500) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 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],target = 30) == 10\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 27) == 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 = 190) == 19\n assert candidate(nums = [500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 999) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1023) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 1000) == 13\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],target = 210) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 225) == 15\n assert candidate(nums = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5],target = 2000) == 5\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],target = 600) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 300) == 7\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160],target = 600) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 7) == 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],target = 10000) == 12\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],target = 750) == -1\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707],target = 1825) == -1\n assert candidate(nums = [250, 125, 62, 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],target = 499) == 27\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 150) == 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],target = 150) == 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],target = 5) == 5\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],target = 100) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 500) == 9\n assert candidate(nums = [333, 334, 333, 334, 333, 334, 333, 334],target = 1000) == 3\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],target = 420) == 10\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],target = 143) == 5\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509],target = 1500) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 150) == 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],target = 20) == 8\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],target = 200) == 13\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1024) == -1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 20) == 4\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],target = 600) == 11\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1023) == 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],target = 10) == 10\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986],target = 4950) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 5000) == 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 = 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],target = 20) == 8\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],target = 300) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 50) == 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],target = 55) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 150) == 11\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],target = 105) == 5\n assert candidate(nums = [500, 300, 200, 100, 50, 25, 10, 5, 1],target = 1000) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 15) == 6\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().lengthOfLongestSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int lengthOfLongestSubsequence(List nums, int target) {", "container": "Solution", "callable": "lengthOfLongestSubsequence", "parameters": [{"name": "nums", "type": "List"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2916, "task_id": "subarrays-distinct-element-sum-of-squares-ii", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums.\nThe distinct count of a subarray of nums is defined as:\n\nLet nums[i..j] be a subarray of nums consisting of all the indices from i to j such that 0 <= i <= j < nums.length. Then the number of distinct values in nums[i..j] is called the distinct count of nums[i..j].\n\nReturn the sum of the squares of distinct counts of all subarrays of nums.\nSince the answer may be very large, return it modulo 109 + 7.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,2,1]\nOutput: 15\nExplanation: Six possible subarrays are:\n[1]: 1 distinct value\n[2]: 1 distinct value\n[1]: 1 distinct value\n[1,2]: 2 distinct values\n[2,1]: 2 distinct values\n[1,2,1]: 2 distinct values\nThe sum of the squares of the distinct counts in all subarrays is equal to 12 + 12 + 12 + 22 + 22 + 22 = 15.\n\nExample 2:\n\nInput: nums = [2,2]\nOutput: 3\nExplanation: Three possible subarrays are:\n[2]: 1 distinct value\n[2]: 1 distinct value\n[2,2]: 1 distinct value\nThe sum of the squares of the distinct counts in all subarrays is equal to 12 + 12 + 12 = 3.\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]) == 105\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 105\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 77\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [1, 1, 1, 1, 1]) == 15\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 2, 1]) == 241\n assert candidate(nums = [1, 3, 2, 3, 1, 4, 2]) == 210\n assert candidate(nums = [5, 5, 5, 5, 5]) == 15\n assert candidate(nums = [1, 3, 3, 1, 2, 2, 4]) == 156\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 15\n assert candidate(nums = [1, 2, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5]) == 105\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1210\n assert candidate(nums = [2, 2]) == 3\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 105\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 1730\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]) == 17100\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 1794\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, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 68610\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 435\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16170\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4]) == 4219\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]) == 7398\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]) == 51040\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 776\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 3010\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 755\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]) == 3003\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 3010\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 1210\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 778\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 1650\n assert candidate(nums = [5, 3, 8, 3, 9, 1, 5, 3, 8, 3, 9, 1, 5, 3, 8, 3, 9, 1, 5, 3, 8, 3, 9, 1]) == 5698\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, 1, 1]) == 26382\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 5440\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]) == 21745\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8085\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]) == 2605\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 510\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 4635\n assert candidate(nums = [5, 3, 8, 3, 9, 1, 5, 3, 8, 3, 9, 1]) == 1098\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 451\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 763\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110]) == 6558\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 4830\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 1210\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 415\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 4830\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 190\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16131\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2]) == 178\n assert candidate(nums = [1, 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]) == 11874\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]) == 1939\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 564\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 3291\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16170\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, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 59260\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 3850\n assert candidate(nums = [1, 2, 1, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9, 8, 9, 10]) == 7710\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]) == 3828\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5]) == 724\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == 1026\n assert candidate(nums = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2]) == 1740\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 1590\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981]) == 16170\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]) == 6455\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, 1, 2, 3, 4, 5]) == 38385\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 778\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]) == 76880\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1210\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10560\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 438\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 370\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 1, 2, 3, 2, 1, 3, 2, 1, 1, 2, 3, 2]) == 1584\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 1210\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 3480\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 3930\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 860\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]) == 23190\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1210\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]) == 38025\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1210\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]) == 11847\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 866\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 16170\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 14574\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2]) == 4409\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]) == 435\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16170\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1]) == 1688\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 2030\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]) == 465\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]) == 12194\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 3480\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]) == 24960\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10560\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 1210\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 1794\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]) == 5942\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]) == 917\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]) == 741\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 2475\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]) == 3865\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10560\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]) == 6455\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 1495\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 658\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 3930\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 210\n assert candidate(nums = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 470\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]) == 6455\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]) == 18525\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumCounts", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int sumCounts(int[] nums) {", "container": "Solution", "callable": "sumCounts", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2917, "task_id": "find-the-k-or-of-an-array", "difficulty": "Easy", "problem_description": "You are given an integer array nums, and an integer k. Let's introduce K-or operation by extending the standard bitwise OR. In K-or, a bit position in the result is set to 1 if at least k numbers in nums have a 1 in that position.\nReturn the K-or of nums.\n \nExample 1: \n\nInput: nums = [7,12,9,8,9,15], k = 4 \nOutput: 9 \nExplanation: \nRepresent numbers in binary:\n\n\n\nNumber\nBit 3\nBit 2\nBit 1\nBit 0\n\n\n7\n0\n1\n1\n1\n\n\n12\n1\n1\n0\n0\n\n\n9\n1\n0\n0\n1\n\n\n8\n1\n0\n0\n0\n\n\n9\n1\n0\n0\n1\n\n\n15\n1\n1\n1\n1\n\n\nResult = 9\n1\n0\n0\n1\n\n\n\nBit 0 is set in 7, 9, 9, and 15. Bit 3 is set in 12, 9, 8, 9, and 15.\nOnly bits 0 and 3 qualify. The result is (1001)2 = 9.\n\nExample 2: \n\nInput: nums = [2,12,1,11,4,5], k = 6 \nOutput: 0 \nExplanation: No bit appears as 1 in all six array numbers, as required for K-or with k = 6. Thus, the result is 0.\n\nExample 3: \n\nInput: nums = [10,8,5,9,11,6,8], k = 1 \nOutput: 15 \nExplanation: Since k == 1, the 1-or of the array is equal to the bitwise OR of all its elements. Hence, the answer is 10 OR 8 OR 5 OR 9 OR 11 OR 6 OR 8 = 15.\n\n \nConstraints:\n\n1 <= nums.length <= 50\n0 <= nums[i] < 231\n1 <= k <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 8, 5, 9, 11, 6, 8],k = 1) == 15\n assert candidate(nums = [7, 12, 9, 8, 9, 15],k = 4) == 9\n assert candidate(nums = [2, 12, 1, 11, 4, 5],k = 6) == 0\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1],k = 3) == 63\n assert candidate(nums = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22],k = 5) == 23\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384],k = 7) == 0\n assert candidate(nums = [32, 64, 128, 256, 512, 1024, 2048, 4096],k = 4) == 0\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],k = 3) == 31\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 6) == 0\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555],k = 2) == 536870879\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444],k = 3) == 534769557\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 6) == 31\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 6) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 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],k = 10) == 63\n assert candidate(nums = [31, 14, 7, 28, 15, 13, 29],k = 3) == 31\n assert candidate(nums = [4294967295, 4294967294, 4294967293, 4294967292, 4294967291],k = 3) == 4294967295\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 = 3) == 262143\n assert candidate(nums = [5, 17, 2, 3, 1, 6, 8, 16, 10, 4],k = 5) == 0\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048],k = 2) == 0\n assert candidate(nums = [13, 29, 53, 79, 101, 131, 157, 181, 211, 239],k = 5) == 157\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],k = 50) == 1\n assert candidate(nums = [31, 14, 7, 28, 15, 23, 11, 9],k = 3) == 31\n assert candidate(nums = [32, 16, 8, 4, 2, 1, 64, 128, 256, 512, 1024],k = 7) == 0\n assert candidate(nums = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17],k = 10) == 17\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 5) == 31\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 = 5) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 2) == 511\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535],k = 4) == 8191\n assert candidate(nums = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 6) == 127\n assert candidate(nums = [8388607, 8388606, 8388605, 8388604, 8388603, 8388602, 8388601, 8388600],k = 4) == 8388607\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 = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 6) == 0\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 8) == 0\n assert candidate(nums = [31, 14, 7, 28, 15, 24, 29, 30],k = 5) == 30\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 10) == 0\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],k = 5) == 24\n assert candidate(nums = [29, 38, 47, 56, 65, 74, 83, 92, 101, 110],k = 7) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(nums = [18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192],k = 10) == 254\n assert candidate(nums = [18, 33, 51, 48, 47, 38, 21, 50, 49, 23],k = 5) == 51\n assert candidate(nums = [3, 5, 6, 7, 10, 12, 15],k = 4) == 7\n assert candidate(nums = [31, 62, 124, 248, 496, 992, 1984],k = 4) == 248\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 10) == 1\n assert candidate(nums = [31, 14, 28, 15, 23, 29, 27, 19],k = 5) == 31\n assert candidate(nums = [1073741824, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152],k = 3) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 2) == 0\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647],k = 25) == 2147483647\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],k = 10) == 15\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 4) == 127\n assert candidate(nums = [31, 14, 7, 28, 15, 29, 10],k = 3) == 31\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, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229],k = 10) == 255\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 5) == 31\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256],k = 5) == 0\n assert candidate(nums = [1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823],k = 5) == 1073741823\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 8) == 31\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035],k = 7) == 2097088\n assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248],k = 4) == 255\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647],k = 10) == 2147483647\n assert candidate(nums = [63, 37, 19, 31, 15, 7, 1, 3, 11],k = 3) == 31\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 = 20) == 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 = 10) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 5) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 7) == 0\n assert candidate(nums = [4294967295, 2147483647, 1073741823, 536870911, 268435455, 134217727],k = 4) == 536870911\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1],k = 5) == 0\n assert candidate(nums = [3, 6, 12, 24, 48, 96],k = 3) == 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 = 30) == 1\n assert candidate(nums = [1073741824, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048],k = 15) == 0\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],k = 5) == 2047\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 5) == 1000000000\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0],k = 4) == 31\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 = 15) == 31\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 = 5) == 2044\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004],k = 2) == 1000000003\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642],k = 3) == 2147483647\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 = 5) == 134217727\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 15) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 5) == 63\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 7) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64],k = 1) == 127\n assert candidate(nums = [31, 17, 14, 19, 28, 15, 30],k = 3) == 31\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 1020\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400],k = 7) == 127\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536],k = 8) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 1\n assert candidate(nums = [33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431, 33554431],k = 15) == 33554431\n assert candidate(nums = [31, 28, 19, 14, 23, 15, 27],k = 3) == 31\n assert candidate(nums = [31, 14, 7, 28, 15, 21, 19],k = 3) == 31\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],k = 30) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128],k = 2) == 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) == 127\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().findKOr", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findKOr(int[] nums, int k) {", "container": "Solution", "callable": "findKOr", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2918, "task_id": "minimum-equal-sum-of-two-arrays-after-replacing-zeros", "difficulty": "Medium", "problem_description": "You are given two arrays nums1 and nums2 consisting of positive integers.\nYou have to replace all the 0's in both arrays with strictly positive integers such that the sum of elements of both arrays becomes equal.\nReturn the minimum equal sum you can obtain, or -1 if it is impossible.\n \nExample 1:\n\nInput: nums1 = [3,2,0,1,0], nums2 = [6,5,0]\nOutput: 12\nExplanation: We can replace 0's in the following way:\n- Replace the two 0's in nums1 with the values 2 and 4. The resulting array is nums1 = [3,2,2,1,4].\n- Replace the 0 in nums2 with the value 1. The resulting array is nums2 = [6,5,1].\nBoth arrays have an equal sum of 12. It can be shown that it is the minimum sum we can obtain.\n\nExample 2:\n\nInput: nums1 = [2,0,2,0], nums2 = [1,4]\nOutput: -1\nExplanation: It is impossible to make the sum of both arrays equal.\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 105\n0 <= nums1[i], nums2[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [1, 0, 0, 0],nums2 = [0, 0, 0, 1]) == 4\n assert candidate(nums1 = [2, 0, 2, 0],nums2 = [1, 4]) == -1\n assert candidate(nums1 = [3, 2, 0, 1, 0],nums2 = [6, 5, 0]) == 12\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == 6\n assert candidate(nums1 = [1, 0, 3],nums2 = [2, 0, 2]) == 5\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 2, 2, 2]) == -1\n assert candidate(nums1 = [0, 0, 0],nums2 = [1, 1, 1]) == 3\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == 3\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0]) == 4\n assert candidate(nums1 = [1, 0],nums2 = [0, 1]) == 2\n assert candidate(nums1 = [10, 20, 30, 0, 0],nums2 = [0, 0, 0, 40, 50]) == 93\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [1000000, 0, 0],nums2 = [500000, 500000, 0]) == 1000002\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 65\n assert candidate(nums1 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 15\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1000000]) == 1000000\n assert candidate(nums1 = [1000000, 0, 0, 0, 0],nums2 = [500000, 500000, 0, 0, 0]) == 1000004\n assert candidate(nums1 = [1000000, 1000000, 0],nums2 = [500000, 500000, 500000, 500000, 500000, 500000, 0]) == 3000001\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]) == 55\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000, 5000000, 0, 0, 0, 0, 0],nums2 = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 0, 0, 0]) == 15000005\n assert candidate(nums1 = [1000000],nums2 = [1000000]) == 1000000\n assert candidate(nums1 = [1000000],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 0, 0],nums2 = [5, 4, 3, 2, 1, 0, 0]) == 17\n assert candidate(nums1 = [1, 2, 3, 0, 0],nums2 = [4, 5, 0, 0, 0]) == 12\n assert candidate(nums1 = [1000000, 0, 0, 0],nums2 = [500000, 500000, 0, 0]) == 1000003\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(nums1 = [999999, 0, 0, 0],nums2 = [500000, 500000, 0]) == 1000002\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0, 1]) == 17\n assert candidate(nums1 = [1, 1, 1, 1, 1, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 0, 0, 0]) == 9\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1000000, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1000009\n assert candidate(nums1 = [999999, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums1 = [999999, 0, 0, 0, 0, 0],nums2 = [1000000, 1, 1, 1, 1, 1]) == 1000005\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums1 = [3, 0, 5, 0, 7],nums2 = [2, 0, 6, 0, 0]) == 17\n assert candidate(nums1 = [1000000, 0, 0, 500000],nums2 = [750000, 250000, 0, 0]) == 1500002\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100, 0]) == -1\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums1 = [999999, 0, 0, 0],nums2 = [1, 1, 1, 1]) == -1\n assert candidate(nums1 = [1000000, 0, 0, 0],nums2 = [500000, 500000, 0, 0]) == 1000003\n assert candidate(nums1 = [1, 2, 3, 4, 0, 0, 0],nums2 = [7, 8, 9, 0, 0]) == 26\n assert candidate(nums1 = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [500000, 500000, 0, 0],nums2 = [250000, 250000, 250000, 250000, 0, 0]) == 1000002\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 15\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]) == 55\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 46\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0]) == 16\n assert candidate(nums1 = [1, 0, 1, 0, 1],nums2 = [0, 1, 0, 1, 0, 1]) == 6\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums1 = [1000000, 1000000, 1000000, 1000000],nums2 = [2000000, 0, 0, 0]) == 4000000\n assert candidate(nums1 = [100, 200, 300, 0, 0, 0, 0, 0, 0, 0],nums2 = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 750\n assert candidate(nums1 = [10, 20, 30, 0, 0],nums2 = [5, 15, 25, 0, 0]) == 62\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 46\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 55\n assert candidate(nums1 = [0, 1000000, 0, 1000000],nums2 = [500000, 0, 0, 500000]) == 2000002\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [0, 0, 0, 0, 0, 0]) == 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]) == 10\n assert candidate(nums1 = [10, 20, 30, 0, 0],nums2 = [15, 15, 0, 0, 0]) == 62\n assert candidate(nums1 = [0, 1, 0, 2, 0, 3],nums2 = [4, 0, 5, 0, 6]) == 17\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 55\n assert candidate(nums1 = [1, 2, 3, 0, 0, 0],nums2 = [6, 5, 0, 0, 0]) == 14\n assert candidate(nums1 = [5, 10, 15, 20],nums2 = [20, 15, 10, 5, 0, 0]) == -1\n assert candidate(nums1 = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0],nums2 = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == 20\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 165\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 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 20\n assert candidate(nums1 = [1000000, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [500000, 500000, 0, 0, 0, 0, 0, 0, 0, 0]) == 1000009\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0],nums2 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0]) == 167\n assert candidate(nums1 = [1000000, 0, 0, 0],nums2 = [500000, 500000, 0]) == 1000003\n assert candidate(nums1 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10\n assert candidate(nums1 = [1, 2, 3, 0, 0, 0],nums2 = [6, 0, 0, 0, 0, 0]) == 11\n assert candidate(nums1 = [1, 0, 3, 0, 5, 0, 7, 0, 9, 0],nums2 = [0, 2, 0, 4, 0, 6, 0, 8, 0, 10]) == 35\n assert candidate(nums1 = [1, 0, 1, 0, 1, 0],nums2 = [0, 1, 0, 1, 0, 1]) == 6\n assert candidate(nums1 = [1, 2, 3, 0, 0, 0],nums2 = [4, 5, 0, 0, 0, 0]) == 13\n assert candidate(nums1 = [10, 20, 30, 40, 50, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 151\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 100\n assert candidate(nums1 = [1, 2, 3, 4, 5, 0, 0],nums2 = [5, 4, 3, 2, 1, 0, 0]) == 17\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10\n assert candidate(nums1 = [999999, 999999, 999999],nums2 = [999999, 999999, 0]) == 2999997\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 12\n assert candidate(nums1 = [1, 0, 0, 0, 0, 0],nums2 = [2, 0, 0, 0, 0, 0]) == 7\n assert candidate(nums1 = [100, 200, 300, 400, 500, 0, 0, 0, 0, 0],nums2 = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [0, 0, 0, 0, 0]) == 15\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0, 0]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 0, 0, 0],nums2 = [10, 0, 0, 0, 0, 0, 0, 0]) == 18\n assert candidate(nums1 = [999999],nums2 = [1, 0, 0, 0, 0, 0, 0]) == 999999\n assert candidate(nums1 = [10, 20, 30],nums2 = [5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums1 = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0],nums2 = [5, 0, 4, 0, 3, 0, 2, 0, 1, 0]) == 20\n assert candidate(nums1 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 15\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [5, 15, 25, 35, 0, 0]) == 100\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0, 0, 0]) == -1\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minSum(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "minSum", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2919, "task_id": "minimum-increment-operations-to-make-array-beautiful", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums having length n, and an integer k.\nYou can perform the following increment operation any number of times (including zero):\n\nChoose an index i in the range [0, n - 1], and increase nums[i] by 1.\n\nAn array is considered beautiful if, for any subarray with a size of 3 or more, its maximum element is greater than or equal to k.\nReturn an integer denoting the minimum number of increment operations needed to make nums beautiful.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [2,3,0,0,2], k = 4\nOutput: 3\nExplanation: We can perform the following increment operations to make nums beautiful:\nChoose index i = 1 and increase nums[1] by 1 -> [2,4,0,0,2].\nChoose index i = 4 and increase nums[4] by 1 -> [2,4,0,0,3].\nChoose index i = 4 and increase nums[4] by 1 -> [2,4,0,0,4].\nThe subarrays with a size of 3 or more are: [2,4,0], [4,0,0], [0,0,4], [2,4,0,0], [4,0,0,4], [2,4,0,0,4].\nIn all the subarrays, the maximum element is equal to k = 4, so nums is now beautiful.\nIt can be shown that nums cannot be made beautiful with fewer than 3 increment operations.\nHence, the answer is 3.\n\nExample 2:\n\nInput: nums = [0,1,3,3], k = 5\nOutput: 2\nExplanation: We can perform the following increment operations to make nums beautiful:\nChoose index i = 2 and increase nums[2] by 1 -> [0,1,4,3].\nChoose index i = 2 and increase nums[2] by 1 -> [0,1,5,3].\nThe subarrays with a size of 3 or more are: [0,1,5], [1,5,3], [0,1,5,3].\nIn all the subarrays, the maximum element is equal to k = 5, so nums is now beautiful.\nIt can be shown that nums cannot be made beautiful with fewer than 2 increment operations.\nHence, the answer is 2.\n\nExample 3:\n\nInput: nums = [1,1,2], k = 1\nOutput: 0\nExplanation: The only subarray with a size of 3 or more in this example is [1,1,2].\nThe maximum element, 2, is already greater than k = 1, so we don't need any increment operation.\nHence, the answer is 0.\n\n \nConstraints:\n\n3 <= n == nums.length <= 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) == 0\n assert candidate(nums = [10, 9, 8, 7, 6],k = 10) == 2\n assert candidate(nums = [1000000000, 0, 1000000000, 0, 1000000000],k = 1000000000) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1],k = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == 2\n assert candidate(nums = [1, 0, 0, 0, 1],k = 2) == 2\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 1000000000) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1],k = 2) == 3\n assert candidate(nums = [5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5],k = 10) == 3\n assert candidate(nums = [2, 3, 0, 0, 2],k = 4) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 12\n assert candidate(nums = [0, 1, 3, 3],k = 5) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 7) == 5\n assert candidate(nums = [5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0],k = 0) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 12\n assert candidate(nums = [1, 1, 2],k = 1) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0],k = 1) == 2\n assert candidate(nums = [0, 0, 0, 0, 0],k = 3) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == 3\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 1000000000) == 2\n assert candidate(nums = [3, 2, 1, 5, 4, 6, 7, 8, 9, 10],k = 5) == 2\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 5) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 12\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 200\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 25) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 7) == 5\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0],k = 1) == 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],k = 10) == 15\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 7) == 14\n assert candidate(nums = [3, 0, 0, 3, 0, 0, 3, 0, 0],k = 3) == 0\n assert candidate(nums = [5, 1, 4, 2, 8, 3, 6, 9, 7],k = 5) == 1\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0],k = 5) == 6\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 2) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 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],k = 10) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 12\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == 10\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 10) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 15\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 3) == 3\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4],k = 4) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 12\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) == 27\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 50) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 3) == 4\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2],k = 2) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == 15\n assert candidate(nums = [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],k = 1) == 6\n assert candidate(nums = [5, 1, 9, 3, 7, 8, 2, 6, 4],k = 6) == 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],k = 2) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 100) == 120\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100) == 0\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 = 4) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == 3\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 4) == 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) == 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 = 3) == 9\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 0) == 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 = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],k = 105) == 3\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9],k = 8) == 3\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 15) == 12\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 = 4) == 6\n assert candidate(nums = [10, 15, 0, 20, 5, 25, 1, 30],k = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 25) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 6) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 12\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 = 15) == 35\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5],k = 5) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\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 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == 8\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, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 200\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 0\n assert candidate(nums = [5, 3, 2, 1, 0, 6, 4, 8, 7],k = 5) == 3\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],k = 900000000) == 800000001\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 7) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 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],k = 2) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],k = 4) == 2\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == 6\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555],k = 777777777) == 0\n assert candidate(nums = [10, 0, 10, 0, 10, 0, 10, 0, 10],k = 5) == 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 = 2) == 6\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 10) == 3\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 50) == 132\n assert candidate(nums = [2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0],k = 2) == 0\n assert candidate(nums = [5, 3, 2, 7, 1, 4, 6, 8, 0],k = 6) == 1\n assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],k = 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],k = 10) == 12\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 25\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 5\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 10) == 3\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 12\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6],k = 6) == 5\n assert candidate(nums = [2, 1, 0, 1, 2, 1, 0, 2, 1, 0],k = 2) == 1\n assert candidate(nums = [5, 3, 2, 8, 6, 7, 10, 1, 4],k = 6) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 2) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 25\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 600) == 300\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 7\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 30\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 55) == 25\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minIncrementOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minIncrementOperations(int[] nums, int k) {", "container": "Solution", "callable": "minIncrementOperations", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2920, "task_id": "maximum-points-after-collecting-coins-from-all-nodes", "difficulty": "Hard", "problem_description": "There exists an undirected tree rooted at node 0 with n nodes labeled from 0 to n - 1. 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. You are also given a 0-indexed array coins of size n where coins[i] indicates the number of coins in the vertex i, and an integer k.\nStarting from the root, you have to collect all the coins such that the coins at a node can only be collected if the coins of its ancestors have been already collected.\nCoins at nodei can be collected in one of the following ways:\n\nCollect all the coins, but you will get coins[i] - k points. If coins[i] - k is negative then you will lose abs(coins[i] - k) points.\nCollect all the coins, but you will get floor(coins[i] / 2) points. If this way is used, then for all the nodej present in the subtree of nodei, coins[j] will get reduced to floor(coins[j] / 2).\n\nReturn the maximum points you can get after collecting the coins from all the tree nodes.\n \nExample 1:\n\n\nInput: edges = [[0,1],[1,2],[2,3]], coins = [10,10,3,3], k = 5\nOutput: 11 \nExplanation: \nCollect all the coins from node 0 using the first way. Total points = 10 - 5 = 5.\nCollect all the coins from node 1 using the first way. Total points = 5 + (10 - 5) = 10.\nCollect all the coins from node 2 using the second way so coins left at node 3 will be floor(3 / 2) = 1. Total points = 10 + floor(3 / 2) = 11.\nCollect all the coins from node 3 using the second way. Total points = 11 + floor(1 / 2) = 11.\nIt can be shown that the maximum points we can get after collecting coins from all the nodes is 11. \n\nExample 2:\n \n\nInput: edges = [[0,1],[0,2]], coins = [8,4,4], k = 0\nOutput: 16\nExplanation: \nCoins will be collected from all the nodes using the first way. Therefore, total points = (8 - 0) + (4 - 0) + (4 - 0) = 16.\n\n \nConstraints:\n\nn == coins.length\n2 <= n <= 105\n0 <= coins[i] <= 104\nedges.length == n - 1\n0 <= edges[i][0], edges[i][1] < n\n0 <= k <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[0, 1], [1, 2], [2, 3]],coins = [10, 10, 3, 3],k = 5) == 11\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5]],coins = [10, 20, 30, 40, 50, 60],k = 15) == 120\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4]],coins = [100, 50, 25, 12, 6],k = 10) == 152\n assert candidate(edges = [[0, 1], [0, 2], [0, 3]],coins = [1000, 2000, 3000, 4000],k = 500) == 8000\n assert candidate(edges = [[0, 1]],coins = [10000, 1],k = 5000) == 5000\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5]],coins = [100, 50, 20, 10, 5, 2],k = 10) == 146\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [3, 4]],coins = [15, 10, 5, 2, 3],k = 6) == 16\n assert candidate(edges = [[0, 1], [0, 2]],coins = [8, 4, 4],k = 0) == 16\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],coins = [10, 20, 30, 40, 5, 6, 7, 8, 9, 1],k = 5) == 96\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8]],coins = [100, 50, 50, 20, 20, 10, 10, 5, 5],k = 10) == 204\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]],coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 20) == 540\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]],coins = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256],k = 512) == 13848\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], [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]],coins = [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 = 1) == 496\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]],coins = [500, 250, 125, 62, 31, 15, 7, 3, 1, 0, 100, 50, 25, 12, 6],k = 10) == 1076\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]],coins = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 500) == 13863\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]],coins = [1000, 200, 300, 400, 500, 600, 700, 800, 900],k = 200) == 3600\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],coins = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100],k = 50) == 6050\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]],coins = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984],k = 5000) == 79912\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]],coins = [5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1, 0, 0],k = 500) == 7851\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13]],coins = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0],k = 512) == 991\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]],coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 190\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]],coins = [10000, 5000, 3000, 2000, 1500, 1000, 800, 600, 400, 300, 200, 100, 50, 25, 12, 6],k = 200) == 22846\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],coins = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 10) == 1967\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]],coins = [15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 2000) == 93000\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],coins = [1000, 500, 300, 200, 150, 100, 50],k = 100) == 1750\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]],coins = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 1000) == 44222\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], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19]],coins = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],k = 1000) == 190000\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],coins = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100],k = 100) == 5500\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]],coins = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1],k = 50) == 5047\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8]],coins = [4000, 3000, 2000, 1500, 1200, 1000, 800, 600, 400],k = 500) == 10600\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],coins = [9999, 4999, 3333, 2500, 1250, 625, 312, 156, 78, 39],k = 1000) == 18060\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],coins = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 5) == 275\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],coins = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100],k = 25) == 6325\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]],coins = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1024, 512, 256, 128, 64, 32, 16, 8, 4],k = 100) == 3018\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [5, 10], [6, 11], [7, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19]],coins = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 100) == 19000\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],coins = [1000, 500, 250, 125, 62, 31, 15, 7],k = 50) == 1731\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]],coins = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980],k = 5000) == 99800\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]],coins = [500, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600],k = 50) == 3750\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]],coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],k = 1) == 78\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],coins = [100, 200, 300, 400, 500, 600, 700],k = 100) == 2100\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]],coins = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985],k = 1000) == 134880\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],coins = [10, 20, 30, 40, 50, 60, 70, 80],k = 15) == 240\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],coins = [500, 300, 200, 150, 100, 80, 60, 40, 30, 20, 10],k = 50) == 1120\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]],coins = [10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0],k = 1000) == 15706\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],coins = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0],k = 100) == 1566\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]],coins = [10000, 5000, 3000, 2000, 1500, 1000, 800, 600, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 0, 9, 8, 7, 6],k = 50) == 24361\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],coins = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],k = 50) == 1714\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]],coins = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 50) == 11250\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]],coins = [20000, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2000) == 31417\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],coins = [100, 200, 150, 50, 10, 20, 30],k = 25) == 430\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]],coins = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0, 100, 50, 25, 12, 6, 3, 1, 0, 100, 50, 25, 12, 6],k = 100) == 1619\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],coins = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],k = 100) == 1566\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]],coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170],k = 10) == 1360\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],coins = [10000, 5000, 3000, 2000, 1500, 1000, 800, 600, 400, 300, 200],k = 1000) == 18275\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]],coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220],k = 10) == 2310\n"}, "metadata": {"canonical_parameter_names": ["edges", "coins", "k"], "leetcode_dataset_entry_point": "Solution().maximumPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumPoints(int[][] edges, int[] coins, int k) {", "container": "Solution", "callable": "maximumPoints", "parameters": [{"name": "edges", "type": "int[][]"}, {"name": "coins", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2923, "task_id": "find-champion-i", "difficulty": "Easy", "problem_description": "There are n teams numbered from 0 to n - 1 in a tournament.\nGiven a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i != j team i is stronger than team j if grid[i][j] == 1, otherwise, team j is stronger than team i.\nTeam a will be the champion of the tournament if there is no team b that is stronger than team a.\nReturn the team that will be the champion of the tournament.\n \nExample 1:\n\nInput: grid = [[0,1],[0,0]]\nOutput: 0\nExplanation: There are two teams in this tournament.\ngrid[0][1] == 1 means that team 0 is stronger than team 1. So team 0 will be the champion.\n\nExample 2:\n\nInput: grid = [[0,0,1],[1,0,1],[0,0,0]]\nOutput: 1\nExplanation: There are three teams in this tournament.\ngrid[1][0] == 1 means that team 1 is stronger than team 0.\ngrid[1][2] == 1 means that team 1 is stronger than team 2.\nSo team 1 will be the champion.\n\n \nConstraints:\n\nn == grid.length\nn == grid[i].length\n2 <= n <= 100\ngrid[i][j] is either 0 or 1.\nFor all i grid[i][i] is 0.\nFor all i, j that i != j, grid[i][j] != grid[j][i].\nThe input is generated such that if team a is stronger than team b and team b is stronger than team c, then team a is stronger than team c.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 1, 1, 1], [0, 0, 0, 0], [0, 1, 0, 1], [0, 1, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 1], [1, 0, 0, 1], [1, 1, 0, 1], [0, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 1, 0], [0, 0, 1], [1, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 1], [1, 0, 1], [0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 1], [0, 0, 0], [0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 1], [1, 0, 1, 1], [1, 0, 0, 1], [0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 1], [0, 0, 1], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1], [0, 0]]) == 0\n assert candidate(grid = [[0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[0, 1, 1, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 1, 1], [1, 0, 0, 0, 1], [1, 1, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 0, 1], [1, 0, 1, 1, 1], [1, 0, 0, 1, 1], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 1, 0], [0, 0, 0, 0, 1], [0, 0, 1, 0, 1], [1, 1, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 1, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 0, 1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 0, 1, 0, 0], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 0, 1, 1], [0, 1, 0, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 0, 1, 1], [1, 0, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 1, 0, 1, 1, 0], [1, 0, 0, 0, 0, 1, 1, 0, 1], [1, 1, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 0, 0], [1, 0, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 0, 0, 1, 1, 1, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 0, 1, 0, 0, 0, 1, 0], [1, 1, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 1, 0, 0], [1, 0, 1, 1, 1, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 0], [1, 1, 0, 1, 0, 0, 1, 1], [1, 0, 1, 0, 0, 0, 0, 1], [1, 1, 0, 1, 1, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 1], [1, 0, 0, 1, 0, 0, 0], [1, 1, 0, 0, 1, 0, 0], [1, 1, 1, 0, 0, 1, 0], [1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0]]) == None\n assert candidate(grid = [[0, 1, 1, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 0, 0, 1], [0, 0, 0, 1, 0, 1, 1, 0], [1, 0, 0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 0, 1, 0, 1], [1, 1, 0, 0, 0, 0, 1, 1], [0, 1, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0, 1, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0], [1, 1, 0, 1, 0, 1, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 0, 1], [1, 0, 0, 1, 1], [1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 1, 1, 0], [1, 0, 0, 1, 1], [0, 1, 0, 1, 0], [0, 0, 0, 0, 1], [1, 0, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 0, 1, 0, 0, 0, 1], [1, 1, 0, 0, 1, 0, 0, 0], [1, 1, 1, 0, 0, 1, 0, 0], [1, 1, 1, 1, 0, 0, 1, 0], [1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 1], [0, 0, 1, 0, 1], [1, 0, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 1, 0], [0, 0, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 0, 0, 1], [1, 0, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 0, 1, 0], [1, 1, 0, 1, 0, 0, 0], [1, 1, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0]]) == None\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 1], [1, 1, 0, 0, 1, 0, 0], [1, 1, 1, 0, 0, 1, 1], [1, 0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 1, 1, 1], [1, 0, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 1], [0, 0, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 0, 0], [1, 0, 1, 0, 0, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 1, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 1, 1, 1, 0, 1, 1], [1, 1, 0, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 0, 1, 0, 1, 1], [1, 1, 0, 1, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0, 0, 1, 0], [1, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1, 0], [1, 1, 0, 0, 0, 1, 0, 0], [1, 1, 1, 0, 0, 1, 1, 0], [1, 1, 1, 1, 0, 0, 1, 0], [1, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1, 0, 1], [0, 1, 1, 1, 1, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 1], [0, 0, 0, 1, 1, 1, 1], [1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 0, 0, 1, 1], [0, 1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1], [0, 1, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 1, 0]]) == None\n assert candidate(grid = [[0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0], [1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1], [1, 1, 1, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 1, 1, 0, 1], [1, 1, 1, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 1, 1, 0], [0, 1, 0, 1, 0, 0, 0, 1], [0, 0, 1, 1, 0, 1, 0, 1], [0, 0, 0, 0, 1, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [1, 0, 0, 1, 0, 0], [1, 1, 0, 0, 1, 0], [1, 1, 1, 0, 0, 1], [1, 1, 1, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 1, 1, 0, 1, 0], [0, 0, 1, 1, 1, 0, 0, 1], [1, 0, 0, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [0, 1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 0, 1], [1, 0, 1, 1, 0], [1, 0, 0, 1, 0], [1, 0, 0, 0, 1], [0, 1, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 1, 1], [1, 0, 0, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 1, 0, 1, 1, 0], [0, 0, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 1], [1, 0, 1, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1], [0, 1, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 1, 1, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 0, 1, 1], [1, 0, 0, 0, 1], [0, 1, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [1, 1, 1, 0, 1, 1], [1, 1, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 1, 0], [1, 1, 0, 0, 1], [1, 1, 1, 0, 0]]) == None\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 1, 0, 0, 1, 0], [1, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0]]) == None\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 0, 1, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 0, 1, 0, 0], [1, 1, 1, 0, 0, 1, 1, 0, 1], [1, 1, 1, 1, 0, 0, 1, 1, 0], [1, 1, 1, 0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 0, 0]]) == None\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().findChampion", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findChampion(int[][] grid) {", "container": "Solution", "callable": "findChampion", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2924, "task_id": "find-champion-ii", "difficulty": "Medium", "problem_description": "There are n teams numbered from 0 to n - 1 in a tournament; each team is also a node in a DAG.\nYou are given the integer n and a 0-indexed 2D integer array edges of length m representing the DAG, where edges[i] = [ui, vi] indicates that there is a directed edge from team ui to team vi in the graph.\nA directed edge from a to b in the graph means that team a is stronger than team b and team b is weaker than team a.\nTeam a will be the champion of the tournament if there is no team b that is stronger than team a.\nReturn the team that will be the champion of the tournament if there is a unique champion, otherwise, return -1.\nNotes\n\nA cycle is a series of nodes a1, a2, ..., an, an+1 such that node a1 is the same node as node an+1, the nodes a1, a2, ..., an are distinct, and there is a directed edge from the node ai to node ai+1 for every i in the range [1, n].\nA DAG is a directed graph that does not have any cycle.\n\n \nExample 1:\n\n\nInput: n = 3, edges = [[0,1],[1,2]]\nOutput: 0\nExplanation: Team 1 is weaker than team 0. Team 2 is weaker than team 1. So the champion is team 0.\n\nExample 2:\n\n\nInput: n = 4, edges = [[0,2],[1,3],[1,2]]\nOutput: -1\nExplanation: Team 2 is weaker than team 0 and team 1. Team 3 is weaker than team 1. But team 1 and team 0 are not weaker than any other teams. So the answer is -1.\n\n \nConstraints:\n\n1 <= n <= 100\nm == edges.length\n0 <= m <= n * (n - 1) / 2\nedges[i].length == 2\n0 <= edge[i][j] <= n - 1\nedges[i][0] != edges[i][1]\nThe input is generated such that if team a is stronger than team b, team b is not stronger than team a.\nThe input is generated such that if team a is stronger than team b and team b is stronger than team c, then team a is stronger than team c.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(n = 2,edges = [[0, 1]]) == 0\n assert candidate(n = 3,edges = [[0, 1]]) == -1\n assert candidate(n = 2,edges = []) == -1\n assert candidate(n = 6,edges = [[0, 1], [2, 3], [4, 5]]) == -1\n assert candidate(n = 4,edges = [[0, 1], [0, 2], [1, 3], [2, 3]]) == 0\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == 0\n assert candidate(n = 3,edges = [[0, 1], [1, 2]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [0, 3], [0, 4]]) == 0\n assert candidate(n = 4,edges = [[0, 1], [2, 3]]) == -1\n assert candidate(n = 1,edges = []) == 0\n assert candidate(n = 3,edges = [[1, 2], [2, 0]]) == 1\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [2, 4]]) == 0\n assert candidate(n = 3,edges = [[1, 0], [2, 0]]) == -1\n assert candidate(n = 4,edges = [[0, 2], [1, 3], [1, 2]]) == -1\n assert candidate(n = 4,edges = [[0, 1], [0, 2], [0, 3]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [2, 3], [3, 4]]) == -1\n assert candidate(n = 6,edges = [[0, 1], [2, 3], [4, 5]]) == -1\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == 0\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [3, 4], [5, 6]]) == -1\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 0], [3, 4]]) == 3\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 2], [2, 3], [2, 4]]) == 0\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 10], [9, 11], [10, 11]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 4]]) == -1\n assert candidate(n = 10,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 2], [1, 3], [4, 6], [5, 7], [8, 0]]) == -1\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 0\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 8]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [0, 2], [3, 4]]) == -1\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]]) == 0\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7]]) == 0\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 0\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 4]]) == 0\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 0], [5, 1]]) == -1\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 6], [4, 6]]) == 0\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 6]]) == -1\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [3, 4], [4, 5]]) == 0\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3], [3, 0]]) == -1\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == -1\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 0\n assert candidate(n = 6,edges = [[0, 1], [2, 3], [4, 5], [0, 2], [1, 3], [4, 0], [5, 1], [2, 4], [3, 5]]) == -1\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 0\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6]]) == 0\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 0\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 1\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]]) == 0\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]]) == -1\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == -1\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]]) == 0\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 0\n assert candidate(n = 15,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]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 9], [6, 9]]) == 0\n assert candidate(n = 15,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], [4, 13], [5, 13], [6, 13], [7, 14], [8, 14], [9, 14]]) == 0\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 4], [3, 4], [4, 5]]) == 0\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]]) == 0\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 6], [7, 8]]) == 0\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 7], [6, 8]]) == 0\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 0]]) == 1\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]]) == 0\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 0\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 4]]) == 0\n assert candidate(n = 8,edges = [[0, 2], [0, 3], [1, 2], [1, 4], [2, 5], [3, 5], [4, 5], [5, 6], [6, 7]]) == -1\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 0\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8]]) == 0\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == -1\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 0\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 6], [4, 5]]) == 0\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == 0\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 6]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().findChampion", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findChampion(int n, int[][] edges) {", "container": "Solution", "callable": "findChampion", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2925, "task_id": "maximum-score-after-applying-operations-on-a-tree", "difficulty": "Medium", "problem_description": "There is 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 values of length n, where values[i] is the value associated with the ith node.\nYou start with a score of 0. In one operation, you can:\n\nPick any node i.\nAdd values[i] to your score.\nSet values[i] to 0.\n\nA tree is healthy if the sum of values on the path from the root to any leaf node is different than zero.\nReturn the maximum score you can obtain after performing these operations on the tree any number of times so that it remains healthy.\n \nExample 1:\n\n\nInput: edges = [[0,1],[0,2],[0,3],[2,4],[4,5]], values = [5,2,5,2,1,1]\nOutput: 11\nExplanation: We can choose nodes 1, 2, 3, 4, and 5. The value of the root is non-zero. Hence, the sum of values on the path from the root to any leaf is different than zero. Therefore, the tree is healthy and the score is values[1] + values[2] + values[3] + values[4] + values[5] = 11.\nIt can be shown that 11 is the maximum score obtainable after any number of operations on the tree.\n\nExample 2:\n\n\nInput: edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]], values = [20,10,9,7,4,3,5]\nOutput: 40\nExplanation: We can choose nodes 0, 2, 3, and 4.\n- The sum of values on the path from 0 to 4 is equal to 10.\n- The sum of values on the path from 0 to 3 is equal to 10.\n- The sum of values on the path from 0 to 5 is equal to 3.\n- The sum of values on the path from 0 to 6 is equal to 5.\nTherefore, the tree is healthy and the score is values[0] + values[2] + values[3] + values[4] = 40.\nIt can be shown that 40 is the maximum score obtainable after any number of operations on the tree.\n\n \nConstraints:\n\n2 <= n <= 2 * 104\nedges.length == n - 1\nedges[i].length == 2\n0 <= ai, bi < n\nvalues.length == n\n1 <= values[i] <= 109\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], [1, 3], [1, 4], [2, 5], [2, 6]],values = [20, 10, 9, 7, 4, 3, 5]) == 40\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [2, 4], [4, 5]],values = [5, 2, 5, 2, 1, 1]) == 11\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 135\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]],values = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 118\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]],values = [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]) == 675\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11]],values = [15, 8, 12, 6, 3, 9, 4, 10, 2, 7, 5, 1]) == 68\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [5, 8]],values = [20, 10, 9, 7, 4, 3, 5, 6, 2]) == 48\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], [7, 13], [7, 14], [8, 15], [8, 16], [11, 17], [11, 18], [12, 19], [12, 20]],values = [1000000000, 500000000, 300000000, 200000000, 200000000, 150000000, 150000000, 100000000, 100000000, 50000000, 50000000, 50000000, 50000000, 30000000, 30000000, 30000000, 30000000, 20000000, 20000000, 20000000, 20000000]) == 2600000000\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]],values = [500, 200, 150, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 8, 12, 9, 4, 6, 7, 3, 2, 1, 11, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 1663\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]],values = [15, 10, 20, 5, 6, 7, 8, 1, 2, 3, 4, 9, 10]) == 85\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19]],values = [100, 50, 30, 20, 10, 5, 5, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 229\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15]],values = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4]) == 550\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]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == 252\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15]],values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 675\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]],values = [100, 50, 30, 20, 25, 15, 10, 5, 8, 12, 9, 4, 6, 7, 3, 2, 1, 11, 13, 14, 16, 17, 18, 19, 21, 22, 23]) == 429\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]],values = [15, 10, 8, 3, 4, 2, 5, 1, 2, 3, 6, 7]) == 53\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], [6, 14], [7, 15], [8, 16]],values = [23, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 168\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]],values = [100, 50, 75, 25, 20, 15, 10, 5, 15, 10, 5, 3, 2]) == 285\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]],values = [100, 200, 300, 10, 10, 10, 5, 5, 5, 5, 5, 5]) == 630\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [5, 8], [5, 9], [7, 10], [7, 11]],values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 770\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]],values = [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]) == 11750\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [5, 8], [6, 9]],values = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 585\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]],values = [10, 20, 30, 5, 5, 5, 5, 2, 2, 1, 1, 1]) == 77\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 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], [13, 29], [13, 30]],values = [30, 20, 40, 50, 35, 25, 45, 15, 25, 5, 10, 6, 18, 3, 9, 2, 4, 1, 7, 12, 14, 8, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 624\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [5, 9], [6, 10]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 65\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]],values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == 1150\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],values = [30, 25, 20, 15, 10, 9, 8, 7, 6, 5, 4]) == 117\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],values = [10, 20, 30, 40, 5, 6, 7, 8, 9, 1]) == 126\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8]],values = [100, 20, 30, 40, 50, 10, 20, 30, 40]) == 320\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 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]],values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 24\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],values = [15, 12, 11, 8, 7, 6, 4, 2, 1, 3]) == 54\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]],values = [25, 15, 12, 8, 10, 9, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 159\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],values = [10, 20, 30, 40, 50, 60, 70, 80]) == 350\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]],values = [30, 20, 40, 50, 35, 25, 45, 15, 25, 5, 10, 6, 18, 3, 9, 2, 4, 1, 7, 12, 14]) == 346\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]],values = [50, 30, 20, 10, 20, 15, 10, 5, 5, 1, 1, 1, 1]) == 130\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11]],values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 7700\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]],values = [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]) == 35000\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]],values = [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]) == 1750\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]],values = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5]) == 72\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]],values = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 234\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 54\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],values = [5, 15, 10, 7, 3, 20, 1, 12, 8, 6, 4]) == 86\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]],values = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985, 999999984, 999999983, 999999982, 999999981, 999999980, 999999979, 999999978, 999999977, 999999976, 999999975, 999999974]) == 24999999675\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19]],values = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 57\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], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20], [13, 21], [14, 22], [15, 23], [16, 24], [17, 25], [18, 26], [19, 27], [20, 28], [21, 29]],values = [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]) == 464\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]],values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 595\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]],values = [50, 50, 50, 20, 20, 20, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 280\n"}, "metadata": {"canonical_parameter_names": ["edges", "values"], "leetcode_dataset_entry_point": "Solution().maximumScoreAfterOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maximumScoreAfterOperations(int[][] edges, int[] values) {", "container": "Solution", "callable": "maximumScoreAfterOperations", "parameters": [{"name": "edges", "type": "int[][]"}, {"name": "values", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2926, "task_id": "maximum-balanced-subsequence-sum", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums.\nA subsequence of nums having length k and consisting of indices i0 < i1 < ... < ik-1 is balanced if the following holds:\n\nnums[ij] - nums[ij-1] >= ij - ij-1, for every j in the range [1, k - 1].\n\nA subsequence of nums having length 1 is considered balanced.\nReturn an integer denoting the maximum possible sum of elements in a balanced subsequence of nums.\nA subsequence of an array is a new non-empty array that is formed from the original array by deleting some (possibly none) of the elements without disturbing the relative positions of the remaining elements.\n \nExample 1:\n\nInput: nums = [3,3,5,6]\nOutput: 14\nExplanation: In this example, the subsequence [3,5,6] consisting of indices 0, 2, and 3 can be selected.\nnums[2] - nums[0] >= 2 - 0.\nnums[3] - nums[2] >= 3 - 2.\nHence, it is a balanced subsequence, and its sum is the maximum among the balanced subsequences of nums.\nThe subsequence consisting of indices 1, 2, and 3 is also valid.\nIt can be shown that it is not possible to get a balanced subsequence with a sum greater than 14.\nExample 2:\n\nInput: nums = [5,-1,-3,8]\nOutput: 13\nExplanation: In this example, the subsequence [5,8] consisting of indices 0 and 3 can be selected.\nnums[3] - nums[0] >= 3 - 0.\nHence, it is a balanced subsequence, and its sum is the maximum among the balanced subsequences of nums.\nIt can be shown that it is not possible to get a balanced subsequence with a sum greater than 13.\n\nExample 3:\n\nInput: nums = [-2,-1]\nOutput: -1\nExplanation: In this example, the subsequence [-1] can be selected.\nIt is a balanced subsequence, and its sum is the maximum among the balanced subsequences of nums.\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 = [-2, -1]) == -1\n assert candidate(nums = [3, 3, 5, 6]) == 14\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 1000000000\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18]) == 115\n assert candidate(nums = [1, 2, 3, 5, 8, 13]) == 32\n assert candidate(nums = [-1, 0, 1, 0, -1]) == 1\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 1000000000\n assert candidate(nums = [10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [-5, -4, -3, -2, -1]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, -1, -3, 8]) == 13\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91]) == -91\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 231\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 11\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [-10, -20, -30, -40, -50]) == -10\n assert candidate(nums = [10, -5, 1, 100, -3]) == 110\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 5\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 1000000000\n assert candidate(nums = [-1000000000, -999999999, -999999998, -999999997, -999999996]) == -999999996\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 5\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 29\n assert candidate(nums = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55]) == 100\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 256\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]) == 375\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5500\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1048575\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 9, 7, 10, 8, 11]) == 19\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\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 5\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 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\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 15\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, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 18\n assert candidate(nums = [33, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, -1, -3, -5, -7]) == 33\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\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]) == 30\n assert candidate(nums = [-1000000000, 1000000000, -999999999, 999999999, -999999998, 999999998, -999999997, 999999997, -999999996, 999999996]) == 1000000000\n assert candidate(nums = [-1000000000, -999999999, -999999998, -999999997, -999999996, -999999995, -999999994, -999999993, -999999992, -999999991]) == -999999991\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]) == 10\n assert candidate(nums = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46]) == 175\n assert candidate(nums = [999999999, -999999999, 999999998, -999999998, 999999997, -999999997, 999999996, -999999996, 999999995, -999999995]) == 999999999\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 300\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == 150\n assert candidate(nums = [500000000, 600000000, 700000000, 800000000, 900000000, 1000000000, 1100000000, 1200000000, 1300000000, 1400000000]) == 9500000000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 275\n assert candidate(nums = [1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504, 927, 1705, 3136, 5768, 10609]) == 23248\n assert candidate(nums = [10, 20, 30, 40, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25]) == 150\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]) == 4179\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 150\n assert candidate(nums = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]) == 165\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 220\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 150\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 30\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 1000000000\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 100\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 1000000000\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 15, 20, 25, 30]) == 115\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000, 10000000000]) == 55000000000\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]) == 10\n assert candidate(nums = [-5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33]) == 289\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 325\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == 36\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 = [-1000000000, 1000000000, -1000000000, 1000000000, -1000000000]) == 1000000000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16]) == 64\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 150\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]) == 8\n assert candidate(nums = [1, 4, 5, 6, 8, 10, 13, 16, 20, 25]) == 108\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 32767\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 100\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 231\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 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4]) == 10\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0]) == 15\n assert candidate(nums = [1, 10, 11, 20, 30, 31, 40, 50, 51, 60]) == 304\n assert candidate(nums = [-1, -2, -3, -4, -5, 5, 4, 3, 2, 1]) == 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\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 16384\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10]) == 19\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [-1000000000, -999999999, -999999998, -999999997, -999999996]) == -999999996\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 100\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n assert candidate(nums = [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [-1000000000, -2000000000, -3000000000, -4000000000, -5000000000, -6000000000, -7000000000, -8000000000, -9000000000, -10000000000]) == -1000000000\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 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 1000\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9]) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50]) == 150\n assert candidate(nums = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5]) == -5\n assert candidate(nums = [-1000000000, 0, 1000000000, -1000000000, 0, 1000000000, -1000000000, 0, 1000000000, -1000000000]) == 1000000000\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 15\n assert candidate(nums = [1, 100, 2, 101, 3, 102, 4, 103, 5, 104]) == 109\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 50, 55, 60, 65, 70, 75, 80]) == 615\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 780\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 11\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 1000000000\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 1045\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 = [-1000000000, 1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 1000000000\n assert candidate(nums = [-1, -2, -3, -4, -5, 5, 4, 3, 2, 1, -1, -2, -3, -4, -5]) == 5\n assert candidate(nums = [10, 9, 8, 8, 8, 8, 8, 7, 6, 5]) == 10\n assert candidate(nums = [10, 1, 21, 2, 32, 3, 43, 4, 54, 5, 65, 6, 76, 7, 87, 8, 98, 9, 109, 10]) == 595\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 39\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 10\n assert candidate(nums = [0, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 5\n assert candidate(nums = [40, 35, 30, 25, 20, 15, 10, 5, 1, -5]) == 40\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]) == 2310\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 400\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 150, 250, 350, 450, 550]) == 2050\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 30\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, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 11\n assert candidate(nums = [1, -1000000000, 2, -999999999, 3, -999999998, 4, -999999997, 5, -999999996]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000, -1000000000]) == 1000000000\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\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 1540\n assert candidate(nums = [524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 524288\n assert candidate(nums = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18, 23, 21, 26, 24, 29, 27, 30, 25]) == 165\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 100\n assert candidate(nums = [10, 1, 11, 2, 12, 3, 13, 4, 14, 5]) == 18\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(nums = [0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 13]) == 36\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000]) == -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\n assert candidate(nums = [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, 1, -1, 1, -1, 1, -1]) == 1\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, 11, -12, 13, -14, 15]) == 64\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == 6\n assert candidate(nums = [5, 3, 5, 10, 15, 20, 25, 30, 35, 40]) == 183\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5]) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5]) == 17\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxBalancedSubsequenceSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxBalancedSubsequenceSum(int[] nums) {", "container": "Solution", "callable": "maxBalancedSubsequenceSum", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2928, "task_id": "distribute-candies-among-children-i", "difficulty": "Easy", "problem_description": "You are given two positive integers n and limit.\nReturn the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.\n \nExample 1:\n\nInput: n = 5, limit = 2\nOutput: 3\nExplanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1, 2, 2), (2, 1, 2) and (2, 2, 1).\n\nExample 2:\n\nInput: n = 3, limit = 3\nOutput: 10\nExplanation: There are 10 ways to distribute 3 candies such that no child gets more than 3 candies: (0, 0, 3), (0, 1, 2), (0, 2, 1), (0, 3, 0), (1, 0, 2), (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0) and (3, 0, 0).\n\n \nConstraints:\n\n1 <= n <= 50\n1 <= limit <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,limit = 5) == 21\n assert candidate(n = 3,limit = 3) == 10\n assert candidate(n = 5,limit = 2) == 3\n assert candidate(n = 4,limit = 2) == 6\n assert candidate(n = 7,limit = 3) == 6\n assert candidate(n = 4,limit = 4) == 15\n assert candidate(n = 25,limit = 10) == 21\n assert candidate(n = 1,limit = 1) == 3\n assert candidate(n = 20,limit = 10) == 66\n assert candidate(n = 20,limit = 15) == 186\n assert candidate(n = 50,limit = 50) == 1326\n assert candidate(n = 15,limit = 10) == 91\n assert candidate(n = 10,limit = 1) == 0\n assert candidate(n = 35,limit = 12) == 3\n assert candidate(n = 50,limit = 1) == 0\n assert candidate(n = 18,limit = 6) == 1\n assert candidate(n = 28,limit = 8) == 0\n assert candidate(n = 31,limit = 9) == 0\n assert candidate(n = 42,limit = 3) == 0\n assert candidate(n = 30,limit = 3) == 0\n assert candidate(n = 40,limit = 15) == 21\n assert candidate(n = 32,limit = 11) == 3\n assert candidate(n = 32,limit = 8) == 0\n assert candidate(n = 15,limit = 3) == 0\n assert candidate(n = 50,limit = 20) == 66\n assert candidate(n = 27,limit = 9) == 1\n assert candidate(n = 45,limit = 15) == 1\n assert candidate(n = 28,limit = 7) == 0\n assert candidate(n = 30,limit = 5) == 0\n assert candidate(n = 33,limit = 8) == 0\n assert candidate(n = 15,limit = 7) == 28\n assert candidate(n = 50,limit = 25) == 351\n assert candidate(n = 22,limit = 7) == 0\n assert candidate(n = 37,limit = 18) == 171\n assert candidate(n = 30,limit = 8) == 0\n assert candidate(n = 49,limit = 17) == 6\n assert candidate(n = 40,limit = 20) == 231\n assert candidate(n = 10,limit = 2) == 0\n assert candidate(n = 38,limit = 19) == 210\n assert candidate(n = 33,limit = 6) == 0\n assert candidate(n = 49,limit = 25) == 375\n assert candidate(n = 30,limit = 12) == 28\n assert candidate(n = 35,limit = 8) == 0\n assert candidate(n = 42,limit = 12) == 0\n assert candidate(n = 30,limit = 10) == 1\n assert candidate(n = 50,limit = 10) == 0\n assert candidate(n = 49,limit = 16) == 0\n assert candidate(n = 30,limit = 20) == 331\n assert candidate(n = 45,limit = 20) == 136\n assert candidate(n = 48,limit = 16) == 1\n assert candidate(n = 49,limit = 14) == 0\n assert candidate(n = 10,limit = 3) == 0\n assert candidate(n = 28,limit = 10) == 6\n assert candidate(n = 15,limit = 5) == 1\n assert candidate(n = 40,limit = 5) == 0\n assert candidate(n = 15,limit = 4) == 0\n assert candidate(n = 35,limit = 10) == 0\n assert candidate(n = 10,limit = 4) == 6\n assert candidate(n = 33,limit = 11) == 1\n assert candidate(n = 49,limit = 18) == 21\n assert candidate(n = 27,limit = 10) == 10\n assert candidate(n = 10,limit = 20) == 66\n assert candidate(n = 22,limit = 11) == 78\n assert candidate(n = 27,limit = 8) == 0\n assert candidate(n = 35,limit = 7) == 0\n assert candidate(n = 10,limit = 10) == 66\n assert candidate(n = 42,limit = 21) == 253\n assert candidate(n = 42,limit = 9) == 0\n assert candidate(n = 49,limit = 20) == 78\n assert candidate(n = 20,limit = 2) == 0\n assert candidate(n = 35,limit = 20) == 306\n"}, "metadata": {"canonical_parameter_names": ["n", "limit"], "leetcode_dataset_entry_point": "Solution().distributeCandies", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int distributeCandies(int n, int limit) {", "container": "Solution", "callable": "distributeCandies", "parameters": [{"name": "n", "type": "int"}, {"name": "limit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2929, "task_id": "distribute-candies-among-children-ii", "difficulty": "Medium", "problem_description": "You are given two positive integers n and limit.\nReturn the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.\n \nExample 1:\n\nInput: n = 5, limit = 2\nOutput: 3\nExplanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1, 2, 2), (2, 1, 2) and (2, 2, 1).\n\nExample 2:\n\nInput: n = 3, limit = 3\nOutput: 10\nExplanation: There are 10 ways to distribute 3 candies such that no child gets more than 3 candies: (0, 0, 3), (0, 1, 2), (0, 2, 1), (0, 3, 0), (1, 0, 2), (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0) and (3, 0, 0).\n\n \nConstraints:\n\n1 <= n <= 106\n1 <= limit <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,limit = 7) == 36\n assert candidate(n = 1000000,limit = 1000000) == 500001500001\n assert candidate(n = 10,limit = 5) == 21\n assert candidate(n = 3,limit = 3) == 10\n assert candidate(n = 5,limit = 2) == 3\n assert candidate(n = 100,limit = 10) == 0\n assert candidate(n = 1000000,limit = 1) == 0\n assert candidate(n = 7,limit = 3) == 6\n assert candidate(n = 1,limit = 1) == 3\n assert candidate(n = 7,limit = 10) == 36\n assert candidate(n = 100,limit = 50) == 1326\n assert candidate(n = 10000,limit = 500) == 0\n assert candidate(n = 150,limit = 20) == 0\n assert candidate(n = 20,limit = 10) == 66\n assert candidate(n = 1000,limit = 50) == 0\n assert candidate(n = 100000,limit = 1000) == 0\n assert candidate(n = 123456,limit = 123456) == 7620877153\n assert candidate(n = 123,limit = 45) == 91\n assert candidate(n = 123456,limit = 45678) == 92201410\n assert candidate(n = 10000,limit = 1000) == 0\n assert candidate(n = 25,limit = 10) == 21\n assert candidate(n = 30,limit = 15) == 136\n assert candidate(n = 20,limit = 7) == 3\n assert candidate(n = 1000,limit = 30) == 0\n assert candidate(n = 75,limit = 35) == 496\n assert candidate(n = 80,limit = 40) == 861\n assert candidate(n = 9,limit = 3) == 1\n assert candidate(n = 15,limit = 4) == 0\n assert candidate(n = 2000,limit = 500) == 0\n assert candidate(n = 1000000,limit = 500000) == 125000750001\n assert candidate(n = 20,limit = 4) == 0\n assert candidate(n = 456,limit = 123) == 0\n assert candidate(n = 999999,limit = 100000) == 0\n assert candidate(n = 789,limit = 234) == 0\n assert candidate(n = 1000,limit = 100) == 0\n assert candidate(n = 12345,limit = 3456) == 0\n assert candidate(n = 10000,limit = 5000) == 12507501\n assert candidate(n = 500000,limit = 250000) == 31250375001\n assert candidate(n = 1000000,limit = 1000) == 0\n assert candidate(n = 999999,limit = 1000000) == 500000500000\n assert candidate(n = 20,limit = 3) == 0\n assert candidate(n = 5000,limit = 50) == 0\n assert candidate(n = 25,limit = 7) == 0\n assert candidate(n = 9,limit = 2) == 0\n assert candidate(n = 150,limit = 15) == 0\n assert candidate(n = 1000,limit = 25) == 0\n assert candidate(n = 30,limit = 30) == 496\n assert candidate(n = 800,limit = 200) == 0\n assert candidate(n = 8,limit = 8) == 45\n assert candidate(n = 999999,limit = 333333) == 1\n assert candidate(n = 50,limit = 20) == 66\n assert candidate(n = 789012,limit = 12345) == 0\n assert candidate(n = 500,limit = 10) == 0\n assert candidate(n = 20,limit = 5) == 0\n assert candidate(n = 500000,limit = 100000) == 0\n assert candidate(n = 999999,limit = 999999) == 500000500000\n assert candidate(n = 500000,limit = 1000) == 0\n assert candidate(n = 300000,limit = 1000) == 0\n assert candidate(n = 75,limit = 20) == 0\n assert candidate(n = 50,limit = 15) == 0\n assert candidate(n = 250,limit = 25) == 0\n assert candidate(n = 15,limit = 5) == 1\n assert candidate(n = 12,limit = 6) == 28\n assert candidate(n = 1000,limit = 20) == 0\n assert candidate(n = 9,limit = 4) == 10\n assert candidate(n = 5000,limit = 2000) == 501501\n assert candidate(n = 100000,limit = 300) == 0\n assert candidate(n = 75,limit = 25) == 1\n assert candidate(n = 500000,limit = 150000) == 0\n assert candidate(n = 500,limit = 200) == 5151\n assert candidate(n = 999,limit = 100) == 0\n assert candidate(n = 10000,limit = 50) == 0\n assert candidate(n = 100000,limit = 50000) == 1250075001\n assert candidate(n = 6,limit = 2) == 1\n assert candidate(n = 500000,limit = 5000) == 0\n assert candidate(n = 6,limit = 1) == 0\n assert candidate(n = 1000,limit = 1000) == 501501\n assert candidate(n = 200,limit = 50) == 0\n assert candidate(n = 200,limit = 20) == 0\n assert candidate(n = 67890,limit = 1000) == 0\n assert candidate(n = 1000,limit = 500) == 125751\n assert candidate(n = 30,limit = 10) == 1\n assert candidate(n = 50,limit = 10) == 0\n assert candidate(n = 999,limit = 333) == 1\n assert candidate(n = 25,limit = 5) == 0\n assert candidate(n = 100000,limit = 30000) == 0\n assert candidate(n = 5000,limit = 200) == 0\n assert candidate(n = 100,limit = 30) == 0\n assert candidate(n = 500,limit = 5) == 0\n assert candidate(n = 10,limit = 1) == 0\n"}, "metadata": {"canonical_parameter_names": ["n", "limit"], "leetcode_dataset_entry_point": "Solution().distributeCandies", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long distributeCandies(int n, int limit) {", "container": "Solution", "callable": "distributeCandies", "parameters": [{"name": "n", "type": "int"}, {"name": "limit", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2930, "task_id": "number-of-strings-which-can-be-rearranged-to-contain-substring", "difficulty": "Medium", "problem_description": "You are given an integer n.\nA string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s such that the new string contains \"leet\" as a substring.\nFor example:\n\nThe string \"lteer\" is good because we can rearrange it to form \"leetr\" .\n\"letl\" is not good because we cannot rearrange it to contain \"leet\" as a substring.\n\nReturn the total number of good strings of length n.\nSince the answer may be large, return it modulo 109 + 7.\nA substring is a contiguous sequence of characters within a string.\n \n \nExample 1:\n\nInput: n = 4\nOutput: 12\nExplanation: The 12 strings which can be rearranged to have \"leet\" as a substring are: \"eelt\", \"eetl\", \"elet\", \"elte\", \"etel\", \"etle\", \"leet\", \"lete\", \"ltee\", \"teel\", \"tele\", and \"tlee\".\n\nExample 2:\n\nInput: n = 10\nOutput: 83943898\nExplanation: The number of strings with length 10 which can be rearranged to have \"leet\" as a substring is 526083947580. Hence the answer is 526083947580 % (109 + 7) = 83943898.\n\n \nConstraints:\n\n1 <= n <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4) == 12\n assert candidate(n = 1) == 0\n assert candidate(n = 10) == 83943898\n assert candidate(n = 5) == 1460\n assert candidate(n = 3) == 0\n assert candidate(n = 125) == 558399309\n assert candidate(n = 100) == 86731066\n assert candidate(n = 50) == 232825199\n assert candidate(n = 30) == 52805056\n assert candidate(n = 2) == 0\n assert candidate(n = 80) == 974106352\n assert candidate(n = 8) == 295164156\n assert candidate(n = 250) == 889526859\n assert candidate(n = 75) == 842828500\n assert candidate(n = 20) == 291395991\n assert candidate(n = 15) == 430509685\n assert candidate(n = 9) == 947613240\n assert candidate(n = 6) == 106620\n assert candidate(n = 7) == 6058192\n assert candidate(n = 90) == 122933939\n assert candidate(n = 25) == 935610434\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().stringCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int stringCount(int n) {", "container": "Solution", "callable": "stringCount", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2931, "task_id": "maximum-spending-after-buying-items", "difficulty": "Hard", "problem_description": "You are given a 0-indexed m * n integer matrix values, representing the values of m * n different items in m different shops. Each shop has n items where the jth item in the ith shop has a value of values[i][j]. Additionally, the items in the ith shop are sorted in non-increasing order of value. That is, values[i][j] >= values[i][j + 1] for all 0 <= j < n - 1.\nOn each day, you would like to buy a single item from one of the shops. Specifically, On the dth day you can:\n\nPick any shop i.\nBuy the rightmost available item j for the price of values[i][j] * d. That is, find the greatest index j such that item j was never bought before, and buy it for the price of values[i][j] * d.\n\nNote that all items are pairwise different. For example, if you have bought item 0 from shop 1, you can still buy item 0 from any other shop.\nReturn the maximum amount of money that can be spent on buying all m * n products.\n \nExample 1:\n\nInput: values = [[8,5,2],[6,4,1],[9,7,3]]\nOutput: 285\nExplanation: On the first day, we buy product 2 from shop 1 for a price of values[1][2] * 1 = 1.\nOn the second day, we buy product 2 from shop 0 for a price of values[0][2] * 2 = 4.\nOn the third day, we buy product 2 from shop 2 for a price of values[2][2] * 3 = 9.\nOn the fourth day, we buy product 1 from shop 1 for a price of values[1][1] * 4 = 16.\nOn the fifth day, we buy product 1 from shop 0 for a price of values[0][1] * 5 = 25.\nOn the sixth day, we buy product 0 from shop 1 for a price of values[1][0] * 6 = 36.\nOn the seventh day, we buy product 1 from shop 2 for a price of values[2][1] * 7 = 49.\nOn the eighth day, we buy product 0 from shop 0 for a price of values[0][0] * 8 = 64.\nOn the ninth day, we buy product 0 from shop 2 for a price of values[2][0] * 9 = 81.\nHence, our total spending is equal to 285.\nIt can be shown that 285 is the maximum amount of money that can be spent buying all m * n products. \n\nExample 2:\n\nInput: values = [[10,8,6,4,2],[9,7,5,3,2]]\nOutput: 386\nExplanation: On the first day, we buy product 4 from shop 0 for a price of values[0][4] * 1 = 2.\nOn the second day, we buy product 4 from shop 1 for a price of values[1][4] * 2 = 4.\nOn the third day, we buy product 3 from shop 1 for a price of values[1][3] * 3 = 9.\nOn the fourth day, we buy product 3 from shop 0 for a price of values[0][3] * 4 = 16.\nOn the fifth day, we buy product 2 from shop 1 for a price of values[1][2] * 5 = 25.\nOn the sixth day, we buy product 2 from shop 0 for a price of values[0][2] * 6 = 36.\nOn the seventh day, we buy product 1 from shop 1 for a price of values[1][1] * 7 = 49.\nOn the eighth day, we buy product 1 from shop 0 for a price of values[0][1] * 8 = 64\nOn the ninth day, we buy product 0 from shop 1 for a price of values[1][0] * 9 = 81.\nOn the tenth day, we buy product 0 from shop 0 for a price of values[0][0] * 10 = 100.\nHence, our total spending is equal to 386.\nIt can be shown that 386 is the maximum amount of money that can be spent buying all m * n products.\n\n \nConstraints:\n\n1 <= m == values.length <= 10\n1 <= n == values[i].length <= 104\n1 <= values[i][j] <= 106\nvalues[i] are sorted in non-increasing order.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(values = [[10, 8, 6, 4, 2], [9, 7, 5, 3, 2]]) == 386\n assert candidate(values = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 78\n assert candidate(values = [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]) == 55\n assert candidate(values = [[1000000], [999999], [999998], [999997]]) == 9999990\n assert candidate(values = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 1485\n assert candidate(values = [[10], [20], [30], [40], [50]]) == 550\n assert candidate(values = [[1000000, 999999, 999998], [999997, 999996, 999995]]) == 20999965\n assert candidate(values = [[8, 5, 2], [6, 4, 1], [9, 7, 3]]) == 285\n assert candidate(values = [[5, 4, 3], [2, 1, 1]]) == 71\n assert candidate(values = [[5, 3, 1], [6, 4, 2], [7, 5, 3]]) == 222\n assert candidate(values = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 1155\n assert candidate(values = [[1000000, 999999, 999998], [1000000, 999999, 999998], [1000000, 999999, 999998]]) == 44999973\n assert candidate(values = [[5, 4, 3], [2, 1, 0]]) == 70\n assert candidate(values = [[100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000]]) == 32500000\n assert candidate(values = [[100, 50, 25, 10, 5], [200, 150, 75, 20, 10], [50, 25, 10, 5, 1], [400, 300, 150, 40, 20]]) == 27441\n assert candidate(values = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [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]]) == 4247\n assert candidate(values = [[15, 12, 9, 6, 3], [14, 11, 8, 5, 2], [13, 10, 7, 4, 1]]) == 1240\n assert candidate(values = [[6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 8155\n assert candidate(values = [[5, 4, 3, 2, 1], [15, 14, 13, 12, 11], [25, 24, 23, 22, 21], [35, 34, 33, 32, 31], [45, 44, 43, 42, 41]]) == 10025\n assert candidate(values = [[20, 15, 10, 5], [15, 10, 5, 0], [10, 5, 0, 0], [5, 0, 0, 0], [0, 0, 0, 0]]) == 1685\n assert candidate(values = [[20, 15, 10, 5], [30, 25, 20, 15], [40, 35, 30, 25]]) == 2160\n assert candidate(values = [[1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]]) == 54999835\n assert candidate(values = [[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]]) == 1225\n assert candidate(values = [[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, 2, 4, 6, 8, 10]]) == 2550\n assert candidate(values = [[1000, 900, 800, 700, 600, 500, 400, 300, 200, 100], [950, 850, 750, 650, 550, 450, 350, 250, 150, 50], [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]]) == 454750\n assert candidate(values = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1953\n assert candidate(values = [[1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1]]) == 37999973\n assert candidate(values = [[1000000], [999999], [999998], [999997], [999996], [999995], [999994], [999993], [999992], [999991]]) == 54999835\n assert candidate(values = [[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]]) == 5425\n assert candidate(values = [[20, 18, 16, 14, 12], [19, 17, 15, 13, 11], [21, 19, 17, 15, 13], [22, 20, 18, 16, 14]]) == 3814\n assert candidate(values = [[20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 2870\n assert candidate(values = [[3, 2, 1], [6, 5, 4], [9, 8, 7]]) == 285\n assert candidate(values = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]]) == 7800\n assert candidate(values = [[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]]) == 7745\n assert candidate(values = [[1000, 500, 100], [900, 400, 90], [800, 300, 80], [700, 200, 70], [600, 100, 60]]) == 67300\n assert candidate(values = [[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], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 2520\n assert candidate(values = [[8, 6, 4, 2, 1], [10, 8, 6, 4, 2], [9, 7, 5, 3, 2]]) == 793\n assert candidate(values = [[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], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 19150\n assert candidate(values = [[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, 2, 4, 6, 8, 10]]) == 2550\n assert candidate(values = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1176\n assert candidate(values = [[1000000, 500000, 250000, 125000, 62500], [100000, 50000, 25000, 12500, 6250], [1000, 500, 250, 125, 62]]) == 29258062\n assert candidate(values = [[30, 20, 10], [25, 15, 5], [20, 10, 0]]) == 885\n assert candidate(values = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [11, 9, 7, 5, 3], [10, 8, 6, 4, 2]]) == 1504\n assert candidate(values = [[1000000, 999998, 999996], [999999, 999997, 999995], [999994, 999992, 999990]]) == 44999876\n assert candidate(values = [[5, 3, 1], [10, 8, 6], [15, 13, 11]]) == 462\n assert candidate(values = [[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]]) == 1979\n assert candidate(values = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 6, 7, 8, 9, 1, 2, 3, 4, 10], [10, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 10, 1, 2, 3, 4, 5, 6, 7, 8], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]]) == 11080\n assert candidate(values = [[1000, 500, 250, 125, 62, 31, 15, 7, 3, 1], [900, 450, 225, 112, 56, 28, 14, 7, 3, 1], [800, 400, 200, 100, 50, 25, 12, 6, 3, 1]]) == 140756\n assert candidate(values = [[100000, 90000, 80000, 70000, 60000], [100000, 90000, 80000, 70000, 60000], [100000, 90000, 80000, 70000, 60000], [100000, 90000, 80000, 70000, 60000]]) == 18400000\n assert candidate(values = [[30, 25, 20, 15, 10], [28, 23, 18, 13, 8], [26, 21, 16, 11, 6]]) == 2630\n assert candidate(values = [[8, 7, 6, 5, 4, 3, 2, 1], [7, 6, 5, 4, 3, 2, 1, 0], [6, 5, 4, 3, 2, 1, 0, -1]]) == 1451\n assert candidate(values = [[50, 40, 30, 20, 10], [45, 35, 25, 15, 5], [40, 30, 20, 10, 0]]) == 3950\n assert candidate(values = [[7, 5, 3, 1], [8, 6, 4, 2], [9, 7, 5, 3], [10, 8, 6, 4], [11, 9, 7, 5]]) == 1562\n assert candidate(values = [[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]]) == 2775\n assert candidate(values = [[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, 2, 4, 6, 8, 10], [10, 8, 6, 4, 2, 1, 3, 5, 7, 9]]) == 4650\n assert candidate(values = [[500, 400, 300], [450, 350, 250], [600, 500, 400], [350, 250, 150]]) == 34200\n assert candidate(values = [[100, 90, 80, 70, 60], [95, 85, 75, 65, 55], [90, 80, 70, 60, 50], [85, 75, 65, 55, 45]]) == 16970\n assert candidate(values = [[10, 8, 6, 4, 2, 0], [9, 7, 5, 3, 1, 0], [8, 6, 4, 2, 0, 0], [7, 5, 3, 1, 0, 0], [6, 4, 2, 0, 0, 0]]) == 2385\n assert candidate(values = [[800, 700, 600, 500], [750, 650, 550, 450], [900, 800, 700, 600], [600, 500, 400, 300]]) == 94600\n assert candidate(values = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [7, 5, 3, 1, 0], [6, 4, 2, 0, 0], [5, 3, 1, 0, 0], [4, 2, 0, 0, 0]]) == 2048\n assert candidate(values = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]]) == 8285\n assert candidate(values = [[15, 10, 5, 1], [14, 9, 4, 1], [13, 8, 3, 1], [12, 7, 2, 1], [11, 6, 1, 1], [10, 5, 1, 1], [9, 4, 1, 1], [8, 3, 1, 1], [7, 2, 1, 1], [6, 1, 1, 1]]) == 5735\n assert candidate(values = [[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]]) == 10100\n assert candidate(values = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [10, 8, 6, 4, 2]]) == 790\n assert candidate(values = [[123456, 111111, 100000], [98765, 87654, 76543], [65432, 54321, 43210], [32109, 21098, 10987]]) == 6816158\n assert candidate(values = [[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]]) == 1225\n assert candidate(values = [[999999, 999998, 999997], [999996, 999995, 999994], [999993, 999992, 999991], [999990, 999989, 999988], [999987, 999986, 999985]]) == 119999320\n assert candidate(values = [[1000000, 999999, 999998, 999997, 999996], [999995, 999994, 999993, 999992, 999991], [999990, 999989, 999988, 999987, 999986]]) == 119999440\n assert candidate(values = [[5, 3, 1], [4, 2, 0], [6, 4, 2], [7, 5, 3]]) == 354\n assert candidate(values = [[9, 7, 5], [8, 6, 4], [7, 5, 3], [6, 4, 2], [5, 3, 1], [4, 2, 0], [3, 1, -1], [2, 0, -2], [1, -1, -3]]) == 1770\n assert candidate(values = [[8, 5, 2, 1], [6, 4, 1, 0], [9, 7, 3, 2]]) == 429\n assert candidate(values = [[20, 18, 16, 14, 12], [19, 17, 15, 13, 11], [21, 19, 17, 15, 13]]) == 2110\n assert candidate(values = [[10, 9, 8, 7, 6, 5], [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]]) == 4219\n assert candidate(values = [[8, 6, 4, 2, 1], [7, 5, 3, 2, 1], [9, 8, 7, 6, 5], [10, 9, 8, 7, 6]]) == 1501\n assert candidate(values = [[100, 90, 80, 70, 60], [50, 40, 30, 20, 10], [95, 85, 75, 65, 55], [45, 35, 25, 15, 5]]) == 14350\n assert candidate(values = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 955\n assert candidate(values = [[50, 45, 40, 35, 30, 25, 20, 15, 10, 5], [48, 43, 38, 33, 28, 23, 18, 13, 8, 3], [46, 41, 36, 31, 26, 21, 16, 11, 6, 1]]) == 15610\n assert candidate(values = [[1000000], [999999], [999998], [999997], [999996], [999995], [999994], [999993], [999992], [999991]]) == 54999835\n assert candidate(values = [[10000, 9000, 8000, 7000, 6000], [9000, 8000, 7000, 6000, 5000], [8000, 7000, 6000, 5000, 4000], [7000, 6000, 5000, 4000, 3000], [6000, 5000, 4000, 3000, 2000]]) == 2304000\n assert candidate(values = [[5, 4, 3, 2, 1], [10, 9, 8, 7, 6], [15, 14, 13, 12, 11], [20, 19, 18, 17, 16], [25, 24, 23, 22, 21]]) == 5525\n assert candidate(values = [[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]]) == 3250\n assert candidate(values = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, 0]]) == 2865\n assert candidate(values = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15]]) == 1240\n assert candidate(values = [[100, 90, 80, 70, 60], [50, 45, 40, 35, 30], [20, 15, 10, 5, 0]]) == 7150\n assert candidate(values = [[50, 40, 30, 20, 10], [90, 80, 70, 60, 50], [130, 120, 110, 100, 90], [170, 160, 150, 140, 130]]) == 24300\n assert candidate(values = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, 0], [7, 6, 5, 4, 3, 2, 1, 0, 0, 0], [6, 5, 4, 3, 2, 1, 0, 0, 0, 0]]) == 6782\n assert candidate(values = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [7, 5, 3, 1, 0], [6, 4, 2, 0, 0]]) == 1088\n assert candidate(values = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [30, 29, 28, 27, 26, 25, 24, 23, 22, 21]]) == 9455\n assert candidate(values = [[1000, 500, 250, 125, 62], [500, 250, 125, 62, 31], [250, 125, 62, 31, 15], [125, 62, 31, 15, 7], [62, 31, 15, 7, 3]]) == 78347\n assert candidate(values = [[9, 8, 7], [6, 5, 4], [3, 2, 1], [9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 1095\n assert candidate(values = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, -1]]) == 2864\n assert candidate(values = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, 0], [2, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 707\n assert candidate(values = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, 0], [7, 6, 5, 4, 3, 2, 1, 0, 0, 0], [6, 5, 4, 3, 2, 1, 0, 0, 0, 0], [5, 4, 3, 2, 1, 0, 0, 0, 0, 0], [4, 3, 2, 1, 0, 0, 0, 0, 0, 0], [3, 2, 1, 0, 0, 0, 0, 0, 0, 0], [2, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 18139\n assert candidate(values = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1], [8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2]]) == 3266\n assert candidate(values = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 6225\n assert candidate(values = [[5, 4, 3, 2, 1], [5, 4, 3, 2, 1], [5, 4, 3, 2, 1], [5, 4, 3, 2, 1]]) == 790\n assert candidate(values = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [7, 5, 3, 1, 0], [6, 4, 2, 0, 0], [5, 3, 1, 0, 0], [4, 2, 0, 0, 0], [3, 1, 0, 0, 0], [2, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 4016\n"}, "metadata": {"canonical_parameter_names": ["values"], "leetcode_dataset_entry_point": "Solution().maxSpending", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long maxSpending(int[][] values) {", "container": "Solution", "callable": "maxSpending", "parameters": [{"name": "values", "type": "int[][]"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2932, "task_id": "maximum-strong-pair-xor-i", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:\n\n|x - y| <= min(x, y)\n\nYou need to select two integers from nums such that they form a strong pair and their bitwise XOR is the maximum among all strong pairs in the array.\nReturn the maximum XOR value out of all possible strong pairs in the array nums.\nNote that you can pick the same integer twice to form a pair.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5]\nOutput: 7\nExplanation: There are 11 strong pairs in the array nums: (1, 1), (1, 2), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (3, 5), (4, 4), (4, 5) and (5, 5).\nThe maximum XOR possible from these pairs is 3 XOR 4 = 7.\n\nExample 2:\n\nInput: nums = [10,100]\nOutput: 0\nExplanation: There are 2 strong pairs in the array nums: (10, 10) and (100, 100).\nThe maximum XOR possible from these pairs is 10 XOR 10 = 0 since the pair (100, 100) also gives 100 XOR 100 = 0.\n\nExample 3:\n\nInput: nums = [5,6,25,30]\nOutput: 7\nExplanation: There are 6 strong pairs in the array nums: (5, 5), (5, 6), (6, 6), (25, 25), (25, 30) and (30, 30).\nThe maximum XOR possible from these pairs is 25 XOR 30 = 7 since the only other non-zero XOR value is 5 XOR 6 = 3.\n\n \nConstraints:\n\n1 <= nums.length <= 50\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [15, 25, 35, 45, 55]) == 58\n assert candidate(nums = [2, 4, 6, 8, 10, 12]) == 14\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 4, 8, 16]) == 24\n assert candidate(nums = [2, 2, 4, 4, 6, 6]) == 6\n assert candidate(nums = [3, 5, 7, 9, 11]) == 14\n assert candidate(nums = [99, 98, 97, 96, 95]) == 63\n assert candidate(nums = [2, 4, 6, 8, 10]) == 14\n assert candidate(nums = [1, 3, 5, 7, 9]) == 14\n assert candidate(nums = [100]) == 0\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50]) == 60\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 122\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 14\n assert candidate(nums = [100, 90, 80, 70, 60]) == 122\n assert candidate(nums = [100, 200, 300, 400, 500]) == 484\n assert candidate(nums = [10, 100]) == 0\n assert candidate(nums = [5, 6, 25, 30]) == 7\n assert candidate(nums = [7, 14, 21, 28, 35]) == 63\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 48\n assert candidate(nums = [15, 30, 45, 60, 75]) == 119\n assert candidate(nums = [50, 40, 30, 20, 10]) == 60\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35]) == 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]) == 125\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 126\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 768\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420]) == 504\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310, 341, 372, 403, 434, 465, 496, 527, 558, 589, 620]) == 1023\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231]) == 231\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310]) == 495\n assert candidate(nums = [7, 77, 777, 7777, 77777, 777777, 7777777]) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91]) == 126\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 968\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]) == 0\n assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21]) == 15\n assert candidate(nums = [23, 45, 67, 89, 111, 133, 155, 177, 199, 221]) == 244\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 63\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64]) == 96\n assert candidate(nums = [99, 1, 49, 50, 98, 51]) == 83\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 288, 384, 480, 576, 672, 768, 864, 960, 1056, 1152, 1248, 1344, 1440]) == 2016\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80]) == 120\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1]) == 61\n assert candidate(nums = [100, 99, 98, 97, 96, 95]) == 63\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 0\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 255\n assert candidate(nums = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001, 1101, 1201, 1301, 1401, 1501, 1601, 1701, 1801, 1901]) == 1992\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == 0\n assert candidate(nums = [1, 10, 20, 30, 40, 50]) == 60\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 6144\n assert candidate(nums = [128, 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920]) == 1920\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 61\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130]) == 247\n assert candidate(nums = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 250\n assert candidate(nums = [4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196]) == 244\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == 63\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 15\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512]) == 768\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]) == 31\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 62\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 7\n assert candidate(nums = [1, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 61\n assert candidate(nums = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67]) == 126\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901]) == 1023\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == 192\n assert candidate(nums = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999]) == 984\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 63\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225]) == 255\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 124\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == 253\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 122\n assert candidate(nums = [88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == 63\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 63\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64, 69, 74, 79, 84, 89, 94, 99]) == 126\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]) == 248\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 7\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 968\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 24576\n assert candidate(nums = [3, 5, 8, 13, 21, 34, 55, 89, 144, 233]) == 201\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 110\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 124\n assert candidate(nums = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901]) == 968\n assert candidate(nums = [8, 15, 23, 42, 55, 60, 62, 71]) == 123\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 0\n assert candidate(nums = [50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400]) == 498\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 96, 128]) == 224\n assert candidate(nums = [50, 49, 48, 47, 46, 45]) == 31\n assert candidate(nums = [63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 24576\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [123, 456, 789, 1011, 1314, 1617, 1918, 2221, 2520, 2829]) == 4051\n assert candidate(nums = [8, 10, 14, 15, 20, 22, 25]) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 250\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512]) == 768\n assert candidate(nums = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95]) == 63\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999]) == 0\n assert candidate(nums = [2, 18, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == 125\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 122\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 98304\n assert candidate(nums = [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 = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 126\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 125\n assert candidate(nums = [8, 4, 2, 1, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 3072\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]) == 127\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 126\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1]) == 192\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == 0\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79]) == 124\n assert candidate(nums = [100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 250\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108]) == 120\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 61\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 122\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985]) == 63\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072]) == 3840\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 63\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]) == 510\n assert candidate(nums = [5, 25, 50, 75, 100, 125, 150, 175, 200]) == 242\n assert candidate(nums = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 63\n assert candidate(nums = [31, 61, 91, 121, 151, 181, 211, 241, 271, 301]) == 510\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 250\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 63\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]) == 124\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840]) == 1008\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumStrongPairXor", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumStrongPairXor(int[] nums) {", "container": "Solution", "callable": "maximumStrongPairXor", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2933, "task_id": "high-access-employees", "difficulty": "Medium", "problem_description": "You are given a 2D 0-indexed array of strings, access_times, with size n. For each i where 0 <= i <= n - 1, access_times[i][0] represents the name of an employee, and access_times[i][1] represents the access time of that employee. All entries in access_times are within the same day.\nThe access time is represented as four digits using a 24-hour time format, for example, \"0800\" or \"2250\".\nAn employee is said to be high-access if he has accessed the system three or more times within a one-hour period.\nTimes with exactly one hour of difference are not considered part of the same one-hour period. For example, \"0815\" and \"0915\" are not part of the same one-hour period.\nAccess times at the start and end of the day are not counted within the same one-hour period. For example, \"0005\" and \"2350\" are not part of the same one-hour period.\nReturn a list that contains the names of high-access employees with any order you want.\n \nExample 1:\n\nInput: access_times = [[\"a\",\"0549\"],[\"b\",\"0457\"],[\"a\",\"0532\"],[\"a\",\"0621\"],[\"b\",\"0540\"]]\nOutput: [\"a\"]\nExplanation: \"a\" has three access times in the one-hour period of [05:32, 06:31] which are 05:32, 05:49, and 06:21.\nBut \"b\" does not have more than two access times at all.\nSo the answer is [\"a\"].\nExample 2:\n\nInput: access_times = [[\"d\",\"0002\"],[\"c\",\"0808\"],[\"c\",\"0829\"],[\"e\",\"0215\"],[\"d\",\"1508\"],[\"d\",\"1444\"],[\"d\",\"1410\"],[\"c\",\"0809\"]]\nOutput: [\"c\",\"d\"]\nExplanation: \"c\" has three access times in the one-hour period of [08:08, 09:07] which are 08:08, 08:09, and 08:29.\n\"d\" has also three access times in the one-hour period of [14:10, 15:09] which are 14:10, 14:44, and 15:08.\nHowever, \"e\" has just one access time, so it can not be in the answer and the final answer is [\"c\",\"d\"].\nExample 3:\n\nInput: access_times = [[\"cd\",\"1025\"],[\"ab\",\"1025\"],[\"cd\",\"1046\"],[\"cd\",\"1055\"],[\"ab\",\"1124\"],[\"ab\",\"1120\"]]\nOutput: [\"ab\",\"cd\"]\nExplanation: \"ab\" has three access times in the one-hour period of [10:25, 11:24] which are 10:25, 11:20, and 11:24.\n\"cd\" has also three access times in the one-hour period of [10:25, 11:24] which are 10:25, 10:46, and 10:55.\nSo the answer is [\"ab\",\"cd\"].\n \nConstraints:\n\n1 <= access_times.length <= 100\naccess_times[i].length == 2\n1 <= access_times[i][0].length <= 10\naccess_times[i][0] consists only of English small letters.\naccess_times[i][1].length == 4\naccess_times[i][1] is in 24-hour time format.\naccess_times[i][1] consists only of '0' to '9'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(access_times = [['z', '1200'], ['z', '1201'], ['z', '1202'], ['z', '1203']]) == ['z']\n assert candidate(access_times = [['r', '0100'], ['r', '0159'], ['r', '0130'], ['r', '0145']]) == ['r']\n assert candidate(access_times = [['x', '0001'], ['x', '0059'], ['x', '0100'], ['x', '0159'], ['x', '0200']]) == ['x']\n assert candidate(access_times = [['m', '0001'], ['m', '2359'], ['m', '0002'], ['m', '2358']]) == []\n assert candidate(access_times = [['y', '1200'], ['y', '1201'], ['y', '1202'], ['y', '1300'], ['y', '1301'], ['y', '1302']]) == ['y']\n assert candidate(access_times = [['a', '0001'], ['a', '0002'], ['a', '2359'], ['b', '0100'], ['b', '0101'], ['b', '0102']]) == ['b']\n assert candidate(access_times = [['z', '2300'], ['z', '2359'], ['z', '0000'], ['z', '0059']]) == []\n assert candidate(access_times = [['a', '0549'], ['b', '0457'], ['a', '0532'], ['a', '0621'], ['b', '0540']]) == ['a']\n assert candidate(access_times = [['one', '1230'], ['two', '1231'], ['three', '1232'], ['four', '1233'], ['five', '1234']]) == []\n assert candidate(access_times = [['d', '0002'], ['c', '0808'], ['c', '0829'], ['e', '0215'], ['d', '1508'], ['d', '1444'], ['d', '1410'], ['c', '0809']]) == ['d', 'c']\n assert candidate(access_times = [['d', '0002'], ['c', '0808'], ['c', '0829'], ['e', '0215'], ['d', '1508'], ['d', '1444'], ['d', '1410'], ['c', '0809']]) == ['d', 'c']\n assert candidate(access_times = [['m', '1130'], ['m', '1131'], ['m', '1132'], ['m', '1230'], ['m', '1231'], ['m', '1232']]) == ['m']\n assert candidate(access_times = [['cd', '1025'], ['ab', '1025'], ['cd', '1046'], ['cd', '1055'], ['ab', '1124'], ['ab', '1120']]) == ['cd', 'ab']\n assert candidate(access_times = [['m', '0900'], ['n', '0901'], ['m', '0902'], ['m', '0903'], ['n', '0902']]) == ['m']\n assert candidate(access_times = [['x', '1200'], ['x', '1201'], ['x', '1202'], ['y', '1200'], ['y', '1201']]) == ['x']\n assert candidate(access_times = [['p', '1300'], ['q', '1400'], ['p', '1330'], ['p', '1315'], ['q', '1359']]) == ['p']\n assert candidate(access_times = [['a', '0549'], ['b', '0457'], ['a', '0532'], ['a', '0621'], ['b', '0540']]) == ['a']\n assert candidate(access_times = [['abc', '1000'], ['def', '1030'], ['ghi', '1100'], ['abc', '1001'], ['def', '1031'], ['ghi', '1101']]) == []\n assert candidate(access_times = [['u', '1300'], ['u', '1330'], ['u', '1400'], ['u', '1430'], ['u', '1500']]) == []\n assert candidate(access_times = [['user1', '1200'], ['user2', '1201'], ['user1', '1202'], ['user1', '1203'], ['user2', '1204']]) == ['user1']\n assert candidate(access_times = [['p', '0859'], ['p', '0900'], ['p', '0901'], ['p', '0959'], ['p', '1000']]) == ['p']\n assert candidate(access_times = [['v', '0900'], ['v', '0915'], ['v', '0930'], ['v', '0945'], ['v', '1000']]) == ['v']\n assert candidate(access_times = [['x', '0900'], ['y', '0930'], ['x', '0915'], ['x', '0945'], ['y', '0931']]) == ['x']\n assert candidate(access_times = [['single', '1000'], ['single', '1001'], ['single', '1002']]) == ['single']\n assert candidate(access_times = [['s', '1100'], ['s', '1100'], ['s', '1100'], ['t', '1100'], ['t', '1100']]) == ['s']\n assert candidate(access_times = [['q', '0001'], ['q', '2359'], ['r', '0002'], ['r', '0003']]) == []\n assert candidate(access_times = [['repeat', '0000'], ['repeat', '0000'], ['repeat', '0000']]) == ['repeat']\n assert candidate(access_times = [['x', '0900'], ['y', '0930'], ['x', '0901'], ['x', '0959'], ['y', '0931']]) == ['x']\n assert candidate(access_times = [['f', '0001'], ['g', '0002'], ['f', '0003'], ['g', '0004'], ['f', '0005'], ['g', '0006'], ['f', '0007'], ['g', '0008'], ['f', '0009'], ['g', '0010']]) == ['f', 'g']\n assert candidate(access_times = [['a', '0100'], ['a', '0159'], ['a', '0200'], ['a', '0259'], ['a', '0300'], ['a', '0359'], ['a', '0400'], ['a', '0459']]) == []\n assert candidate(access_times = [['z', '0001'], ['z', '0101'], ['z', '0201'], ['z', '0301'], ['z', '0401'], ['z', '0501'], ['z', '0601'], ['z', '0701'], ['z', '0801'], ['z', '0901'], ['z', '1001'], ['z', '1101'], ['z', '1201'], ['z', '1301'], ['z', '1401'], ['z', '1501'], ['z', '1601'], ['z', '1701'], ['z', '1801'], ['z', '1901'], ['z', '2001'], ['z', '2101'], ['z', '2201'], ['z', '2301']]) == []\n assert candidate(access_times = [['k', '1200'], ['k', '1230'], ['k', '1259'], ['k', '1300'], ['k', '1330'], ['k', '1359'], ['k', '1400'], ['k', '1430'], ['k', '1459']]) == ['k']\n assert candidate(access_times = [['c', '1200'], ['c', '1230'], ['c', '1300'], ['c', '1330'], ['c', '1400'], ['c', '1430'], ['c', '1500'], ['c', '1530']]) == []\n assert candidate(access_times = [['charlie', '1200'], ['charlie', '1201'], ['charlie', '1202'], ['charlie', '1203'], ['charlie', '1204'], ['charlie', '1205'], ['charlie', '1206'], ['charlie', '1207'], ['charlie', '1208'], ['charlie', '1209'], ['charlie', '1210'], ['charlie', '1211'], ['charlie', '1212'], ['charlie', '1213'], ['charlie', '1214'], ['charlie', '1215'], ['charlie', '1216'], ['charlie', '1217'], ['charlie', '1218'], ['charlie', '1219'], ['charlie', '1220'], ['charlie', '1221'], ['charlie', '1222'], ['charlie', '1223'], ['charlie', '1224'], ['charlie', '1225'], ['charlie', '1226'], ['charlie', '1227'], ['charlie', '1228'], ['charlie', '1229'], ['charlie', '1230']]) == ['charlie']\n assert candidate(access_times = [['tech', '1400'], ['tech', '1405'], ['tech', '1410'], ['tech', '1415'], ['tech', '1420'], ['tech', '1425'], ['tech', '1430'], ['tech', '1435'], ['tech', '1440'], ['tech', '1445'], ['tech', '1450']]) == ['tech']\n assert candidate(access_times = [['eve', '0001'], ['eve', '0030'], ['eve', '0059'], ['eve', '0100'], ['eve', '0101'], ['eve', '0130'], ['eve', '0159'], ['eve', '0200'], ['eve', '0201'], ['eve', '0230'], ['eve', '0259'], ['eve', '0300'], ['eve', '0301'], ['eve', '0330'], ['eve', '0359'], ['eve', '0400'], ['eve', '0401'], ['eve', '0430'], ['eve', '0459'], ['eve', '0500'], ['eve', '0501'], ['eve', '0530'], ['eve', '0559'], ['eve', '0600'], ['eve', '0601'], ['eve', '0630'], ['eve', '0659'], ['eve', '0700'], ['eve', '0701'], ['eve', '0730'], ['eve', '0759'], ['eve', '0800'], ['eve', '0801'], ['eve', '0830'], ['eve', '0859'], ['eve', '0900'], ['eve', '0901'], ['eve', '0930'], ['eve', '0959'], ['eve', '1000'], ['eve', '1001'], ['eve', '1030'], ['eve', '1059'], ['eve', '1100'], ['eve', '1101'], ['eve', '1130'], ['eve', '1159'], ['eve', '1200'], ['eve', '1201'], ['eve', '1230'], ['eve', '1259'], ['eve', '1300'], ['eve', '1301'], ['eve', '1330'], ['eve', '1359'], ['eve', '1400'], ['eve', '1401'], ['eve', '1430'], ['eve', '1459'], ['eve', '1500'], ['eve', '1501'], ['eve', '1530'], ['eve', '1559'], ['eve', '1600'], ['eve', '1601'], ['eve', '1630'], ['eve', '1659'], ['eve', '1700'], ['eve', '1701'], ['eve', '1730'], ['eve', '1759'], ['eve', '1800'], ['eve', '1801'], ['eve', '1830'], ['eve', '1859'], ['eve', '1900'], ['eve', '1901'], ['eve', '1930'], ['eve', '1959'], ['eve', '2000'], ['eve', '2001'], ['eve', '2030'], ['eve', '2059'], ['eve', '2100'], ['eve', '2101'], ['eve', '2130'], ['eve', '2159'], ['eve', '2200'], ['eve', '2201'], ['eve', '2230'], ['eve', '2259'], ['eve', '2300'], ['eve', '2301'], ['eve', '2330'], ['eve', '2359']]) == ['eve']\n assert candidate(access_times = [['h', '0100'], ['i', '0101'], ['h', '0102'], ['i', '0103'], ['h', '0104'], ['i', '0105'], ['h', '0106'], ['i', '0107'], ['h', '0108'], ['i', '0109']]) == ['h', 'i']\n assert candidate(access_times = [['r', '1100'], ['r', '1130'], ['r', '1200'], ['r', '1230'], ['r', '1300'], ['r', '1330'], ['r', '1400'], ['r', '1430'], ['r', '1500'], ['r', '1530']]) == []\n assert candidate(access_times = [['t', '0515'], ['t', '0545'], ['t', '0615'], ['t', '0645'], ['t', '0715'], ['t', '0745'], ['t', '0815'], ['t', '0845'], ['t', '0915'], ['t', '0945']]) == []\n assert candidate(access_times = [['m', '0500'], ['n', '0501'], ['m', '0502'], ['n', '0503'], ['m', '0504'], ['n', '0505'], ['m', '0506'], ['n', '0507'], ['m', '0508'], ['n', '0509']]) == ['m', 'n']\n assert candidate(access_times = [['tech', '0900'], ['tech', '0930'], ['tech', '1000'], ['tech', '1030'], ['tech', '1100'], ['tech', '1130'], ['tech', '1200'], ['tech', '1230'], ['tech', '1300'], ['tech', '1330'], ['tech', '1400'], ['tech', '1430'], ['tech', '1500'], ['tech', '1530'], ['tech', '1600'], ['tech', '1630']]) == []\n assert candidate(access_times = [['z', '1500'], ['z', '1530'], ['z', '1600'], ['z', '1630'], ['z', '1700'], ['z', '1730'], ['z', '1800'], ['z', '1830'], ['z', '1900']]) == []\n assert candidate(access_times = [['m', '1200'], ['m', '1205'], ['m', '1210'], ['n', '1215'], ['n', '1220'], ['n', '1225'], ['m', '1230'], ['m', '1235'], ['m', '1240'], ['n', '1245'], ['n', '1250'], ['n', '1255']]) == ['m', 'n']\n assert candidate(access_times = [['y', '1100'], ['y', '1159'], ['y', '1200'], ['y', '1259'], ['y', '1300'], ['y', '1359'], ['y', '1400'], ['y', '1459']]) == []\n assert candidate(access_times = [['eve', '1100'], ['eve', '1101'], ['eve', '1102'], ['eve', '1159'], ['eve', '1200'], ['eve', '1201'], ['eve', '1202'], ['eve', '1259']]) == ['eve']\n assert candidate(access_times = [['beta', '1400'], ['beta', '1401'], ['beta', '1402'], ['beta', '1403'], ['beta', '1404'], ['beta', '1405'], ['beta', '1406'], ['beta', '1407']]) == ['beta']\n assert candidate(access_times = [['s', '2200'], ['s', '2230'], ['s', '2300'], ['s', '2330'], ['s', '0000'], ['s', '0030'], ['s', '0100'], ['s', '0130'], ['s', '0200'], ['s', '0230']]) == []\n assert candidate(access_times = [['r', '1300'], ['r', '1330'], ['r', '1400'], ['r', '1430'], ['r', '1500'], ['r', '1530'], ['r', '1600'], ['r', '1630'], ['r', '1700']]) == []\n assert candidate(access_times = [['a', '0001'], ['a', '0059'], ['b', '0100'], ['b', '0159'], ['c', '0200'], ['c', '0259'], ['d', '0300'], ['d', '0359'], ['e', '0400'], ['e', '0459']]) == []\n assert candidate(access_times = [['x', '0001'], ['x', '0059'], ['x', '0100'], ['x', '0159'], ['x', '0200'], ['x', '0259'], ['x', '0300'], ['x', '0359']]) == ['x']\n assert candidate(access_times = [['a', '0100'], ['a', '0115'], ['a', '0130'], ['a', '0145'], ['a', '0200'], ['a', '0215'], ['a', '0230'], ['a', '0245']]) == ['a']\n assert candidate(access_times = [['x', '1200'], ['x', '1210'], ['x', '1220'], ['x', '1300'], ['x', '1310'], ['x', '1320'], ['y', '1330'], ['y', '1340'], ['y', '1350'], ['y', '1400'], ['y', '1410'], ['y', '1420']]) == ['x', 'y']\n assert candidate(access_times = [['charlie', '1010'], ['charlie', '1011'], ['delta', '1012'], ['charlie', '1013'], ['delta', '1014'], ['charlie', '1015'], ['delta', '1016'], ['charlie', '1017']]) == ['charlie', 'delta']\n assert candidate(access_times = [['hannah', '0810'], ['hannah', '0840'], ['hannah', '0910'], ['hannah', '0940'], ['hannah', '1010'], ['hannah', '1040'], ['hannah', '1110'], ['hannah', '1140'], ['hannah', '1210'], ['hannah', '1240'], ['hannah', '1310'], ['hannah', '1340'], ['hannah', '1410'], ['hannah', '1440'], ['hannah', '1510'], ['hannah', '1540'], ['hannah', '1610'], ['hannah', '1640'], ['hannah', '1710'], ['hannah', '1740'], ['hannah', '1810'], ['hannah', '1840'], ['hannah', '1910'], ['hannah', '1940'], ['hannah', '2010'], ['hannah', '2040'], ['hannah', '2110'], ['hannah', '2140'], ['hannah', '2210'], ['hannah', '2240'], ['hannah', '2310'], ['hannah', '2340'], ['hannah', '0010'], ['hannah', '0040'], ['hannah', '0110'], ['hannah', '0140'], ['hannah', '0210'], ['hannah', '0240'], ['hannah', '0310'], ['hannah', '0340'], ['hannah', '0410'], ['hannah', '0440'], ['hannah', '0510'], ['hannah', '0540'], ['hannah', '0610'], ['hannah', '0640'], ['hannah', '0710'], ['hannah', '0740'], ['hannah', '0810'], ['hannah', '0840'], ['hannah', '0910'], ['hannah', '0940']]) == ['hannah']\n assert candidate(access_times = [['d', '1400'], ['d', '1430'], ['d', '1500'], ['d', '1530'], ['d', '1600'], ['d', '1630'], ['d', '1700'], ['d', '1730']]) == []\n assert candidate(access_times = [['v', '0800'], ['w', '0801'], ['v', '0802'], ['w', '0803'], ['v', '0804'], ['w', '0805'], ['v', '0806'], ['w', '0807'], ['v', '0808'], ['w', '0809'], ['v', '0810'], ['w', '0811'], ['v', '0812'], ['w', '0813']]) == ['v', 'w']\n assert candidate(access_times = [['x', '0101'], ['y', '0102'], ['z', '0103'], ['x', '0104'], ['y', '0105'], ['z', '0106'], ['x', '0107'], ['y', '0108'], ['z', '0109']]) == ['x', 'y', 'z']\n assert candidate(access_times = [['alice', '0800'], ['bob', '0801'], ['alice', '0830'], ['bob', '0900'], ['alice', '0930'], ['bob', '0931'], ['alice', '1000'], ['bob', '1030']]) == []\n assert candidate(access_times = [['worker', '0859'], ['worker', '0900'], ['worker', '0901'], ['worker', '0959'], ['worker', '1000'], ['worker', '1001'], ['worker', '1059'], ['worker', '1100'], ['worker', '1101']]) == ['worker']\n assert candidate(access_times = [['v', '1100'], ['v', '1101'], ['v', '1102'], ['v', '1103'], ['v', '1104'], ['v', '1105'], ['v', '1106'], ['v', '1107'], ['v', '1108'], ['v', '1109'], ['v', '1110'], ['v', '1111'], ['v', '1112'], ['v', '1113'], ['v', '1114'], ['v', '1115'], ['v', '1116'], ['v', '1117'], ['v', '1118'], ['v', '1119']]) == ['v']\n assert candidate(access_times = [['w', '2359'], ['w', '2301'], ['x', '2358'], ['x', '0002'], ['y', '2357'], ['y', '0003'], ['z', '2356'], ['z', '0004']]) == []\n assert candidate(access_times = [['l', '0715'], ['m', '0716'], ['l', '0717'], ['m', '0718'], ['l', '0719'], ['m', '0720'], ['l', '0721'], ['m', '0722'], ['l', '0723'], ['m', '0724'], ['l', '0725'], ['m', '0726'], ['l', '0727'], ['m', '0728'], ['l', '0729'], ['m', '0730']]) == ['l', 'm']\n assert candidate(access_times = [['x', '0001'], ['y', '0002'], ['x', '0003'], ['y', '0004'], ['x', '0005'], ['y', '0006'], ['x', '0007'], ['y', '0008'], ['x', '0009'], ['y', '0010']]) == ['x', 'y']\n assert candidate(access_times = [['admin', '2300'], ['admin', '2305'], ['admin', '2310'], ['admin', '2315'], ['admin', '2320'], ['admin', '2325'], ['admin', '2330'], ['admin', '2335'], ['admin', '2340'], ['admin', '2345'], ['admin', '2350']]) == ['admin']\n assert candidate(access_times = [['b', '0800'], ['b', '0859'], ['b', '0900'], ['b', '0959'], ['b', '1000'], ['b', '1059'], ['b', '1100'], ['b', '1159']]) == []\n assert candidate(access_times = [['user1', '0900'], ['user1', '0901'], ['user1', '0902'], ['user2', '0903'], ['user2', '0904'], ['user2', '0905'], ['user1', '0906'], ['user1', '0907'], ['user1', '0908'], ['user2', '0909'], ['user2', '0910'], ['user2', '0911']]) == ['user1', 'user2']\n assert candidate(access_times = [['x', '1000'], ['x', '1010'], ['x', '1020'], ['x', '1030'], ['x', '1040'], ['x', '1050']]) == ['x']\n assert candidate(access_times = [['alice', '0800'], ['alice', '0805'], ['alice', '0810'], ['bob', '0900'], ['bob', '0905'], ['bob', '0910'], ['alice', '0915'], ['alice', '0920'], ['alice', '0925']]) == ['alice', 'bob']\n assert candidate(access_times = [['s', '2300'], ['s', '2330'], ['s', '2359'], ['s', '0001'], ['s', '0030'], ['s', '0100'], ['s', '0130'], ['s', '0200'], ['s', '0230']]) == ['s']\n assert candidate(access_times = [['x', '0915'], ['y', '0916'], ['x', '0917'], ['x', '0918'], ['y', '0919'], ['y', '0920'], ['x', '0921'], ['y', '0922'], ['x', '0923']]) == ['x', 'y']\n assert candidate(access_times = [['emp1', '0900'], ['emp2', '0901'], ['emp3', '0902'], ['emp1', '0903'], ['emp2', '0904'], ['emp3', '0905'], ['emp1', '0906'], ['emp2', '0907'], ['emp3', '0908'], ['emp1', '0909'], ['emp2', '0910'], ['emp3', '0911'], ['emp1', '0912']]) == ['emp1', 'emp2', 'emp3']\n assert candidate(access_times = [['u', '1200'], ['u', '1205'], ['u', '1210'], ['u', '1215'], ['u', '1220'], ['u', '1225'], ['u', '1230'], ['u', '1235'], ['u', '1240'], ['u', '1245'], ['u', '1250'], ['u', '1255'], ['u', '1300'], ['u', '1305']]) == ['u']\n assert candidate(access_times = [['z', '1345'], ['w', '1346'], ['z', '1347'], ['w', '1348'], ['z', '1349'], ['w', '1350'], ['z', '1351'], ['w', '1352'], ['z', '1353']]) == ['z', 'w']\n assert candidate(access_times = [['m', '1200'], ['n', '1210'], ['m', '1220'], ['n', '1230'], ['m', '1240'], ['n', '1250'], ['m', '1300'], ['n', '1310'], ['m', '1320'], ['n', '1330'], ['m', '1340'], ['n', '1350'], ['m', '1400'], ['n', '1410'], ['m', '1420'], ['n', '1430']]) == ['m', 'n']\n assert candidate(access_times = [['dev', '0100'], ['dev', '0105'], ['dev', '0110'], ['dev', '0115'], ['dev', '0120'], ['dev', '0125'], ['dev', '0130'], ['dev', '0135'], ['dev', '0140'], ['dev', '0145'], ['dev', '0150']]) == ['dev']\n assert candidate(access_times = [['user1', '1200'], ['user2', '1201'], ['user1', '1202'], ['user2', '1203'], ['user1', '1204'], ['user2', '1205'], ['user1', '1206'], ['user2', '1207'], ['user1', '1208'], ['user2', '1209']]) == ['user1', 'user2']\n assert candidate(access_times = [['y', '2359'], ['y', '0001'], ['y', '0010'], ['y', '0020'], ['y', '0030'], ['y', '0040']]) == ['y']\n assert candidate(access_times = [['a', '0800'], ['a', '0830'], ['b', '0830'], ['a', '0900'], ['b', '0900'], ['a', '0930'], ['b', '0930'], ['a', '1000'], ['b', '1000'], ['a', '1030'], ['b', '1030'], ['a', '1100'], ['b', '1100']]) == []\n assert candidate(access_times = [['q', '1000'], ['q', '1010'], ['q', '1020'], ['q', '1030'], ['q', '1040'], ['q', '1050'], ['q', '1100'], ['q', '1110'], ['q', '1120'], ['q', '1130'], ['q', '1140']]) == ['q']\n assert candidate(access_times = [['z', '0001'], ['z', '0002'], ['z', '0003'], ['z', '0004'], ['z', '0005'], ['z', '0006'], ['z', '0007'], ['z', '0008'], ['z', '0009'], ['z', '0010']]) == ['z']\n assert candidate(access_times = [['alice', '0910'], ['bob', '0911'], ['alice', '0912'], ['alice', '1009'], ['bob', '0913'], ['alice', '1010'], ['alice', '1011'], ['bob', '1008']]) == ['alice', 'bob']\n assert candidate(access_times = [['a', '0900'], ['a', '0905'], ['a', '0910'], ['a', '0915'], ['a', '0920'], ['a', '0925'], ['a', '0930'], ['a', '0935']]) == ['a']\n assert candidate(access_times = [['j', '0549'], ['k', '0457'], ['j', '0532'], ['j', '0621'], ['k', '0540'], ['j', '0533'], ['k', '0539'], ['j', '0534'], ['k', '0538'], ['j', '0535'], ['k', '0537'], ['j', '0536']]) == ['j', 'k']\n assert candidate(access_times = [['alice', '0900'], ['bob', '0901'], ['alice', '0902'], ['bob', '0903'], ['alice', '0904'], ['bob', '0905'], ['alice', '0906'], ['bob', '0907'], ['alice', '0908'], ['bob', '0909']]) == ['alice', 'bob']\n assert candidate(access_times = [['t', '0800'], ['t', '0805'], ['t', '0810'], ['t', '0815'], ['t', '0820'], ['t', '0825'], ['t', '0830'], ['t', '0835'], ['t', '0840'], ['t', '0845'], ['t', '0850'], ['t', '0855'], ['t', '0900']]) == ['t']\n assert candidate(access_times = [['u', '0910'], ['u', '0911'], ['u', '0912'], ['u', '0913'], ['u', '0914'], ['u', '0915'], ['u', '0916'], ['u', '0917'], ['u', '0918'], ['u', '0919']]) == ['u']\n assert candidate(access_times = [['a', '2300'], ['b', '2301'], ['a', '2302'], ['b', '2303'], ['a', '2304'], ['b', '2305'], ['a', '2306'], ['b', '2307'], ['a', '2308'], ['b', '2309']]) == ['a', 'b']\n assert candidate(access_times = [['grace', '1200'], ['grace', '1230'], ['grace', '1300'], ['grace', '1330'], ['grace', '1400'], ['grace', '1430'], ['grace', '1500'], ['grace', '1530'], ['grace', '1600'], ['grace', '1630'], ['grace', '1700'], ['grace', '1730'], ['grace', '1800'], ['grace', '1830'], ['grace', '1900'], ['grace', '1930'], ['grace', '2000'], ['grace', '2030'], ['grace', '2100'], ['grace', '2130'], ['grace', '2200'], ['grace', '2230'], ['grace', '2300'], ['grace', '2330'], ['grace', '0000'], ['grace', '0030'], ['grace', '0100'], ['grace', '0130'], ['grace', '0200'], ['grace', '0230'], ['grace', '0300'], ['grace', '0330'], ['grace', '0400'], ['grace', '0430'], ['grace', '0500'], ['grace', '0530'], ['grace', '0600'], ['grace', '0630'], ['grace', '0700'], ['grace', '0730'], ['grace', '0800'], ['grace', '0830'], ['grace', '0900'], ['grace', '0930'], ['grace', '1000'], ['grace', '1030'], ['grace', '1100'], ['grace', '1130']]) == []\n assert candidate(access_times = [['g', '0300'], ['g', '0315'], ['g', '0330'], ['g', '0345'], ['g', '0400'], ['g', '0415'], ['g', '0430'], ['g', '0445']]) == ['g']\n assert candidate(access_times = [['m', '0600'], ['n', '0601'], ['m', '0602'], ['n', '0603'], ['m', '0604'], ['n', '0605'], ['m', '0606'], ['n', '0607'], ['m', '0608']]) == ['m', 'n']\n assert candidate(access_times = [['omega', '0730'], ['omega', '0731'], ['omega', '0732'], ['omega', '0829'], ['omega', '0830'], ['omega', '0831'], ['omega', '0832'], ['omega', '0833']]) == ['omega']\n assert candidate(access_times = [['o', '0600'], ['o', '0630'], ['o', '0700'], ['o', '0730'], ['o', '0800'], ['o', '0830'], ['o', '0900'], ['o', '0930'], ['o', '1000'], ['o', '1030']]) == []\n assert candidate(access_times = [['x', '2350'], ['x', '0005'], ['y', '1200'], ['y', '1259'], ['z', '1300'], ['z', '1359'], ['z', '1400'], ['x', '2355']]) == []\n assert candidate(access_times = [['abc', '0910'], ['def', '0911'], ['ghi', '0912'], ['jkl', '0913'], ['mno', '0914'], ['pqr', '0915'], ['stu', '0916'], ['vwx', '0917'], ['yz', '0918']]) == []\n assert candidate(access_times = [['p', '0859'], ['q', '0900'], ['r', '0901'], ['s', '0959'], ['t', '1000'], ['u', '0859'], ['v', '0900'], ['w', '0901'], ['x', '0959'], ['y', '1000']]) == []\n assert candidate(access_times = [['p', '1000'], ['q', '1001'], ['p', '1002'], ['q', '1003'], ['p', '1004'], ['q', '1005'], ['p', '1006'], ['q', '1007'], ['p', '1008'], ['q', '1009'], ['p', '1010'], ['q', '1011']]) == ['p', 'q']\n assert candidate(access_times = [['w', '0001'], ['w', '0059'], ['w', '0101'], ['w', '0159'], ['w', '0201'], ['w', '0259'], ['w', '0301'], ['w', '0359'], ['w', '0401'], ['w', '0459']]) == []\n assert candidate(access_times = [['a', '0700'], ['a', '0710'], ['a', '0720'], ['a', '0730'], ['a', '0740'], ['a', '0750'], ['b', '0800'], ['b', '0810'], ['b', '0820'], ['b', '0830'], ['b', '0840'], ['b', '0850']]) == ['a', 'b']\n assert candidate(access_times = [['x', '1200'], ['x', '1201'], ['x', '1202'], ['y', '1200'], ['y', '1230'], ['y', '1231'], ['y', '1259'], ['x', '1300'], ['x', '1301']]) == ['x', 'y']\n assert candidate(access_times = [['alpha', '0830'], ['alpha', '0845'], ['alpha', '0859'], ['alpha', '0900'], ['alpha', '0901'], ['alpha', '0902'], ['alpha', '0903'], ['alpha', '0904']]) == ['alpha']\n assert candidate(access_times = [['l', '2300'], ['l', '2359'], ['l', '0001'], ['l', '0059'], ['l', '0101'], ['l', '0159'], ['l', '0201'], ['l', '0259'], ['l', '0301'], ['l', '0359']]) == []\n assert candidate(access_times = [['z', '0900'], ['z', '0930'], ['z', '1000'], ['z', '1030'], ['z', '1100'], ['z', '1130']]) == []\n assert candidate(access_times = [['alpha', '1330'], ['beta', '1331'], ['gamma', '1332'], ['alpha', '1333'], ['beta', '1334'], ['gamma', '1335'], ['alpha', '1336'], ['beta', '1337'], ['gamma', '1338']]) == ['alpha', 'beta', 'gamma']\n assert candidate(access_times = [['gamma', '0550'], ['gamma', '0551'], ['gamma', '0552'], ['gamma', '0649'], ['gamma', '0650'], ['gamma', '0651'], ['gamma', '0652'], ['gamma', '0653']]) == ['gamma']\n assert candidate(access_times = [['alice', '0800'], ['alice', '0830'], ['alice', '0859'], ['alice', '0900'], ['alice', '0901'], ['alice', '0930'], ['alice', '1000'], ['alice', '1030'], ['alice', '1100'], ['alice', '1130'], ['alice', '1200'], ['alice', '1230'], ['alice', '1300'], ['alice', '1330'], ['alice', '1400'], ['alice', '1430'], ['alice', '1500'], ['alice', '1530'], ['alice', '1600'], ['alice', '1630'], ['alice', '1700'], ['alice', '1730'], ['alice', '1800'], ['alice', '1830'], ['alice', '1900'], ['alice', '1930'], ['alice', '2000'], ['alice', '2030'], ['alice', '2100'], ['alice', '2130'], ['alice', '2200'], ['alice', '2230'], ['alice', '2300'], ['alice', '2330']]) == ['alice']\n assert candidate(access_times = [['dev', '0800'], ['dev', '0830'], ['dev', '0900'], ['dev', '0930'], ['dev', '1000'], ['dev', '1030'], ['dev', '1100'], ['dev', '1130'], ['dev', '1200'], ['dev', '1230'], ['dev', '1300'], ['dev', '1330'], ['dev', '1400'], ['dev', '1430'], ['dev', '1500'], ['dev', '1530'], ['dev', '1600'], ['dev', '1630'], ['dev', '1700'], ['dev', '1730']]) == []\n assert candidate(access_times = [['frank', '0001'], ['frank', '2359'], ['frank', '0002'], ['frank', '0003'], ['frank', '0004'], ['frank', '0005'], ['frank', '0006'], ['frank', '0007'], ['frank', '0008'], ['frank', '0009'], ['frank', '0010'], ['frank', '0011'], ['frank', '0012'], ['frank', '0013'], ['frank', '0014'], ['frank', '0015'], ['frank', '0016'], ['frank', '0017'], ['frank', '0018'], ['frank', '0019'], ['frank', '0020'], ['frank', '0021'], ['frank', '0022'], ['frank', '0023'], ['frank', '0024'], ['frank', '0025'], ['frank', '0026'], ['frank', '0027'], ['frank', '0028'], ['frank', '0029'], ['frank', '0030']]) == ['frank']\n assert candidate(access_times = [['n', '1234'], ['n', '1235'], ['n', '1236'], ['n', '1237'], ['n', '1238'], ['n', '1239'], ['n', '1240'], ['n', '1241'], ['n', '1242'], ['n', '1243'], ['n', '1244'], ['n', '1245'], ['n', '1246'], ['n', '1247'], ['n', '1248'], ['n', '1249']]) == ['n']\n assert candidate(access_times = [['sigma', '1100'], ['sigma', '1101'], ['sigma', '1102'], ['sigma', '1159'], ['sigma', '1200'], ['sigma', '1201'], ['sigma', '1202'], ['sigma', '1259'], ['sigma', '1300']]) == ['sigma']\n assert candidate(access_times = [['worker', '0859'], ['worker', '0900'], ['worker', '0901'], ['worker', '0959'], ['worker', '1000'], ['worker', '1001'], ['worker', '1059'], ['worker', '1100'], ['worker', '1101'], ['worker', '1159']]) == ['worker']\n assert candidate(access_times = [['user1', '0900'], ['user1', '0915'], ['user1', '0925'], ['user2', '0900'], ['user2', '0915'], ['user2', '0925'], ['user1', '0935'], ['user2', '0935'], ['user1', '0945'], ['user2', '0945'], ['user1', '1000'], ['user2', '1000'], ['user1', '1015'], ['user2', '1015']]) == ['user1', 'user2']\n assert candidate(access_times = [['z', '0001'], ['z', '0059'], ['z', '0101'], ['z', '0159'], ['z', '0201'], ['z', '0259'], ['z', '0301'], ['z', '0359']]) == []\n assert candidate(access_times = [['one', '0501'], ['two', '0502'], ['three', '0503'], ['four', '0504'], ['five', '0505'], ['six', '0506'], ['seven', '0507'], ['eight', '0508'], ['nine', '0509']]) == []\n assert candidate(access_times = [['user1', '1400'], ['user2', '1401'], ['user1', '1402'], ['user2', '1403'], ['user1', '1404'], ['user2', '1405'], ['user1', '1406'], ['user2', '1407'], ['user1', '1408']]) == ['user1', 'user2']\n assert candidate(access_times = [['alice', '0915'], ['bob', '1000'], ['alice', '1005'], ['alice', '1010'], ['bob', '1005'], ['alice', '1030'], ['bob', '1025'], ['alice', '1045']]) == ['alice', 'bob']\n assert candidate(access_times = [['a', '0910'], ['b', '0911'], ['a', '0912'], ['b', '0913'], ['a', '0914'], ['b', '0915'], ['a', '0916'], ['b', '0917'], ['a', '0918']]) == ['a', 'b']\n assert candidate(access_times = [['x', '0900'], ['y', '0901'], ['x', '0902'], ['x', '0959'], ['y', '0958'], ['y', '0959'], ['x', '1000'], ['y', '1001']]) == ['x', 'y']\n assert candidate(access_times = [['tom', '0800'], ['jerry', '0801'], ['tom', '0802'], ['tom', '0900'], ['jerry', '0901'], ['jerry', '0902'], ['tom', '0959'], ['jerry', '1000']]) == ['jerry']\n assert candidate(access_times = [['f', '0500'], ['f', '0515'], ['f', '0530'], ['f', '0545'], ['f', '0600'], ['f', '0615'], ['f', '0630'], ['f', '0645']]) == ['f']\n assert candidate(access_times = [['e', '0000'], ['e', '0059'], ['e', '0100'], ['e', '0159'], ['e', '0200'], ['e', '0259'], ['e', '0300'], ['e', '0359']]) == []\n"}, "metadata": {"canonical_parameter_names": ["access_times"], "leetcode_dataset_entry_point": "Solution().findHighAccessEmployees", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List findHighAccessEmployees(List> access_times) {", "container": "Solution", "callable": "findHighAccessEmployees", "parameters": [{"name": "access_times", "type": "List>"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2934, "task_id": "minimum-operations-to-maximize-last-elements-in-arrays", "difficulty": "Medium", "problem_description": "You are given two 0-indexed integer arrays, nums1 and nums2, both having length n.\nYou are allowed to perform a series of operations (possibly none).\nIn an operation, you select an index i in the range [0, n - 1] and swap the values of nums1[i] and nums2[i].\nYour task is to find the minimum number of operations required to satisfy the following conditions:\n\nnums1[n - 1] is equal to the maximum value among all elements of nums1, i.e., nums1[n - 1] = max(nums1[0], nums1[1], ..., nums1[n - 1]).\nnums2[n - 1] is equal to the maximum value among all elements of nums2, i.e., nums2[n - 1] = max(nums2[0], nums2[1], ..., nums2[n - 1]).\n\nReturn an integer denoting the minimum number of operations needed to meet both conditions, or -1 if it is impossible to satisfy both conditions.\n \nExample 1:\n\nInput: nums1 = [1,2,7], nums2 = [4,5,3]\nOutput: 1\nExplanation: In this example, an operation can be performed using index i = 2.\nWhen nums1[2] and nums2[2] are swapped, nums1 becomes [1,2,3] and nums2 becomes [4,5,7].\nBoth conditions are now satisfied.\nIt can be shown that the minimum number of operations needed to be performed is 1.\nSo, the answer is 1.\n\nExample 2:\n\nInput: nums1 = [2,3,4,5,9], nums2 = [8,8,4,4,4]\nOutput: 2\nExplanation: In this example, the following operations can be performed:\nFirst operation using index i = 4.\nWhen nums1[4] and nums2[4] are swapped, nums1 becomes [2,3,4,5,4], and nums2 becomes [8,8,4,4,9].\nAnother operation using index i = 3.\nWhen nums1[3] and nums2[3] are swapped, nums1 becomes [2,3,4,4,4], and nums2 becomes [8,8,4,5,9].\nBoth conditions are now satisfied.\nIt can be shown that the minimum number of operations needed to be performed is 2.\nSo, the answer is 2. \n\nExample 3:\n\nInput: nums1 = [1,5,4], nums2 = [2,5,3]\nOutput: -1\nExplanation: In this example, it is not possible to satisfy both conditions. \nSo, the answer is -1.\n\n \nConstraints:\n\n1 <= n == nums1.length == nums2.length <= 1000\n1 <= nums1[i] <= 109\n1 <= nums2[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [5, 5, 5],nums2 = [5, 5, 5]) == 0\n assert candidate(nums1 = [1, 2],nums2 = [2, 1]) == 1\n assert candidate(nums1 = [10, 9, 8],nums2 = [7, 6, 5]) == -1\n assert candidate(nums1 = [3, 3, 3],nums2 = [3, 3, 3]) == 0\n assert candidate(nums1 = [1, 1, 1],nums2 = [1, 1, 1]) == 0\n assert candidate(nums1 = [3, 1],nums2 = [2, 2]) == -1\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [5, 3, 1],nums2 = [4, 2, 6]) == -1\n assert candidate(nums1 = [2, 3, 4, 5, 9],nums2 = [8, 8, 4, 4, 4]) == 2\n assert candidate(nums1 = [9],nums2 = [9]) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [5, 5, 5, 5]) == 0\n assert candidate(nums1 = [10, 20, 30],nums2 = [15, 25, 20]) == 1\n assert candidate(nums1 = [1],nums2 = [2]) == 0\n assert candidate(nums1 = [1, 3, 5],nums2 = [2, 4, 6]) == 0\n assert candidate(nums1 = [1, 5, 4],nums2 = [2, 5, 3]) == -1\n assert candidate(nums1 = [1, 2, 7],nums2 = [4, 5, 3]) == 1\n assert candidate(nums1 = [1],nums2 = [1]) == 0\n assert candidate(nums1 = [6, 4, 2],nums2 = [5, 3, 1]) == -1\n assert candidate(nums1 = [10, 10, 10],nums2 = [10, 10, 10]) == 0\n assert candidate(nums1 = [10, 20, 30],nums2 = [10, 20, 30]) == 0\n assert candidate(nums1 = [1000000000, 1000000000],nums2 = [1000000000, 1000000000]) == 0\n assert candidate(nums1 = [1, 9, 3, 7, 5],nums2 = [6, 2, 8, 4, 10]) == 2\n assert candidate(nums1 = [9, 5, 1, 4, 7, 3, 6, 8, 2, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1000000000, 999999999, 999999998],nums2 = [1, 2, 3]) == -1\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14],nums2 = [14, 12, 10, 8, 6, 4, 2]) == -1\n assert candidate(nums1 = [1, 1, 2, 2, 3],nums2 = [3, 3, 2, 2, 1]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 1]) == -1\n assert candidate(nums1 = [1, 10, 3, 9, 5, 6, 4],nums2 = [2, 8, 4, 7, 10, 1, 5]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60],nums2 = [60, 50, 40, 30, 20, 10]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums1 = [3, 1, 2],nums2 = [3, 1, 2]) == -1\n assert candidate(nums1 = [5, 15, 25, 35, 45],nums2 = [45, 35, 25, 15, 5]) == -1\n assert candidate(nums1 = [1, 2, 2, 1, 2],nums2 = [2, 1, 1, 2, 1]) == 2\n assert candidate(nums1 = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],nums2 = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 5\n assert candidate(nums1 = [5, 3, 8, 6, 7],nums2 = [4, 6, 2, 9, 1]) == -1\n assert candidate(nums1 = [9, 7, 5, 3, 1],nums2 = [8, 6, 4, 2, 0]) == -1\n assert candidate(nums1 = [1000000000, 1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 1000000000]) == 1\n assert candidate(nums1 = [8, 6, 4, 3, 1],nums2 = [7, 5, 9, 2, 10]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [10, 9, 8, 7, 6]) == -1\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 100, 200, 300, 400]) == 1\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]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11]) == 0\n assert candidate(nums1 = [9, 7, 5, 3, 1],nums2 = [2, 4, 6, 8, 10]) == -1\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -1\n assert candidate(nums1 = [5, 3, 8, 6, 2, 7, 4, 1, 9],nums2 = [9, 1, 4, 7, 2, 6, 8, 3, 5]) == -1\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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(nums1 = [100, 90, 80, 70, 60],nums2 = [60, 70, 80, 90, 100]) == -1\n assert candidate(nums1 = [5, 9, 1, 3, 7],nums2 = [8, 4, 6, 2, 5]) == -1\n assert candidate(nums1 = [3, 3, 3, 3, 3],nums2 = [3, 3, 3, 3, 3]) == 0\n assert candidate(nums1 = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10],nums2 = [1, 5, 3, 9, 2, 8, 4, 7, 10, 6]) == 4\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [3, 3, 3, 3, 3],nums2 = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums1 = [3, 2, 1, 4, 5, 6],nums2 = [6, 5, 4, 1, 2, 3]) == 3\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums1 = [1, 3, 2, 4, 5],nums2 = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [9, 1, 8, 2, 7],nums2 = [3, 6, 5, 4, 10]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [9, 7, 5, 3, 1]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums1 = [9, 8, 7, 6, 5],nums2 = [10, 9, 8, 7, 6]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\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]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == -1\n assert candidate(nums1 = [9, 7, 5, 3, 1],nums2 = [10, 8, 6, 4, 2]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 1000000000],nums2 = [1000000000, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [2, 2, 2, 2, 2],nums2 = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [3, 3, 2, 2, 1, 1]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2]) == 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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [5, 3, 8, 6, 7],nums2 = [4, 9, 2, 1, 10]) == 1\n assert candidate(nums1 = [7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 0\n assert candidate(nums1 = [1000000000, 1, 2],nums2 = [1, 2, 1000000000]) == 1\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6]) == 0\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1000000000],nums2 = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49],nums2 = [49, 42, 35, 28, 21, 14, 7]) == -1\n assert candidate(nums1 = [3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums1 = [5, 3, 1, 7, 9],nums2 = [8, 6, 4, 2, 10]) == 0\n assert candidate(nums1 = [7, 7, 7, 7, 1],nums2 = [8, 8, 8, 8, 2]) == -1\n assert candidate(nums1 = [8, 6, 7, 5, 3, 0, 9],nums2 = [1, 4, 2, 8, 6, 7, 4]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10, 12]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [11, 9, 7, 5, 3, 1]) == -1\n assert candidate(nums1 = [9, 8, 7, 6, 5],nums2 = [1, 2, 3, 4, 10]) == 1\n assert candidate(nums1 = [1, 2, 1000000000],nums2 = [1000000000, 1, 2]) == 1\n assert candidate(nums1 = [1000000000, 1, 1, 1, 1],nums2 = [1, 1000000000, 1, 1, 1]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 3, 1, 2, 4]) == 1\n assert candidate(nums1 = [1, 2, 2, 2, 2],nums2 = [2, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [1, 3, 2, 5, 4],nums2 = [4, 2, 3, 1, 5]) == 1\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]) == 0\n assert candidate(nums1 = [9, 2, 5, 7, 1],nums2 = [1, 8, 3, 4, 6]) == -1\n assert candidate(nums1 = [3, 6, 9, 12, 15],nums2 = [15, 12, 9, 6, 3]) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [10, 20, 30, 40, 50]) == -1\n assert candidate(nums1 = [5, 7, 3, 9, 2],nums2 = [8, 1, 6, 4, 10]) == -1\n assert candidate(nums1 = [10, 10, 10, 10],nums2 = [10, 10, 10, 10]) == 0\n assert candidate(nums1 = [3, 5, 1, 4, 2, 6, 8, 7, 10, 9],nums2 = [9, 7, 10, 8, 6, 4, 2, 5, 1, 3]) == -1\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == -1\n assert candidate(nums1 = [5, 8, 10, 2, 9],nums2 = [7, 6, 1, 10, 3]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2]) == 0\n assert candidate(nums1 = [7, 3, 5, 8, 6],nums2 = [2, 4, 1, 9, 5]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [9, 18, 27, 36, 45]) == 0\n assert candidate(nums1 = [10, 10, 10, 10, 1],nums2 = [1, 10, 10, 10, 10]) == -1\n assert candidate(nums1 = [1, 1, 2, 2, 3],nums2 = [3, 3, 2, 2, 1]) == -1\n assert candidate(nums1 = [5, 1, 8, 3, 7, 6, 4],nums2 = [4, 9, 2, 6, 1, 8, 5]) == -1\n assert candidate(nums1 = [1, 9, 3, 7, 5, 2],nums2 = [6, 8, 4, 2, 9, 1]) == -1\n assert candidate(nums1 = [9, 1, 4, 8, 5, 3],nums2 = [2, 7, 6, 3, 10, 9]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == -1\n assert candidate(nums1 = [2, 2, 2, 2, 2],nums2 = [2, 2, 2, 2, 2]) == 0\n assert candidate(nums1 = [1, 9, 9, 9, 9, 9],nums2 = [9, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90],nums2 = [90, 80, 70, 60, 50, 40, 30, 20, 10]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == -1\n assert candidate(nums1 = [5, 6, 3, 4, 7],nums2 = [4, 5, 6, 7, 8]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == -1\n assert candidate(nums1 = [3, 3, 3, 3, 3],nums2 = [3, 3, 3, 3, 3]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minOperations(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2935, "task_id": "maximum-strong-pair-xor-ii", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:\n\n|x - y| <= min(x, y)\n\nYou need to select two integers from nums such that they form a strong pair and their bitwise XOR is the maximum among all strong pairs in the array.\nReturn the maximum XOR value out of all possible strong pairs in the array nums.\nNote that you can pick the same integer twice to form a pair.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5]\nOutput: 7\nExplanation: There are 11 strong pairs in the array nums: (1, 1), (1, 2), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (3, 5), (4, 4), (4, 5) and (5, 5).\nThe maximum XOR possible from these pairs is 3 XOR 4 = 7.\n\nExample 2:\n\nInput: nums = [10,100]\nOutput: 0\nExplanation: There are 2 strong pairs in the array nums: (10, 10) and (100, 100).\nThe maximum XOR possible from these pairs is 10 XOR 10 = 0 since the pair (100, 100) also gives 100 XOR 100 = 0.\n\nExample 3:\n\nInput: nums = [500,520,2500,3000]\nOutput: 1020\nExplanation: There are 6 strong pairs in the array nums: (500, 500), (500, 520), (520, 520), (2500, 2500), (2500, 3000) and (3000, 3000).\nThe maximum XOR possible from these pairs is 500 XOR 520 = 1020 since the only other non-zero XOR value is 2500 XOR 3000 = 636.\n\n \nConstraints:\n\n1 <= nums.length <= 5 * 104\n1 <= nums[i] <= 220 - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == 192\n assert candidate(nums = [1023, 2047, 3071, 4095, 5119]) == 7168\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [100000, 100001, 100002, 100003]) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12]) == 14\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023]) == 0\n assert candidate(nums = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 768\n assert candidate(nums = [1, 3, 5, 7, 9]) == 14\n assert candidate(nums = [15, 30, 45, 60, 75, 90]) == 119\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 14\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1023, 1024, 2047, 2048]) == 4095\n assert candidate(nums = [10, 100]) == 0\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383]) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == 0\n assert candidate(nums = [500, 520, 2500, 3000]) == 1020\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 48\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1536\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == 0\n assert candidate(nums = [2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [15, 30, 45, 60, 75]) == 119\n assert candidate(nums = [1000, 1023, 1048, 1071, 1094, 1117, 1140, 1163, 1186, 1209]) == 2032\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 30\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 125\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1992\n assert candidate(nums = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500]) == 484\n assert candidate(nums = [500, 520, 1000, 1020, 1500, 1520, 2000, 2020, 2500, 2520]) == 3644\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 393216\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 786432\n assert candidate(nums = [16384, 16385, 16386, 16387, 16388, 16389, 16390, 16391]) == 7\n assert candidate(nums = [16384, 16385, 16386, 16387, 16388, 16389, 16390, 16391, 16392, 16393, 16394, 16395, 16396, 16397, 16398, 16399, 16400, 16401, 16402, 16403, 16404, 16405, 16406, 16407, 16408, 16409, 16410, 16411, 16412, 16413, 16414, 16415]) == 31\n assert candidate(nums = [13, 29, 47, 71, 97, 131, 167, 211, 257, 307, 359, 419, 479, 541, 601]) == 1018\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 31\n assert candidate(nums = [31, 62, 124, 248, 496, 992, 1984, 3968]) == 2112\n assert candidate(nums = [98765, 87654, 76543, 65432, 54321, 43210, 32109, 21098, 10987]) == 130766\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 61\n assert candidate(nums = [2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023]) == 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]) == 62\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215]) == 0\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216, 10240]) == 15360\n assert candidate(nums = [10000, 10050, 10100, 10150, 10200, 10250, 10300, 10350, 10400, 10450]) == 4068\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 786432\n assert candidate(nums = [127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]) == 0\n assert candidate(nums = [2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061]) == 4095\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 30\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 1992\n assert candidate(nums = [1, 2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642, 2147483641]) == 7\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 0\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180]) == 255\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234]) == 990651\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383]) == 0\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047]) == 0\n assert candidate(nums = [1048575, 1048574, 1048573, 1048572, 1048571, 1048570, 1048569, 1048568]) == 7\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225]) == 255\n assert candidate(nums = [123, 246, 369, 492, 615, 738, 861, 984, 1107, 1230, 1353]) == 1963\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]) == 62\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == 253\n assert candidate(nums = [17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == 126\n assert candidate(nums = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000, 5000000, 10000000]) == 1367488\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 15, 20, 25, 30, 35, 40]) == 61\n assert candidate(nums = [512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 393216\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 968\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 24576\n assert candidate(nums = [10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009]) == 15\n assert candidate(nums = [1, 21845, 21846, 21847, 21848, 21849, 21850, 21851, 21852, 21853, 21854, 21855]) == 15\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 786432\n assert candidate(nums = [1, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 0\n assert candidate(nums = [1, 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240]) == 15360\n assert candidate(nums = [1, 2, 3, 6, 7, 14, 15, 30, 31, 62, 63, 126, 127, 254, 255, 510, 511, 1022, 1023, 2046, 2047, 4094, 4095]) == 2049\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 24576\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 0\n assert candidate(nums = [123456, 123457, 123458, 123459, 123460, 123461, 123462, 123463, 123464, 123465, 123466, 123467, 123468, 123469, 123470]) == 15\n assert candidate(nums = [2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056]) == 4095\n assert candidate(nums = [134217727, 134217728, 134217729, 134217730, 134217731, 134217732, 134217733, 134217734, 134217735]) == 2097151\n assert candidate(nums = [220, 440, 880, 1760, 3520, 7040, 14080, 28160, 56320, 112640, 225280]) == 182272\n assert candidate(nums = [1023, 2047, 3071, 4095, 5119, 6143, 7167, 8191, 9215, 10239, 11263, 12287, 13311, 14335, 15359]) == 15360\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]) == 126\n assert candidate(nums = [8191, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200]) == 16383\n assert candidate(nums = [100000, 100002, 100004, 100006, 100008, 100010, 100012, 100014, 100016, 100018, 100020, 100022, 100024, 100026, 100028, 100030, 100032, 100034, 100036, 100038, 100040, 100042, 100044, 100046, 100048]) == 126\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [1023, 2047, 3071, 4095, 5119, 6143, 7167, 8191, 9215, 10239]) == 15360\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 250\n assert candidate(nums = [1, 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 1558208\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]) == 250\n assert candidate(nums = [150000, 150001, 150002, 150003, 150004, 150005, 150006, 150007, 150008, 150009, 150010]) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 210, 220, 230, 240, 250]) == 122\n assert candidate(nums = [5, 9, 14, 23, 37, 59, 92, 144, 233, 377]) == 400\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287]) == 0\n assert candidate(nums = [7, 23, 45, 79, 121, 177, 247, 327, 417, 517, 627, 747, 877, 1017]) == 978\n assert candidate(nums = [1000000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000, 4500000]) == 1780896\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 15752\n assert candidate(nums = [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 = [268435455, 268435456, 268435457, 268435458, 268435459, 268435460, 268435461, 268435462, 268435463]) == 2097151\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == 795\n assert candidate(nums = [10, 20, 21, 30, 31, 32, 40, 41, 42, 43, 50, 51, 52, 53, 54, 60, 61, 62, 63, 64]) == 127\n assert candidate(nums = [314159, 271828, 141421, 161803, 707106, 353553, 414213]) == 1027891\n assert candidate(nums = [16384, 32768, 49152, 65536, 81920, 98304, 114688, 131072, 147456, 163840]) == 245760\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 12463\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095]) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 12288\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 62\n assert candidate(nums = [16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152]) == 1572864\n assert candidate(nums = [1, 1048575, 2, 1048574, 3, 1048573, 4, 1048572, 5, 1048571]) == 7\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 6144\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992]) == 31\n assert candidate(nums = [1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032]) == 15\n assert candidate(nums = [511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1536\n assert candidate(nums = [500000, 500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009]) == 15\n assert candidate(nums = [8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202]) == 15\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800]) == 996\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 0\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216, 10240, 11264, 12288, 13312, 14336, 15360]) == 15360\n assert candidate(nums = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 786432\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 15464\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015]) == 31\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 1558208\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumStrongPairXor", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumStrongPairXor(int[] nums) {", "container": "Solution", "callable": "maximumStrongPairXor", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2937, "task_id": "make-three-strings-equal", "difficulty": "Easy", "problem_description": "You are given three strings: s1, s2, and s3. In one operation you can choose one of these strings and delete its rightmost character. Note that you cannot completely empty a string.\nReturn the minimum number of operations required to make the strings equal. If it is impossible to make them equal, return -1.\n \nExample 1:\n\nInput: s1 = \"abc\", s2 = \"abb\", s3 = \"ab\"\nOutput: 2\nExplanation: Deleting the rightmost character from both s1 and s2 will result in three equal strings.\n\nExample 2:\n\nInput: s1 = \"dac\", s2 = \"bac\", s3 = \"cac\"\nOutput: -1\nExplanation: Since the first letters of s1 and s2 differ, they cannot be made equal.\n\n \nConstraints:\n\n1 <= s1.length, s2.length, s3.length <= 100\ns1, s2 and s3 consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"abc\",s2 = \"abb\",s3 = \"ab\") == 2\n assert candidate(s1 = \"abcde\",s2 = \"abcdf\",s3 = \"abcde\") == 3\n assert candidate(s1 = \"abcd\",s2 = \"abcf\",s3 = \"abcd\") == 3\n assert candidate(s1 = \"abcd\",s2 = \"abce\",s3 = \"abcd\") == 3\n assert candidate(s1 = \"xyz\",s2 = \"xyw\",s3 = \"xyv\") == 3\n assert candidate(s1 = \"abcde\",s2 = \"abcde\",s3 = \"abcdef\") == 1\n assert candidate(s1 = \"abcde\",s2 = \"abfde\",s3 = \"abcde\") == 9\n assert candidate(s1 = \"abcdef\",s2 = \"abcghi\",s3 = \"abcjkl\") == 9\n assert candidate(s1 = \"aaa\",s2 = \"aaa\",s3 = \"aaa\") == 0\n assert candidate(s1 = \"abc\",s2 = \"abc\",s3 = \"abcd\") == 1\n assert candidate(s1 = \"a\",s2 = \"a\",s3 = \"a\") == 0\n assert candidate(s1 = \"xyz\",s2 = \"xyw\",s3 = \"xy\") == 2\n assert candidate(s1 = \"dac\",s2 = \"bac\",s3 = \"cac\") == -1\n assert candidate(s1 = \"xyz\",s2 = \"xyw\",s3 = \"xyx\") == 3\n assert candidate(s1 = \"aaaaa\",s2 = \"aaaaab\",s3 = \"aaaaac\") == 2\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdegh\",s3 = \"abcdexh\") == 7\n assert candidate(s1 = \"zzzzzzz\",s2 = \"zzzzzzz\",s3 = \"zzzzzzz\") == 0\n assert candidate(s1 = \"same\",s2 = \"same\",s3 = \"same\") == 0\n assert candidate(s1 = \"abcdabcdabcdabcd\",s2 = \"abcdabcdabcdabcd\",s3 = \"abcdabcdabcdabc\") == 2\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefg\",s3 = \"abcdefg\") == 0\n assert candidate(s1 = \"different\",s2 = \"differences\",s3 = \"differentl\") == 6\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghik\",s3 = \"abcdefghi\") == 2\n assert candidate(s1 = \"abcdefg\",s2 = \"ghijklm\",s3 = \"nopqrst\") == -1\n assert candidate(s1 = \"aabbaabb\",s2 = \"aabbaacc\",s3 = \"aabbaadd\") == 6\n assert candidate(s1 = \"pqrstu\",s2 = \"pqrstv\",s3 = \"pqrstu\") == 3\n assert candidate(s1 = \"abcdeabcde\",s2 = \"abcdeabcdf\",s3 = \"abcdeabcde\") == 3\n assert candidate(s1 = \"qwerty\",s2 = \"qwerty\",s3 = \"qwertyu\") == 1\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdeghi\",s3 = \"abcdefgj\") == 9\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbc\",s3 = \"aabcc\") == 7\n assert candidate(s1 = \"abcabcabcabcabcabc\",s2 = \"abcabcabcabcabcabc\",s3 = \"abcabcabcabcabcab\") == 2\n assert candidate(s1 = \"mississippi\",s2 = \"mississipp\",s3 = \"mississipp\") == 1\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdefga\",s3 = \"abcdefg\") == 2\n assert candidate(s1 = \"hello\",s2 = \"hell\",s3 = \"helo\") == 4\n assert candidate(s1 = \"abcdef\",s2 = \"abcde\",s3 = \"abcd\") == 3\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbc\",s3 = \"aab\") == 5\n assert candidate(s1 = \"testcase\",s2 = \"testcase\",s3 = \"testcases\") == 1\n assert candidate(s1 = \"zzzzzzzzzz\",s2 = \"zzzzzzzzzz\",s3 = \"zzzzzzzzzzz\") == 1\n assert candidate(s1 = \"aabbccdd\",s2 = \"aabbccdd\",s3 = \"aabbcddd\") == 9\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdefgh\",s3 = \"abcdefgh\") == 0\n assert candidate(s1 = \"abcdef\",s2 = \"abcxyz\",s3 = \"abcuvw\") == 9\n assert candidate(s1 = \"xyzz\",s2 = \"xyyz\",s3 = \"xyzz\") == 6\n assert candidate(s1 = \"zzzzzzzz\",s2 = \"zzzzzzzz\",s3 = \"zzzzzzzz\") == 0\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefg\",s3 = \"abcdef\") == 2\n assert candidate(s1 = \"abcdef\",s2 = \"abcdef\",s3 = \"ghijkl\") == -1\n assert candidate(s1 = \"abracadabra\",s2 = \"abracadabr\",s3 = \"abracadaba\") == 4\n assert candidate(s1 = \"abcdabcd\",s2 = \"abcdabc\",s3 = \"abcdab\") == 3\n assert candidate(s1 = \"aaaaabbbb\",s2 = \"aaaaacccc\",s3 = \"aaaaadddd\") == 12\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdefgj\",s3 = \"abcdefg\") == 2\n assert candidate(s1 = \"aaaaaa\",s2 = \"aaaaaa\",s3 = \"aaaaaaa\") == 1\n assert candidate(s1 = \"abcdef\",s2 = \"abcdeg\",s3 = \"abcdef\") == 3\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\",s3 = \"abcdef\") == -1\n assert candidate(s1 = \"qrstuv\",s2 = \"qrstuw\",s3 = \"qrstvv\") == 6\n assert candidate(s1 = \"mnop\",s2 = \"mnoq\",s3 = \"mnop\") == 3\n assert candidate(s1 = \"longerstring\",s2 = \"longeststring\",s3 = \"longerstrings\") == 23\n assert candidate(s1 = \"abcdefgxyz\",s2 = \"abcdefgxyw\",s3 = \"abcdefgxy\") == 2\n assert candidate(s1 = \"xylophone\",s2 = \"xylophon\",s3 = \"xylopho\") == 3\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdehi\",s3 = \"abcdejk\") == 6\n assert candidate(s1 = \"python\",s2 = \"pythpn\",s3 = \"pythpn\") == 6\n assert candidate(s1 = \"abcdabcd\",s2 = \"abcdabce\",s3 = \"abcdabcd\") == 3\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefg\",s3 = \"abcdefx\") == 3\n assert candidate(s1 = \"abcdabcdabcd\",s2 = \"abcdabcdabcd\",s3 = \"abcdabcdabc\") == 2\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghij\",s3 = \"abcdefghijk\") == 1\n assert candidate(s1 = \"aaaabbbb\",s2 = \"aaaabbbb\",s3 = \"aaaabbb\") == 2\n assert candidate(s1 = \"aabbccdd\",s2 = \"aabbccde\",s3 = \"aabbccdf\") == 3\n assert candidate(s1 = \"abcabc\",s2 = \"abcabc\",s3 = \"abcabd\") == 3\n assert candidate(s1 = \"a\",s2 = \"a\",s3 = \"b\") == -1\n assert candidate(s1 = \"abcdef\",s2 = \"ghijkl\",s3 = \"mnopqr\") == -1\n assert candidate(s1 = \"aabbaabb\",s2 = \"aabbaabb\",s3 = \"aabbaab\") == 2\n assert candidate(s1 = \"matching\",s2 = \"match\",s3 = \"matchi\") == 4\n assert candidate(s1 = \"unique\",s2 = \"uniquely\",s3 = \"uniquer\") == 3\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefg\",s3 = \"abcdefh\") == 3\n assert candidate(s1 = \"abcdxyz\",s2 = \"abcdwxy\",s3 = \"abcdvwx\") == 9\n assert candidate(s1 = \"programming\",s2 = \"programmer\",s3 = \"programing\") == 10\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbbc\",s3 = \"aabbbcc\") == 7\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdefgg\",s3 = \"abcdefg\") == 2\n assert candidate(s1 = \"abcdefghijk\",s2 = \"abcdefghij\",s3 = \"abcdefgh\") == 5\n assert candidate(s1 = \"mnopqr\",s2 = \"mnopqs\",s3 = \"mnopqt\") == 3\n assert candidate(s1 = \"aabbcc\",s2 = \"aabccc\",s3 = \"aabccx\") == 9\n assert candidate(s1 = \"abcxyz\",s2 = \"abcxyw\",s3 = \"abcxy\") == 2\n assert candidate(s1 = \"abcdabcd\",s2 = \"abcdabcde\",s3 = \"abcdabcd\") == 1\n assert candidate(s1 = \"zxy\",s2 = \"zyx\",s3 = \"xyz\") == -1\n assert candidate(s1 = \"zzzzz\",s2 = \"zzzzz\",s3 = \"zzzz\") == 2\n assert candidate(s1 = \"abcabcabc\",s2 = \"abcabcabc\",s3 = \"abcabcabd\") == 3\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbcd\",s3 = \"aabbbc\") == 6\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefh\",s3 = \"abcdefi\") == 3\n assert candidate(s1 = \"abcabcabcabc\",s2 = \"abcabcabcabc\",s3 = \"abcabcabcab\") == 2\n assert candidate(s1 = \"aaaaa\",s2 = \"aaaaa\",s3 = \"aaaab\") == 3\n assert candidate(s1 = \"xyzxyz\",s2 = \"xyzxyw\",s3 = \"xyzxy\") == 2\n assert candidate(s1 = \"aaaaab\",s2 = \"aaaabb\",s3 = \"aaaaab\") == 6\n assert candidate(s1 = \"abcabcabc\",s2 = \"abcabcabcd\",s3 = \"abcabcabcde\") == 3\n assert candidate(s1 = \"abcdef\",s2 = \"abcdfe\",s3 = \"abcdee\") == 6\n assert candidate(s1 = \"abcd\",s2 = \"abcde\",s3 = \"abcdf\") == 2\n assert candidate(s1 = \"xyzxyzxyz\",s2 = \"xyzxyzxy\",s3 = \"xyzxyz\") == 5\n assert candidate(s1 = \"abcdabcd\",s2 = \"abcdbcd\",s3 = \"abcdabcd\") == 11\n assert candidate(s1 = \"programming\",s2 = \"prognmming\",s3 = \"progrmming\") == 19\n assert candidate(s1 = \"\",s2 = \"\",s3 = \"\") == 0\n assert candidate(s1 = \"abcdefghijk\",s2 = \"abcdefghijl\",s3 = \"abcdefghijk\") == 3\n assert candidate(s1 = \"abcdabcd\",s2 = \"abcdeabc\",s3 = \"abcdabcd\") == 12\n assert candidate(s1 = \"abcdabcdabcd\",s2 = \"abcdabcdabca\",s3 = \"abcdabcdabcd\") == 3\n assert candidate(s1 = \"abcabcabcabcabc\",s2 = \"abcabcabcabcabc\",s3 = \"abcabcabcabc\") == 6\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdegh\",s3 = \"abcdefg\") == 7\n assert candidate(s1 = \"zzzzzz\",s2 = \"zzzzz\",s3 = \"zzzz\") == 3\n assert candidate(s1 = \"abcabcabc\",s2 = \"abcabcaba\",s3 = \"abcabcabc\") == 3\n assert candidate(s1 = \"aaaaaaaa\",s2 = \"aaaaaaab\",s3 = \"aaaaaaac\") == 3\n assert candidate(s1 = \"aabbccdd\",s2 = \"aabbccdee\",s3 = \"aabbccdde\") == 5\n assert candidate(s1 = \"xyxzyxzy\",s2 = \"xyxzyxzz\",s3 = \"xyxzyxzq\") == 3\n assert candidate(s1 = \"abcabcabc\",s2 = \"abcabcabc\",s3 = \"abcabcab\") == 2\n assert candidate(s1 = \"zzzzzzzz\",s2 = \"zzzzzzz\",s3 = \"zzzzzz\") == 3\n assert candidate(s1 = \"abcdeabcde\",s2 = \"abcdeabced\",s3 = \"abcdeabcde\") == 6\n assert candidate(s1 = \"aabbccddeeff\",s2 = \"aabbccddeeffg\",s3 = \"aabbccddeeffh\") == 2\n assert candidate(s1 = \"hello\",s2 = \"hallo\",s3 = \"hella\") == 12\n assert candidate(s1 = \"abcabcabc\",s2 = \"abcabcabc\",s3 = \"abcabcabcd\") == 1\n assert candidate(s1 = \"aabbaabb\",s2 = \"aabbaaba\",s3 = \"aabbaabb\") == 3\n assert candidate(s1 = \"sameprefix\",s2 = \"sameprefixa\",s3 = \"sameprefixb\") == 2\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghik\",s3 = \"abcdefghil\") == 3\n assert candidate(s1 = \"aabbccddeeffgg\",s2 = \"aabbccddeeffgg\",s3 = \"aabbccddeeffgghh\") == 2\n assert candidate(s1 = \"abcabcabc\",s2 = \"abcabcabc\",s3 = \"abcabcabx\") == 3\n assert candidate(s1 = \"abacabad\",s2 = \"abacabae\",s3 = \"abacabad\") == 3\n assert candidate(s1 = \"xyzxyzxyz\",s2 = \"xyzxyzxyw\",s3 = \"xyzxyzxyv\") == 3\n assert candidate(s1 = \"xyzz\",s2 = \"xyzz\",s3 = \"xyzy\") == 3\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdexyz\",s3 = \"abcdefyz\") == 9\n assert candidate(s1 = \"abababab\",s2 = \"babababa\",s3 = \"abababab\") == -1\n assert candidate(s1 = \"abcdef\",s2 = \"abcdef\",s3 = \"abc\") == 6\n assert candidate(s1 = \"xyzxyz\",s2 = \"xyzxyz\",s3 = \"xyzxyzz\") == 1\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbbcc\",s3 = \"aabcccc\") == 11\n assert candidate(s1 = \"zzzzzz\",s2 = \"zzzzzz\",s3 = \"zzzzzz\") == 0\n"}, "metadata": {"canonical_parameter_names": ["s1", "s2", "s3"], "leetcode_dataset_entry_point": "Solution().findMinimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findMinimumOperations(String s1, String s2, String s3) {", "container": "Solution", "callable": "findMinimumOperations", "parameters": [{"name": "s1", "type": "String"}, {"name": "s2", "type": "String"}, {"name": "s3", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2938, "task_id": "separate-black-and-white-balls", "difficulty": "Medium", "problem_description": "There are n balls on a table, each ball has a color black or white.\nYou are given a 0-indexed binary string s of length n, where 1 and 0 represent black and white balls, respectively.\nIn each step, you can choose two adjacent balls and swap them.\nReturn the minimum number of steps to group all the black balls to the right and all the white balls to the left.\n \nExample 1:\n\nInput: s = \"101\"\nOutput: 1\nExplanation: We can group all the black balls to the right in the following way:\n- Swap s[0] and s[1], s = \"011\".\nInitially, 1s are not grouped together, requiring at least 1 step to group them to the right.\nExample 2:\n\nInput: s = \"100\"\nOutput: 2\nExplanation: We can group all the black balls to the right in the following way:\n- Swap s[0] and s[1], s = \"010\".\n- Swap s[1] and s[2], s = \"001\".\nIt can be proven that the minimum number of steps needed is 2.\n\nExample 3:\n\nInput: s = \"0111\"\nOutput: 0\nExplanation: All the black balls are already grouped to the right.\n\n \nConstraints:\n\n1 <= n == s.length <= 105\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"110100\") == 8\n assert candidate(s = \"1111\") == 0\n assert candidate(s = \"100100101\") == 9\n assert candidate(s = \"110011\") == 4\n assert candidate(s = \"00110011\") == 4\n assert candidate(s = \"11110000\") == 16\n assert candidate(s = \"0000\") == 0\n assert candidate(s = \"0111\") == 0\n assert candidate(s = \"111000\") == 9\n assert candidate(s = \"100\") == 2\n assert candidate(s = \"00001111\") == 0\n assert candidate(s = \"000111\") == 0\n assert candidate(s = \"101\") == 1\n assert candidate(s = \"1001001001\") == 12\n assert candidate(s = \"11111\") == 0\n assert candidate(s = \"01010101\") == 6\n assert candidate(s = \"10101010\") == 10\n assert candidate(s = \"1010101010\") == 15\n assert candidate(s = \"010101\") == 3\n assert candidate(s = \"101010\") == 6\n assert candidate(s = \"1101001\") == 8\n assert candidate(s = \"11001100\") == 12\n assert candidate(s = \"0101010101\") == 10\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"101010101010101010\") == 45\n assert candidate(s = \"11111111110000000000000000000000111111111100000000000000000\") == 560\n assert candidate(s = \"1111111111111111111110\") == 21\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101010101010101010101010101010\") == 820\n assert candidate(s = \"111000111000111000\") == 54\n assert candidate(s = \"010101010101010101010101010101010101\") == 153\n assert candidate(s = \"000000000000000000000000000000111111\") == 0\n assert candidate(s = \"1000001000001000001000001000\") == 65\n assert candidate(s = \"0110110110110110110110110110\") == 90\n assert candidate(s = \"00101011010\") == 12\n assert candidate(s = \"0000000000000000000000001111\") == 0\n assert candidate(s = \"1111111111111111111111110000\") == 96\n assert candidate(s = \"110110110110110110110110110110110110110110110110110110110110110\") == 462\n assert candidate(s = \"000111000111000111000111000111000111\") == 135\n assert candidate(s = \"10101010101010101010101010\") == 91\n assert candidate(s = \"00001111000011110000\") == 48\n assert candidate(s = \"11111111111100000000\") == 96\n assert candidate(s = \"11110000000000111100\") == 56\n assert candidate(s = \"101010101010101010101010\") == 78\n assert candidate(s = \"0000000000\") == 0\n assert candidate(s = \"101010101010101010101010101\") == 91\n assert candidate(s = \"1101101101101101101101101101\") == 90\n assert candidate(s = \"0000000000000000000001\") == 0\n assert candidate(s = \"1001001001001001001001001001001001001\") == 156\n assert candidate(s = \"011011011011011011011011011011011011011011011011011011011011011\") == 420\n assert candidate(s = \"0001110001110001110001110001\") == 90\n assert candidate(s = \"000111000111000111000111\") == 54\n assert candidate(s = \"100100100100100100100\") == 56\n assert candidate(s = \"0111110111110111110111110111\") == 50\n assert candidate(s = \"10000000000000000000\") == 19\n assert candidate(s = \"111000111000111000111000111000111000\") == 189\n assert candidate(s = \"0101010101010101010101\") == 55\n assert candidate(s = \"00000000000000000000000000000000111111\") == 0\n assert candidate(s = \"0011001100110011\") == 24\n assert candidate(s = \"0000000000000000000000000000111111\") == 0\n assert candidate(s = \"00001111000011110000111100001111000011110000111100001111\") == 336\n assert candidate(s = \"00000001111111111111\") == 0\n assert candidate(s = \"0010010010010010010010010010\") == 81\n assert candidate(s = \"1001001001001001001001001001001\") == 110\n assert candidate(s = \"11110000111100001111\") == 48\n assert candidate(s = \"01010101010101010101010101\") == 78\n assert candidate(s = \"1111100000000000\") == 55\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010\") == 406\n assert candidate(s = \"100100100100100\") == 30\n assert candidate(s = \"10101001010101010101\") == 48\n assert candidate(s = \"0110110110110110110110\") == 56\n assert candidate(s = \"0000011111\") == 0\n assert candidate(s = \"11111111111111111111\") == 0\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000001\") == 0\n assert candidate(s = \"01101101101101101101101101\") == 72\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010101\") == 561\n assert candidate(s = \"0000111111\") == 0\n assert candidate(s = \"111000000000\") == 27\n assert candidate(s = \"0000000000000000000000111111\") == 0\n assert candidate(s = \"001100110011\") == 12\n assert candidate(s = \"1110000000000000000000000000\") == 75\n assert candidate(s = \"001001001001001001001001001001001\") == 110\n assert candidate(s = \"01010110101010101010\") == 52\n assert candidate(s = \"00000000001111111111\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010\") == 666\n assert candidate(s = \"100000000001\") == 10\n assert candidate(s = \"100000100001000010001000010000100001\") == 109\n assert candidate(s = \"0000000000001111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"11111111110000000000\") == 100\n assert candidate(s = \"11100011100011100011\") == 54\n assert candidate(s = \"10010010010010010010\") == 49\n assert candidate(s = \"1010101010101010101010101010\") == 105\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"000111111100000000\") == 56\n assert candidate(s = \"1001001001001001001001\") == 56\n assert candidate(s = \"00000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"11110000111100001111000011110000111100001111000011110000\") == 448\n assert candidate(s = \"011001100110011001100110011001100110\") == 162\n assert candidate(s = \"1111111000000000000000000000\") == 147\n assert candidate(s = \"11111000011110000111\") == 56\n assert candidate(s = \"000011111111111111110000\") == 64\n assert candidate(s = \"01100110011001100110\") == 50\n assert candidate(s = \"111110000111100001111\") == 56\n assert candidate(s = \"11011011011011011011\") == 42\n assert candidate(s = \"10000000001111111111100000000000111111111111100000000000\") == 416\n assert candidate(s = \"00000000001111111111111111111111000000000011111111111111111\") == 220\n assert candidate(s = \"1111111111111111111111111111\") == 0\n assert candidate(s = \"1110001110001110001110001110\") == 105\n assert candidate(s = \"00000100000100000100\") == 21\n assert candidate(s = \"0101010101010101010101010101\") == 91\n assert candidate(s = \"11111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"0110101010101010101010101010101010101010101010101010\") == 350\n assert candidate(s = \"10001000100010001000\") == 45\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"01001001001001001001\") == 42\n assert candidate(s = \"00110011001100110011\") == 40\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001\") == 380\n assert candidate(s = \"0010010010\") == 9\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101\") == 465\n assert candidate(s = \"111111000000000000000000000000000000\") == 180\n assert candidate(s = \"00000111100001111000\") == 40\n assert candidate(s = \"100101001010101010\") == 40\n assert candidate(s = \"00000000000000000000\") == 0\n assert candidate(s = \"00110011001100110011001100110011001100\") == 180\n assert candidate(s = \"1001001001001001001001001\") == 72\n assert candidate(s = \"0000000000000001\") == 0\n assert candidate(s = \"111110000000000000000000000000000000\") == 155\n assert candidate(s = \"0110001100001111\") == 22\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010101010101010\") == 741\n assert candidate(s = \"1010101010101010101010\") == 66\n assert candidate(s = \"1111111111\") == 0\n assert candidate(s = \"110011001100110011001100110011001100\") == 180\n assert candidate(s = \"0000000000000000011111111111111\") == 0\n assert candidate(s = \"00011100011100011100\") == 45\n assert candidate(s = \"11101110111011101110\") == 45\n assert candidate(s = \"001001001001001001001001001001001001001001001001001001001001001001\") == 462\n assert candidate(s = \"11100000011\") == 18\n assert candidate(s = \"1111110000000000000000000000000000000000000000000000000\") == 294\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\") == 351\n assert candidate(s = \"110011001100110011001100110011\") == 112\n assert candidate(s = \"01010101010101010101\") == 45\n assert candidate(s = \"1001001001001001001001001001\") == 90\n assert candidate(s = \"1000011110000111100001\") == 60\n assert candidate(s = \"101010101010101010101010101010101010\") == 171\n assert candidate(s = \"011111111111111111111111111111111111\") == 0\n assert candidate(s = \"110110110110110\") == 30\n assert candidate(s = \"10101010101010101010\") == 55\n assert candidate(s = \"111000111000111000111000\") == 90\n assert candidate(s = \"1000010000100001000010000100001\") == 84\n assert candidate(s = \"0111100001110000111000\") == 74\n assert candidate(s = \"0000000000000000000000000000\") == 0\n assert candidate(s = \"000111000111000\") == 27\n assert candidate(s = \"0000111100001111\") == 16\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumSteps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long minimumSteps(String s) {", "container": "Solution", "callable": "minimumSteps", "parameters": [{"name": "s", "type": "String"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2939, "task_id": "maximum-xor-product", "difficulty": "Medium", "problem_description": "Given three integers a, b, and n, return the maximum value of (a XOR x) * (b XOR x) where 0 <= x < 2n.\nSince the answer may be too large, return it modulo 109 + 7.\nNote that XOR is the bitwise XOR operation.\n \nExample 1:\n\nInput: a = 12, b = 5, n = 4\nOutput: 98\nExplanation: For x = 2, (a XOR x) = 14 and (b XOR x) = 7. Hence, (a XOR x) * (b XOR x) = 98. \nIt can be shown that 98 is the maximum value of (a XOR x) * (b XOR x) for all 0 <= x < 2n.\n\nExample 2:\n\nInput: a = 6, b = 7 , n = 5\nOutput: 930\nExplanation: For x = 25, (a XOR x) = 31 and (b XOR x) = 30. Hence, (a XOR x) * (b XOR x) = 930.\nIt can be shown that 930 is the maximum value of (a XOR x) * (b XOR x) for all 0 <= x < 2n.\nExample 3:\n\nInput: a = 1, b = 6, n = 3\nOutput: 12\nExplanation: For x = 5, (a XOR x) = 4 and (b XOR x) = 3. Hence, (a XOR x) * (b XOR x) = 12.\nIt can be shown that 12 is the maximum value of (a XOR x) * (b XOR x) for all 0 <= x < 2n.\n\n \nConstraints:\n\n0 <= a, b < 250\n0 <= n <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 7,b = 14,n = 4) == 98\n assert candidate(a = 15,b = 9,n = 4) == 143\n assert candidate(a = 1,b = 2,n = 1) == 2\n assert candidate(a = 6,b = 7,n = 5) == 930\n assert candidate(a = 1024,b = 512,n = 11) == 1570305\n assert candidate(a = 3,b = 12,n = 4) == 56\n assert candidate(a = 12,b = 5,n = 4) == 98\n assert candidate(a = 249,b = 249,n = 50) == 178448631\n assert candidate(a = 0,b = 0,n = 50) == 178448631\n assert candidate(a = 0,b = 0,n = 5) == 961\n assert candidate(a = 3,b = 3,n = 2) == 9\n assert candidate(a = 8,b = 8,n = 4) == 225\n assert candidate(a = 1024,b = 512,n = 10) == 1570305\n assert candidate(a = 249,b = 248,n = 50) == 279487308\n assert candidate(a = 7,b = 3,n = 3) == 21\n assert candidate(a = 1,b = 1,n = 1) == 1\n assert candidate(a = 1,b = 6,n = 3) == 12\n assert candidate(a = 1099511627776,b = 2199023255552,n = 42) == 421746426\n assert candidate(a = 123,b = 456,n = 10) == 647348\n assert candidate(a = 1000000000,b = 1000000000,n = 30) == 388912871\n assert candidate(a = 1023456789,b = 9876543210,n = 30) == 443244632\n assert candidate(a = 4294967295,b = 1,n = 32) == 145586001\n assert candidate(a = 256,b = 1024,n = 11) == 1832193\n assert candidate(a = 25,b = 25,n = 5) == 961\n assert candidate(a = 1,b = 2499999999999,n = 50) == 63711638\n assert candidate(a = 4294967295,b = 4294967295,n = 32) == 992409480\n assert candidate(a = 0,b = 1,n = 50) == 279487308\n assert candidate(a = 1023,b = 512,n = 10) == 589056\n assert candidate(a = 123456,b = 654321,n = 20) == 306001604\n assert candidate(a = 123456789,b = 987654321,n = 35) == 251423918\n assert candidate(a = 4294967294,b = 4294967295,n = 32) == 697442213\n assert candidate(a = 8,b = 15,n = 4) == 132\n assert candidate(a = 2,b = 3,n = 50) == 279487308\n assert candidate(a = 500000000,b = 500000001,n = 30) == 315171055\n assert candidate(a = 45,b = 28,n = 6) == 1426\n assert candidate(a = 500000000,b = 1000000000,n = 35) == 632039372\n assert candidate(a = 8,b = 4,n = 3) == 77\n assert candidate(a = 9876543210987654,b = 1234567890123456,n = 50) == 300686351\n assert candidate(a = 1023,b = 2047,n = 11) == 2094081\n assert candidate(a = 456789123,b = 234567891,n = 35) == 765343141\n assert candidate(a = 999999999,b = 888888888,n = 45) == 179328999\n assert candidate(a = 789,b = 101112,n = 15) == 211542482\n assert candidate(a = 123456789,b = 987654321,n = 20) == 309102622\n assert candidate(a = 67890,b = 13579,n = 15) == 715925548\n assert candidate(a = 31,b = 15,n = 5) == 465\n assert candidate(a = 1000000000,b = 500000000,n = 30) == 446861332\n assert candidate(a = 111111111,b = 222222222,n = 40) == 554920250\n assert candidate(a = 1000000000,b = 2000000000,n = 49) == 857287546\n assert candidate(a = 1,b = 2147483647,n = 30) == 536396503\n assert candidate(a = 987654321,b = 123456789,n = 30) == 664805056\n assert candidate(a = 555555555,b = 666666666,n = 48) == 651387213\n assert candidate(a = 299999999,b = 299999998,n = 28) == 523486406\n assert candidate(a = 1048576,b = 2097152,n = 22) == 64477598\n assert candidate(a = 2147483647,b = 1073741823,n = 31) == 851567558\n assert candidate(a = 1,b = 2147483647,n = 50) == 519485508\n assert candidate(a = 135792468,b = 246813579,n = 32) == 736568943\n assert candidate(a = 1000000000000,b = 999999999999,n = 40) == 810111777\n assert candidate(a = 1,b = 2,n = 50) == 481564664\n assert candidate(a = 18446744073709551615,b = 18446744073709551614,n = 50) == 532600269\n assert candidate(a = 50,b = 50,n = 10) == 1046529\n assert candidate(a = 2147483647,b = 2147483647,n = 32) == 992409480\n assert candidate(a = 65535,b = 131071,n = 17) == 589737929\n assert candidate(a = 13,b = 29,n = 5) == 465\n assert candidate(a = 123456789,b = 987654321,n = 30) == 664805056\n assert candidate(a = 2147483647,b = 1,n = 30) == 536396503\n assert candidate(a = 1000000000,b = 1000000000,n = 31) == 850618742\n assert candidate(a = 123,b = 456,n = 8) == 84660\n assert candidate(a = 12345,b = 67890,n = 15) == 742597886\n assert candidate(a = 2,b = 3,n = 1) == 6\n assert candidate(a = 1,b = 2147483647,n = 31) == 536396503\n assert candidate(a = 248,b = 231,n = 10) == 1015056\n assert candidate(a = 999999999,b = 999999998,n = 30) == 315171055\n assert candidate(a = 511,b = 1023,n = 10) == 522753\n assert candidate(a = 1,b = 0,n = 50) == 279487308\n"}, "metadata": {"canonical_parameter_names": ["a", "b", "n"], "leetcode_dataset_entry_point": "Solution().maximumXorProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximumXorProduct(long a, long b, int n) {", "container": "Solution", "callable": "maximumXorProduct", "parameters": [{"name": "a", "type": "long"}, {"name": "b", "type": "long"}, {"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2940, "task_id": "find-building-where-alice-and-bob-can-meet", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building.\nIf a person is in building i, they can move to any other building j if and only if i < j and heights[i] < heights[j].\nYou are also given another array queries where queries[i] = [ai, bi]. On the ith query, Alice is in building ai while Bob is in building bi.\nReturn an array ans where ans[i] is the index of the leftmost building where Alice and Bob can meet on the ith query. If Alice and Bob cannot move to a common building on query i, set ans[i] to -1.\n \nExample 1:\n\nInput: heights = [6,4,8,5,2,7], queries = [[0,1],[0,3],[2,4],[3,4],[2,2]]\nOutput: [2,5,-1,5,2]\nExplanation: In the first query, Alice and Bob can move to building 2 since heights[0] < heights[2] and heights[1] < heights[2]. \nIn the second query, Alice and Bob can move to building 5 since heights[0] < heights[5] and heights[3] < heights[5]. \nIn the third query, Alice cannot meet Bob since Alice cannot move to any other building.\nIn the fourth query, Alice and Bob can move to building 5 since heights[3] < heights[5] and heights[4] < heights[5].\nIn the fifth query, Alice and Bob are already in the same building. \nFor ans[i] != -1, It can be shown that ans[i] is the leftmost building where Alice and Bob can meet.\nFor ans[i] == -1, It can be shown that there is no building where Alice and Bob can meet.\n\nExample 2:\n\nInput: heights = [5,3,8,2,6,1,4,6], queries = [[0,7],[3,5],[5,2],[3,0],[1,6]]\nOutput: [7,6,-1,4,6]\nExplanation: In the first query, Alice can directly move to Bob's building since heights[0] < heights[7].\nIn the second query, Alice and Bob can move to building 6 since heights[3] < heights[6] and heights[5] < heights[6].\nIn the third query, Alice cannot meet Bob since Bob cannot move to any other building.\nIn the fourth query, Alice and Bob can move to building 4 since heights[3] < heights[4] and heights[0] < heights[4].\nIn the fifth query, Alice can directly move to Bob's building since heights[1] < heights[6].\nFor ans[i] != -1, It can be shown that ans[i] is the leftmost building where Alice and Bob can meet.\nFor ans[i] == -1, It can be shown that there is no building where Alice and Bob can meet.\n\n\n \nConstraints:\n\n1 <= heights.length <= 5 * 104\n1 <= heights[i] <= 109\n1 <= queries.length <= 5 * 104\nqueries[i] = [ai, bi]\n0 <= ai, bi <= heights.length - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [10, 20, 30, 40, 50],queries = [[0, 4], [1, 3], [2, 2], [3, 1]]) == [4, 3, 2, 3]\n assert candidate(heights = [1, 2, 3, 4, 5],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 4]]) == [1, 2, 3, 4, 4]\n assert candidate(heights = [5, 4, 3, 2, 1],queries = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [-1, -1, -1, -1]\n assert candidate(heights = [5, 5, 5, 5, 5],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == [-1, -1, -1, -1, -1]\n assert candidate(heights = [1, 3, 5, 7, 9],queries = [[0, 2], [1, 3], [2, 4], [3, 4]]) == [2, 3, 4, 4]\n assert candidate(heights = [1, 2, 3, 2, 1],queries = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [1, 2, -1, -1]\n assert candidate(heights = [1, 2, 3, 4, 5],queries = [[0, 4], [1, 3], [2, 2], [3, 1], [4, 0]]) == [4, 3, 2, 3, 4]\n assert candidate(heights = [5, 4, 3, 2, 1],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == [-1, -1, -1, -1, -1]\n assert candidate(heights = [6, 4, 8, 5, 2, 7],queries = [[0, 1], [0, 3], [2, 4], [3, 4], [2, 2]]) == [2, 5, -1, 5, 2]\n assert candidate(heights = [100, 200, 150, 300, 250],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == [1, 3, 3, -1, 4]\n assert candidate(heights = [50, 40, 30, 20, 10],queries = [[0, 4], [1, 3], [2, 2], [3, 1]]) == [-1, -1, 2, -1]\n assert candidate(heights = [10, 20, 30, 40, 50],queries = [[0, 2], [1, 3], [2, 4], [0, 4], [1, 4]]) == [2, 3, 4, 4, 4]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6]]) == [-1, -1, -1, -1]\n assert candidate(heights = [1, 2, 3, 4, 5],queries = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [1, 2, 3, 4]\n assert candidate(heights = [1, 2, 3, 4, 5],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == [1, 2, 3, 4, 4]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [-1, -1, -1, -1, -1]\n assert candidate(heights = [1, 1, 1, 1, 1],queries = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [-1, -1, -1, -1]\n assert candidate(heights = [5, 3, 8, 2, 6, 1, 4, 6],queries = [[0, 7], [3, 5], [5, 2], [3, 0], [1, 6]]) == [7, 6, -1, 4, 6]\n assert candidate(heights = [10, 20, 30, 40, 50],queries = [[0, 2], [1, 3], [2, 4], [0, 4], [1, 2]]) == [2, 3, 4, 4, 2]\n assert candidate(heights = [1, 1, 1, 1, 1],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == [-1, -1, -1, -1, -1]\n assert candidate(heights = [1, 9, 2, 8, 3, 7, 4, 6, 5],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [1, -1, 3, -1, 5, -1, 7, -1]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [8, 6], [9, 5], [10, 4], [11, 3], [12, 2], [13, 1]]) == [14, 13, 12, 11, 10, 9, 8, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [0, 8]]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [10, 10, 10, 10, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4], [4, 0], [3, 2], [2, 1], [1, 0]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [5, 3, 8, 2, 6, 1, 4, 6, 9, 7, 11, 13, 12],queries = [[0, 12], [1, 11], [2, 10], [3, 9], [4, 8], [5, 7], [6, 6], [7, 5], [8, 4], [9, 3], [10, 2], [11, 1], [12, 0]]) == [12, 11, 10, 9, 8, 7, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == [1, -1, 3, -1, 5, -1, 7, -1, 9, 9]\n assert candidate(heights = [5, 3, 8, 6, 7, 2, 4, 1, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [9, 8, 8, 8, 8, 8, 8, 8, 8, 9]\n assert candidate(heights = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == [13, 12, 11, 10, 9, 8, 7]\n assert candidate(heights = [5, 4, 3, 2, 1, 2, 3, 4, 5],queries = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [0, 8], [1, 7], [2, 6], [3, 5]]) == [-1, 8, 7, 7, 8, -1, 8, 7, 6]\n assert candidate(heights = [1, 2, 3, 2, 1, 3, 2, 1, 2, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [-1, -1, -1, -1, 5, 5, -1, -1, -1, -1]\n assert candidate(heights = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [9, 9, 7, 9, 5, 5, 9, 7, 9, 9]\n assert candidate(heights = [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], [0, 15], [1, 16], [2, 17], [3, 18], [0, 18], [1, 17], [2, 16], [3, 15]]) == [19, 18, 17, 16, 15, 15, 16, 17, 18, 18, 17, 16, 15]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [14, 13, 12, 11, 10, 9, 8, 7]\n assert candidate(heights = [5, 4, 3, 2, 1, 10],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [0, 4]]) == [5, 5, 5, 5, 5, 5]\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9]\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [-1, -1, -1, -1, -1]\n assert candidate(heights = [50, 40, 30, 20, 10],queries = [[0, 4], [1, 3], [2, 2], [3, 1], [4, 0]]) == [-1, -1, 2, -1, -1]\n assert candidate(heights = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [1, -1, 3, -1, 5, -1, 7, -1, 9]\n assert candidate(heights = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600],queries = [[0, 9], [2, 5], [3, 7], [1, 8], [4, 6]]) == [9, 5, 7, 8, 6]\n assert candidate(heights = [1, 2, 3, 2, 1, 2, 3, 2, 1],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0]]) == [-1, -1, -1, 6, 4, 6, -1, -1, -1]\n assert candidate(heights = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2],queries = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [0, 9]]) == [2, 6, -1, 6, 6, -1, -1, -1, 9]\n assert candidate(heights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [1, 0], [3, 2], [5, 4], [7, 6], [9, 8]]) == [1, 3, 5, 7, 9, 1, 3, 5, 7, 9]\n assert candidate(heights = [1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [0, 5], [1, 6], [2, 7]]) == [8, 7, 6, 5, 4, 5, 6, 7]\n assert candidate(heights = [1, 2, 3, 4, 5, 4, 3, 2, 1],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0]]) == [-1, -1, -1, -1, 4, -1, -1, -1, -1]\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [1, 6], [2, 7], [3, 8], [0, 8]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [-1, -1, -1, -1, -1, 14, 13, 12, 11, 10]\n assert candidate(heights = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],queries = [[0, 5], [5, 0], [2, 8], [8, 2], [4, 4]]) == [5, 5, 8, 8, 4]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [9, -1, 7, -1, 5, 5, -1, 7, -1, 9]\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [9, 8, 7, 6, 5, 5, 6, 7, 8, 9]\n assert candidate(heights = [1, 5, 3, 7, 9, 2, 8, 6, 4, 10],queries = [[0, 9], [2, 5], [3, 7], [1, 8], [4, 6]]) == [9, 6, 9, 9, 9]\n assert candidate(heights = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 10, 8, 9, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [-1, -1, 17, -1, 15, -1, 13, 12, 11, 10]\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [-1, -1, -1, -1, -1]\n assert candidate(heights = [1, 10, 3, 12, 5, 14, 7, 16, 9, 18],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == [1, 3, 3, 5, 5, 7, 7, 9, 9, 9]\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],queries = [[0, 9], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18]]) == [10, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [0, 6], [1, 5], [2, 4], [3, 5], [4, 5], [5, 7], [6, 8]]) == [10, 9, 8, 7, 6, 6, 5, 4, 5, 5, 7, 8]\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [2, 2, 4, 4, 6, 6, 8, 8, -1]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[9, 0], [8, 1], [7, 2], [6, 3], [5, 4], [4, 5], [3, 6], [2, 7], [1, 8], [0, 9]]) == [9, 8, 7, 6, 5, 5, 6, 7, 8, 9]\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [9, 8, 7, 6, 5, 5, 6, 7, 8, 9]\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [100, 200, 150, 250, 300, 100, 150, 200, 250, 300],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [9, 8, 7, 9, -1, -1, 9, 7, 8, 9]\n assert candidate(heights = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [0, 8]]) == [-1, 8, 8, 6, 6, 6, 6, 8, 8, 8]\n assert candidate(heights = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [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], [0, 5], [5, 0]]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 5, 5]\n assert candidate(heights = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [9, 8, 7, 6, 5, 5, 6, 7, 8, 9]\n assert candidate(heights = [5, 15, 25, 35, 45, 30, 20, 10, 50, 60],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [9, 8, 8, 8, 8, 8, 8, 8, 8, 9]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [0, 6], [1, 5], [2, 4], [3, 5], [4, 5]]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [100, 200, 150, 300, 250, 350],queries = [[0, 2], [1, 5], [2, 3], [3, 4], [4, 5], [0, 5]]) == [2, 5, 3, 5, 5, 5]\n assert candidate(heights = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [8, 6], [9, 5], [10, 4], [11, 3], [12, 2], [13, 1]]) == [14, 13, 12, 11, 10, 9, 8, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(heights = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [5, 1, 4, 3, 2, 6, 7, 8],queries = [[0, 6], [1, 5], [2, 7], [3, 4], [5, 7], [6, 7], [0, 7]]) == [6, 5, 7, 5, 7, 7, 7]\n assert candidate(heights = [50, 40, 30, 20, 10],queries = [[4, 0], [3, 1], [2, 2], [1, 3], [0, 4]]) == [-1, -1, 2, -1, -1]\n assert candidate(heights = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 6, 4, 7, 3, 8, 2, 9, 1],queries = [[0, 17], [1, 16], [2, 15], [3, 14], [4, 13], [5, 12], [6, 11], [7, 10], [8, 9], [9, 8], [10, 7], [11, 6], [12, 5], [13, 4], [14, 3], [15, 2], [16, 1], [17, 0]]) == [-1, -1, 16, 16, 14, 14, 12, 12, 10, 10, 12, 12, 14, 14, 16, 16, -1, -1]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [1, 6], [2, 7], [3, 8], [0, 8]]) == [9, -1, 7, -1, 5, 5, -1, 7, -1, 8]\n assert candidate(heights = [1, 2, 3, 4, 5, 4, 3, 2, 1],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0]]) == [-1, -1, -1, -1, 4, 3, 2, 1, 0]\n assert candidate(heights = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [0, 5], [1, 6], [2, 7]]) == [-1, -1, -1, -1, 4, -1, -1, -1]\n assert candidate(heights = [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], [7, 7]]) == [14, 13, 12, 11, 10, 9, 8, 7]\n assert candidate(heights = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [-1, 8, -1, 6, -1]\n assert candidate(heights = [1, 5, 3, 6, 7, 8, 2, 4],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 4], [1, 5], [6, 7]]) == [7, -1, 5, 4, 4, 5, 7]\n assert candidate(heights = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [-1, 8, -1, 6, -1, -1, 6, -1, 8, -1]\n assert candidate(heights = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [9, 8, 7, 6, 5]\n assert candidate(heights = [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], [0, 8]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [-1, -1, -1, -1, -1, 14, 13, 12, 11, 10]\n assert candidate(heights = [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]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [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], [10, 9], [11, 8], [12, 7], [13, 6], [14, 5], [15, 4], [16, 3], [17, 2], [18, 1], [19, 0]]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(heights = [1, 3, 2, 4, 7, 6, 5, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [9, 8, 7, 6, 7, 7, 6, 7, 8, 9]\n assert candidate(heights = [1, 10, 1, 10, 1, 10, 1, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [1, -1, 3, -1, 5, -1, 7]\n assert candidate(heights = [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]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(heights = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == [-1, -1, -1, -1, -1]\n assert candidate(heights = [5, 1, 4, 2, 3, 6, 8, 7, 10, 9],queries = [[0, 4], [1, 3], [2, 5], [6, 9], [7, 8]]) == [5, 3, 5, 9, 8]\n assert candidate(heights = [5, 1, 3, 7, 9, 2, 8, 6, 10],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 3], [5, 2], [6, 1], [7, 0]]) == [8, 7, 6, 6, 4, 6, 6, 7]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [1, 0]]) == [9, -1, 7, -1, 5, 1, 1]\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2],queries = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == [9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [0, 8]]) == [9, 8, 7, 6, 5, 5, 6, 7, 8, 8]\n assert candidate(heights = [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], [0, 10], [5, 15]]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 10, 15]\n assert candidate(heights = [1, 3, 2, 4, 3, 5, 4],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6]]) == [1, 3, 3, 5, 5, -1, 6]\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [14, 13, 12, 11, 10, 9, 8, 7]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [9, 8, 7, 6, 5, 5, 6, 7, 8, 9]\n assert candidate(heights = [5, 3, 8, 2, 6, 1, 4, 6],queries = [[0, 7], [3, 5], [5, 2], [3, 0], [1, 6], [2, 4], [6, 3], [4, 5]]) == [7, 6, -1, 4, 6, -1, 6, -1]\n assert candidate(heights = [100, 200, 150, 300, 250, 400, 350, 500],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 4], [1, 5], [2, 6], [0, 6], [1, 7]]) == [7, 6, 5, 5, 4, 5, 6, 6, 7]\n assert candidate(heights = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10],queries = [[0, 9], [2, 5], [4, 8], [1, 7], [3, 6]]) == [9, 5, 8, 7, 6]\n assert candidate(heights = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [-1, -1, 7, 7, -1, -1, 7, 7, -1, -1]\n assert candidate(heights = [5, 5, 5, 5, 5, 5],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 5]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(heights = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [-1, -1, -1, -1, -1, -1, -1, 7]\n assert candidate(heights = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0]]) == [-1, -1, -1, -1, 4, -1, -1, -1, -1]\n"}, "metadata": {"canonical_parameter_names": ["heights", "queries"], "leetcode_dataset_entry_point": "Solution().leftmostBuildingQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] leftmostBuildingQueries(int[] heights, int[][] queries) {", "container": "Solution", "callable": "leftmostBuildingQueries", "parameters": [{"name": "heights", "type": "int[]"}, {"name": "queries", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2942, "task_id": "find-words-containing-character", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array of strings words and a character x.\nReturn an array of indices representing the words that contain the character x.\nNote that the returned array may be in any order.\n \nExample 1:\n\nInput: words = [\"leet\",\"code\"], x = \"e\"\nOutput: [0,1]\nExplanation: \"e\" occurs in both words: \"leet\", and \"code\". Hence, we return indices 0 and 1.\n\nExample 2:\n\nInput: words = [\"abc\",\"bcd\",\"aaaa\",\"cbc\"], x = \"a\"\nOutput: [0,2]\nExplanation: \"a\" occurs in \"abc\", and \"aaaa\". Hence, we return indices 0 and 2.\n\nExample 3:\n\nInput: words = [\"abc\",\"bcd\",\"aaaa\",\"cbc\"], x = \"z\"\nOutput: []\nExplanation: \"z\" does not occur in any of the words. Hence, we return an empty array.\n\n \nConstraints:\n\n1 <= words.length <= 50\n1 <= words[i].length <= 50\nx is a lowercase English letter.\nwords[i] consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'bcd', 'aaaa', 'cbc'],x = \"z\") == []\n assert candidate(words = ['python', 'programming'],x = \"o\") == [0, 1]\n assert candidate(words = ['ab', 'cd', 'ef'],x = \"g\") == []\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc'],x = \"a\") == [0]\n assert candidate(words = ['apple', 'banana', 'cherry'],x = \"a\") == [0, 1]\n assert candidate(words = ['hello', 'world'],x = \"l\") == [0, 1]\n assert candidate(words = ['hello', 'world'],x = \"o\") == [0, 1]\n assert candidate(words = ['algorithm', 'data', 'structure'],x = \"t\") == [0, 1, 2]\n assert candidate(words = ['leet', 'code'],x = \"e\") == [0, 1]\n assert candidate(words = ['red', 'blue', 'green'],x = \"e\") == [0, 1, 2]\n assert candidate(words = ['sun', 'moon', 'star'],x = \"u\") == [0]\n assert candidate(words = ['test', 'example', 'input'],x = \"t\") == [0, 2]\n assert candidate(words = ['abc', 'bcd', 'aaaa', 'cbc'],x = \"a\") == [0, 2]\n assert candidate(words = ['algorithm', 'data', 'structure'],x = \"a\") == [0, 1]\n assert candidate(words = ['example', 'test', 'case'],x = \"x\") == [0]\n assert candidate(words = ['unique', 'characters'],x = \"u\") == [0]\n assert candidate(words = ['a', 'b', 'c'],x = \"d\") == []\n assert candidate(words = ['hello', 'world', 'python'],x = \"o\") == [0, 1, 2]\n assert candidate(words = ['one', 'two', 'three'],x = \"t\") == [1, 2]\n assert candidate(words = ['meeting', 'event', 'conference'],x = \"e\") == [0, 1, 2]\n assert candidate(words = ['find', 'words', 'containing'],x = \"n\") == [0, 2]\n assert candidate(words = ['python', 'java', 'csharp'],x = \"p\") == [0, 2]\n assert candidate(words = ['dog', 'cat', 'bird'],x = \"d\") == [0, 2]\n assert candidate(words = ['one', 'two', 'three'],x = \"e\") == [0, 2]\n assert candidate(words = ['algorithm', 'datastructure', 'programming', 'interview'],x = \"m\") == [0, 2]\n assert candidate(words = ['banana', 'apple', 'orange', 'grape'],x = \"o\") == [2]\n assert candidate(words = ['interface', 'function', 'method', 'parameter', 'argument'],x = \"p\") == [3]\n assert candidate(words = ['mississippi', 'delaware', 'indiana', 'illinois'],x = \"i\") == [0, 2, 3]\n assert candidate(words = ['repeated', 'character', 'example'],x = \"e\") == [0, 1, 2]\n assert candidate(words = ['mississippi', 'hawaii', 'alaska'],x = \"i\") == [0, 1]\n assert candidate(words = ['quizzing', 'quiz', 'quizzes'],x = \"z\") == [0, 1, 2]\n assert candidate(words = ['sunshine', 'rainbow', 'cloud', 'sky', 'ocean', 'beach'],x = \"n\") == [0, 1, 4]\n assert candidate(words = ['xylophone', 'triangle', 'square', 'rectangle', 'pentagon'],x = \"p\") == [0, 4]\n assert candidate(words = ['repetition', 'repeated', 'repetitive', 'repetition'],x = \"p\") == [0, 1, 2, 3]\n assert candidate(words = ['mississippi', 'mississippian', 'mississippians', 'mississippify'],x = \"p\") == [0, 1, 2, 3]\n assert candidate(words = ['xylophone', 'xylography', 'xylophonist'],x = \"x\") == [0, 1, 2]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],x = \"a\") == [0, 1, 3]\n assert candidate(words = ['mississippi', 'hannah', 'racecar', 'level'],x = \"i\") == [0]\n assert candidate(words = ['university', 'college', 'school', 'institute'],x = \"u\") == [0, 3]\n assert candidate(words = ['docker', 'kubernetes', 'container', 'orchestration', 'deployment'],x = \"d\") == [0, 4]\n assert candidate(words = ['python', 'java', 'c', 'javascript'],x = \"v\") == [1, 3]\n assert candidate(words = ['repetition', 'occurrence', 'continuous', 'discontinuous'],x = \"o\") == [0, 1, 2, 3]\n assert candidate(words = ['fantastic', 'extraordinary', 'remarkable', 'astonishing', 'amazing'],x = \"a\") == [0, 1, 2, 3, 4]\n assert candidate(words = ['onlyonecharacter', 'twochars', 'threechars'],x = \"c\") == [0, 1, 2]\n assert candidate(words = ['zebra', 'elephant', 'giraffe', 'hippopotamus'],x = \"e\") == [0, 1, 2]\n assert candidate(words = ['antidisestablishmentarianism', 'floccinaucinihilipilification', 'supercalifragilisticexpialidocious'],x = \"t\") == [0, 1, 2]\n assert candidate(words = ['abcdefg', 'hijklmn', 'opqrstu'],x = \"x\") == []\n assert candidate(words = ['floccinaucinihilipilification', 'supercalifragilisticexpialidocious'],x = \"c\") == [0, 1]\n assert candidate(words = ['mississippi', 'misterious', 'mismatch', 'misconduct'],x = \"m\") == [0, 1, 2, 3]\n assert candidate(words = ['responsive', 'design', 'user', 'interface'],x = \"e\") == [0, 1, 2, 3]\n assert candidate(words = ['same', 'same', 'same'],x = \"a\") == [0, 1, 2]\n assert candidate(words = ['abcdefghij', 'klmnopqrstu', 'vwxyz'],x = \"x\") == [2]\n assert candidate(words = ['angular', 'react', 'vue', 'ember', 'svelte'],x = \"a\") == [0, 1]\n assert candidate(words = ['algorithm', 'datastructure', 'programming'],x = \"a\") == [0, 1, 2]\n assert candidate(words = ['programming', 'coding', 'software', 'development'],x = \"o\") == [0, 1, 2, 3]\n assert candidate(words = ['encyclopedia', 'dictionary', 'thesaurus'],x = \"o\") == [0, 1]\n assert candidate(words = ['environment', 'environmental', 'environments', 'environmentalist'],x = \"v\") == [0, 1, 2, 3]\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'abcdefgh', 'dcba'],x = \"f\") == [0, 1, 2]\n assert candidate(words = ['sequential', 'search', 'binary', 'hashmap'],x = \"h\") == [1, 3]\n assert candidate(words = ['multifaceted', 'multicolored', 'multifarious', 'multilingual'],x = \"m\") == [0, 1, 2, 3]\n assert candidate(words = ['optimization', 'complexity', 'graph', 'matrix'],x = \"i\") == [0, 1, 3]\n assert candidate(words = ['xyz', 'zyx', 'yxz', 'zyzxzyx'],x = \"x\") == [0, 1, 2, 3]\n assert candidate(words = ['database', 'schema', 'table', 'column', 'index'],x = \"b\") == [0, 2]\n assert candidate(words = ['single'],x = \"s\") == [0]\n assert candidate(words = ['university', 'algorithm', 'quantum', 'computer'],x = \"u\") == [0, 2, 3]\n assert candidate(words = ['embedded', 'real', 'time', 'system'],x = \"z\") == []\n assert candidate(words = ['xylophone', 'guitar', 'drum', 'flute'],x = \"u\") == [1, 2, 3]\n assert candidate(words = ['algorithm', 'datastructure', 'code', 'debug'],x = \"a\") == [0, 1]\n assert candidate(words = ['pneumonoultramicroscopicsilicovolcanoconiosis', 'super', 'hyper', 'sub'],x = \"o\") == [0]\n assert candidate(words = ['unbelievable', 'unbelievably', 'unbelievable', 'unbelievable'],x = \"u\") == [0, 1, 2, 3]\n assert candidate(words = ['interstellar', 'galaxy', 'cosmic', 'universe'],x = \"i\") == [0, 2, 3]\n assert candidate(words = ['mississippi', 'massachusetts', 'minimum'],x = \"i\") == [0, 2]\n assert candidate(words = ['unitedstates', 'canada', 'mexico', 'brazil'],x = \"a\") == [0, 1, 3]\n assert candidate(words = ['xylophone', 'xylo', 'xy', 'x'],x = \"x\") == [0, 1, 2, 3]\n assert candidate(words = ['congratulations', 'celebration', 'felicitation'],x = \"t\") == [0, 1, 2]\n assert candidate(words = ['apple', 'banana', 'cherry', 'date'],x = \"b\") == [1]\n assert candidate(words = ['repetition', 'occurrence', 'frequency', 'infrequent'],x = \"r\") == [0, 1, 2, 3]\n assert candidate(words = ['machine', 'learning', 'artificial', 'intelligence', 'neural'],x = \"a\") == [0, 1, 2, 4]\n assert candidate(words = ['character', 'charts', 'chocolate', 'chartreuse'],x = \"c\") == [0, 1, 2, 3]\n assert candidate(words = ['supercalifragilisticexpialidocious', 'pneumonoultramicroscopicsilicovolcanoconiosis'],x = \"s\") == [0, 1]\n assert candidate(words = ['hello', 'world', 'python', 'programming'],x = \"m\") == [3]\n assert candidate(words = ['complexity', 'analysis', 'optimization'],x = \"x\") == [0]\n assert candidate(words = ['banana', 'bandana', 'panacea'],x = \"a\") == [0, 1, 2]\n assert candidate(words = ['python', 'java', 'csharp', 'javascript'],x = \"p\") == [0, 2, 3]\n assert candidate(words = ['compiler', 'interpreter', 'virtual', 'machine'],x = \"r\") == [0, 1, 2]\n assert candidate(words = ['repetition', 'character', 'sequence', 'word', 'dictionary'],x = \"e\") == [0, 1, 2]\n assert candidate(words = ['typescript', 'javascript', 'python', 'java', 'csharp'],x = \"s\") == [0, 1, 4]\n assert candidate(words = ['network', 'protocol', 'security', 'encryption', 'decryption'],x = \"c\") == [1, 2, 3, 4]\n assert candidate(words = ['rain', 'rainbow', 'raining', 'raincoat'],x = \"n\") == [0, 1, 2, 3]\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],x = \"b\") == [0, 1, 2, 3, 4, 5]\n assert candidate(words = ['xylophone', 'xylography', 'xylophone'],x = \"x\") == [0, 1, 2]\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],x = \"a\") == [0, 4]\n assert candidate(words = ['algorithm', 'data', 'structure', 'programming'],x = \"a\") == [0, 1, 3]\n assert candidate(words = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm', 'qwerty'],x = \"t\") == [0, 3]\n assert candidate(words = ['environment', 'variable', 'configuration', 'parameter', 'setting'],x = \"e\") == [0, 1, 3, 4]\n assert candidate(words = ['internet', 'of', 'things', 'iot'],x = \"t\") == [0, 2, 3]\n assert candidate(words = ['xyz', 'zyx', 'yxz'],x = \"z\") == [0, 1, 2]\n assert candidate(words = ['repetition', 'recursion', 'iteration', 'permutation'],x = \"e\") == [0, 1, 2, 3]\n assert candidate(words = ['zebra', 'xylophone', 'zoo', 'zest'],x = \"z\") == [0, 2, 3]\n assert candidate(words = ['quintessential', 'quotation', 'quiver', 'quadrilateral'],x = \"q\") == [0, 1, 2, 3]\n assert candidate(words = ['unique', 'united', 'union', 'unity'],x = \"i\") == [0, 1, 2, 3]\n assert candidate(words = ['supercalifragilisticexpialidocious', 'supercalifragilisticexpialidocious', 'supercalifragilisticexpialidocious'],x = \"x\") == [0, 1, 2]\n assert candidate(words = ['database', 'management', 'query', 'optimization'],x = \"q\") == [2]\n assert candidate(words = ['sequence', 'subsequence', 'consequence', 'dessequence'],x = \"q\") == [0, 1, 2, 3]\n assert candidate(words = ['programming', 'language', 'python'],x = \"o\") == [0, 2]\n assert candidate(words = ['compiler', 'interpreter', 'debugger', 'profiler', 'virtual'],x = \"o\") == [0, 3]\n assert candidate(words = ['fantastic', 'fantasy', 'fantastic', 'fantastically'],x = \"f\") == [0, 1, 2, 3]\n assert candidate(words = ['interview', 'question', 'answer', 'example'],x = \"i\") == [0, 1]\n assert candidate(words = ['responsive', 'layout', 'flexbox', 'grid', 'animation'],x = \"n\") == [0, 4]\n assert candidate(words = ['quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'],x = \"z\") == [6]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyzabcdefghijkl'],x = \"m\") == [0, 1, 2]\n assert candidate(words = ['artificial', 'intelligence', 'machine', 'learning'],x = \"i\") == [0, 1, 2, 3]\n assert candidate(words = ['encyclopedia', 'encyclopedia', 'encyclopedia', 'encyclopedia'],x = \"n\") == [0, 1, 2, 3]\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry'],x = \"a\") == [0, 1, 3]\n assert candidate(words = ['filesystem', 'directory', 'permission', 'read', 'write'],x = \"r\") == [1, 2, 3, 4]\n assert candidate(words = ['xylophone', 'xylography', 'xylophonist', 'xylophone'],x = \"x\") == [0, 1, 2, 3]\n assert candidate(words = ['algorithm', 'data', 'structure', 'programming', 'design'],x = \"g\") == [0, 3, 4]\n assert candidate(words = ['binary', 'search', 'tree', 'avl', 'hashmap'],x = \"h\") == [1, 4]\n assert candidate(words = ['abcdefghij', 'klmnopqr', 'stuvwxyz'],x = \"z\") == [2]\n assert candidate(words = ['verylongwordthatcontainsmanycharacters', 'short', 'tiny'],x = \"w\") == [0]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz'],x = \"m\") == [0, 1, 2]\n assert candidate(words = ['alphabet', 'beta', 'gamma', 'delta', 'epsilon'],x = \"a\") == [0, 1, 2, 3]\n assert candidate(words = ['nineteen', 'eighteen', 'seventeen'],x = \"e\") == [0, 1, 2]\n assert candidate(words = ['concurrent', 'parallel', 'distributed', 'systems'],x = \"c\") == [0]\n assert candidate(words = ['banana', 'ananas', 'pineapple', 'mango'],x = \"n\") == [0, 1, 2, 3]\n assert candidate(words = ['supercalifragilisticexpialidocious', 'pneumonoultramicroscopicsilicovolcanoconiosis'],x = \"o\") == [0, 1]\n assert candidate(words = ['frontend', 'backend', 'database', 'api', 'client'],x = \"d\") == [0, 1, 2]\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'],x = \"q\") == [16]\n assert candidate(words = ['embedded', 'real', 'time', 'system'],x = \"b\") == [0]\n assert candidate(words = ['unique', 'words', 'only'],x = \"q\") == [0]\n assert candidate(words = ['alphabet', 'xylophone', 'encyclopedia', 'dictionary', 'glossary'],x = \"y\") == [1, 2, 3, 4]\n assert candidate(words = ['repeated', 'characters', 'in', 'words'],x = \"e\") == [0, 1]\n assert candidate(words = ['longitudinal', 'lateral', 'longest', 'longevity'],x = \"o\") == [0, 2, 3]\n assert candidate(words = ['continuous', 'integration', 'deployment', 'pipeline', 'automation'],x = \"n\") == [0, 1, 2, 3, 4]\n assert candidate(words = ['algorithm', 'data', 'structures', 'binary'],x = \"a\") == [0, 1, 3]\n assert candidate(words = ['documentation', 'repository', 'commit', 'branch', 'merge'],x = \"m\") == [0, 2, 4]\n assert candidate(words = ['programming', 'language', 'python', 'java'],x = \"o\") == [0, 2]\n assert candidate(words = ['blockchain', 'cryptography', 'security', 'privacy'],x = \"y\") == [1, 2, 3]\n assert candidate(words = ['complex', 'complicated', 'complexContent', 'compulsive'],x = \"c\") == [0, 1, 2, 3]\n assert candidate(words = ['programming', 'language', 'python'],x = \"p\") == [0, 2]\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyza'],x = \"a\") == [0, 1, 2]\n"}, "metadata": {"canonical_parameter_names": ["words", "x"], "leetcode_dataset_entry_point": "Solution().findWordsContaining", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List findWordsContaining(String[] words, char x) {", "container": "Solution", "callable": "findWordsContaining", "parameters": [{"name": "words", "type": "String[]"}, {"name": "x", "type": "char"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2943, "task_id": "maximize-area-of-square-hole-in-grid", "difficulty": "Medium", "problem_description": "You are given the two integers, n and m and two integer arrays, hBars and vBars. The grid has n + 2 horizontal and m + 2 vertical bars, creating 1 x 1 unit cells. The bars are indexed starting from 1.\nYou can remove some of the bars in hBars from horizontal bars and some of the bars in vBars from vertical bars. Note that other bars are fixed and cannot be removed.\nReturn an integer denoting the maximum area of a square-shaped hole in the grid, after removing some bars (possibly none).\n \nExample 1:\n\n\nInput: n = 2, m = 1, hBars = [2,3], vBars = [2]\nOutput: 4\nExplanation:\nThe left image shows the initial grid formed by the bars. The horizontal bars are [1,2,3,4], and the vertical bars are [1,2,3].\nOne way to get the maximum square-shaped hole is by removing horizontal bar 2 and vertical bar 2.\n\nExample 2:\n\n\nInput: n = 1, m = 1, hBars = [2], vBars = [2]\nOutput: 4\nExplanation:\nTo get the maximum square-shaped hole, we remove horizontal bar 2 and vertical bar 2.\n\nExample 3:\n\n\nInput: n = 2, m = 3, hBars = [2,3], vBars = [2,4]\nOutput: 4\nExplanation:\nOne way to get the maximum square-shaped hole is by removing horizontal bar 3, and vertical bar 4.\n\n \nConstraints:\n\n1 <= n <= 109\n1 <= m <= 109\n1 <= hBars.length <= 100\n2 <= hBars[i] <= n + 1\n1 <= vBars.length <= 100\n2 <= vBars[i] <= m + 1\nAll values in hBars are distinct.\nAll values in vBars are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,m = 1,hBars = [2],vBars = [2]) == 4\n assert candidate(n = 2,m = 3,hBars = [2, 3],vBars = [2, 4]) == 4\n assert candidate(n = 2,m = 1,hBars = [2, 3],vBars = [2]) == 4\n assert candidate(n = 5,m = 5,hBars = [2, 3, 4],vBars = [2, 3, 4]) == 16\n assert candidate(n = 10,m = 10,hBars = [3, 5, 7],vBars = [4, 6, 8]) == 4\n assert candidate(n = 20,m = 10,hBars = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],vBars = [2, 4, 6, 8, 10]) == 4\n assert candidate(n = 15,m = 15,hBars = [3, 5, 7, 9, 11],vBars = [3, 5, 7, 9, 11]) == 4\n assert candidate(n = 20,m = 15,hBars = [5, 7, 9, 11, 13, 15, 17, 19],vBars = [6, 8, 10, 12, 14, 16, 18, 20]) == 4\n assert candidate(n = 15,m = 15,hBars = [3, 5, 7, 9, 11, 13, 15],vBars = [3, 5, 7, 9, 11, 13, 15]) == 4\n assert candidate(n = 10,m = 10,hBars = [2, 3, 5, 6],vBars = [3, 5, 7]) == 4\n assert candidate(n = 20,m = 10,hBars = [2, 4, 6, 8, 10],vBars = [3, 6, 9]) == 4\n assert candidate(n = 8,m = 6,hBars = [2, 3, 5, 7, 8],vBars = [2, 4, 6]) == 4\n assert candidate(n = 100,m = 50,hBars = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],vBars = [10, 20, 30, 40, 50]) == 4\n assert candidate(n = 20,m = 20,hBars = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],vBars = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 4\n assert candidate(n = 20,m = 20,hBars = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],vBars = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 400\n assert candidate(n = 6,m = 4,hBars = [2, 3, 4, 5, 6],vBars = [2, 4]) == 4\n assert candidate(n = 7,m = 6,hBars = [2, 4, 5, 7],vBars = [2, 4, 5]) == 9\n assert candidate(n = 3,m = 2,hBars = [2, 3],vBars = [2]) == 4\n assert candidate(n = 40,m = 30,hBars = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],vBars = [5, 7, 9, 11, 13, 15]) == 4\n assert candidate(n = 300,m = 200,hBars = [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],vBars = [40, 60, 80, 100, 120, 140, 160, 180, 200]) == 4\n assert candidate(n = 25,m = 25,hBars = [5, 10, 15, 20, 25],vBars = [5, 10, 15, 20, 25]) == 4\n assert candidate(n = 10,m = 10,hBars = [2, 3, 5, 7, 9],vBars = [2, 3, 5, 7, 9]) == 9\n assert candidate(n = 25,m = 25,hBars = [2, 5, 7, 10, 13, 15, 18, 20, 23],vBars = [3, 6, 9, 12, 15, 18, 21, 24]) == 4\n assert candidate(n = 9,m = 9,hBars = [2, 3, 5, 7, 8, 9],vBars = [2, 4, 6, 8]) == 4\n assert candidate(n = 9,m = 9,hBars = [3, 6, 9],vBars = [3, 6, 9]) == 4\n assert candidate(n = 50,m = 50,hBars = [10, 15, 20, 25, 30, 35, 40, 45, 50],vBars = [10, 15, 20, 25, 30, 35, 40, 45, 50]) == 4\n assert candidate(n = 200,m = 150,hBars = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44],vBars = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 4\n assert candidate(n = 20,m = 15,hBars = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],vBars = [2, 4, 6, 8, 10, 12, 14]) == 4\n assert candidate(n = 100,m = 100,hBars = [2, 50, 51, 52, 100],vBars = [2, 50, 51, 52, 100]) == 16\n assert candidate(n = 10,m = 10,hBars = [3, 5, 7],vBars = [3, 5, 7]) == 4\n assert candidate(n = 3,m = 3,hBars = [2, 3],vBars = [2, 3, 4]) == 9\n assert candidate(n = 25,m = 20,hBars = [2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],vBars = [2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 9\n assert candidate(n = 30,m = 25,hBars = [6, 12, 18, 24],vBars = [5, 10, 15, 20]) == 4\n assert candidate(n = 10,m = 10,hBars = [2, 3, 5, 7, 9],vBars = [2, 4, 6, 8, 10]) == 4\n assert candidate(n = 8,m = 8,hBars = [2, 3, 5, 6, 7],vBars = [2, 3, 5, 6, 7]) == 16\n assert candidate(n = 5,m = 5,hBars = [2, 4, 5],vBars = [2, 4]) == 4\n assert candidate(n = 150,m = 100,hBars = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38],vBars = [20, 30, 40, 50, 60, 70, 80, 90, 100]) == 4\n assert candidate(n = 6,m = 3,hBars = [2, 3, 4, 5],vBars = [2, 3]) == 9\n assert candidate(n = 50,m = 50,hBars = [2, 25, 26, 50],vBars = [2, 25, 26, 50]) == 9\n assert candidate(n = 50,m = 50,hBars = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],vBars = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]) == 4\n assert candidate(n = 5,m = 5,hBars = [2, 3, 4, 5],vBars = [2, 3, 4]) == 16\n assert candidate(n = 10,m = 20,hBars = [2, 3, 4, 5, 6],vBars = [5, 10, 15, 20]) == 4\n assert candidate(n = 15,m = 10,hBars = [3, 5, 7, 9, 11, 13, 15],vBars = [3, 5, 7, 9]) == 4\n assert candidate(n = 9,m = 9,hBars = [2, 3, 4, 5, 6, 7, 8, 9, 10],vBars = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(n = 7,m = 7,hBars = [3, 4, 5],vBars = [3, 4, 5]) == 16\n assert candidate(n = 30,m = 20,hBars = [2, 3, 4, 5, 6, 7, 8, 9, 10],vBars = [2, 4, 6, 8, 10, 12]) == 4\n assert candidate(n = 5,m = 4,hBars = [2, 4, 5],vBars = [2, 4]) == 4\n assert candidate(n = 50,m = 50,hBars = [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],vBars = [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]) == 4\n assert candidate(n = 10,m = 10,hBars = [2, 4, 6, 8],vBars = [2, 4, 6, 8]) == 4\n assert candidate(n = 7,m = 7,hBars = [2, 3, 5, 6],vBars = [2, 4, 5, 7]) == 9\n assert candidate(n = 7,m = 7,hBars = [3, 4, 5, 6],vBars = [3, 4, 5, 6]) == 25\n assert candidate(n = 10,m = 10,hBars = [2, 4, 6, 8, 10, 12],vBars = [2, 4, 6, 8, 10, 12]) == 4\n assert candidate(n = 10,m = 5,hBars = [3, 4, 5, 7, 8],vBars = [2, 4, 5, 7]) == 9\n assert candidate(n = 9,m = 9,hBars = [2, 3, 5, 6, 8, 9],vBars = [2, 3, 5, 6, 8, 9]) == 9\n assert candidate(n = 12,m = 12,hBars = [2, 4, 6, 8, 10],vBars = [2, 4, 6, 8, 10]) == 4\n assert candidate(n = 15,m = 10,hBars = [2, 4, 6, 8, 10, 12, 14],vBars = [2, 4, 6, 8, 10]) == 4\n assert candidate(n = 10,m = 10,hBars = [2, 3, 4, 5],vBars = [2, 3, 4, 5]) == 25\n assert candidate(n = 7,m = 7,hBars = [3, 5, 6],vBars = [3, 5, 6]) == 9\n assert candidate(n = 25,m = 20,hBars = [5, 10, 15, 20],vBars = [4, 8, 12, 16]) == 4\n assert candidate(n = 100,m = 100,hBars = [10, 20, 30, 40, 50],vBars = [15, 25, 35, 45, 55]) == 4\n assert candidate(n = 8,m = 8,hBars = [2, 4, 6, 8],vBars = [2, 4, 6, 8]) == 4\n assert candidate(n = 6,m = 6,hBars = [2, 3, 4, 5],vBars = [2, 3, 4, 5]) == 25\n assert candidate(n = 3,m = 3,hBars = [2, 3, 4],vBars = [2, 3, 4]) == 16\n assert candidate(n = 4,m = 3,hBars = [2, 3, 4],vBars = [2, 3]) == 9\n assert candidate(n = 10,m = 10,hBars = [2, 4, 6, 8, 10],vBars = [2, 4, 6, 8, 10]) == 4\n assert candidate(n = 10,m = 8,hBars = [2, 4, 6, 8],vBars = [2, 4, 6, 8]) == 4\n assert candidate(n = 100,m = 100,hBars = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],vBars = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 4\n assert candidate(n = 8,m = 6,hBars = [2, 3, 4, 5, 6, 7, 8],vBars = [2, 3, 4, 5, 6, 7, 8]) == 64\n assert candidate(n = 5,m = 4,hBars = [2, 3, 4],vBars = [2, 3, 4]) == 16\n assert candidate(n = 20,m = 15,hBars = [3, 6, 9, 12, 15, 18, 21],vBars = [3, 6, 9, 12, 15, 18]) == 4\n assert candidate(n = 12,m = 12,hBars = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],vBars = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 121\n assert candidate(n = 7,m = 6,hBars = [2, 3, 4, 5, 6],vBars = [2, 3, 4, 5]) == 25\n assert candidate(n = 9,m = 9,hBars = [2, 3, 5, 7, 9],vBars = [2, 4, 6, 8]) == 4\n assert candidate(n = 15,m = 12,hBars = [2, 3, 5, 7, 9, 11, 13, 15],vBars = [2, 3, 5, 7, 9, 11, 13, 15]) == 9\n assert candidate(n = 15,m = 10,hBars = [5, 6, 7, 8, 9, 10, 12],vBars = [4, 6, 7, 9, 10, 12, 14]) == 9\n assert candidate(n = 3,m = 4,hBars = [2, 3],vBars = [2, 3, 4]) == 9\n assert candidate(n = 100,m = 100,hBars = [50, 51, 52, 53, 54],vBars = [50, 51, 52, 53, 54]) == 36\n assert candidate(n = 7,m = 3,hBars = [2, 3, 4, 5],vBars = [2, 3]) == 9\n assert candidate(n = 7,m = 7,hBars = [2, 3, 5, 6],vBars = [2, 3, 5, 6]) == 9\n assert candidate(n = 3,m = 3,hBars = [2, 3],vBars = [2, 3]) == 9\n assert candidate(n = 20,m = 30,hBars = [10, 12, 13, 15],vBars = [15, 16, 18, 20]) == 9\n assert candidate(n = 5,m = 5,hBars = [2, 3, 4],vBars = [2, 3, 4]) == 16\n assert candidate(n = 5,m = 4,hBars = [2, 3, 5],vBars = [2, 3, 4]) == 9\n assert candidate(n = 8,m = 7,hBars = [3, 5, 6],vBars = [3, 5, 6, 7]) == 9\n assert candidate(n = 15,m = 10,hBars = [2, 3, 5, 7, 9, 11, 13, 15],vBars = [2, 4, 6, 8, 10]) == 4\n assert candidate(n = 6,m = 5,hBars = [2, 3, 5],vBars = [2, 4, 5]) == 9\n assert candidate(n = 5,m = 4,hBars = [2, 3, 4],vBars = [2, 3]) == 9\n assert candidate(n = 12,m = 15,hBars = [2, 3, 4, 6, 8, 10, 12],vBars = [3, 5, 7, 9, 11, 13, 15]) == 4\n assert candidate(n = 1,m = 1,hBars = [],vBars = []) == 4\n assert candidate(n = 4,m = 2,hBars = [2, 3, 4],vBars = [2]) == 4\n assert candidate(n = 30,m = 40,hBars = [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],vBars = [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]) == 961\n assert candidate(n = 100,m = 100,hBars = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],vBars = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 4\n assert candidate(n = 100,m = 50,hBars = [20, 22, 24, 26, 28, 30, 32, 34, 36, 38],vBars = [10, 15, 20, 25, 30, 35, 40]) == 4\n assert candidate(n = 10,m = 5,hBars = [3, 4, 5, 6],vBars = [3, 4]) == 9\n assert candidate(n = 5,m = 5,hBars = [2, 3, 4, 5, 6],vBars = [2, 3, 4, 5, 6]) == 36\n assert candidate(n = 4,m = 6,hBars = [2, 4],vBars = [2, 3, 4, 5, 6]) == 4\n assert candidate(n = 12,m = 12,hBars = [3, 6, 9, 12],vBars = [3, 6, 9, 12]) == 4\n assert candidate(n = 8,m = 6,hBars = [2, 3, 5, 6],vBars = [2, 4, 6]) == 4\n assert candidate(n = 9,m = 9,hBars = [2, 3, 4, 5, 6, 7, 8],vBars = [2, 3, 4, 5, 6, 7, 8]) == 64\n assert candidate(n = 15,m = 15,hBars = [3, 4, 5, 7, 8],vBars = [5, 6, 7, 9, 10]) == 16\n"}, "metadata": {"canonical_parameter_names": ["n", "m", "hBars", "vBars"], "leetcode_dataset_entry_point": "Solution().maximizeSquareHoleArea", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maximizeSquareHoleArea(int n, int m, int[] hBars, int[] vBars) {", "container": "Solution", "callable": "maximizeSquareHoleArea", "parameters": [{"name": "n", "type": "int"}, {"name": "m", "type": "int"}, {"name": "hBars", "type": "int[]"}, {"name": "vBars", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2944, "task_id": "minimum-number-of-coins-for-fruits", "difficulty": "Medium", "problem_description": "You are given an 0-indexed integer array prices where prices[i] denotes the number of coins needed to purchase the (i + 1)th fruit.\nThe fruit market has the following reward for each fruit:\n\nIf you purchase the (i + 1)th fruit at prices[i] coins, you can get any number of the next i fruits for free.\n\nNote that even if you can take fruit j for free, you can still purchase it for prices[j - 1] coins to receive its reward.\nReturn the minimum number of coins needed to acquire all the fruits.\n \nExample 1:\n\nInput: prices = [3,1,2]\nOutput: 4\nExplanation:\n\nPurchase the 1st fruit with prices[0] = 3 coins, you are allowed to take the 2nd fruit for free.\nPurchase the 2nd fruit with prices[1] = 1 coin, you are allowed to take the 3rd fruit for free.\nTake the 3rd fruit for free.\n\nNote that even though you could take the 2nd fruit for free as a reward of buying 1st fruit, you purchase it to receive its reward, which is more optimal.\n\nExample 2:\n\nInput: prices = [1,10,1,1]\nOutput: 2\nExplanation:\n\nPurchase the 1st fruit with prices[0] = 1 coin, you are allowed to take the 2nd fruit for free.\nTake the 2nd fruit for free.\nPurchase the 3rd fruit for prices[2] = 1 coin, you are allowed to take the 4th fruit for free.\nTake the 4th fruit for free.\n\n\nExample 3:\n\nInput: prices = [26,18,6,12,49,7,45,45]\nOutput: 39\nExplanation:\n\nPurchase the 1st fruit with prices[0] = 26 coin, you are allowed to take the 2nd fruit for free.\nTake the 2nd fruit for free.\nPurchase the 3rd fruit for prices[2] = 6 coin, you are allowed to take the 4th, 5th and 6th (the next three) fruits for free.\nTake the 4th fruit for free.\nTake the 5th fruit for free.\nPurchase the 6th fruit with prices[5] = 7 coin, you are allowed to take the 8th and 9th fruit for free.\nTake the 7th fruit for free.\nTake the 8th fruit for free.\n\nNote that even though you could take the 6th fruit for free as a reward of buying 3rd fruit, you purchase it to receive its reward, which is more optimal.\n\n \nConstraints:\n\n1 <= prices.length <= 1000\n1 <= prices[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prices = [1, 10, 1, 1]) == 2\n assert candidate(prices = [5, 5, 5, 5]) == 10\n assert candidate(prices = [1]) == 1\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 22\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(prices = [3, 1, 2]) == 4\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(prices = [1, 2, 3, 4, 5]) == 4\n assert candidate(prices = [5, 5, 5, 5, 5, 5]) == 10\n assert candidate(prices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 40\n assert candidate(prices = [10, 20, 30, 40, 50]) == 40\n assert candidate(prices = [100, 1, 100, 1, 100]) == 102\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 18\n assert candidate(prices = [5, 4, 3, 2, 1]) == 8\n assert candidate(prices = [26, 18, 6, 12, 49, 7, 45, 45]) == 39\n assert candidate(prices = [5]) == 5\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(prices = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 300000\n assert candidate(prices = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 104\n assert candidate(prices = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1266\n assert candidate(prices = [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]) == 221\n assert candidate(prices = [50, 40, 30, 20, 10, 5, 4, 3, 2, 1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 85\n assert candidate(prices = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 5\n assert candidate(prices = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 531\n assert candidate(prices = [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]) == 374\n assert candidate(prices = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 3\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0]) == 22\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(prices = [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]) == 10\n assert candidate(prices = [100, 10, 1, 0, 1, 10, 100, 1000, 10000, 100000, 100000, 10000, 1000, 100, 10]) == 211\n assert candidate(prices = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 0, 1, 3, 6]) == 2203\n assert candidate(prices = [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]) == 42\n assert candidate(prices = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900]) == 225000\n assert candidate(prices = [10, 1, 5, 2, 8, 3, 6, 4, 7, 9]) == 16\n assert candidate(prices = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 20737\n assert candidate(prices = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 1004\n assert candidate(prices = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 6\n assert candidate(prices = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 14\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 130\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(prices = [1000, 1, 500, 2, 250, 3, 125, 4, 62, 5, 31, 6, 15, 7, 7]) == 1007\n assert candidate(prices = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 801\n assert candidate(prices = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 72\n assert candidate(prices = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 20\n assert candidate(prices = [26, 18, 6, 12, 49, 7, 45, 45, 100, 50, 25, 12, 6, 3, 1]) == 45\n assert candidate(prices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 180\n assert candidate(prices = [3, 6, 2, 8, 4, 10, 1]) == 6\n assert candidate(prices = [3, 1, 2, 2, 1, 3, 1, 2, 2, 1, 3, 1, 2, 2, 1]) == 6\n assert candidate(prices = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 21\n assert candidate(prices = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 58\n assert candidate(prices = [26, 18, 6, 12, 49, 7, 45, 45, 10, 20, 30, 40, 50]) == 49\n assert candidate(prices = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 10\n assert candidate(prices = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16]) == 98\n assert candidate(prices = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 2, 4, 6, 8]) == 45\n assert candidate(prices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 41\n assert candidate(prices = [5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(prices = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 12\n assert candidate(prices = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 1]) == 46\n assert candidate(prices = [26, 18, 6, 12, 49, 7, 45, 45, 30, 20, 10, 5, 2, 1, 10, 20, 30, 40, 50, 60]) == 41\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(prices = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(prices = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 4\n assert candidate(prices = [10, 25, 5, 7, 12, 20, 3, 8, 15, 6, 2, 9, 11, 4, 14]) == 20\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 26\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 40\n assert candidate(prices = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]) == 17\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 40\n assert candidate(prices = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 220\n assert candidate(prices = [5, 2, 1, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 8\n assert candidate(prices = [5, 5, 5, 5, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(prices = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 139\n assert candidate(prices = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10]) == 40\n assert candidate(prices = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 139\n assert candidate(prices = [100, 50, 20, 10, 5, 2, 1, 2, 5, 10, 20, 50, 100]) == 121\n assert candidate(prices = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1, 0, 0, 0]) == 126568\n assert candidate(prices = [10, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 13\n assert candidate(prices = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 19\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 32\n assert candidate(prices = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 4\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 18\n assert candidate(prices = [3, 1, 2, 5, 4, 6, 3]) == 8\n assert candidate(prices = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1]) == 1266\n assert candidate(prices = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 30\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == 126\n assert candidate(prices = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40]) == 90\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0, 0]) == 126\n assert candidate(prices = [1000, 1, 100, 1, 10, 1, 1000, 1, 100, 1, 10, 1, 1000, 1, 100]) == 1003\n assert candidate(prices = [10, 5, 2, 1, 3, 1, 2, 1]) == 13\n assert candidate(prices = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 2200\n assert candidate(prices = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2]) == 4\n assert candidate(prices = [1, 100, 2, 200, 3, 300, 4, 400, 5, 500]) == 6\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 30\n assert candidate(prices = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 100003\n assert candidate(prices = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == 25\n assert candidate(prices = [100, 200, 50, 75, 300, 100, 50, 150]) == 200\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1]) == 18\n assert candidate(prices = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 6\n assert candidate(prices = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 7\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(prices = [1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 10, 20, 30, 40, 50]) == 9\n assert candidate(prices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 150\n assert candidate(prices = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 374\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(prices = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 3\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 23\n assert candidate(prices = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 74\n assert candidate(prices = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 9\n assert candidate(prices = [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]) == 300\n assert candidate(prices = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(prices = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 4\n assert candidate(prices = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110]) == 130\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 22\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(prices = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 13\n assert candidate(prices = [210, 190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1]) == 507\n assert candidate(prices = [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]) == 89\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1, 0, 1, 3, 6, 12, 25, 50, 100]) == 126\n assert candidate(prices = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 24\n assert candidate(prices = [100, 200, 1, 500, 10, 300, 20, 400, 3, 600]) == 111\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(prices = [100, 50, 20, 10, 5, 1]) == 120\n"}, "metadata": {"canonical_parameter_names": ["prices"], "leetcode_dataset_entry_point": "Solution().minimumCoins", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumCoins(int[] prices) {", "container": "Solution", "callable": "minimumCoins", "parameters": [{"name": "prices", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2945, "task_id": "find-maximum-non-decreasing-array-length", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums.\nYou can perform any number of operations, where each operation involves selecting a subarray of the array and replacing it with the sum of its elements. For example, if the given array is [1,3,5,6] and you select subarray [3,5] the array will convert to [1,8,6].\nReturn the maximum length of a non-decreasing array that can be made after applying operations.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [5,2,2]\nOutput: 1\nExplanation: This array with length 3 is not non-decreasing.\nWe have two ways to make the array length two.\nFirst, choosing subarray [2,2] converts the array to [5,4].\nSecond, choosing subarray [5,2] converts the array to [7,2].\nIn these two ways the array is not non-decreasing.\nAnd if we choose subarray [5,2,2] and replace it with [9] it becomes non-decreasing. \nSo the answer is 1.\n\nExample 2:\n\nInput: nums = [1,2,3,4]\nOutput: 4\nExplanation: The array is non-decreasing. So the answer is 4.\n\nExample 3:\n\nInput: nums = [4,3,2,6]\nOutput: 3\nExplanation: Replacing [3,2] with [5] converts the given array to [4,5,6] that is non-decreasing.\nBecause the given array is not non-decreasing, the maximum possible answer is 3.\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 = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8]) == 10\n assert candidate(nums = [1, 100, 1000]) == 3\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [3, 3, 3, 3]) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8]) == 4\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 3, 4]) == 4\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == 7\n assert candidate(nums = [1, 2, 4, 3, 5]) == 4\n assert candidate(nums = [4, 3, 2, 6]) == 3\n assert candidate(nums = [100, 10, 1]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [7, 7, 7, 7, 7]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [9, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [10, 5, 7, 10]) == 2\n assert candidate(nums = [10, 5, 7, 10, 6]) == 3\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 5\n assert candidate(nums = [1, 100, 2, 101, 1]) == 3\n assert candidate(nums = [5, 2, 2]) == 1\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000]) == 2\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 4\n assert candidate(nums = [3, 5, 2, 5, 6]) == 3\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 2\n assert candidate(nums = [5, 6, 2, 8, 3, 9, 1, 10, 4, 11]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 7\n assert candidate(nums = [1, 10, 1, 10, 1, 10]) == 4\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 19\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 500, 600, 700, 800, 900]) == 12\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 12\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, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 6\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, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93]) == 9\n assert candidate(nums = [10, 20, 15, 25, 30, 35, 40, 45, 50]) == 5\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 40, 45]) == 4\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, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 20\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, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 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, 1, 1, 1, 1, 1]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 12\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 5\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 = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 13\n assert candidate(nums = [100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 1]) == 4\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 6\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 7\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]) == 10\n assert candidate(nums = [3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 10\n assert candidate(nums = [100, 200, 100, 300, 200, 400, 300, 500]) == 5\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 15]) == 20\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 6\n assert candidate(nums = [10, 5, 3, 8, 12, 7, 9, 11]) == 4\n assert candidate(nums = [1, 3, 5, 4, 6, 7, 5, 8, 9, 10, 11, 9, 12, 13, 14]) == 9\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 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, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 8\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 6\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 6\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 = [1, 2, 3, 4, 5, 4, 3, 2, 1, 6, 7, 8, 9]) == 8\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 = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 5\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6]) == 5\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == 13\n assert candidate(nums = [1, 100, 2, 101, 3, 102, 4, 103, 5, 104]) == 6\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15]) == 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]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 3\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 5]) == 6\n assert candidate(nums = [5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 6\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]) == 6\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 10\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 13\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 10\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 8\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\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == 7\n assert candidate(nums = [100, 200, 150, 250, 300, 100, 400, 500, 350, 450]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 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 = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11\n assert candidate(nums = [10, 5, 3, 7, 8, 12, 1]) == 3\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 8, 5, 9, 10]) == 7\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 7\n assert candidate(nums = [10, 5, 1, 1, 1, 15, 20, 25, 30]) == 5\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 45, 50]) == 5\n assert candidate(nums = [5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 7\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9]) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findMaximumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int findMaximumLength(int[] nums) {", "container": "Solution", "callable": "findMaximumLength", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2946, "task_id": "matrix-similarity-after-cyclic-shifts", "difficulty": "Easy", "problem_description": "You are given an m x n integer matrix mat and an integer k. The matrix rows are 0-indexed.\nThe following proccess happens k times:\n\nEven-indexed rows (0, 2, 4, ...) are cyclically shifted to the left.\n\n\n\nOdd-indexed rows (1, 3, 5, ...) are cyclically shifted to the right.\n\n\nReturn true if the final modified matrix after k steps is identical to the original matrix, and false otherwise.\n \nExample 1:\n\nInput: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 4\nOutput: false\nExplanation:\nIn each step left shift is applied to rows 0 and 2 (even indices), and right shift to row 1 (odd index).\n\n\nExample 2:\n\nInput: mat = [[1,2,1,2],[5,5,5,5],[6,3,6,3]], k = 2\nOutput: true\nExplanation:\n\n\nExample 3:\n\nInput: mat = [[2,2],[2,2]], k = 3\nOutput: true\nExplanation:\nAs all the values are equal in the matrix, even after performing cyclic shifts the matrix will remain the same.\n\n \nConstraints:\n\n1 <= mat.length <= 25\n1 <= mat[i].length <= 25\n1 <= mat[i][j] <= 25\n1 <= k <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[2, 2], [2, 2]],k = 3) == True\n assert candidate(mat = [[1, 2, 1, 2], [5, 5, 5, 5], [6, 3, 6, 3]],k = 2) == True\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],k = 1) == False\n assert candidate(mat = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],k = 3) == True\n assert candidate(mat = [[3, 3, 3], [3, 3, 3], [3, 3, 3]],k = 25) == True\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 10) == True\n assert candidate(mat = [[3, 4, 5], [6, 7, 8]],k = 1) == False\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 50) == True\n assert candidate(mat = [[5, 10], [15, 20]],k = 1) == False\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 4) == False\n assert candidate(mat = [[3, 4, 5], [8, 7, 6]],k = 2) == False\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 4) == True\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]],k = 100) == True\n assert candidate(mat = [[2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [3, 3, 3, 3, 3]],k = 7) == False\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15], [16, 14, 12, 10, 8, 6, 4, 2]],k = 8) == True\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 17) == False\n assert candidate(mat = [[7, 7, 7], [7, 7, 7], [7, 7, 7], [7, 7, 7], [7, 7, 7]],k = 20) == True\n assert candidate(mat = [[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]],k = 7) == True\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 20) == True\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]],k = 12) == True\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]],k = 1) == False\n assert candidate(mat = [[7, 8, 9], [16, 17, 18], [25, 26, 27], [34, 35, 36], [43, 44, 45]],k = 9) == True\n assert candidate(mat = [[7, 8, 9], [8, 9, 7], [9, 7, 8]],k = 9) == True\n assert candidate(mat = [[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, 24, 23, 22, 21, 20]],k = 30) == True\n assert candidate(mat = [[7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 17, 18], [19, 20, 21, 22]],k = 8) == True\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]],k = 25) == True\n assert candidate(mat = [[7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 17, 18], [19, 20, 21, 22]],k = 40) == True\n assert candidate(mat = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0]],k = 5) == True\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 25) == False\n assert candidate(mat = [[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 = 25) == True\n assert candidate(mat = [[1, 2, 1, 2], [2, 1, 2, 1], [1, 2, 1, 2], [2, 1, 2, 1]],k = 3) == False\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],k = 1) == False\n assert candidate(mat = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],k = 1) == False\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 3) == True\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 5) == False\n assert candidate(mat = [[1, 2, 3], [3, 2, 1], [1, 2, 3], [3, 2, 1], [1, 2, 3]],k = 7) == False\n assert candidate(mat = [[1, 1, 2, 2, 3, 3], [3, 3, 1, 1, 2, 2], [2, 2, 3, 3, 1, 1], [1, 1, 2, 2, 3, 3]],k = 6) == True\n assert candidate(mat = [[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]],k = 10) == True\n assert candidate(mat = [[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]],k = 15) == False\n assert candidate(mat = [[1, 1, 2, 2], [3, 3, 4, 4], [1, 1, 2, 2], [3, 3, 4, 4]],k = 2) == False\n assert candidate(mat = [[1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1]],k = 12) == True\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18]],k = 6) == True\n assert candidate(mat = [[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) == True\n assert candidate(mat = [[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]],k = 30) == True\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 50) == True\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2]],k = 12) == True\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]],k = 30) == True\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],k = 10) == False\n assert candidate(mat = [[1, 2, 3, 4, 5], [10, 20, 30, 40, 50], [100, 200, 300, 400, 500], [2, 4, 6, 8, 10], [11, 22, 33, 44, 55]],k = 5) == True\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 1, 1, 1, 1], [2, 2, 2, 2, 2]],k = 3) == False\n assert candidate(mat = [[7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9], [10, 10, 10, 10, 10, 10]],k = 15) == True\n assert candidate(mat = [[2, 3, 2, 3], [3, 2, 3, 2], [2, 3, 2, 3], [3, 2, 3, 2]],k = 7) == False\n assert candidate(mat = [[9, 8, 7, 6], [5, 4, 3, 2], [1, 0, 1, 0], [9, 8, 7, 6]],k = 2) == False\n assert candidate(mat = [[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]],k = 20) == True\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 8) == True\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6]],k = 5) == True\n assert candidate(mat = [[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 = 5) == True\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6]],k = 6) == True\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1]],k = 16) == True\n assert candidate(mat = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]],k = 2) == False\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 5) == True\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]],k = 12) == True\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]],k = 8) == True\n assert candidate(mat = [[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], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 10) == True\n assert candidate(mat = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]],k = 49) == True\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2]],k = 5) == True\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 5) == True\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11], [12, 10, 8, 6, 4, 2]],k = 3) == False\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],k = 1) == False\n assert candidate(mat = [[1, 1, 2, 2, 3, 3], [4, 4, 5, 5, 6, 6], [7, 7, 8, 8, 9, 9]],k = 3) == False\n assert candidate(mat = [[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 = 24) == False\n assert candidate(mat = [[5, 5, 5, 5, 5], [4, 4, 4, 4, 4], [3, 3, 3, 3, 3], [2, 2, 2, 2, 2]],k = 50) == True\n assert candidate(mat = [[1, 1, 2, 2, 3, 3, 4, 4, 5, 5], [5, 5, 4, 4, 3, 3, 2, 2, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 100) == True\n assert candidate(mat = [[7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25, 26]],k = 25) == True\n assert candidate(mat = [[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]],k = 12) == True\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7]],k = 14) == True\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 3) == True\n assert candidate(mat = [[23, 24, 25, 23, 24], [24, 25, 23, 24, 25], [25, 23, 24, 25, 23], [23, 24, 25, 23, 24], [24, 25, 23, 24, 25]],k = 7) == False\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],k = 30) == True\n assert candidate(mat = [[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, 2, 4, 6, 8, 10], [10, 8, 6, 4, 2, 1, 3, 5, 7, 9]],k = 25) == False\n assert candidate(mat = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10]],k = 25) == True\n assert candidate(mat = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [12, 11, 10], [13, 14, 15]],k = 15) == True\n assert candidate(mat = [[10, 20, 30, 40, 50], [90, 80, 70, 60, 50], [45, 35, 25, 15, 5]],k = 10) == True\n assert candidate(mat = [[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 = 30) == True\n assert candidate(mat = [[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 = 25) == False\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8, 8, 8]],k = 40) == True\n assert candidate(mat = [[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 = 1) == False\n assert candidate(mat = [[1, 2, 3], [3, 2, 1], [1, 2, 3], [3, 2, 1]],k = 6) == True\n assert candidate(mat = [[1, 2], [2, 1], [1, 2], [2, 1]],k = 3) == False\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]],k = 100) == True\n assert candidate(mat = [[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 = 15) == True\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2]],k = 14) == True\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 15) == True\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]],k = 15) == True\n assert candidate(mat = [[25, 24, 23], [22, 21, 20], [19, 18, 17]],k = 20) == False\n assert candidate(mat = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [5, 6, 7, 8, 9], [3, 4, 5, 6, 7]],k = 5) == True\n assert candidate(mat = [[1, 1, 2, 2], [2, 2, 1, 1], [3, 3, 4, 4], [4, 4, 3, 3]],k = 15) == False\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15]],k = 8) == True\n assert candidate(mat = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]],k = 100) == True\n"}, "metadata": {"canonical_parameter_names": ["mat", "k"], "leetcode_dataset_entry_point": "Solution().areSimilar", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public boolean areSimilar(int[][] mat, int k) {", "container": "Solution", "callable": "areSimilar", "parameters": [{"name": "mat", "type": "int[][]"}, {"name": "k", "type": "int"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2947, "task_id": "count-beautiful-substrings-i", "difficulty": "Medium", "problem_description": "You are given a string s and a positive integer k.\nLet vowels and consonants be the number of vowels and consonants in a string.\nA string is beautiful if:\n\nvowels == consonants.\n(vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k.\n\nReturn the number of non-empty beautiful substrings in the given string s.\nA substring is a contiguous sequence of characters in a string.\nVowel letters in English are 'a', 'e', 'i', 'o', and 'u'.\nConsonant letters in English are every letter except vowels.\n \nExample 1:\n\nInput: s = \"baeyh\", k = 2\nOutput: 2\nExplanation: There are 2 beautiful substrings in the given string.\n- Substring \"baeyh\", vowels = 2 ([\"a\",e\"]), consonants = 2 ([\"y\",\"h\"]).\nYou can see that string \"aeyh\" is beautiful as vowels == consonants and vowels * consonants % k == 0.\n- Substring \"baeyh\", vowels = 2 ([\"a\",e\"]), consonants = 2 ([\"b\",\"y\"]). \nYou can see that string \"baey\" is beautiful as vowels == consonants and vowels * consonants % k == 0.\nIt can be shown that there are only 2 beautiful substrings in the given string.\n\nExample 2:\n\nInput: s = \"abba\", k = 1\nOutput: 3\nExplanation: There are 3 beautiful substrings in the given string.\n- Substring \"abba\", vowels = 1 ([\"a\"]), consonants = 1 ([\"b\"]). \n- Substring \"abba\", vowels = 1 ([\"a\"]), consonants = 1 ([\"b\"]).\n- Substring \"abba\", vowels = 2 ([\"a\",\"a\"]), consonants = 2 ([\"b\",\"b\"]).\nIt can be shown that there are only 3 beautiful substrings in the given string.\n\nExample 3:\n\nInput: s = \"bcdf\", k = 1\nOutput: 0\nExplanation: There are no beautiful substrings in the given string.\n\n \nConstraints:\n\n1 <= s.length <= 1000\n1 <= k <= 1000\ns consists of only English lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aeaeaeae\",k = 8) == 0\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\",k = 2) == 0\n assert candidate(s = \"aebcdfe\",k = 3) == 0\n assert candidate(s = \"\",k = 1) == 0\n assert candidate(s = \"baeyh\",k = 2) == 2\n assert candidate(s = \"aebcdeedaa\",k = 4) == 6\n assert candidate(s = \"bcdf\",k = 1) == 0\n assert candidate(s = \"abcd\",k = 1) == 1\n assert candidate(s = \"\",k = 3) == 0\n assert candidate(s = \"abba\",k = 1) == 3\n assert candidate(s = \"bcdfgh\",k = 2) == 0\n assert candidate(s = \"aabbccdd\",k = 2) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 2) == 0\n assert candidate(s = \"a\",k = 1) == 0\n assert candidate(s = \"aabb\",k = 2) == 1\n assert candidate(s = \"aeiou\",k = 5) == 0\n assert candidate(s = \"abcdefgh\",k = 4) == 0\n assert candidate(s = \"b\",k = 1) == 0\n assert candidate(s = \"aabbccddeeff\",k = 4) == 4\n assert candidate(s = \"aeiouaeiouaeiouaeiou\",k = 25) == 0\n assert candidate(s = \"aabbaaeeiioouuccddffgg\",k = 10) == 1\n assert candidate(s = \"aeiouaeiouaeiouaeiou\",k = 200) == 0\n assert candidate(s = \"aeioubcdfgh\",k = 5) == 1\n assert candidate(s = \"aeioubcdfghjklmnpqrstvwxyzaeioubcdfghjklmnpqrstvwxyz\",k = 12) == 0\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 7) == 0\n assert candidate(s = \"vowelsandconsonantsareimportant\",k = 12) == 0\n assert candidate(s = \"abacabadabacaba\",k = 3) == 14\n assert candidate(s = \"aebcdfeab\",k = 2) == 4\n assert candidate(s = \"aeioubcdefghijklmnopqrstuvwxyz\",k = 10) == 0\n assert candidate(s = \"vowelsconsonantsvowelsconsonants\",k = 8) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20) == 0\n assert candidate(s = \"vowelsandconsonants\",k = 6) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 100) == 0\n assert candidate(s = \"aabbccddeeffgg\",k = 12) == 0\n assert candidate(s = \"aebcdefghijklmnopqrstuvwxyz\",k = 7) == 0\n assert candidate(s = \"aaaaaaaaaaaabbbbbbbbbbcccccccccc\",k = 25) == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 7) == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == 0\n assert candidate(s = \"bbbbbbaaaaeiiuuuccccc\",k = 15) == 0\n assert candidate(s = \"thisisaverylongstringwithmixedcharacters\",k = 7) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 12) == 0\n assert candidate(s = \"beautifulstring\",k = 3) == 2\n assert candidate(s = \"abcdefghijabcdefghij\",k = 20) == 0\n assert candidate(s = \"consonantsandvowelsareequal\",k = 14) == 0\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 2) == 0\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\",k = 25) == 0\n assert candidate(s = \"zzzzzaaaaabbbbcccc\",k = 16) == 2\n assert candidate(s = \"aeioubcdfg\",k = 5) == 1\n assert candidate(s = \"bcdfg\",k = 1) == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 100) == 0\n assert candidate(s = \"aeiouaeiou\",k = 5) == 0\n assert candidate(s = \"aeiou\",k = 1) == 0\n assert candidate(s = \"aabbaaeebbeeaabbaa\",k = 3) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 49) == 0\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 3) == 0\n assert candidate(s = \"aaeeiioouubbbccddffgg\",k = 10) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 9) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 6) == 0\n assert candidate(s = \"vowelsandconsonants\",k = 10) == 0\n assert candidate(s = \"xylophoneaeiouaeiou\",k = 12) == 1\n assert candidate(s = \"exampleexampleexample\",k = 9) == 10\n assert candidate(s = \"aabbccddeeff\",k = 6) == 0\n assert candidate(s = \"xylophoneisfun\",k = 7) == 0\n assert candidate(s = \"beautifulstringwithvowelsandconsonants\",k = 20) == 0\n assert candidate(s = \"aeiouaeiou\",k = 25) == 0\n assert candidate(s = \"aeiouzzzzzzzzzz\",k = 200) == 0\n assert candidate(s = \"aeioubcdfghjklmnpqrstvwxyz\",k = 5) == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 21) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10) == 0\n assert candidate(s = \"bbaaeeddbb\",k = 4) == 5\n assert candidate(s = \"eeeeeeeeeeaaaaaaaaaaiiiiiiiiiiooooooooouuuuuuuuuu\",k = 100) == 0\n assert candidate(s = \"zzzzyyyyxxxx\",k = 9) == 0\n assert candidate(s = \"thisisaverylongstringwithvowelsandconsonants\",k = 20) == 0\n assert candidate(s = \"thisisbeautifulstringwithvariousvowelsandconsonants\",k = 8) == 10\n assert candidate(s = \"aeiouaeiouaeiouaeioubcdfghjklmnpqrstvwxy\",k = 11) == 1\n assert candidate(s = \"beautifulstringwithvowelandconsonants\",k = 7) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 5) == 0\n assert candidate(s = \"consonantsconsonantsconsonants\",k = 30) == 0\n assert candidate(s = \"mamamamamamamamama\",k = 2) == 36\n assert candidate(s = \"thisisaverylongstringwithmanyvowelsandconsonants\",k = 12) == 0\n assert candidate(s = \"vowelsarebeautiful\",k = 6) == 3\n assert candidate(s = \"bcdfghjklmnpqrstvwxyzaeiou\",k = 10) == 0\n assert candidate(s = \"bcdfghjklmnpqrstvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 8) == 0\n assert candidate(s = \"aeaeaeaeaeaeaeaeaeae\",k = 2) == 0\n assert candidate(s = \"aeiouaeiouaeiouaeiou\",k = 4) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 15) == 0\n assert candidate(s = \"aaaeeeiioouu\",k = 1) == 0\n assert candidate(s = \"bcdfghjklmnpqrstvwxybcdfghjklmnpqrstvwxy\",k = 9) == 0\n assert candidate(s = \"zzzzzzzzzz\",k = 100) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 50) == 0\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().beautifulSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int beautifulSubstrings(String s, int k) {", "container": "Solution", "callable": "beautifulSubstrings", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2948, "task_id": "make-lexicographically-smallest-array-by-swapping-elements", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of positive integers nums and a positive integer limit.\nIn one operation, you can choose any two indices i and j and swap nums[i] and nums[j] if |nums[i] - nums[j]| <= limit.\nReturn the lexicographically smallest array that can be obtained by performing the operation any number of times.\nAn array a is lexicographically smaller than an array b if in the first position where a and b differ, array a has an element that is less than the corresponding element in b. For example, the array [2,10,3] is lexicographically smaller than the array [10,2,3] because they differ at index 0 and 2 < 10.\n \nExample 1:\n\nInput: nums = [1,5,3,9,8], limit = 2\nOutput: [1,3,5,8,9]\nExplanation: Apply the operation 2 times:\n- Swap nums[1] with nums[2]. The array becomes [1,3,5,9,8]\n- Swap nums[3] with nums[4]. The array becomes [1,3,5,8,9]\nWe cannot obtain a lexicographically smaller array by applying any more operations.\nNote that it may be possible to get the same result by doing different operations.\n\nExample 2:\n\nInput: nums = [1,7,6,18,2,1], limit = 3\nOutput: [1,6,7,18,1,2]\nExplanation: Apply the operation 3 times:\n- Swap nums[1] with nums[2]. The array becomes [1,6,7,18,2,1]\n- Swap nums[0] with nums[4]. The array becomes [2,6,7,18,1,1]\n- Swap nums[0] with nums[5]. The array becomes [1,6,7,18,1,2]\nWe cannot obtain a lexicographically smaller array by applying any more operations.\n\nExample 3:\n\nInput: nums = [1,7,28,19,10], limit = 3\nOutput: [1,7,28,19,10]\nExplanation: [1,7,28,19,10] is the lexicographically smallest array we can obtain because we cannot apply the operation on any two indices.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= limit <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10, 10],limit = 0) == [10, 10, 10, 10, 10]\n assert candidate(nums = [1, 1, 1, 1, 1],limit = 1) == [1, 1, 1, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],limit = 2) == [1, 1, 2, 3, 3, 9, 4, 5, 5, 5, 6]\n assert candidate(nums = [9, 7, 5, 3, 1],limit = 2) == [1, 3, 5, 7, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 20, 30, 40, 50],limit = 5) == [10, 20, 30, 40, 50]\n assert candidate(nums = [10, 9, 8, 7, 6],limit = 1) == [6, 7, 8, 9, 10]\n assert candidate(nums = [1, 7, 28, 19, 10],limit = 3) == [1, 7, 28, 19, 10]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],limit = 9) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [5, 5, 5, 5, 5],limit = 0) == [5, 5, 5, 5, 5]\n assert candidate(nums = [1, 3, 5, 7, 9],limit = 2) == [1, 3, 5, 7, 9]\n assert candidate(nums = [5, 4, 3, 2, 1],limit = 1) == [1, 2, 3, 4, 5]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 7, 6, 18, 2, 1],limit = 3) == [1, 6, 7, 18, 1, 2]\n assert candidate(nums = [5, 5, 5, 5, 5],limit = 1) == [5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 10) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1, 5, 3, 9, 8],limit = 2) == [1, 3, 5, 8, 9]\n assert candidate(nums = [10, 20, 15, 18, 17, 25, 30, 35, 40, 45],limit = 5) == [10, 15, 17, 18, 20, 25, 30, 35, 40, 45]\n assert candidate(nums = [3, 8, 13, 18, 23, 28, 33],limit = 10) == [3, 8, 13, 18, 23, 28, 33]\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [5, 9, 2, 8, 1, 7, 3, 6, 4, 10],limit = 3) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [3, 5, 1, 8, 7, 2, 4, 6],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\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],limit = 1) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [10, 14, 13, 12, 11, 9, 8, 7, 6, 5],limit = 2) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [1, 3, 2, 6, 5, 4, 9, 7, 8, 10],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],limit = 2) == [1, 1, 2, 3, 3, 9, 4, 5, 5, 5, 6]\n assert candidate(nums = [100, 101, 99, 102, 103, 98, 104, 105, 97, 106],limit = 5) == [97, 98, 99, 100, 101, 102, 103, 104, 105, 106]\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99],limit = 10) == [9, 19, 29, 39, 49, 59, 69, 79, 89, 99]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],limit = 50) == [1, 96, 2, 97, 3, 98, 4, 99, 5, 100]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 15) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],limit = 3) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 25) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 5, 3, 9, 8, 4, 6, 7, 2, 10],limit = 3) == [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],limit = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 2) == [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, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],limit = 2) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],limit = 1) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 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],limit = 1) == [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, 6, 8, 2, 4, 3, 9, 10, 12, 11],limit = 3) == [1, 2, 3, 4, 6, 8, 9, 10, 11, 12]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],limit = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],limit = 1) == [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 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],limit = 2) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 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],limit = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 2) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 3) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 0) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],limit = 5) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995],limit = 10) == [999999995, 999999996, 999999997, 999999998, 999999999, 1000000000]\n assert candidate(nums = [109, 98, 87, 76, 65, 54, 43, 32, 21, 10],limit = 10) == [109, 98, 87, 76, 65, 54, 43, 32, 21, 10]\n assert candidate(nums = [1, 5, 3, 9, 8, 2, 6, 4, 10, 7],limit = 3) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5],limit = 5) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [2, 1, 5, 6, 3, 4, 8, 7, 10, 9],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 1) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 3, 9, 1, 5, 11, 13, 12, 14, 10],limit = 3) == [1, 3, 5, 7, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [4, 1, 5, 3, 2, 8, 7, 6],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = [1, 5, 3, 7, 2, 6, 4, 8, 10, 9],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],limit = 5) == [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],limit = 5) == [999999991, 999999992, 999999993, 999999994, 999999995, 999999996, 999999997, 999999998, 999999999, 1000000000]\n assert candidate(nums = [15, 20, 10, 12, 14, 13, 9, 8, 7, 6],limit = 3) == [6, 20, 7, 8, 9, 10, 12, 13, 14, 15]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],limit = 2) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],limit = 6) == [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],limit = 5) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],limit = 2) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],limit = 100000000) == [999999990, 999999991, 999999992, 999999993, 999999994, 999999995, 999999996, 999999997, 999999998, 999999999]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 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],limit = 50) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],limit = 4) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5],limit = 9) == [1, 2, 20, 3, 30, 4, 40, 5, 50, 10]\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59],limit = 6) == [5, 11, 17, 23, 29, 35, 41, 47, 53, 59]\n assert candidate(nums = [5, 1, 4, 3, 2, 8, 7, 6, 10, 9],limit = 2) == [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],limit = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 15) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 4, 2, 5, 3, 8, 6, 7, 10, 9],limit = 3) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996],limit = 1000000000) == [1, 2, 3, 4, 5, 999999996, 999999997, 999999998, 999999999, 1000000000]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],limit = 2) == [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],limit = 500000000) == [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995],limit = 3) == [999999995, 999999996, 999999997, 999999998, 999999999, 1000000000]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 1) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 15) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],limit = 10) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5],limit = 4) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 7, 10, 9],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5],limit = 9) == [1, 2, 20, 3, 30, 4, 40, 5, 50, 10]\n assert candidate(nums = [10, 2, 14, 4, 18, 6, 20, 8, 22, 10],limit = 6) == [2, 4, 6, 8, 10, 10, 14, 18, 20, 22]\n assert candidate(nums = [3, 8, 2, 6, 5, 10, 7, 1],limit = 3) == [1, 2, 3, 5, 6, 7, 8, 10]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],limit = 1) == [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109],limit = 10) == [10, 21, 32, 43, 54, 65, 76, 87, 98, 109]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],limit = 2) == [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],limit = 5) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [3, 8, 1, 6, 2, 7, 5, 10, 4, 9],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 9) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 1) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],limit = 2) == [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],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50],limit = 5) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 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],limit = 4) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16],limit = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100],limit = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [5, 9, 2, 6, 3, 8, 1, 7, 4, 10],limit = 3) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [3, 1, 2, 5, 4, 7, 6, 9, 8, 10],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 15, 13, 12, 11, 20, 19, 18, 17, 16],limit = 2) == [10, 11, 12, 13, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, 25, 20, 30, 35, 15, 5, 40, 45, 50],limit = 5) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],limit = 5) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],limit = 5) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],limit = 2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36],limit = 15) == [1, 6, 11, 16, 21, 26, 31, 36]\n assert candidate(nums = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50],limit = 10) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],limit = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56],limit = 21) == [7, 14, 21, 28, 35, 42, 49, 56]\n assert candidate(nums = [15, 10, 5, 20, 25, 30, 35, 40, 45, 50],limit = 5) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [3, 12, 21, 30, 39, 48, 57, 66, 75, 84],limit = 9) == [3, 12, 21, 30, 39, 48, 57, 66, 75, 84]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],limit = 1) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],limit = 2) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],limit = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [5, 1, 4, 2, 3, 8, 6, 7, 10, 9],limit = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 5, 15, 20, 25, 30],limit = 5) == [5, 10, 15, 20, 25, 30]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],limit = 15) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],limit = 4) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],limit = 500) == [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 4) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 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],limit = 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(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 1) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(nums = [3, 1, 2, 5, 4, 7, 6, 9, 8, 10],limit = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"}, "metadata": {"canonical_parameter_names": ["nums", "limit"], "leetcode_dataset_entry_point": "Solution().lexicographicallySmallestArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] lexicographicallySmallestArray(int[] nums, int limit) {", "container": "Solution", "callable": "lexicographicallySmallestArray", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "limit", "type": "int"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2949, "task_id": "count-beautiful-substrings-ii", "difficulty": "Hard", "problem_description": "You are given a string s and a positive integer k.\nLet vowels and consonants be the number of vowels and consonants in a string.\nA string is beautiful if:\n\nvowels == consonants.\n(vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k.\n\nReturn the number of non-empty beautiful substrings in the given string s.\nA substring is a contiguous sequence of characters in a string.\nVowel letters in English are 'a', 'e', 'i', 'o', and 'u'.\nConsonant letters in English are every letter except vowels.\n \nExample 1:\n\nInput: s = \"baeyh\", k = 2\nOutput: 2\nExplanation: There are 2 beautiful substrings in the given string.\n- Substring \"baeyh\", vowels = 2 ([\"a\",e\"]), consonants = 2 ([\"y\",\"h\"]).\nYou can see that string \"aeyh\" is beautiful as vowels == consonants and vowels * consonants % k == 0.\n- Substring \"baeyh\", vowels = 2 ([\"a\",e\"]), consonants = 2 ([\"b\",\"y\"]).\nYou can see that string \"baey\" is beautiful as vowels == consonants and vowels * consonants % k == 0.\nIt can be shown that there are only 2 beautiful substrings in the given string.\n\nExample 2:\n\nInput: s = \"abba\", k = 1\nOutput: 3\nExplanation: There are 3 beautiful substrings in the given string.\n- Substring \"abba\", vowels = 1 ([\"a\"]), consonants = 1 ([\"b\"]).\n- Substring \"abba\", vowels = 1 ([\"a\"]), consonants = 1 ([\"b\"]).\n- Substring \"abba\", vowels = 2 ([\"a\",\"a\"]), consonants = 2 ([\"b\",\"b\"]).\nIt can be shown that there are only 3 beautiful substrings in the given string.\n\nExample 3:\n\nInput: s = \"bcdf\", k = 1\nOutput: 0\nExplanation: There are no beautiful substrings in the given string.\n\n \nConstraints:\n\n1 <= s.length <= 5 * 104\n1 <= k <= 1000\ns consists of only English lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuooououuoiiiuuuuaeiou\",k = 10) == 0\n assert candidate(s = \"aabbcc\",k = 4) == 1\n assert candidate(s = \"zzzzz\",k = 1) == 0\n assert candidate(s = \"\",k = 1) == 0\n assert candidate(s = \"baeyh\",k = 2) == 2\n assert candidate(s = \"bbaeaeaaeiou\",k = 3) == 0\n assert candidate(s = \"bcdf\",k = 1) == 0\n assert candidate(s = \"aeiou\",k = 25) == 0\n assert candidate(s = \"vowelsandconsonants\",k = 10) == 0\n assert candidate(s = \"\",k = 3) == 0\n assert candidate(s = \"abba\",k = 1) == 3\n assert candidate(s = \"abcdefghij\",k = 2) == 0\n assert candidate(s = \"aebcde\",k = 3) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 7) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 2) == 0\n assert candidate(s = \"a\",k = 1) == 0\n assert candidate(s = \"aeiou\",k = 5) == 0\n assert candidate(s = \"beautifulstring\",k = 7) == 0\n assert candidate(s = \"aabbccddeeff\",k = 4) == 4\n assert candidate(s = \"aaabbbcccddd\",k = 6) == 0\n assert candidate(s = \"consonantsandvowels\",k = 20) == 0\n assert candidate(s = \"bbaaccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 12) == 0\n assert candidate(s = \"vowelsvowelsvowelsvowels\",k = 4) == 8\n assert candidate(s = \"thisisaverylongstringwithabunchoflettersandvariousvowelsandconsonants\",k = 10) == 0\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 11) == 0\n assert candidate(s = \"aebcdefghijklmnopqrstuvwxyz\",k = 5) == 0\n assert candidate(s = \"abacabadabacaba\",k = 10) == 0\n assert candidate(s = \"vowelsandconsonants\",k = 6) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 100) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 13) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 20) == 0\n assert candidate(s = \"aeiouaeiouaeiou\",k = 25) == 0\n assert candidate(s = \"vwxyzvwxyzvwxyzvwxyz\",k = 20) == 0\n assert candidate(s = \"abcdabcdabcdabcdabcdabcd\",k = 9) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 10) == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffff\",k = 16) == 6\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",k = 3) == 0\n assert candidate(s = \"bcdfghjklmnpqrstvwxyzbcd\",k = 15) == 0\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 11) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzz\",k = 20) == 0\n assert candidate(s = \"abcdeffedcba\",k = 4) == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 2) == 0\n assert candidate(s = \"repeatedcharactersaaaaaaaabbbbbbbbcccccccc\",k = 16) == 13\n assert candidate(s = \"aaeeiioouu\",k = 10) == 0\n assert candidate(s = \"thisisalongstringwithvariousvowelsandconsonants\",k = 36) == 6\n assert candidate(s = \"beautifulstring\",k = 3) == 2\n assert candidate(s = \"abcdefghefghijklmnopqrstuvwxyz\",k = 8) == 0\n assert candidate(s = \"aeioubcdfghjklmnpqrstvwxyz\",k = 25) == 1\n assert candidate(s = \"zzzzzaaaaabbbbbbccccccdddddd\",k = 12) == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == 0\n assert candidate(s = \"aeiouaeiou\",k = 5) == 0\n assert candidate(s = \"aeioubcdfg\",k = 5) == 1\n assert candidate(s = \"bcaedfghioklmnpqrstuvwxyz\",k = 7) == 0\n assert candidate(s = \"bcdfghjklmnpqrstvwxyzzzzzzzz\",k = 11) == 0\n assert candidate(s = \"beautifulstring\",k = 2) == 5\n assert candidate(s = \"abababababababababab\",k = 6) == 9\n assert candidate(s = \"aaeeiioouubbccddeeffgghhjjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 10) == 1\n assert candidate(s = \"aeeeeiiioouu\",k = 10) == 0\n assert candidate(s = \"aeiouaeiouaeiou\",k = 3) == 0\n assert candidate(s = \"vowelvowelvowelvowelvowel\",k = 10) == 0\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbb\",k = 1) == 10\n assert candidate(s = \"abacabadabacaba\",k = 2) == 24\n assert candidate(s = \"aaaabbbbcccc\",k = 10) == 0\n assert candidate(s = \"eiouaeiouaeiouaeiou\",k = 5) == 0\n assert candidate(s = \"aeioubcdfghjklmnpqrstvwxyz\",k = 5) == 1\n assert candidate(s = \"thisisaverylongstringwithvariouscharacters\",k = 11) == 0\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 3) == 0\n assert candidate(s = \"bcdfghjklmnpqrstvwxyzbcdfghjklmnpqrstvwxyz\",k = 30) == 0\n assert candidate(s = \"aeiaeiouaeiaeiouaeiaeiou\",k = 18) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\",k = 50) == 0\n assert candidate(s = \"consonantconsonantconsonant\",k = 15) == 0\n assert candidate(s = \"bcbcbcbcbcbcbc\",k = 3) == 0\n assert candidate(s = \"vowelsconsonants\",k = 4) == 5\n assert candidate(s = \"aebcdeioufhgjk\",k = 12) == 1\n assert candidate(s = \"xylophone\",k = 2) == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 25) == 0\n assert candidate(s = \"xyzabcxyzabc\",k = 9) == 0\n assert candidate(s = \"thisisateststring\",k = 7) == 0\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\",k = 100) == 1\n assert candidate(s = \"vowelsandconsonants\",k = 18) == 0\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\",k = 26) == 0\n assert candidate(s = \"aabbbbcccc\",k = 4) == 1\n assert candidate(s = \"beautifulsubstring\",k = 5) == 2\n assert candidate(s = \"xyzxyzxyzxyz\",k = 9) == 0\n assert candidate(s = \"abecidofug\",k = 8) == 3\n assert candidate(s = \"xyzxyzxyzxyz\",k = 3) == 0\n assert candidate(s = \"aaaabbbbccccdddd\",k = 8) == 1\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewwq\",k = 11) == 0\n assert candidate(s = \"aeiouaeiouaeiouaeiou\",k = 25) == 0\n assert candidate(s = \"aaaaaaaaaeeeeeeiiioooouuuu\",k = 10) == 0\n assert candidate(s = \"consonantsconsonantsconsonants\",k = 9) == 3\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().beautifulSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long beautifulSubstrings(String s, int k) {", "container": "Solution", "callable": "beautifulSubstrings", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2951, "task_id": "find-the-peaks", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array mountain. Your task is to find all the peaks in the mountain array.\nReturn an array that consists of indices of peaks in the given array in any order.\nNotes:\n\nA peak is defined as an element that is strictly greater than its neighboring elements.\nThe first and last elements of the array are not a peak.\n\n \nExample 1:\n\nInput: mountain = [2,4,4]\nOutput: []\nExplanation: mountain[0] and mountain[2] can not be a peak because they are first and last elements of the array.\nmountain[1] also can not be a peak because it is not strictly greater than mountain[2].\nSo the answer is [].\n\nExample 2:\n\nInput: mountain = [1,4,3,8,5]\nOutput: [1,3]\nExplanation: mountain[0] and mountain[4] can not be a peak because they are first and last elements of the array.\nmountain[2] also can not be a peak because it is not strictly greater than mountain[3] and mountain[1].\nBut mountain [1] and mountain[3] are strictly greater than their neighboring elements.\nSo the answer is [1,3].\n\n \nConstraints:\n\n3 <= mountain.length <= 100\n1 <= mountain[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mountain = [1, 2, 3, 4, 5]) == []\n assert candidate(mountain = [5, 6, 7, 8, 9, 10, 8, 6, 4]) == [5]\n assert candidate(mountain = [2, 4, 4]) == []\n assert candidate(mountain = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == [4]\n assert candidate(mountain = [10, 20, 10, 20, 10]) == [1, 3]\n assert candidate(mountain = [1, 2, 3, 4, 5, 6, 7]) == []\n assert candidate(mountain = [7, 6, 5, 4, 3, 2, 1]) == []\n assert candidate(mountain = [1, 4, 3, 8, 5]) == [1, 3]\n assert candidate(mountain = [1, 2, 3, 1, 2, 3, 1]) == [2, 5]\n assert candidate(mountain = [1, 3, 2, 4, 3, 6, 5]) == [1, 3, 5]\n assert candidate(mountain = [3, 2, 1, 4, 3, 2, 1]) == [3]\n assert candidate(mountain = [1, 3, 2, 4, 3, 5, 1]) == [1, 3, 5]\n assert candidate(mountain = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [2, 5, 7]\n assert candidate(mountain = [1, 3, 1, 3, 1]) == [1, 3]\n assert candidate(mountain = [1, 3, 2, 1]) == [1]\n assert candidate(mountain = [1, 3, 2, 4, 3, 5, 4]) == [1, 3, 5]\n assert candidate(mountain = [5, 4, 3, 2, 1]) == []\n assert candidate(mountain = [10, 9, 8, 7, 6, 5, 4, 5, 6, 7, 8, 9, 10]) == []\n assert candidate(mountain = [50, 40, 30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10, 20, 30]) == [6, 10]\n assert candidate(mountain = [10, 20, 15, 25, 20, 30, 25, 35, 30]) == [1, 3, 5, 7]\n assert candidate(mountain = [8, 9, 7, 10, 8, 11, 9, 12, 10, 13, 11, 14, 12, 15, 13, 16, 14, 17, 15, 18, 16, 19, 17]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n assert candidate(mountain = [3, 4, 3, 5, 6, 5, 7, 8, 7, 9, 10, 9, 11, 12, 11, 13, 14, 13, 15, 16, 15]) == [1, 4, 7, 10, 13, 16, 19]\n assert candidate(mountain = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6]) == [1, 3, 5, 7, 9]\n assert candidate(mountain = [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, 1, 3, 5, 7, 9, 2, 6, 5, 3, 5, 9]) == [2, 5, 7, 11, 13, 17, 19, 21, 29, 31]\n assert candidate(mountain = [1, 2, 3, 4, 5, 6, 5, 7, 8, 7, 9, 10, 9, 11, 12, 11, 13, 14, 13, 15, 16, 15, 17, 18, 17]) == [5, 8, 11, 14, 17, 20, 23]\n assert candidate(mountain = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == [3, 9]\n assert candidate(mountain = [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]) == [9, 27]\n assert candidate(mountain = [10, 20, 15, 25, 30, 5, 35, 40, 38, 45, 50]) == [1, 4, 7]\n assert candidate(mountain = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 40, 30]) == [4, 12]\n assert candidate(mountain = [1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1]) == [3, 8]\n assert candidate(mountain = [5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == [1, 3, 5, 7, 9]\n assert candidate(mountain = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == [9]\n assert candidate(mountain = [3, 5, 4, 5, 4, 5, 4, 5, 4, 5]) == [1, 3, 5, 7]\n assert candidate(mountain = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 9, 7, 5, 3]) == [5, 15]\n assert candidate(mountain = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [2, 5, 7]\n assert candidate(mountain = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3]) == [1, 3, 5, 7, 9, 11, 13]\n assert candidate(mountain = [10, 20, 15, 25, 20, 30, 25, 35, 30, 40]) == [1, 3, 5, 7]\n assert candidate(mountain = [5, 3, 1, 2, 4, 6, 5, 4, 3, 5, 7, 9, 7, 5, 6, 8, 6, 4, 3, 2]) == [5, 11, 15]\n assert candidate(mountain = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2, 4, 6, 8]\n assert candidate(mountain = [3, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == [1, 3, 5, 7, 9, 11]\n assert candidate(mountain = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7]) == [1, 3, 5, 7, 9, 11]\n assert candidate(mountain = [8, 1, 9, 2, 10, 3, 11, 4, 12, 5]) == [2, 4, 6, 8]\n assert candidate(mountain = [6, 7, 5, 8, 6, 9, 7, 10, 8, 11, 9, 12, 10, 13, 11, 14, 12, 15, 13, 16, 14, 17, 15]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n assert candidate(mountain = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == [3, 9]\n assert candidate(mountain = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(mountain = [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, 6]) == [2, 5, 7, 11, 13, 17, 19, 21, 25, 29]\n assert candidate(mountain = [2, 4, 3, 5, 6, 4, 7, 8, 6, 9, 10, 7, 11, 12, 9, 13, 14, 11, 15, 16, 12, 17, 18, 13]) == [1, 4, 7, 10, 13, 16, 19, 22]\n assert candidate(mountain = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == [2, 6, 10]\n assert candidate(mountain = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 2, 1]) == [4, 10]\n assert candidate(mountain = [8, 9, 7, 10, 6, 11, 5, 12, 4, 13, 3]) == [1, 3, 5, 7, 9]\n assert candidate(mountain = [5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5]) == [4, 8]\n assert candidate(mountain = [2, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 8, 7, 9, 8, 7, 6]) == [1, 3, 5, 7, 9, 11, 13, 17, 19]\n assert candidate(mountain = [2, 1, 4, 1, 6, 1, 8, 1, 10, 1, 12, 1, 14, 1, 16, 1, 18, 1]) == [2, 4, 6, 8, 10, 12, 14, 16]\n assert candidate(mountain = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == [2, 7, 14]\n assert candidate(mountain = [1, 2, 3, 4, 3, 2, 1, 4, 5, 6, 5, 4, 3, 2, 1]) == [3, 9]\n assert candidate(mountain = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == [2, 6, 10]\n assert candidate(mountain = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 45, 40, 35, 30, 25]) == [9]\n assert candidate(mountain = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [2, 4, 6, 8, 10, 12]\n assert candidate(mountain = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9]) == [17]\n assert candidate(mountain = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == [1, 3, 5, 7, 9, 11]\n assert candidate(mountain = [10, 20, 15, 25, 30, 28, 35, 40, 38, 45, 43]) == [1, 4, 7, 9]\n assert candidate(mountain = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == [2, 5, 8, 11, 14, 17, 20]\n assert candidate(mountain = [9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9]) == [2, 4, 6, 8, 10]\n assert candidate(mountain = [10, 20, 15, 30, 25, 40, 35]) == [1, 3, 5]\n assert candidate(mountain = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5]) == [8]\n assert candidate(mountain = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7]) == [1, 3, 5, 7, 9, 11, 13]\n assert candidate(mountain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10]\n assert candidate(mountain = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == [2, 4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(mountain = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3]) == [6]\n assert candidate(mountain = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7]) == [1, 3, 5, 7, 9, 11]\n assert candidate(mountain = [10, 20, 15, 30, 25, 35, 40, 20, 50, 45]) == [1, 3, 6, 8]\n assert candidate(mountain = [5, 10, 5, 15, 10, 20, 15, 25, 20, 30, 25]) == [1, 3, 5, 7, 9]\n assert candidate(mountain = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 8, 9, 8, 7, 6, 5]) == [8, 12]\n assert candidate(mountain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [9]\n assert candidate(mountain = [7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10]\n assert candidate(mountain = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == [4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(mountain = [1, 9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9]) == [1, 7, 13]\n assert candidate(mountain = [5, 3, 8, 6, 7, 2, 9, 4, 10, 1, 11]) == [2, 4, 6, 8]\n assert candidate(mountain = [2, 3, 4, 3, 5, 4, 6, 5, 7, 6, 8]) == [2, 4, 6, 8]\n assert candidate(mountain = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == [3, 9, 15, 21]\n assert candidate(mountain = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(mountain = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == [8]\n assert candidate(mountain = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == [4, 11]\n assert candidate(mountain = [1, 3, 2, 5, 4, 7, 6, 8, 7]) == [1, 3, 5, 7]\n assert candidate(mountain = [1, 3, 2, 5, 4, 7, 6]) == [1, 3, 5]\n assert candidate(mountain = [8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13]) == [2, 4, 6, 8]\n assert candidate(mountain = [5, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 10, 12, 11, 13, 14, 12, 15, 16, 14, 17, 18, 16]) == [2, 5, 7, 12, 15, 18, 21, 24]\n assert candidate(mountain = [8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6]) == [4, 8, 12]\n assert candidate(mountain = [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]) == [16]\n assert candidate(mountain = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1]) == [1, 3, 5, 7, 9, 11]\n assert candidate(mountain = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [2, 6, 10]\n assert candidate(mountain = [2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4]) == [2, 6, 10, 14]\n assert candidate(mountain = [5, 3, 4, 3, 5, 3, 5, 7, 5, 8, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11]) == [2, 4, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(mountain = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10]\n assert candidate(mountain = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1]) == [5]\n assert candidate(mountain = [2, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n assert candidate(mountain = [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]) == []\n assert candidate(mountain = [1, 10, 5, 15, 10, 20, 15, 25, 20, 30, 25, 35, 30, 40, 35]) == [1, 3, 5, 7, 9, 11, 13]\n assert candidate(mountain = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == [1, 4, 7, 10, 13, 16, 19]\n assert candidate(mountain = [10, 20, 15, 25, 30, 20, 50, 45, 60, 55]) == [1, 4, 6, 8]\n assert candidate(mountain = [1, 3, 5, 7, 9, 11, 13, 11, 9, 7, 5, 3, 1]) == [6]\n assert candidate(mountain = [10, 20, 15, 25, 30, 20, 35, 40, 50, 45]) == [1, 4, 8]\n assert candidate(mountain = [2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == [6]\n assert candidate(mountain = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]) == [6]\n assert candidate(mountain = [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]) == [19]\n assert candidate(mountain = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [11]\n assert candidate(mountain = [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]) == [4, 12, 20]\n assert candidate(mountain = [50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [15]\n assert candidate(mountain = [5, 10, 5, 15, 10, 20, 15, 25, 20, 30, 25]) == [1, 3, 5, 7, 9]\n assert candidate(mountain = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10]) == [1, 3, 5, 7, 9, 11, 13, 15, 17]\n assert candidate(mountain = [5, 10, 5, 15, 10, 20, 15, 25, 20, 30, 25, 35, 30, 40, 35]) == [1, 3, 5, 7, 9, 11, 13]\n assert candidate(mountain = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == [4, 8, 12]\n assert candidate(mountain = [1, 3, 2, 4, 1, 5, 4, 6, 1]) == [1, 3, 5, 7]\n assert candidate(mountain = [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, 1, 3, 5, 7, 9, 2, 6, 5, 3, 5, 9, 1, 3, 4, 6, 5, 4, 3, 2, 1, 2, 3]) == [2, 5, 7, 11, 13, 17, 19, 21, 29, 31, 35, 39]\n assert candidate(mountain = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n"}, "metadata": {"canonical_parameter_names": ["mountain"], "leetcode_dataset_entry_point": "Solution().findPeaks", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public List findPeaks(int[] mountain) {", "container": "Solution", "callable": "findPeaks", "parameters": [{"name": "mountain", "type": "int[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2952, "task_id": "minimum-number-of-coins-to-be-added", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array coins, representing the values of the coins available, and an integer target.\nAn integer x is obtainable if there exists a subsequence of coins that sums to x.\nReturn the minimum number of coins of any value that need to be added to the array so that every integer in the range [1, target] is obtainable.\nA subsequence of an array is a new non-empty array that is formed from the original array by deleting some (possibly none) of the elements without disturbing the relative positions of the remaining elements.\n \nExample 1:\n\nInput: coins = [1,4,10], target = 19\nOutput: 2\nExplanation: We need to add coins 2 and 8. The resulting array will be [1,2,4,8,10].\nIt can be shown that all integers from 1 to 19 are obtainable from the resulting array, and that 2 is the minimum number of coins that need to be added to the array. \n\nExample 2:\n\nInput: coins = [1,4,10,5,7,19], target = 19\nOutput: 1\nExplanation: We only need to add the coin 2. The resulting array will be [1,2,4,5,7,10,19].\nIt can be shown that all integers from 1 to 19 are obtainable from the resulting array, and that 1 is the minimum number of coins that need to be added to the array. \n\nExample 3:\n\nInput: coins = [1,1,1], target = 20\nOutput: 3\nExplanation: We need to add coins 4, 8, and 16. The resulting array will be [1,1,1,4,8,16].\nIt can be shown that all integers from 1 to 20 are obtainable from the resulting array, and that 3 is the minimum number of coins that need to be added to the array.\n\n \nConstraints:\n\n1 <= target <= 105\n1 <= coins.length <= 105\n1 <= coins[i] <= target\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coins = [3, 6, 9],target = 15) == 2\n assert candidate(coins = [2, 5, 10],target = 20) == 2\n assert candidate(coins = [1, 4, 10],target = 19) == 2\n assert candidate(coins = [1, 1, 1],target = 20) == 3\n assert candidate(coins = [1, 4, 10, 5, 7, 19],target = 19) == 1\n assert candidate(coins = [1, 2, 4, 8, 16],target = 31) == 0\n assert candidate(coins = [1, 3, 7, 15, 31, 63, 127],target = 256) == 2\n assert candidate(coins = [1, 2, 5, 10, 20],target = 99) == 3\n assert candidate(coins = [1, 5, 10, 25, 50, 100],target = 500) == 5\n assert candidate(coins = [1, 10, 25, 50, 100],target = 300) == 4\n assert candidate(coins = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],target = 150) == 1\n assert candidate(coins = [1, 3, 6, 13, 26, 52],target = 100) == 1\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 100) == 1\n assert candidate(coins = [2, 3, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101],target = 100000) == 8\n assert candidate(coins = [1, 2, 3, 5, 10, 20, 50, 100],target = 1000) == 4\n assert candidate(coins = [10, 20, 30, 40, 50],target = 150) == 4\n assert candidate(coins = [1, 3, 6, 12, 24, 48],target = 100) == 2\n assert candidate(coins = [5, 11, 17, 23, 29, 35, 41, 47, 53],target = 200) == 3\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256],target = 512) == 1\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1023) == 0\n assert candidate(coins = [1, 2, 5, 10, 20, 50],target = 99) == 2\n assert candidate(coins = [2, 6, 18, 54],target = 150) == 5\n assert candidate(coins = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],target = 400) == 4\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 2048) == 1\n assert candidate(coins = [1, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432],target = 1000000) == 1\n assert candidate(coins = [1, 1, 2, 2, 5, 5, 10, 10],target = 50) == 1\n assert candidate(coins = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23],target = 100) == 0\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100],target = 500) == 4\n assert candidate(coins = [2, 4, 6, 8, 10],target = 25) == 1\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000],target = 100000) == 5\n assert candidate(coins = [3, 7, 15, 23],target = 50) == 3\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 30) == 0\n assert candidate(coins = [1, 3, 6, 12],target = 50) == 3\n assert candidate(coins = [2, 6, 10, 14, 18, 22],target = 50) == 2\n assert candidate(coins = [2, 6, 10, 14, 18, 22],target = 100) == 3\n assert candidate(coins = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99],target = 100) == 2\n assert candidate(coins = [3, 6, 9, 12, 15, 18, 21, 24, 27],target = 100) == 2\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64],target = 128) == 1\n assert candidate(coins = [1, 2, 3, 6, 12, 24, 48],target = 100) == 1\n assert candidate(coins = [5, 12, 19, 26, 33, 40, 47, 54, 61, 68, 75],target = 200) == 3\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 250) == 3\n assert candidate(coins = [1, 3, 7, 11, 15],target = 30) == 1\n assert candidate(coins = [2, 3, 6, 9, 18],target = 50) == 2\n assert candidate(coins = [3, 6, 9, 12],target = 45) == 3\n assert candidate(coins = [1, 3, 5, 7, 9, 11],target = 50) == 2\n assert candidate(coins = [5, 9, 12, 18, 23, 34, 41, 50, 65, 78, 90, 100, 120, 150, 200],target = 500) == 3\n assert candidate(coins = [1, 3, 6, 12, 24, 48, 96, 192],target = 500) == 2\n assert candidate(coins = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, 16],target = 100) == 1\n assert candidate(coins = [1, 2, 3, 5, 11, 21, 41],target = 100) == 1\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000],target = 100000) == 5\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 100) == 4\n assert candidate(coins = [2, 6, 18, 54],target = 100) == 4\n assert candidate(coins = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],target = 200) == 3\n assert candidate(coins = [1, 5, 10, 25, 50],target = 120) == 3\n assert candidate(coins = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],target = 999999) == 1\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64],target = 127) == 0\n assert candidate(coins = [2, 3, 5, 7, 11, 13],target = 50) == 2\n assert candidate(coins = [1, 5, 10, 25],target = 100) == 4\n assert candidate(coins = [1, 1, 2, 2, 5, 5],target = 50) == 2\n assert candidate(coins = [5, 10, 20, 50],target = 100) == 4\n assert candidate(coins = [2, 3, 5, 7, 11],target = 30) == 2\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 32767) == 0\n assert candidate(coins = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89],target = 200) == 0\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 50) == 0\n assert candidate(coins = [1, 5, 10, 25, 50],target = 99) == 3\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1024) == 1\n assert candidate(coins = [5, 7, 11, 23],target = 100) == 4\n assert candidate(coins = [1, 3, 9, 30],target = 50) == 3\n assert candidate(coins = [1, 5, 10, 25, 50],target = 100) == 3\n assert candidate(coins = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],target = 2047) == 2\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128],target = 255) == 0\n assert candidate(coins = [1, 5, 10, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000],target = 99999) == 6\n assert candidate(coins = [7, 14, 21, 28, 35, 42, 49],target = 100) == 3\n assert candidate(coins = [5, 10, 20, 50, 100],target = 200) == 4\n assert candidate(coins = [1, 3, 4, 7, 10, 12, 15, 18],target = 100) == 2\n assert candidate(coins = [5, 10, 20, 50, 100, 200],target = 1000) == 6\n assert candidate(coins = [1, 5, 10, 20, 50, 100],target = 300) == 4\n assert candidate(coins = [1, 1, 2, 4, 8, 16, 32, 64, 128],target = 255) == 0\n assert candidate(coins = [10, 20, 30, 40, 50],target = 100) == 4\n assert candidate(coins = [1, 2, 5, 10, 20, 50],target = 100) == 2\n assert candidate(coins = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],target = 100) == 3\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 550) == 4\n assert candidate(coins = [1, 5, 10, 25, 50, 100],target = 300) == 4\n assert candidate(coins = [1, 5, 10, 25],target = 100) == 4\n assert candidate(coins = [2, 4, 8, 16, 32],target = 100) == 2\n assert candidate(coins = [2, 3, 6, 11],target = 30) == 2\n assert candidate(coins = [1, 2, 5, 10, 20, 50],target = 100) == 2\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000],target = 5000000) == 7\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 55) == 0\n assert candidate(coins = [1, 2, 4, 8, 16],target = 100) == 2\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15],target = 100) == 2\n assert candidate(coins = [7, 14, 28, 56],target = 100) == 3\n assert candidate(coins = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],target = 60) == 2\n assert candidate(coins = [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],target = 210) == 3\n assert candidate(coins = [1, 2, 3, 5, 8, 13, 21],target = 50) == 0\n assert candidate(coins = [1, 3, 7, 15, 31, 63],target = 128) == 2\n assert candidate(coins = [10, 20, 30, 40, 50],target = 200) == 5\n assert candidate(coins = [5, 10, 20, 40, 80],target = 200) == 4\n assert candidate(coins = [1, 2, 6, 14, 30],target = 63) == 2\n assert candidate(coins = [2, 6, 14, 30, 62, 126],target = 255) == 3\n assert candidate(coins = [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],target = 60) == 1\n assert candidate(coins = [3, 9, 27, 81],target = 243) == 6\n assert candidate(coins = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],target = 100) == 3\n assert candidate(coins = [1, 3, 6, 12, 24],target = 100) == 3\n assert candidate(coins = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],target = 200) == 2\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == 0\n assert candidate(coins = [3, 7, 11, 25],target = 60) == 3\n assert candidate(coins = [1, 2, 5, 10, 25],target = 100) == 3\n assert candidate(coins = [5, 10, 25],target = 100) == 5\n assert candidate(coins = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300],target = 300) == 1\n"}, "metadata": {"canonical_parameter_names": ["coins", "target"], "leetcode_dataset_entry_point": "Solution().minimumAddedCoins", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int minimumAddedCoins(int[] coins, int target) {", "container": "Solution", "callable": "minimumAddedCoins", "parameters": [{"name": "coins", "type": "int[]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2953, "task_id": "count-complete-substrings", "difficulty": "Hard", "problem_description": "You are given a string word and an integer k.\nA substring s of word is complete if:\n\nEach character in s occurs exactly k times.\nThe difference between two adjacent characters is at most 2. That is, for any two adjacent characters c1 and c2 in s, the absolute difference in their positions in the alphabet is at most 2.\n\nReturn the number of complete substrings of word.\nA substring is a non-empty contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: word = \"igigee\", k = 2\nOutput: 3\nExplanation: The complete substrings where each character appears exactly twice and the difference between adjacent characters is at most 2 are: igigee, igigee, igigee.\n\nExample 2:\n\nInput: word = \"aaabbbccc\", k = 3\nOutput: 6\nExplanation: The complete substrings where each character appears exactly three times and the difference between adjacent characters is at most 2 are: aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc.\n\n \nConstraints:\n\n1 <= word.length <= 105\nword consists only of lowercase English letters.\n1 <= k <= word.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"xyzyxzyzxzyz\",k = 2) == 2\n assert candidate(word = \"mississippi\",k = 1) == 11\n assert candidate(word = \"zzzzzzzzz\",k = 9) == 1\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == 351\n assert candidate(word = \"ababababab\",k = 1) == 19\n assert candidate(word = \"ababab\",k = 2) == 3\n assert candidate(word = \"ababababab\",k = 2) == 7\n assert candidate(word = \"abcdabcdabcd\",k = 4) == 0\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 1) == 77\n assert candidate(word = \"qrstuvqrstuvqrstuv\",k = 3) == 0\n assert candidate(word = \"mnopqrspqr\",k = 2) == 0\n assert candidate(word = \"zzzzzzzzz\",k = 3) == 7\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",k = 1) == 351\n assert candidate(word = \"aabbccddeeffgghhii\",k = 2) == 45\n assert candidate(word = \"abacabadabacaba\",k = 1) == 31\n assert candidate(word = \"zzzzzzzzz\",k = 2) == 8\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 5) == 46\n assert candidate(word = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\",k = 4) == 0\n assert candidate(word = \"abcdefg\",k = 1) == 28\n assert candidate(word = \"abcd\",k = 1) == 10\n assert candidate(word = \"abcabcabcabcabc\",k = 3) == 7\n assert candidate(word = \"aaabbbccc\",k = 3) == 6\n assert candidate(word = \"abcde\",k = 1) == 15\n assert candidate(word = \"abababababababababababababababababababababababababababababababababa\",k = 2) == 64\n assert candidate(word = \"xyzxyzxyz\",k = 3) == 1\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 1) == 114\n assert candidate(word = \"zzzzzzyyyxx\",k = 2) == 10\n assert candidate(word = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == 31\n assert candidate(word = \"abcabcabcabc\",k = 4) == 1\n assert candidate(word = \"a\",k = 1) == 1\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 26) == 25\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 5) == 40\n assert candidate(word = \"abcabcabcabc\",k = 3) == 4\n assert candidate(word = \"igigee\",k = 2) == 3\n assert candidate(word = \"aaaaaa\",k = 6) == 1\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 3) == 58\n assert candidate(word = \"abcabcabc\",k = 3) == 1\n assert candidate(word = \"xxxxxxyyyyyzzzzz\",k = 5) == 7\n assert candidate(word = \"abcabcabcabcabcabcabc\",k = 3) == 13\n assert candidate(word = \"aabbaa\",k = 2) == 6\n assert candidate(word = \"qqqqqqqqqqqqqqqqqqqq\",k = 5) == 16\n assert candidate(word = \"aaaabbbbcccc\",k = 4) == 6\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == 50\n assert candidate(word = \"acacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacaca\",k = 2) == 64\n assert candidate(word = \"ababababababababababababab\",k = 2) == 23\n assert candidate(word = \"zzzzzz\",k = 2) == 5\n assert candidate(word = \"zzzzzzzzzz\",k = 5) == 6\n assert candidate(word = \"zzzyyyxxxwwvvuuttrrqqqppponnmmllkkjjiihhggffeeddccbbbaaa\",k = 3) == 12\n assert candidate(word = \"aaaabbbbccccddddeeeeffff\",k = 4) == 21\n assert candidate(word = \"aaaabbbbccccdddd\",k = 4) == 10\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 3) == 55\n assert candidate(word = \"abacabadabacaba\",k = 3) == 0\n assert candidate(word = \"mississippi\",k = 2) == 3\n assert candidate(word = \"aaa\",k = 1) == 3\n assert candidate(word = \"aabbbcccaabb\",k = 2) == 12\n assert candidate(word = \"abcdefghi\",k = 1) == 45\n assert candidate(word = \"ababababababababababababababababababababab\",k = 2) == 39\n assert candidate(word = \"zzzyyyxxxwwwwvvvuuutttsssrrrqqqpppoonnmmmlllkkkjjjiii\",k = 3) == 61\n assert candidate(word = \"aabbcc\",k = 2) == 6\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzzz\",k = 1) == 354\n assert candidate(word = \"xyzyxzyzxzyx\",k = 2) == 3\n assert candidate(word = \"zzzzz\",k = 5) == 1\n assert candidate(word = \"abacaba\",k = 1) == 15\n assert candidate(word = \"aabbaabbaabbaabb\",k = 2) == 21\n assert candidate(word = \"abacabadabacaba\",k = 2) == 0\n assert candidate(word = \"abcdabcdeabcdabcde\",k = 2) == 0\n assert candidate(word = \"abcabcabc\",k = 1) == 24\n assert candidate(word = \"zzzzz\",k = 1) == 5\n assert candidate(word = \"mnopqr\",k = 1) == 21\n assert candidate(word = \"xyxxyxyxyx\",k = 2) == 6\n assert candidate(word = \"mnopqrsmnopqrsmnopqrsmnopqrs\",k = 5) == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 5) == 47\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnm\",k = 1) == 51\n assert candidate(word = \"abcdefghij\",k = 1) == 55\n assert candidate(word = \"zzzaaa\",k = 3) == 2\n assert candidate(word = \"qqwweerrtt\",k = 2) == 6\n assert candidate(word = \"abcdefghijk\",k = 1) == 66\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 2) == 351\n assert candidate(word = \"abcdabcdabcd\",k = 2) == 0\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabc\",k = 3) == 22\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzaaa\",k = 1) == 354\n assert candidate(word = \"aaaabbbbccccaaaabbbbcccc\",k = 4) == 24\n assert candidate(word = \"zzzzzz\",k = 1) == 6\n assert candidate(word = \"abcabcabcabcabcabc\",k = 3) == 10\n assert candidate(word = \"abababababababababab\",k = 2) == 17\n assert candidate(word = \"abcdef\",k = 1) == 21\n assert candidate(word = \"aabbccddeeaabbccddeeaabbccddeeddeeaabbcc\",k = 2) == 57\n assert candidate(word = \"abcdabc\",k = 2) == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 43\n assert candidate(word = \"zzzyyyxxx\",k = 3) == 6\n assert candidate(word = \"xyzzzzzyxxyzzzzzyx\",k = 3) == 6\n"}, "metadata": {"canonical_parameter_names": ["word", "k"], "leetcode_dataset_entry_point": "Solution().countCompleteSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countCompleteSubstrings(String word, int k) {", "container": "Solution", "callable": "countCompleteSubstrings", "parameters": [{"name": "word", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2956, "task_id": "find-common-elements-between-two-arrays", "difficulty": "Easy", "problem_description": "You are given two integer arrays nums1 and nums2 of sizes n and m, respectively. Calculate the following values:\n\nanswer1 : the number of indices i such that nums1[i] exists in nums2.\nanswer2 : the number of indices i such that nums2[i] exists in nums1.\n\nReturn [answer1,answer2].\n \nExample 1:\n\nInput: nums1 = [2,3,2], nums2 = [1,2]\nOutput: [2,1]\nExplanation:\n\n\nExample 2:\n\nInput: nums1 = [4,3,2,3,1], nums2 = [2,2,5,2,3,6]\nOutput: [3,4]\nExplanation:\nThe elements at indices 1, 2, and 3 in nums1 exist in nums2 as well. So answer1 is 3.\nThe elements at indices 0, 1, 3, and 4 in nums2 exist in nums1. So answer2 is 4.\n\nExample 3:\n\nInput: nums1 = [3,4,2,3], nums2 = [1,5]\nOutput: [0,0]\nExplanation:\nNo numbers are common between nums1 and nums2, so answer is [0,0].\n\n \nConstraints:\n\nn == nums1.length\nm == nums2.length\n1 <= n, m <= 100\n1 <= nums1[i], nums2[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10, 20, 30],nums2 = [5, 15, 25, 35]) == [0, 0]\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10]) == [3, 3]\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == [4, 4]\n assert candidate(nums1 = [2, 3, 2],nums2 = [1, 2]) == [2, 1]\n assert candidate(nums1 = [10, 20, 30],nums2 = [5, 15, 25, 35, 45]) == [0, 0]\n assert candidate(nums1 = [100, 99, 98],nums2 = [97, 96, 95]) == [0, 0]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == [0, 0]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == [5, 5]\n assert candidate(nums1 = [50, 60, 70],nums2 = [50, 60, 70, 80, 90]) == [3, 3]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == [0, 0]\n assert candidate(nums1 = [50, 51, 52],nums2 = [49, 50, 51]) == [2, 2]\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5]) == [1, 1]\n assert candidate(nums1 = [1],nums2 = [2]) == [0, 0]\n assert candidate(nums1 = [50, 50, 50],nums2 = [50, 50]) == [3, 2]\n assert candidate(nums1 = [100, 1, 50],nums2 = [50, 100, 200]) == [2, 2]\n assert candidate(nums1 = [4, 3, 2, 3, 1],nums2 = [2, 2, 5, 2, 3, 6]) == [3, 4]\n assert candidate(nums1 = [3, 4, 2, 3],nums2 = [1, 5]) == [0, 0]\n assert candidate(nums1 = [100, 100, 100],nums2 = [100]) == [3, 1]\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == [0, 0]\n assert candidate(nums1 = [10],nums2 = [10]) == [1, 1]\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1]) == [4, 3]\n assert candidate(nums1 = [1],nums2 = [1]) == [1, 1]\n assert candidate(nums1 = [1, 2, 3],nums2 = [1, 2, 3, 4, 5]) == [3, 3]\n assert candidate(nums1 = [100],nums2 = [100]) == [1, 1]\n assert candidate(nums1 = [50],nums2 = [50]) == [1, 1]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [5, 5]\n assert candidate(nums1 = [99, 98, 97, 96, 95],nums2 = [50, 40, 30, 20, 10]) == [0, 0]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [10, 15, 20, 25, 30]) == [3, 3]\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]) == [3, 3]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [5, 10]\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]) == [6, 6]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [10, 10]\n assert candidate(nums1 = [99, 98, 97, 96, 95],nums2 = [95, 96, 97, 98, 99]) == [5, 5]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60],nums2 = [5, 15, 25, 35, 45, 55, 65]) == [0, 0]\n assert candidate(nums1 = [23, 45, 67, 89, 12, 34, 56],nums2 = [12, 23, 34, 45, 56, 67, 78, 89, 90]) == [7, 7]\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, 10]\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 1, 2, 3, 4, 5, 6]) == [3, 3]\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, 11, 12]) == [10, 10]\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5]) == [5, 5]\n assert candidate(nums1 = [100, 99, 98, 97, 96],nums2 = [95, 96, 97, 98, 99]) == [4, 4]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9]) == [5, 5]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [0, 0]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [3, 3, 3, 3, 2, 2, 1, 1]) == [6, 8]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 10]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5]) == [5, 5]\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]) == [5, 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]) == [0, 0]\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [0, 0]\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, 1, 2, 3, 4, 5]) == [10, 15]\n assert candidate(nums1 = [50],nums2 = [50, 50, 50, 50, 50, 50]) == [1, 6]\n assert candidate(nums1 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0]\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49],nums2 = [7, 21, 35, 49, 56, 63, 70]) == [4, 4]\n assert candidate(nums1 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],nums2 = [91, 92, 93, 94, 95]) == [5, 5]\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [15, 25, 35, 45, 55]) == [2, 2]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == [0, 0]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5]) == [0, 0]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 5]\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5]) == [7, 5]\n assert candidate(nums1 = [99, 98, 97, 96, 95],nums2 = [95, 94, 93, 92, 91]) == [1, 1]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [40, 50, 60, 70, 80]) == [2, 2]\n assert candidate(nums1 = [99, 98, 97, 96, 95],nums2 = [94, 93, 92, 91, 90]) == [0, 0]\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, 5]\n assert candidate(nums1 = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],nums2 = [1, 2, 3, 4, 5, 90, 91, 92, 93, 94]) == [5, 5]\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [10, 10]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == [5, 5]\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55],nums2 = [10, 20, 30, 40, 50]) == [0, 0]\n assert candidate(nums1 = [7, 8, 9, 10, 11, 12],nums2 = [5, 6, 7, 8, 9, 10]) == [4, 4]\n assert candidate(nums1 = [42],nums2 = [42, 42, 42, 42, 42]) == [1, 5]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [0, 0]\n assert candidate(nums1 = [42],nums2 = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [1, 10]\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5]) == [7, 7]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [3, 3, 2, 2, 1, 1]) == [6, 6]\n assert candidate(nums1 = [9, 18, 27, 36, 45],nums2 = [8, 17, 26, 35, 44, 53]) == [0, 0]\n assert candidate(nums1 = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0]\n assert candidate(nums1 = [7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9]) == [3, 3]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [10, 10]\n assert candidate(nums1 = [2, 4, 6, 8, 10, 2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == [0, 0]\n assert candidate(nums1 = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 100]) == [10, 10]\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [5, 5]\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]) == [1, 1]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == [0, 0]\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5]) == [5, 8]\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [25, 20, 15, 10, 5]) == [5, 5]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == [5, 10]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9, 10]) == [1, 1]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 5]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [10, 10]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [10, 10]\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [10, 20, 30, 40, 50]) == [2, 2]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == [5, 5]\n assert candidate(nums1 = [100, 1, 50, 75],nums2 = [50, 75, 100, 1, 50, 75, 100, 1]) == [4, 8]\n assert candidate(nums1 = [100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100]) == [1, 1]\n assert candidate(nums1 = [1, 10, 20, 30, 40],nums2 = [1, 10, 20, 30, 40]) == [5, 5]\n assert candidate(nums1 = [1, 2, 2, 3, 4],nums2 = [2, 3, 3, 4, 5]) == [4, 4]\n assert candidate(nums1 = [23, 45, 67, 89, 23],nums2 = [23, 45, 99, 23, 67, 100]) == [4, 4]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5, 10, 20, 30, 40, 50]) == [5, 5]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55]) == [0, 0]\n assert candidate(nums1 = [100, 99, 98, 97, 96],nums2 = [95, 94, 93, 92, 91]) == [0, 0]\n assert candidate(nums1 = [50, 50, 50, 50, 50],nums2 = [50, 50, 50, 50, 50]) == [5, 5]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == [5, 5]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [11, 22, 33, 44, 55]) == [0, 0]\n assert candidate(nums1 = [100, 99, 98, 97, 96, 95],nums2 = [96, 97, 98, 99, 100]) == [5, 5]\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().findIntersectionValues", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] findIntersectionValues(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "findIntersectionValues", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2957, "task_id": "remove-adjacent-almost-equal-characters", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string word.\nIn one operation, you can pick any index i of word and change word[i] to any lowercase English letter.\nReturn the minimum number of operations needed to remove all adjacent almost-equal characters from word.\nTwo characters a and b are almost-equal if a == b or a and b are adjacent in the alphabet.\n \nExample 1:\n\nInput: word = \"aaaaa\"\nOutput: 2\nExplanation: We can change word into \"acaca\" which does not have any adjacent almost-equal characters.\nIt can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.\n\nExample 2:\n\nInput: word = \"abddez\"\nOutput: 2\nExplanation: We can change word into \"ybdoez\" which does not have any adjacent almost-equal characters.\nIt can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.\nExample 3:\n\nInput: word = \"zyxyxyz\"\nOutput: 3\nExplanation: We can change word into \"zaxaxaz\" which does not have any adjacent almost-equal characters. \nIt can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 3.\n\n \nConstraints:\n\n1 <= word.length <= 100\nword consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"abddez\") == 2\n assert candidate(word = \"qrstuvwpqrstuvwxyz\") == 8\n assert candidate(word = \"abecidof\") == 1\n assert candidate(word = \"zzz\") == 1\n assert candidate(word = \"abacaba\") == 2\n assert candidate(word = \"abababab\") == 4\n assert candidate(word = \"acacacac\") == 0\n assert candidate(word = \"xyz\") == 1\n assert candidate(word = \"abcde\") == 2\n assert candidate(word = \"aabbcc\") == 3\n assert candidate(word = \"zzzzz\") == 2\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 26\n assert candidate(word = \"abcdefg\") == 3\n assert candidate(word = \"a\") == 0\n assert candidate(word = \"mnonmo\") == 2\n assert candidate(word = \"abc\") == 1\n assert candidate(word = \"acxz\") == 0\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\") == 13\n assert candidate(word = \"aaaaa\") == 2\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 13\n assert candidate(word = \"qwert\") == 0\n assert candidate(word = \"zyxyxyz\") == 3\n assert candidate(word = \"aabbaabbaabbaabbaabbaabb\") == 12\n assert candidate(word = \"aaabbbccc\") == 4\n assert candidate(word = \"aaaaabbbbbaaaa\") == 7\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 39\n assert candidate(word = \"zzzyyxxwwvvuuttrrssqqppoonnllkkjjiihhggffeeddccbbaa\") == 25\n assert candidate(word = \"abbbccddeeefffggghhhhiiiiijjjjkkkkllllmmmmmnnnnnooooo\") == 26\n assert candidate(word = \"mississippi\") == 3\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmnnnooopppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 50\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbbaaaa\") == 54\n assert candidate(word = \"aabbbcccddddeeeeffffgggghhhhiiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwwxxxxxyyyyyzzzzz\") == 52\n assert candidate(word = \"aazzbbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 27\n assert candidate(word = \"zzzzyyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbbaaaa\") == 30\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(word = \"aaaabbbbcccc\") == 6\n assert candidate(word = \"qwerttyuiiooppllkkiijjhhggffeedcvvbbnnaassddffgghhjjiikkllppoouuyyttrewqq\") == 32\n assert candidate(word = \"aaaabbbbccccaaaabbbbcccc\") == 12\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmnnnooopppqqqqrrrrssssttttuuuuuvvvvwwwwxxxxyyyyzzzz\") == 50\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 39\n assert candidate(word = \"aabbaaabbbaaa\") == 6\n assert candidate(word = \"banana\") == 1\n assert candidate(word = \"abcabcabcabcabcabc\") == 6\n assert candidate(word = \"abcdeedcba\") == 5\n assert candidate(word = \"zyxzyxzyx\") == 3\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 50\n assert candidate(word = \"ababababababababababc\") == 10\n assert candidate(word = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == 18\n assert candidate(word = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxyyyzzz\") == 40\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(word = \"aabbccddeeaabbccddee\") == 10\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == 27\n assert candidate(word = \"ababababababababababababababababababababab\") == 21\n assert candidate(word = \"zyxzyxzyxzyxzyxzyxzyxzyx\") == 8\n assert candidate(word = \"mnopqrspqrstmnopqrspqrstmnopqrspqrst\") == 15\n assert candidate(word = \"aaaaabbbbbaaaaabbbbbaaaa\") == 12\n assert candidate(word = \"aaaabbbbccccdddd\") == 8\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 26\n assert candidate(word = \"abzycxyxbwaxavauatassarapaoanamaalakajaiagafae\") == 5\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcba\") == 39\n assert candidate(word = \"ababababab\") == 5\n assert candidate(word = \"abzabzabzabzabz\") == 5\n assert candidate(word = \"aabbaabbccddeeffaabbccddeeff\") == 14\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzz\") == 10\n assert candidate(word = \"abacabcabacabcabacabcabacabcabacabcabacabc\") == 12\n assert candidate(word = \"abacabadabacabadaba\") == 5\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbaaaaaaaaaaaaa\") == 19\n assert candidate(word = \"aaaaabbbbbccccc\") == 7\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcb\") == 25\n assert candidate(word = \"zzzyyyxxxwwwwvvvuuuuttttssssrrrrqqqqppppllllooooiiiihhhhhgggggffffffeeeeeeeedddddccccbbbbaaa\") == 46\n assert candidate(word = \"abcabcabc\") == 3\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 25\n assert candidate(word = \"acxzacxzacxzacxzacxzacxz\") == 0\n assert candidate(word = \"zzzyyxxwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbbaaa\") == 27\n assert candidate(word = \"zazazazazazazazazaza\") == 0\n assert candidate(word = \"ababababababababababababababababababababababababababababababab\") == 31\n assert candidate(word = \"bookkeeper\") == 3\n assert candidate(word = \"abababababababababababababababababab\") == 18\n assert candidate(word = \"abababababababababababababab\") == 14\n assert candidate(word = \"zazazazazazazazazaabc\") == 2\n assert candidate(word = \"abczyxabczyxabczyx\") == 6\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 41\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 21\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaa\") == 27\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(word = \"abzabzabz\") == 3\n assert candidate(word = \"abacabadabacabadabacabad\") == 6\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 22\n assert candidate(word = \"abcdabcdabcdabcdabcdabcd\") == 12\n assert candidate(word = \"abcabcabcabc\") == 4\n assert candidate(word = \"abacabadabacabadabacabadabacabad\") == 8\n assert candidate(word = \"abacabadabacaba\") == 4\n assert candidate(word = \"abababababababababab\") == 10\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 26\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().removeAlmostEqualCharacters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int removeAlmostEqualCharacters(String word) {", "container": "Solution", "callable": "removeAlmostEqualCharacters", "parameters": [{"name": "word", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2958, "task_id": "length-of-longest-subarray-with-at-most-k-frequency", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k.\nThe frequency of an element x is the number of times it occurs in an array.\nAn array is called good if the frequency of each element in this array is less than or equal to k.\nReturn the length of the longest good subarray of nums.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,2,3,1,2,3,1,2], k = 2\nOutput: 6\nExplanation: The longest possible good subarray is [1,2,3,1,2,3] since the values 1, 2, and 3 occur at most twice in this subarray. Note that the subarrays [2,3,1,2,3,1] and [3,1,2,3,1,2] are also good.\nIt can be shown that there are no good subarrays with length more than 6.\n\nExample 2:\n\nInput: nums = [1,2,1,2,1,2,1,2], k = 1\nOutput: 2\nExplanation: The longest possible good subarray is [1,2] since the values 1 and 2 occur at most once in this subarray. Note that the subarray [2,1] is also good.\nIt can be shown that there are no good subarrays with length more than 2.\n\nExample 3:\n\nInput: nums = [5,5,5,5,5,5,5], k = 4\nOutput: 4\nExplanation: The longest possible good subarray is [5,5,5,5] since the value 5 occurs 4 times in this subarray.\nIt can be shown that there are no good subarrays with length more than 4.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= k <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],k = 2) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 1) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],k = 3) == 3\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 3) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 4) == 4\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 2) == 2\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2],k = 1) == 2\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1],k = 2) == 5\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2],k = 2) == 6\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 2) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 3) == 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],k = 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],k = 1) == 1\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 = 2) == 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],k = 5) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 4\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 = 1) == 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, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 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, 6],k = 3) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 2, 3, 4, 5, 6],k = 4) == 9\n assert candidate(nums = [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],k = 1) == 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 4\n assert candidate(nums = [100, 200, 100, 300, 200, 100, 400, 300, 200, 100],k = 2) == 7\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 = 3) == 9\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 = 1) == 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],k = 1) == 1\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],k = 2) == 4\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 = 2) == 20\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6, 4, 5, 6, 7, 8, 9, 7, 8, 9, 7, 8, 9, 10, 10, 10, 10, 10],k = 2) == 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 = 1) == 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],k = 5) == 5\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, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 18\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],k = 3) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3],k = 2) == 4\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 3) == 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 = 1) == 20\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],k = 2) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 10\n assert candidate(nums = [100, 200, 100, 300, 100, 200, 400, 200, 100, 200, 100, 300, 100, 400, 100],k = 3) == 9\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 8, 9, 8, 9, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 2) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 4) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 2) == 10\n assert candidate(nums = [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, 0, 0],k = 2) == 20\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 = 10) == 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 5\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9],k = 3) == 9\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 = 1) == 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, 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 = 1) == 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5],k = 2) == 8\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) == 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],k = 2) == 6\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],k = 20) == 20\n assert candidate(nums = [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],k = 2) == 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 = 1) == 2\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 999999999, 999999999, 999999999, 888888888, 888888888, 888888888, 777777777, 777777777, 777777777],k = 3) == 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, 7, 6, 5, 4, 3, 2, 1],k = 2) == 18\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],k = 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, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 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],k = 2) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 30\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 3) == 15\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3],k = 3) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\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, 0, 0, 0],k = 3) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 3) == 15\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],k = 4) == 20\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6],k = 4) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 10) == 30\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 3) == 9\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],k = 2) == 6\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 5) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 30\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],k = 2) == 6\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 = 2) == 5\n assert candidate(nums = [9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5],k = 3) == 6\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 16\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2],k = 2) == 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],k = 3) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3],k = 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, 8, 8, 8, 9, 9, 9, 10, 10, 10, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],k = 3) == 30\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300],k = 3) == 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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 2) == 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 = 10) == 20\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],k = 4) == 24\n assert candidate(nums = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 5) == 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, 1, 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) == 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 40\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 = 3) == 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0],k = 2) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 40\n assert candidate(nums = [5, 7, 7, 7, 7, 3, 3, 5, 5, 5, 7, 7, 5, 5, 7, 7, 5, 5, 5, 5],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, 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],k = 2) == 20\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],k = 2) == 18\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10],k = 3) == 8\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 2) == 4\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 = 5) == 25\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],k = 3) == 30\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxSubarrayLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int maxSubarrayLength(int[] nums, int k) {", "container": "Solution", "callable": "maxSubarrayLength", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2959, "task_id": "number-of-possible-sets-of-closing-branches", "difficulty": "Hard", "problem_description": "There is a company with n branches across the country, some of which are connected by roads. Initially, all branches are reachable from each other by traveling some roads.\nThe company has realized that they are spending an excessive amount of time traveling between their branches. As a result, they have decided to close down some of these branches (possibly none). However, they want to ensure that the remaining branches have a distance of at most maxDistance from each other.\nThe distance between two branches is the minimum total traveled length needed to reach one branch from another.\nYou are given integers n, maxDistance, and a 0-indexed 2D array roads, where roads[i] = [ui, vi, wi] represents the undirected road between branches ui and vi with length wi.\nReturn the number of possible sets of closing branches, so that any branch has a distance of at most maxDistance from any other.\nNote that, after closing a branch, the company will no longer have access to any roads connected to it.\nNote that, multiple roads are allowed.\n \nExample 1:\n\n\nInput: n = 3, maxDistance = 5, roads = [[0,1,2],[1,2,10],[0,2,10]]\nOutput: 5\nExplanation: The possible sets of closing branches are:\n- The set [2], after closing, active branches are [0,1] and they are reachable to each other within distance 2.\n- The set [0,1], after closing, the active branch is [2].\n- The set [1,2], after closing, the active branch is [0].\n- The set [0,2], after closing, the active branch is [1].\n- The set [0,1,2], after closing, there are no active branches.\nIt can be proven, that there are only 5 possible sets of closing branches.\n\nExample 2:\n\n\nInput: n = 3, maxDistance = 5, roads = [[0,1,20],[0,1,10],[1,2,2],[0,2,2]]\nOutput: 7\nExplanation: The possible sets of closing branches are:\n- The set [], after closing, active branches are [0,1,2] and they are reachable to each other within distance 4.\n- The set [0], after closing, active branches are [1,2] and they are reachable to each other within distance 2.\n- The set [1], after closing, active branches are [0,2] and they are reachable to each other within distance 2.\n- The set [0,1], after closing, the active branch is [2].\n- The set [1,2], after closing, the active branch is [0].\n- The set [0,2], after closing, the active branch is [1].\n- The set [0,1,2], after closing, there are no active branches.\nIt can be proven, that there are only 7 possible sets of closing branches.\n\nExample 3:\n\nInput: n = 1, maxDistance = 10, roads = []\nOutput: 2\nExplanation: The possible sets of closing branches are:\n- The set [], after closing, the active branch is [0].\n- The set [0], after closing, there are no active branches.\nIt can be proven, that there are only 2 possible sets of closing branches.\n\n \nConstraints:\n\n1 <= n <= 10\n1 <= maxDistance <= 105\n0 <= roads.length <= 1000\nroads[i].length == 3\n0 <= ui, vi <= n - 1\nui != vi\n1 <= wi <= 1000\nAll branches are reachable from each other by traveling some roads.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,maxDistance = 5,roads = [[0, 1, 2], [1, 2, 10], [0, 2, 10]]) == 5\n assert candidate(n = 5,maxDistance = 10,roads = [[0, 1, 2], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 0, 5]]) == 20\n assert candidate(n = 1,maxDistance = 10,roads = []) == 2\n assert candidate(n = 2,maxDistance = 1,roads = [[0, 1, 1]]) == 4\n assert candidate(n = 4,maxDistance = 6,roads = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 0, 1]]) == 14\n assert candidate(n = 6,maxDistance = 15,roads = [[0, 1, 3], [1, 2, 3], [2, 3, 3], [3, 4, 3], [4, 5, 3], [5, 0, 3]]) == 32\n assert candidate(n = 3,maxDistance = 5,roads = [[0, 1, 20], [0, 1, 10], [1, 2, 2], [0, 2, 2]]) == 7\n assert candidate(n = 5,maxDistance = 6,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [3, 4, 4]]) == 11\n assert candidate(n = 4,maxDistance = 4,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 0, 4]]) == 10\n assert candidate(n = 4,maxDistance = 15,roads = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [0, 3, 15]]) == 12\n assert candidate(n = 4,maxDistance = 3,roads = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 0, 2]]) == 9\n assert candidate(n = 5,maxDistance = 5,roads = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 0, 1], [0, 2, 1], [1, 3, 1], [2, 4, 1], [3, 0, 1], [4, 1, 1]]) == 32\n assert candidate(n = 5,maxDistance = 5,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 0, 5], [0, 2, 6], [1, 3, 7], [2, 4, 8]]) == 13\n assert candidate(n = 9,maxDistance = 15,roads = [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 4, 2], [1, 5, 3], [2, 4, 4], [2, 6, 5], [3, 5, 1], [3, 7, 2], [4, 6, 3], [4, 8, 4], [5, 7, 6], [6, 8, 7], [7, 8, 1]]) == 198\n assert candidate(n = 8,maxDistance = 10,roads = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 0, 1]]) == 58\n assert candidate(n = 5,maxDistance = 10,roads = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 1, 3]]) == 30\n assert candidate(n = 6,maxDistance = 12,roads = [[0, 1, 2], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [0, 3, 6], [1, 4, 7], [2, 5, 8], [3, 0, 9], [4, 1, 10], [5, 2, 11]]) == 43\n assert candidate(n = 5,maxDistance = 8,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 0, 6], [0, 2, 1], [1, 3, 1], [2, 4, 1]]) == 29\n assert candidate(n = 7,maxDistance = 12,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7], [0, 3, 3], [1, 4, 4], [2, 5, 5], [3, 6, 6], [4, 0, 1], [5, 1, 2], [6, 2, 3]]) == 109\n assert candidate(n = 4,maxDistance = 4,roads = [[0, 1, 1], [0, 2, 3], [1, 2, 2], [1, 3, 2], [2, 3, 3]]) == 14\n assert candidate(n = 10,maxDistance = 30,roads = [[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, 0, 10], [0, 3, 2], [1, 4, 2], [2, 5, 2], [3, 6, 2], [4, 7, 2], [5, 8, 2], [6, 9, 2], [7, 0, 2], [8, 1, 2], [9, 2, 2]]) == 807\n assert candidate(n = 9,maxDistance = 25,roads = [[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], [0, 5, 10], [1, 6, 11], [2, 7, 12], [3, 8, 13], [4, 0, 14], [5, 1, 15], [6, 2, 16], [7, 3, 17], [8, 4, 18]]) == 252\n assert candidate(n = 8,maxDistance = 20,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 4, 9], [1, 5, 10], [2, 6, 11], [3, 7, 12], [4, 0, 13], [5, 1, 14], [6, 2, 15], [7, 3, 16]]) == 137\n assert candidate(n = 7,maxDistance = 12,roads = [[0, 1, 3], [1, 2, 2], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 2], [6, 0, 1], [0, 3, 2], [2, 4, 3], [1, 5, 2]]) == 87\n assert candidate(n = 6,maxDistance = 10,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6], [0, 2, 1], [1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 0, 1], [5, 1, 1]]) == 61\n assert candidate(n = 5,maxDistance = 5,roads = [[0, 1, 5], [1, 2, 3], [2, 3, 2], [3, 4, 4], [4, 0, 3], [1, 4, 1], [2, 4, 2], [0, 3, 2]]) == 28\n assert candidate(n = 5,maxDistance = 10,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 0, 6]]) == 17\n assert candidate(n = 5,maxDistance = 7,roads = [[0, 1, 3], [1, 2, 2], [2, 3, 4], [3, 4, 5], [4, 0, 6], [1, 3, 1]]) == 18\n assert candidate(n = 6,maxDistance = 10,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 0, 7], [0, 3, 1], [1, 4, 2], [2, 5, 3]]) == 52\n assert candidate(n = 6,maxDistance = 10,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 0, 1]]) == 23\n assert candidate(n = 4,maxDistance = 2,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 0, 4]]) == 7\n assert candidate(n = 6,maxDistance = 8,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 2], [3, 4, 3], [4, 5, 2], [5, 0, 1], [0, 3, 4], [2, 4, 1], [1, 3, 2]]) == 50\n assert candidate(n = 6,maxDistance = 7,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 2], [3, 4, 3], [4, 5, 2], [5, 0, 3]]) == 23\n assert candidate(n = 8,maxDistance = 8,roads = [[0, 1, 2], [0, 3, 5], [0, 4, 8], [1, 2, 3], [1, 5, 6], [2, 6, 4], [3, 4, 2], [3, 5, 1], [4, 6, 7], [5, 7, 2], [6, 7, 3]]) == 41\n assert candidate(n = 4,maxDistance = 4,roads = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 0, 1], [0, 2, 1], [1, 3, 1], [0, 3, 1], [2, 1, 1]]) == 16\n assert candidate(n = 5,maxDistance = 7,roads = [[0, 1, 10], [0, 2, 15], [0, 3, 20], [0, 4, 25], [1, 2, 5], [1, 3, 10], [1, 4, 15], [2, 3, 5], [2, 4, 10], [3, 4, 5]]) == 9\n assert candidate(n = 6,maxDistance = 10,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 1], [3, 4, 4], [4, 5, 2], [5, 0, 5], [0, 3, 3], [1, 4, 2], [2, 5, 4]]) == 56\n assert candidate(n = 5,maxDistance = 10,roads = [[0, 1, 5], [1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 0, 1], [0, 2, 1], [1, 3, 2], [2, 4, 3]]) == 30\n assert candidate(n = 7,maxDistance = 8,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7]]) == 20\n assert candidate(n = 5,maxDistance = 15,roads = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 0, 50]]) == 7\n assert candidate(n = 7,maxDistance = 15,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7], [0, 3, 8], [1, 4, 9], [2, 5, 10], [3, 6, 11], [4, 0, 12], [5, 1, 13], [6, 2, 14]]) == 85\n assert candidate(n = 10,maxDistance = 30,roads = [[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, 0, 10], [0, 6, 11], [1, 7, 12], [2, 8, 13], [3, 9, 14], [4, 0, 15], [5, 1, 16], [6, 2, 17], [7, 3, 18], [8, 4, 19], [9, 5, 20]]) == 573\n assert candidate(n = 9,maxDistance = 15,roads = [[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], [0, 2, 1], [1, 3, 2], [2, 4, 3], [3, 5, 4], [4, 6, 5], [5, 7, 6], [6, 8, 7], [7, 1, 8], [8, 2, 9]]) == 245\n assert candidate(n = 5,maxDistance = 10,roads = [[0, 1, 3], [1, 2, 1], [2, 3, 4], [3, 4, 2], [4, 0, 5]]) == 21\n assert candidate(n = 6,maxDistance = 7,roads = [[0, 1, 2], [0, 2, 3], [1, 3, 1], [2, 4, 2], [3, 4, 2], [3, 5, 1], [4, 5, 3]]) == 35\n assert candidate(n = 5,maxDistance = 3,roads = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 0, 2], [0, 3, 1], [1, 4, 1], [2, 0, 1], [3, 1, 1], [4, 2, 1]]) == 32\n assert candidate(n = 5,maxDistance = 20,roads = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 0, 25], [0, 3, 1], [1, 4, 6]]) == 21\n assert candidate(n = 6,maxDistance = 15,roads = [[0, 1, 2], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6], [0, 3, 1], [1, 4, 1], [2, 5, 1]]) == 56\n assert candidate(n = 4,maxDistance = 4,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 0, 5], [0, 2, 1], [1, 3, 1], [2, 0, 1], [3, 1, 1]]) == 14\n assert candidate(n = 5,maxDistance = 6,roads = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 0, 1], [0, 2, 2], [1, 3, 2], [2, 4, 2], [3, 0, 2], [4, 1, 2]]) == 32\n assert candidate(n = 4,maxDistance = 5,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 0, 4], [0, 2, 2], [1, 3, 3], [2, 0, 3], [3, 1, 4]]) == 16\n assert candidate(n = 5,maxDistance = 5,roads = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 0, 5]]) == 11\n assert candidate(n = 8,maxDistance = 15,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 0, 9]]) == 29\n assert candidate(n = 10,maxDistance = 20,roads = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [1, 5, 6], [1, 6, 7], [2, 6, 8], [2, 7, 9], [3, 7, 10], [3, 8, 11], [4, 8, 12], [4, 9, 13], [5, 9, 14], [6, 9, 15], [7, 9, 16], [8, 9, 17]]) == 120\n assert candidate(n = 5,maxDistance = 10,roads = [[0, 1, 3], [0, 2, 5], [1, 3, 2], [2, 3, 4], [3, 4, 1]]) == 22\n assert candidate(n = 7,maxDistance = 20,roads = [[0, 1, 5], [1, 2, 6], [2, 3, 7], [3, 4, 8], [4, 5, 9], [5, 6, 10], [6, 0, 11], [0, 4, 3], [1, 5, 4], [2, 6, 5]]) == 75\n assert candidate(n = 6,maxDistance = 8,roads = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 0, 1], [0, 3, 1], [1, 4, 1], [2, 5, 1], [3, 0, 1], [4, 1, 1], [5, 2, 1]]) == 56\n assert candidate(n = 6,maxDistance = 4,roads = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 0, 2], [0, 3, 1], [1, 4, 1], [2, 5, 1], [3, 0, 1], [4, 1, 1], [5, 2, 1]]) == 56\n assert candidate(n = 8,maxDistance = 25,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 2, 1], [1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 6, 1], [5, 7, 1], [6, 0, 1], [7, 1, 1]]) == 208\n assert candidate(n = 6,maxDistance = 5,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6], [0, 3, 2], [1, 4, 2], [2, 5, 2], [3, 0, 2], [4, 1, 2], [5, 2, 2]]) == 35\n assert candidate(n = 5,maxDistance = 3,roads = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 0, 1], [0, 2, 2], [1, 3, 2], [2, 4, 2], [3, 0, 2], [4, 1, 2]]) == 32\n assert candidate(n = 10,maxDistance = 20,roads = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 6], [2, 5, 4], [2, 6, 1], [3, 7, 2], [4, 8, 5], [5, 9, 3], [6, 9, 6], [7, 8, 1], [8, 9, 2], [0, 3, 2], [1, 5, 1], [2, 4, 5]]) == 474\n assert candidate(n = 5,maxDistance = 5,roads = [[0, 1, 2], [1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 0, 3]]) == 19\n assert candidate(n = 6,maxDistance = 10,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 0, 7], [0, 3, 8], [1, 4, 9], [2, 5, 10]]) == 24\n assert candidate(n = 7,maxDistance = 12,roads = [[0, 1, 4], [0, 2, 3], [1, 2, 1], [1, 3, 2], [2, 4, 5], [3, 4, 2], [3, 5, 6], [4, 6, 3], [5, 6, 1]]) == 65\n assert candidate(n = 9,maxDistance = 25,roads = [[0, 1, 3], [1, 2, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 10], [8, 0, 11], [0, 4, 2], [1, 5, 3], [2, 6, 4], [3, 7, 5], [4, 8, 6], [5, 0, 7], [6, 1, 8], [7, 2, 9], [8, 3, 10]]) == 329\n assert candidate(n = 6,maxDistance = 5,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6]]) == 14\n assert candidate(n = 5,maxDistance = 20,roads = [[0, 1, 5], [0, 2, 5], [1, 3, 5], [2, 4, 5], [3, 4, 5]]) == 22\n assert candidate(n = 5,maxDistance = 4,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 1], [3, 4, 2], [4, 0, 3]]) == 17\n assert candidate(n = 8,maxDistance = 12,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 0, 9]]) == 24\n assert candidate(n = 6,maxDistance = 5,roads = [[0, 1, 2], [1, 2, 2], [2, 3, 3], [3, 4, 3], [4, 5, 4], [5, 0, 4]]) == 15\n assert candidate(n = 7,maxDistance = 8,roads = [[0, 1, 2], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7], [0, 3, 1], [1, 4, 2], [2, 5, 3], [3, 6, 4], [4, 0, 5], [5, 1, 6], [6, 2, 7]]) == 71\n assert candidate(n = 5,maxDistance = 7,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 0, 5], [0, 2, 1], [1, 3, 1], [2, 4, 1], [3, 0, 1], [4, 1, 1]]) == 32\n assert candidate(n = 5,maxDistance = 5,roads = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 0, 2], [0, 2, 2], [1, 3, 2], [2, 4, 2], [3, 0, 2], [4, 1, 2]]) == 32\n assert candidate(n = 8,maxDistance = 20,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 5], [4, 6, 6], [5, 7, 7]]) == 167\n assert candidate(n = 5,maxDistance = 7,roads = [[0, 1, 2], [1, 2, 2], [2, 3, 3], [3, 4, 1], [4, 0, 1]]) == 22\n assert candidate(n = 7,maxDistance = 15,roads = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 0, 10], [4, 5, 5], [5, 6, 5], [6, 4, 5], [4, 6, 3], [5, 4, 4]]) == 16\n assert candidate(n = 5,maxDistance = 8,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 0, 5], [0, 2, 3], [1, 3, 4], [2, 4, 5], [3, 0, 6], [4, 1, 7]]) == 32\n assert candidate(n = 5,maxDistance = 5,roads = [[0, 1, 3], [1, 2, 3], [2, 3, 3], [3, 4, 3], [4, 0, 3], [0, 2, 1], [1, 3, 1], [2, 4, 1], [3, 0, 1], [4, 1, 1]]) == 32\n assert candidate(n = 6,maxDistance = 7,roads = [[0, 1, 2], [0, 2, 3], [1, 3, 2], [1, 4, 5], [2, 5, 1], [3, 4, 2], [4, 5, 3]]) == 29\n assert candidate(n = 7,maxDistance = 8,roads = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 6, 3], [6, 0, 4]]) == 32\n assert candidate(n = 6,maxDistance = 9,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [0, 5, 6]]) == 21\n assert candidate(n = 5,maxDistance = 5,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 0, 5], [0, 2, 6], [1, 3, 7], [2, 4, 8], [3, 0, 9], [4, 1, 10]]) == 13\n assert candidate(n = 8,maxDistance = 15,roads = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 0, 9], [0, 5, 5], [1, 6, 6], [2, 7, 7], [3, 0, 0]]) == 115\n assert candidate(n = 5,maxDistance = 7,roads = [[0, 1, 3], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 0, 5]]) == 18\n assert candidate(n = 6,maxDistance = 10,roads = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 0, 1], [0, 2, 1], [1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 0, 1], [5, 1, 1]]) == 61\n"}, "metadata": {"canonical_parameter_names": ["n", "maxDistance", "roads"], "leetcode_dataset_entry_point": "Solution().numberOfSets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int numberOfSets(int n, int maxDistance, int[][] roads) {", "container": "Solution", "callable": "numberOfSets", "parameters": [{"name": "n", "type": "int"}, {"name": "maxDistance", "type": "int"}, {"name": "roads", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2960, "task_id": "count-tested-devices-after-test-operations", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices.\nYour task is to test each device i in order from 0 to n - 1, by performing the following test operations:\n\nIf batteryPercentages[i] is greater than 0:\n\n\t\nIncrement the count of tested devices.\nDecrease the battery percentage of all devices with indices j in the range [i + 1, n - 1] by 1, ensuring their battery percentage never goes below 0, i.e, batteryPercentages[j] = max(0, batteryPercentages[j] - 1).\nMove to the next device.\n\n\nOtherwise, move to the next device without performing any test.\n\nReturn an integer denoting the number of devices that will be tested after performing the test operations in order.\n \nExample 1:\n\nInput: batteryPercentages = [1,1,2,1,3]\nOutput: 3\nExplanation: Performing the test operations in order starting from device 0:\nAt device 0, batteryPercentages[0] > 0, so there is now 1 tested device, and batteryPercentages becomes [1,0,1,0,2].\nAt device 1, batteryPercentages[1] == 0, so we move to the next device without testing.\nAt device 2, batteryPercentages[2] > 0, so there are now 2 tested devices, and batteryPercentages becomes [1,0,1,0,1].\nAt device 3, batteryPercentages[3] == 0, so we move to the next device without testing.\nAt device 4, batteryPercentages[4] > 0, so there are now 3 tested devices, and batteryPercentages stays the same.\nSo, the answer is 3.\n\nExample 2:\n\nInput: batteryPercentages = [0,1,2]\nOutput: 2\nExplanation: Performing the test operations in order starting from device 0:\nAt device 0, batteryPercentages[0] == 0, so we move to the next device without testing.\nAt device 1, batteryPercentages[1] > 0, so there is now 1 tested device, and batteryPercentages becomes [0,1,1].\nAt device 2, batteryPercentages[2] > 0, so there are now 2 tested devices, and batteryPercentages stays the same.\nSo, the answer is 2.\n\n \nConstraints:\n\n1 <= n == batteryPercentages.length <= 100 \n0 <= batteryPercentages[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(batteryPercentages = [100, 99, 98, 97, 96]) == 5\n assert candidate(batteryPercentages = [50, 49, 48, 47, 46]) == 5\n assert candidate(batteryPercentages = [100, 100, 100]) == 3\n assert candidate(batteryPercentages = [100, 0, 100, 0, 100]) == 3\n assert candidate(batteryPercentages = [3, 2, 1, 0, 4, 3, 2, 1]) == 3\n assert candidate(batteryPercentages = [3, 0, 2, 0, 1]) == 2\n assert candidate(batteryPercentages = [1, 1, 2, 1, 3]) == 3\n assert candidate(batteryPercentages = [0, 1, 0, 1, 0]) == 1\n assert candidate(batteryPercentages = [1]) == 1\n assert candidate(batteryPercentages = [1, 2, 3, 4, 5]) == 5\n assert candidate(batteryPercentages = [0, 0, 0]) == 0\n assert candidate(batteryPercentages = [3, 2, 1, 0, 4, 3, 2, 1, 0]) == 3\n assert candidate(batteryPercentages = [50, 40, 30, 20, 10]) == 5\n assert candidate(batteryPercentages = [50, 0, 50, 0, 50]) == 3\n assert candidate(batteryPercentages = [0, 1, 2]) == 2\n assert candidate(batteryPercentages = [100]) == 1\n assert candidate(batteryPercentages = [0, 0, 0, 0, 0]) == 0\n assert candidate(batteryPercentages = [100, 99, 98, 97]) == 4\n assert candidate(batteryPercentages = [50, 50, 50, 50, 50]) == 5\n assert candidate(batteryPercentages = [1, 0, 1, 0, 1]) == 1\n assert candidate(batteryPercentages = [0, 0, 0, 0]) == 0\n assert candidate(batteryPercentages = [1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(batteryPercentages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(batteryPercentages = [0]) == 0\n assert candidate(batteryPercentages = [10, 20, 30, 40, 50]) == 5\n assert candidate(batteryPercentages = [5, 5, 5, 5, 5]) == 5\n assert candidate(batteryPercentages = [1, 0, 2, 0, 3, 0, 4]) == 4\n assert candidate(batteryPercentages = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == 5\n assert candidate(batteryPercentages = [5, 3, 0, 2, 1, 0, 4, 0, 3]) == 3\n assert candidate(batteryPercentages = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(batteryPercentages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(batteryPercentages = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(batteryPercentages = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(batteryPercentages = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(batteryPercentages = [3, 0, 3, 0, 3, 0, 3, 0, 3, 0]) == 3\n assert candidate(batteryPercentages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(batteryPercentages = [5, 0, 5, 0, 5, 0, 5, 0]) == 4\n assert candidate(batteryPercentages = [0, 1, 0, 2, 0, 3, 0, 4]) == 4\n assert candidate(batteryPercentages = [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(batteryPercentages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(batteryPercentages = [100, 0, 99, 1, 98, 2, 97, 3, 96, 4]) == 5\n assert candidate(batteryPercentages = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 2\n assert candidate(batteryPercentages = [3, 2, 1, 0, 5, 4, 3, 2, 1]) == 4\n assert candidate(batteryPercentages = [0, 10, 0, 20, 0, 30, 0, 40, 0, 50]) == 5\n assert candidate(batteryPercentages = [20, 20, 19, 19, 18, 18, 17, 17, 16, 16]) == 10\n assert candidate(batteryPercentages = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 10\n assert candidate(batteryPercentages = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == 8\n assert candidate(batteryPercentages = [10, 0, 10, 0, 10, 0, 10]) == 4\n assert candidate(batteryPercentages = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 10\n assert candidate(batteryPercentages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0]) == 5\n assert candidate(batteryPercentages = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(batteryPercentages = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5]) == 5\n assert candidate(batteryPercentages = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 20\n assert candidate(batteryPercentages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(batteryPercentages = [3, 0, 5, 2, 8, 0, 6]) == 4\n assert candidate(batteryPercentages = [3, 2, 1, 0, 4, 5]) == 4\n assert candidate(batteryPercentages = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(batteryPercentages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(batteryPercentages = [100, 0, 100, 0, 100, 0, 100]) == 4\n assert candidate(batteryPercentages = [20, 0, 15, 5, 0, 10, 0, 0, 0, 5]) == 5\n assert candidate(batteryPercentages = [50, 25, 0, 75, 100, 0, 0, 25, 50, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 7\n assert candidate(batteryPercentages = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == 10\n assert candidate(batteryPercentages = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(batteryPercentages = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 10\n assert candidate(batteryPercentages = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(batteryPercentages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(batteryPercentages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(batteryPercentages = [3, 2, 2, 1, 1, 0, 0, 1, 1, 0]) == 2\n assert candidate(batteryPercentages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 5\n assert candidate(batteryPercentages = [100, 99, 98, 97, 96, 95, 94]) == 7\n assert candidate(batteryPercentages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(batteryPercentages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(batteryPercentages = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == 5\n assert candidate(batteryPercentages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(batteryPercentages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 5\n assert candidate(batteryPercentages = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(batteryPercentages = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0]) == 3\n assert candidate(batteryPercentages = [0, 100, 0, 100, 0, 100, 0, 100]) == 4\n assert candidate(batteryPercentages = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 7\n assert candidate(batteryPercentages = [50, 25, 0, 75, 50, 25, 0, 75, 50, 25]) == 8\n assert candidate(batteryPercentages = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]) == 10\n assert candidate(batteryPercentages = [50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100]) == 20\n assert candidate(batteryPercentages = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0]) == 5\n assert candidate(batteryPercentages = [90, 0, 90, 0, 90, 0, 90, 0, 90, 0, 90, 0, 90, 0, 90, 0, 90, 0, 90, 0, 90, 0, 90, 0, 90, 0, 90, 0, 90, 0]) == 15\n assert candidate(batteryPercentages = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(batteryPercentages = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6]) == 6\n assert candidate(batteryPercentages = [100, 0, 99, 0, 98, 0, 97, 0, 96, 0]) == 5\n assert candidate(batteryPercentages = [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\n assert candidate(batteryPercentages = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(batteryPercentages = [2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1]) == 2\n assert candidate(batteryPercentages = [100, 99, 98, 97, 96, 95]) == 6\n assert candidate(batteryPercentages = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 100, 100, 100]) == 5\n assert candidate(batteryPercentages = [0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0]) == 6\n assert candidate(batteryPercentages = [3, 2, 1, 0, 4, 5, 0, 6]) == 5\n assert candidate(batteryPercentages = [5, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 0]) == 5\n assert candidate(batteryPercentages = [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]) == 31\n assert candidate(batteryPercentages = [3, 2, 1, 0, 1, 2, 3]) == 3\n assert candidate(batteryPercentages = [100, 100, 0, 0, 50, 50, 0, 0, 25, 25]) == 6\n assert candidate(batteryPercentages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(batteryPercentages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(batteryPercentages = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 5\n assert candidate(batteryPercentages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(batteryPercentages = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 1\n assert candidate(batteryPercentages = [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]) == 29\n assert candidate(batteryPercentages = [1, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1]) == 10\n assert candidate(batteryPercentages = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(batteryPercentages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n"}, "metadata": {"canonical_parameter_names": ["batteryPercentages"], "leetcode_dataset_entry_point": "Solution().countTestedDevices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int countTestedDevices(int[] batteryPercentages) {", "container": "Solution", "callable": "countTestedDevices", "parameters": [{"name": "batteryPercentages", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2962, "task_id": "count-subarrays-where-max-element-appears-at-least-k-times", "difficulty": "Medium", "problem_description": "You are given an integer array nums and a positive integer k.\nReturn the number of subarrays where the maximum element of nums appears at least k times in that subarray.\nA subarray is a contiguous sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,3,2,3,3], k = 2\nOutput: 6\nExplanation: The subarrays that contain the element 3 at least 2 times are: [1,3,2,3], [1,3,2,3,3], [3,2,3], [3,2,3,3], [2,3,3] and [3,3].\n\nExample 2:\n\nInput: nums = [1,4,2,1], k = 3\nOutput: 0\nExplanation: No subarray contains the element 4 at least 3 times.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 106\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 1, 10, 10],k = 4) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 5) == 21\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 0\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 4) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 10\n assert candidate(nums = [1, 3, 2, 3, 3],k = 2) == 6\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 5\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 10) == 1\n assert candidate(nums = [5, 5, 5, 5, 5],k = 3) == 6\n assert candidate(nums = [1, 4, 2, 1],k = 3) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 3) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 55\n assert candidate(nums = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 2) == 29\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 = 5) == 136\n assert candidate(nums = [3, 1, 4, 3, 3, 2, 3, 3, 3],k = 4) == 0\n assert candidate(nums = [1000000, 999999, 1000000, 999999, 1000000, 999999, 1000000, 999999, 1000000, 999999],k = 5) == 2\n assert candidate(nums = [5, 5, 1, 5, 5, 1, 5, 5, 1, 5, 5, 1, 5, 5],k = 3) == 63\n assert candidate(nums = [1000000, 999999, 999999, 1000000, 999999, 1000000, 1000000, 999999, 1000000, 1000000],k = 4) == 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, 5, 5, 5, 5, 5, 5, 5, 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) == 903\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 = 10) == 66\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 15) == 171\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 = 2) == 96\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],k = 20) == 66\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 8) == 6\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) == 66\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1],k = 3) == 0\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 5) == 6\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],k = 2) == 72\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) == 20\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100],k = 5) == 0\n assert candidate(nums = [1000000, 999999, 1000000, 999999, 1000000, 999999, 1000000, 999999, 1000000, 999999],k = 3) == 18\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 = 3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1],k = 3) == 0\n assert candidate(nums = [100, 200, 300, 100, 400, 100, 500, 100, 600, 100, 700, 100, 800, 100, 900, 100, 100, 100, 100],k = 4) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 100],k = 2) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1],k = 3) == 36\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],k = 5) == 48\n assert candidate(nums = [3, 3, 3, 2, 2, 3, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3, 3],k = 5) == 630\n assert candidate(nums = [9, 9, 8, 9, 8, 9, 8, 9, 8, 9, 9, 9, 9, 9],k = 5) == 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],k = 20) == 0\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 = 2) == 10\n assert candidate(nums = [7, 3, 7, 7, 2, 7, 7, 7, 7, 7],k = 6) == 8\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 = 5) == 0\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 = 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],k = 5) == 0\n assert candidate(nums = [7, 5, 7, 8, 7, 9, 7, 7, 6, 7],k = 3) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 5) == 36\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 100\n assert candidate(nums = [7, 7, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1],k = 4) == 102\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) == 66\n assert candidate(nums = [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],k = 5) == 200\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],k = 3) == 5\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 5) == 72\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 2) == 27\n assert candidate(nums = [1, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3],k = 10) == 3826\n assert candidate(nums = [1000000, 999999, 1000000, 999999, 1000000, 999999, 1000000],k = 4) == 1\n assert candidate(nums = [7, 7, 7, 1, 7, 1, 7, 7, 7, 7],k = 3) == 29\n assert candidate(nums = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300],k = 2) == 36\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 = 1) == 120\n assert candidate(nums = [1000000, 1000000, 1000000, 999999, 999999, 1000000, 999999, 1000000, 1000000, 999999],k = 4) == 10\n assert candidate(nums = [5, 6, 7, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6],k = 4) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 21\n assert candidate(nums = [1, 3, 3, 2, 3, 3, 3, 3, 3, 1, 3, 3, 2, 3, 3, 3, 3, 3, 1, 3, 3, 2, 3, 3, 3, 3, 3, 1, 3, 3, 2, 3, 3, 3, 3, 3, 1, 3, 3, 2, 3, 3, 3, 3, 3, 1, 3, 3, 2, 3, 3, 3, 3, 3],k = 6) == 1150\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],k = 2) == 156\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 3) == 5\n assert candidate(nums = [7, 1, 5, 3, 6, 4, 7, 7, 7, 2, 7],k = 3) == 23\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],k = 4) == 105\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 = 2) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1],k = 3) == 138\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) == 231\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],k = 15) == 496\n assert candidate(nums = [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 = 7) == 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],k = 2) == 100\n assert candidate(nums = [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],k = 5) == 0\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],k = 20) == 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],k = 3) == 19\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],k = 4) == 0\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],k = 20) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 28\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, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 0, 3, 0, 5, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 0\n assert candidate(nums = [1, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == 111\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],k = 25) == 231\n assert candidate(nums = [3, 3, 3, 1, 1, 1, 3, 3, 1, 1, 1, 3, 3, 3, 1, 1, 1, 3, 3, 3, 1, 1, 1],k = 4) == 132\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 171\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public long countSubarrays(int[] nums, int k) {", "container": "Solution", "callable": "countSubarrays", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2965, "task_id": "find-missing-and-repeated-values", "difficulty": "Easy", "problem_description": "You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twice and b which is missing. The task is to find the repeating and missing numbers a and b.\nReturn a 0-indexed integer array ans of size 2 where ans[0] equals to a and ans[1] equals to b.\n \nExample 1:\n\nInput: grid = [[1,3],[2,2]]\nOutput: [2,4]\nExplanation: Number 2 is repeated and number 4 is missing so the answer is [2,4].\n\nExample 2:\n\nInput: grid = [[9,1,7],[8,9,2],[3,4,6]]\nOutput: [9,5]\nExplanation: Number 9 is repeated and number 5 is missing so the answer is [9,5].\n\n \nConstraints:\n\n2 <= n == grid.length == grid[i].length <= 50\n1 <= grid[i][j] <= n * n\nFor all x that 1 <= x <= n * n there is exactly one x that is not equal to any of the grid members.\nFor all x that 1 <= x <= n * n there is exactly one x that is equal to exactly two of the grid members.\nFor all x that 1 <= x <= n * n except two of them there is exactly one pair of i, j that 0 <= i, j <= n - 1 and grid[i][j] == x.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1], [2, 3]]) == [1, 4]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 8]]) == [8, 9]\n assert candidate(grid = [[1, 3], [2, 2]]) == [2, 4]\n assert candidate(grid = [[4, 5, 6], [7, 8, 9], [1, 2, 1]]) == [1, 3]\n assert candidate(grid = [[1, 2], [2, 3]]) == [2, 4]\n assert candidate(grid = [[4, 3, 2], [1, 5, 2], [6, 7, 8]]) == [2, 9]\n assert candidate(grid = [[9, 1, 7], [8, 9, 2], [3, 4, 6]]) == [9, 5]\n assert candidate(grid = [[16, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 13]]) == [13, 1]\n assert candidate(grid = [[16, 2, 3, 4], [5, 13, 6, 7], [8, 9, 12, 10], [11, 15, 14, 13]]) == [13, 1]\n assert candidate(grid = [[4, 1, 3], [3, 2, 5], [6, 5, 7]]) == [5, 9]\n assert candidate(grid = [[4, 3, 2], [1, 5, 1], [6, 7, 8]]) == [1, 9]\n assert candidate(grid = [[25, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [25, 21, 22, 23, 24]]) == [25, 1]\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], [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, 99]]) == [99, 100]\n assert candidate(grid = [[36, 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]]) == [36, 100]\n assert candidate(grid = [[36, 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, 31, 32, 33, 34, 35]]) == [0, 0]\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]]) == [0, 0]\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, 42]]) == [42, 49]\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, 1]]) == [1, 25]\n assert candidate(grid = [[25, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 24, 24]]) == [24, 23]\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, 23, 25]]) == [23, 24]\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, 30]]) == [30, 36]\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, 24]]) == [24, 25]\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, 48]]) == [48, 49]\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, 36, 36]]) == [36, 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, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 49, 49]]) == [49, 48]\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, 40]]) == [40, 49]\n assert candidate(grid = [[36, 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]]) == [36, 1]\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, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 63]]) == [63, 64]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 10], [21, 22, 23, 24, 25]]) == [10, 20]\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, 44]]) == [44, 49]\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, 25, 25]]) == [25, 24]\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, 25, 24, 25]]) == [25, 23]\n assert candidate(grid = [[25, 24, 23, 22, 21], [20, 19, 18, 17, 16], [15, 14, 13, 12, 11], [10, 9, 8, 7, 6], [5, 4, 3, 2, 3]]) == [3, 1]\n assert candidate(grid = [[25, 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, 1]\n assert candidate(grid = [[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, 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]]) == [49, 100]\n assert candidate(grid = [[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]]) == [25, 24]\n assert candidate(grid = [[4, 2, 3, 1, 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, 59]]) == [59, 100]\n assert candidate(grid = [[25, 1, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 24]]) == [24, 2]\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, 25, 25]]) == [25, 24]\n assert candidate(grid = [[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, 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]]) == [49, 81]\n assert candidate(grid = [[4, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [4, 1]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [25, 22, 23, 24, 25]]) == [25, 21]\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, 24]]) == [24, 25]\n assert candidate(grid = [[25, 24, 23, 22, 21], [20, 19, 18, 17, 16], [15, 14, 13, 12, 11], [10, 9, 8, 7, 6], [5, 4, 3, 3, 1]]) == [3, 2]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 25], [21, 22, 23, 24, 25]]) == [25, 20]\n assert candidate(grid = [[36, 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, 35]]) == [35, 1]\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, 16]]) == [16, 25]\n assert candidate(grid = [[16, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 24]]) == [24, 25]\n assert candidate(grid = [[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, 2]]) == [2, 1]\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20], [21, 22, 23, 24, 24]]) == [24, 25]\n assert candidate(grid = [[1, 3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25, 22]]) == [22, 2]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 25], [21, 22, 25, 24, 25]]) == [0, 23]\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, 29]]) == [29, 36]\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]]) == [0, 0]\n assert candidate(grid = [[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]]) == [25, 1]\n assert candidate(grid = [[4, 2, 3, 1, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 24]]) == [24, 25]\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, 10]]) == [10, 25]\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, 23]]) == [23, 25]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [22, 23, 24, 25, 22]]) == [22, 21]\n assert candidate(grid = [[25, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [1, 21, 22, 23, 24]]) == [0, 0]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 20, 20], [21, 22, 23, 24, 19]]) == [20, 25]\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, 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, 80]]) == [80, 81]\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, 35]]) == [35, 36]\n assert candidate(grid = [[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, 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, 80, 80]]) == [80, 81]\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]]) == [0, 0]\n assert candidate(grid = [[25, 22, 23, 24, 20], [18, 17, 16, 15, 14], [13, 12, 11, 10, 9], [8, 7, 6, 5, 4], [3, 2, 1, 1, 19]]) == [1, 21]\n assert candidate(grid = [[25, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 24]]) == [24, 1]\n assert candidate(grid = [[25, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [25, 22, 23, 24, 21]]) == [25, 1]\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, 21]]) == [21, 25]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().findMissingAndRepeatedValues", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[] findMissingAndRepeatedValues(int[][] grid) {", "container": "Solution", "callable": "findMissingAndRepeatedValues", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2966, "task_id": "divide-array-into-arrays-with-max-difference", "difficulty": "Medium", "problem_description": "You are given an integer array nums of size n where n is a multiple of 3 and a positive integer k.\nDivide the array nums into n / 3 arrays of size 3 satisfying the following condition:\n\nThe difference between any two elements in one array is less than or equal to k.\n\nReturn a 2D array containing the arrays. If it is impossible to satisfy the conditions, return an empty array. And if there are multiple answers, return any of them.\n \nExample 1:\n\nInput: nums = [1,3,4,8,7,9,3,5,1], k = 2\nOutput: [[1,1,3],[3,4,5],[7,8,9]]\nExplanation:\nThe difference between any two elements in each array is less than or equal to 2.\n\nExample 2:\n\nInput: nums = [2,4,2,2,5,2], k = 2\nOutput: []\nExplanation:\nDifferent ways to divide nums into 2 arrays of size 3 are:\n\n[[2,2,2],[2,4,5]] (and its permutations)\n[[2,2,4],[2,2,5]] (and its permutations)\n\nBecause there are four 2s there will be an array with the elements 2 and 5 no matter how we divide it. since 5 - 2 = 3 > k, the condition is not satisfied and so there is no valid division.\n\nExample 3:\n\nInput: nums = [4,2,9,8,2,12,7,12,10,5,8,5,5,7,9,2,5,11], k = 14\nOutput: [[2,2,12],[4,8,5],[5,9,7],[7,8,5],[5,9,10],[11,12,2]]\nExplanation:\nThe difference between any two elements in each array is less than or equal to 14.\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\nn is a multiple of 3\n1 <= nums[i] <= 105\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 0) == [[5, 5, 5], [5, 5, 5]]\n assert candidate(nums = [2, 4, 2, 2, 5, 2],k = 2) == []\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n assert candidate(nums = [1, 3, 4, 8, 7, 9, 3, 5, 1],k = 2) == [[1, 1, 3], [3, 4, 5], [7, 8, 9]]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == [[5, 5, 5], [5, 5, 5], [5, 5, 5]]\n assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 2) == [[1, 2, 3], [4, 5, 6]]\n assert candidate(nums = [4, 2, 9, 8, 2, 12, 7, 12, 10, 5, 8, 5, 5, 7, 9, 2, 5, 11],k = 14) == [[2, 2, 2], [4, 5, 5], [5, 5, 7], [7, 8, 8], [9, 9, 10], [11, 12, 12]]\n assert candidate(nums = [5, 5, 5, 10, 10, 10, 15, 15, 15, 20, 20, 20, 25, 25, 25, 30, 30, 30],k = 4) == [[5, 5, 5], [10, 10, 10], [15, 15, 15], [20, 20, 20], [25, 25, 25], [30, 30, 30]]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 0) == [[1, 1, 1], [1, 1, 1], [2, 2, 2], [2, 2, 2]]\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 9) == []\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41],k = 2) == [[30, 31, 32], [33, 34, 35], [36, 37, 38], [39, 40, 41]]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 15) == []\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 300, 300, 300],k = 100) == [[100, 100, 100], [200, 200, 200], [300, 300, 300]]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 5) == []\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 20) == [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120]]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == [[3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3]]\n assert candidate(nums = [3, 3, 3, 6, 6, 6, 9, 9, 9, 12, 12, 12],k = 3) == [[3, 3, 3], [6, 6, 6], [9, 9, 9], [12, 12, 12]]\n assert candidate(nums = [1, 3, 6, 10, 15, 18, 20, 25, 30, 33, 36, 40],k = 5) == []\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 2) == []\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 2) == []\n assert candidate(nums = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == [[9, 10, 11], [12, 13, 14], [15, 16, 17], [18, 19, 20]]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],k = 50) == [[1, 10, 20], [30, 40, 50], [60, 70, 80], [90, 100, 110]]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 9) == []\n assert candidate(nums = [15, 15, 15, 25, 25, 25, 35, 35, 35, 45, 45, 45, 55, 55, 55, 65, 65, 65],k = 9) == [[15, 15, 15], [25, 25, 25], [35, 35, 35], [45, 45, 45], [55, 55, 55], [65, 65, 65]]\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, 15, 15],k = 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]]\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 = 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]]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995],k = 2) == [[99995, 99996, 99997], [99998, 99999, 100000]]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 4) == [[1, 3, 5], [7, 9, 11], [13, 15, 17], [19, 21, 23]]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 3) == [[1, 1, 2], [2, 3, 3], [4, 4, 5], [5, 6, 6], [7, 8, 9], [10, 11, 12]]\n assert candidate(nums = [1, 100, 200, 101, 201, 300, 102, 202, 301],k = 100) == [[1, 100, 101], [102, 200, 201], [202, 300, 301]]\n assert candidate(nums = [3, 3, 3, 6, 6, 6, 9, 9, 9, 12, 12, 12, 15, 15, 15],k = 3) == [[3, 3, 3], [6, 6, 6], [9, 9, 9], [12, 12, 12], [15, 15, 15]]\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 7, 9, 11, 8, 10, 12],k = 3) == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 250) == [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200]]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 1) == []\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2],k = 2) == [[-2, -1, 0], [1, 2, 3], [4, 5, 6], [7, 8, 9]]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 1) == [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]\n assert candidate(nums = [1, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010],k = 10) == []\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],k = 99) == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [86, 87, 88], [89, 90, 91], [92, 93, 94], [95, 96, 97], [98, 99, 100]]\n assert candidate(nums = [1, 6, 8, 10, 12, 14, 16, 20, 22, 24, 26, 28],k = 4) == []\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 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, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 90) == [[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]]\n assert candidate(nums = [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, 9, 9, 9, 9, 9],k = 0) == [[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, 9, 9], [9, 9, 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],k = 2) == [[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]]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115],k = 10) == []\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12],k = 1) == [[7, 7, 8], [8, 9, 9], [10, 10, 11], [11, 12, 12]]\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 10, 11, 12, 15, 16, 17],k = 2) == [[1, 2, 3], [6, 7, 8], [10, 11, 12], [15, 16, 17]]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 5) == [[2, 4, 6], [8, 10, 12], [14, 16, 18], [20, 22, 24]]\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 11, 12, 13, 16, 17, 18, 21, 22, 23, 26, 27, 28, 31, 32, 33, 36, 37, 38, 41, 42, 43, 46, 47, 48],k = 2) == [[1, 2, 3], [6, 7, 8], [11, 12, 13], [16, 17, 18], [21, 22, 23], [26, 27, 28], [31, 32, 33], [36, 37, 38], [41, 42, 43], [46, 47, 48]]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],k = 3) == []\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9, 2, 4, 1, 11, 10],k = 3) == [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7],k = 1) == [[1, 2, 2], [3, 3, 4], [4, 5, 5], [6, 6, 7]]\n assert candidate(nums = [100, 200, 300, 101, 201, 301, 102, 202, 302, 103, 203, 303],k = 3) == []\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 10) == []\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 0) == [[8, 8, 8], [8, 8, 8], [8, 8, 8], [8, 8, 8]]\n assert candidate(nums = [100, 101, 102, 200, 201, 202, 300, 301, 302, 400, 401, 402, 500, 501, 502],k = 2) == [[100, 101, 102], [200, 201, 202], [300, 301, 302], [400, 401, 402], [500, 501, 502]]\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9],k = 1) == [[1, 1, 2], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 1) == [[1, 2, 2], [3, 3, 3], [4, 4, 4], [4, 5, 5], [5, 5, 5]]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17],k = 4) == [[1, 3, 5], [7, 9, 11], [13, 15, 17]]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 0, 1000],k = 10000) == []\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 11, 10, 12],k = 2) == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == []\n assert candidate(nums = [1, 6, 7, 8, 10, 11, 15, 16, 17],k = 2) == []\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 1) == []\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 11, 12, 13, 16, 17, 18],k = 2) == [[1, 2, 3], [6, 7, 8], [11, 12, 13], [16, 17, 18]]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54],k = 3) == []\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 2) == [[5, 6, 7], [8, 9, 10], [11, 12, 13], [14, 15, 16]]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108],k = 2) == [[100, 101, 102], [103, 104, 105], [106, 107, 108]]\n assert candidate(nums = [99, 99, 99, 99, 99, 99, 99, 99, 99],k = 0) == [[99, 99, 99], [99, 99, 99], [99, 99, 99]]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],k = 12) == [[3, 6, 9], [12, 15, 18], [21, 24, 27], [30, 33, 36]]\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],k = 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]]\n assert candidate(nums = [3, 3, 3, 6, 6, 6, 9, 9, 9, 12, 12, 12],k = 2) == [[3, 3, 3], [6, 6, 6], [9, 9, 9], [12, 12, 12]]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 2) == []\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9],k = 2) == [[1, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]\n assert candidate(nums = [10, 15, 10, 20, 25, 15, 30, 35, 30],k = 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],k = 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]]\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],k = 10) == [[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]]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170],k = 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, 11, 11, 11],k = 2) == [[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]]\n assert candidate(nums = [5, 10, 5, 15, 10, 20, 25, 30, 35],k = 5) == []\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],k = 1) == [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6]]\n assert candidate(nums = [10, 20, 20, 20, 30, 30, 30, 40, 40, 50, 50, 50],k = 15) == [[10, 20, 20], [20, 30, 30], [30, 40, 40], [50, 50, 50]]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992],k = 3) == [[99992, 99993, 99994], [99995, 99996, 99997], [99998, 99999, 100000]]\n assert candidate(nums = [100, 101, 102, 200, 201, 202, 300, 301, 302, 400, 401, 402],k = 2) == [[100, 101, 102], [200, 201, 202], [300, 301, 302], [400, 401, 402]]\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 = 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]]\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],k = 1) == [[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]]\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41],k = 0) == []\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 0) == [[1, 1, 1], [1, 1, 1], [2, 2, 2], [2, 2, 2], [3, 3, 3], [3, 3, 3]]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27],k = 9) == [[3, 6, 9], [12, 15, 18], [21, 24, 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],k = 4) == [[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(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 9) == []\n assert candidate(nums = [100000, 100000, 100000, 99999, 99999, 99999, 99998, 99998, 99998, 99997, 99997, 99997],k = 1) == [[99997, 99997, 99997], [99998, 99998, 99998], [99999, 99999, 99999], [100000, 100000, 100000]]\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 11, 12, 13, 16, 17, 18, 21, 22, 23],k = 2) == [[1, 2, 3], [6, 7, 8], [11, 12, 13], [16, 17, 18], [21, 22, 23]]\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],k = 1) == [[1, 1, 2], [2, 3, 3], [4, 4, 5], [5, 6, 6], [7, 7, 8], [8, 9, 9], [10, 10, 11], [11, 12, 12]]\n assert candidate(nums = [10, 20, 30, 11, 21, 31, 12, 22, 32, 13, 23, 33],k = 1) == []\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50],k = 10) == [[10, 15, 20], [25, 30, 35], [40, 45, 50]]\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().divideArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "java", "interface": {"raw_signature": "public int[][] divideArray(int[] nums, int k) {", "container": "Solution", "callable": "divideArray", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}